Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(539)

Side by Side Diff: content/renderer/media/media_stream_video_capturer_source.cc

Issue 1849003002: Add video frame refresh to MediaStream and VideoCapture stacks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed nick's PS3 comments (moving non-observer impl out of MSVideoSink interface). Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/media_stream_video_capturer_source.h" 5 #include "content/renderer/media/media_stream_video_capturer_source.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 203
204 // VideoCaptureDelegate Implementation. 204 // VideoCaptureDelegate Implementation.
205 void GetCurrentSupportedFormats( 205 void GetCurrentSupportedFormats(
206 int max_requested_width, 206 int max_requested_width,
207 int max_requested_height, 207 int max_requested_height,
208 double max_requested_frame_rate, 208 double max_requested_frame_rate,
209 const VideoCaptureDeviceFormatsCB& callback) override; 209 const VideoCaptureDeviceFormatsCB& callback) override;
210 void StartCapture(const media::VideoCaptureParams& params, 210 void StartCapture(const media::VideoCaptureParams& params,
211 const VideoCaptureDeliverFrameCB& new_frame_callback, 211 const VideoCaptureDeliverFrameCB& new_frame_callback,
212 const RunningCallback& running_callback) override; 212 const RunningCallback& running_callback) override;
213 void RequestRefreshFrame() override;
213 void StopCapture() override; 214 void StopCapture() override;
214 215
215 private: 216 private:
216 void OnStateUpdate(VideoCaptureState state); 217 void OnStateUpdate(VideoCaptureState state);
217 void OnDeviceFormatsInUseReceived(const media::VideoCaptureFormats& formats); 218 void OnDeviceFormatsInUseReceived(const media::VideoCaptureFormats& formats);
218 void OnDeviceSupportedFormatsEnumerated( 219 void OnDeviceSupportedFormatsEnumerated(
219 const media::VideoCaptureFormats& formats); 220 const media::VideoCaptureFormats& formats);
220 221
221 // |session_id_| identifies the capture device used for this capture session. 222 // |session_id_| identifies the capture device used for this capture session.
222 const media::VideoCaptureSessionId session_id_; 223 const media::VideoCaptureSessionId session_id_;
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 DCHECK(thread_checker_.CalledOnValidThread()); 303 DCHECK(thread_checker_.CalledOnValidThread());
303 running_callback_ = running_callback; 304 running_callback_ = running_callback;
304 305
305 stop_capture_cb_ = manager_->StartCapture( 306 stop_capture_cb_ = manager_->StartCapture(
306 session_id_, params, media::BindToCurrentLoop(base::Bind( 307 session_id_, params, media::BindToCurrentLoop(base::Bind(
307 &LocalVideoCapturerSource::OnStateUpdate, 308 &LocalVideoCapturerSource::OnStateUpdate,
308 weak_factory_.GetWeakPtr())), 309 weak_factory_.GetWeakPtr())),
309 new_frame_callback); 310 new_frame_callback);
310 } 311 }
311 312
313 void LocalVideoCapturerSource::RequestRefreshFrame() {
314 DVLOG(3) << __FUNCTION__;
315 DCHECK(thread_checker_.CalledOnValidThread());
316 if (stop_capture_cb_.is_null())
317 return; // Do not request frames if the source is stopped.
318 manager_->RequestRefreshFrame(session_id_);
319 }
320
321
312 void LocalVideoCapturerSource::StopCapture() { 322 void LocalVideoCapturerSource::StopCapture() {
313 DVLOG(3) << __FUNCTION__; 323 DVLOG(3) << __FUNCTION__;
314 DCHECK(thread_checker_.CalledOnValidThread()); 324 DCHECK(thread_checker_.CalledOnValidThread());
315 // Immediately make sure we don't provide more frames. 325 // Immediately make sure we don't provide more frames.
316 if (!stop_capture_cb_.is_null()) 326 if (!stop_capture_cb_.is_null())
317 base::ResetAndReturn(&stop_capture_cb_).Run(); 327 base::ResetAndReturn(&stop_capture_cb_).Run();
318 running_callback_.Reset(); 328 running_callback_.Reset();
319 // Invalidate any potential format enumerations going on. 329 // Invalidate any potential format enumerations going on.
320 formats_enumerated_callback_.Reset(); 330 formats_enumerated_callback_.Reset();
321 } 331 }
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 void MediaStreamVideoCapturerSource::OnStarted(bool result) { 450 void MediaStreamVideoCapturerSource::OnStarted(bool result) {
441 OnStartDone(result ? MEDIA_DEVICE_OK : MEDIA_DEVICE_TRACK_START_FAILURE); 451 OnStartDone(result ? MEDIA_DEVICE_OK : MEDIA_DEVICE_TRACK_START_FAILURE);
442 } 452 }
443 453
444 const char* 454 const char*
445 MediaStreamVideoCapturerSource::GetPowerLineFrequencyForTesting() const { 455 MediaStreamVideoCapturerSource::GetPowerLineFrequencyForTesting() const {
446 return kPowerLineFrequency; 456 return kPowerLineFrequency;
447 } 457 }
448 458
449 } // namespace content 459 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698