Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1330)

Unified Diff: media/mp4/mp4_stream_parser.cc

Issue 10834101: Fix MP4StreamParser discard behavior when retaining 'moof'. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tgt_offset -> offset Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/mp4/mp4_stream_parser.h ('k') | media/mp4/mp4_stream_parser_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/mp4/mp4_stream_parser.cc
diff --git a/media/mp4/mp4_stream_parser.cc b/media/mp4/mp4_stream_parser.cc
index d153d69161e00df969ab933bd26ebfd07c020a3b..ca8ef63a705dda8294d4d896f0f28f81f6f20b4e 100644
--- a/media/mp4/mp4_stream_parser.cc
+++ b/media/mp4/mp4_stream_parser.cc
@@ -86,8 +86,7 @@ bool MP4StreamParser::Parse(const uint8* buf, int size) {
result = EnqueueSample(&audio_buffers, &video_buffers, &err);
if (result) {
int64 max_clear = runs_->GetMaxClearOffset() + moof_head_;
- DCHECK(max_clear <= queue_.tail());
- err = !(ReadMDATsUntil(max_clear) && queue_.Trim(max_clear));
+ err = !ReadAndDiscardMDATsUntil(max_clear);
}
}
} while (result && !err);
@@ -438,29 +437,26 @@ bool MP4StreamParser::SendAndFlushSamples(BufferQueue* audio_buffers,
return !err;
}
-bool MP4StreamParser::ReadMDATsUntil(const int64 tgt_offset) {
- DCHECK(tgt_offset <= queue_.tail());
-
- while (mdat_tail_ < tgt_offset) {
+bool MP4StreamParser::ReadAndDiscardMDATsUntil(const int64 offset) {
+ bool err = false;
+ while (mdat_tail_ < offset) {
const uint8* buf;
int size;
queue_.PeekAt(mdat_tail_, &buf, &size);
FourCC type;
int box_sz;
- bool err;
if (!BoxReader::StartTopLevelBox(buf, size, &type, &box_sz, &err))
- return false;
+ break;
if (type != FOURCC_MDAT) {
DLOG(WARNING) << "Unexpected type while parsing MDATs: "
<< FourCCToString(type);
}
-
mdat_tail_ += box_sz;
}
-
- return true;
+ queue_.Trim(std::min(mdat_tail_, offset));
+ return !err;
}
void MP4StreamParser::ChangeState(State new_state) {
« no previous file with comments | « media/mp4/mp4_stream_parser.h ('k') | media/mp4/mp4_stream_parser_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698