diff options
Diffstat (limited to 'media')
-rw-r--r-- | media/libmediaplayerservice/StagefrightRecorder.cpp | 9 | ||||
-rw-r--r-- | media/libmediaplayerservice/StagefrightRecorder.h | 1 | ||||
-rw-r--r-- | media/libstagefright/MPEG4Writer.cpp | 34 |
3 files changed, 34 insertions, 10 deletions
diff --git a/media/libmediaplayerservice/StagefrightRecorder.cpp b/media/libmediaplayerservice/StagefrightRecorder.cpp index 9eb84d2..978571c 100644 --- a/media/libmediaplayerservice/StagefrightRecorder.cpp +++ b/media/libmediaplayerservice/StagefrightRecorder.cpp @@ -1453,6 +1453,12 @@ status_t StagefrightRecorder::setupMPEG4Recording( writer->setMaxFileSize(mMaxFileSizeBytes); } + mStartTimeOffsetMs = mEncoderProfiles->getStartTimeOffsetMs(mCameraId); + if (mStartTimeOffsetMs > 0) { + reinterpret_cast<MPEG4Writer *>(writer.get())-> + setStartTimeOffsetMs(mStartTimeOffsetMs); + } + writer->setListener(mListener); *mediaWriter = writer; return OK; @@ -1659,6 +1665,7 @@ status_t StagefrightRecorder::reset() { mAudioTimeScale = -1; mVideoTimeScale = -1; mCameraId = 0; + mStartTimeOffsetMs = -1; mVideoEncoderProfile = -1; mVideoEncoderLevel = -1; mMaxFileDurationUs = 0; @@ -1747,6 +1754,8 @@ status_t StagefrightRecorder::dump( result.append(buffer); snprintf(buffer, SIZE, " Camera Id: %d\n", mCameraId); result.append(buffer); + snprintf(buffer, SIZE, " Start time offset (ms): %d\n", mStartTimeOffsetMs); + result.append(buffer); snprintf(buffer, SIZE, " Encoder: %d\n", mVideoEncoder); result.append(buffer); snprintf(buffer, SIZE, " Encoder profile: %d\n", mVideoEncoderProfile); diff --git a/media/libmediaplayerservice/StagefrightRecorder.h b/media/libmediaplayerservice/StagefrightRecorder.h index 7795554..aa67aa7 100644 --- a/media/libmediaplayerservice/StagefrightRecorder.h +++ b/media/libmediaplayerservice/StagefrightRecorder.h @@ -99,6 +99,7 @@ private: int32_t mRotationDegrees; // Clockwise int32_t mLatitudex10000; int32_t mLongitudex10000; + int32_t mStartTimeOffsetMs; bool mCaptureTimeLapse; int64_t mTimeBetweenTimeLapseFrameCaptureUs; 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, |