Loading include/media/mediarecorder.h +3 −1 Original line number Diff line number Diff line Loading @@ -136,7 +136,9 @@ enum media_recorder_info_type { MEDIA_RECORDER_INFO_UNKNOWN = 1, MEDIA_RECORDER_INFO_MAX_DURATION_REACHED = 800, MEDIA_RECORDER_INFO_MAX_FILESIZE_REACHED = 801, MEDIA_RECORDER_INFO_STOP_PREMATURELY = 802 MEDIA_RECORDER_INFO_COMPLETION_STATUS = 802, MEDIA_RECORDER_INFO_PROGRESS_FRAME_STATUS = 803, MEDIA_RECORDER_INFO_PROGRESS_TIME_STATUS = 804, }; // ---------------------------------------------------------------------------- Loading include/media/stagefright/MPEG4Writer.h +1 −1 Original line number Diff line number Diff line Loading @@ -81,7 +81,7 @@ private: void setStartTimestampUs(int64_t timeUs); int64_t getStartTimestampUs(); // Not const status_t startTracks(); status_t startTracks(MetaData *params); size_t numTracks(); int64_t estimateMoovBoxSize(int32_t bitRate); Loading include/media/stagefright/MetaData.h +15 −1 Original line number Diff line number Diff line Loading @@ -43,7 +43,6 @@ enum { kKeyVorbisInfo = 'vinf', // raw data kKeyVorbisBooks = 'vboo', // raw data kKeyWantsNALFragments = 'NALf', kKey64BitFileOffset = 'fobt', // int32_t (bool) kKeyIsSyncFrame = 'sync', // int32_t (bool) kKeyIsCodecConfig = 'conf', // int32_t (bool) kKeyTime = 'time', // int64_t (usecs) Loading @@ -69,6 +68,21 @@ enum { kKeyDiscNumber = 'dnum', // cstring kKeyDate = 'date', // cstring kKeyWriter = 'writ', // cstring // Set this key to enable authoring files in 64-bit offset kKey64BitFileOffset = 'fobt', // int32_t (bool) // Identify the file output format for authoring // Please see <media/mediarecorder.h> for the supported // file output formats. kKeyFileType = 'ftyp', // int32_t // Track authoring progress status // kKeyTrackTimeStatus is used to track progress in elapsed time // kKeyTrackFrameStatus is used to track progress in authored frames kKeyTrackFrameStatus = 'tkfm', // int32_t kKeyTrackTimeStatus = 'tktm', // int64_t }; enum { Loading media/libmediaplayerservice/StagefrightRecorder.cpp +67 −14 Original line number Diff line number Diff line Loading @@ -310,8 +310,8 @@ status_t StagefrightRecorder::setParamInterleaveDuration(int32_t durationUs) { // If interval < 0, only the first frame is I frame, and rest are all P frames // If interval == 0, all frames are encoded as I frames. No P frames // If interval > 0, it is the time spacing between 2 neighboring I frames status_t StagefrightRecorder::setParamIFramesInterval(int32_t interval) { LOGV("setParamIFramesInterval: %d seconds", interval); status_t StagefrightRecorder::setParamVideoIFramesInterval(int32_t interval) { LOGV("setParamVideoIFramesInterval: %d seconds", interval); mIFramesInterval = interval; return OK; } Loading @@ -323,6 +323,33 @@ status_t StagefrightRecorder::setParam64BitFileOffset(bool use64Bit) { return OK; } status_t StagefrightRecorder::setParamVideoCameraId(int32_t cameraId) { LOGV("setParamVideoCameraId: %d", cameraId); if (cameraId < 0) { return BAD_VALUE; } mCameraId = cameraId; return OK; } status_t StagefrightRecorder::setParamTrackFrameStatus(int32_t nFrames) { LOGV("setParamTrackFrameStatus: %d", nFrames); if (nFrames <= 0) { return BAD_VALUE; } mTrackEveryNumberOfFrames = nFrames; return OK; } status_t StagefrightRecorder::setParamTrackTimeStatus(int64_t timeDurationUs) { LOGV("setParamTrackTimeStatus: %lld", timeDurationUs); if (timeDurationUs < 20000) { // Infeasible if shorter than 20 ms? return BAD_VALUE; } mTrackEveryTimeDurationUs = timeDurationUs; return OK; } status_t StagefrightRecorder::setParameter( const String8 &key, const String8 &value) { LOGV("setParameter: key (%s) => value (%s)", key.string(), value.string()); Loading @@ -338,6 +365,26 @@ status_t StagefrightRecorder::setParameter( return setParamMaxDurationOrFileSize( max_filesize_bytes, false /* limit is filesize */); } } else if (key == "interleave-duration-us") { int32_t durationUs; if (safe_strtoi32(value.string(), &durationUs)) { return setParamInterleaveDuration(durationUs); } } else if (key == "param-use-64bit-offset") { int32_t use64BitOffset; if (safe_strtoi32(value.string(), &use64BitOffset)) { return setParam64BitFileOffset(use64BitOffset != 0); } } else if (key == "param-track-frame-status") { int32_t nFrames; if (safe_strtoi32(value.string(), &nFrames)) { return setParamTrackFrameStatus(nFrames); } } else if (key == "param-track-time-status") { int64_t timeDurationUs; if (safe_strtoi64(value.string(), &timeDurationUs)) { return setParamTrackTimeStatus(timeDurationUs); } } else if (key == "audio-param-sampling-rate") { int32_t sampling_rate; if (safe_strtoi32(value.string(), &sampling_rate)) { Loading @@ -358,20 +405,15 @@ status_t StagefrightRecorder::setParameter( if (safe_strtoi32(value.string(), &video_bitrate)) { return setParamVideoEncodingBitRate(video_bitrate); } } else if (key == "param-interleave-duration-us") { int32_t durationUs; if (safe_strtoi32(value.string(), &durationUs)) { return setParamInterleaveDuration(durationUs); } } else if (key == "param-i-frames-interval") { } else if (key == "video-param-i-frames-interval") { int32_t interval; if (safe_strtoi32(value.string(), &interval)) { return setParamIFramesInterval(interval); return setParamVideoIFramesInterval(interval); } } else if (key == "param-use-64bit-offset") { int32_t use64BitOffset; if (safe_strtoi32(value.string(), &use64BitOffset)) { return setParam64BitFileOffset(use64BitOffset != 0); } else if (key == "video-param-camera-id") { int32_t cameraId; if (safe_strtoi32(value.string(), &cameraId)) { return setParamVideoCameraId(cameraId); } } else { LOGE("setParameter: failed to find key %s", key.string()); Loading Loading @@ -677,7 +719,7 @@ status_t StagefrightRecorder::startMPEG4Recording() { int64_t token = IPCThreadState::self()->clearCallingIdentity(); if (mCamera == 0) { mCamera = Camera::connect(0); mCamera = Camera::connect(mCameraId); mCamera->lock(); } Loading Loading @@ -778,8 +820,16 @@ status_t StagefrightRecorder::startMPEG4Recording() { } mWriter->setListener(mListener); sp<MetaData> meta = new MetaData; meta->setInt64(kKeyTime, systemTime() / 1000); meta->setInt32(kKeyFileType, mOutputFormat); meta->setInt32(kKeyBitRate, totalBitRate); meta->setInt32(kKey64BitFileOffset, mUse64BitFileOffset); if (mTrackEveryNumberOfFrames > 0) { meta->setInt32(kKeyTrackFrameStatus, mTrackEveryNumberOfFrames); } if (mTrackEveryTimeDurationUs > 0) { meta->setInt64(kKeyTrackTimeStatus, mTrackEveryTimeDurationUs); } mWriter->start(meta.get()); return OK; } Loading Loading @@ -842,6 +892,9 @@ status_t StagefrightRecorder::reset() { mIFramesInterval = 1; mAudioSourceNode = 0; mUse64BitFileOffset = false; mCameraId = 0; mTrackEveryNumberOfFrames = 0; mTrackEveryTimeDurationUs = 0; mEncoderProfiles = MediaProfiles::getInstance(); mOutputFd = -1; Loading media/libmediaplayerservice/StagefrightRecorder.h +8 −2 Original line number Diff line number Diff line Loading @@ -81,8 +81,11 @@ private: int32_t mSampleRate; int32_t mInterleaveDurationUs; int32_t mIFramesInterval; int32_t mCameraId; int64_t mMaxFileSizeBytes; int64_t mMaxFileDurationUs; int32_t mTrackEveryNumberOfFrames; int64_t mTrackEveryTimeDurationUs; String8 mParams; int mOutputFd; Loading @@ -95,12 +98,15 @@ private: status_t startAACRecording(); sp<MediaSource> createAudioSource(); status_t setParameter(const String8 &key, const String8 &value); status_t setParamVideoEncodingBitRate(int32_t bitRate); status_t setParamAudioEncodingBitRate(int32_t bitRate); status_t setParamAudioNumberOfChannels(int32_t channles); status_t setParamAudioSamplingRate(int32_t sampleRate); status_t setParamVideoEncodingBitRate(int32_t bitRate); status_t setParamVideoIFramesInterval(int32_t interval); status_t setParamVideoCameraId(int32_t cameraId); status_t setParamTrackTimeStatus(int64_t timeDurationUs); status_t setParamTrackFrameStatus(int32_t nFrames); status_t setParamInterleaveDuration(int32_t durationUs); status_t setParamIFramesInterval(int32_t interval); status_t setParam64BitFileOffset(bool use64BitFileOffset); status_t setParamMaxDurationOrFileSize(int64_t limit, bool limit_is_duration); void clipVideoBitRate(); Loading Loading
include/media/mediarecorder.h +3 −1 Original line number Diff line number Diff line Loading @@ -136,7 +136,9 @@ enum media_recorder_info_type { MEDIA_RECORDER_INFO_UNKNOWN = 1, MEDIA_RECORDER_INFO_MAX_DURATION_REACHED = 800, MEDIA_RECORDER_INFO_MAX_FILESIZE_REACHED = 801, MEDIA_RECORDER_INFO_STOP_PREMATURELY = 802 MEDIA_RECORDER_INFO_COMPLETION_STATUS = 802, MEDIA_RECORDER_INFO_PROGRESS_FRAME_STATUS = 803, MEDIA_RECORDER_INFO_PROGRESS_TIME_STATUS = 804, }; // ---------------------------------------------------------------------------- Loading
include/media/stagefright/MPEG4Writer.h +1 −1 Original line number Diff line number Diff line Loading @@ -81,7 +81,7 @@ private: void setStartTimestampUs(int64_t timeUs); int64_t getStartTimestampUs(); // Not const status_t startTracks(); status_t startTracks(MetaData *params); size_t numTracks(); int64_t estimateMoovBoxSize(int32_t bitRate); Loading
include/media/stagefright/MetaData.h +15 −1 Original line number Diff line number Diff line Loading @@ -43,7 +43,6 @@ enum { kKeyVorbisInfo = 'vinf', // raw data kKeyVorbisBooks = 'vboo', // raw data kKeyWantsNALFragments = 'NALf', kKey64BitFileOffset = 'fobt', // int32_t (bool) kKeyIsSyncFrame = 'sync', // int32_t (bool) kKeyIsCodecConfig = 'conf', // int32_t (bool) kKeyTime = 'time', // int64_t (usecs) Loading @@ -69,6 +68,21 @@ enum { kKeyDiscNumber = 'dnum', // cstring kKeyDate = 'date', // cstring kKeyWriter = 'writ', // cstring // Set this key to enable authoring files in 64-bit offset kKey64BitFileOffset = 'fobt', // int32_t (bool) // Identify the file output format for authoring // Please see <media/mediarecorder.h> for the supported // file output formats. kKeyFileType = 'ftyp', // int32_t // Track authoring progress status // kKeyTrackTimeStatus is used to track progress in elapsed time // kKeyTrackFrameStatus is used to track progress in authored frames kKeyTrackFrameStatus = 'tkfm', // int32_t kKeyTrackTimeStatus = 'tktm', // int64_t }; enum { Loading
media/libmediaplayerservice/StagefrightRecorder.cpp +67 −14 Original line number Diff line number Diff line Loading @@ -310,8 +310,8 @@ status_t StagefrightRecorder::setParamInterleaveDuration(int32_t durationUs) { // If interval < 0, only the first frame is I frame, and rest are all P frames // If interval == 0, all frames are encoded as I frames. No P frames // If interval > 0, it is the time spacing between 2 neighboring I frames status_t StagefrightRecorder::setParamIFramesInterval(int32_t interval) { LOGV("setParamIFramesInterval: %d seconds", interval); status_t StagefrightRecorder::setParamVideoIFramesInterval(int32_t interval) { LOGV("setParamVideoIFramesInterval: %d seconds", interval); mIFramesInterval = interval; return OK; } Loading @@ -323,6 +323,33 @@ status_t StagefrightRecorder::setParam64BitFileOffset(bool use64Bit) { return OK; } status_t StagefrightRecorder::setParamVideoCameraId(int32_t cameraId) { LOGV("setParamVideoCameraId: %d", cameraId); if (cameraId < 0) { return BAD_VALUE; } mCameraId = cameraId; return OK; } status_t StagefrightRecorder::setParamTrackFrameStatus(int32_t nFrames) { LOGV("setParamTrackFrameStatus: %d", nFrames); if (nFrames <= 0) { return BAD_VALUE; } mTrackEveryNumberOfFrames = nFrames; return OK; } status_t StagefrightRecorder::setParamTrackTimeStatus(int64_t timeDurationUs) { LOGV("setParamTrackTimeStatus: %lld", timeDurationUs); if (timeDurationUs < 20000) { // Infeasible if shorter than 20 ms? return BAD_VALUE; } mTrackEveryTimeDurationUs = timeDurationUs; return OK; } status_t StagefrightRecorder::setParameter( const String8 &key, const String8 &value) { LOGV("setParameter: key (%s) => value (%s)", key.string(), value.string()); Loading @@ -338,6 +365,26 @@ status_t StagefrightRecorder::setParameter( return setParamMaxDurationOrFileSize( max_filesize_bytes, false /* limit is filesize */); } } else if (key == "interleave-duration-us") { int32_t durationUs; if (safe_strtoi32(value.string(), &durationUs)) { return setParamInterleaveDuration(durationUs); } } else if (key == "param-use-64bit-offset") { int32_t use64BitOffset; if (safe_strtoi32(value.string(), &use64BitOffset)) { return setParam64BitFileOffset(use64BitOffset != 0); } } else if (key == "param-track-frame-status") { int32_t nFrames; if (safe_strtoi32(value.string(), &nFrames)) { return setParamTrackFrameStatus(nFrames); } } else if (key == "param-track-time-status") { int64_t timeDurationUs; if (safe_strtoi64(value.string(), &timeDurationUs)) { return setParamTrackTimeStatus(timeDurationUs); } } else if (key == "audio-param-sampling-rate") { int32_t sampling_rate; if (safe_strtoi32(value.string(), &sampling_rate)) { Loading @@ -358,20 +405,15 @@ status_t StagefrightRecorder::setParameter( if (safe_strtoi32(value.string(), &video_bitrate)) { return setParamVideoEncodingBitRate(video_bitrate); } } else if (key == "param-interleave-duration-us") { int32_t durationUs; if (safe_strtoi32(value.string(), &durationUs)) { return setParamInterleaveDuration(durationUs); } } else if (key == "param-i-frames-interval") { } else if (key == "video-param-i-frames-interval") { int32_t interval; if (safe_strtoi32(value.string(), &interval)) { return setParamIFramesInterval(interval); return setParamVideoIFramesInterval(interval); } } else if (key == "param-use-64bit-offset") { int32_t use64BitOffset; if (safe_strtoi32(value.string(), &use64BitOffset)) { return setParam64BitFileOffset(use64BitOffset != 0); } else if (key == "video-param-camera-id") { int32_t cameraId; if (safe_strtoi32(value.string(), &cameraId)) { return setParamVideoCameraId(cameraId); } } else { LOGE("setParameter: failed to find key %s", key.string()); Loading Loading @@ -677,7 +719,7 @@ status_t StagefrightRecorder::startMPEG4Recording() { int64_t token = IPCThreadState::self()->clearCallingIdentity(); if (mCamera == 0) { mCamera = Camera::connect(0); mCamera = Camera::connect(mCameraId); mCamera->lock(); } Loading Loading @@ -778,8 +820,16 @@ status_t StagefrightRecorder::startMPEG4Recording() { } mWriter->setListener(mListener); sp<MetaData> meta = new MetaData; meta->setInt64(kKeyTime, systemTime() / 1000); meta->setInt32(kKeyFileType, mOutputFormat); meta->setInt32(kKeyBitRate, totalBitRate); meta->setInt32(kKey64BitFileOffset, mUse64BitFileOffset); if (mTrackEveryNumberOfFrames > 0) { meta->setInt32(kKeyTrackFrameStatus, mTrackEveryNumberOfFrames); } if (mTrackEveryTimeDurationUs > 0) { meta->setInt64(kKeyTrackTimeStatus, mTrackEveryTimeDurationUs); } mWriter->start(meta.get()); return OK; } Loading Loading @@ -842,6 +892,9 @@ status_t StagefrightRecorder::reset() { mIFramesInterval = 1; mAudioSourceNode = 0; mUse64BitFileOffset = false; mCameraId = 0; mTrackEveryNumberOfFrames = 0; mTrackEveryTimeDurationUs = 0; mEncoderProfiles = MediaProfiles::getInstance(); mOutputFd = -1; Loading
media/libmediaplayerservice/StagefrightRecorder.h +8 −2 Original line number Diff line number Diff line Loading @@ -81,8 +81,11 @@ private: int32_t mSampleRate; int32_t mInterleaveDurationUs; int32_t mIFramesInterval; int32_t mCameraId; int64_t mMaxFileSizeBytes; int64_t mMaxFileDurationUs; int32_t mTrackEveryNumberOfFrames; int64_t mTrackEveryTimeDurationUs; String8 mParams; int mOutputFd; Loading @@ -95,12 +98,15 @@ private: status_t startAACRecording(); sp<MediaSource> createAudioSource(); status_t setParameter(const String8 &key, const String8 &value); status_t setParamVideoEncodingBitRate(int32_t bitRate); status_t setParamAudioEncodingBitRate(int32_t bitRate); status_t setParamAudioNumberOfChannels(int32_t channles); status_t setParamAudioSamplingRate(int32_t sampleRate); status_t setParamVideoEncodingBitRate(int32_t bitRate); status_t setParamVideoIFramesInterval(int32_t interval); status_t setParamVideoCameraId(int32_t cameraId); status_t setParamTrackTimeStatus(int64_t timeDurationUs); status_t setParamTrackFrameStatus(int32_t nFrames); status_t setParamInterleaveDuration(int32_t durationUs); status_t setParamIFramesInterval(int32_t interval); status_t setParam64BitFileOffset(bool use64BitFileOffset); status_t setParamMaxDurationOrFileSize(int64_t limit, bool limit_is_duration); void clipVideoBitRate(); Loading