OLD | NEW |
---|---|
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 Loading... | |
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 Loading... | |
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( | |
tommi (sloooow) - chröme
2014/10/01 07:17:03
fix indent
michaelbai
2014/10/01 22:09:33
Done.
| |
307 it->second.get(), controller_id, this); | |
308 } | |
309 | |
310 // Send PAUSED_STATE? | |
tommi (sloooow) - chröme
2014/10/01 07:17:03
is this something for the next patch set?
michaelbai
2014/10/01 22:09:33
I don't think this ACK message is needed if curren
| |
311 } | |
312 | |
313 void VideoCaptureHost::OnResumeCapture( | |
314 int device_id, | |
315 media::VideoCaptureSessionId session_id, | |
316 const media::VideoCaptureParams& params) { | |
317 DCHECK_CURRENTLY_ON(BrowserThread::IO); | |
318 DVLOG(1) << "VideoCaptureHost::OnResumeCapture, device_id " << device_id; | |
319 | |
320 VideoCaptureControllerID controller_id(device_id); | |
321 EntryMap::iterator it = entries_.find(controller_id); | |
322 if (it == entries_.end()) | |
323 return; | |
324 | |
325 if (it->second) { | |
326 media_stream_manager_->video_capture_manager()->ResumeCaptureForClient( | |
tommi (sloooow) - chröme
2014/10/01 07:17:03
indent
michaelbai
2014/10/01 22:09:33
Done.
| |
327 session_id, params, it->second.get(), controller_id, this); | |
328 } | |
300 } | 329 } |
301 | 330 |
302 void VideoCaptureHost::OnReceiveEmptyBuffer(int device_id, | 331 void VideoCaptureHost::OnReceiveEmptyBuffer(int device_id, |
303 int buffer_id, | 332 int buffer_id, |
304 uint32 sync_point) { | 333 uint32 sync_point) { |
305 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 334 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
306 | 335 |
307 VideoCaptureControllerID controller_id(device_id); | 336 VideoCaptureControllerID controller_id(device_id); |
308 EntryMap::iterator it = entries_.find(controller_id); | 337 EntryMap::iterator it = entries_.find(controller_id); |
309 if (it != entries_.end()) { | 338 if (it != entries_.end()) { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
356 return; | 385 return; |
357 | 386 |
358 if (it->second) { | 387 if (it->second) { |
359 media_stream_manager_->video_capture_manager()->StopCaptureForClient( | 388 media_stream_manager_->video_capture_manager()->StopCaptureForClient( |
360 it->second.get(), controller_id, this, on_error); | 389 it->second.get(), controller_id, this, on_error); |
361 } | 390 } |
362 entries_.erase(it); | 391 entries_.erase(it); |
363 } | 392 } |
364 | 393 |
365 } // namespace content | 394 } // namespace content |
OLD | NEW |