2014-01-17 23:30:02 +04:00
|
|
|
/* -*- 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;
|
2014-01-17 23:30:13 +04:00
|
|
|
class OMXAudioEncoder;
|
2014-01-17 23:30:02 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* There are two major classes defined in file OmxTrackEncoder;
|
|
|
|
* OmxVideoTrackEncoder and OmxAudioTrackEncoder, the video and audio track
|
2014-01-17 23:30:13 +04:00
|
|
|
* encoder for media type AVC/H.264 and AAC. OMXCodecWrapper wraps and controls
|
2014-01-17 23:30:02 +04:00
|
|
|
* an instance of MediaCodec, defined in libstagefright, runs on Android Jelly
|
|
|
|
* Bean platform.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
class OmxVideoTrackEncoder: public VideoTrackEncoder
|
|
|
|
{
|
|
|
|
public:
|
2015-01-03 01:27:02 +03:00
|
|
|
OmxVideoTrackEncoder();
|
|
|
|
~OmxVideoTrackEncoder();
|
2014-01-17 23:30:02 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
already_AddRefed<TrackMetadataBase> GetMetadata() override;
|
2014-01-17 23:30:02 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
nsresult GetEncodedTrack(EncodedFrameContainer& aData) override;
|
2014-01-17 23:30:02 +04:00
|
|
|
|
|
|
|
protected:
|
2014-02-21 10:27:41 +04:00
|
|
|
nsresult Init(int aWidth, int aHeight,
|
|
|
|
int aDisplayWidth, int aDisplayHeight,
|
2015-03-21 19:28:04 +03:00
|
|
|
TrackRate aTrackRate) override;
|
2014-01-17 23:30:02 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
nsAutoPtr<android::OMXVideoEncoder> mEncoder;
|
|
|
|
};
|
|
|
|
|
2014-03-19 10:52:45 +04:00
|
|
|
class OmxAudioTrackEncoder : public AudioTrackEncoder
|
2014-01-17 23:30:13 +04:00
|
|
|
{
|
|
|
|
public:
|
2015-01-03 01:27:02 +03:00
|
|
|
OmxAudioTrackEncoder();
|
|
|
|
~OmxAudioTrackEncoder();
|
2014-01-17 23:30:13 +04:00
|
|
|
|
2014-03-19 10:52:45 +04:00
|
|
|
already_AddRefed<TrackMetadataBase> GetMetadata() = 0;
|
2014-01-17 23:30:13 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
nsresult GetEncodedTrack(EncodedFrameContainer& aData) override;
|
2014-01-17 23:30:13 +04:00
|
|
|
|
|
|
|
protected:
|
2014-03-19 10:52:45 +04:00
|
|
|
nsresult Init(int aChannels, int aSamplingRate) = 0;
|
2014-01-17 23:30:13 +04:00
|
|
|
|
|
|
|
// Append encoded frames to aContainer.
|
|
|
|
nsresult AppendEncodedFrames(EncodedFrameContainer& aContainer);
|
|
|
|
|
|
|
|
nsAutoPtr<android::OMXAudioEncoder> mEncoder;
|
|
|
|
};
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class OmxAACAudioTrackEncoder final : public OmxAudioTrackEncoder
|
2014-03-19 10:52:45 +04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
OmxAACAudioTrackEncoder()
|
|
|
|
: OmxAudioTrackEncoder()
|
|
|
|
{}
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
already_AddRefed<TrackMetadataBase> GetMetadata() override;
|
2014-03-19 10:52:45 +04:00
|
|
|
|
|
|
|
protected:
|
2015-03-21 19:28:04 +03:00
|
|
|
nsresult Init(int aChannels, int aSamplingRate) override;
|
2014-03-19 10:52:45 +04:00
|
|
|
};
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class OmxAMRAudioTrackEncoder final : public OmxAudioTrackEncoder
|
2014-03-19 10:52:45 +04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
OmxAMRAudioTrackEncoder()
|
|
|
|
: OmxAudioTrackEncoder()
|
|
|
|
{}
|
|
|
|
|
|
|
|
enum {
|
|
|
|
AMR_NB_SAMPLERATE = 8000,
|
|
|
|
};
|
2015-03-21 19:28:04 +03:00
|
|
|
already_AddRefed<TrackMetadataBase> GetMetadata() override;
|
2014-03-19 10:52:45 +04:00
|
|
|
|
|
|
|
protected:
|
2015-03-21 19:28:04 +03:00
|
|
|
nsresult Init(int aChannels, int aSamplingRate) override;
|
2014-03-19 10:52:45 +04:00
|
|
|
};
|
|
|
|
|
2015-10-27 10:12:26 +03:00
|
|
|
class OmxEVRCAudioTrackEncoder final : public OmxAudioTrackEncoder
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
OmxEVRCAudioTrackEncoder()
|
|
|
|
: OmxAudioTrackEncoder()
|
|
|
|
{}
|
|
|
|
|
|
|
|
enum {
|
|
|
|
EVRC_SAMPLERATE = 8000,
|
|
|
|
};
|
|
|
|
already_AddRefed<TrackMetadataBase> GetMetadata() override;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
nsresult Init(int aChannels, int aSamplingRate) override;
|
|
|
|
};
|
|
|
|
|
2014-01-17 23:30:02 +04:00
|
|
|
}
|
|
|
|
#endif
|