| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/blink/webmediaplayer_impl.h" | 5 #include "media/blink/webmediaplayer_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <limits> | 9 #include <limits> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1014 base::saturated_cast<unsigned int>(init_data.size())); | 1014 base::saturated_cast<unsigned int>(init_data.size())); |
| 1015 } | 1015 } |
| 1016 | 1016 |
| 1017 void WebMediaPlayerImpl::OnFFmpegMediaTracksUpdated( | 1017 void WebMediaPlayerImpl::OnFFmpegMediaTracksUpdated( |
| 1018 std::unique_ptr<MediaTracks> tracks) { | 1018 std::unique_ptr<MediaTracks> tracks) { |
| 1019 // For MSE/chunk_demuxer case the media track updates are handled by | 1019 // For MSE/chunk_demuxer case the media track updates are handled by |
| 1020 // WebSourceBufferImpl. | 1020 // WebSourceBufferImpl. |
| 1021 DCHECK(demuxer_.get()); | 1021 DCHECK(demuxer_.get()); |
| 1022 DCHECK(!chunk_demuxer_); | 1022 DCHECK(!chunk_demuxer_); |
| 1023 | 1023 |
| 1024 // Report the media track information to blink. | 1024 // Report the media track information to blink. Only the first audio track and |
| 1025 // the first video track are enabled by default to match blink logic. |
| 1026 bool is_first_audio_track = true; |
| 1027 bool is_first_video_track = true; |
| 1025 for (const auto& track : tracks->tracks()) { | 1028 for (const auto& track : tracks->tracks()) { |
| 1026 if (track->type() == MediaTrack::Audio) { | 1029 if (track->type() == MediaTrack::Audio) { |
| 1027 client_->AddAudioTrack(blink::WebString::FromUTF8(track->id()), | 1030 client_->AddAudioTrack(blink::WebString::FromUTF8(track->id()), |
| 1028 blink::WebMediaPlayerClient::kAudioTrackKindMain, | 1031 blink::WebMediaPlayerClient::kAudioTrackKindMain, |
| 1029 blink::WebString::FromUTF8(track->label()), | 1032 blink::WebString::FromUTF8(track->label()), |
| 1030 blink::WebString::FromUTF8(track->language()), | 1033 blink::WebString::FromUTF8(track->language()), |
| 1031 /*enabled*/ true); | 1034 is_first_audio_track); |
| 1035 is_first_audio_track = false; |
| 1032 } else if (track->type() == MediaTrack::Video) { | 1036 } else if (track->type() == MediaTrack::Video) { |
| 1033 client_->AddVideoTrack(blink::WebString::FromUTF8(track->id()), | 1037 client_->AddVideoTrack(blink::WebString::FromUTF8(track->id()), |
| 1034 blink::WebMediaPlayerClient::kVideoTrackKindMain, | 1038 blink::WebMediaPlayerClient::kVideoTrackKindMain, |
| 1035 blink::WebString::FromUTF8(track->label()), | 1039 blink::WebString::FromUTF8(track->label()), |
| 1036 blink::WebString::FromUTF8(track->language()), | 1040 blink::WebString::FromUTF8(track->language()), |
| 1037 /*selected*/ true); | 1041 is_first_video_track); |
| 1042 is_first_video_track = false; |
| 1038 } else { | 1043 } else { |
| 1039 // Text tracks are not supported through this code path yet. | 1044 // Text tracks are not supported through this code path yet. |
| 1040 NOTREACHED(); | 1045 NOTREACHED(); |
| 1041 } | 1046 } |
| 1042 } | 1047 } |
| 1043 } | 1048 } |
| 1044 | 1049 |
| 1045 void WebMediaPlayerImpl::SetCdm(blink::WebContentDecryptionModule* cdm) { | 1050 void WebMediaPlayerImpl::SetCdm(blink::WebContentDecryptionModule* cdm) { |
| 1046 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 1051 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 1047 DCHECK(cdm); | 1052 DCHECK(cdm); |
| (...skipping 1277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2325 | 2330 |
| 2326 void WebMediaPlayerImpl::RecordUnderflowDuration(base::TimeDelta duration) { | 2331 void WebMediaPlayerImpl::RecordUnderflowDuration(base::TimeDelta duration) { |
| 2327 DCHECK(data_source_ || chunk_demuxer_); | 2332 DCHECK(data_source_ || chunk_demuxer_); |
| 2328 if (data_source_) | 2333 if (data_source_) |
| 2329 UMA_HISTOGRAM_TIMES("Media.UnderflowDuration", duration); | 2334 UMA_HISTOGRAM_TIMES("Media.UnderflowDuration", duration); |
| 2330 else | 2335 else |
| 2331 UMA_HISTOGRAM_TIMES("Media.UnderflowDuration.MSE", duration); | 2336 UMA_HISTOGRAM_TIMES("Media.UnderflowDuration.MSE", duration); |
| 2332 } | 2337 } |
| 2333 | 2338 |
| 2334 } // namespace media | 2339 } // namespace media |
| OLD | NEW |