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

Unified Diff: media/base/media_tracks.cc

Issue 1812543003: Allow muting/unmuting audio through media track API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@blink-sb-tracks6
Patch Set: Avoid ChunkDemuxer/PipelineImpl deadlock Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/base/media_tracks.h ('k') | media/base/mock_filters.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/media_tracks.cc
diff --git a/media/base/media_tracks.cc b/media/base/media_tracks.cc
index 832e5a822b12a497f43d01aabc9ef898c55fb7d0..070e8c7689e889414f3ec63504d8610403c02fb8 100644
--- a/media/base/media_tracks.cc
+++ b/media/base/media_tracks.cc
@@ -14,30 +14,66 @@ MediaTracks::MediaTracks() {}
MediaTracks::~MediaTracks() {}
-void MediaTracks::AddAudioTrack(const AudioDecoderConfig& config,
- const std::string& id,
- const std::string& kind,
- const std::string& label,
- const std::string& language) {
+const MediaTrack* MediaTracks::AddAudioTrack(const AudioDecoderConfig& config,
+ const std::string& id,
+ const std::string& kind,
+ const std::string& label,
+ const std::string& language) {
DCHECK(config.IsValidConfig());
CHECK(audio_configs_.find(id) == audio_configs_.end());
scoped_ptr<MediaTrack> track = make_scoped_ptr(
new MediaTrack(MediaTrack::Audio, id, kind, label, language));
tracks_.push_back(std::move(track));
audio_configs_[id] = config;
+ return tracks_.back().get();
}
-void MediaTracks::AddVideoTrack(const VideoDecoderConfig& config,
- const std::string& id,
- const std::string& kind,
- const std::string& label,
- const std::string& language) {
+const MediaTrack* MediaTracks::AddVideoTrack(const VideoDecoderConfig& config,
+ const std::string& id,
+ const std::string& kind,
+ const std::string& label,
+ const std::string& language) {
DCHECK(config.IsValidConfig());
CHECK(video_configs_.find(id) == video_configs_.end());
scoped_ptr<MediaTrack> track = make_scoped_ptr(
new MediaTrack(MediaTrack::Video, id, kind, label, language));
tracks_.push_back(std::move(track));
video_configs_[id] = config;
+ return tracks_.back().get();
+}
+
+void MediaTracks::SetDemuxerStreamForMediaTrack(const MediaTrack* track,
+ const DemuxerStream* stream) {
+ DCHECK(track_to_demux_stream_map_.find(track) ==
+ track_to_demux_stream_map_.end());
+
+ bool track_found = false;
+ for (const auto& t : tracks_) {
+ if (t.get() == track) {
+ track_found = true;
+ break;
+ }
+ }
+ CHECK(track_found);
+
+ track_to_demux_stream_map_[track] = stream;
+}
+
+MediaTracks::TrackIdToDemuxStreamMap MediaTracks::OnTrackIdsAssigned(
+ const std::vector<unsigned>& track_ids) const {
+ TrackIdToDemuxStreamMap result;
+ CHECK_EQ(tracks().size(), track_ids.size());
+ CHECK_EQ(track_to_demux_stream_map_.size(), tracks().size());
+ for (size_t i = 0; i < track_ids.size(); ++i) {
+ const MediaTrack* track = tracks()[i].get();
+ DCHECK(track);
+ const auto& it = track_to_demux_stream_map_.find(track);
+ CHECK(it != track_to_demux_stream_map_.end());
+ DVLOG(3) << "OnTrackIdsAssigned track_id=" << track_ids[i]
+ << " DemuxerStream=" << it->second;
+ result[track_ids[i]] = it->second;
+ }
+ return result;
}
const AudioDecoderConfig& MediaTracks::getAudioConfig(
« no previous file with comments | « media/base/media_tracks.h ('k') | media/base/mock_filters.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698