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

Side by Side 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: rebase 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/base/media_tracks.h" 5 #include "media/base/media_tracks.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "media/base/audio_decoder_config.h" 8 #include "media/base/audio_decoder_config.h"
9 #include "media/base/video_decoder_config.h" 9 #include "media/base/video_decoder_config.h"
10 10
11 namespace media { 11 namespace media {
12 12
13 MediaTracks::MediaTracks() {} 13 MediaTracks::MediaTracks() {}
14 14
15 MediaTracks::~MediaTracks() {} 15 MediaTracks::~MediaTracks() {}
16 16
17 void MediaTracks::AddAudioTrack(const AudioDecoderConfig& config, 17 const MediaTrack* MediaTracks::AddAudioTrack(const AudioDecoderConfig& config,
18 const std::string& id, 18 const std::string& id,
19 const std::string& kind, 19 const std::string& kind,
20 const std::string& label, 20 const std::string& label,
21 const std::string& language) { 21 const std::string& language) {
22 DCHECK(config.IsValidConfig()); 22 DCHECK(config.IsValidConfig());
23 CHECK(audio_configs_.find(id) == audio_configs_.end()); 23 CHECK(audio_configs_.find(id) == audio_configs_.end());
24 scoped_ptr<MediaTrack> track = make_scoped_ptr( 24 scoped_ptr<MediaTrack> track = make_scoped_ptr(
25 new MediaTrack(MediaTrack::Audio, id, kind, label, language)); 25 new MediaTrack(MediaTrack::Audio, id, kind, label, language));
26 tracks_.push_back(std::move(track)); 26 tracks_.push_back(std::move(track));
27 audio_configs_[id] = config; 27 audio_configs_[id] = config;
28 return tracks_.back().get();
28 } 29 }
29 30
30 void MediaTracks::AddVideoTrack(const VideoDecoderConfig& config, 31 const MediaTrack* MediaTracks::AddVideoTrack(const VideoDecoderConfig& config,
31 const std::string& id, 32 const std::string& id,
32 const std::string& kind, 33 const std::string& kind,
33 const std::string& label, 34 const std::string& label,
34 const std::string& language) { 35 const std::string& language) {
35 DCHECK(config.IsValidConfig()); 36 DCHECK(config.IsValidConfig());
36 CHECK(video_configs_.find(id) == video_configs_.end()); 37 CHECK(video_configs_.find(id) == video_configs_.end());
37 scoped_ptr<MediaTrack> track = make_scoped_ptr( 38 scoped_ptr<MediaTrack> track = make_scoped_ptr(
38 new MediaTrack(MediaTrack::Video, id, kind, label, language)); 39 new MediaTrack(MediaTrack::Video, id, kind, label, language));
39 tracks_.push_back(std::move(track)); 40 tracks_.push_back(std::move(track));
40 video_configs_[id] = config; 41 video_configs_[id] = config;
42 return tracks_.back().get();
41 } 43 }
42 44
43 const AudioDecoderConfig& MediaTracks::getAudioConfig( 45 const AudioDecoderConfig& MediaTracks::getAudioConfig(
44 const std::string& id) const { 46 const std::string& id) const {
45 auto it = audio_configs_.find(id); 47 auto it = audio_configs_.find(id);
46 if (it != audio_configs_.end()) 48 if (it != audio_configs_.end())
47 return it->second; 49 return it->second;
48 static AudioDecoderConfig invalidConfig; 50 static AudioDecoderConfig invalidConfig;
49 return invalidConfig; 51 return invalidConfig;
50 } 52 }
(...skipping 21 matching lines...) Expand all
72 for (const auto& track : tracks()) { 74 for (const auto& track : tracks()) {
73 if (track->type() == MediaTrack::Video) { 75 if (track->type() == MediaTrack::Video) {
74 return getVideoConfig(track->id()); 76 return getVideoConfig(track->id());
75 } 77 }
76 } 78 }
77 static VideoDecoderConfig invalidConfig; 79 static VideoDecoderConfig invalidConfig;
78 return invalidConfig; 80 return invalidConfig;
79 } 81 }
80 82
81 } // namespace media 83 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698