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

Side by Side Diff: media/mp4/mp4_stream_parser.cc

Issue 10660005: Flush sample buffers when reading new segments in Media Source BMFF parser. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 6 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 unified diff | Download patch
« no previous file with comments | « no previous file | media/mp4/mp4_stream_parser_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/mp4/mp4_stream_parser.h" 5 #include "media/mp4/mp4_stream_parser.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/time.h" 9 #include "base/time.h"
10 #include "media/base/audio_decoder_config.h" 10 #include "media/base/audio_decoder_config.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 69
70 queue_.Push(buf, size); 70 queue_.Push(buf, size);
71 71
72 BufferQueue audio_buffers; 72 BufferQueue audio_buffers;
73 BufferQueue video_buffers; 73 BufferQueue video_buffers;
74 74
75 bool result, err = false; 75 bool result, err = false;
76 76
77 do { 77 do {
78 if (state_ == kParsingBoxes) { 78 if (state_ == kParsingBoxes) {
79 // Flush any buffers we've gotten in this chunk so that buffers don't
acolwell GONE FROM CHROMIUM 2012/06/25 21:22:16 It might be clearer to place this logic in Enqueue
strobe_ 2012/06/26 00:37:59 Done.
80 // cross NewSegment() calls
81 if (!audio_buffers.empty()) {
acolwell GONE FROM CHROMIUM 2012/06/25 21:22:16 This isn't sufficient. You need to do all the same
strobe_ 2012/06/26 00:37:59 What checks are missing here as compared to below?
acolwell GONE FROM CHROMIUM 2012/06/26 15:25:14 Sorry. The CHECK/DCHECK here was actually inapprop
82 CHECK(!audio_cb_.is_null());
acolwell GONE FROM CHROMIUM 2012/06/25 21:22:16 Use DCHECK here and below. Let the null pointer ex
strobe_ 2012/06/26 00:37:59 Done. (well, moved into the shared error condition
83 RCHECK(audio_cb_.Run(audio_buffers));
84 audio_buffers.clear();
85 }
86 if (!video_buffers.empty()) {
87 CHECK(!video_cb_.is_null());
88 RCHECK(video_cb_.Run(video_buffers));
89 video_buffers.clear();
90 }
91
79 if (mdat_tail_ > queue_.head()) { 92 if (mdat_tail_ > queue_.head()) {
80 result = queue_.Trim(mdat_tail_); 93 result = queue_.Trim(mdat_tail_);
81 } else { 94 } else {
82 result = ParseBox(&err); 95 result = ParseBox(&err);
83 } 96 }
84 } else { 97 } else {
85 DCHECK_EQ(kEmittingSamples, state_); 98 DCHECK_EQ(kEmittingSamples, state_);
86 result = EnqueueSample(&audio_buffers, &video_buffers, &err); 99 result = EnqueueSample(&audio_buffers, &video_buffers, &err);
87 if (result) { 100 if (result) {
88 int64 max_clear = runs_.GetMaxClearOffset() + moof_head_; 101 int64 max_clear = runs_.GetMaxClearOffset() + moof_head_;
89 DCHECK(max_clear <= queue_.tail()); 102 DCHECK(max_clear <= queue_.tail());
90 err = !(ReadMDATsUntil(max_clear) && queue_.Trim(max_clear)); 103 err = !(ReadMDATsUntil(max_clear) && queue_.Trim(max_clear));
91 } 104 }
92 } 105 }
93 } while (result && !err); 106 } while (result && !err);
94 107
95 if (err) { 108 if (err) {
96 DLOG(ERROR) << "Unknown error while parsing MP4"; 109 DLOG(ERROR) << "Unknown error while parsing MP4";
97 queue_.Reset(); 110 queue_.Reset();
98 moov_.reset(); 111 moov_.reset();
99 ChangeState(kError); 112 ChangeState(kError);
100 return false; 113 return false;
101 } 114 }
102 115
103 if (!audio_buffers.empty() && 116 if (!audio_buffers.empty() &&
104 (audio_cb_.is_null() || !audio_cb_.Run(audio_buffers))) 117 (audio_cb_.is_null() || !audio_cb_.Run(audio_buffers)))
105 return false; 118 return false;
acolwell GONE FROM CHROMIUM 2012/06/25 21:22:16 You should have a ChangeState(kError) here and bel
strobe_ 2012/06/26 00:37:59 Done.
106 if (!video_buffers.empty() && 119 if (!video_buffers.empty() &&
107 (video_cb_.is_null() || !video_cb_.Run(video_buffers))) 120 (video_cb_.is_null() || !video_cb_.Run(video_buffers)))
108 return false; 121 return false;
109 122
110 return true; 123 return true;
111 } 124 }
112 125
113 bool MP4StreamParser::ParseBox(bool* err) { 126 bool MP4StreamParser::ParseBox(bool* err) {
114 const uint8* buf; 127 const uint8* buf;
115 int size; 128 int size;
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 return true; 349 return true;
337 } 350 }
338 351
339 void MP4StreamParser::ChangeState(State new_state) { 352 void MP4StreamParser::ChangeState(State new_state) {
340 DVLOG(2) << "Changing state: " << new_state; 353 DVLOG(2) << "Changing state: " << new_state;
341 state_ = new_state; 354 state_ = new_state;
342 } 355 }
343 356
344 } // namespace mp4 357 } // namespace mp4
345 } // namespace media 358 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | media/mp4/mp4_stream_parser_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698