summaryrefslogtreecommitdiffstats
path: root/media/mp4/mp4_stream_parser.cc
diff options
context:
space:
mode:
authorstrobe@google.com <strobe@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-02 22:54:35 +0000
committerstrobe@google.com <strobe@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-02 22:54:35 +0000
commitadd0ea3389c412caf495c54433646611cafde270 (patch)
treed32060411e458921b7904ed7fe6744e100dcfb44 /media/mp4/mp4_stream_parser.cc
parent27d1b57da9b8ae6f08a95509e557a27b08b450e3 (diff)
downloadchromium_src-add0ea3389c412caf495c54433646611cafde270.zip
chromium_src-add0ea3389c412caf495c54433646611cafde270.tar.gz
chromium_src-add0ea3389c412caf495c54433646611cafde270.tar.bz2
Fix sourceAbort() for BMFF streams.
MP4StreamParser::Flush() (called eventually by sourceAbort()) did not reset the parser state, and so would only work if the call happened to come when the parser was already in a particular state (which happened to always be true for the browser test harness it was originally tested with). Additionally, the format-specific buffer conversion methods did not cause an error to be propagated to the caller on failure, resulting in unexpected success for the added test. BUG= TEST=MP4StreamParserTest.TestFlush Review URL: https://chromiumcodereview.appspot.com/10843044 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@149730 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/mp4/mp4_stream_parser.cc')
-rw-r--r--media/mp4/mp4_stream_parser.cc30
1 files changed, 21 insertions, 9 deletions
diff --git a/media/mp4/mp4_stream_parser.cc b/media/mp4/mp4_stream_parser.cc
index 67264f4..166fcc8 100644
--- a/media/mp4/mp4_stream_parser.cc
+++ b/media/mp4/mp4_stream_parser.cc
@@ -58,14 +58,20 @@ void MP4StreamParser::Init(const InitCB& init_cb,
end_of_segment_cb_ = end_of_segment_cb;
}
-void MP4StreamParser::Flush() {
- DCHECK_NE(state_, kWaitingForInit);
-
+void MP4StreamParser::Reset() {
queue_.Reset();
+ moov_.reset();
+ runs_.reset();
moof_head_ = 0;
mdat_tail_ = 0;
}
+void MP4StreamParser::Flush() {
+ DCHECK_NE(state_, kWaitingForInit);
+ Reset();
+ ChangeState(kParsingBoxes);
+}
+
bool MP4StreamParser::Parse(const uint8* buf, int size) {
DCHECK_NE(state_, kWaitingForInit);
@@ -97,9 +103,7 @@ bool MP4StreamParser::Parse(const uint8* buf, int size) {
if (err) {
DLOG(ERROR) << "Error while parsing MP4";
- queue_.Reset();
- moov_.reset();
- runs_.reset();
+ Reset();
ChangeState(kError);
return false;
}
@@ -378,8 +382,12 @@ bool MP4StreamParser::EnqueueSample(BufferQueue* audio_buffers,
std::vector<SubsampleEntry> subsamples;
if (decrypt_config.get())
subsamples = decrypt_config->subsamples();
- RCHECK(PrepareAVCBuffer(runs_->video_description().avcc,
- &frame_buf, &subsamples));
+ if (!PrepareAVCBuffer(runs_->video_description().avcc,
+ &frame_buf, &subsamples)) {
+ DLOG(ERROR) << "Failed to prepare AVC sample for decode";
+ *err = true;
+ return false;
+ }
if (!subsamples.empty()) {
decrypt_config.reset(new DecryptConfig(
decrypt_config->key_id(),
@@ -392,7 +400,11 @@ bool MP4StreamParser::EnqueueSample(BufferQueue* audio_buffers,
if (audio) {
const AAC& aac = runs_->audio_description().esds.aac;
- RCHECK(aac.ConvertEsdsToADTS(&frame_buf));
+ if (!aac.ConvertEsdsToADTS(&frame_buf)) {
+ DLOG(ERROR) << "Failed to convert ESDS to ADTS";
+ *err = true;
+ return false;
+ }
}
scoped_refptr<StreamParserBuffer> stream_buf =