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 "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 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 696 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 696 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 697 | 697 |
| 698 base::Optional<MediaTrack::Id> selected_video_track_id; | 698 base::Optional<MediaTrack::Id> selected_video_track_id; |
| 699 if (selectedTrackId && !video_track_disabled_) | 699 if (selectedTrackId && !video_track_disabled_) |
| 700 selected_video_track_id = MediaTrack::Id(selectedTrackId->utf8().data()); | 700 selected_video_track_id = MediaTrack::Id(selectedTrackId->utf8().data()); |
| 701 MEDIA_LOG(INFO, media_log_) << "Selected video track: [" | 701 MEDIA_LOG(INFO, media_log_) << "Selected video track: [" |
| 702 << selected_video_track_id.value_or("") << "]"; | 702 << selected_video_track_id.value_or("") << "]"; |
| 703 pipeline_controller_.OnSelectedVideoTrackChanged(selected_video_track_id); | 703 pipeline_controller_.OnSelectedVideoTrackChanged(selected_video_track_id); |
| 704 } | 704 } |
| 705 | 705 |
| 706 bool WebMediaPlayerImpl::getLastUploadedFrameInfo(unsigned* width, | |
| 707 unsigned* height, | |
| 708 double* timestamp) { | |
| 709 *width = last_uploaded_frame_size_.width(); | |
| 710 *height = last_uploaded_frame_size_.height(); | |
| 711 *timestamp = last_uploaded_frame_timestamp_.InSecondsF(); | |
| 712 return true; | |
| 713 } | |
| 714 | |
| 706 blink::WebSize WebMediaPlayerImpl::naturalSize() const { | 715 blink::WebSize WebMediaPlayerImpl::naturalSize() const { |
| 707 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 716 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 708 | 717 |
| 709 return blink::WebSize(pipeline_metadata_.natural_size); | 718 return blink::WebSize(pipeline_metadata_.natural_size); |
| 710 } | 719 } |
| 711 | 720 |
| 712 bool WebMediaPlayerImpl::paused() const { | 721 bool WebMediaPlayerImpl::paused() const { |
| 713 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 722 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 714 | 723 |
| 715 #if defined(OS_ANDROID) // WMPI_CAST | 724 #if defined(OS_ANDROID) // WMPI_CAST |
| (...skipping 1110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1826 *video_frame_out = compositor->GetCurrentFrameAndUpdateIfStale(); | 1835 *video_frame_out = compositor->GetCurrentFrameAndUpdateIfStale(); |
| 1827 event->Signal(); | 1836 event->Signal(); |
| 1828 } | 1837 } |
| 1829 | 1838 |
| 1830 scoped_refptr<VideoFrame> WebMediaPlayerImpl::GetCurrentFrameFromCompositor() { | 1839 scoped_refptr<VideoFrame> WebMediaPlayerImpl::GetCurrentFrameFromCompositor() { |
| 1831 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 1840 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 1832 TRACE_EVENT0("media", "WebMediaPlayerImpl::GetCurrentFrameFromCompositor"); | 1841 TRACE_EVENT0("media", "WebMediaPlayerImpl::GetCurrentFrameFromCompositor"); |
| 1833 | 1842 |
| 1834 // Needed when the |main_task_runner_| and |compositor_task_runner_| are the | 1843 // Needed when the |main_task_runner_| and |compositor_task_runner_| are the |
| 1835 // same to avoid deadlock in the Wait() below. | 1844 // same to avoid deadlock in the Wait() below. |
| 1836 if (compositor_task_runner_->BelongsToCurrentThread()) | 1845 if (compositor_task_runner_->BelongsToCurrentThread()) { |
| 1837 return compositor_->GetCurrentFrameAndUpdateIfStale(); | 1846 scoped_refptr<VideoFrame> video_frame = |
| 1847 compositor_->GetCurrentFrameAndUpdateIfStale(); | |
| 1848 if (video_frame) { | |
|
dglazkov
2017/03/27 20:08:21
Early return might be easier to read?
if (!video_
Kai Ninomiya
2017/03/28 21:33:23
Done.
| |
| 1849 last_uploaded_frame_size_ = video_frame->natural_size(); | |
| 1850 last_uploaded_frame_timestamp_ = video_frame->timestamp(); | |
| 1851 } | |
| 1852 return video_frame; | |
| 1853 } | |
| 1838 | 1854 |
| 1839 // Use a posted task and waitable event instead of a lock otherwise | 1855 // Use a posted task and waitable event instead of a lock otherwise |
| 1840 // WebGL/Canvas can see different content than what the compositor is seeing. | 1856 // WebGL/Canvas can see different content than what the compositor is seeing. |
| 1841 scoped_refptr<VideoFrame> video_frame; | 1857 scoped_refptr<VideoFrame> video_frame; |
| 1842 base::WaitableEvent event(base::WaitableEvent::ResetPolicy::AUTOMATIC, | 1858 base::WaitableEvent event(base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 1843 base::WaitableEvent::InitialState::NOT_SIGNALED); | 1859 base::WaitableEvent::InitialState::NOT_SIGNALED); |
| 1844 compositor_task_runner_->PostTask( | 1860 compositor_task_runner_->PostTask( |
| 1845 FROM_HERE, | 1861 FROM_HERE, |
| 1846 base::Bind(&GetCurrentFrameAndSignal, base::Unretained(compositor_), | 1862 base::Bind(&GetCurrentFrameAndSignal, base::Unretained(compositor_), |
| 1847 &video_frame, &event)); | 1863 &video_frame, &event)); |
| 1848 event.Wait(); | 1864 event.Wait(); |
| 1865 | |
| 1866 if (video_frame) { | |
|
dglazkov
2017/03/27 20:08:21
Same here.
Kai Ninomiya
2017/03/28 21:33:23
Done.
| |
| 1867 last_uploaded_frame_size_ = video_frame->natural_size(); | |
| 1868 last_uploaded_frame_timestamp_ = video_frame->timestamp(); | |
| 1869 } | |
| 1849 return video_frame; | 1870 return video_frame; |
| 1850 } | 1871 } |
| 1851 | 1872 |
| 1852 void WebMediaPlayerImpl::UpdatePlayState() { | 1873 void WebMediaPlayerImpl::UpdatePlayState() { |
| 1853 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 1874 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 1854 | 1875 |
| 1855 #if defined(OS_ANDROID) // WMPI_CAST | 1876 #if defined(OS_ANDROID) // WMPI_CAST |
| 1856 bool is_remote = isRemote(); | 1877 bool is_remote = isRemote(); |
| 1857 bool can_auto_suspend = true; | 1878 bool can_auto_suspend = true; |
| 1858 #else | 1879 #else |
| (...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2332 | 2353 |
| 2333 void WebMediaPlayerImpl::RecordUnderflowDuration(base::TimeDelta duration) { | 2354 void WebMediaPlayerImpl::RecordUnderflowDuration(base::TimeDelta duration) { |
| 2334 DCHECK(data_source_ || chunk_demuxer_); | 2355 DCHECK(data_source_ || chunk_demuxer_); |
| 2335 if (data_source_) | 2356 if (data_source_) |
| 2336 UMA_HISTOGRAM_TIMES("Media.UnderflowDuration", duration); | 2357 UMA_HISTOGRAM_TIMES("Media.UnderflowDuration", duration); |
| 2337 else | 2358 else |
| 2338 UMA_HISTOGRAM_TIMES("Media.UnderflowDuration.MSE", duration); | 2359 UMA_HISTOGRAM_TIMES("Media.UnderflowDuration.MSE", duration); |
| 2339 } | 2360 } |
| 2340 | 2361 |
| 2341 } // namespace media | 2362 } // namespace media |
| OLD | NEW |