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

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

Issue 10803019: Chrome-side implementation of media source timestamp offset (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move logic from parser to demuxer 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 unified diff | Download patch | Annotate | Revision Log
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/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/time.h" 10 #include "base/time.h"
(...skipping 19 matching lines...) Expand all
30 size_of_nalu_length_(0) { 30 size_of_nalu_length_(0) {
31 } 31 }
32 32
33 MP4StreamParser::~MP4StreamParser() {} 33 MP4StreamParser::~MP4StreamParser() {}
34 34
35 void MP4StreamParser::Init(const InitCB& init_cb, 35 void MP4StreamParser::Init(const InitCB& init_cb,
36 const NewConfigCB& config_cb, 36 const NewConfigCB& config_cb,
37 const NewBuffersCB& audio_cb, 37 const NewBuffersCB& audio_cb,
38 const NewBuffersCB& video_cb, 38 const NewBuffersCB& video_cb,
39 const NeedKeyCB& need_key_cb, 39 const NeedKeyCB& need_key_cb,
40 const NewMediaSegmentCB& new_segment_cb) { 40 const NewMediaSegmentCB& new_segment_cb,
41 const base::Closure& end_of_segment_cb) {
41 DCHECK_EQ(state_, kWaitingForInit); 42 DCHECK_EQ(state_, kWaitingForInit);
42 DCHECK(init_cb_.is_null()); 43 DCHECK(init_cb_.is_null());
43 DCHECK(!init_cb.is_null()); 44 DCHECK(!init_cb.is_null());
44 DCHECK(!config_cb.is_null()); 45 DCHECK(!config_cb.is_null());
45 DCHECK(!audio_cb.is_null() || !video_cb.is_null()); 46 DCHECK(!audio_cb.is_null() || !video_cb.is_null());
46 DCHECK(!need_key_cb.is_null()); 47 DCHECK(!need_key_cb.is_null());
48 DCHECK(!end_of_segment_cb.is_null());
47 49
48 ChangeState(kParsingBoxes); 50 ChangeState(kParsingBoxes);
49 init_cb_ = init_cb; 51 init_cb_ = init_cb;
50 config_cb_ = config_cb; 52 config_cb_ = config_cb;
51 audio_cb_ = audio_cb; 53 audio_cb_ = audio_cb;
52 video_cb_ = video_cb; 54 video_cb_ = video_cb;
53 need_key_cb_ = need_key_cb; 55 need_key_cb_ = need_key_cb;
54 new_segment_cb_ = new_segment_cb; 56 new_segment_cb_ = new_segment_cb;
57 end_of_segment_cb_ = end_of_segment_cb;
55 } 58 }
56 59
57 void MP4StreamParser::Flush() { 60 void MP4StreamParser::Flush() {
58 DCHECK_NE(state_, kWaitingForInit); 61 DCHECK_NE(state_, kWaitingForInit);
59 62
60 queue_.Reset(); 63 queue_.Reset();
61 moof_head_ = 0; 64 moof_head_ = 0;
62 mdat_tail_ = 0; 65 mdat_tail_ = 0;
63 } 66 }
64 67
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 } 237 }
235 238
236 bool MP4StreamParser::EnqueueSample(BufferQueue* audio_buffers, 239 bool MP4StreamParser::EnqueueSample(BufferQueue* audio_buffers,
237 BufferQueue* video_buffers, 240 BufferQueue* video_buffers,
238 bool* err) { 241 bool* err) {
239 if (!runs_.RunValid()) { 242 if (!runs_.RunValid()) {
240 // Flush any buffers we've gotten in this chunk so that buffers don't 243 // Flush any buffers we've gotten in this chunk so that buffers don't
241 // cross NewSegment() calls 244 // cross NewSegment() calls
242 *err = !SendAndFlushSamples(audio_buffers, video_buffers); 245 *err = !SendAndFlushSamples(audio_buffers, video_buffers);
243 if (*err) return false; 246 if (*err) return false;
244 ChangeState(kParsingBoxes); 247 ChangeState(kParsingBoxes);
acolwell GONE FROM CHROMIUM 2012/07/20 18:21:01 I believe this is where you should call end_of_seg
vrk (LEFT CHROMIUM) 2012/07/25 17:16:48 Done, and fixed some indentation nits since I was
245 return true; 248 return true;
246 } 249 }
247 250
248 if (!runs_.SampleValid()) { 251 if (!runs_.SampleValid()) {
249 runs_.AdvanceRun(); 252 runs_.AdvanceRun();
250 return true; 253 return true;
251 } 254 }
252 255
253 DCHECK(!(*err)); 256 DCHECK(!(*err));
254 257
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 return true; 367 return true;
365 } 368 }
366 369
367 void MP4StreamParser::ChangeState(State new_state) { 370 void MP4StreamParser::ChangeState(State new_state) {
368 DVLOG(2) << "Changing state: " << new_state; 371 DVLOG(2) << "Changing state: " << new_state;
369 state_ = new_state; 372 state_ = new_state;
370 } 373 }
371 374
372 } // namespace mp4 375 } // namespace mp4
373 } // namespace media 376 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698