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

Side by Side Diff: media/filters/chunk_demuxer.cc

Issue 13419002: Media Source dispatches inband text tracks (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: clean compile Created 7 years, 7 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
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/filters/chunk_demuxer.h" 5 #include "media/filters/chunk_demuxer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <deque> 8 #include <deque>
9 #include <limits> 9 #include <limits>
10 10
(...skipping 13 matching lines...) Expand all
24 // Contains state belonging to a source id. 24 // Contains state belonging to a source id.
25 class SourceState { 25 class SourceState {
26 public: 26 public:
27 explicit SourceState(scoped_ptr<StreamParser> stream_parser); 27 explicit SourceState(scoped_ptr<StreamParser> stream_parser);
28 28
29 void Init(const StreamParser::InitCB& init_cb, 29 void Init(const StreamParser::InitCB& init_cb,
30 const StreamParser::NewConfigCB& config_cb, 30 const StreamParser::NewConfigCB& config_cb,
31 const StreamParser::NewBuffersCB& audio_cb, 31 const StreamParser::NewBuffersCB& audio_cb,
32 const StreamParser::NewBuffersCB& video_cb, 32 const StreamParser::NewBuffersCB& video_cb,
33 const StreamParser::NeedKeyCB& need_key_cb, 33 const StreamParser::NeedKeyCB& need_key_cb,
34 const AddTextTrackCB& add_text_track_cb,
34 const StreamParser::NewMediaSegmentCB& new_segment_cb, 35 const StreamParser::NewMediaSegmentCB& new_segment_cb,
35 const LogCB& log_cb); 36 const LogCB& log_cb);
36 37
37 // Appends new data to the StreamParser. 38 // Appends new data to the StreamParser.
38 // Returns true if the data was successfully appended. Returns false if an 39 // Returns true if the data was successfully appended. Returns false if an
39 // error occurred. 40 // error occurred.
40 bool Append(const uint8* data, size_t length); 41 bool Append(const uint8* data, size_t length);
41 42
42 // Aborts the current append sequence and resets the parser. 43 // Aborts the current append sequence and resets the parser.
43 void Abort(); 44 void Abort();
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 SourceState::SourceState(scoped_ptr<StreamParser> stream_parser) 87 SourceState::SourceState(scoped_ptr<StreamParser> stream_parser)
87 : can_update_offset_(true), 88 : can_update_offset_(true),
88 stream_parser_(stream_parser.release()) { 89 stream_parser_(stream_parser.release()) {
89 } 90 }
90 91
91 void SourceState::Init(const StreamParser::InitCB& init_cb, 92 void SourceState::Init(const StreamParser::InitCB& init_cb,
92 const StreamParser::NewConfigCB& config_cb, 93 const StreamParser::NewConfigCB& config_cb,
93 const StreamParser::NewBuffersCB& audio_cb, 94 const StreamParser::NewBuffersCB& audio_cb,
94 const StreamParser::NewBuffersCB& video_cb, 95 const StreamParser::NewBuffersCB& video_cb,
95 const StreamParser::NeedKeyCB& need_key_cb, 96 const StreamParser::NeedKeyCB& need_key_cb,
97 const AddTextTrackCB& add_text_track_cb,
96 const StreamParser::NewMediaSegmentCB& new_segment_cb, 98 const StreamParser::NewMediaSegmentCB& new_segment_cb,
97 const LogCB& log_cb) { 99 const LogCB& log_cb) {
98 stream_parser_->Init(init_cb, config_cb, 100 stream_parser_->Init(init_cb, config_cb,
99 base::Bind(&SourceState::OnBuffers, 101 base::Bind(&SourceState::OnBuffers,
100 base::Unretained(this), audio_cb), 102 base::Unretained(this), audio_cb),
101 base::Bind(&SourceState::OnBuffers, 103 base::Bind(&SourceState::OnBuffers,
102 base::Unretained(this), video_cb), 104 base::Unretained(this), video_cb),
103 need_key_cb, 105 need_key_cb,
106 add_text_track_cb,
104 base::Bind(&SourceState::OnNewMediaSegment, 107 base::Bind(&SourceState::OnNewMediaSegment,
105 base::Unretained(this), new_segment_cb), 108 base::Unretained(this), new_segment_cb),
106 base::Bind(&SourceState::OnEndOfMediaSegment, 109 base::Bind(&SourceState::OnEndOfMediaSegment,
107 base::Unretained(this)), 110 base::Unretained(this)),
108 log_cb); 111 log_cb);
109 } 112 }
110 113
111 bool SourceState::SetTimestampOffset(TimeDelta timestamp_offset) { 114 bool SourceState::SetTimestampOffset(TimeDelta timestamp_offset) {
112 if (!can_update_offset_) 115 if (!can_update_offset_)
113 return false; 116 return false;
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 *buffer = StreamParserBuffer::CreateEOSBuffer(); 541 *buffer = StreamParserBuffer::CreateEOSBuffer();
539 return true; 542 return true;
540 } 543 }
541 544
542 NOTREACHED(); 545 NOTREACHED();
543 return false; 546 return false;
544 } 547 }
545 548
546 ChunkDemuxer::ChunkDemuxer(const base::Closure& open_cb, 549 ChunkDemuxer::ChunkDemuxer(const base::Closure& open_cb,
547 const NeedKeyCB& need_key_cb, 550 const NeedKeyCB& need_key_cb,
551 const AddTextTrackCB& add_text_track_cb,
548 const LogCB& log_cb) 552 const LogCB& log_cb)
549 : state_(WAITING_FOR_INIT), 553 : state_(WAITING_FOR_INIT),
550 host_(NULL), 554 host_(NULL),
551 open_cb_(open_cb), 555 open_cb_(open_cb),
552 need_key_cb_(need_key_cb), 556 need_key_cb_(need_key_cb),
557 add_text_track_cb_(add_text_track_cb),
553 log_cb_(log_cb), 558 log_cb_(log_cb),
554 duration_(kNoTimestamp()), 559 duration_(kNoTimestamp()),
555 user_specified_duration_(-1) { 560 user_specified_duration_(-1) {
556 DCHECK(!open_cb_.is_null()); 561 DCHECK(!open_cb_.is_null());
557 DCHECK(!need_key_cb_.is_null()); 562 DCHECK(!need_key_cb_.is_null());
558 } 563 }
559 564
560 void ChunkDemuxer::Initialize(DemuxerHost* host, const PipelineStatusCB& cb) { 565 void ChunkDemuxer::Initialize(DemuxerHost* host, const PipelineStatusCB& cb) {
561 DVLOG(1) << "Init()"; 566 DVLOG(1) << "Init()";
562 567
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 audio_cb = base::Bind(&ChunkDemuxer::OnAudioBuffers, 701 audio_cb = base::Bind(&ChunkDemuxer::OnAudioBuffers,
697 base::Unretained(this)); 702 base::Unretained(this));
698 } 703 }
699 704
700 if (has_video) { 705 if (has_video) {
701 source_id_video_ = id; 706 source_id_video_ = id;
702 video_cb = base::Bind(&ChunkDemuxer::OnVideoBuffers, 707 video_cb = base::Bind(&ChunkDemuxer::OnVideoBuffers,
703 base::Unretained(this)); 708 base::Unretained(this));
704 } 709 }
705 710
711 // TODO(matthewjheaney): still need this?
712 // TODO(matthewjheaney): need a predicate here?
713 //StreamParser::NewBuffersCB text_cb;
714 //text_cb = base::Bind(&ChunkDemuxer::OnTextBuffers,
715 // base::Unretained(this));
716
706 scoped_ptr<SourceState> source_state(new SourceState(stream_parser.Pass())); 717 scoped_ptr<SourceState> source_state(new SourceState(stream_parser.Pass()));
707 source_state->Init( 718 source_state->Init(
708 base::Bind(&ChunkDemuxer::OnSourceInitDone, base::Unretained(this)), 719 base::Bind(&ChunkDemuxer::OnSourceInitDone, base::Unretained(this)),
709 base::Bind(&ChunkDemuxer::OnNewConfigs, base::Unretained(this), 720 base::Bind(&ChunkDemuxer::OnNewConfigs, base::Unretained(this),
710 has_audio, has_video), 721 has_audio, has_video),
711 audio_cb, 722 audio_cb,
712 video_cb, 723 video_cb,
713 base::Bind(&ChunkDemuxer::OnNeedKey, base::Unretained(this)), 724 base::Bind(&ChunkDemuxer::OnNeedKey, base::Unretained(this)),
725 add_text_track_cb_,
714 base::Bind(&ChunkDemuxer::OnNewMediaSegment, base::Unretained(this), id), 726 base::Bind(&ChunkDemuxer::OnNewMediaSegment, base::Unretained(this), id),
715 log_cb_); 727 log_cb_);
716 728
717 source_state_map_[id] = source_state.release(); 729 source_state_map_[id] = source_state.release();
718 return kOk; 730 return kOk;
719 } 731 }
720 732
721 void ChunkDemuxer::RemoveId(const std::string& id) { 733 void ChunkDemuxer::RemoveId(const std::string& id) {
722 base::AutoLock auto_lock(lock_); 734 base::AutoLock auto_lock(lock_);
723 CHECK(IsValidId(id)); 735 CHECK(IsValidId(id));
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
1250 1262
1251 Ranges<TimeDelta> ChunkDemuxer::GetBufferedRanges() const { 1263 Ranges<TimeDelta> ChunkDemuxer::GetBufferedRanges() const {
1252 if (audio_ && !video_) 1264 if (audio_ && !video_)
1253 return audio_->GetBufferedRanges(duration_); 1265 return audio_->GetBufferedRanges(duration_);
1254 else if (!audio_ && video_) 1266 else if (!audio_ && video_)
1255 return video_->GetBufferedRanges(duration_); 1267 return video_->GetBufferedRanges(duration_);
1256 return ComputeIntersection(); 1268 return ComputeIntersection();
1257 } 1269 }
1258 1270
1259 } // namespace media 1271 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698