summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/MPEG4Writer.cpp
diff options
context:
space:
mode:
authorJames Dong <jdong@google.com>2011-05-09 16:56:25 -0700
committerJames Dong <jdong@google.com>2011-05-14 07:18:43 -0700
commit86b7f47aa7482424cf8fd248f1315311919be3b0 (patch)
treeddc0e28c8736a20d20bcd87f652cecf4bc18e7b6 /media/libstagefright/MPEG4Writer.cpp
parent9b1e4f1a18ac2489e24b4272a0a7ccfd0018efcc (diff)
downloadframeworks_av-86b7f47aa7482424cf8fd248f1315311919be3b0.zip
frameworks_av-86b7f47aa7482424cf8fd248f1315311919be3b0.tar.gz
frameworks_av-86b7f47aa7482424cf8fd248f1315311919be3b0.tar.bz2
Support platform and camera dependent recording start time offset
related-to-bug: 4390777 Change-Id: Icb52973ad4ac716f04fb103ef527915a966d06d5
Diffstat (limited to 'media/libstagefright/MPEG4Writer.cpp')
-rw-r--r--media/libstagefright/MPEG4Writer.cpp34
1 files changed, 24 insertions, 10 deletions
diff --git a/media/libstagefright/MPEG4Writer.cpp b/media/libstagefright/MPEG4Writer.cpp
index 63878b7..9dc83a6 100644
--- a/media/libstagefright/MPEG4Writer.cpp
+++ b/media/libstagefright/MPEG4Writer.cpp
@@ -260,7 +260,8 @@ MPEG4Writer::MPEG4Writer(const char *filename)
mInterleaveDurationUs(1000000),
mLatitudex10000(0),
mLongitudex10000(0),
- mAreGeoTagsAvailable(false) {
+ mAreGeoTagsAvailable(false),
+ mStartTimeOffsetMs(-1) {
mFd = open(filename, O_CREAT | O_LARGEFILE | O_TRUNC | O_RDWR);
if (mFd >= 0) {
@@ -282,7 +283,8 @@ MPEG4Writer::MPEG4Writer(int fd)
mInterleaveDurationUs(1000000),
mLatitudex10000(0),
mLongitudex10000(0),
- mAreGeoTagsAvailable(false) {
+ mAreGeoTagsAvailable(false),
+ mStartTimeOffsetMs(-1) {
}
MPEG4Writer::~MPEG4Writer() {
@@ -1425,10 +1427,15 @@ status_t MPEG4Writer::Track::start(MetaData *params) {
* session, and it also helps eliminate the "recording" sound for
* camcorder applications.
*
- * Ideally, this platform-specific value should be defined
- * in media_profiles.xml file
+ * If client does not set the start time offset, we fall back to
+ * use the default initial delay value.
*/
- startTimeUs += kInitialDelayTimeUs;
+ int64_t startTimeOffsetUs = mOwner->getStartTimeOffsetMs() * 1000LL;
+ if (startTimeOffsetUs < 0) { // Start time offset was not set
+ startTimeOffsetUs = kInitialDelayTimeUs;
+ }
+ startTimeUs += startTimeOffsetUs;
+ LOGI("Start time offset: %lld us", startTimeOffsetUs);
}
meta->setInt64(kKeyTime, startTimeUs);
@@ -2234,13 +2241,20 @@ void MPEG4Writer::Track::sendTrackSummary(bool hasMultipleTracks) {
trackNum | MEDIA_RECORDER_TRACK_INFO_ENCODED_FRAMES,
mNumSamples);
- // The system delay time excluding the requested initial delay that
- // is used to eliminate the recording sound.
- int64_t initialDelayUs =
- mFirstSampleTimeRealUs - mStartTimeRealUs - kInitialDelayTimeUs;
- mOwner->notify(MEDIA_RECORDER_TRACK_EVENT_INFO,
+ {
+ // The system delay time excluding the requested initial delay that
+ // is used to eliminate the recording sound.
+ int64_t startTimeOffsetUs = mOwner->getStartTimeOffsetMs() * 1000LL;
+ if (startTimeOffsetUs < 0) { // Start time offset was not set
+ startTimeOffsetUs = kInitialDelayTimeUs;
+ }
+ int64_t initialDelayUs =
+ mFirstSampleTimeRealUs - mStartTimeRealUs - startTimeOffsetUs;
+
+ mOwner->notify(MEDIA_RECORDER_TRACK_EVENT_INFO,
trackNum | MEDIA_RECORDER_TRACK_INFO_INITIAL_DELAY_MS,
(initialDelayUs) / 1000);
+ }
if (hasMultipleTracks) {
mOwner->notify(MEDIA_RECORDER_TRACK_EVENT_INFO,