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

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: incorporated Frank's comments Created 7 years, 8 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 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 *buffer = StreamParserBuffer::CreateEOSBuffer(); 399 *buffer = StreamParserBuffer::CreateEOSBuffer();
400 return true; 400 return true;
401 } 401 }
402 402
403 NOTREACHED(); 403 NOTREACHED();
404 return false; 404 return false;
405 } 405 }
406 406
407 ChunkDemuxer::ChunkDemuxer(const base::Closure& open_cb, 407 ChunkDemuxer::ChunkDemuxer(const base::Closure& open_cb,
408 const NeedKeyCB& need_key_cb, 408 const NeedKeyCB& need_key_cb,
409 const TextTrackCB& text_track_cb,
410 const TextCB& text_cb,
409 const LogCB& log_cb) 411 const LogCB& log_cb)
410 : state_(WAITING_FOR_INIT), 412 : state_(WAITING_FOR_INIT),
411 host_(NULL), 413 host_(NULL),
412 open_cb_(open_cb), 414 open_cb_(open_cb),
413 need_key_cb_(need_key_cb), 415 need_key_cb_(need_key_cb),
416 text_track_cb_(text_track_cb),
417 text_cb_(text_cb),
414 log_cb_(log_cb), 418 log_cb_(log_cb),
415 duration_(kNoTimestamp()), 419 duration_(kNoTimestamp()),
416 user_specified_duration_(-1) { 420 user_specified_duration_(-1) {
417 DCHECK(!open_cb_.is_null()); 421 DCHECK(!open_cb_.is_null());
418 DCHECK(!need_key_cb_.is_null()); 422 DCHECK(!need_key_cb_.is_null());
419 } 423 }
420 424
421 void ChunkDemuxer::Initialize(DemuxerHost* host, const PipelineStatusCB& cb) { 425 void ChunkDemuxer::Initialize(DemuxerHost* host, const PipelineStatusCB& cb) {
422 DVLOG(1) << "Init()"; 426 DVLOG(1) << "Init()";
423 427
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 audio_cb = base::Bind(&ChunkDemuxer::OnAudioBuffers, 562 audio_cb = base::Bind(&ChunkDemuxer::OnAudioBuffers,
559 base::Unretained(this)); 563 base::Unretained(this));
560 } 564 }
561 565
562 if (has_video) { 566 if (has_video) {
563 source_id_video_ = id; 567 source_id_video_ = id;
564 video_cb = base::Bind(&ChunkDemuxer::OnVideoBuffers, 568 video_cb = base::Bind(&ChunkDemuxer::OnVideoBuffers,
565 base::Unretained(this)); 569 base::Unretained(this));
566 } 570 }
567 571
572 // TODO(matthewjheaney): need a predicate here?
573 StreamParser::NewBuffersCB text_cb;
574 text_cb = base::Bind(&ChunkDemuxer::OnTextBuffers,
acolwell GONE FROM CHROMIUM 2013/04/05 16:29:23 nit: Inline this in the Init() call like the other
Matthew Heaney (Chromium) 2013/05/09 03:53:11 I wasn't sure whether this is OBE or not. Some of
575 base::Unretained(this));
576
568 stream_parser->Init( 577 stream_parser->Init(
569 base::Bind(&ChunkDemuxer::OnStreamParserInitDone, base::Unretained(this)), 578 base::Bind(&ChunkDemuxer::OnStreamParserInitDone, base::Unretained(this)),
570 base::Bind(&ChunkDemuxer::OnNewConfigs, base::Unretained(this), 579 base::Bind(&ChunkDemuxer::OnNewConfigs, base::Unretained(this),
571 has_audio, has_video), 580 has_audio, has_video),
572 audio_cb, 581 audio_cb,
573 video_cb, 582 video_cb,
574 base::Bind(&ChunkDemuxer::OnNeedKey, base::Unretained(this)), 583 base::Bind(&ChunkDemuxer::OnNeedKey, base::Unretained(this)),
584 text_track_cb_,
585 text_cb,
575 base::Bind(&ChunkDemuxer::OnNewMediaSegment, base::Unretained(this), id), 586 base::Bind(&ChunkDemuxer::OnNewMediaSegment, base::Unretained(this), id),
576 base::Bind(&ChunkDemuxer::OnEndOfMediaSegment, 587 base::Bind(&ChunkDemuxer::OnEndOfMediaSegment,
577 base::Unretained(this), id), 588 base::Unretained(this), id),
578 log_cb_); 589 log_cb_);
579 590
580 stream_parser_map_[id] = stream_parser.release(); 591 stream_parser_map_[id] = stream_parser.release();
581 SourceInfo info = { base::TimeDelta(), true }; 592 SourceInfo info = { base::TimeDelta(), true };
582 source_info_map_[id] = info; 593 source_info_map_[id] = info;
583 594
584 return kOk; 595 return kOk;
585 } 596 }
586 597
587 void ChunkDemuxer::RemoveId(const std::string& id) { 598 void ChunkDemuxer::RemoveId(const std::string& id) {
acolwell GONE FROM CHROMIUM 2013/04/05 16:29:23 You'll need to add code in here to handle the case
588 base::AutoLock auto_lock(lock_); 599 base::AutoLock auto_lock(lock_);
589 CHECK(IsValidId(id)); 600 CHECK(IsValidId(id));
590 601
591 delete stream_parser_map_[id]; 602 delete stream_parser_map_[id];
592 stream_parser_map_.erase(id); 603 stream_parser_map_.erase(id);
593 source_info_map_.erase(id); 604 source_info_map_.erase(id);
594 605
595 if (source_id_audio_ == id) { 606 if (source_id_audio_ == id) {
596 if (audio_) 607 if (audio_)
597 audio_->Shutdown(); 608 audio_->Shutdown();
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
1068 // this method can be removed and need_key_cb_ can be passed directly 1079 // this method can be removed and need_key_cb_ can be passed directly
1069 // to the parser. 1080 // to the parser.
1070 bool ChunkDemuxer::OnNeedKey(const std::string& type, 1081 bool ChunkDemuxer::OnNeedKey(const std::string& type,
1071 scoped_array<uint8> init_data, 1082 scoped_array<uint8> init_data,
1072 int init_data_size) { 1083 int init_data_size) {
1073 lock_.AssertAcquired(); 1084 lock_.AssertAcquired();
1074 need_key_cb_.Run(type, init_data.Pass(), init_data_size); 1085 need_key_cb_.Run(type, init_data.Pass(), init_data_size);
1075 return true; 1086 return true;
1076 } 1087 }
1077 1088
1089 bool ChunkDemuxer::OnTextBuffers(const StreamParser::BufferQueue& buffers) {
1090 lock_.AssertAcquired();
1091 DCHECK_NE(state_, SHUTDOWN);
1092
1093 StreamParser::BufferQueue::const_iterator it = buffers.begin();
1094 const StreamParser::BufferQueue::const_iterator it_end = buffers.end();
1095
1096 while (it != it_end) {
1097 const StreamParser::BufferQueue::value_type& buffer = *it++;
acolwell GONE FROM CHROMIUM 2013/04/05 16:29:23 nit: Please don't use this construct. Use a normal
Matthew Heaney (Chromium) 2013/05/09 03:53:11 Done.
1098 const base::TimeDelta time = buffer->GetDecodeTimestamp();
acolwell GONE FROM CHROMIUM 2013/04/05 16:29:23 AdjustBufferTimestamp() needs to be called here li
Matthew Heaney (Chromium) 2013/05/09 03:53:11 I did have a question about that, since some of th
1099 text_cb_.Run(time);
1100 }
1101
1102 return true;
1103 }
1104
1078 void ChunkDemuxer::OnNewMediaSegment(const std::string& source_id, 1105 void ChunkDemuxer::OnNewMediaSegment(const std::string& source_id,
1079 TimeDelta timestamp) { 1106 TimeDelta timestamp) {
1080 DCHECK(timestamp != kNoTimestamp()); 1107 DCHECK(timestamp != kNoTimestamp());
1081 DVLOG(2) << "OnNewMediaSegment(" << source_id << ", " 1108 DVLOG(2) << "OnNewMediaSegment(" << source_id << ", "
1082 << timestamp.InSecondsF() << ")"; 1109 << timestamp.InSecondsF() << ")";
1083 lock_.AssertAcquired(); 1110 lock_.AssertAcquired();
1084 1111
1085 CHECK(IsValidId(source_id)); 1112 CHECK(IsValidId(source_id));
1086 source_info_map_[source_id].can_update_offset = false; 1113 source_info_map_[source_id].can_update_offset = false;
1087 base::TimeDelta start_timestamp = 1114 base::TimeDelta start_timestamp =
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1153 1180
1154 Ranges<TimeDelta> ChunkDemuxer::GetBufferedRanges() const { 1181 Ranges<TimeDelta> ChunkDemuxer::GetBufferedRanges() const {
1155 if (audio_ && !video_) 1182 if (audio_ && !video_)
1156 return audio_->GetBufferedRanges(duration_); 1183 return audio_->GetBufferedRanges(duration_);
1157 else if (!audio_ && video_) 1184 else if (!audio_ && video_)
1158 return video_->GetBufferedRanges(duration_); 1185 return video_->GetBufferedRanges(duration_);
1159 return ComputeIntersection(); 1186 return ComputeIntersection();
1160 } 1187 }
1161 1188
1162 } // namespace media 1189 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698