2013-06-05 10:29:12 +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/. */
|
|
|
|
#include "MediaEncoder.h"
|
|
|
|
#include "MediaDecoder.h"
|
2013-09-06 00:25:17 +04:00
|
|
|
#include "nsIPrincipal.h"
|
2013-12-10 11:24:51 +04:00
|
|
|
#include "nsMimeTypes.h"
|
2015-05-19 21:15:34 +03:00
|
|
|
#include "mozilla/Logging.h"
|
2014-01-14 11:26:04 +04:00
|
|
|
#include "mozilla/Preferences.h"
|
2014-07-01 09:25:29 +04:00
|
|
|
#include "mozilla/StaticPtr.h"
|
2013-10-25 06:59:52 +04:00
|
|
|
|
2014-10-20 12:17:26 +04:00
|
|
|
#include"GeckoProfiler.h"
|
2013-06-05 10:29:12 +04:00
|
|
|
#include "OggWriter.h"
|
|
|
|
#include "OpusTrackEncoder.h"
|
2014-01-15 10:21:14 +04:00
|
|
|
|
|
|
|
#ifdef MOZ_VORBIS
|
|
|
|
#include "VorbisTrackEncoder.h"
|
2013-06-05 10:29:12 +04:00
|
|
|
#endif
|
2013-12-10 11:24:51 +04:00
|
|
|
#ifdef MOZ_WEBM_ENCODER
|
|
|
|
#include "VorbisTrackEncoder.h"
|
|
|
|
#include "VP8TrackEncoder.h"
|
|
|
|
#include "WebMWriter.h"
|
|
|
|
#endif
|
|
|
|
#ifdef MOZ_OMX_ENCODER
|
|
|
|
#include "OmxTrackEncoder.h"
|
|
|
|
#include "ISOMediaWriter.h"
|
|
|
|
#endif
|
2013-06-05 10:29:12 +04:00
|
|
|
|
2013-12-10 11:24:51 +04:00
|
|
|
#ifdef LOG
|
|
|
|
#undef LOG
|
|
|
|
#endif
|
|
|
|
|
|
|
|
PRLogModuleInfo* gMediaEncoderLog;
|
|
|
|
#define LOG(type, msg) PR_LOG(gMediaEncoderLog, type, msg)
|
2013-06-05 10:29:12 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
void
|
|
|
|
MediaEncoder::NotifyQueuedTrackChanges(MediaStreamGraph* aGraph,
|
|
|
|
TrackID aID,
|
2014-09-18 09:20:43 +04:00
|
|
|
StreamTime aTrackOffset,
|
2013-06-05 10:29:12 +04:00
|
|
|
uint32_t aTrackEvents,
|
|
|
|
const MediaSegment& aQueuedMedia)
|
|
|
|
{
|
|
|
|
// Process the incoming raw track data from MediaStreamGraph, called on the
|
|
|
|
// thread of MediaStreamGraph.
|
2013-12-10 11:24:51 +04:00
|
|
|
if (mAudioEncoder && aQueuedMedia.GetType() == MediaSegment::AUDIO) {
|
2014-09-18 03:51:13 +04:00
|
|
|
mAudioEncoder->NotifyQueuedTrackChanges(aGraph, aID,
|
2013-06-05 10:29:12 +04:00
|
|
|
aTrackOffset, aTrackEvents,
|
|
|
|
aQueuedMedia);
|
|
|
|
|
2013-12-10 11:24:51 +04:00
|
|
|
} else if (mVideoEncoder && aQueuedMedia.GetType() == MediaSegment::VIDEO) {
|
2014-09-18 03:51:13 +04:00
|
|
|
mVideoEncoder->NotifyQueuedTrackChanges(aGraph, aID,
|
2013-12-10 11:24:51 +04:00
|
|
|
aTrackOffset, aTrackEvents,
|
|
|
|
aQueuedMedia);
|
2013-06-05 10:29:12 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-07-14 09:47:56 +04:00
|
|
|
MediaEncoder::NotifyEvent(MediaStreamGraph* aGraph,
|
|
|
|
MediaStreamListener::MediaStreamGraphEvent event)
|
2013-06-05 10:29:12 +04:00
|
|
|
{
|
|
|
|
// In case that MediaEncoder does not receive a TRACK_EVENT_ENDED event.
|
2013-12-10 11:24:51 +04:00
|
|
|
LOG(PR_LOG_DEBUG, ("NotifyRemoved in [MediaEncoder]."));
|
|
|
|
if (mAudioEncoder) {
|
2014-07-14 09:47:56 +04:00
|
|
|
mAudioEncoder->NotifyEvent(aGraph, event);
|
2013-12-10 11:24:51 +04:00
|
|
|
}
|
|
|
|
if (mVideoEncoder) {
|
2014-07-14 09:47:56 +04:00
|
|
|
mVideoEncoder->NotifyEvent(aGraph, event);
|
2013-12-10 11:24:51 +04:00
|
|
|
}
|
2013-06-05 10:29:12 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* static */
|
|
|
|
already_AddRefed<MediaEncoder>
|
2013-12-10 11:24:51 +04:00
|
|
|
MediaEncoder::CreateEncoder(const nsAString& aMIMEType, uint8_t aTrackTypes)
|
2013-06-05 10:29:12 +04:00
|
|
|
{
|
2013-12-10 11:24:51 +04:00
|
|
|
if (!gMediaEncoderLog) {
|
|
|
|
gMediaEncoderLog = PR_NewLogModule("MediaEncoder");
|
|
|
|
}
|
2014-10-20 12:17:26 +04:00
|
|
|
PROFILER_LABEL("MediaEncoder", "CreateEncoder",
|
|
|
|
js::ProfileEntry::Category::OTHER);
|
|
|
|
|
2013-06-05 10:29:12 +04:00
|
|
|
nsAutoPtr<ContainerWriter> writer;
|
|
|
|
nsAutoPtr<AudioTrackEncoder> audioEncoder;
|
|
|
|
nsAutoPtr<VideoTrackEncoder> videoEncoder;
|
|
|
|
nsRefPtr<MediaEncoder> encoder;
|
2013-12-10 11:24:51 +04:00
|
|
|
nsString mimeType;
|
|
|
|
if (!aTrackTypes) {
|
|
|
|
LOG(PR_LOG_ERROR, ("NO TrackTypes!!!"));
|
|
|
|
return nullptr;
|
2013-06-05 10:29:12 +04:00
|
|
|
}
|
2013-12-10 11:24:51 +04:00
|
|
|
#ifdef MOZ_WEBM_ENCODER
|
2014-01-14 11:26:04 +04:00
|
|
|
else if (MediaEncoder::IsWebMEncoderEnabled() &&
|
2013-12-10 11:24:51 +04:00
|
|
|
(aMIMEType.EqualsLiteral(VIDEO_WEBM) ||
|
2014-01-30 20:06:11 +04:00
|
|
|
(aTrackTypes & ContainerWriter::CREATE_VIDEO_TRACK))) {
|
|
|
|
if (aTrackTypes & ContainerWriter::CREATE_AUDIO_TRACK) {
|
2013-12-10 11:24:51 +04:00
|
|
|
audioEncoder = new VorbisTrackEncoder();
|
|
|
|
NS_ENSURE_TRUE(audioEncoder, nullptr);
|
|
|
|
}
|
|
|
|
videoEncoder = new VP8TrackEncoder();
|
|
|
|
writer = new WebMWriter(aTrackTypes);
|
|
|
|
NS_ENSURE_TRUE(writer, nullptr);
|
|
|
|
NS_ENSURE_TRUE(videoEncoder, nullptr);
|
|
|
|
mimeType = NS_LITERAL_STRING(VIDEO_WEBM);
|
|
|
|
}
|
|
|
|
#endif //MOZ_WEBM_ENCODER
|
|
|
|
#ifdef MOZ_OMX_ENCODER
|
2014-01-14 11:26:04 +04:00
|
|
|
else if (MediaEncoder::IsOMXEncoderEnabled() &&
|
|
|
|
(aMIMEType.EqualsLiteral(VIDEO_MP4) ||
|
2014-01-30 20:06:11 +04:00
|
|
|
(aTrackTypes & ContainerWriter::CREATE_VIDEO_TRACK))) {
|
|
|
|
if (aTrackTypes & ContainerWriter::CREATE_AUDIO_TRACK) {
|
2014-03-19 10:52:45 +04:00
|
|
|
audioEncoder = new OmxAACAudioTrackEncoder();
|
2013-12-10 11:24:51 +04:00
|
|
|
NS_ENSURE_TRUE(audioEncoder, nullptr);
|
|
|
|
}
|
|
|
|
videoEncoder = new OmxVideoTrackEncoder();
|
|
|
|
writer = new ISOMediaWriter(aTrackTypes);
|
|
|
|
NS_ENSURE_TRUE(writer, nullptr);
|
|
|
|
NS_ENSURE_TRUE(videoEncoder, nullptr);
|
|
|
|
mimeType = NS_LITERAL_STRING(VIDEO_MP4);
|
2014-03-19 10:52:45 +04:00
|
|
|
} else if (MediaEncoder::IsOMXEncoderEnabled() &&
|
|
|
|
(aMIMEType.EqualsLiteral(AUDIO_3GPP))) {
|
|
|
|
audioEncoder = new OmxAMRAudioTrackEncoder();
|
|
|
|
NS_ENSURE_TRUE(audioEncoder, nullptr);
|
|
|
|
|
|
|
|
writer = new ISOMediaWriter(aTrackTypes, ISOMediaWriter::TYPE_FRAG_3GP);
|
|
|
|
NS_ENSURE_TRUE(writer, nullptr);
|
|
|
|
mimeType = NS_LITERAL_STRING(AUDIO_3GPP);
|
2013-12-10 11:24:51 +04:00
|
|
|
}
|
|
|
|
#endif // MOZ_OMX_ENCODER
|
|
|
|
else if (MediaDecoder::IsOggEnabled() && MediaDecoder::IsOpusEnabled() &&
|
|
|
|
(aMIMEType.EqualsLiteral(AUDIO_OGG) ||
|
2014-01-30 20:06:11 +04:00
|
|
|
(aTrackTypes & ContainerWriter::CREATE_AUDIO_TRACK))) {
|
2013-06-05 10:29:12 +04:00
|
|
|
writer = new OggWriter();
|
|
|
|
audioEncoder = new OpusTrackEncoder();
|
2013-12-10 11:24:51 +04:00
|
|
|
NS_ENSURE_TRUE(writer, nullptr);
|
|
|
|
NS_ENSURE_TRUE(audioEncoder, nullptr);
|
|
|
|
mimeType = NS_LITERAL_STRING(AUDIO_OGG);
|
2013-06-05 10:29:12 +04:00
|
|
|
}
|
2013-12-10 11:24:51 +04:00
|
|
|
else {
|
|
|
|
LOG(PR_LOG_ERROR, ("Can not find any encoder to record this media stream"));
|
|
|
|
return nullptr;
|
2013-06-05 10:29:12 +04:00
|
|
|
}
|
2013-12-10 11:24:51 +04:00
|
|
|
LOG(PR_LOG_DEBUG, ("Create encoder result:a[%d] v[%d] w[%d] mimeType = %s.",
|
|
|
|
audioEncoder != nullptr, videoEncoder != nullptr,
|
|
|
|
writer != nullptr, mimeType.get()));
|
2013-06-05 10:29:12 +04:00
|
|
|
encoder = new MediaEncoder(writer.forget(), audioEncoder.forget(),
|
2013-12-10 11:24:51 +04:00
|
|
|
videoEncoder.forget(), mimeType);
|
2013-06-05 10:29:12 +04:00
|
|
|
return encoder.forget();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GetEncodedData() runs as a state machine, starting with mState set to
|
2013-10-25 06:59:52 +04:00
|
|
|
* GET_METADDATA, the procedure should be as follow:
|
2013-06-05 10:29:12 +04:00
|
|
|
*
|
|
|
|
* While non-stop
|
2013-10-25 06:59:52 +04:00
|
|
|
* If mState is GET_METADDATA
|
|
|
|
* Get the meta data from audio/video encoder
|
|
|
|
* If a meta data is generated
|
|
|
|
* Get meta data from audio/video encoder
|
2013-06-05 10:29:12 +04:00
|
|
|
* Set mState to ENCODE_TRACK
|
2013-10-25 06:59:52 +04:00
|
|
|
* Return the final container data
|
2013-06-05 10:29:12 +04:00
|
|
|
*
|
|
|
|
* If mState is ENCODE_TRACK
|
|
|
|
* Get encoded track data from audio/video encoder
|
|
|
|
* If a packet of track data is generated
|
|
|
|
* Insert encoded track data into the container stream of writer
|
|
|
|
* If the final container data is copied to aOutput
|
|
|
|
* Return the copy of final container data
|
|
|
|
* If this is the last packet of input stream
|
|
|
|
* Set mState to ENCODE_DONE
|
|
|
|
*
|
2013-11-25 03:57:52 +04:00
|
|
|
* If mState is ENCODE_DONE or ENCODE_ERROR
|
2013-06-05 10:29:12 +04:00
|
|
|
* Stop the loop
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
MediaEncoder::GetEncodedData(nsTArray<nsTArray<uint8_t> >* aOutputBufs,
|
|
|
|
nsAString& aMIMEType)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(!NS_IsMainThread());
|
2013-12-19 14:13:05 +04:00
|
|
|
|
2013-06-05 10:29:12 +04:00
|
|
|
aMIMEType = mMIMEType;
|
2014-10-20 12:17:26 +04:00
|
|
|
PROFILER_LABEL("MediaEncoder", "GetEncodedData",
|
|
|
|
js::ProfileEntry::Category::OTHER);
|
2013-06-05 10:29:12 +04:00
|
|
|
|
|
|
|
bool reloop = true;
|
|
|
|
while (reloop) {
|
|
|
|
switch (mState) {
|
2013-10-25 06:59:52 +04:00
|
|
|
case ENCODE_METADDATA: {
|
2013-12-10 11:24:51 +04:00
|
|
|
LOG(PR_LOG_DEBUG, ("ENCODE_METADDATA TimeStamp = %f", GetEncodeTimeStamp()));
|
|
|
|
nsresult rv = CopyMetadataToMuxer(mAudioEncoder.get());
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
LOG(PR_LOG_ERROR, ("Error! Fail to Set Audio Metadata"));
|
2013-11-25 03:57:52 +04:00
|
|
|
break;
|
|
|
|
}
|
2013-12-10 11:24:51 +04:00
|
|
|
rv = CopyMetadataToMuxer(mVideoEncoder.get());
|
2013-06-05 10:29:12 +04:00
|
|
|
if (NS_FAILED(rv)) {
|
2013-12-10 11:24:51 +04:00
|
|
|
LOG(PR_LOG_ERROR, ("Error! Fail to Set Video Metadata"));
|
|
|
|
break;
|
2013-06-05 10:29:12 +04:00
|
|
|
}
|
|
|
|
|
2013-10-25 06:59:52 +04:00
|
|
|
rv = mWriter->GetContainerData(aOutputBufs,
|
|
|
|
ContainerWriter::GET_HEADER);
|
2014-07-01 09:25:29 +04:00
|
|
|
if (aOutputBufs != nullptr) {
|
|
|
|
mSizeOfBuffer = aOutputBufs->SizeOfExcludingThis(MallocSizeOf);
|
|
|
|
}
|
2013-10-25 06:59:52 +04:00
|
|
|
if (NS_FAILED(rv)) {
|
2013-12-10 11:24:51 +04:00
|
|
|
LOG(PR_LOG_ERROR,("Error! writer fail to generate header!"));
|
2013-11-25 03:57:52 +04:00
|
|
|
mState = ENCODE_ERROR;
|
2013-10-25 06:59:52 +04:00
|
|
|
break;
|
2013-06-05 10:29:12 +04:00
|
|
|
}
|
2013-12-10 11:24:51 +04:00
|
|
|
LOG(PR_LOG_DEBUG, ("Finish ENCODE_METADDATA TimeStamp = %f", GetEncodeTimeStamp()));
|
2013-10-25 06:59:52 +04:00
|
|
|
mState = ENCODE_TRACK;
|
2013-06-05 10:29:12 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case ENCODE_TRACK: {
|
2013-12-10 11:24:51 +04:00
|
|
|
LOG(PR_LOG_DEBUG, ("ENCODE_TRACK TimeStamp = %f", GetEncodeTimeStamp()));
|
2013-10-25 06:59:52 +04:00
|
|
|
EncodedFrameContainer encodedData;
|
2013-12-10 11:24:51 +04:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
rv = WriteEncodedDataToMuxer(mAudioEncoder.get());
|
2013-06-05 10:29:12 +04:00
|
|
|
if (NS_FAILED(rv)) {
|
2013-12-10 11:24:51 +04:00
|
|
|
LOG(PR_LOG_ERROR, ("Error! Fail to write audio encoder data to muxer"));
|
2013-06-05 10:29:12 +04:00
|
|
|
break;
|
|
|
|
}
|
2013-12-10 11:24:51 +04:00
|
|
|
LOG(PR_LOG_DEBUG, ("Audio encoded TimeStamp = %f", GetEncodeTimeStamp()));
|
|
|
|
rv = WriteEncodedDataToMuxer(mVideoEncoder.get());
|
2013-06-05 10:29:12 +04:00
|
|
|
if (NS_FAILED(rv)) {
|
2013-12-10 11:24:51 +04:00
|
|
|
LOG(PR_LOG_ERROR, ("Fail to write video encoder data to muxer"));
|
2013-06-05 10:29:12 +04:00
|
|
|
break;
|
|
|
|
}
|
2013-12-10 11:24:51 +04:00
|
|
|
LOG(PR_LOG_DEBUG, ("Video encoded TimeStamp = %f", GetEncodeTimeStamp()));
|
|
|
|
// In audio only or video only case, let unavailable track's flag to be true.
|
|
|
|
bool isAudioCompleted = (mAudioEncoder && mAudioEncoder->IsEncodingComplete()) || !mAudioEncoder;
|
|
|
|
bool isVideoCompleted = (mVideoEncoder && mVideoEncoder->IsEncodingComplete()) || !mVideoEncoder;
|
2013-06-05 10:29:12 +04:00
|
|
|
rv = mWriter->GetContainerData(aOutputBufs,
|
2013-12-10 11:24:51 +04:00
|
|
|
isAudioCompleted && isVideoCompleted ?
|
2013-06-05 10:29:12 +04:00
|
|
|
ContainerWriter::FLUSH_NEEDED : 0);
|
2014-07-01 09:25:29 +04:00
|
|
|
if (aOutputBufs != nullptr) {
|
|
|
|
mSizeOfBuffer = aOutputBufs->SizeOfExcludingThis(MallocSizeOf);
|
|
|
|
}
|
2013-06-05 10:29:12 +04:00
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
// Successfully get the copy of final container data from writer.
|
|
|
|
reloop = false;
|
|
|
|
}
|
2013-12-10 11:24:51 +04:00
|
|
|
mState = (mWriter->IsWritingComplete()) ? ENCODE_DONE : ENCODE_TRACK;
|
|
|
|
LOG(PR_LOG_DEBUG, ("END ENCODE_TRACK TimeStamp = %f "
|
|
|
|
"mState = %d aComplete %d vComplete %d",
|
|
|
|
GetEncodeTimeStamp(), mState, isAudioCompleted, isVideoCompleted));
|
2013-06-05 10:29:12 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case ENCODE_DONE:
|
2013-11-25 03:57:52 +04:00
|
|
|
case ENCODE_ERROR:
|
2013-12-10 11:24:51 +04:00
|
|
|
LOG(PR_LOG_DEBUG, ("MediaEncoder has been shutdown."));
|
2014-07-01 09:25:29 +04:00
|
|
|
mSizeOfBuffer = 0;
|
2013-11-25 03:57:52 +04:00
|
|
|
mShutdown = true;
|
|
|
|
reloop = false;
|
|
|
|
break;
|
2013-06-05 10:29:12 +04:00
|
|
|
default:
|
2013-06-29 05:38:30 +04:00
|
|
|
MOZ_CRASH("Invalid encode state");
|
2013-06-05 10:29:12 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-10 11:24:51 +04:00
|
|
|
nsresult
|
|
|
|
MediaEncoder::WriteEncodedDataToMuxer(TrackEncoder *aTrackEncoder)
|
|
|
|
{
|
|
|
|
if (aTrackEncoder == nullptr) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
if (aTrackEncoder->IsEncodingComplete()) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2014-10-20 12:17:26 +04:00
|
|
|
|
|
|
|
PROFILER_LABEL("MediaEncoder", "WriteEncodedDataToMuxer",
|
|
|
|
js::ProfileEntry::Category::OTHER);
|
|
|
|
|
2013-12-10 11:24:51 +04:00
|
|
|
EncodedFrameContainer encodedVideoData;
|
|
|
|
nsresult rv = aTrackEncoder->GetEncodedTrack(encodedVideoData);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
// Encoding might be canceled.
|
|
|
|
LOG(PR_LOG_ERROR, ("Error! Fail to get encoded data from video encoder."));
|
|
|
|
mState = ENCODE_ERROR;
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
rv = mWriter->WriteEncodedTrack(encodedVideoData,
|
|
|
|
aTrackEncoder->IsEncodingComplete() ?
|
|
|
|
ContainerWriter::END_OF_STREAM : 0);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
LOG(PR_LOG_ERROR, ("Error! Fail to write encoded video track to the media container."));
|
|
|
|
mState = ENCODE_ERROR;
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
MediaEncoder::CopyMetadataToMuxer(TrackEncoder *aTrackEncoder)
|
|
|
|
{
|
|
|
|
if (aTrackEncoder == nullptr) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2014-10-20 12:17:26 +04:00
|
|
|
|
|
|
|
PROFILER_LABEL("MediaEncoder", "CopyMetadataToMuxer",
|
|
|
|
js::ProfileEntry::Category::OTHER);
|
|
|
|
|
2013-12-10 11:24:51 +04:00
|
|
|
nsRefPtr<TrackMetadataBase> meta = aTrackEncoder->GetMetadata();
|
|
|
|
if (meta == nullptr) {
|
|
|
|
LOG(PR_LOG_ERROR, ("Error! metadata = null"));
|
|
|
|
mState = ENCODE_ERROR;
|
|
|
|
return NS_ERROR_ABORT;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult rv = mWriter->SetMetadata(meta);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
LOG(PR_LOG_ERROR, ("Error! SetMetadata fail"));
|
|
|
|
mState = ENCODE_ERROR;
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2014-01-14 11:26:04 +04:00
|
|
|
#ifdef MOZ_WEBM_ENCODER
|
|
|
|
bool
|
|
|
|
MediaEncoder::IsWebMEncoderEnabled()
|
|
|
|
{
|
|
|
|
return Preferences::GetBool("media.encoder.webm.enabled");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef MOZ_OMX_ENCODER
|
|
|
|
bool
|
|
|
|
MediaEncoder::IsOMXEncoderEnabled()
|
|
|
|
{
|
|
|
|
return Preferences::GetBool("media.encoder.omx.enabled");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-07-01 09:25:29 +04:00
|
|
|
/*
|
|
|
|
* SizeOfExcludingThis measures memory being used by the Media Encoder.
|
|
|
|
* Currently it measures the size of the Encoder buffer and memory occupied
|
|
|
|
* by mAudioEncoder and mVideoEncoder.
|
|
|
|
*/
|
|
|
|
size_t
|
|
|
|
MediaEncoder::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
|
|
|
|
{
|
|
|
|
size_t amount = 0;
|
|
|
|
if (mState == ENCODE_TRACK) {
|
|
|
|
amount = mSizeOfBuffer +
|
|
|
|
(mAudioEncoder != nullptr ? mAudioEncoder->SizeOfExcludingThis(aMallocSizeOf) : 0) +
|
|
|
|
(mVideoEncoder != nullptr ? mVideoEncoder->SizeOfExcludingThis(aMallocSizeOf) : 0);
|
|
|
|
}
|
|
|
|
return amount;
|
|
|
|
}
|
|
|
|
|
2013-06-05 10:29:12 +04:00
|
|
|
}
|