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

Unified Diff: media/filters/media_source_state.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: Fixed issues that caused test failures 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
Index: media/filters/media_source_state.cc
diff --git a/media/filters/media_source_state.cc b/media/filters/media_source_state.cc
index 98028b40a00cc9cb59a6208628ed90c152362829..1753750803db5cb22a9b9445748a1697fbce73c7 100644
--- a/media/filters/media_source_state.cc
+++ b/media/filters/media_source_state.cc
@@ -481,8 +481,22 @@ bool MediaSourceState::OnNewConfigs(
DCHECK_GE(state_, PENDING_PARSER_CONFIG);
DCHECK(tracks.get());
media_tracks_ = std::move(tracks);
wolenetz 2016/04/15 22:47:18 minor nit: might we not want to replace our cache
servolk 2016/04/15 23:26:31 In fact it turns out that we don't need to store t
wolenetz 2016/04/15 23:52:17 Acknowledged.
- const AudioDecoderConfig& audio_config = media_tracks_->getFirstAudioConfig();
- const VideoDecoderConfig& video_config = media_tracks_->getFirstVideoConfig();
+
+ const MediaTrack* audio_track = nullptr;
+ const MediaTrack* video_track = nullptr;
+ AudioDecoderConfig audio_config;
+ VideoDecoderConfig video_config;
+ for (const auto& track : media_tracks_->tracks()) {
+ if (!audio_track && track->type() == MediaTrack::Audio &&
+ media_tracks_->getAudioConfig(track->id()).IsValidConfig()) {
+ audio_config = media_tracks_->getAudioConfig(track->id());
+ audio_track = track.get();
+ } else if (!video_track && track->type() == MediaTrack::Video &&
+ media_tracks_->getVideoConfig(track->id()).IsValidConfig()) {
+ video_config = media_tracks_->getVideoConfig(track->id());
+ video_track = track.get();
+ }
+ }
DVLOG(1) << "OnNewConfigs(" << allow_audio << ", " << allow_video << ", "
<< audio_config.IsValidConfig() << ", "
@@ -530,7 +544,8 @@ bool MediaSourceState::OnNewConfigs(
}
if (!audio_) {
- audio_ = create_demuxer_stream_cb_.Run(DemuxerStream::AUDIO);
+ DCHECK(audio_track);
+ audio_ = create_demuxer_stream_cb_.Run(*audio_track);
if (!audio_) {
DVLOG(1) << "Failed to create an audio stream.";
@@ -558,7 +573,8 @@ bool MediaSourceState::OnNewConfigs(
}
if (!video_) {
- video_ = create_demuxer_stream_cb_.Run(DemuxerStream::VIDEO);
+ DCHECK(video_track);
+ video_ = create_demuxer_stream_cb_.Run(*video_track);
if (!video_) {
DVLOG(1) << "Failed to create a video stream.";
@@ -578,8 +594,11 @@ bool MediaSourceState::OnNewConfigs(
if (text_stream_map_.empty()) {
for (TextConfigItr itr = text_configs.begin(); itr != text_configs.end();
++itr) {
+ // TODO(servolk): Look into unifying text tracks code path with audio and
+ // video track code paths.
+ MediaTrack dummy_text_track(MediaTrack::Text, "", "", "", "");
ChunkDemuxerStream* const text_stream =
- create_demuxer_stream_cb_.Run(DemuxerStream::TEXT);
+ create_demuxer_stream_cb_.Run(dummy_text_track);
if (!frame_processor_->AddTrack(itr->first, text_stream)) {
success &= false;
MEDIA_LOG(ERROR, media_log_) << "Failed to add text track ID "
@@ -651,6 +670,15 @@ bool MediaSourceState::OnNewConfigs(
frame_processor_->SetAllTrackBuffersNeedRandomAccessPoint();
+ if (audio_track) {
+ DCHECK(audio_);
+ media_tracks_->SetDemuxerStreamForMediaTrack(audio_track, audio_);
wolenetz 2016/04/15 22:47:18 I think this will now hit DCHECK on repeated init
servolk 2016/04/15 23:26:31 No, it's ok, because for each new init segment a n
wolenetz 2016/04/15 23:52:17 Acknowledged.
+ }
+ if (video_track) {
+ DCHECK(video_);
+ media_tracks_->SetDemuxerStreamForMediaTrack(video_track, video_);
wolenetz 2016/04/15 22:47:18 ditto.
servolk 2016/04/15 23:26:31 Acknowledged.
+ }
+
DVLOG(1) << "OnNewConfigs() : " << (success ? "success" : "failed");
if (success) {
if (state_ == PENDING_PARSER_CONFIG)

Powered by Google App Engine
This is Rietveld 408576698