Chromium Code Reviews| Index: media/blink/webmediaplayer_impl.cc |
| diff --git a/media/blink/webmediaplayer_impl.cc b/media/blink/webmediaplayer_impl.cc |
| index af22e14e9e2a620a0d766f52965fcbf09ee4a9e3..12992a3202c2f300a367207e9f32576e14314df5 100644 |
| --- a/media/blink/webmediaplayer_impl.cc |
| +++ b/media/blink/webmediaplayer_impl.cc |
| @@ -854,6 +854,41 @@ void WebMediaPlayerImpl::OnFFmpegMediaTracksUpdated( |
| // WebSourceBufferImpl. |
| DCHECK(demuxer_.get()); |
| DCHECK(!chunk_demuxer_); |
| + DCHECK(client_); |
|
wolenetz
2016/03/11 23:19:54
nit: are you aware of any path, in any WMPI method
servolk
2016/03/18 18:36:42
Good point, indeed the client_ is set only once in
|
| + |
| + // Remove the old tracks first, if any were present |
|
wolenetz
2016/03/11 23:19:54
I'm not aware of any code path that allows multipl
servolk
2016/03/18 18:36:42
Yes, currently FFmpeg tracks are only going to be
|
| + 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() { |