| 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/html_video_element_capturer_source.h" | 5 #include "content/renderer/media/html_video_element_capturer_source.h" |
| 6 | 6 |
| 7 #include "base/thread_task_runner_handle.h" | 7 #include "base/thread_task_runner_handle.h" |
| 8 #include "base/trace_event/trace_event.h" | 8 #include "base/trace_event/trace_event.h" |
| 9 #include "content/public/renderer/render_thread.h" | 9 #include "content/public/renderer/render_thread.h" |
| 10 #include "content/renderer/media/media_stream_video_source.h" | 10 #include "content/renderer/media/media_stream_video_source.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 << media::VideoCaptureFormat::ToString(params.requested_format); | 83 << media::VideoCaptureFormat::ToString(params.requested_format); |
| 84 DCHECK(params.requested_format.IsValid()); | 84 DCHECK(params.requested_format.IsValid()); |
| 85 DCHECK(thread_checker_.CalledOnValidThread()); | 85 DCHECK(thread_checker_.CalledOnValidThread()); |
| 86 | 86 |
| 87 running_callback_ = running_callback; | 87 running_callback_ = running_callback; |
| 88 if (!web_media_player_ || !web_media_player_->hasVideo()) { | 88 if (!web_media_player_ || !web_media_player_->hasVideo()) { |
| 89 running_callback_.Run(false); | 89 running_callback_.Run(false); |
| 90 return; | 90 return; |
| 91 } | 91 } |
| 92 const blink::WebSize resolution = web_media_player_->naturalSize(); | 92 const blink::WebSize resolution = web_media_player_->naturalSize(); |
| 93 canvas_ = skia::AdoptRef(skia::CreatePlatformCanvas(resolution.width, | 93 canvas_ = sk_sp<SkCanvas>(skia::CreatePlatformCanvas(resolution.width, |
| 94 resolution.height, | 94 resolution.height, |
| 95 true /* is_opaque */)); | 95 true /* is_opaque */)); |
| 96 | 96 |
| 97 new_frame_callback_ = new_frame_callback; | 97 new_frame_callback_ = new_frame_callback; |
| 98 // Force |capture_frame_rate_| to be in between k{Min,Max}FramesPerSecond. | 98 // Force |capture_frame_rate_| to be in between k{Min,Max}FramesPerSecond. |
| 99 capture_frame_rate_ = | 99 capture_frame_rate_ = |
| 100 std::max(kMinFramesPerSecond, | 100 std::max(kMinFramesPerSecond, |
| 101 std::min(static_cast<float>(media::limits::kMaxFramesPerSecond), | 101 std::min(static_cast<float>(media::limits::kMaxFramesPerSecond), |
| 102 params.requested_format.frame_rate)); | 102 params.requested_format.frame_rate)); |
| 103 | 103 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 next_capture_time_ = current_time; | 181 next_capture_time_ = current_time; |
| 182 } | 182 } |
| 183 // Schedule next capture. | 183 // Schedule next capture. |
| 184 base::MessageLoop::current()->PostDelayedTask( | 184 base::MessageLoop::current()->PostDelayedTask( |
| 185 FROM_HERE, base::Bind(&HtmlVideoElementCapturerSource::sendNewFrame, | 185 FROM_HERE, base::Bind(&HtmlVideoElementCapturerSource::sendNewFrame, |
| 186 weak_factory_.GetWeakPtr()), | 186 weak_factory_.GetWeakPtr()), |
| 187 next_capture_time_ - current_time); | 187 next_capture_time_ - current_time); |
| 188 } | 188 } |
| 189 | 189 |
| 190 } // namespace content | 190 } // namespace content |
| OLD | NEW |