summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/MPEG4Writer.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fixed an issue where the reserved free space in the file writer was larger ↵James Dong2010-10-041-2/+14
| | | | | | | | | | | | | | | than intended The problem was that even though user does not explicitly request the max file size limit via MediaRecorder.setMaxFileSize(), the file writer sets an implicit file size limit if 32-bit file offset is used on user's behalf. The reserved free space is estimated based on the file size, if the file size limit is set by the user. The fix is to add an extra bool to tell the difference between an explit requested file size and an implicit file limit and use that to set the estimated moov box size accordingly. Change-Id: I731aca6c7833aa764ed7b905edb77721577471b3
* Resilent media time stamp adjustmentJames Dong2010-10-041-24/+181
| | | | Change-Id: I13ab87c05f26bb11a3cc9bf8559f98e6ea0752db
* Turn off media time adjustment by defaultJames Dong2010-10-011-1/+1
| | | | Change-Id: I1f8021d605d0fd896e0639607a84e3f7c459612e
* Fix track duration calculation if the start timestamp is non-zeroJames Dong2010-09-271-3/+36
| | | | | | | o Updated the comments in the patch o Added some additional checks on the timestamp Change-Id: I8ad81eb6bfe358c1db5245cbb52efc905cdc234c
* Depending on our preference to write 2-byte or 4-byte NALs, patch the codec ↵Andreas Huber2010-09-231-1/+9
| | | | | | specific data 'avcC' accordingly. Change-Id: I1423923fafbcac6911218277e2bbfa068e49dcc6
* Add some explicit error log messagesJames Dong2010-09-141-5/+5
| | | | Change-Id: I8a69157b75a67f0d3c19f05775a8cb0629232299
* When 32-bit offset is used,James Dong2010-09-081-3/+4
| | | | | | | if the requested max file size is greater than the 32-bit offset limit, set the limit to the max 32-bit offset limit. Change-Id: Ie74cbed98469721d4280a0b87491e888948f0046
* Remove unused/debugging code from MP4 file writerJames Dong2010-09-031-204/+47
| | | | | | o also makes nal length in the recorded file modifiable at runtime Change-Id: I731b4dde7070d8d9628b36b523a5b2c011c7c2cf
* Better file size estimateJames Dong2010-09-021-34/+103
| | | | | | | | | When the recorded file becomes large, the metadata size can no longer be ignored. This makes it possible to save the recorded file when the storage becomes almost full at the end of the recording session. Change-Id: Ief038080f825c9946ce550949c03e914aec1e31a
* Calculate audio media drift time from AudioSourceJames Dong2010-09-011-20/+9
| | | | | | | | | | | | | | | | | | | The problem was that the time to receive an output buffer from an audio encoder is different because the encoder does not need to read from the source for all output buffers. This leads to large fluctuation in terms of wall clock duration between two neighboring audio sample outputs from the audio encoder. As a result, the media time for the video track after adjustment using the drifting changes wildly sometimes. This patch addresses this issue by only updating the media drift time when an audio source input buffer is read. the wall clock for the audio track is also calculated at the same time when the input audio buffer is read at AudioSource. bug - 2959800 Change-Id: I3174aa182f744784b540f0a7198524d4eee8bd7b
* Make sure that timestamp does not go backward in MP4 file writerJames Dong2010-08-241-2/+2
| | | | Change-Id: I90745b9df7f19d61f3ab826bf9d2419fe788554e
* Runtime dump support for MediaWriterJames Dong2010-08-231-0/+32
| | | | Change-Id: I10b2c474de612ee4cef4b7c9eae2ee1dd8c2e895
* Don't drop a late frame which may lead to missing I frames in the MP4 fileJames Dong2010-08-191-1/+15
| | | | Change-Id: I8fef1454264230c1369561670236eb0a19ae4e76
* Return error from MPEG4Writer stop() if the check on codec specific data failedJames Dong2010-08-191-0/+26
| | | | Change-Id: Icbd08eec9b4201facbad56ff2040f0830cfb0115
* Make MediaWriter stop and pause return errors if necessaryJames Dong2010-08-191-19/+50
| | | | | | | | | | | o Make the API consistent with SF framework, which the MediaSource provides a return status for stop o Also, helps to convey errors that occurred right when a premature stop() is called, leading to a potentially mal-formed output file. Change-Id: I52a932345f38570fdf8ea04d67d73dd94ccd30ef
* Change the default time scale for audio/video track during recordingJames Dong2010-08-161-8/+51
| | | | | | | | | | | and reduce rounding errors in calculating the sample duration - Default time scale for tracks other than audio is set to 90000. - Audio track by default uses the audio sampling rate as the time scale. - Default movie time scale remains to be 1000. - The default time scale values will be overwritten by a user-supplied value if exits. Change-Id: I81b40ed0626ea45e9fd24a89e21a2c5a4a2c3415
* Use audio clock as the reference media clockJames Dong2010-08-131-0/+65
| | | | | | | | | | | | o Only do this for realtime applications o Adjust other track clock based on audio clock o Assume other track uses wall clock as the media clock o Use some heuristics to reduce the size of stts box by 2/3. - also o Remove one unused key from MetaData.h Change-Id: Ib9432842627b61795b533508158c25258a527332
* Fix a crash due to unnecessary check on the codec config data for H263 video ↵James Dong2010-08-111-2/+2
| | | | | | track Change-Id: I00e8b65d25731153e4d9be6a443eeed91c8fb605
* Only check the codec specific data when the output buffer contains ↵James Dong2010-08-101-85/+6
| | | | | | | | | | | | | | kKeyIsCodecConfig in MP4 writer o Assume there is only a single output buffer containing such information. This simplifies the logic in MP4 file writer o Output SPS and PPS in the very first buffer for software AVC encoder This is to make AVC encoder work with the MP4 file writer o Add timestamp value for codec config data Change-Id: Iad27a04579e6028332429cd0bebd30976041e997
* Support multiple PPS and SPS in avcC boxJames Dong2010-08-091-27/+236
| | | | | | | | | | - Also o do not use the hard-coded profile and levels. Instead, we are using the profile and level found in the codec config data o we are not supporting FRExt profile and levels for now, which requires additional seq parameter set extension for instance. Change-Id: If695b4c996d073d8e48aa45fdd7001e9f016f375
* Fix an issue where the track duration does not include the last sample durationJames Dong2010-08-051-11/+12
| | | | Change-Id: Ib6e01c1c84ad9b7404536f9c40bf90a13340ae53
* File writer has a designated writer thread nowJames Dong2010-08-021-49/+215
| | | | | | | | + This reduces the file I/O block time for audio/video track processing - Since the file writer is buffering some output samples, the memory usage would go up, depending on how many output samples are buffered. Change-Id: I780cc5b26f4b53a5efbd643fcf9505dfc19cd4cd
* Added damr box for AMR (NB and WB) sample entryJames Dong2010-07-301-0/+10
| | | | | | - Some players, like QT, sometimes are picky about the missing sample entry Change-Id: Ia32d78e48ac9fd8af8285dbc67f0d69142ba98b4
* Eliminate the linear cost associated with mSampleSizes.size()James Dong2010-07-281-9/+15
| | | | | | | | | | | | | | - The linear cost associated with mSampleSizes.size() call causes the CPU load to increase overtime as more and more audio/video samples are recorded. - Other Lists used in the MP4 file writer may have similar issues, but the size() call is not made for each output audio/video output sample, or the size of the list is bounded (not linear to the total number of audio/video output samples). As for now, we can live with the small cost (tested with 30 minutes long recording). Change-Id: I23bd93ea4256cb0be0c1649760e39e6809eb4946
* Reduce memory usage by the MP4 file writerJames Dong2010-07-281-42/+44
| | | | | | | | | | - Don't store timestamp for each output sample - Don't store timestamp for statistical data collection if the collection of statistical data is not requested TODO: 1. Reduce CPU load by elimnating the list cost associated with List.size() call. Change-Id: I590bc17176596a65952c982574b82ee3b15b7d1c
* Interleave the audio and video by defaultJames Dong2010-07-281-2/+2
| | | | | | | | | - default interleave duration is set to 1 second This can dramatically reduce the memory usage by the MP4 file writer. Change-Id: Ia3ff202cabfcd2d3f183065d31e4596617c2dded
* Progress status notificationJames Dong2010-07-201-26/+51
| | | | | | - Keep track of per-track progress Change-Id: Ibd36f0e8c78581928c8aa2f5e23c5e7e0615c2cc
* Support user-supplied timescales for authoringJames Dong2010-07-141-39/+63
| | | | | | - also, change all the real time unit to microseconds in MPEG4Writer Change-Id: I260f512f2eb670ade7b8858a56335a5d639de756
* Support for writing the extracted data to an .mp4 file in the stagefright ↵Andreas Huber2010-07-011-1/+40
| | | | | | commandline tool. Change-Id: I972324a8fc9757e6e8116b0270ec0882106f8733
* Collect statistical data from authoring engine (second part)James Dong2010-06-281-25/+41
| | | | | | | | | | - added sample duration to the statistcal log messages. - fixed the bug on miscalcuting the average frame rate. - also fixed an issue where both frame and time progress status notifications are sent out even though only one of them is explicitly requsted. Change-Id: Ib86f15a85fad3dbeabde120c3c782b79c16da46c
* Provide progress status report during authoringJames Dong2010-06-251-11/+79
| | | | | | | | | - Track either the number of A/V frames authored, or the time elapsed - Track the completion of the authoring - Add multiple camera support for authoring by accepting a camera id parameter - Set file type based on the OUTPUT_FORMAT requested Change-Id: I0f9d31b3b7a8fa43eb53f572410fb0ebd4fa0bb7
* Enable passing parameters to the MediaWriter at runtime (at start() call).James Dong2010-06-251-6/+70
| | | | | | | | | | - estimate the moov box size for mp4 file writer based on the file size/duration limit and target bit rate. - can switch to use 64 bit file offset at runtime rebased Change-Id: Ibbe1f57e91ab2605820d5d96e8048d11e5559c53
* Fixed the software AAC encoderJames Dong2010-06-231-3/+2
| | | | | | | Make sure that each input frame contains at least 1024 samples, as required by the AAC encoder, and fix the incorrect timestamp. Change-Id: I344cafe8c89be51d6e64552fab70539990ff6049
* Fixed some meta data issues in the recorded mp4 fileJames Dong2010-06-231-31/+68
| | | | | | | | | | | | | | - Mainly correcting the location of stbl box which should be a child of minf box. This resolved the issue where the mis-muxed encoded file could not be played by QT/VLC. - Enabled the the recorded tracks by setting the flags to 0x07 by default - Allows for encoding either 32-bit or 64-bit offsets. By default encoding 32-bit offsets to reduce the metadata overhead - Fixed a edts box issue where an empty elst box was used at the end Change-Id: I570621a26714a81dc9400271aa5d3a07b483172f
* Single track optimizationJames Dong2010-06-221-1/+19
| | | | | | | | We don't need to do interleave when the total number of tracks to be recorded is one. Metadata-wise, we only need to have one chunk in chunk offset table, and a single entry in the stsc table. Change-Id: I46f0e4b3860620311e7a91b68a9067acaa137bb2
* Audio/video sync during recording (second part)James Dong2010-06-211-16/+24
| | | | Change-Id: Iba0b35f57fdeac7ee1da16899406bf4b957a2c8c
* Initial checkin for pause and resume controlJames Dong2010-06-111-12/+81
| | | | Change-Id: Ibdcf7bea5fb66baa81878704ba4091dfcfe382ee
* Initial check-in for collecting stats from authoring engine at runtimeJames Dong2010-06-081-0/+88
| | | | Change-Id: I93a9d8bd260efc5e7fc135b726e3f1307c6df794
* Second part of speeding up video recording frame rateJames Dong2010-06-081-23/+25
| | | | | | | | | | | | | | 1. Avoid copying the input recording frames to the encoder via OMX interface for TI video encoder This is a missing change for part one which help reduces the CPU load. 2. Release output buffers as early as possible. This is a little bit helpful, but not critical. TODO: We should save the underlying pointers allocated by the OMX component before we replace them and restore them before we call OMX_FreeBuffer()! Change-Id: Ib3a88978f4c3b1153808872eaa7ac4c265a811ff
* Properly handle start code in H264/AVC encoder outputJames Dong2010-05-201-2/+2
| | | | | | | | - Some H264/AVC encoder output start code in each output buffer, and others don't. This patch always strips the start code first so that the sample contains the correct size. - Also properly initialize the interleave duration. Change-Id: I692043ce7e38f0215e1097aad9e847a57907b6e4
* Initial software encoder checkinsJames Dong2010-05-191-7/+8
| | | | Change-Id: I27f387db23594e46384c4eb3a0093ce220bb6b60
* Detect and handle premature termination of a recording sessionJames Dong2010-05-141-1/+3
| | | | Change-Id: Ifb83b19f3e68580345b23efed5d5956fb81baeb8
* Audio/video initial recording time synchronizationJames Dong2010-05-141-0/+34
| | | | Change-Id: Iac58b63d474fe09c1d36ba6ecde91dafbb7fef9a
* Handle recording file size and/or duration limitJames Dong2010-05-141-0/+52
| | | | Change-Id: Ib9ed1f3ebd8fef550cc130a7ef11f2905fa9aedc
* Output streamable MP4 file during MP4 file recordingJames Dong2010-05-111-24/+100
| | | | | | | When the reserved moov box space is not big enough, fall back to non-streamable MP4 file. Change-Id: I93382d037d657a3f3fe2af31e4ea26e1898b4d95
* Metadata construction optimizationJames Dong2010-05-061-38/+65
| | | | | | | - Potentially much shorter stts box if samples have roughly the same duration - Potentially much shorter stsz box if all samples have the same size Change-Id: I4f7663dd64285070995585a02bb3ba1e1049a0cf
* Support audio and video track interleaving in the recorded mp4 fileJames Dong2010-05-051-33/+116
| | | | Change-Id: Ifa27eb23ee265f84fe06773b29b0eb2b0b075b60
* Support AAC recordingJames Dong2010-05-031-22/+85
| | | | | | | | - Extend the audio recording to AAC format - Add support for setting some recording parameters - Add stss box to the meta data in the recorded file Change-Id: I41167bfd9d70ef9cd33906f8437b39c232b6d3b7
* I accidentally broken passion encoding while working around problems with ↵Andreas Huber2010-04-091-8/+58
| | | | | | the sholes encoder. Change-Id: Id91b837ed17083cb21efb08e1c1ab9cc3ff3fa8f
* Various fixes to enable recording on passion and nexus1.Andreas Huber2010-04-091-40/+185
| | | | Change-Id: I75a461c9882e2449082ad754ee7b231c1ceec039