summaryrefslogtreecommitdiffstats
path: root/include/media
diff options
context:
space:
mode:
authorJames Dong <jdong@google.com>2010-08-03 10:35:55 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2010-08-03 10:35:55 -0700
commit26ab7ab7f543a03b65735a41de8496c54d3e490e (patch)
tree769f80090d1ddb44bf7873043d6b2574b7983b6c /include/media
parenta5740924c0a71871f2697139effd43b137750597 (diff)
parent1c9747a4653aec1395c2bd6896c9b87cb5447837 (diff)
downloadframeworks_av-26ab7ab7f543a03b65735a41de8496c54d3e490e.zip
frameworks_av-26ab7ab7f543a03b65735a41de8496c54d3e490e.tar.gz
frameworks_av-26ab7ab7f543a03b65735a41de8496c54d3e490e.tar.bz2
Merge "File writer has a designated writer thread now" into gingerbread
Diffstat (limited to 'include/media')
-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();