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

Unified Diff: media/blink/webmediaplayer_impl.cc

Issue 1735803002: Implemented passing media track info from ffmpeg into blink (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: wolenetz@ CR feedback + better track info extraction in ffmpeg Created 4 years, 10 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.h » ('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 3749bf2f1878ab954dc318a122e029e88e123d58..a007f84d2e842a5b2224ee045acef7814d55500b 100644
--- a/media/blink/webmediaplayer_impl.cc
+++ b/media/blink/webmediaplayer_impl.cc
@@ -843,6 +843,46 @@ void WebMediaPlayerImpl::OnEncryptedMediaInitData(
base::saturated_cast<unsigned int>(init_data.size()));
}
+void WebMediaPlayerImpl::OnMediaTracksUpdated(scoped_ptr<MediaTracks> tracks) {
+ // For MSE/chunk_demuxer case the media tracks should be handled by WSBI
+ DCHECK(!chunk_demuxer_);
+ DCHECK(client_);
+
+ // Remove the old tracks first, if any were present
+ while (!blink_audio_tracks_.empty()) {
+ client_->removeAudioTrack(blink_audio_tracks_[0]);
+ blink_audio_tracks_.erase(blink_audio_tracks_.begin());
+ }
+ while (!blink_video_tracks_.empty()) {
+ client_->removeVideoTrack(blink_video_tracks_[0]);
+ blink_audio_tracks_.erase(blink_audio_tracks_.begin());
+ }
+
+ // Now report the new media tracks to blink
+ for (const auto& track : tracks->tracks()) {
+ if (track->type() == MediaTrack::Audio) {
+ auto track_id = client_->addAudioTrack(
+ blink::WebString::fromUTF8(track->id()),
+ blink::WebMediaPlayerClient::AudioTrackKindMain,
+ blink::WebString::fromUTF8(track->label()),
+ blink::WebString::fromUTF8(track->language()),
+ /*enabled*/ true);
+ blink_audio_tracks_.push_back(track_id);
+ } else if (track->type() == MediaTrack::Video) {
+ auto track_id = client_->addVideoTrack(
+ blink::WebString::fromUTF8(track->id()),
+ blink::WebMediaPlayerClient::VideoTrackKindMain,
+ blink::WebString::fromUTF8(track->label()),
+ blink::WebString::fromUTF8(track->language()),
+ /*selected*/ true);
+ blink_video_tracks_.push_back(track_id);
+ } else {
+ // Text tracks are not supported yet.
+ NOTREACHED();
+ }
+ }
+}
+
void WebMediaPlayerImpl::OnWaitingForDecryptionKey() {
encrypted_client_->didBlockPlaybackWaitingForKey();
@@ -1371,6 +1411,9 @@ void WebMediaPlayerImpl::StartPipeline() {
Demuxer::EncryptedMediaInitDataCB encrypted_media_init_data_cb =
BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnEncryptedMediaInitData);
+ Demuxer::MediaTracksUpdatedCB media_tracks_updated_cb =
+ BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnMediaTracksUpdated);
+
// Figure out which demuxer to use.
if (load_type_ != LoadTypeMediaSource) {
DCHECK(!chunk_demuxer_);
@@ -1378,7 +1421,8 @@ void WebMediaPlayerImpl::StartPipeline() {
#if !defined(MEDIA_DISABLE_FFMPEG)
demuxer_.reset(new FFmpegDemuxer(media_task_runner_, data_source_.get(),
- encrypted_media_init_data_cb, media_log_));
+ encrypted_media_init_data_cb,
+ media_tracks_updated_cb, media_log_));
#else
OnPipelineError(PipelineStatus::DEMUXER_ERROR_COULD_NOT_OPEN);
return;
« no previous file with comments | « media/blink/webmediaplayer_impl.h ('k') | media/blink/websourcebuffer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698