summaryrefslogtreecommitdiffstats
path: root/include/media/stagefright/MPEG4Writer.h
diff options
context:
space:
mode:
authorJames Dong <jdong@google.com>2010-07-30 17:41:22 -0700
committerJames Dong <jdong@google.com>2010-08-02 18:08:02 -0700
commit1c9747a4653aec1395c2bd6896c9b87cb5447837 (patch)
treeb92985a7f54cc988d6485862088c5a440f744fb5 /include/media/stagefright/MPEG4Writer.h
parent901335c2f0ce73a78277d90eb77807dcd1d65c95 (diff)
downloadframeworks_av-1c9747a4653aec1395c2bd6896c9b87cb5447837.zip
frameworks_av-1c9747a4653aec1395c2bd6896c9b87cb5447837.tar.gz
frameworks_av-1c9747a4653aec1395c2bd6896c9b87cb5447837.tar.bz2
File writer has a designated writer thread now
+ This reduces the file I/O block time for audio/video track processing - Since the file writer is buffering some output samples, the memory usage would go up, depending on how many output samples are buffered. Change-Id: I780cc5b26f4b53a5efbd643fcf9505dfc19cd4cd
Diffstat (limited to 'include/media/stagefright/MPEG4Writer.h')
-rw-r--r--include/media/stagefright/MPEG4Writer.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/include/media/stagefright/MPEG4Writer.h b/include/media/stagefright/MPEG4Writer.h
index d0c2dca..2e1e8d8 100644
--- a/include/media/stagefright/MPEG4Writer.h
+++ b/include/media/stagefright/MPEG4Writer.h
@@ -75,6 +75,7 @@ private:
uint32_t mInterleaveDurationUs;
int32_t mTimeScale;
int64_t mStartTimestampUs;
+
Mutex mLock;
List<Track *> mTracks;
@@ -87,6 +88,46 @@ private:
size_t numTracks();
int64_t estimateMoovBoxSize(int32_t bitRate);
+ struct Chunk {
+ Track *mTrack; // Owner
+ int64_t mTimeStampUs; // Timestamp of the 1st sample
+ List<MediaBuffer *> mSamples; // Sample data
+
+ // Convenient constructor
+ Chunk(Track *track, int64_t timeUs, List<MediaBuffer *> samples)
+ : mTrack(track), mTimeStampUs(timeUs), mSamples(samples) {
+ }
+
+ };
+ struct ChunkInfo {
+ Track *mTrack; // Owner
+ List<Chunk> mChunks; // Remaining chunks to be written
+ };
+
+ bool mIsFirstChunk;
+ volatile bool mDone; // Writer thread is done?
+ pthread_t mThread; // Thread id for the writer
+ List<ChunkInfo> mChunkInfos; // Chunk infos
+ Condition mChunkReadyCondition; // Signal that chunks are available
+
+ // Writer thread handling
+ status_t startWriterThread();
+ void stopWriterThread();
+ static void *ThreadWrapper(void *me);
+ void threadFunc();
+
+ // Buffer a single chunk to be written out later.
+ void bufferChunk(const Chunk& chunk);
+
+ // Write all buffered chunks from all tracks
+ void writeChunks();
+
+ // Write a chunk if there is one
+ status_t writeOneChunk();
+
+ // Write the first chunk from the given ChunkInfo.
+ void writeFirstChunk(ChunkInfo* info);
+
void lock();
void unlock();