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

Side by Side Diff: content/browser/renderer_host/media/video_capture_host.cc

Issue 615043006: Release the camera when WebRTC is not visible in Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sync Created 6 years, 2 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/browser/renderer_host/media/video_capture_host.h" 5 #include "content/browser/renderer_host/media/video_capture_host.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "content/browser/browser_main_loop.h" 9 #include "content/browser/browser_main_loop.h"
10 #include "content/browser/renderer_host/media/media_stream_manager.h" 10 #include "content/browser/renderer_host/media/media_stream_manager.h"
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 DeleteVideoCaptureControllerOnIOThread(controller_id, false); 195 DeleteVideoCaptureControllerOnIOThread(controller_id, false);
196 } 196 }
197 197
198 /////////////////////////////////////////////////////////////////////////////// 198 ///////////////////////////////////////////////////////////////////////////////
199 // IPC Messages handler. 199 // IPC Messages handler.
200 bool VideoCaptureHost::OnMessageReceived(const IPC::Message& message) { 200 bool VideoCaptureHost::OnMessageReceived(const IPC::Message& message) {
201 bool handled = true; 201 bool handled = true;
202 IPC_BEGIN_MESSAGE_MAP(VideoCaptureHost, message) 202 IPC_BEGIN_MESSAGE_MAP(VideoCaptureHost, message)
203 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_Start, OnStartCapture) 203 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_Start, OnStartCapture)
204 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_Pause, OnPauseCapture) 204 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_Pause, OnPauseCapture)
205 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_Resume, OnResumeCapture)
205 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_Stop, OnStopCapture) 206 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_Stop, OnStopCapture)
206 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_BufferReady, OnReceiveEmptyBuffer) 207 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_BufferReady, OnReceiveEmptyBuffer)
207 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_GetDeviceSupportedFormats, 208 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_GetDeviceSupportedFormats,
208 OnGetDeviceSupportedFormats) 209 OnGetDeviceSupportedFormats)
209 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_GetDeviceFormatsInUse, 210 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_GetDeviceFormatsInUse,
210 OnGetDeviceFormatsInUse) 211 OnGetDeviceFormatsInUse)
211 IPC_MESSAGE_UNHANDLED(handled = false) 212 IPC_MESSAGE_UNHANDLED(handled = false)
212 IPC_END_MESSAGE_MAP() 213 IPC_END_MESSAGE_MAP()
213 214
214 return handled; 215 return handled;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 VideoCaptureControllerID controller_id(device_id); 289 VideoCaptureControllerID controller_id(device_id);
289 290
290 Send(new VideoCaptureMsg_StateChanged(device_id, 291 Send(new VideoCaptureMsg_StateChanged(device_id,
291 VIDEO_CAPTURE_STATE_STOPPED)); 292 VIDEO_CAPTURE_STATE_STOPPED));
292 DeleteVideoCaptureControllerOnIOThread(controller_id, false); 293 DeleteVideoCaptureControllerOnIOThread(controller_id, false);
293 } 294 }
294 295
295 void VideoCaptureHost::OnPauseCapture(int device_id) { 296 void VideoCaptureHost::OnPauseCapture(int device_id) {
296 DCHECK_CURRENTLY_ON(BrowserThread::IO); 297 DCHECK_CURRENTLY_ON(BrowserThread::IO);
297 DVLOG(1) << "VideoCaptureHost::OnPauseCapture, device_id " << device_id; 298 DVLOG(1) << "VideoCaptureHost::OnPauseCapture, device_id " << device_id;
298 // Not used. 299
299 Send(new VideoCaptureMsg_StateChanged(device_id, VIDEO_CAPTURE_STATE_ERROR)); 300 VideoCaptureControllerID controller_id(device_id);
301 EntryMap::iterator it = entries_.find(controller_id);
302 if (it == entries_.end())
303 return;
304
305 if (it->second) {
306 media_stream_manager_->video_capture_manager()->PauseCaptureForClient(
307 it->second.get(), controller_id, this);
308 }
309 }
310
311 void VideoCaptureHost::OnResumeCapture(
312 int device_id,
313 media::VideoCaptureSessionId session_id,
314 const media::VideoCaptureParams& params) {
315 DCHECK_CURRENTLY_ON(BrowserThread::IO);
316 DVLOG(1) << "VideoCaptureHost::OnResumeCapture, device_id " << device_id;
317
318 VideoCaptureControllerID controller_id(device_id);
319 EntryMap::iterator it = entries_.find(controller_id);
320 if (it == entries_.end())
321 return;
322
323 if (it->second) {
324 media_stream_manager_->video_capture_manager()->ResumeCaptureForClient(
325 session_id, params, it->second.get(), controller_id, this);
326 }
300 } 327 }
301 328
302 void VideoCaptureHost::OnReceiveEmptyBuffer(int device_id, 329 void VideoCaptureHost::OnReceiveEmptyBuffer(int device_id,
303 int buffer_id, 330 int buffer_id,
304 uint32 sync_point) { 331 uint32 sync_point) {
305 DCHECK_CURRENTLY_ON(BrowserThread::IO); 332 DCHECK_CURRENTLY_ON(BrowserThread::IO);
306 333
307 VideoCaptureControllerID controller_id(device_id); 334 VideoCaptureControllerID controller_id(device_id);
308 EntryMap::iterator it = entries_.find(controller_id); 335 EntryMap::iterator it = entries_.find(controller_id);
309 if (it != entries_.end()) { 336 if (it != entries_.end()) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 return; 383 return;
357 384
358 if (it->second) { 385 if (it->second) {
359 media_stream_manager_->video_capture_manager()->StopCaptureForClient( 386 media_stream_manager_->video_capture_manager()->StopCaptureForClient(
360 it->second.get(), controller_id, this, on_error); 387 it->second.get(), controller_id, this, on_error);
361 } 388 }
362 entries_.erase(it); 389 entries_.erase(it);
363 } 390 }
364 391
365 } // namespace content 392 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/media/video_capture_host.h ('k') | content/browser/renderer_host/media/video_capture_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698