mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-08 20:47:44 +00:00
97 lines
2.3 KiB
C++
97 lines
2.3 KiB
C++
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#ifndef OmxTrackEncoder_h_
|
|
#define OmxTrackEncoder_h_
|
|
|
|
#include "TrackEncoder.h"
|
|
|
|
namespace android {
|
|
class OMXVideoEncoder;
|
|
class OMXAudioEncoder;
|
|
}
|
|
|
|
/**
|
|
* There are two major classes defined in file OmxTrackEncoder;
|
|
* OmxVideoTrackEncoder and OmxAudioTrackEncoder, the video and audio track
|
|
* encoder for media type AVC/H.264 and AAC. OMXCodecWrapper wraps and controls
|
|
* an instance of MediaCodec, defined in libstagefright, runs on Android Jelly
|
|
* Bean platform.
|
|
*/
|
|
|
|
namespace mozilla {
|
|
|
|
class OmxVideoTrackEncoder: public VideoTrackEncoder
|
|
{
|
|
public:
|
|
OmxVideoTrackEncoder()
|
|
: VideoTrackEncoder()
|
|
{}
|
|
|
|
already_AddRefed<TrackMetadataBase> GetMetadata() MOZ_OVERRIDE;
|
|
|
|
nsresult GetEncodedTrack(EncodedFrameContainer& aData) MOZ_OVERRIDE;
|
|
|
|
protected:
|
|
nsresult Init(int aWidth, int aHeight,
|
|
int aDisplayWidth, int aDisplayHeight,
|
|
TrackRate aTrackRate) MOZ_OVERRIDE;
|
|
|
|
private:
|
|
nsAutoPtr<android::OMXVideoEncoder> mEncoder;
|
|
};
|
|
|
|
class OmxAudioTrackEncoder : public AudioTrackEncoder
|
|
{
|
|
public:
|
|
OmxAudioTrackEncoder()
|
|
: AudioTrackEncoder()
|
|
{}
|
|
|
|
already_AddRefed<TrackMetadataBase> GetMetadata() = 0;
|
|
|
|
nsresult GetEncodedTrack(EncodedFrameContainer& aData) MOZ_OVERRIDE;
|
|
|
|
protected:
|
|
nsresult Init(int aChannels, int aSamplingRate) = 0;
|
|
|
|
// Append encoded frames to aContainer.
|
|
nsresult AppendEncodedFrames(EncodedFrameContainer& aContainer);
|
|
|
|
nsAutoPtr<android::OMXAudioEncoder> mEncoder;
|
|
};
|
|
|
|
class OmxAACAudioTrackEncoder MOZ_FINAL : public OmxAudioTrackEncoder
|
|
{
|
|
public:
|
|
OmxAACAudioTrackEncoder()
|
|
: OmxAudioTrackEncoder()
|
|
{}
|
|
|
|
already_AddRefed<TrackMetadataBase> GetMetadata() MOZ_OVERRIDE;
|
|
|
|
protected:
|
|
nsresult Init(int aChannels, int aSamplingRate) MOZ_OVERRIDE;
|
|
};
|
|
|
|
class OmxAMRAudioTrackEncoder MOZ_FINAL : public OmxAudioTrackEncoder
|
|
{
|
|
public:
|
|
OmxAMRAudioTrackEncoder()
|
|
: OmxAudioTrackEncoder()
|
|
{}
|
|
|
|
enum {
|
|
AMR_NB_SAMPLERATE = 8000,
|
|
};
|
|
already_AddRefed<TrackMetadataBase> GetMetadata() MOZ_OVERRIDE;
|
|
|
|
protected:
|
|
nsresult Init(int aChannels, int aSamplingRate) MOZ_OVERRIDE;
|
|
};
|
|
|
|
}
|
|
#endif
|