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

Side by Side Diff: media/blink/webmediaplayer_impl.cc

Issue 1904793002: Move Pipeline permanent callbacks into Pipeline::Client interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 7 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 unified diff | Download patch
OLDNEW
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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 media_task_runner_(params.media_task_runner()), 158 media_task_runner_(params.media_task_runner()),
159 worker_task_runner_(params.worker_task_runner()), 159 worker_task_runner_(params.worker_task_runner()),
160 media_log_(params.media_log()), 160 media_log_(params.media_log()),
161 pipeline_(media_task_runner_, media_log_.get()), 161 pipeline_(media_task_runner_, media_log_.get()),
162 pipeline_controller_( 162 pipeline_controller_(
163 &pipeline_, 163 &pipeline_,
164 base::Bind(&WebMediaPlayerImpl::CreateRenderer, 164 base::Bind(&WebMediaPlayerImpl::CreateRenderer,
165 base::Unretained(this)), 165 base::Unretained(this)),
166 base::Bind(&WebMediaPlayerImpl::OnPipelineSeeked, AsWeakPtr()), 166 base::Bind(&WebMediaPlayerImpl::OnPipelineSeeked, AsWeakPtr()),
167 base::Bind(&WebMediaPlayerImpl::OnPipelineSuspended, AsWeakPtr()), 167 base::Bind(&WebMediaPlayerImpl::OnPipelineSuspended, AsWeakPtr()),
168 base::Bind(&WebMediaPlayerImpl::OnPipelineError, AsWeakPtr())), 168 base::Bind(&WebMediaPlayerImpl::OnError, AsWeakPtr())),
169 load_type_(LoadTypeURL), 169 load_type_(LoadTypeURL),
170 opaque_(false), 170 opaque_(false),
171 playback_rate_(0.0), 171 playback_rate_(0.0),
172 paused_(true), 172 paused_(true),
173 seeking_(false), 173 seeking_(false),
174 pending_suspend_resume_cycle_(false), 174 pending_suspend_resume_cycle_(false),
175 ended_(false), 175 ended_(false),
176 should_notify_time_changed_(false), 176 should_notify_time_changed_(false),
177 fullscreen_(false), 177 fullscreen_(false),
178 decoder_requires_restart_for_fullscreen_(false), 178 decoder_requires_restart_for_fullscreen_(false),
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 // 2) For MSE. 433 // 2) For MSE.
434 // Because the buffers may have changed between seeks, MSE seeks are 434 // Because the buffers may have changed between seeks, MSE seeks are
435 // never elided. 435 // never elided.
436 if (paused_ && pipeline_controller_.IsStable() && paused_time_ == time && 436 if (paused_ && pipeline_controller_.IsStable() && paused_time_ == time &&
437 !chunk_demuxer_) { 437 !chunk_demuxer_) {
438 // If the ready state was high enough before, we can indicate that the seek 438 // If the ready state was high enough before, we can indicate that the seek
439 // completed just by restoring it. Otherwise we will just wait for the real 439 // completed just by restoring it. Otherwise we will just wait for the real
440 // ready state change to eventually happen. 440 // ready state change to eventually happen.
441 if (old_state == ReadyStateHaveEnoughData) { 441 if (old_state == ReadyStateHaveEnoughData) {
442 main_task_runner_->PostTask( 442 main_task_runner_->PostTask(
443 FROM_HERE, 443 FROM_HERE, base::Bind(&WebMediaPlayerImpl::OnBufferingStateChange,
444 base::Bind(&WebMediaPlayerImpl::OnPipelineBufferingStateChanged, 444 AsWeakPtr(), BUFFERING_HAVE_ENOUGH));
445 AsWeakPtr(), BUFFERING_HAVE_ENOUGH));
446 } 445 }
447 return; 446 return;
448 } 447 }
449 448
450 // TODO(sandersd): Ideally we would not clear the idle state if 449 // TODO(sandersd): Ideally we would not clear the idle state if
451 // |pipeline_controller_| can elide the seek. 450 // |pipeline_controller_| can elide the seek.
452 is_idle_ = false; 451 is_idle_ = false;
453 ended_ = false; 452 ended_ = false;
454 453
455 seeking_ = true; 454 seeking_ = true;
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 blink::WebString::fromUTF8(track->language()), 841 blink::WebString::fromUTF8(track->language()),
843 /*selected*/ true); 842 /*selected*/ true);
844 (void)track_id; 843 (void)track_id;
845 } else { 844 } else {
846 // Text tracks are not supported through this code path yet. 845 // Text tracks are not supported through this code path yet.
847 NOTREACHED(); 846 NOTREACHED();
848 } 847 }
849 } 848 }
850 } 849 }
851 850
852 void WebMediaPlayerImpl::OnWaitingForDecryptionKey() {
853 encrypted_client_->didBlockPlaybackWaitingForKey();
854
855 // TODO(jrummell): didResumePlaybackBlockedForKey() should only be called
856 // when a key has been successfully added (e.g. OnSessionKeysChange() with
857 // |has_additional_usable_key| = true). http://crbug.com/461903
858 encrypted_client_->didResumePlaybackBlockedForKey();
859 }
860
861 void WebMediaPlayerImpl::SetCdm(const CdmAttachedCB& cdm_attached_cb, 851 void WebMediaPlayerImpl::SetCdm(const CdmAttachedCB& cdm_attached_cb,
862 CdmContext* cdm_context) { 852 CdmContext* cdm_context) {
863 if (!cdm_context) { 853 if (!cdm_context) {
864 cdm_attached_cb.Run(false); 854 cdm_attached_cb.Run(false);
865 return; 855 return;
866 } 856 }
867 857
868 // If CDM initialization succeeded, tell the pipeline about it. 858 // If CDM initialization succeeded, tell the pipeline about it.
869 pipeline_.SetCdm(cdm_context, cdm_attached_cb); 859 pipeline_.SetCdm(cdm_context, cdm_attached_cb);
870 } 860 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 } 909 }
920 910
921 ReportMemoryUsage(); 911 ReportMemoryUsage();
922 912
923 if (pending_suspend_resume_cycle_) { 913 if (pending_suspend_resume_cycle_) {
924 pending_suspend_resume_cycle_ = false; 914 pending_suspend_resume_cycle_ = false;
925 UpdatePlayState(); 915 UpdatePlayState();
926 } 916 }
927 } 917 }
928 918
929 void WebMediaPlayerImpl::OnPipelineEnded() { 919 void WebMediaPlayerImpl::OnDemuxerOpened() {
920 DCHECK(main_task_runner_->BelongsToCurrentThread());
921 client_->mediaSourceOpened(
922 new WebMediaSourceImpl(chunk_demuxer_, media_log_));
923 }
924
925 void WebMediaPlayerImpl::OnError(PipelineStatus status) {
926 DVLOG(1) << __FUNCTION__;
927 DCHECK(main_task_runner_->BelongsToCurrentThread());
928 DCHECK_NE(status, PIPELINE_OK);
929
930 if (suppress_destruction_errors_)
931 return;
932
933 media_log_->AddEvent(media_log_->CreatePipelineErrorEvent(status));
934
935 if (ready_state_ == WebMediaPlayer::ReadyStateHaveNothing) {
936 // Any error that occurs before reaching ReadyStateHaveMetadata should
937 // be considered a format error.
938 SetNetworkState(WebMediaPlayer::NetworkStateFormatError);
939 } else {
940 SetNetworkState(PipelineErrorToNetworkState(status));
941 }
942
943 UpdatePlayState();
944 }
945
946 void WebMediaPlayerImpl::OnEnded() {
930 DVLOG(1) << __FUNCTION__; 947 DVLOG(1) << __FUNCTION__;
931 DCHECK(main_task_runner_->BelongsToCurrentThread()); 948 DCHECK(main_task_runner_->BelongsToCurrentThread());
932 949
933 // Ignore state changes until we've completed all outstanding operations. 950 // Ignore state changes until we've completed all outstanding operations.
934 if (!pipeline_controller_.IsStable()) 951 if (!pipeline_controller_.IsStable())
935 return; 952 return;
936 953
937 ended_ = true; 954 ended_ = true;
938 client_->timeChanged(); 955 client_->timeChanged();
939 956
940 // We don't actually want this to run until |client_| calls seek() or pause(), 957 // We don't actually want this to run until |client_| calls seek() or pause(),
941 // but that should have already happened in timeChanged() and so this is 958 // but that should have already happened in timeChanged() and so this is
942 // expected to be a no-op. 959 // expected to be a no-op.
943 UpdatePlayState(); 960 UpdatePlayState();
944 } 961 }
945 962
946 void WebMediaPlayerImpl::OnPipelineError(PipelineStatus error) { 963 void WebMediaPlayerImpl::OnMetadata(PipelineMetadata metadata) {
947 DVLOG(1) << __FUNCTION__; 964 DVLOG(1) << __FUNCTION__;
948 DCHECK(main_task_runner_->BelongsToCurrentThread()); 965 DCHECK(main_task_runner_->BelongsToCurrentThread());
949 DCHECK_NE(error, PIPELINE_OK);
950
951 if (suppress_destruction_errors_)
952 return;
953
954 media_log_->AddEvent(media_log_->CreatePipelineErrorEvent(error));
955
956 if (ready_state_ == WebMediaPlayer::ReadyStateHaveNothing) {
957 // Any error that occurs before reaching ReadyStateHaveMetadata should
958 // be considered a format error.
959 SetNetworkState(WebMediaPlayer::NetworkStateFormatError);
960 } else {
961 SetNetworkState(PipelineErrorToNetworkState(error));
962 }
963
964 UpdatePlayState();
965 }
966
967 void WebMediaPlayerImpl::OnPipelineMetadata(
968 PipelineMetadata metadata) {
969 DVLOG(1) << __FUNCTION__;
970 966
971 pipeline_metadata_ = metadata; 967 pipeline_metadata_ = metadata;
972 968
973 UMA_HISTOGRAM_ENUMERATION("Media.VideoRotation", metadata.video_rotation, 969 UMA_HISTOGRAM_ENUMERATION("Media.VideoRotation", metadata.video_rotation,
974 VIDEO_ROTATION_MAX + 1); 970 VIDEO_ROTATION_MAX + 1);
975 SetReadyState(WebMediaPlayer::ReadyStateHaveMetadata); 971 SetReadyState(WebMediaPlayer::ReadyStateHaveMetadata);
976 972
977 if (hasVideo()) { 973 if (hasVideo()) {
978 DCHECK(!video_weblayer_); 974 DCHECK(!video_weblayer_);
979 scoped_refptr<cc::VideoLayer> layer = 975 scoped_refptr<cc::VideoLayer> layer =
980 cc::VideoLayer::Create(compositor_, pipeline_metadata_.video_rotation); 976 cc::VideoLayer::Create(compositor_, pipeline_metadata_.video_rotation);
981 977
982 if (pipeline_metadata_.video_rotation == VIDEO_ROTATION_90 || 978 if (pipeline_metadata_.video_rotation == VIDEO_ROTATION_90 ||
983 pipeline_metadata_.video_rotation == VIDEO_ROTATION_270) { 979 pipeline_metadata_.video_rotation == VIDEO_ROTATION_270) {
984 gfx::Size size = pipeline_metadata_.natural_size; 980 gfx::Size size = pipeline_metadata_.natural_size;
985 pipeline_metadata_.natural_size = gfx::Size(size.height(), size.width()); 981 pipeline_metadata_.natural_size = gfx::Size(size.height(), size.width());
986 } 982 }
987 983
988 video_weblayer_.reset(new cc_blink::WebLayerImpl(layer)); 984 video_weblayer_.reset(new cc_blink::WebLayerImpl(layer));
989 video_weblayer_->layer()->SetContentsOpaque(opaque_); 985 video_weblayer_->layer()->SetContentsOpaque(opaque_);
990 video_weblayer_->SetContentsOpaqueIsFixed(true); 986 video_weblayer_->SetContentsOpaqueIsFixed(true);
991 client_->setWebLayer(video_weblayer_.get()); 987 client_->setWebLayer(video_weblayer_.get());
992 } 988 }
993 989
994 UpdatePlayState(); 990 UpdatePlayState();
995 } 991 }
996 992
997 void WebMediaPlayerImpl::OnPipelineBufferingStateChanged( 993 void WebMediaPlayerImpl::OnBufferingStateChange(BufferingState state) {
998 BufferingState buffering_state) { 994 DVLOG(1) << __FUNCTION__ << "(" << state << ")";
999 DVLOG(1) << __FUNCTION__ << "(" << buffering_state << ")"; 995 DCHECK(main_task_runner_->BelongsToCurrentThread());
1000 996
1001 // Ignore buffering state changes until we've completed all outstanding 997 // Ignore buffering state changes until we've completed all outstanding
1002 // operations. 998 // operations.
1003 if (!pipeline_controller_.IsStable()) 999 if (!pipeline_controller_.IsStable())
1004 return; 1000 return;
1005 1001
1006 // TODO(scherkus): Handle other buffering states when Pipeline starts using 1002 // TODO(scherkus): Handle other buffering states when Pipeline starts using
1007 // them and translate them ready state changes http://crbug.com/144683 1003 // them and translate them ready state changes http://crbug.com/144683
1008 DCHECK_EQ(buffering_state, BUFFERING_HAVE_ENOUGH); 1004 DCHECK_EQ(state, BUFFERING_HAVE_ENOUGH);
1009 SetReadyState(WebMediaPlayer::ReadyStateHaveEnoughData); 1005 SetReadyState(WebMediaPlayer::ReadyStateHaveEnoughData);
1010 1006
1011 // Let the DataSource know we have enough data. It may use this information to 1007 // Let the DataSource know we have enough data. It may use this information to
1012 // release unused network connections. 1008 // release unused network connections.
1013 if (data_source_) 1009 if (data_source_)
1014 data_source_->OnBufferingHaveEnough(false); 1010 data_source_->OnBufferingHaveEnough(false);
1015 1011
1016 // Blink expects a timeChanged() in response to a seek(). 1012 // Blink expects a timeChanged() in response to a seek().
1017 if (should_notify_time_changed_) 1013 if (should_notify_time_changed_)
1018 client_->timeChanged(); 1014 client_->timeChanged();
1019 1015
1020 // Once we have enough, start reporting the total memory usage. We'll also 1016 // Once we have enough, start reporting the total memory usage. We'll also
1021 // report once playback starts. 1017 // report once playback starts.
1022 ReportMemoryUsage(); 1018 ReportMemoryUsage();
1023 1019
1024 UpdatePlayState(); 1020 UpdatePlayState();
1025 } 1021 }
1026 1022
1027 void WebMediaPlayerImpl::OnDemuxerOpened() { 1023 void WebMediaPlayerImpl::OnDurationChange() {
1028 DCHECK(main_task_runner_->BelongsToCurrentThread()); 1024 DCHECK(main_task_runner_->BelongsToCurrentThread());
1029 client_->mediaSourceOpened( 1025
1030 new WebMediaSourceImpl(chunk_demuxer_, media_log_)); 1026 // TODO(sandersd): We should call delegate_->DidPlay() with the new duration,
1027 // especially if it changed from <5s to >5s.
1028 if (ready_state_ == WebMediaPlayer::ReadyStateHaveNothing)
1029 return;
1030
1031 client_->durationChanged();
1031 } 1032 }
1032 1033
1033 void WebMediaPlayerImpl::OnAddTextTrack( 1034 void WebMediaPlayerImpl::OnAddTextTrack(const TextTrackConfig& config,
1034 const TextTrackConfig& config, 1035 const AddTextTrackDoneCB& done_cb) {
1035 const AddTextTrackDoneCB& done_cb) {
1036 DCHECK(main_task_runner_->BelongsToCurrentThread()); 1036 DCHECK(main_task_runner_->BelongsToCurrentThread());
1037 1037
1038 const WebInbandTextTrackImpl::Kind web_kind = 1038 const WebInbandTextTrackImpl::Kind web_kind =
1039 static_cast<WebInbandTextTrackImpl::Kind>(config.kind()); 1039 static_cast<WebInbandTextTrackImpl::Kind>(config.kind());
1040 const blink::WebString web_label = 1040 const blink::WebString web_label =
1041 blink::WebString::fromUTF8(config.label()); 1041 blink::WebString::fromUTF8(config.label());
1042 const blink::WebString web_language = 1042 const blink::WebString web_language =
1043 blink::WebString::fromUTF8(config.language()); 1043 blink::WebString::fromUTF8(config.language());
1044 const blink::WebString web_id = 1044 const blink::WebString web_id =
1045 blink::WebString::fromUTF8(config.id()); 1045 blink::WebString::fromUTF8(config.id());
1046 1046
1047 std::unique_ptr<WebInbandTextTrackImpl> web_inband_text_track( 1047 std::unique_ptr<WebInbandTextTrackImpl> web_inband_text_track(
1048 new WebInbandTextTrackImpl(web_kind, web_label, web_language, web_id)); 1048 new WebInbandTextTrackImpl(web_kind, web_label, web_language, web_id));
1049 1049
1050 std::unique_ptr<media::TextTrack> text_track(new TextTrackImpl( 1050 std::unique_ptr<media::TextTrack> text_track(new TextTrackImpl(
1051 main_task_runner_, client_, std::move(web_inband_text_track))); 1051 main_task_runner_, client_, std::move(web_inband_text_track)));
1052 1052
1053 done_cb.Run(std::move(text_track)); 1053 done_cb.Run(std::move(text_track));
1054 } 1054 }
1055 1055
1056 void WebMediaPlayerImpl::OnWaitingForDecryptionKey() {
1057 DCHECK(main_task_runner_->BelongsToCurrentThread());
1058
1059 encrypted_client_->didBlockPlaybackWaitingForKey();
1060 // TODO(jrummell): didResumePlaybackBlockedForKey() should only be called
1061 // when a key has been successfully added (e.g. OnSessionKeysChange() with
1062 // |has_additional_usable_key| = true). http://crbug.com/461903
1063 encrypted_client_->didResumePlaybackBlockedForKey();
1064 }
1065
1056 void WebMediaPlayerImpl::OnHidden() { 1066 void WebMediaPlayerImpl::OnHidden() {
1057 DCHECK(main_task_runner_->BelongsToCurrentThread()); 1067 DCHECK(main_task_runner_->BelongsToCurrentThread());
1058 UpdatePlayState(); 1068 UpdatePlayState();
1059 } 1069 }
1060 1070
1061 void WebMediaPlayerImpl::OnShown() { 1071 void WebMediaPlayerImpl::OnShown() {
1062 DCHECK(main_task_runner_->BelongsToCurrentThread()); 1072 DCHECK(main_task_runner_->BelongsToCurrentThread());
1063 must_suspend_ = false; 1073 must_suspend_ = false;
1064 UpdatePlayState(); 1074 UpdatePlayState();
1065 } 1075 }
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
1241 DCHECK(data_source_); 1251 DCHECK(data_source_);
1242 1252
1243 #if !defined(MEDIA_DISABLE_FFMPEG) 1253 #if !defined(MEDIA_DISABLE_FFMPEG)
1244 Demuxer::MediaTracksUpdatedCB media_tracks_updated_cb = 1254 Demuxer::MediaTracksUpdatedCB media_tracks_updated_cb =
1245 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnFFmpegMediaTracksUpdated); 1255 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnFFmpegMediaTracksUpdated);
1246 1256
1247 demuxer_.reset(new FFmpegDemuxer(media_task_runner_, data_source_.get(), 1257 demuxer_.reset(new FFmpegDemuxer(media_task_runner_, data_source_.get(),
1248 encrypted_media_init_data_cb, 1258 encrypted_media_init_data_cb,
1249 media_tracks_updated_cb, media_log_)); 1259 media_tracks_updated_cb, media_log_));
1250 #else 1260 #else
1251 OnPipelineError(PipelineStatus::DEMUXER_ERROR_COULD_NOT_OPEN); 1261 OnError(PipelineStatus::DEMUXER_ERROR_COULD_NOT_OPEN);
1252 return; 1262 return;
1253 #endif 1263 #endif
1254 } else { 1264 } else {
1255 DCHECK(!chunk_demuxer_); 1265 DCHECK(!chunk_demuxer_);
1256 DCHECK(!data_source_); 1266 DCHECK(!data_source_);
1257 1267
1258 chunk_demuxer_ = new ChunkDemuxer( 1268 chunk_demuxer_ = new ChunkDemuxer(
1259 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnDemuxerOpened), 1269 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnDemuxerOpened),
1260 encrypted_media_init_data_cb, media_log_, true); 1270 encrypted_media_init_data_cb, media_log_, true);
1261 demuxer_.reset(chunk_demuxer_); 1271 demuxer_.reset(chunk_demuxer_);
1262 } 1272 }
1263 1273
1264 // TODO(sandersd): FileSystem objects may also be non-static, but due to our 1274 // TODO(sandersd): FileSystem objects may also be non-static, but due to our
1265 // caching layer such situations are broken already. http://crbug.com/593159 1275 // caching layer such situations are broken already. http://crbug.com/593159
1266 bool is_static = !chunk_demuxer_; 1276 bool is_static = !chunk_demuxer_;
1267 1277
1268 // ... and we're ready to go! 1278 // ... and we're ready to go!
1269 seeking_ = true; 1279 seeking_ = true;
1270 1280
1271 // TODO(sandersd): On Android, defer Start() if the tab is not visible. 1281 // TODO(sandersd): On Android, defer Start() if the tab is not visible.
1272 bool is_streaming = (data_source_ && data_source_->IsStreaming()); 1282 bool is_streaming = (data_source_ && data_source_->IsStreaming());
1273 pipeline_controller_.Start( 1283 pipeline_controller_.Start(demuxer_.get(), this, is_streaming, is_static);
1274 demuxer_.get(), is_streaming, is_static,
1275 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnPipelineEnded),
1276 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnPipelineMetadata),
1277 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnPipelineBufferingStateChanged),
1278 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnDurationChanged),
1279 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnAddTextTrack),
1280 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnWaitingForDecryptionKey));
1281 } 1284 }
1282 1285
1283 void WebMediaPlayerImpl::SetNetworkState(WebMediaPlayer::NetworkState state) { 1286 void WebMediaPlayerImpl::SetNetworkState(WebMediaPlayer::NetworkState state) {
1284 DVLOG(1) << __FUNCTION__ << "(" << state << ")"; 1287 DVLOG(1) << __FUNCTION__ << "(" << state << ")";
1285 DCHECK(main_task_runner_->BelongsToCurrentThread()); 1288 DCHECK(main_task_runner_->BelongsToCurrentThread());
1286 network_state_ = state; 1289 network_state_ = state;
1287 // Always notify to ensure client has the latest value. 1290 // Always notify to ensure client has the latest value.
1288 client_->networkStateChanged(); 1291 client_->networkStateChanged();
1289 } 1292 }
1290 1293
(...skipping 21 matching lines...) Expand all
1312 base::TimeDelta duration = pipeline_.GetMediaDuration(); 1315 base::TimeDelta duration = pipeline_.GetMediaDuration();
1313 1316
1314 // Return positive infinity if the resource is unbounded. 1317 // Return positive infinity if the resource is unbounded.
1315 // http://www.whatwg.org/specs/web-apps/current-work/multipage/video.html#dom- media-duration 1318 // http://www.whatwg.org/specs/web-apps/current-work/multipage/video.html#dom- media-duration
1316 if (duration == kInfiniteDuration()) 1319 if (duration == kInfiniteDuration())
1317 return std::numeric_limits<double>::infinity(); 1320 return std::numeric_limits<double>::infinity();
1318 1321
1319 return duration.InSecondsF(); 1322 return duration.InSecondsF();
1320 } 1323 }
1321 1324
1322 void WebMediaPlayerImpl::OnDurationChanged() {
1323 // TODO(sandersd): We should call delegate_->DidPlay() with the new duration,
1324 // especially if it changed from <5s to >5s.
1325 if (ready_state_ == WebMediaPlayer::ReadyStateHaveNothing)
1326 return;
1327
1328 client_->durationChanged();
1329 }
1330
1331 void WebMediaPlayerImpl::OnNaturalSizeChanged(gfx::Size size) { 1325 void WebMediaPlayerImpl::OnNaturalSizeChanged(gfx::Size size) {
1332 DCHECK(main_task_runner_->BelongsToCurrentThread()); 1326 DCHECK(main_task_runner_->BelongsToCurrentThread());
1333 DCHECK_NE(ready_state_, WebMediaPlayer::ReadyStateHaveNothing); 1327 DCHECK_NE(ready_state_, WebMediaPlayer::ReadyStateHaveNothing);
1334 1328
1335 if (size == pipeline_metadata_.natural_size) 1329 if (size == pipeline_metadata_.natural_size)
1336 return; 1330 return;
1337 1331
1338 TRACE_EVENT0("media", "WebMediaPlayerImpl::OnNaturalSizeChanged"); 1332 TRACE_EVENT0("media", "WebMediaPlayerImpl::OnNaturalSizeChanged");
1339 media_log_->AddEvent( 1333 media_log_->AddEvent(
1340 media_log_->CreateVideoSizeSetEvent(size.width(), size.height())); 1334 media_log_->CreateVideoSizeSetEvent(size.width(), size.height()));
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
1594 << ", Video: " << stats.video_memory_usage << ", DataSource: " 1588 << ", Video: " << stats.video_memory_usage << ", DataSource: "
1595 << (data_source_ ? data_source_->GetMemoryUsage() : 0) 1589 << (data_source_ ? data_source_->GetMemoryUsage() : 0)
1596 << ", Demuxer: " << demuxer_memory_usage; 1590 << ", Demuxer: " << demuxer_memory_usage;
1597 1591
1598 const int64_t delta = current_memory_usage - last_reported_memory_usage_; 1592 const int64_t delta = current_memory_usage - last_reported_memory_usage_;
1599 last_reported_memory_usage_ = current_memory_usage; 1593 last_reported_memory_usage_ = current_memory_usage;
1600 adjust_allocated_memory_cb_.Run(delta); 1594 adjust_allocated_memory_cb_.Run(delta);
1601 } 1595 }
1602 1596
1603 } // namespace media 1597 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698