| 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..021ce24ca996bf43a36276bdc5cd0ad029bb47e5 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,22 @@ 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;
|
| +
|
| + DCHECK(client->paused != pause);
|
| + client->paused = pause;
|
| +}
|
| +
|
| void VideoCaptureController::StopSession(int session_id) {
|
| DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
| DVLOG(1) << "VideoCaptureController::StopSession, id " << session_id;
|
| @@ -573,7 +594,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) {
|
| @@ -684,9 +705,19 @@ VideoCaptureController::FindClient(
|
| return NULL;
|
| }
|
|
|
| -int VideoCaptureController::GetClientCount() {
|
| +int VideoCaptureController::GetClientCount() const {
|
| DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
| return controller_clients_.size();
|
| }
|
|
|
| +int VideoCaptureController::GetActiveClientCount() const {
|
| + DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
| + int active_client_count = 0;
|
| + for (ControllerClient* client : controller_clients_) {
|
| + if (!client->paused)
|
| + ++active_client_count;
|
| + }
|
| + return active_client_count;
|
| +}
|
| +
|
| } // namespace content
|
|
|