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

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

Issue 2667283002: Refactor MediaResource to be multi-stream capable (Closed)
Patch Set: Created 3 years, 10 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 | « media/filters/chunk_demuxer.h ('k') | media/filters/chunk_demuxer_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/filters/chunk_demuxer.h" 5 #include "media/filters/chunk_demuxer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 is_enabled_ = enabled; 301 is_enabled_ = enabled;
302 if (enabled) { 302 if (enabled) {
303 DCHECK(stream_); 303 DCHECK(stream_);
304 stream_->Seek(timestamp); 304 stream_->Seek(timestamp);
305 } else if (!read_cb_.is_null()) { 305 } else if (!read_cb_.is_null()) {
306 DVLOG(1) << "Read from disabled stream, returning EOS"; 306 DVLOG(1) << "Read from disabled stream, returning EOS";
307 base::ResetAndReturn(&read_cb_).Run(kOk, 307 base::ResetAndReturn(&read_cb_).Run(kOk,
308 StreamParserBuffer::CreateEOSBuffer()); 308 StreamParserBuffer::CreateEOSBuffer());
309 } 309 }
310 if (!stream_status_change_cb_.is_null()) 310 if (!stream_status_change_cb_.is_null())
311 stream_status_change_cb_.Run(is_enabled_, timestamp); 311 stream_status_change_cb_.Run(this, is_enabled_, timestamp);
312 } 312 }
313 313
314 void ChunkDemuxerStream::SetStreamStatusChangeCB( 314 void ChunkDemuxerStream::SetStreamStatusChangeCB(
315 const StreamStatusChangeCB& cb) { 315 const StreamStatusChangeCB& cb) {
316 DCHECK(!cb.is_null()); 316 DCHECK(!cb.is_null());
317 stream_status_change_cb_ = BindToCurrentLoop(cb); 317 stream_status_change_cb_ = BindToCurrentLoop(cb);
318 } 318 }
319 319
320 TextTrackConfig ChunkDemuxerStream::text_track_config() { 320 TextTrackConfig ChunkDemuxerStream::text_track_config() {
321 CHECK_EQ(type_, TEXT); 321 CHECK_EQ(type_, TEXT);
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 } 484 }
485 485
486 base::ResetAndReturn(&seek_cb_).Run(PIPELINE_OK); 486 base::ResetAndReturn(&seek_cb_).Run(PIPELINE_OK);
487 } 487 }
488 488
489 // Demuxer implementation. 489 // Demuxer implementation.
490 base::Time ChunkDemuxer::GetTimelineOffset() const { 490 base::Time ChunkDemuxer::GetTimelineOffset() const {
491 return timeline_offset_; 491 return timeline_offset_;
492 } 492 }
493 493
494 DemuxerStream* ChunkDemuxer::GetStream(DemuxerStream::Type type) { 494 std::vector<DemuxerStream*> ChunkDemuxer::GetStreams() {
495 DCHECK_NE(type, DemuxerStream::TEXT);
496 base::AutoLock auto_lock(lock_); 495 base::AutoLock auto_lock(lock_);
497 496
498 // TODO(servolk): For now return only the first enabled audio/video stream, 497 std::vector<DemuxerStream*> result;
499 // since this GetStream method is part of the implementation of the 498 for (const auto& stream : audio_streams_)
500 // DemuxerStreamProvider interface that is used in many places and can't be 499 result.push_back(stream.get());
501 // changed easily. It will be fixed later, when we add support for multiple
502 // streams/tracks in DemuxerStreamProvider, tracked by crbug.com/646669
503 if (type == DemuxerStream::AUDIO)
504 for (const auto& s : audio_streams_)
505 if (s->enabled())
506 return s.get();
507 500
508 if (type == DemuxerStream::VIDEO) 501 for (const auto& stream : video_streams_)
509 for (const auto& s : video_streams_) 502 result.push_back(stream.get());
510 if (s->enabled())
511 return s.get();
512 503
513 return NULL; 504 return result;
505 }
506
507 void ChunkDemuxer::SetStreamStatusChangeCB(const StreamStatusChangeCB& cb) {
508 DCHECK(!cb.is_null());
509 for (const auto& s : audio_streams_)
510 s->SetStreamStatusChangeCB(cb);
511 for (const auto& s : video_streams_)
512 s->SetStreamStatusChangeCB(cb);
514 } 513 }
515 514
516 TimeDelta ChunkDemuxer::GetStartTime() const { 515 TimeDelta ChunkDemuxer::GetStartTime() const {
517 return TimeDelta(); 516 return TimeDelta();
518 } 517 }
519 518
520 int64_t ChunkDemuxer::GetMemoryUsage() const { 519 int64_t ChunkDemuxer::GetMemoryUsage() const {
521 base::AutoLock auto_lock(lock_); 520 base::AutoLock auto_lock(lock_);
522 int64_t mem = 0; 521 int64_t mem = 0;
523 for (const auto& s : audio_streams_) 522 for (const auto& s : audio_streams_)
(...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after
1329 } 1328 }
1330 1329
1331 void ChunkDemuxer::ShutdownAllStreams() { 1330 void ChunkDemuxer::ShutdownAllStreams() {
1332 for (auto itr = source_state_map_.begin(); itr != source_state_map_.end(); 1331 for (auto itr = source_state_map_.begin(); itr != source_state_map_.end();
1333 ++itr) { 1332 ++itr) {
1334 itr->second->Shutdown(); 1333 itr->second->Shutdown();
1335 } 1334 }
1336 } 1335 }
1337 1336
1338 } // namespace media 1337 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/chunk_demuxer.h ('k') | media/filters/chunk_demuxer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698