Chromium Code Reviews| 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 "content/renderer/media/webmediaplayer_impl.h" | 5 #include "content/renderer/media/webmediaplayer_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 197 | 197 |
| 198 // Use the null sink if no sink was provided. | 198 // Use the null sink if no sink was provided. |
| 199 audio_source_provider_ = new WebAudioSourceProviderImpl( | 199 audio_source_provider_ = new WebAudioSourceProviderImpl( |
| 200 params.audio_renderer_sink().get() | 200 params.audio_renderer_sink().get() |
| 201 ? params.audio_renderer_sink() | 201 ? params.audio_renderer_sink() |
| 202 : new media::NullAudioSink(media_loop_)); | 202 : new media::NullAudioSink(media_loop_)); |
| 203 } | 203 } |
| 204 | 204 |
| 205 WebMediaPlayerImpl::~WebMediaPlayerImpl() { | 205 WebMediaPlayerImpl::~WebMediaPlayerImpl() { |
| 206 SetVideoFrameProviderClient(NULL); | 206 SetVideoFrameProviderClient(NULL); |
| 207 GetClient()->setWebLayer(NULL); | 207 client_->setWebLayer(NULL); |
| 208 | 208 |
| 209 DCHECK(main_loop_->BelongsToCurrentThread()); | 209 DCHECK(main_loop_->BelongsToCurrentThread()); |
| 210 media_log_->AddEvent( | 210 media_log_->AddEvent( |
| 211 media_log_->CreateEvent(media::MediaLogEvent::WEBMEDIAPLAYER_DESTROYED)); | 211 media_log_->CreateEvent(media::MediaLogEvent::WEBMEDIAPLAYER_DESTROYED)); |
| 212 | 212 |
| 213 if (delegate_.get()) | 213 if (delegate_.get()) |
| 214 delegate_->PlayerGone(this); | 214 delegate_->PlayerGone(this); |
| 215 | 215 |
| 216 Destroy(); | 216 Destroy(); |
| 217 } | 217 } |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 267 | 267 |
| 268 GURL gurl(url); | 268 GURL gurl(url); |
| 269 UMA_HISTOGRAM_ENUMERATION("Media.URLScheme", URLScheme(gurl), kMaxURLScheme); | 269 UMA_HISTOGRAM_ENUMERATION("Media.URLScheme", URLScheme(gurl), kMaxURLScheme); |
| 270 | 270 |
| 271 // Set subresource URL for crash reporting. | 271 // Set subresource URL for crash reporting. |
| 272 base::debug::SetCrashKeyValue("subresource_url", gurl.spec()); | 272 base::debug::SetCrashKeyValue("subresource_url", gurl.spec()); |
| 273 | 273 |
| 274 load_type_ = load_type; | 274 load_type_ = load_type; |
| 275 | 275 |
| 276 // Handle any volume/preload changes that occurred before load(). | 276 // Handle any volume/preload changes that occurred before load(). |
| 277 setVolume(GetClient()->volume()); | 277 setVolume(client_->volume()); |
| 278 setPreload(GetClient()->preload()); | 278 setPreload(client_->preload()); |
| 279 | 279 |
| 280 SetNetworkState(WebMediaPlayer::NetworkStateLoading); | 280 SetNetworkState(WebMediaPlayer::NetworkStateLoading); |
| 281 SetReadyState(WebMediaPlayer::ReadyStateHaveNothing); | 281 SetReadyState(WebMediaPlayer::ReadyStateHaveNothing); |
| 282 media_log_->AddEvent(media_log_->CreateLoadEvent(url.spec())); | 282 media_log_->AddEvent(media_log_->CreateLoadEvent(url.spec())); |
| 283 | 283 |
| 284 // Media source pipelines can start immediately. | 284 // Media source pipelines can start immediately. |
| 285 if (load_type == LoadTypeMediaSource) { | 285 if (load_type == LoadTypeMediaSource) { |
| 286 supports_save_ = false; | 286 supports_save_ = false; |
| 287 StartPipeline(); | 287 StartPipeline(); |
| 288 return; | 288 return; |
| (...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 867 std::swap(pending_size_change_, size_changed); | 867 std::swap(pending_size_change_, size_changed); |
| 868 if (pending_repaint_) { | 868 if (pending_repaint_) { |
| 869 TRACE_EVENT_ASYNC_END0( | 869 TRACE_EVENT_ASYNC_END0( |
| 870 "media", "WebMediaPlayerImpl:repaintPending", this); | 870 "media", "WebMediaPlayerImpl:repaintPending", this); |
| 871 pending_repaint_ = false; | 871 pending_repaint_ = false; |
| 872 } | 872 } |
| 873 } | 873 } |
| 874 | 874 |
| 875 if (size_changed) { | 875 if (size_changed) { |
| 876 TRACE_EVENT0("media", "WebMediaPlayerImpl:clientSizeChanged"); | 876 TRACE_EVENT0("media", "WebMediaPlayerImpl:clientSizeChanged"); |
| 877 GetClient()->sizeChanged(); | 877 client_->sizeChanged(); |
| 878 } | 878 } |
| 879 | 879 |
| 880 TRACE_EVENT0("media", "WebMediaPlayerImpl:clientRepaint"); | 880 TRACE_EVENT0("media", "WebMediaPlayerImpl:clientRepaint"); |
| 881 GetClient()->repaint(); | 881 client_->repaint(); |
| 882 } | 882 } |
| 883 | 883 |
| 884 void WebMediaPlayerImpl::OnPipelineSeek(PipelineStatus status) { | 884 void WebMediaPlayerImpl::OnPipelineSeek(PipelineStatus status) { |
| 885 DCHECK(main_loop_->BelongsToCurrentThread()); | 885 DCHECK(main_loop_->BelongsToCurrentThread()); |
| 886 starting_ = false; | 886 starting_ = false; |
| 887 seeking_ = false; | 887 seeking_ = false; |
| 888 if (pending_seek_) { | 888 if (pending_seek_) { |
| 889 pending_seek_ = false; | 889 pending_seek_ = false; |
| 890 seek(pending_seek_seconds_); | 890 seek(pending_seek_seconds_); |
| 891 return; | 891 return; |
| 892 } | 892 } |
| 893 | 893 |
| 894 if (status != media::PIPELINE_OK) { | 894 if (status != media::PIPELINE_OK) { |
| 895 OnPipelineError(status); | 895 OnPipelineError(status); |
| 896 return; | 896 return; |
| 897 } | 897 } |
| 898 | 898 |
| 899 // Update our paused time. | 899 // Update our paused time. |
| 900 if (paused_) | 900 if (paused_) |
| 901 paused_time_ = pipeline_->GetMediaTime(); | 901 paused_time_ = pipeline_->GetMediaTime(); |
| 902 | 902 |
| 903 GetClient()->timeChanged(); | 903 client_->timeChanged(); |
| 904 } | 904 } |
| 905 | 905 |
| 906 void WebMediaPlayerImpl::OnPipelineEnded() { | 906 void WebMediaPlayerImpl::OnPipelineEnded() { |
| 907 DCHECK(main_loop_->BelongsToCurrentThread()); | 907 DCHECK(main_loop_->BelongsToCurrentThread()); |
| 908 GetClient()->timeChanged(); | 908 client_->timeChanged(); |
| 909 } | 909 } |
| 910 | 910 |
| 911 void WebMediaPlayerImpl::OnPipelineError(PipelineStatus error) { | 911 void WebMediaPlayerImpl::OnPipelineError(PipelineStatus error) { |
| 912 DCHECK(main_loop_->BelongsToCurrentThread()); | 912 DCHECK(main_loop_->BelongsToCurrentThread()); |
| 913 DCHECK_NE(error, media::PIPELINE_OK); | 913 DCHECK_NE(error, media::PIPELINE_OK); |
| 914 | 914 |
| 915 if (ready_state_ == WebMediaPlayer::ReadyStateHaveNothing) { | 915 if (ready_state_ == WebMediaPlayer::ReadyStateHaveNothing) { |
| 916 // Any error that occurs before reaching ReadyStateHaveMetadata should | 916 // Any error that occurs before reaching ReadyStateHaveMetadata should |
| 917 // be considered a format error. | 917 // be considered a format error. |
| 918 SetNetworkState(WebMediaPlayer::NetworkStateFormatError); | 918 SetNetworkState(WebMediaPlayer::NetworkStateFormatError); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 930 } | 930 } |
| 931 | 931 |
| 932 void WebMediaPlayerImpl::OnPipelineBufferingState( | 932 void WebMediaPlayerImpl::OnPipelineBufferingState( |
| 933 media::Pipeline::BufferingState buffering_state) { | 933 media::Pipeline::BufferingState buffering_state) { |
| 934 DVLOG(1) << "OnPipelineBufferingState(" << buffering_state << ")"; | 934 DVLOG(1) << "OnPipelineBufferingState(" << buffering_state << ")"; |
| 935 | 935 |
| 936 switch (buffering_state) { | 936 switch (buffering_state) { |
| 937 case media::Pipeline::kHaveMetadata: | 937 case media::Pipeline::kHaveMetadata: |
| 938 SetReadyState(WebMediaPlayer::ReadyStateHaveMetadata); | 938 SetReadyState(WebMediaPlayer::ReadyStateHaveMetadata); |
| 939 | 939 |
| 940 if (hasVideo() && GetClient()->needsWebLayerForVideo()) { | 940 if (hasVideo() && client_->needsWebLayerForVideo()) { |
| 941 DCHECK(!video_weblayer_); | 941 DCHECK(!video_weblayer_); |
| 942 video_weblayer_.reset( | 942 video_weblayer_.reset( |
| 943 new webkit::WebLayerImpl(cc::VideoLayer::Create(this))); | 943 new webkit::WebLayerImpl(cc::VideoLayer::Create(this))); |
| 944 GetClient()->setWebLayer(video_weblayer_.get()); | 944 client_->setWebLayer(video_weblayer_.get()); |
| 945 } | 945 } |
| 946 break; | 946 break; |
| 947 case media::Pipeline::kPrerollCompleted: | 947 case media::Pipeline::kPrerollCompleted: |
| 948 // Only transition to ReadyStateHaveEnoughData if we don't have | 948 // Only transition to ReadyStateHaveEnoughData if we don't have |
| 949 // any pending seeks because the transition can cause Blink to | 949 // any pending seeks because the transition can cause Blink to |
| 950 // report that the most recent seek has completed. | 950 // report that the most recent seek has completed. |
| 951 if (!pending_seek_) | 951 if (!pending_seek_) |
| 952 SetReadyState(WebMediaPlayer::ReadyStateHaveEnoughData); | 952 SetReadyState(WebMediaPlayer::ReadyStateHaveEnoughData); |
| 953 break; | 953 break; |
| 954 } | 954 } |
| 955 | 955 |
| 956 // Repaint to trigger UI update. | 956 // Repaint to trigger UI update. |
| 957 Repaint(); | 957 Repaint(); |
| 958 } | 958 } |
| 959 | 959 |
| 960 void WebMediaPlayerImpl::OnDemuxerOpened() { | 960 void WebMediaPlayerImpl::OnDemuxerOpened() { |
| 961 DCHECK(main_loop_->BelongsToCurrentThread()); | 961 DCHECK(main_loop_->BelongsToCurrentThread()); |
| 962 GetClient()->mediaSourceOpened(new WebMediaSourceImpl( | 962 client_->mediaSourceOpened(new WebMediaSourceImpl( |
| 963 chunk_demuxer_, base::Bind(&LogMediaSourceError, media_log_))); | 963 chunk_demuxer_, base::Bind(&LogMediaSourceError, media_log_))); |
| 964 } | 964 } |
| 965 | 965 |
| 966 void WebMediaPlayerImpl::OnKeyAdded(const std::string& session_id) { | 966 void WebMediaPlayerImpl::OnKeyAdded(const std::string& session_id) { |
| 967 DCHECK(main_loop_->BelongsToCurrentThread()); | 967 DCHECK(main_loop_->BelongsToCurrentThread()); |
| 968 EmeUMAHistogramCounts(current_key_system_, "KeyAdded", 1); | 968 EmeUMAHistogramCounts(current_key_system_, "KeyAdded", 1); |
| 969 GetClient()->keyAdded(current_key_system_, | 969 client_->keyAdded(current_key_system_, WebString::fromUTF8(session_id)); |
| 970 WebString::fromUTF8(session_id)); | |
| 971 } | 970 } |
| 972 | 971 |
| 973 void WebMediaPlayerImpl::OnNeedKey(const std::string& type, | 972 void WebMediaPlayerImpl::OnNeedKey(const std::string& type, |
| 974 const std::vector<uint8>& init_data) { | 973 const std::vector<uint8>& init_data) { |
| 975 DCHECK(main_loop_->BelongsToCurrentThread()); | 974 DCHECK(main_loop_->BelongsToCurrentThread()); |
| 976 | 975 |
| 977 // Do not fire NeedKey event if encrypted media is not enabled. | 976 // Do not fire NeedKey event if encrypted media is not enabled. |
| 978 if (!decryptor_) | 977 if (!decryptor_) |
| 979 return; | 978 return; |
| 980 | 979 |
| 981 UMA_HISTOGRAM_COUNTS(kMediaEme + std::string("NeedKey"), 1); | 980 UMA_HISTOGRAM_COUNTS(kMediaEme + std::string("NeedKey"), 1); |
| 982 | 981 |
| 983 DCHECK(init_data_type_.empty() || type.empty() || type == init_data_type_); | 982 DCHECK(init_data_type_.empty() || type.empty() || type == init_data_type_); |
| 984 if (init_data_type_.empty()) | 983 if (init_data_type_.empty()) |
| 985 init_data_type_ = type; | 984 init_data_type_ = type; |
| 986 | 985 |
| 987 const uint8* init_data_ptr = init_data.empty() ? NULL : &init_data[0]; | 986 const uint8* init_data_ptr = init_data.empty() ? NULL : &init_data[0]; |
| 988 GetClient()->keyNeeded(WebString(), | 987 client_->keyNeeded(WebString(), WebString(), init_data_ptr, init_data.size()); |
| 989 WebString(), | |
| 990 init_data_ptr, | |
| 991 init_data.size()); | |
| 992 } | 988 } |
| 993 | 989 |
| 994 void WebMediaPlayerImpl::OnAddTextTrack( | 990 void WebMediaPlayerImpl::OnAddTextTrack( |
| 995 const media::TextTrackConfig& config, | 991 const media::TextTrackConfig& config, |
| 996 const media::AddTextTrackDoneCB& done_cb) { | 992 const media::AddTextTrackDoneCB& done_cb) { |
| 997 DCHECK(main_loop_->BelongsToCurrentThread()); | 993 DCHECK(main_loop_->BelongsToCurrentThread()); |
| 998 | 994 |
| 999 const WebInbandTextTrackImpl::Kind web_kind = | 995 const WebInbandTextTrackImpl::Kind web_kind = |
| 1000 static_cast<WebInbandTextTrackImpl::Kind>(config.kind()); | 996 static_cast<WebInbandTextTrackImpl::Kind>(config.kind()); |
| 1001 const blink::WebString web_label = | 997 const blink::WebString web_label = |
| 1002 blink::WebString::fromUTF8(config.label()); | 998 blink::WebString::fromUTF8(config.label()); |
| 1003 const blink::WebString web_language = | 999 const blink::WebString web_language = |
| 1004 blink::WebString::fromUTF8(config.language()); | 1000 blink::WebString::fromUTF8(config.language()); |
| 1005 const blink::WebString web_id = | 1001 const blink::WebString web_id = |
| 1006 blink::WebString::fromUTF8(config.id()); | 1002 blink::WebString::fromUTF8(config.id()); |
| 1007 | 1003 |
| 1008 scoped_ptr<WebInbandTextTrackImpl> web_inband_text_track( | 1004 scoped_ptr<WebInbandTextTrackImpl> web_inband_text_track( |
| 1009 new WebInbandTextTrackImpl(web_kind, web_label, web_language, web_id, | 1005 new WebInbandTextTrackImpl(web_kind, web_label, web_language, web_id, |
| 1010 text_track_index_++)); | 1006 text_track_index_++)); |
| 1011 | 1007 |
| 1012 scoped_ptr<media::TextTrack> text_track( | 1008 scoped_ptr<media::TextTrack> text_track( |
| 1013 new TextTrackImpl(main_loop_, GetClient(), web_inband_text_track.Pass())); | 1009 new TextTrackImpl(main_loop_, client_, web_inband_text_track.Pass())); |
| 1014 | 1010 |
| 1015 done_cb.Run(text_track.Pass()); | 1011 done_cb.Run(text_track.Pass()); |
| 1016 } | 1012 } |
| 1017 | 1013 |
| 1018 void WebMediaPlayerImpl::OnKeyError(const std::string& session_id, | 1014 void WebMediaPlayerImpl::OnKeyError(const std::string& session_id, |
| 1019 media::MediaKeys::KeyError error_code, | 1015 media::MediaKeys::KeyError error_code, |
| 1020 int system_code) { | 1016 int system_code) { |
| 1021 DCHECK(main_loop_->BelongsToCurrentThread()); | 1017 DCHECK(main_loop_->BelongsToCurrentThread()); |
| 1022 | 1018 |
| 1023 EmeUMAHistogramEnumeration(current_key_system_, "KeyError", | 1019 EmeUMAHistogramEnumeration(current_key_system_, "KeyError", |
| 1024 error_code, media::MediaKeys::kMaxKeyError); | 1020 error_code, media::MediaKeys::kMaxKeyError); |
| 1025 | 1021 |
| 1026 GetClient()->keyError( | 1022 client_->keyError( |
| 1027 current_key_system_, | 1023 current_key_system_, |
| 1028 WebString::fromUTF8(session_id), | 1024 WebString::fromUTF8(session_id), |
| 1029 static_cast<blink::WebMediaPlayerClient::MediaKeyErrorCode>(error_code), | 1025 static_cast<blink::WebMediaPlayerClient::MediaKeyErrorCode>(error_code), |
| 1030 system_code); | 1026 system_code); |
| 1031 } | 1027 } |
| 1032 | 1028 |
| 1033 void WebMediaPlayerImpl::OnKeyMessage(const std::string& session_id, | 1029 void WebMediaPlayerImpl::OnKeyMessage(const std::string& session_id, |
| 1034 const std::vector<uint8>& message, | 1030 const std::vector<uint8>& message, |
| 1035 const std::string& default_url) { | 1031 const std::string& default_url) { |
| 1036 DCHECK(main_loop_->BelongsToCurrentThread()); | 1032 DCHECK(main_loop_->BelongsToCurrentThread()); |
| 1037 | 1033 |
| 1038 const GURL default_url_gurl(default_url); | 1034 const GURL default_url_gurl(default_url); |
| 1039 DLOG_IF(WARNING, !default_url.empty() && !default_url_gurl.is_valid()) | 1035 DLOG_IF(WARNING, !default_url.empty() && !default_url_gurl.is_valid()) |
| 1040 << "Invalid URL in default_url: " << default_url; | 1036 << "Invalid URL in default_url: " << default_url; |
| 1041 | 1037 |
| 1042 GetClient()->keyMessage(current_key_system_, | 1038 client_->keyMessage(current_key_system_, |
| 1043 WebString::fromUTF8(session_id), | 1039 WebString::fromUTF8(session_id), |
| 1044 message.empty() ? NULL : &message[0], | 1040 message.empty() ? NULL : &message[0], |
| 1045 message.size(), | 1041 message.size(), |
| 1046 default_url_gurl); | 1042 default_url_gurl); |
| 1047 } | 1043 } |
| 1048 | 1044 |
| 1049 void WebMediaPlayerImpl::SetOpaque(bool opaque) { | 1045 void WebMediaPlayerImpl::SetOpaque(bool opaque) { |
| 1050 DCHECK(main_loop_->BelongsToCurrentThread()); | 1046 DCHECK(main_loop_->BelongsToCurrentThread()); |
| 1051 | 1047 |
| 1052 GetClient()->setOpaque(opaque); | 1048 client_->setOpaque(opaque); |
| 1053 } | 1049 } |
| 1054 | 1050 |
| 1055 void WebMediaPlayerImpl::DataSourceInitialized(const GURL& gurl, bool success) { | 1051 void WebMediaPlayerImpl::DataSourceInitialized(const GURL& gurl, bool success) { |
| 1056 DCHECK(main_loop_->BelongsToCurrentThread()); | 1052 DCHECK(main_loop_->BelongsToCurrentThread()); |
| 1057 | 1053 |
| 1058 if (!success) { | 1054 if (!success) { |
| 1059 SetNetworkState(WebMediaPlayer::NetworkStateFormatError); | 1055 SetNetworkState(WebMediaPlayer::NetworkStateFormatError); |
| 1060 Repaint(); | 1056 Repaint(); |
| 1061 return; | 1057 return; |
| 1062 } | 1058 } |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1169 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnPipelineSeek), | 1165 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnPipelineSeek), |
| 1170 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnPipelineBufferingState), | 1166 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnPipelineBufferingState), |
| 1171 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnDurationChange)); | 1167 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnDurationChange)); |
| 1172 } | 1168 } |
| 1173 | 1169 |
| 1174 void WebMediaPlayerImpl::SetNetworkState(WebMediaPlayer::NetworkState state) { | 1170 void WebMediaPlayerImpl::SetNetworkState(WebMediaPlayer::NetworkState state) { |
| 1175 DCHECK(main_loop_->BelongsToCurrentThread()); | 1171 DCHECK(main_loop_->BelongsToCurrentThread()); |
| 1176 DVLOG(1) << "SetNetworkState: " << state; | 1172 DVLOG(1) << "SetNetworkState: " << state; |
| 1177 network_state_ = state; | 1173 network_state_ = state; |
| 1178 // Always notify to ensure client has the latest value. | 1174 // Always notify to ensure client has the latest value. |
| 1179 GetClient()->networkStateChanged(); | 1175 client_->networkStateChanged(); |
| 1180 } | 1176 } |
| 1181 | 1177 |
| 1182 void WebMediaPlayerImpl::SetReadyState(WebMediaPlayer::ReadyState state) { | 1178 void WebMediaPlayerImpl::SetReadyState(WebMediaPlayer::ReadyState state) { |
| 1183 DCHECK(main_loop_->BelongsToCurrentThread()); | 1179 DCHECK(main_loop_->BelongsToCurrentThread()); |
| 1184 DVLOG(1) << "SetReadyState: " << state; | 1180 DVLOG(1) << "SetReadyState: " << state; |
| 1185 | 1181 |
| 1186 if (state == WebMediaPlayer::ReadyStateHaveEnoughData && | 1182 if (state == WebMediaPlayer::ReadyStateHaveEnoughData && |
| 1187 is_local_source_ && | 1183 is_local_source_ && |
| 1188 network_state_ == WebMediaPlayer::NetworkStateLoading) | 1184 network_state_ == WebMediaPlayer::NetworkStateLoading) |
| 1189 SetNetworkState(WebMediaPlayer::NetworkStateLoaded); | 1185 SetNetworkState(WebMediaPlayer::NetworkStateLoaded); |
| 1190 | 1186 |
| 1191 ready_state_ = state; | 1187 ready_state_ = state; |
| 1192 // Always notify to ensure client has the latest value. | 1188 // Always notify to ensure client has the latest value. |
| 1193 GetClient()->readyStateChanged(); | 1189 client_->readyStateChanged(); |
| 1194 } | 1190 } |
| 1195 | 1191 |
| 1196 void WebMediaPlayerImpl::Destroy() { | 1192 void WebMediaPlayerImpl::Destroy() { |
| 1197 DCHECK(main_loop_->BelongsToCurrentThread()); | 1193 DCHECK(main_loop_->BelongsToCurrentThread()); |
| 1198 | 1194 |
| 1199 // Abort any pending IO so stopping the pipeline doesn't get blocked. | 1195 // Abort any pending IO so stopping the pipeline doesn't get blocked. |
| 1200 if (data_source_) | 1196 if (data_source_) |
| 1201 data_source_->Abort(); | 1197 data_source_->Abort(); |
| 1202 if (chunk_demuxer_) { | 1198 if (chunk_demuxer_) { |
| 1203 chunk_demuxer_->Shutdown(); | 1199 chunk_demuxer_->Shutdown(); |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 1222 -kPlayerExtraMemory); | 1218 -kPlayerExtraMemory); |
| 1223 incremented_externally_allocated_memory_ = false; | 1219 incremented_externally_allocated_memory_ = false; |
| 1224 } | 1220 } |
| 1225 | 1221 |
| 1226 // Release any final references now that everything has stopped. | 1222 // Release any final references now that everything has stopped. |
| 1227 pipeline_.reset(); | 1223 pipeline_.reset(); |
| 1228 demuxer_.reset(); | 1224 demuxer_.reset(); |
| 1229 data_source_.reset(); | 1225 data_source_.reset(); |
| 1230 } | 1226 } |
| 1231 | 1227 |
| 1232 blink::WebMediaPlayerClient* WebMediaPlayerImpl::GetClient() { | |
| 1233 DCHECK(main_loop_->BelongsToCurrentThread()); | |
|
Ami GONE FROM CHROMIUM
2013/12/19 21:00:50
This is the only bit I (slightly) regret losing wi
scherkus (not reviewing)
2013/12/19 21:14:10
that assumes future coders realize they should be
| |
| 1234 DCHECK(client_); | |
| 1235 return client_; | |
| 1236 } | |
| 1237 | |
| 1238 blink::WebAudioSourceProvider* WebMediaPlayerImpl::audioSourceProvider() { | 1228 blink::WebAudioSourceProvider* WebMediaPlayerImpl::audioSourceProvider() { |
| 1239 return audio_source_provider_.get(); | 1229 return audio_source_provider_.get(); |
| 1240 } | 1230 } |
| 1241 | 1231 |
| 1242 void WebMediaPlayerImpl::IncrementExternallyAllocatedMemory() { | 1232 void WebMediaPlayerImpl::IncrementExternallyAllocatedMemory() { |
| 1243 DCHECK(main_loop_->BelongsToCurrentThread()); | 1233 DCHECK(main_loop_->BelongsToCurrentThread()); |
| 1244 incremented_externally_allocated_memory_ = true; | 1234 incremented_externally_allocated_memory_ = true; |
| 1245 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory( | 1235 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory( |
| 1246 kPlayerExtraMemory); | 1236 kPlayerExtraMemory); |
| 1247 } | 1237 } |
| 1248 | 1238 |
| 1249 double WebMediaPlayerImpl::GetPipelineDuration() const { | 1239 double WebMediaPlayerImpl::GetPipelineDuration() const { |
| 1250 base::TimeDelta duration = pipeline_->GetMediaDuration(); | 1240 base::TimeDelta duration = pipeline_->GetMediaDuration(); |
| 1251 | 1241 |
| 1252 // Return positive infinity if the resource is unbounded. | 1242 // Return positive infinity if the resource is unbounded. |
| 1253 // http://www.whatwg.org/specs/web-apps/current-work/multipage/video.html#dom- media-duration | 1243 // http://www.whatwg.org/specs/web-apps/current-work/multipage/video.html#dom- media-duration |
| 1254 if (duration == media::kInfiniteDuration()) | 1244 if (duration == media::kInfiniteDuration()) |
| 1255 return std::numeric_limits<double>::infinity(); | 1245 return std::numeric_limits<double>::infinity(); |
| 1256 | 1246 |
| 1257 return duration.InSecondsF(); | 1247 return duration.InSecondsF(); |
| 1258 } | 1248 } |
| 1259 | 1249 |
| 1260 void WebMediaPlayerImpl::OnDurationChange() { | 1250 void WebMediaPlayerImpl::OnDurationChange() { |
| 1261 if (ready_state_ == WebMediaPlayer::ReadyStateHaveNothing) | 1251 if (ready_state_ == WebMediaPlayer::ReadyStateHaveNothing) |
| 1262 return; | 1252 return; |
| 1263 | 1253 |
| 1264 GetClient()->durationChanged(); | 1254 client_->durationChanged(); |
| 1265 } | 1255 } |
| 1266 | 1256 |
| 1267 void WebMediaPlayerImpl::FrameReady( | 1257 void WebMediaPlayerImpl::FrameReady( |
| 1268 const scoped_refptr<media::VideoFrame>& frame) { | 1258 const scoped_refptr<media::VideoFrame>& frame) { |
| 1269 base::AutoLock auto_lock(lock_); | 1259 base::AutoLock auto_lock(lock_); |
| 1270 | 1260 |
| 1271 if (current_frame_ && | 1261 if (current_frame_ && |
| 1272 current_frame_->natural_size() != frame->natural_size() && | 1262 current_frame_->natural_size() != frame->natural_size() && |
| 1273 !pending_size_change_) { | 1263 !pending_size_change_) { |
| 1274 pending_size_change_ = true; | 1264 pending_size_change_ = true; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1309 // The |current_frame_| wasn't painted, it is being replaced, and we haven't | 1299 // The |current_frame_| wasn't painted, it is being replaced, and we haven't |
| 1310 // even gotten the chance to request a repaint for it yet. Mark it as dropped. | 1300 // even gotten the chance to request a repaint for it yet. Mark it as dropped. |
| 1311 TRACE_EVENT0("media", "WebMediaPlayerImpl:frameDropped"); | 1301 TRACE_EVENT0("media", "WebMediaPlayerImpl:frameDropped"); |
| 1312 DVLOG(1) << "Frame dropped before being painted: " | 1302 DVLOG(1) << "Frame dropped before being painted: " |
| 1313 << current_frame_->GetTimestamp().InSecondsF(); | 1303 << current_frame_->GetTimestamp().InSecondsF(); |
| 1314 if (frames_dropped_before_paint_ < kuint32max) | 1304 if (frames_dropped_before_paint_ < kuint32max) |
| 1315 frames_dropped_before_paint_++; | 1305 frames_dropped_before_paint_++; |
| 1316 } | 1306 } |
| 1317 | 1307 |
| 1318 } // namespace content | 1308 } // namespace content |
| OLD | NEW |