Loading include/media/stagefright/MPEG4Writer.h +2 −0 Original line number Diff line number Diff line Loading @@ -186,6 +186,8 @@ private: void release(); status_t reset(); static uint32_t getMpeg4Time(); MPEG4Writer(const MPEG4Writer &); MPEG4Writer &operator=(const MPEG4Writer &); }; Loading media/libstagefright/MPEG4Writer.cpp +15 −6 Original line number Diff line number Diff line Loading @@ -236,11 +236,11 @@ private: void writeDrefBox(); void writeDinfBox(); void writeDamrBox(); void writeMdhdBox(time_t now); void writeMdhdBox(uint32_t now); void writeSmhdBox(); void writeVmhdBox(); void writeHdlrBox(); void writeTkhdBox(time_t now); void writeTkhdBox(uint32_t now); void writeMp4aEsdsBox(); void writeMp4vEsdsBox(); void writeAudioFourCCBox(); Loading Loading @@ -723,8 +723,17 @@ status_t MPEG4Writer::reset() { return err; } void MPEG4Writer::writeMvhdBox(int64_t durationUs) { uint32_t MPEG4Writer::getMpeg4Time() { time_t now = time(NULL); // MP4 file uses time counting seconds since midnight, Jan. 1, 1904 // while time function returns Unix epoch values which starts // at 1970-01-01. Lets add the number of seconds between them uint32_t mpeg4Time = now + (66 * 365 + 17) * (24 * 60 * 60); return mpeg4Time; } void MPEG4Writer::writeMvhdBox(int64_t durationUs) { uint32_t now = getMpeg4Time(); beginBox("mvhd"); writeInt32(0); // version=0, flags=0 writeInt32(now); // creation time Loading Loading @@ -2357,7 +2366,7 @@ void MPEG4Writer::Track::writeTrackHeader(bool use32BitOffset) { ALOGV("%s track time scale: %d", mIsAudio? "Audio": "Video", mTimeScale); time_t now = time(NULL); uint32_t now = getMpeg4Time(); mOwner->beginBox("trak"); writeTkhdBox(now); mOwner->beginBox("mdia"); Loading Loading @@ -2570,7 +2579,7 @@ void MPEG4Writer::Track::writeMp4vEsdsBox() { mOwner->endBox(); // esds } void MPEG4Writer::Track::writeTkhdBox(time_t now) { void MPEG4Writer::Track::writeTkhdBox(uint32_t now) { mOwner->beginBox("tkhd"); // Flags = 7 to indicate that the track is enabled, and // part of the presentation Loading Loading @@ -2639,7 +2648,7 @@ void MPEG4Writer::Track::writeHdlrBox() { mOwner->endBox(); } void MPEG4Writer::Track::writeMdhdBox(time_t now) { void MPEG4Writer::Track::writeMdhdBox(uint32_t now) { int64_t trakDurationUs = getDurationUs(); mOwner->beginBox("mdhd"); mOwner->writeInt32(0); // version=0, flags=0 Loading Loading
include/media/stagefright/MPEG4Writer.h +2 −0 Original line number Diff line number Diff line Loading @@ -186,6 +186,8 @@ private: void release(); status_t reset(); static uint32_t getMpeg4Time(); MPEG4Writer(const MPEG4Writer &); MPEG4Writer &operator=(const MPEG4Writer &); }; Loading
media/libstagefright/MPEG4Writer.cpp +15 −6 Original line number Diff line number Diff line Loading @@ -236,11 +236,11 @@ private: void writeDrefBox(); void writeDinfBox(); void writeDamrBox(); void writeMdhdBox(time_t now); void writeMdhdBox(uint32_t now); void writeSmhdBox(); void writeVmhdBox(); void writeHdlrBox(); void writeTkhdBox(time_t now); void writeTkhdBox(uint32_t now); void writeMp4aEsdsBox(); void writeMp4vEsdsBox(); void writeAudioFourCCBox(); Loading Loading @@ -723,8 +723,17 @@ status_t MPEG4Writer::reset() { return err; } void MPEG4Writer::writeMvhdBox(int64_t durationUs) { uint32_t MPEG4Writer::getMpeg4Time() { time_t now = time(NULL); // MP4 file uses time counting seconds since midnight, Jan. 1, 1904 // while time function returns Unix epoch values which starts // at 1970-01-01. Lets add the number of seconds between them uint32_t mpeg4Time = now + (66 * 365 + 17) * (24 * 60 * 60); return mpeg4Time; } void MPEG4Writer::writeMvhdBox(int64_t durationUs) { uint32_t now = getMpeg4Time(); beginBox("mvhd"); writeInt32(0); // version=0, flags=0 writeInt32(now); // creation time Loading Loading @@ -2357,7 +2366,7 @@ void MPEG4Writer::Track::writeTrackHeader(bool use32BitOffset) { ALOGV("%s track time scale: %d", mIsAudio? "Audio": "Video", mTimeScale); time_t now = time(NULL); uint32_t now = getMpeg4Time(); mOwner->beginBox("trak"); writeTkhdBox(now); mOwner->beginBox("mdia"); Loading Loading @@ -2570,7 +2579,7 @@ void MPEG4Writer::Track::writeMp4vEsdsBox() { mOwner->endBox(); // esds } void MPEG4Writer::Track::writeTkhdBox(time_t now) { void MPEG4Writer::Track::writeTkhdBox(uint32_t now) { mOwner->beginBox("tkhd"); // Flags = 7 to indicate that the track is enabled, and // part of the presentation Loading Loading @@ -2639,7 +2648,7 @@ void MPEG4Writer::Track::writeHdlrBox() { mOwner->endBox(); } void MPEG4Writer::Track::writeMdhdBox(time_t now) { void MPEG4Writer::Track::writeMdhdBox(uint32_t now) { int64_t trakDurationUs = getDurationUs(); mOwner->beginBox("mdhd"); mOwner->writeInt32(0); // version=0, flags=0 Loading