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

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

Issue 1727243002: Unify media track info reporting on a demuxer level (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@tracks-impl-in-media
Patch Set: rebase Created 4 years, 9 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 <limits> 8 #include <limits>
9 #include <list> 9 #include <list>
10 #include <utility> 10 #include <utility>
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 } 542 }
543 543
544 source_state->Init( 544 source_state->Init(
545 base::Bind(&ChunkDemuxer::OnSourceInitDone, base::Unretained(this)), 545 base::Bind(&ChunkDemuxer::OnSourceInitDone, base::Unretained(this)),
546 has_audio, has_video, encrypted_media_init_data_cb_, new_text_track_cb); 546 has_audio, has_video, encrypted_media_init_data_cb_, new_text_track_cb);
547 547
548 source_state_map_[id] = source_state.release(); 548 source_state_map_[id] = source_state.release();
549 return kOk; 549 return kOk;
550 } 550 }
551 551
552 void ChunkDemuxer::SetTracksWatcher(
553 const std::string& id,
554 const MediaTracksUpdatedCB& tracks_updated_cb) {
555 base::AutoLock auto_lock(lock_);
556 CHECK(IsValidId(id));
557 source_state_map_[id]->SetTracksWatcher(tracks_updated_cb);
558 }
559
552 void ChunkDemuxer::RemoveId(const std::string& id) { 560 void ChunkDemuxer::RemoveId(const std::string& id) {
553 base::AutoLock auto_lock(lock_); 561 base::AutoLock auto_lock(lock_);
554 CHECK(IsValidId(id)); 562 CHECK(IsValidId(id));
555 563
556 delete source_state_map_[id]; 564 delete source_state_map_[id];
557 source_state_map_.erase(id); 565 source_state_map_.erase(id);
558 566
559 if (source_id_audio_ == id) 567 if (source_id_audio_ == id)
560 source_id_audio_.clear(); 568 source_id_audio_.clear();
561 569
(...skipping 27 matching lines...) Expand all
589 597
590 DCHECK(!id.empty()); 598 DCHECK(!id.empty());
591 MediaSourceStateMap::const_iterator itr = source_state_map_.find(id); 599 MediaSourceStateMap::const_iterator itr = source_state_map_.find(id);
592 if (itr == source_state_map_.end()) { 600 if (itr == source_state_map_.end()) {
593 LOG(WARNING) << __FUNCTION__ << " stream " << id << " not found"; 601 LOG(WARNING) << __FUNCTION__ << " stream " << id << " not found";
594 return false; 602 return false;
595 } 603 }
596 return itr->second->EvictCodedFrames(media_time_dts, newDataSize); 604 return itr->second->EvictCodedFrames(media_time_dts, newDataSize);
597 } 605 }
598 606
599 void ChunkDemuxer::AppendData( 607 void ChunkDemuxer::AppendData(const std::string& id,
600 const std::string& id, 608 const uint8_t* data,
601 const uint8_t* data, 609 size_t length,
602 size_t length, 610 TimeDelta append_window_start,
603 TimeDelta append_window_start, 611 TimeDelta append_window_end,
604 TimeDelta append_window_end, 612 TimeDelta* timestamp_offset) {
605 TimeDelta* timestamp_offset,
606 const MediaSourceState::InitSegmentReceivedCB& init_segment_received_cb) {
607 DVLOG(1) << "AppendData(" << id << ", " << length << ")"; 613 DVLOG(1) << "AppendData(" << id << ", " << length << ")";
608 614
609 DCHECK(!id.empty()); 615 DCHECK(!id.empty());
610 DCHECK(timestamp_offset); 616 DCHECK(timestamp_offset);
611 DCHECK(!init_segment_received_cb.is_null());
612 617
613 Ranges<TimeDelta> ranges; 618 Ranges<TimeDelta> ranges;
614 619
615 { 620 {
616 base::AutoLock auto_lock(lock_); 621 base::AutoLock auto_lock(lock_);
617 DCHECK_NE(state_, ENDED); 622 DCHECK_NE(state_, ENDED);
618 623
619 // Capture if any of the SourceBuffers are waiting for data before we start 624 // Capture if any of the SourceBuffers are waiting for data before we start
620 // parsing. 625 // parsing.
621 bool old_waiting_for_data = IsSeekWaitingForData_Locked(); 626 bool old_waiting_for_data = IsSeekWaitingForData_Locked();
622 627
623 if (length == 0u) 628 if (length == 0u)
624 return; 629 return;
625 630
626 DCHECK(data); 631 DCHECK(data);
627 632
628 switch (state_) { 633 switch (state_) {
629 case INITIALIZING: 634 case INITIALIZING:
630 case INITIALIZED: 635 case INITIALIZED:
631 DCHECK(IsValidId(id)); 636 DCHECK(IsValidId(id));
632 if (!source_state_map_[id]->Append(data, length, 637 if (!source_state_map_[id]->Append(data, length, append_window_start,
633 append_window_start,
634 append_window_end, 638 append_window_end,
635 timestamp_offset, 639 timestamp_offset)) {
636 init_segment_received_cb)) {
637 ReportError_Locked(PIPELINE_ERROR_DECODE); 640 ReportError_Locked(PIPELINE_ERROR_DECODE);
638 return; 641 return;
639 } 642 }
640 break; 643 break;
641 644
642 case PARSE_ERROR: 645 case PARSE_ERROR:
643 DVLOG(1) << "AppendData(): Ignoring data after a parse error."; 646 DVLOG(1) << "AppendData(): Ignoring data after a parse error.";
644 return; 647 return;
645 648
646 case WAITING_FOR_INIT: 649 case WAITING_FOR_INIT:
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
1110 } 1113 }
1111 1114
1112 void ChunkDemuxer::ShutdownAllStreams() { 1115 void ChunkDemuxer::ShutdownAllStreams() {
1113 for (MediaSourceStateMap::iterator itr = source_state_map_.begin(); 1116 for (MediaSourceStateMap::iterator itr = source_state_map_.begin();
1114 itr != source_state_map_.end(); ++itr) { 1117 itr != source_state_map_.end(); ++itr) {
1115 itr->second->Shutdown(); 1118 itr->second->Shutdown();
1116 } 1119 }
1117 } 1120 }
1118 1121
1119 } // namespace media 1122 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698