summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/MPEG4Writer.cpp
diff options
context:
space:
mode:
authorJean-Baptiste Queru <jbq@google.com>2012-08-08 14:08:28 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2012-08-08 14:08:28 -0700
commite983aa4ff4d80af7702888e230b9aaa93a7b7e57 (patch)
tree09e62e3a573248dd1a3c7b2dae082810f16dfe79 /media/libstagefright/MPEG4Writer.cpp
parentf6a3576006f3fbe7d87ab49c1ebf292be5ddaa24 (diff)
parent51af4af2414cdaaf0185b971a41fc0b4f8c0b7e4 (diff)
downloadframeworks_av-e983aa4ff4d80af7702888e230b9aaa93a7b7e57.zip
frameworks_av-e983aa4ff4d80af7702888e230b9aaa93a7b7e57.tar.gz
frameworks_av-e983aa4ff4d80af7702888e230b9aaa93a7b7e57.tar.bz2
am 51af4af2: am e28df5b9: Merge "Store correct time stamps in recorded mp4 files"
* commit '51af4af2414cdaaf0185b971a41fc0b4f8c0b7e4': Store correct time stamps in recorded mp4 files
Diffstat (limited to 'media/libstagefright/MPEG4Writer.cpp')
-rwxr-xr-xmedia/libstagefright/MPEG4Writer.cpp21
1 files changed, 15 insertions, 6 deletions
diff --git a/media/libstagefright/MPEG4Writer.cpp b/media/libstagefright/MPEG4Writer.cpp
index 86477ba..8b52e15 100755
--- a/media/libstagefright/MPEG4Writer.cpp
+++ b/media/libstagefright/MPEG4Writer.cpp
@@ -317,11 +317,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();
@@ -821,8 +821,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
@@ -2473,7 +2482,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");
@@ -2686,7 +2695,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
@@ -2755,7 +2764,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