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

Unified Diff: media/blink/webmediaplayer_impl.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/blink/webmediaplayer_impl.h ('k') | media/blink/websourcebuffer_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/blink/webmediaplayer_impl.cc
diff --git a/media/blink/webmediaplayer_impl.cc b/media/blink/webmediaplayer_impl.cc
index be941de92d309ee677004e624a5bab79574742a5..009eee61b19f149e2a6b851aa1a39ca5015bfc7f 100644
--- a/media/blink/webmediaplayer_impl.cc
+++ b/media/blink/webmediaplayer_impl.cc
@@ -7,6 +7,7 @@
#include <algorithm>
#include <cmath>
#include <limits>
+#include <sstream>
#include <string>
#include <utility>
@@ -564,6 +565,45 @@ bool WebMediaPlayerImpl::hasAudio() const {
return pipeline_metadata_.has_audio;
}
+void WebMediaPlayerImpl::enabledAudioTracksChanged(
+ const blink::WebVector<blink::WebMediaPlayer::TrackId>& enabledTrackIds) {
+ DCHECK(main_task_runner_->BelongsToCurrentThread());
+ CHECK(demuxer_.get());
+
+ std::vector<const DemuxerStream*> enabledAudioStreams;
+ std::stringstream trackIdsStr;
+ for (const auto& trackId : enabledTrackIds) {
+ const DemuxerStream* s = demuxer_->GetDemuxerStreamByTrackId(trackId);
+ CHECK(s);
+ enabledAudioStreams.push_back(s);
+ trackIdsStr << trackId << " ";
+ }
+ MEDIA_LOG(INFO, media_log_)
+ << "WebMediaPlayerImpl::enabledAudioTracksChanged enabledTrackIds="
+ << trackIdsStr.str();
+ pipeline_.OnEnabledAudioStreamsChanged(enabledAudioStreams);
+}
+
+void WebMediaPlayerImpl::selectedVideoTrackChanged(
+ blink::WebMediaPlayer::TrackId* selectedTrackId) {
+ DCHECK(main_task_runner_->BelongsToCurrentThread());
+ CHECK(demuxer_.get());
+
+ const DemuxerStream* selectedVideoStream = nullptr;
+ if (selectedTrackId) {
+ selectedVideoStream = demuxer_->GetDemuxerStreamByTrackId(*selectedTrackId);
+ CHECK(selectedVideoStream);
+ MEDIA_LOG(INFO, media_log_)
+ << "WebMediaPlayerImpl::selectedVideoTrackChanged selectedTrackId="
+ << *selectedTrackId << " selectedVideoStream=" << selectedVideoStream;
+ } else {
+ MEDIA_LOG(INFO, media_log_) << "WebMediaPlayerImpl::"
+ "selectedVideoTrackChanged "
+ "selectedTrackId=none";
+ }
+ pipeline_.OnSelectedVideoStreamChanged(selectedVideoStream);
+}
+
blink::WebSize WebMediaPlayerImpl::naturalSize() const {
DCHECK(main_task_runner_->BelongsToCurrentThread());
@@ -827,6 +867,7 @@ void WebMediaPlayerImpl::OnFFmpegMediaTracksUpdated(
DCHECK(!chunk_demuxer_);
// Report the media track information to blink.
+ std::vector<blink::WebMediaPlayer::TrackId> blinkTrackIds;
for (const auto& track : tracks->tracks()) {
if (track->type() == MediaTrack::Audio) {
auto track_id = client_->addAudioTrack(
@@ -835,7 +876,7 @@ void WebMediaPlayerImpl::OnFFmpegMediaTracksUpdated(
blink::WebString::fromUTF8(track->label()),
blink::WebString::fromUTF8(track->language()),
/*enabled*/ true);
- (void)track_id;
+ blinkTrackIds.push_back(track_id);
} else if (track->type() == MediaTrack::Video) {
auto track_id = client_->addVideoTrack(
blink::WebString::fromUTF8(track->id()),
@@ -843,12 +884,14 @@ void WebMediaPlayerImpl::OnFFmpegMediaTracksUpdated(
blink::WebString::fromUTF8(track->label()),
blink::WebString::fromUTF8(track->language()),
/*selected*/ true);
- (void)track_id;
+ blinkTrackIds.push_back(track_id);
} else {
// Text tracks are not supported through this code path yet.
NOTREACHED();
}
}
+
+ demuxer_->OnTrackIdsAssigned(*tracks.get(), blinkTrackIds);
}
void WebMediaPlayerImpl::OnWaitingForDecryptionKey() {
« no previous file with comments | « media/blink/webmediaplayer_impl.h ('k') | media/blink/websourcebuffer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698