Index: content/browser/renderer_host/media/video_capture_controller.cc |
diff --git a/content/browser/renderer_host/media/video_capture_controller.cc b/content/browser/renderer_host/media/video_capture_controller.cc |
index 4b6d4b94b1e0fca3c3d4827a4c0bb200130f42ea..2f0bf655fe768aa0d49244f6c548d3d5d900130a 100644 |
--- a/content/browser/renderer_host/media/video_capture_controller.cc |
+++ b/content/browser/renderer_host/media/video_capture_controller.cc |
@@ -103,7 +103,8 @@ struct VideoCaptureController::ControllerClient { |
render_process_handle(render_process), |
session_id(session_id), |
parameters(params), |
- session_closed(false) {} |
+ session_closed(false), |
+ paused(false) {} |
~ControllerClient() {} |
@@ -135,6 +136,10 @@ struct VideoCaptureController::ControllerClient { |
// implicitly), we could avoid tracking this state here in the Controller, and |
// simplify the code in both places. |
bool session_closed; |
+ |
+ // Indicates whether the client is paused, if true, VideoCaptureController |
+ // stops updating its buffer. |
+ bool paused; |
}; |
// Receives events from the VideoCaptureDevice and posts them to a |
@@ -269,6 +274,21 @@ int VideoCaptureController::RemoveClient( |
return session_id; |
} |
+void VideoCaptureController::PauseOrResumeClient( |
+ const VideoCaptureControllerID& id, |
+ VideoCaptureControllerEventHandler* event_handler, |
+ bool pause) { |
+ DCHECK_CURRENTLY_ON(BrowserThread::IO); |
+ DVLOG(1) << "VideoCaptureController::PauseOrResumeClient, id " |
+ << id.device_id << ", " << pause; |
+ |
+ ControllerClient* client = FindClient(id, event_handler, controller_clients_); |
+ if (!client) |
+ return; |
tommi (sloooow) - chröme
2014/10/01 07:17:03
should the event handler be notified of this someh
michaelbai
2014/10/01 22:09:33
That's what I wondered in the first place, I think
tommi (sloooow) - chröme
2014/10/02 11:10:39
Acknowledged.
|
+ |
+ client->paused = pause; |
+} |
+ |
void VideoCaptureController::StopSession(int session_id) { |
DCHECK_CURRENTLY_ON(BrowserThread::IO); |
DVLOG(1) << "VideoCaptureController::StopSession, id " << session_id; |
@@ -573,7 +593,7 @@ void VideoCaptureController::DoIncomingCapturedVideoFrameOnIOThread( |
for (ControllerClients::iterator client_it = controller_clients_.begin(); |
client_it != controller_clients_.end(); ++client_it) { |
ControllerClient* client = *client_it; |
- if (client->session_closed) |
+ if (client->session_closed || client->paused) |
continue; |
if (frame->format() == media::VideoFrame::NATIVE_TEXTURE) { |
@@ -689,4 +709,14 @@ int VideoCaptureController::GetClientCount() { |
return controller_clients_.size(); |
} |
+int VideoCaptureController::GetActiveClientCount() { |
+ DCHECK_CURRENTLY_ON(BrowserThread::IO); |
+ int active_client_count = 0; |
+ for (ControllerClient* client : controller_clients_) { |
tommi (sloooow) - chröme
2014/10/01 07:17:03
oooh...! :)
michaelbai
2014/10/01 22:09:33
I am happy that how simple it is :)
|
+ if (!client->paused) |
+ active_client_count++; |
tommi (sloooow) - chröme
2014/10/01 07:17:02
++active_client_count
michaelbai
2014/10/01 22:09:33
Done.
|
+ } |
+ return active_client_count; |
+} |
+ |
} // namespace content |