diff options
author | Surajit Podder <spodder@codeaurora.org> | 2016-02-25 20:23:24 +0530 |
---|---|---|
committer | Steve Kondik <steve@cyngn.com> | 2016-04-13 13:54:55 -0700 |
commit | 51b3174ac272f146f7a4fb502103d8130b6f4703 (patch) | |
tree | 941d43998d3212a890acf30f52ccbf725f0c5a53 | |
parent | 7262eae1402f3256606ad1776e35c4a08ed267c3 (diff) | |
download | frameworks_av-51b3174ac272f146f7a4fb502103d8130b6f4703.zip frameworks_av-51b3174ac272f146f7a4fb502103d8130b6f4703.tar.gz frameworks_av-51b3174ac272f146f7a4fb502103d8130b6f4703.tar.bz2 |
video: Use boot clock for recording start time
Camera HAL3 uses boot time for buffer timestamp, rather
than system monotonic time. This leads to issues as
framework uses system monotonic time as reference start
time for timestamp adjustment.
Add change to use boot time for reference start time.
CRs-Fixed: 946735
Change-Id: Id0af9c8aed1a983095275ac03f7f59abc31594cc
-rw-r--r-- | include/media/stagefright/MetaData.h | 1 | ||||
-rw-r--r-- | media/libmediaplayerservice/StagefrightRecorder.cpp | 2 | ||||
-rw-r--r-- | media/libstagefright/CameraSource.cpp | 10 | ||||
-rw-r--r-- | media/libstagefright/MPEG4Writer.cpp | 10 | ||||
-rw-r--r-- | media/libstagefright/MediaCodecSource.cpp | 10 |
5 files changed, 31 insertions, 2 deletions
diff --git a/include/media/stagefright/MetaData.h b/include/media/stagefright/MetaData.h index 2a3df22..66e7d63 100644 --- a/include/media/stagefright/MetaData.h +++ b/include/media/stagefright/MetaData.h @@ -68,6 +68,7 @@ enum { kKeyIsSyncFrame = 'sync', // int32_t (bool) kKeyIsCodecConfig = 'conf', // int32_t (bool) kKeyTime = 'time', // int64_t (usecs) + kKeyTimeBoot = 'timb', // int64_t (usecs) kKeyDecodingTime = 'decT', // int64_t (decoding timestamp in usecs) kKeyNTPTime = 'ntpT', // uint64_t (ntp-timestamp) kKeyTargetTime = 'tarT', // int64_t (usecs) diff --git a/media/libmediaplayerservice/StagefrightRecorder.cpp b/media/libmediaplayerservice/StagefrightRecorder.cpp index 18df1fc..442dba1 100644 --- a/media/libmediaplayerservice/StagefrightRecorder.cpp +++ b/media/libmediaplayerservice/StagefrightRecorder.cpp @@ -1814,6 +1814,8 @@ status_t StagefrightRecorder::setupMPEG4orWEBMRecording() { void StagefrightRecorder::setupMPEG4orWEBMMetaData(sp<MetaData> *meta) { int64_t startTimeUs = systemTime() / 1000; (*meta)->setInt64(kKeyTime, startTimeUs); + int64_t startTimeBootUs = systemTime(SYSTEM_TIME_BOOTTIME) / 1000; + (*meta)->setInt64(kKeyTimeBoot, startTimeBootUs); (*meta)->setInt32(kKeyFileType, mOutputFormat); (*meta)->setInt32(kKeyBitRate, mTotalBitRate); if (mMovieTimeScale > 0) { diff --git a/media/libstagefright/CameraSource.cpp b/media/libstagefright/CameraSource.cpp index e2ad924..64e7f90 100644 --- a/media/libstagefright/CameraSource.cpp +++ b/media/libstagefright/CameraSource.cpp @@ -701,7 +701,15 @@ status_t CameraSource::start(MetaData *meta) { if (meta) { int64_t startTimeUs; - if (meta->findInt64(kKeyTime, &startTimeUs)) { + + auto key = kKeyTimeBoot; + char value[PROPERTY_VALUE_MAX]; + if (property_get("media.camera.ts.monotonic", value, "0") && + atoi(value)) { + key = kKeyTime; + } + + if (meta->findInt64(key, &startTimeUs)) { mStartTimeUs = startTimeUs; } diff --git a/media/libstagefright/MPEG4Writer.cpp b/media/libstagefright/MPEG4Writer.cpp index 6a8664e..16da3eb 100644 --- a/media/libstagefright/MPEG4Writer.cpp +++ b/media/libstagefright/MPEG4Writer.cpp @@ -1837,9 +1837,16 @@ status_t MPEG4Writer::Track::start(MetaData *params) { } int64_t startTimeUs; + if (params == NULL || !params->findInt64(kKeyTime, &startTimeUs)) { startTimeUs = 0; } + + int64_t startTimeBootUs; + if (params == NULL || !params->findInt64(kKeyTimeBoot, &startTimeBootUs)) { + startTimeBootUs = 0; + } + mStartTimeRealUs = startTimeUs; int32_t rotationDegrees; @@ -1850,6 +1857,7 @@ status_t MPEG4Writer::Track::start(MetaData *params) { initTrackingProgressStatus(params); sp<MetaData> meta = new MetaData; + if (mOwner->isRealTimeRecording() && mOwner->numTracks() > 1) { /* * This extra delay of accepting incoming audio/video signals @@ -1865,10 +1873,12 @@ status_t MPEG4Writer::Track::start(MetaData *params) { startTimeOffsetUs = kInitialDelayTimeUs; } startTimeUs += startTimeOffsetUs; + startTimeBootUs += startTimeOffsetUs; ALOGI("Start time offset: %" PRId64 " us", startTimeOffsetUs); } meta->setInt64(kKeyTime, startTimeUs); + meta->setInt64(kKeyTimeBoot, startTimeBootUs); status_t err = mSource->start(meta.get()); if (err != OK) { diff --git a/media/libstagefright/MediaCodecSource.cpp b/media/libstagefright/MediaCodecSource.cpp index adbde54..b15ee64 100644 --- a/media/libstagefright/MediaCodecSource.cpp +++ b/media/libstagefright/MediaCodecSource.cpp @@ -38,6 +38,7 @@ #include <media/stagefright/Utils.h> #include <OMX_Core.h> #include <stagefright/AVExtensions.h> +#include <cutils/properties.h> namespace android { @@ -663,8 +664,15 @@ status_t MediaCodecSource::onStart(MetaData *params) { status_t err = OK; if (mFlags & FLAG_USE_SURFACE_INPUT) { + auto key = kKeyTimeBoot; + char value[PROPERTY_VALUE_MAX]; + if (property_get("media.camera.ts.monotonic", value, "0") && + atoi(value)) { + key = kKeyTime; + } + int64_t startTimeUs; - if (!params || !params->findInt64(kKeyTime, &startTimeUs)) { + if (!params || !params->findInt64(key, &startTimeUs)) { startTimeUs = -1ll; } resume(startTimeUs); |