| 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 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 546 AsWeakPtr(), BUFFERING_HAVE_ENOUGH)); | 546 AsWeakPtr(), BUFFERING_HAVE_ENOUGH)); |
| 547 } | 547 } |
| 548 return; | 548 return; |
| 549 } | 549 } |
| 550 | 550 |
| 551 // Call this before setting |seeking_| so that the current media time can be | 551 // Call this before setting |seeking_| so that the current media time can be |
| 552 // recorded by the reporter. | 552 // recorded by the reporter. |
| 553 if (watch_time_reporter_) | 553 if (watch_time_reporter_) |
| 554 watch_time_reporter_->OnSeeking(); | 554 watch_time_reporter_->OnSeeking(); |
| 555 | 555 |
| 556 // Clear any new frame processed callbacks on seek; otherwise we'll end up |
| 557 // logging a time long after the seek completes. |
| 558 frame_time_report_cb_.Cancel(); |
| 559 |
| 556 // TODO(sandersd): Move |seeking_| to PipelineController. | 560 // TODO(sandersd): Move |seeking_| to PipelineController. |
| 557 // TODO(sandersd): Do we want to reset the idle timer here? | 561 // TODO(sandersd): Do we want to reset the idle timer here? |
| 558 delegate_->SetIdle(delegate_id_, false); | 562 delegate_->SetIdle(delegate_id_, false); |
| 559 ended_ = false; | 563 ended_ = false; |
| 560 seeking_ = true; | 564 seeking_ = true; |
| 561 seek_time_ = time; | 565 seek_time_ = time; |
| 562 if (paused_) | 566 if (paused_) |
| 563 paused_time_ = time; | 567 paused_time_ = time; |
| 564 pipeline_controller_.Seek(time, time_updated); | 568 pipeline_controller_.Seek(time, time_updated); |
| 565 | 569 |
| (...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1225 DVLOG(1) << __func__; | 1229 DVLOG(1) << __func__; |
| 1226 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 1230 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 1227 | 1231 |
| 1228 // Ignore state changes until we've completed all outstanding operations. | 1232 // Ignore state changes until we've completed all outstanding operations. |
| 1229 if (!pipeline_controller_.IsStable()) | 1233 if (!pipeline_controller_.IsStable()) |
| 1230 return; | 1234 return; |
| 1231 | 1235 |
| 1232 ended_ = true; | 1236 ended_ = true; |
| 1233 client_->timeChanged(); | 1237 client_->timeChanged(); |
| 1234 | 1238 |
| 1239 // Clear any new frame processed callbacks on end; otherwise we'll end up |
| 1240 // logging a time long after playback ends. |
| 1241 frame_time_report_cb_.Cancel(); |
| 1242 |
| 1235 // We don't actually want this to run until |client_| calls seek() or pause(), | 1243 // We don't actually want this to run until |client_| calls seek() or pause(), |
| 1236 // but that should have already happened in timeChanged() and so this is | 1244 // but that should have already happened in timeChanged() and so this is |
| 1237 // expected to be a no-op. | 1245 // expected to be a no-op. |
| 1238 UpdatePlayState(); | 1246 UpdatePlayState(); |
| 1239 } | 1247 } |
| 1240 | 1248 |
| 1241 void WebMediaPlayerImpl::OnMetadata(PipelineMetadata metadata) { | 1249 void WebMediaPlayerImpl::OnMetadata(PipelineMetadata metadata) { |
| 1242 DVLOG(1) << __func__; | 1250 DVLOG(1) << __func__; |
| 1243 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 1251 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 1244 | 1252 |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1455 video_locked_when_paused_when_hidden_ = false; | 1463 video_locked_when_paused_when_hidden_ = false; |
| 1456 | 1464 |
| 1457 if (watch_time_reporter_) | 1465 if (watch_time_reporter_) |
| 1458 watch_time_reporter_->OnShown(); | 1466 watch_time_reporter_->OnShown(); |
| 1459 | 1467 |
| 1460 // Only track the time to the first frame if playing or about to play because | 1468 // Only track the time to the first frame if playing or about to play because |
| 1461 // of being shown and only for videos we would optimize background playback | 1469 // of being shown and only for videos we would optimize background playback |
| 1462 // for. | 1470 // for. |
| 1463 if ((!paused_ && IsBackgroundOptimizationCandidate()) || | 1471 if ((!paused_ && IsBackgroundOptimizationCandidate()) || |
| 1464 paused_when_hidden_) { | 1472 paused_when_hidden_) { |
| 1465 VideoFrameCompositor::OnNewProcessedFrameCB new_processed_frame_cb = | 1473 frame_time_report_cb_.Reset( |
| 1466 BindToCurrentLoop(base::Bind( | 1474 base::Bind(&WebMediaPlayerImpl::ReportTimeFromForegroundToFirstFrame, |
| 1467 &WebMediaPlayerImpl::ReportTimeFromForegroundToFirstFrame, | 1475 AsWeakPtr(), base::TimeTicks::Now())); |
| 1468 AsWeakPtr(), base::TimeTicks::Now())); | |
| 1469 compositor_task_runner_->PostTask( | 1476 compositor_task_runner_->PostTask( |
| 1470 FROM_HERE, | 1477 FROM_HERE, |
| 1471 base::Bind(&VideoFrameCompositor::SetOnNewProcessedFrameCallback, | 1478 base::Bind(&VideoFrameCompositor::SetOnNewProcessedFrameCallback, |
| 1472 base::Unretained(compositor_), new_processed_frame_cb)); | 1479 base::Unretained(compositor_), |
| 1480 BindToCurrentLoop(frame_time_report_cb_.callback()))); |
| 1473 } | 1481 } |
| 1474 | 1482 |
| 1475 EnableVideoTrackIfNeeded(); | 1483 EnableVideoTrackIfNeeded(); |
| 1476 | 1484 |
| 1477 if (paused_when_hidden_) { | 1485 if (paused_when_hidden_) { |
| 1478 paused_when_hidden_ = false; | 1486 paused_when_hidden_ = false; |
| 1479 OnPlay(); // Calls UpdatePlayState() so return afterwards. | 1487 OnPlay(); // Calls UpdatePlayState() so return afterwards. |
| 1480 return; | 1488 return; |
| 1481 } | 1489 } |
| 1482 | 1490 |
| (...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2325 | 2333 |
| 2326 void WebMediaPlayerImpl::RecordUnderflowDuration(base::TimeDelta duration) { | 2334 void WebMediaPlayerImpl::RecordUnderflowDuration(base::TimeDelta duration) { |
| 2327 DCHECK(data_source_ || chunk_demuxer_); | 2335 DCHECK(data_source_ || chunk_demuxer_); |
| 2328 if (data_source_) | 2336 if (data_source_) |
| 2329 UMA_HISTOGRAM_TIMES("Media.UnderflowDuration", duration); | 2337 UMA_HISTOGRAM_TIMES("Media.UnderflowDuration", duration); |
| 2330 else | 2338 else |
| 2331 UMA_HISTOGRAM_TIMES("Media.UnderflowDuration.MSE", duration); | 2339 UMA_HISTOGRAM_TIMES("Media.UnderflowDuration.MSE", duration); |
| 2332 } | 2340 } |
| 2333 | 2341 |
| 2334 } // namespace media | 2342 } // namespace media |
| OLD | NEW |