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

Unified Diff: content/browser/renderer_host/media/video_capture_manager.cc

Issue 2365223002: Video Capture: Allow suspension of individual devices. (Closed)
Patch Set: Style tweaks, per mcasas's comments. Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/media/video_capture_manager.cc
diff --git a/content/browser/renderer_host/media/video_capture_manager.cc b/content/browser/renderer_host/media/video_capture_manager.cc
index 380c626ba34760249828cf06abb3a42de254a9a1..f86009aefed82fc268dcaa99a0e31868d7a13577 100644
--- a/content/browser/renderer_host/media/video_capture_manager.cc
+++ b/content/browser/renderer_host/media/video_capture_manager.cc
@@ -739,11 +739,20 @@ void VideoCaptureManager::PauseCaptureForClient(
if (!entry)
NOTREACHED() << "Got Null entry while pausing capture";
- // Do not pause Content Video Capture devices, e.g. Tab or Screen capture.
- if (entry->stream_type != MEDIA_DEVICE_VIDEO_CAPTURE)
- return;
-
+ const bool had_active_client = controller->HasActiveClient();
controller->PauseClient(client_id, client_handler);
+ if (!had_active_client || controller->HasActiveClient())
+ return;
+ if (media::VideoCaptureDevice* device = entry->video_capture_device()) {
+ device_task_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(&VideoCaptureDevice::MaybeSuspend,
+ // Unretained is safe to use here because |device| would be
+ // null if it was scheduled for shutdown and destruction, and
+ // because this task is guaranteed to run before the task
+ // that destroys the |device|.
+ base::Unretained(device)));
+ }
}
void VideoCaptureManager::ResumeCaptureForClient(
@@ -760,11 +769,20 @@ void VideoCaptureManager::ResumeCaptureForClient(
if (!entry)
NOTREACHED() << "Got Null entry while resuming capture";
- // Do not resume Content Video Capture devices, e.g. Tab or Screen capture.
- if (entry->stream_type != MEDIA_DEVICE_VIDEO_CAPTURE)
- return;
-
+ const bool had_active_client = controller->HasActiveClient();
controller->ResumeClient(client_id, client_handler);
+ if (had_active_client || !controller->HasActiveClient())
+ return;
+ if (media::VideoCaptureDevice* device = entry->video_capture_device()) {
+ device_task_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(&VideoCaptureDevice::Resume,
+ // Unretained is safe to use here because |device| would be
+ // null if it was scheduled for shutdown and destruction, and
+ // because this task is guaranteed to run before the task
+ // that destroys the |device|.
+ base::Unretained(device)));
+ }
}
void VideoCaptureManager::RequestRefreshFrameForClient(

Powered by Google App Engine
This is Rietveld 408576698