Loading cmds/stagefright/muxer.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -69,7 +69,8 @@ static int muxing( ALOGV("input file %s, output file %s", path, outputFileName); ALOGV("useAudio %d, useVideo %d", useAudio, useVideo); sp<MediaMuxer> muxer = new MediaMuxer(outputFileName); sp<MediaMuxer> muxer = new MediaMuxer(outputFileName, MediaMuxer::OUTPUT_FORMAT_MPEG_4); size_t trackCount = extractor->countTracks(); // Map the extractor's track index to the muxer's track index. Loading include/media/stagefright/MediaMuxer.h +17 −2 Original line number Diff line number Diff line Loading @@ -40,11 +40,25 @@ struct MPEG4Writer; // deleting the output file after stop. struct MediaMuxer : public RefBase { public: // Please update media/java/android/media/MediaMuxer.java if the // SampleFlags is updated. enum SampleFlags { SAMPLE_FLAG_SYNC = 1, }; // Please update media/java/android/media/MediaMuxer.java if the // OutputFormat is updated. enum OutputFormat { OUTPUT_FORMAT_MPEG_4 = 0, OUTPUT_FORMAT_LIST_END // must be last - used to validate format type }; // Construct the muxer with the output file path. MediaMuxer(const char* pathOut); MediaMuxer(const char *path, OutputFormat format); // Construct the muxer with the file descriptor. Note that the MediaMuxer // will close this file at stop(). MediaMuxer(int fd); MediaMuxer(int fd, OutputFormat format); virtual ~MediaMuxer(); Loading Loading @@ -94,6 +108,7 @@ private: Mutex mMuxerLock; enum State { UNINITED, INITED, STARTED, STOPPED Loading media/libstagefright/MediaMuxer.cpp +14 −9 Original line number Diff line number Diff line Loading @@ -35,14 +35,20 @@ namespace android { MediaMuxer::MediaMuxer(const char* pathOut) : mState(INITED) { mWriter = new MPEG4Writer(pathOut); MediaMuxer::MediaMuxer(const char *path, OutputFormat format) : mState(UNINITED) { if (format == OUTPUT_FORMAT_MPEG_4) { mWriter = new MPEG4Writer(path); mState = INITED; } } MediaMuxer::MediaMuxer(int fd) : mState(INITED) { MediaMuxer::MediaMuxer(int fd, OutputFormat format) : mState(UNINITED) { if (format == OUTPUT_FORMAT_MPEG_4) { mWriter = new MPEG4Writer(fd); mState = INITED; } } MediaMuxer::~MediaMuxer() { Loading Loading @@ -107,8 +113,6 @@ status_t MediaMuxer::writeSampleData(const sp<ABuffer> &buffer, size_t trackInde int64_t timeUs, uint32_t flags) { Mutex::Autolock autoLock(mMuxerLock); sp<MediaAdapter> currentTrack = mTrackList[trackIndex]; if (buffer.get() == NULL) { ALOGE("WriteSampleData() get an NULL buffer."); return -EINVAL; Loading @@ -134,10 +138,11 @@ status_t MediaMuxer::writeSampleData(const sp<ABuffer> &buffer, size_t trackInde // Just set the kKeyDecodingTime as the presentation time for now. metaData->setInt64(kKeyDecodingTime, timeUs); if (flags & MediaCodec::BUFFER_FLAG_SYNCFRAME) { if (flags & SAMPLE_FLAG_SYNC) { metaData->setInt32(kKeyIsSyncFrame, true); } sp<MediaAdapter> currentTrack = mTrackList[trackIndex]; // This pushBuffer will wait until the mediaBuffer is consumed. return currentTrack->pushBuffer(mediaBuffer); } Loading Loading
cmds/stagefright/muxer.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -69,7 +69,8 @@ static int muxing( ALOGV("input file %s, output file %s", path, outputFileName); ALOGV("useAudio %d, useVideo %d", useAudio, useVideo); sp<MediaMuxer> muxer = new MediaMuxer(outputFileName); sp<MediaMuxer> muxer = new MediaMuxer(outputFileName, MediaMuxer::OUTPUT_FORMAT_MPEG_4); size_t trackCount = extractor->countTracks(); // Map the extractor's track index to the muxer's track index. Loading
include/media/stagefright/MediaMuxer.h +17 −2 Original line number Diff line number Diff line Loading @@ -40,11 +40,25 @@ struct MPEG4Writer; // deleting the output file after stop. struct MediaMuxer : public RefBase { public: // Please update media/java/android/media/MediaMuxer.java if the // SampleFlags is updated. enum SampleFlags { SAMPLE_FLAG_SYNC = 1, }; // Please update media/java/android/media/MediaMuxer.java if the // OutputFormat is updated. enum OutputFormat { OUTPUT_FORMAT_MPEG_4 = 0, OUTPUT_FORMAT_LIST_END // must be last - used to validate format type }; // Construct the muxer with the output file path. MediaMuxer(const char* pathOut); MediaMuxer(const char *path, OutputFormat format); // Construct the muxer with the file descriptor. Note that the MediaMuxer // will close this file at stop(). MediaMuxer(int fd); MediaMuxer(int fd, OutputFormat format); virtual ~MediaMuxer(); Loading Loading @@ -94,6 +108,7 @@ private: Mutex mMuxerLock; enum State { UNINITED, INITED, STARTED, STOPPED Loading
media/libstagefright/MediaMuxer.cpp +14 −9 Original line number Diff line number Diff line Loading @@ -35,14 +35,20 @@ namespace android { MediaMuxer::MediaMuxer(const char* pathOut) : mState(INITED) { mWriter = new MPEG4Writer(pathOut); MediaMuxer::MediaMuxer(const char *path, OutputFormat format) : mState(UNINITED) { if (format == OUTPUT_FORMAT_MPEG_4) { mWriter = new MPEG4Writer(path); mState = INITED; } } MediaMuxer::MediaMuxer(int fd) : mState(INITED) { MediaMuxer::MediaMuxer(int fd, OutputFormat format) : mState(UNINITED) { if (format == OUTPUT_FORMAT_MPEG_4) { mWriter = new MPEG4Writer(fd); mState = INITED; } } MediaMuxer::~MediaMuxer() { Loading Loading @@ -107,8 +113,6 @@ status_t MediaMuxer::writeSampleData(const sp<ABuffer> &buffer, size_t trackInde int64_t timeUs, uint32_t flags) { Mutex::Autolock autoLock(mMuxerLock); sp<MediaAdapter> currentTrack = mTrackList[trackIndex]; if (buffer.get() == NULL) { ALOGE("WriteSampleData() get an NULL buffer."); return -EINVAL; Loading @@ -134,10 +138,11 @@ status_t MediaMuxer::writeSampleData(const sp<ABuffer> &buffer, size_t trackInde // Just set the kKeyDecodingTime as the presentation time for now. metaData->setInt64(kKeyDecodingTime, timeUs); if (flags & MediaCodec::BUFFER_FLAG_SYNCFRAME) { if (flags & SAMPLE_FLAG_SYNC) { metaData->setInt32(kKeyIsSyncFrame, true); } sp<MediaAdapter> currentTrack = mTrackList[trackIndex]; // This pushBuffer will wait until the mediaBuffer is consumed. return currentTrack->pushBuffer(mediaBuffer); } Loading