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

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

Issue 2451473002: Follow up: stop mirroring session when tab is closed. Rename the callback function and clarify the … (Closed)
Patch Set: Created 4 years, 1 month 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 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 360
361 case VIDEO_CAPTURE_STATE_STOPPING: 361 case VIDEO_CAPTURE_STATE_STOPPING:
362 case VIDEO_CAPTURE_STATE_STOPPED: 362 case VIDEO_CAPTURE_STATE_STOPPED:
363 case VIDEO_CAPTURE_STATE_ERROR: 363 case VIDEO_CAPTURE_STATE_ERROR:
364 case VIDEO_CAPTURE_STATE_ENDED: 364 case VIDEO_CAPTURE_STATE_ENDED:
365 base::ResetAndReturn(&running_callback_).Run(false); 365 base::ResetAndReturn(&running_callback_).Run(false);
366 break; 366 break;
367 367
368 case VIDEO_CAPTURE_STATE_PAUSED: 368 case VIDEO_CAPTURE_STATE_PAUSED:
369 case VIDEO_CAPTURE_STATE_RESUMED: 369 case VIDEO_CAPTURE_STATE_RESUMED:
370 // Not applicable to reporting on device start success/failure. 370 // Not applicable to reporting on device starts or errors.
371 break; 371 break;
372 } 372 }
373 } 373 }
374 374
375 void LocalVideoCapturerSource::OnDeviceFormatsInUseReceived( 375 void LocalVideoCapturerSource::OnDeviceFormatsInUseReceived(
376 const media::VideoCaptureFormats& formats_in_use) { 376 const media::VideoCaptureFormats& formats_in_use) {
377 DVLOG(3) << __func__ << ", #formats received: " << formats_in_use.size(); 377 DVLOG(3) << __func__ << ", #formats received: " << formats_in_use.size();
378 DCHECK(thread_checker_.CalledOnValidThread()); 378 DCHECK(thread_checker_.CalledOnValidThread());
379 // StopCapture() might have destroyed |formats_enumerated_callback_| before 379 // StopCapture() might have destroyed |formats_enumerated_callback_| before
380 // arriving here. 380 // arriving here.
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 const VideoCaptureDeliverFrameCB& frame_callback) { 475 const VideoCaptureDeliverFrameCB& frame_callback) {
476 media::VideoCaptureParams new_params; 476 media::VideoCaptureParams new_params;
477 new_params.requested_format = format; 477 new_params.requested_format = format;
478 if (IsContentVideoCaptureDevice(device_info())) { 478 if (IsContentVideoCaptureDevice(device_info())) {
479 SetContentCaptureParamsFromConstraints( 479 SetContentCaptureParamsFromConstraints(
480 constraints, device_info().device.type, &new_params); 480 constraints, device_info().device.type, &new_params);
481 } else if (device_info().device.type == MEDIA_DEVICE_VIDEO_CAPTURE) { 481 } else if (device_info().device.type == MEDIA_DEVICE_VIDEO_CAPTURE) {
482 SetPowerLineFrequencyParamFromConstraints(constraints, &new_params); 482 SetPowerLineFrequencyParamFromConstraints(constraints, &new_params);
483 } 483 }
484 484
485 source_->StartCapture(new_params, 485 is_capture_starting_ = true;
486 frame_callback, 486 source_->StartCapture(
487 base::Bind(&MediaStreamVideoCapturerSource::OnStarted, 487 new_params, frame_callback,
488 base::Unretained(this))); 488 base::Bind(&MediaStreamVideoCapturerSource::OnRunStateChanged,
489 base::Unretained(this)));
489 } 490 }
490 491
491 void MediaStreamVideoCapturerSource::StopSourceImpl() { 492 void MediaStreamVideoCapturerSource::StopSourceImpl() {
492 source_->StopCapture(); 493 source_->StopCapture();
493 } 494 }
494 495
495 void MediaStreamVideoCapturerSource::OnStarted(bool result) { 496 void MediaStreamVideoCapturerSource::OnRunStateChanged(bool is_running) {
496 OnStartDone(result ? MEDIA_DEVICE_OK : MEDIA_DEVICE_TRACK_START_FAILURE); 497 if (is_capture_starting_) {
498 OnStartDone(is_running ? MEDIA_DEVICE_OK
499 : MEDIA_DEVICE_TRACK_START_FAILURE);
500 is_capture_starting_ = false;
501 } else if (!is_running) {
502 StopSource();
503 }
497 } 504 }
498 505
499 const char* 506 const char*
500 MediaStreamVideoCapturerSource::GetPowerLineFrequencyForTesting() const { 507 MediaStreamVideoCapturerSource::GetPowerLineFrequencyForTesting() const {
501 return kPowerLineFrequency; 508 return kPowerLineFrequency;
502 } 509 }
503 510
504 } // namespace content 511 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698