120111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber/*
220111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber * Copyright (C) 2009 The Android Open Source Project
320111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber *
420111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber * Licensed under the Apache License, Version 2.0 (the "License");
520111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber * you may not use this file except in compliance with the License.
620111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber * You may obtain a copy of the License at
720111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber *
820111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber *      http://www.apache.org/licenses/LICENSE-2.0
920111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber *
1020111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber * Unless required by applicable law or agreed to in writing, software
1120111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber * distributed under the License is distributed on an "AS IS" BASIS,
1220111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1320111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber * See the License for the specific language governing permissions and
1420111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber * limitations under the License.
1520111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber */
1620111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber
1720111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber#ifndef MPEG4_WRITER_H_
1820111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber
1920111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber#define MPEG4_WRITER_H_
2020111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber
2120111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber#include <stdio.h>
2220111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber
23b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen#include <media/IMediaSource.h>
242dce41ad26cb3e9e15c9e456a84bcf5309548ca0Andreas Huber#include <media/stagefright/MediaWriter.h>
2520111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber#include <utils/List.h>
2620111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber#include <utils/threads.h>
27fe44e4f74fe2582cbf012687059278dbcbdaa6f7Hangyu Kuang#include <media/stagefright/foundation/AHandlerReflector.h>
28fe44e4f74fe2582cbf012687059278dbcbdaa6f7Hangyu Kuang#include <media/stagefright/foundation/ALooper.h>
2920111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber
3020111aa043c5f404472bc63b90bc5aad906b1101Andreas Hubernamespace android {
3120111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber
32fe44e4f74fe2582cbf012687059278dbcbdaa6f7Hangyu Kuangclass AMessage;
3320111aa043c5f404472bc63b90bc5aad906b1101Andreas Huberclass MediaBuffer;
3420111aa043c5f404472bc63b90bc5aad906b1101Andreas Huberclass MetaData;
3520111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber
362dce41ad26cb3e9e15c9e456a84bcf5309548ca0Andreas Huberclass MPEG4Writer : public MediaWriter {
3720111aa043c5f404472bc63b90bc5aad906b1101Andreas Huberpublic:
3830ab66297501757d745b9ae10da61adcd891f497Andreas Huber    MPEG4Writer(int fd);
3920111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber
40acc47642e0f5d962f6289e6ba687fabf68f8312bJames Dong    // Limitations
4125adc33c1ba77b95162ebce8a4c2a7a07baeb98fHangyu Kuang    // No more than one video and/or one audio source can be added, but
4225adc33c1ba77b95162ebce8a4c2a7a07baeb98fHangyu Kuang    // multiple metadata sources can be added.
43b2487f03f12dcafdb801fc0007c8df8412397f44Marco Nelissen    virtual status_t addSource(const sp<IMediaSource> &source);
44acc47642e0f5d962f6289e6ba687fabf68f8312bJames Dong
45acc47642e0f5d962f6289e6ba687fabf68f8312bJames Dong    // Returns INVALID_OPERATION if there is no source or track.
462dec2b5be2056c6d9428897dc672185872d30d17James Dong    virtual status_t start(MetaData *param = NULL);
478bcc65c753085fe3328592cceda0cf0e8f8b0a45James Dong    virtual status_t stop() { return reset(); }
4837187916a486504acaf83bea30147eb5fbf46ae5James Dong    virtual status_t pause();
492dce41ad26cb3e9e15c9e456a84bcf5309548ca0Andreas Huber    virtual bool reachedEOS();
50dedf414d3fe2e79ee0aad0f1c82ca16ebd886ff6James Dong    virtual status_t dump(int fd, const Vector<String16>& args);
5120111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber
5220111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber    void beginBox(const char *fourcc);
53e76dba7af9589d9ed7b116eec3a74168a8352925Chong Zhang    void beginBox(uint32_t id);
5420111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber    void writeInt8(int8_t x);
5520111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber    void writeInt16(int16_t x);
5620111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber    void writeInt32(int32_t x);
5720111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber    void writeInt64(int64_t x);
5820111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber    void writeCString(const char *s);
5920111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber    void writeFourcc(const char *fourcc);
6020111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber    void write(const void *data, size_t size);
618c460498c028888c533ab442be12b6d4b669b965James Dong    inline size_t write(const void *ptr, size_t size, size_t nmemb);
6220111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber    void endBox();
6313aec890216948b0c364f8f92792129d0335f506James Dong    uint32_t interleaveDuration() const { return mInterleaveDurationUs; }
6413aec890216948b0c364f8f92792129d0335f506James Dong    status_t setInterleaveDuration(uint32_t duration);
658f5f2fcee5c12d08df71d17017410c50951fc2e3James Dong    int32_t getTimeScale() const { return mTimeScale; }
6620111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber
6707b1bb529a1ae76c46a71b01338c166f9490629dJames Dong    status_t setGeoData(int latitudex10000, int longitudex10000);
68e76dba7af9589d9ed7b116eec3a74168a8352925Chong Zhang    status_t setCaptureRate(float captureFps);
694dbff11975e737482537e1636051690188f3fbc4Praveen Chavan    status_t setTemporalLayerCount(uint32_t layerCount);
70fe44e4f74fe2582cbf012687059278dbcbdaa6f7Hangyu Kuang    void notifyApproachingLimit();
71d8cf55d878edddfc36bb821a95b88dfb2453c2c3Robert Shih    virtual void setStartTimeOffsetMs(int ms) { mStartTimeOffsetMs = ms; }
72d8cf55d878edddfc36bb821a95b88dfb2453c2c3Robert Shih    virtual int32_t getStartTimeOffsetMs() const { return mStartTimeOffsetMs; }
73fe44e4f74fe2582cbf012687059278dbcbdaa6f7Hangyu Kuang    virtual status_t setNextFd(int fd);
7407b1bb529a1ae76c46a71b01338c166f9490629dJames Dong
75693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huberprotected:
76693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber    virtual ~MPEG4Writer();
77693d271e62a3726689ff68f4505ba49228eb94b2Andreas Huber
7820111aa043c5f404472bc63b90bc5aad906b1101Andreas Huberprivate:
7920111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber    class Track;
80fe44e4f74fe2582cbf012687059278dbcbdaa6f7Hangyu Kuang    friend struct AHandlerReflector<MPEG4Writer>;
81fe44e4f74fe2582cbf012687059278dbcbdaa6f7Hangyu Kuang
82fe44e4f74fe2582cbf012687059278dbcbdaa6f7Hangyu Kuang    enum {
83fe44e4f74fe2582cbf012687059278dbcbdaa6f7Hangyu Kuang        kWhatSwitch                          = 'swch',
84fe44e4f74fe2582cbf012687059278dbcbdaa6f7Hangyu Kuang    };
8520111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber
86c7fc37a3dab9bd1f96713649f351b5990e6316ffJames Dong    int  mFd;
87fe44e4f74fe2582cbf012687059278dbcbdaa6f7Hangyu Kuang    int mNextFd;
88fe44e4f74fe2582cbf012687059278dbcbdaa6f7Hangyu Kuang    sp<MetaData> mStartMeta;
89674ebd0b4e1143e38392a4e3bb38b4679a4577bcJames Dong    status_t mInitCheck;
90de05c8eab188e98798f2b9c3dfac53dbc18ef584ztenghui    bool mIsRealTimeRecording;
91b4d5320bda29cd9694461c9b61d0211f801ff0afJames Dong    bool mUse4ByteNalLength;
921acfe8649f8169caf2ff098c2dc2de880d9a3760James Dong    bool mUse32BitOffset;
93a007e8229fb2be4866c483f9cd6c4af238a2da5eJames Dong    bool mIsFileSizeLimitExplicitlyRequested;
94a7d1a2dd776bf356c228785a94ba8e0ff6a2ec7fJames Dong    bool mPaused;
95411ba422e3635d534928ffd81abf54f4f291c739James Dong    bool mStarted;  // Writer thread + track threads started successfully
96411ba422e3635d534928ffd81abf54f4f291c739James Dong    bool mWriterThreadStarted;  // Only writer thread started successfully
97fe44e4f74fe2582cbf012687059278dbcbdaa6f7Hangyu Kuang    bool mSendNotify;
98c7fc37a3dab9bd1f96713649f351b5990e6316ffJames Dong    off64_t mOffset;
9920111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber    off_t mMdatOffset;
1007837c17063a4c50bc856ba59418516fdab731de7James Dong    uint8_t *mMoovBoxBuffer;
101c7fc37a3dab9bd1f96713649f351b5990e6316ffJames Dong    off64_t mMoovBoxBufferOffset;
1027837c17063a4c50bc856ba59418516fdab731de7James Dong    bool  mWriteMoovBoxToMemory;
103c7fc37a3dab9bd1f96713649f351b5990e6316ffJames Dong    off64_t mFreeBoxOffset;
1047837c17063a4c50bc856ba59418516fdab731de7James Dong    bool mStreamableFile;
105c7fc37a3dab9bd1f96713649f351b5990e6316ffJames Dong    off64_t mEstimatedMoovBoxSize;
1067c4820d23b68f748b8dfff3d4bb5b13e9d4811a8Chong Zhang    off64_t mMoovExtraSize;
10713aec890216948b0c364f8f92792129d0335f506James Dong    uint32_t mInterleaveDurationUs;
1088f5f2fcee5c12d08df71d17017410c50951fc2e3James Dong    int32_t mTimeScale;
1093c0131f02b6f008321608044c53bccce2ac5f6ddJames Dong    int64_t mStartTimestampUs;
11007b1bb529a1ae76c46a71b01338c166f9490629dJames Dong    int mLatitudex10000;
11107b1bb529a1ae76c46a71b01338c166f9490629dJames Dong    int mLongitudex10000;
11207b1bb529a1ae76c46a71b01338c166f9490629dJames Dong    bool mAreGeoTagsAvailable;
11386b7f47aa7482424cf8fd248f1315311919be3b0James Dong    int32_t mStartTimeOffsetMs;
114fe44e4f74fe2582cbf012687059278dbcbdaa6f7Hangyu Kuang    bool mSwitchPending;
115fe44e4f74fe2582cbf012687059278dbcbdaa6f7Hangyu Kuang
116fe44e4f74fe2582cbf012687059278dbcbdaa6f7Hangyu Kuang    sp<ALooper> mLooper;
117fe44e4f74fe2582cbf012687059278dbcbdaa6f7Hangyu Kuang    sp<AHandlerReflector<MPEG4Writer> > mReflector;
1181c9747a4653aec1395c2bd6896c9b87cb5447837James Dong
11920111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber    Mutex mLock;
12020111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber
12120111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber    List<Track *> mTracks;
12220111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber
123c7fc37a3dab9bd1f96713649f351b5990e6316ffJames Dong    List<off64_t> mBoxes;
12420111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber
125e76dba7af9589d9ed7b116eec3a74168a8352925Chong Zhang    sp<AMessage> mMetaKeys;
126e76dba7af9589d9ed7b116eec3a74168a8352925Chong Zhang
127f60cafe0e6aad8f9ce54660fa88b651ae4e749e6James Dong    void setStartTimestampUs(int64_t timeUs);
128f60cafe0e6aad8f9ce54660fa88b651ae4e749e6James Dong    int64_t getStartTimestampUs();  // Not const
12993d6b102a13afa23bfa80d74c399d93d542e6ad6James Dong    status_t startTracks(MetaData *params);
13058ae9c530247668f8af36e30d228c716c226b3d4James Dong    size_t numTracks();
1312dec2b5be2056c6d9428897dc672185872d30d17James Dong    int64_t estimateMoovBoxSize(int32_t bitRate);
1323c0131f02b6f008321608044c53bccce2ac5f6ddJames Dong
1331c9747a4653aec1395c2bd6896c9b87cb5447837James Dong    struct Chunk {
1341c9747a4653aec1395c2bd6896c9b87cb5447837James Dong        Track               *mTrack;        // Owner
1351c9747a4653aec1395c2bd6896c9b87cb5447837James Dong        int64_t             mTimeStampUs;   // Timestamp of the 1st sample
1361c9747a4653aec1395c2bd6896c9b87cb5447837James Dong        List<MediaBuffer *> mSamples;       // Sample data
1371c9747a4653aec1395c2bd6896c9b87cb5447837James Dong
1381c9747a4653aec1395c2bd6896c9b87cb5447837James Dong        // Convenient constructor
139fcac8fa9421f442f024018628a6042d7a14fbfb0James Dong        Chunk(): mTrack(NULL), mTimeStampUs(0) {}
140fcac8fa9421f442f024018628a6042d7a14fbfb0James Dong
1411c9747a4653aec1395c2bd6896c9b87cb5447837James Dong        Chunk(Track *track, int64_t timeUs, List<MediaBuffer *> samples)
1421c9747a4653aec1395c2bd6896c9b87cb5447837James Dong            : mTrack(track), mTimeStampUs(timeUs), mSamples(samples) {
1431c9747a4653aec1395c2bd6896c9b87cb5447837James Dong        }
1441c9747a4653aec1395c2bd6896c9b87cb5447837James Dong
1451c9747a4653aec1395c2bd6896c9b87cb5447837James Dong    };
1461c9747a4653aec1395c2bd6896c9b87cb5447837James Dong    struct ChunkInfo {
1471c9747a4653aec1395c2bd6896c9b87cb5447837James Dong        Track               *mTrack;        // Owner
1481c9747a4653aec1395c2bd6896c9b87cb5447837James Dong        List<Chunk>         mChunks;        // Remaining chunks to be written
14970ccfd44c4bfe95ddecc2df6c3695efc48229d72James Dong
15070ccfd44c4bfe95ddecc2df6c3695efc48229d72James Dong        // Previous chunk timestamp that has been written
15170ccfd44c4bfe95ddecc2df6c3695efc48229d72James Dong        int64_t mPrevChunkTimestampUs;
15270ccfd44c4bfe95ddecc2df6c3695efc48229d72James Dong
15370ccfd44c4bfe95ddecc2df6c3695efc48229d72James Dong        // Max time interval between neighboring chunks
15470ccfd44c4bfe95ddecc2df6c3695efc48229d72James Dong        int64_t mMaxInterChunkDurUs;
15570ccfd44c4bfe95ddecc2df6c3695efc48229d72James Dong
1561c9747a4653aec1395c2bd6896c9b87cb5447837James Dong    };
1571c9747a4653aec1395c2bd6896c9b87cb5447837James Dong
1581c9747a4653aec1395c2bd6896c9b87cb5447837James Dong    bool            mIsFirstChunk;
1591c9747a4653aec1395c2bd6896c9b87cb5447837James Dong    volatile bool   mDone;                  // Writer thread is done?
1601c9747a4653aec1395c2bd6896c9b87cb5447837James Dong    pthread_t       mThread;                // Thread id for the writer
1611c9747a4653aec1395c2bd6896c9b87cb5447837James Dong    List<ChunkInfo> mChunkInfos;            // Chunk infos
1621c9747a4653aec1395c2bd6896c9b87cb5447837James Dong    Condition       mChunkReadyCondition;   // Signal that chunks are available
1631c9747a4653aec1395c2bd6896c9b87cb5447837James Dong
1641c9747a4653aec1395c2bd6896c9b87cb5447837James Dong    // Writer thread handling
1651c9747a4653aec1395c2bd6896c9b87cb5447837James Dong    status_t startWriterThread();
1661c9747a4653aec1395c2bd6896c9b87cb5447837James Dong    void stopWriterThread();
1671c9747a4653aec1395c2bd6896c9b87cb5447837James Dong    static void *ThreadWrapper(void *me);
1681c9747a4653aec1395c2bd6896c9b87cb5447837James Dong    void threadFunc();
1691c9747a4653aec1395c2bd6896c9b87cb5447837James Dong
1701c9747a4653aec1395c2bd6896c9b87cb5447837James Dong    // Buffer a single chunk to be written out later.
1711c9747a4653aec1395c2bd6896c9b87cb5447837James Dong    void bufferChunk(const Chunk& chunk);
1721c9747a4653aec1395c2bd6896c9b87cb5447837James Dong
1731c9747a4653aec1395c2bd6896c9b87cb5447837James Dong    // Write all buffered chunks from all tracks
174fcac8fa9421f442f024018628a6042d7a14fbfb0James Dong    void writeAllChunks();
1751c9747a4653aec1395c2bd6896c9b87cb5447837James Dong
176fcac8fa9421f442f024018628a6042d7a14fbfb0James Dong    // Retrieve the proper chunk to write if there is one
177fcac8fa9421f442f024018628a6042d7a14fbfb0James Dong    // Return true if a chunk is found; otherwise, return false.
178fcac8fa9421f442f024018628a6042d7a14fbfb0James Dong    bool findChunkToWrite(Chunk *chunk);
1791c9747a4653aec1395c2bd6896c9b87cb5447837James Dong
180fcac8fa9421f442f024018628a6042d7a14fbfb0James Dong    // Actually write the given chunk to the file.
181fcac8fa9421f442f024018628a6042d7a14fbfb0James Dong    void writeChunkToFile(Chunk* chunk);
1821c9747a4653aec1395c2bd6896c9b87cb5447837James Dong
183e259531ce59ab1f31de5a23124b22536f6a5a767James Dong    // Adjust other track media clock (presumably wall clock)
184e259531ce59ab1f31de5a23124b22536f6a5a767James Dong    // based on audio track media clock with the drift time.
185e259531ce59ab1f31de5a23124b22536f6a5a767James Dong    int64_t mDriftTimeUs;
186d707fcb3e29707ca4a5935c294ef0b38eb5aba5fJames Dong    void setDriftTimeUs(int64_t driftTimeUs);
187e259531ce59ab1f31de5a23124b22536f6a5a767James Dong    int64_t getDriftTimeUs();
188e259531ce59ab1f31de5a23124b22536f6a5a767James Dong
189b4d5320bda29cd9694461c9b61d0211f801ff0afJames Dong    // Return whether the nal length is 4 bytes or 2 bytes
190b4d5320bda29cd9694461c9b61d0211f801ff0afJames Dong    // Only makes sense for H.264/AVC
191b4d5320bda29cd9694461c9b61d0211f801ff0afJames Dong    bool useNalLengthFour();
192b4d5320bda29cd9694461c9b61d0211f801ff0afJames Dong
193de05c8eab188e98798f2b9c3dfac53dbc18ef584ztenghui    // Return whether the writer is used for real time recording.
194de05c8eab188e98798f2b9c3dfac53dbc18ef584ztenghui    // In real time recording mode, new samples will be allowed to buffered into
195de05c8eab188e98798f2b9c3dfac53dbc18ef584ztenghui    // chunks in higher priority thread, even though the file writer has not
196de05c8eab188e98798f2b9c3dfac53dbc18ef584ztenghui    // drained the chunks yet.
197de05c8eab188e98798f2b9c3dfac53dbc18ef584ztenghui    // By default, real time recording is on.
198de05c8eab188e98798f2b9c3dfac53dbc18ef584ztenghui    bool isRealTimeRecording() const;
199de05c8eab188e98798f2b9c3dfac53dbc18ef584ztenghui
20013aec890216948b0c364f8f92792129d0335f506James Dong    void lock();
20113aec890216948b0c364f8f92792129d0335f506James Dong    void unlock();
20213aec890216948b0c364f8f92792129d0335f506James Dong
203fe44e4f74fe2582cbf012687059278dbcbdaa6f7Hangyu Kuang    void initInternal(int fd);
204fe44e4f74fe2582cbf012687059278dbcbdaa6f7Hangyu Kuang
20513aec890216948b0c364f8f92792129d0335f506James Dong    // Acquire lock before calling these methods
206c7fc37a3dab9bd1f96713649f351b5990e6316ffJames Dong    off64_t addSample_l(MediaBuffer *buffer);
207c7fc37a3dab9bd1f96713649f351b5990e6316ffJames Dong    off64_t addLengthPrefixedSample_l(MediaBuffer *buffer);
20880f78b773f92048944a850efb7b60629643370cdPraveen Chavan    off64_t addMultipleLengthPrefixedSamples_l(MediaBuffer *buffer);
20920111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber
210d599cd4573b5a2d5914c5040e0565ef866749b77James Dong    bool exceedsFileSizeLimit();
2111f90c4b3fda9dbd2824d67fd679f850572f114dcJames Dong    bool use32BitFileOffset() const;
212d599cd4573b5a2d5914c5040e0565ef866749b77James Dong    bool exceedsFileDurationLimit();
213fe44e4f74fe2582cbf012687059278dbcbdaa6f7Hangyu Kuang    bool approachingFileSizeLimit();
21478a1a286f736888ae7af8860b2c424af0d978848James Dong    bool isFileStreamable() const;
215bc07bcc65e91c7aea9713631ae67760dcf1b0286James Dong    void trackProgressStatus(size_t trackId, int64_t timeUs, status_t err = OK);
21613f6284305e4b27395a23db7882d670bdb1bcae1James Dong    void writeCompositionMatrix(int32_t degrees);
217b21c564ce47041f9dd3ab65e36fed57c4937a42dJames Dong    void writeMvhdBox(int64_t durationUs);
218b21c564ce47041f9dd3ab65e36fed57c4937a42dJames Dong    void writeMoovBox(int64_t durationUs);
2192cf9c5073ca3342ee52673ad68763fadd2c2be79James Dong    void writeFtypBox(MetaData *param);
22007b1bb529a1ae76c46a71b01338c166f9490629dJames Dong    void writeUdtaBox();
22107b1bb529a1ae76c46a71b01338c166f9490629dJames Dong    void writeGeoDataBox();
22207b1bb529a1ae76c46a71b01338c166f9490629dJames Dong    void writeLatitude(int degreex10000);
22307b1bb529a1ae76c46a71b01338c166f9490629dJames Dong    void writeLongitude(int degreex10000);
224fe44e4f74fe2582cbf012687059278dbcbdaa6f7Hangyu Kuang    void finishCurrentSession();
2257c4820d23b68f748b8dfff3d4bb5b13e9d4811a8Chong Zhang
2267c4820d23b68f748b8dfff3d4bb5b13e9d4811a8Chong Zhang    void addDeviceMeta();
227e76dba7af9589d9ed7b116eec3a74168a8352925Chong Zhang    void writeHdlr();
228e76dba7af9589d9ed7b116eec3a74168a8352925Chong Zhang    void writeKeys();
229e76dba7af9589d9ed7b116eec3a74168a8352925Chong Zhang    void writeIlst();
230e76dba7af9589d9ed7b116eec3a74168a8352925Chong Zhang    void writeMetaBox();
23170ccfd44c4bfe95ddecc2df6c3695efc48229d72James Dong    void sendSessionSummary();
232411ba422e3635d534928ffd81abf54f4f291c739James Dong    void release();
233fe44e4f74fe2582cbf012687059278dbcbdaa6f7Hangyu Kuang    status_t switchFd();
234fe44e4f74fe2582cbf012687059278dbcbdaa6f7Hangyu Kuang    status_t reset(bool stopSource = true);
2357837c17063a4c50bc856ba59418516fdab731de7James Dong
236efcdf187baab9ec29e12adcf85e63fe3e6d5aa4dJohannes Carlsson    static uint32_t getMpeg4Time();
237efcdf187baab9ec29e12adcf85e63fe3e6d5aa4dJohannes Carlsson
238fe44e4f74fe2582cbf012687059278dbcbdaa6f7Hangyu Kuang    void onMessageReceived(const sp<AMessage> &msg);
239fe44e4f74fe2582cbf012687059278dbcbdaa6f7Hangyu Kuang
24020111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber    MPEG4Writer(const MPEG4Writer &);
24120111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber    MPEG4Writer &operator=(const MPEG4Writer &);
24220111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber};
24320111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber
24420111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber}  // namespace android
24520111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber
24620111aa043c5f404472bc63b90bc5aad906b1101Andreas Huber#endif  // MPEG4_WRITER_H_
247