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

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

Issue 2379653004: Rename MediaSourceState -> SourceBufferState (Closed)
Patch Set: nits Created 4 years, 2 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 if (!read_cb_.is_null()) { 74 if (!read_cb_.is_null()) {
75 base::ResetAndReturn(&read_cb_).Run(DemuxerStream::kOk, 75 base::ResetAndReturn(&read_cb_).Run(DemuxerStream::kOk,
76 StreamParserBuffer::CreateEOSBuffer()); 76 StreamParserBuffer::CreateEOSBuffer());
77 } 77 }
78 } 78 }
79 79
80 bool ChunkDemuxerStream::IsSeekWaitingForData() const { 80 bool ChunkDemuxerStream::IsSeekWaitingForData() const {
81 base::AutoLock auto_lock(lock_); 81 base::AutoLock auto_lock(lock_);
82 82
83 // This method should not be called for text tracks. See the note in 83 // This method should not be called for text tracks. See the note in
84 // MediaSourceState::IsSeekWaitingForData(). 84 // SourceBufferState::IsSeekWaitingForData().
85 DCHECK_NE(type_, DemuxerStream::TEXT); 85 DCHECK_NE(type_, DemuxerStream::TEXT);
86 86
87 return stream_->IsSeekPending(); 87 return stream_->IsSeekPending();
88 } 88 }
89 89
90 void ChunkDemuxerStream::Seek(TimeDelta time) { 90 void ChunkDemuxerStream::Seek(TimeDelta time) {
91 DVLOG(1) << "ChunkDemuxerStream::Seek(" << time.InSecondsF() << ")"; 91 DVLOG(1) << "ChunkDemuxerStream::Seek(" << time.InSecondsF() << ")";
92 base::AutoLock auto_lock(lock_); 92 base::AutoLock auto_lock(lock_);
93 DCHECK(read_cb_.is_null()); 93 DCHECK(read_cb_.is_null());
94 DCHECK(state_ == UNINITIALIZED || state_ == RETURNING_ABORT_FOR_READS) 94 DCHECK(state_ == UNINITIALIZED || state_ == RETURNING_ABORT_FOR_READS)
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 StreamParserFactory::Create(type, parsed_codec_ids, media_log_)); 589 StreamParserFactory::Create(type, parsed_codec_ids, media_log_));
590 590
591 if (!stream_parser) 591 if (!stream_parser)
592 return ChunkDemuxer::kNotSupported; 592 return ChunkDemuxer::kNotSupported;
593 593
594 std::unique_ptr<FrameProcessor> frame_processor( 594 std::unique_ptr<FrameProcessor> frame_processor(
595 new FrameProcessor(base::Bind(&ChunkDemuxer::IncreaseDurationIfNecessary, 595 new FrameProcessor(base::Bind(&ChunkDemuxer::IncreaseDurationIfNecessary,
596 base::Unretained(this)), 596 base::Unretained(this)),
597 media_log_)); 597 media_log_));
598 598
599 std::unique_ptr<MediaSourceState> source_state( 599 std::unique_ptr<SourceBufferState> source_state(new SourceBufferState(
600 new MediaSourceState(std::move(stream_parser), std::move(frame_processor), 600 std::move(stream_parser), std::move(frame_processor),
601 base::Bind(&ChunkDemuxer::CreateDemuxerStream, 601 base::Bind(&ChunkDemuxer::CreateDemuxerStream, base::Unretained(this),
602 base::Unretained(this), id), 602 id),
603 media_log_)); 603 media_log_));
604 604
605 MediaSourceState::NewTextTrackCB new_text_track_cb; 605 SourceBufferState::NewTextTrackCB new_text_track_cb;
606 606
607 if (enable_text_) { 607 if (enable_text_) {
608 new_text_track_cb = base::Bind(&ChunkDemuxer::OnNewTextTrack, 608 new_text_track_cb = base::Bind(&ChunkDemuxer::OnNewTextTrack,
609 base::Unretained(this)); 609 base::Unretained(this));
610 } 610 }
611 611
612 pending_source_init_ids_.insert(id); 612 pending_source_init_ids_.insert(id);
613 613
614 std::string expected_mss_codecs = codecs; 614 std::string expected_sbs_codecs = codecs;
615 if (codecs == "" && type == "audio/aac") 615 if (codecs == "" && type == "audio/aac")
616 expected_mss_codecs = "aac"; 616 expected_sbs_codecs = "aac";
617 if (codecs == "" && (type == "audio/mpeg" || type == "audio/mp3")) 617 if (codecs == "" && (type == "audio/mpeg" || type == "audio/mp3"))
618 expected_mss_codecs = "mp3"; 618 expected_sbs_codecs = "mp3";
619 619
620 source_state->Init( 620 source_state->Init(
621 base::Bind(&ChunkDemuxer::OnSourceInitDone, base::Unretained(this), id), 621 base::Bind(&ChunkDemuxer::OnSourceInitDone, base::Unretained(this), id),
622 expected_mss_codecs, encrypted_media_init_data_cb_, new_text_track_cb); 622 expected_sbs_codecs, encrypted_media_init_data_cb_, new_text_track_cb);
623 623
624 source_state_map_[id] = std::move(source_state); 624 source_state_map_[id] = std::move(source_state);
625 return kOk; 625 return kOk;
626 } 626 }
627 627
628 void ChunkDemuxer::SetTracksWatcher( 628 void ChunkDemuxer::SetTracksWatcher(
629 const std::string& id, 629 const std::string& id,
630 const MediaTracksUpdatedCB& tracks_updated_cb) { 630 const MediaTracksUpdatedCB& tracks_updated_cb) {
631 base::AutoLock auto_lock(lock_); 631 base::AutoLock auto_lock(lock_);
632 CHECK(IsValidId(id)); 632 CHECK(IsValidId(id));
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after
1264 base::AutoLock auto_lock(lock_); 1264 base::AutoLock auto_lock(lock_);
1265 return GetBufferedRanges_Locked(); 1265 return GetBufferedRanges_Locked();
1266 } 1266 }
1267 1267
1268 Ranges<TimeDelta> ChunkDemuxer::GetBufferedRanges_Locked() const { 1268 Ranges<TimeDelta> ChunkDemuxer::GetBufferedRanges_Locked() const {
1269 lock_.AssertAcquired(); 1269 lock_.AssertAcquired();
1270 1270
1271 bool ended = state_ == ENDED; 1271 bool ended = state_ == ENDED;
1272 // TODO(acolwell): When we start allowing SourceBuffers that are not active, 1272 // TODO(acolwell): When we start allowing SourceBuffers that are not active,
1273 // we'll need to update this loop to only add ranges from active sources. 1273 // we'll need to update this loop to only add ranges from active sources.
1274 MediaSourceState::RangesList ranges_list; 1274 SourceBufferState::RangesList ranges_list;
1275 for (auto itr = source_state_map_.begin(); itr != source_state_map_.end(); 1275 for (auto itr = source_state_map_.begin(); itr != source_state_map_.end();
1276 ++itr) { 1276 ++itr) {
1277 ranges_list.push_back(itr->second->GetBufferedRanges(duration_, ended)); 1277 ranges_list.push_back(itr->second->GetBufferedRanges(duration_, ended));
1278 } 1278 }
1279 1279
1280 return MediaSourceState::ComputeRangesIntersection(ranges_list, ended); 1280 return SourceBufferState::ComputeRangesIntersection(ranges_list, ended);
1281 } 1281 }
1282 1282
1283 void ChunkDemuxer::StartReturningData() { 1283 void ChunkDemuxer::StartReturningData() {
1284 for (auto itr = source_state_map_.begin(); itr != source_state_map_.end(); 1284 for (auto itr = source_state_map_.begin(); itr != source_state_map_.end();
1285 ++itr) { 1285 ++itr) {
1286 itr->second->StartReturningData(); 1286 itr->second->StartReturningData();
1287 } 1287 }
1288 } 1288 }
1289 1289
1290 void ChunkDemuxer::AbortPendingReads_Locked() { 1290 void ChunkDemuxer::AbortPendingReads_Locked() {
(...skipping 18 matching lines...) Expand all
1309 } 1309 }
1310 1310
1311 void ChunkDemuxer::ShutdownAllStreams() { 1311 void ChunkDemuxer::ShutdownAllStreams() {
1312 for (auto itr = source_state_map_.begin(); itr != source_state_map_.end(); 1312 for (auto itr = source_state_map_.begin(); itr != source_state_map_.end();
1313 ++itr) { 1313 ++itr) {
1314 itr->second->Shutdown(); 1314 itr->second->Shutdown();
1315 } 1315 }
1316 } 1316 }
1317 1317
1318 } // namespace media 1318 } // 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