| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_capture_from_element/html_video_element_capture
r_source.h" | 5 #include "content/renderer/media_capture_from_element/html_video_element_capture
r_source.h" |
| 6 | 6 |
| 7 #include "base/location.h" | 7 #include "base/location.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 io_task_runner_(io_task_runner), | 48 io_task_runner_(io_task_runner), |
| 49 capture_frame_rate_(0.0), | 49 capture_frame_rate_(0.0), |
| 50 weak_factory_(this) { | 50 weak_factory_(this) { |
| 51 DCHECK(web_media_player_); | 51 DCHECK(web_media_player_); |
| 52 } | 52 } |
| 53 | 53 |
| 54 HtmlVideoElementCapturerSource::~HtmlVideoElementCapturerSource() { | 54 HtmlVideoElementCapturerSource::~HtmlVideoElementCapturerSource() { |
| 55 DCHECK(thread_checker_.CalledOnValidThread()); | 55 DCHECK(thread_checker_.CalledOnValidThread()); |
| 56 } | 56 } |
| 57 | 57 |
| 58 void HtmlVideoElementCapturerSource::GetCurrentSupportedFormats( | 58 media::VideoCaptureFormats |
| 59 int max_requested_width, | 59 HtmlVideoElementCapturerSource::GetPreferredFormats() { |
| 60 int max_requested_height, | |
| 61 double max_requested_frame_rate, | |
| 62 const VideoCaptureDeviceFormatsCB& callback) { | |
| 63 DVLOG(2) << __func__ << "{ max_requested_height = " << max_requested_height | |
| 64 << "}) { max_requested_width = " << max_requested_width | |
| 65 << "}) { max_requested_frame_rate = " << max_requested_frame_rate | |
| 66 << "})"; | |
| 67 DCHECK(thread_checker_.CalledOnValidThread()); | 60 DCHECK(thread_checker_.CalledOnValidThread()); |
| 68 | 61 |
| 69 // WebMediaPlayer has a setRate() but can't be read back. | 62 // WebMediaPlayer has a setRate() but can't be read back. |
| 70 // TODO(mcasas): Add getRate() to WMPlayer and/or fix the spec to allow users | 63 // TODO(mcasas): Add getRate() to WMPlayer and/or fix the spec to allow users |
| 71 // to specify it. | 64 // to specify it. |
| 72 const media::VideoCaptureFormat format( | 65 const media::VideoCaptureFormat format( |
| 73 web_media_player_->naturalSize(), | 66 web_media_player_->naturalSize(), |
| 74 MediaStreamVideoSource::kDefaultFrameRate, | 67 MediaStreamVideoSource::kDefaultFrameRate, |
| 75 media::PIXEL_FORMAT_I420); | 68 media::PIXEL_FORMAT_I420); |
| 76 media::VideoCaptureFormats formats; | 69 media::VideoCaptureFormats formats; |
| 77 formats.push_back(format); | 70 formats.push_back(format); |
| 78 callback.Run(formats); | 71 return formats; |
| 79 } | 72 } |
| 80 | 73 |
| 81 void HtmlVideoElementCapturerSource::StartCapture( | 74 void HtmlVideoElementCapturerSource::StartCapture( |
| 82 const media::VideoCaptureParams& params, | 75 const media::VideoCaptureParams& params, |
| 83 const VideoCaptureDeliverFrameCB& new_frame_callback, | 76 const VideoCaptureDeliverFrameCB& new_frame_callback, |
| 84 const RunningCallback& running_callback) { | 77 const RunningCallback& running_callback) { |
| 85 DVLOG(2) << __func__ << " requested " | 78 DVLOG(2) << __func__ << " requested " |
| 86 << media::VideoCaptureFormat::ToString(params.requested_format); | 79 << media::VideoCaptureFormat::ToString(params.requested_format); |
| 87 DCHECK(params.requested_format.IsValid()); | 80 DCHECK(params.requested_format.IsValid()); |
| 88 DCHECK(thread_checker_.CalledOnValidThread()); | 81 DCHECK(thread_checker_.CalledOnValidThread()); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 next_capture_time_ = current_time; | 181 next_capture_time_ = current_time; |
| 189 } | 182 } |
| 190 // Schedule next capture. | 183 // Schedule next capture. |
| 191 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 184 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 192 FROM_HERE, base::Bind(&HtmlVideoElementCapturerSource::sendNewFrame, | 185 FROM_HERE, base::Bind(&HtmlVideoElementCapturerSource::sendNewFrame, |
| 193 weak_factory_.GetWeakPtr()), | 186 weak_factory_.GetWeakPtr()), |
| 194 next_capture_time_ - current_time); | 187 next_capture_time_ - current_time); |
| 195 } | 188 } |
| 196 | 189 |
| 197 } // namespace content | 190 } // namespace content |
| OLD | NEW |