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

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

Powered by Google App Engine
This is Rietveld 408576698