| 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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 | 135 |
| 136 #define BIND_TO_RENDER_LOOP1(function, arg1) \ | 136 #define BIND_TO_RENDER_LOOP1(function, arg1) \ |
| 137 (DCHECK(main_task_runner_->BelongsToCurrentThread()), \ | 137 (DCHECK(main_task_runner_->BelongsToCurrentThread()), \ |
| 138 BindToCurrentLoop(base::Bind(function, AsWeakPtr(), arg1))) | 138 BindToCurrentLoop(base::Bind(function, AsWeakPtr(), arg1))) |
| 139 | 139 |
| 140 WebMediaPlayerImpl::WebMediaPlayerImpl( | 140 WebMediaPlayerImpl::WebMediaPlayerImpl( |
| 141 blink::WebLocalFrame* frame, | 141 blink::WebLocalFrame* frame, |
| 142 blink::WebMediaPlayerClient* client, | 142 blink::WebMediaPlayerClient* client, |
| 143 blink::WebMediaPlayerEncryptedMediaClient* encrypted_client, | 143 blink::WebMediaPlayerEncryptedMediaClient* encrypted_client, |
| 144 base::WeakPtr<WebMediaPlayerDelegate> delegate, | 144 base::WeakPtr<WebMediaPlayerDelegate> delegate, |
| 145 scoped_ptr<RendererFactory> renderer_factory, | 145 std::unique_ptr<RendererFactory> renderer_factory, |
| 146 linked_ptr<UrlIndex> url_index, | 146 linked_ptr<UrlIndex> url_index, |
| 147 const WebMediaPlayerParams& params) | 147 const WebMediaPlayerParams& params) |
| 148 : frame_(frame), | 148 : frame_(frame), |
| 149 delegate_state_(DelegateState::GONE), | 149 delegate_state_(DelegateState::GONE), |
| 150 is_idle_(false), | 150 is_idle_(false), |
| 151 must_suspend_(false), | 151 must_suspend_(false), |
| 152 network_state_(WebMediaPlayer::NetworkStateEmpty), | 152 network_state_(WebMediaPlayer::NetworkStateEmpty), |
| 153 ready_state_(WebMediaPlayer::ReadyStateHaveNothing), | 153 ready_state_(WebMediaPlayer::ReadyStateHaveNothing), |
| 154 highest_ready_state_(WebMediaPlayer::ReadyStateHaveNothing), | 154 highest_ready_state_(WebMediaPlayer::ReadyStateHaveNothing), |
| 155 preload_(BufferedDataSource::AUTO), | 155 preload_(BufferedDataSource::AUTO), |
| (...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 812 | 812 |
| 813 // TODO(xhwang): Update this UMA name. https://crbug.com/589251 | 813 // TODO(xhwang): Update this UMA name. https://crbug.com/589251 |
| 814 UMA_HISTOGRAM_COUNTS("Media.EME.NeedKey", 1); | 814 UMA_HISTOGRAM_COUNTS("Media.EME.NeedKey", 1); |
| 815 | 815 |
| 816 encrypted_client_->encrypted( | 816 encrypted_client_->encrypted( |
| 817 ConvertToWebInitDataType(init_data_type), init_data.data(), | 817 ConvertToWebInitDataType(init_data_type), init_data.data(), |
| 818 base::saturated_cast<unsigned int>(init_data.size())); | 818 base::saturated_cast<unsigned int>(init_data.size())); |
| 819 } | 819 } |
| 820 | 820 |
| 821 void WebMediaPlayerImpl::OnFFmpegMediaTracksUpdated( | 821 void WebMediaPlayerImpl::OnFFmpegMediaTracksUpdated( |
| 822 scoped_ptr<MediaTracks> tracks) { | 822 std::unique_ptr<MediaTracks> tracks) { |
| 823 // For MSE/chunk_demuxer case the media track updates are handled by | 823 // For MSE/chunk_demuxer case the media track updates are handled by |
| 824 // WebSourceBufferImpl. | 824 // WebSourceBufferImpl. |
| 825 DCHECK(demuxer_.get()); | 825 DCHECK(demuxer_.get()); |
| 826 DCHECK(!chunk_demuxer_); | 826 DCHECK(!chunk_demuxer_); |
| 827 | 827 |
| 828 // Report the media track information to blink. | 828 // Report the media track information to blink. |
| 829 for (const auto& track : tracks->tracks()) { | 829 for (const auto& track : tracks->tracks()) { |
| 830 if (track->type() == MediaTrack::Audio) { | 830 if (track->type() == MediaTrack::Audio) { |
| 831 auto track_id = client_->addAudioTrack( | 831 auto track_id = client_->addAudioTrack( |
| 832 blink::WebString::fromUTF8(track->id()), | 832 blink::WebString::fromUTF8(track->id()), |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1038 | 1038 |
| 1039 const WebInbandTextTrackImpl::Kind web_kind = | 1039 const WebInbandTextTrackImpl::Kind web_kind = |
| 1040 static_cast<WebInbandTextTrackImpl::Kind>(config.kind()); | 1040 static_cast<WebInbandTextTrackImpl::Kind>(config.kind()); |
| 1041 const blink::WebString web_label = | 1041 const blink::WebString web_label = |
| 1042 blink::WebString::fromUTF8(config.label()); | 1042 blink::WebString::fromUTF8(config.label()); |
| 1043 const blink::WebString web_language = | 1043 const blink::WebString web_language = |
| 1044 blink::WebString::fromUTF8(config.language()); | 1044 blink::WebString::fromUTF8(config.language()); |
| 1045 const blink::WebString web_id = | 1045 const blink::WebString web_id = |
| 1046 blink::WebString::fromUTF8(config.id()); | 1046 blink::WebString::fromUTF8(config.id()); |
| 1047 | 1047 |
| 1048 scoped_ptr<WebInbandTextTrackImpl> web_inband_text_track( | 1048 std::unique_ptr<WebInbandTextTrackImpl> web_inband_text_track( |
| 1049 new WebInbandTextTrackImpl(web_kind, web_label, web_language, web_id)); | 1049 new WebInbandTextTrackImpl(web_kind, web_label, web_language, web_id)); |
| 1050 | 1050 |
| 1051 scoped_ptr<media::TextTrack> text_track(new TextTrackImpl( | 1051 std::unique_ptr<media::TextTrack> text_track(new TextTrackImpl( |
| 1052 main_task_runner_, client_, std::move(web_inband_text_track))); | 1052 main_task_runner_, client_, std::move(web_inband_text_track))); |
| 1053 | 1053 |
| 1054 done_cb.Run(std::move(text_track)); | 1054 done_cb.Run(std::move(text_track)); |
| 1055 } | 1055 } |
| 1056 | 1056 |
| 1057 void WebMediaPlayerImpl::OnHidden() { | 1057 void WebMediaPlayerImpl::OnHidden() { |
| 1058 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 1058 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 1059 UpdatePlayState(); | 1059 UpdatePlayState(); |
| 1060 } | 1060 } |
| 1061 | 1061 |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1212 decoder_requires_restart_for_fullscreen_ = true; | 1212 decoder_requires_restart_for_fullscreen_ = true; |
| 1213 if (fullscreen_) { | 1213 if (fullscreen_) { |
| 1214 surface_manager_->CreateFullscreenSurface(pipeline_metadata_.natural_size, | 1214 surface_manager_->CreateFullscreenSurface(pipeline_metadata_.natural_size, |
| 1215 surface_created_cb); | 1215 surface_created_cb); |
| 1216 } else { | 1216 } else { |
| 1217 // Tell the decoder to create its own surface. | 1217 // Tell the decoder to create its own surface. |
| 1218 surface_created_cb.Run(SurfaceManager::kNoSurfaceID); | 1218 surface_created_cb.Run(SurfaceManager::kNoSurfaceID); |
| 1219 } | 1219 } |
| 1220 } | 1220 } |
| 1221 | 1221 |
| 1222 scoped_ptr<Renderer> WebMediaPlayerImpl::CreateRenderer() { | 1222 std::unique_ptr<Renderer> WebMediaPlayerImpl::CreateRenderer() { |
| 1223 RequestSurfaceCB request_surface_cb; | 1223 RequestSurfaceCB request_surface_cb; |
| 1224 #if defined(OS_ANDROID) | 1224 #if defined(OS_ANDROID) |
| 1225 request_surface_cb = | 1225 request_surface_cb = |
| 1226 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnSurfaceRequested); | 1226 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnSurfaceRequested); |
| 1227 #endif | 1227 #endif |
| 1228 return renderer_factory_->CreateRenderer( | 1228 return renderer_factory_->CreateRenderer( |
| 1229 media_task_runner_, worker_task_runner_, audio_source_provider_.get(), | 1229 media_task_runner_, worker_task_runner_, audio_source_provider_.get(), |
| 1230 compositor_, request_surface_cb); | 1230 compositor_, request_surface_cb); |
| 1231 } | 1231 } |
| 1232 | 1232 |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1594 << ", Video: " << stats.video_memory_usage << ", DataSource: " | 1594 << ", Video: " << stats.video_memory_usage << ", DataSource: " |
| 1595 << (data_source_ ? data_source_->GetMemoryUsage() : 0) | 1595 << (data_source_ ? data_source_->GetMemoryUsage() : 0) |
| 1596 << ", Demuxer: " << demuxer_memory_usage; | 1596 << ", Demuxer: " << demuxer_memory_usage; |
| 1597 | 1597 |
| 1598 const int64_t delta = current_memory_usage - last_reported_memory_usage_; | 1598 const int64_t delta = current_memory_usage - last_reported_memory_usage_; |
| 1599 last_reported_memory_usage_ = current_memory_usage; | 1599 last_reported_memory_usage_ = current_memory_usage; |
| 1600 adjust_allocated_memory_cb_.Run(delta); | 1600 adjust_allocated_memory_cb_.Run(delta); |
| 1601 } | 1601 } |
| 1602 | 1602 |
| 1603 } // namespace media | 1603 } // namespace media |
| OLD | NEW |