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/canvas_capture_handler.h" | 5 #include "content/renderer/media_capture_from_element/canvas_capture_handler.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 AddVideoCapturerSourceToVideoTrack(std::move(video_source), track); | 134 AddVideoCapturerSourceToVideoTrack(std::move(video_source), track); |
135 } | 135 } |
136 | 136 |
137 CanvasCaptureHandler::~CanvasCaptureHandler() { | 137 CanvasCaptureHandler::~CanvasCaptureHandler() { |
138 DVLOG(3) << __func__; | 138 DVLOG(3) << __func__; |
139 DCHECK(main_render_thread_checker_.CalledOnValidThread()); | 139 DCHECK(main_render_thread_checker_.CalledOnValidThread()); |
140 io_task_runner_->DeleteSoon(FROM_HERE, delegate_.release()); | 140 io_task_runner_->DeleteSoon(FROM_HERE, delegate_.release()); |
141 } | 141 } |
142 | 142 |
143 // static | 143 // static |
144 CanvasCaptureHandler* CanvasCaptureHandler::CreateCanvasCaptureHandler( | 144 std::unique_ptr<CanvasCaptureHandler> |
| 145 CanvasCaptureHandler::CreateCanvasCaptureHandler( |
145 const blink::WebSize& size, | 146 const blink::WebSize& size, |
146 double frame_rate, | 147 double frame_rate, |
147 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, | 148 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, |
148 blink::WebMediaStreamTrack* track) { | 149 blink::WebMediaStreamTrack* track) { |
149 // Save histogram data so we can see how much CanvasCapture is used. | 150 // Save histogram data so we can see how much CanvasCapture is used. |
150 // The histogram counts the number of calls to the JS API. | 151 // The histogram counts the number of calls to the JS API. |
151 UpdateWebRTCMethodCount(WEBKIT_CANVAS_CAPTURE_STREAM); | 152 UpdateWebRTCMethodCount(WEBKIT_CANVAS_CAPTURE_STREAM); |
152 | 153 |
153 return new CanvasCaptureHandler(size, frame_rate, io_task_runner, track); | 154 return std::unique_ptr<CanvasCaptureHandler>( |
| 155 new CanvasCaptureHandler(size, frame_rate, io_task_runner, track)); |
154 } | 156 } |
155 | 157 |
156 void CanvasCaptureHandler::SendNewFrame(const SkImage* image) { | 158 void CanvasCaptureHandler::SendNewFrame(const SkImage* image) { |
157 DCHECK(main_render_thread_checker_.CalledOnValidThread()); | 159 DCHECK(main_render_thread_checker_.CalledOnValidThread()); |
158 CreateNewFrame(image); | 160 CreateNewFrame(image); |
159 } | 161 } |
160 | 162 |
161 bool CanvasCaptureHandler::NeedsNewFrame() const { | 163 bool CanvasCaptureHandler::NeedsNewFrame() const { |
162 DCHECK(main_render_thread_checker_.CalledOnValidThread()); | 164 DCHECK(main_render_thread_checker_.CalledOnValidThread()); |
163 return ask_for_new_frame_; | 165 return ask_for_new_frame_; |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 track_id, false); | 266 track_id, false); |
265 webkit_source.SetExtraData(media_stream_source.get()); | 267 webkit_source.SetExtraData(media_stream_source.get()); |
266 | 268 |
267 web_track->Initialize(webkit_source); | 269 web_track->Initialize(webkit_source); |
268 web_track->SetTrackData(new MediaStreamVideoTrack( | 270 web_track->SetTrackData(new MediaStreamVideoTrack( |
269 media_stream_source.release(), | 271 media_stream_source.release(), |
270 MediaStreamVideoSource::ConstraintsCallback(), true)); | 272 MediaStreamVideoSource::ConstraintsCallback(), true)); |
271 } | 273 } |
272 | 274 |
273 } // namespace content | 275 } // namespace content |
OLD | NEW |