| 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/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "content/browser/browser_main_loop.h" | 10 #include "content/browser/browser_main_loop.h" |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 | 152 |
| 153 /////////////////////////////////////////////////////////////////////////////// | 153 /////////////////////////////////////////////////////////////////////////////// |
| 154 // IPC Messages handler. | 154 // IPC Messages handler. |
| 155 bool VideoCaptureHost::OnMessageReceived(const IPC::Message& message) { | 155 bool VideoCaptureHost::OnMessageReceived(const IPC::Message& message) { |
| 156 bool handled = true; | 156 bool handled = true; |
| 157 IPC_BEGIN_MESSAGE_MAP(VideoCaptureHost, message) | 157 IPC_BEGIN_MESSAGE_MAP(VideoCaptureHost, message) |
| 158 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_Start, OnStartCapture) | 158 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_Start, OnStartCapture) |
| 159 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_Pause, OnPauseCapture) | 159 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_Pause, OnPauseCapture) |
| 160 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_Resume, OnResumeCapture) | 160 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_Resume, OnResumeCapture) |
| 161 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_Stop, OnStopCapture) | 161 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_Stop, OnStopCapture) |
| 162 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_BufferReady, OnReceiveEmptyBuffer) | 162 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_BufferReady, |
| 163 OnRendererFinishedWithBuffer) |
| 163 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_GetDeviceSupportedFormats, | 164 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_GetDeviceSupportedFormats, |
| 164 OnGetDeviceSupportedFormats) | 165 OnGetDeviceSupportedFormats) |
| 165 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_GetDeviceFormatsInUse, | 166 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_GetDeviceFormatsInUse, |
| 166 OnGetDeviceFormatsInUse) | 167 OnGetDeviceFormatsInUse) |
| 167 IPC_MESSAGE_UNHANDLED(handled = false) | 168 IPC_MESSAGE_UNHANDLED(handled = false) |
| 168 IPC_END_MESSAGE_MAP() | 169 IPC_END_MESSAGE_MAP() |
| 169 | 170 |
| 170 return handled; | 171 return handled; |
| 171 } | 172 } |
| 172 | 173 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 EntryMap::iterator it = entries_.find(controller_id); | 266 EntryMap::iterator it = entries_.find(controller_id); |
| 266 if (it == entries_.end()) | 267 if (it == entries_.end()) |
| 267 return; | 268 return; |
| 268 | 269 |
| 269 if (it->second) { | 270 if (it->second) { |
| 270 media_stream_manager_->video_capture_manager()->ResumeCaptureForClient( | 271 media_stream_manager_->video_capture_manager()->ResumeCaptureForClient( |
| 271 session_id, params, it->second.get(), controller_id, this); | 272 session_id, params, it->second.get(), controller_id, this); |
| 272 } | 273 } |
| 273 } | 274 } |
| 274 | 275 |
| 275 void VideoCaptureHost::OnReceiveEmptyBuffer(int device_id, | 276 void VideoCaptureHost::OnRendererFinishedWithBuffer( |
| 276 int buffer_id, | 277 int device_id, |
| 277 uint32 sync_point) { | 278 int buffer_id, |
| 279 uint32 sync_point, |
| 280 double consumer_resource_utilization) { |
| 278 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 281 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 279 | 282 |
| 280 VideoCaptureControllerID controller_id(device_id); | 283 VideoCaptureControllerID controller_id(device_id); |
| 281 EntryMap::iterator it = entries_.find(controller_id); | 284 EntryMap::iterator it = entries_.find(controller_id); |
| 282 if (it != entries_.end()) { | 285 if (it != entries_.end()) { |
| 283 const base::WeakPtr<VideoCaptureController>& controller = it->second; | 286 const base::WeakPtr<VideoCaptureController>& controller = it->second; |
| 284 if (controller) | 287 if (controller) { |
| 285 controller->ReturnBuffer(controller_id, this, buffer_id, sync_point); | 288 controller->ReturnBuffer(controller_id, |
| 289 this, |
| 290 buffer_id, |
| 291 sync_point, |
| 292 consumer_resource_utilization); |
| 293 } |
| 286 } | 294 } |
| 287 } | 295 } |
| 288 | 296 |
| 289 void VideoCaptureHost::OnGetDeviceSupportedFormats( | 297 void VideoCaptureHost::OnGetDeviceSupportedFormats( |
| 290 int device_id, | 298 int device_id, |
| 291 media::VideoCaptureSessionId capture_session_id) { | 299 media::VideoCaptureSessionId capture_session_id) { |
| 292 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 300 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 293 DVLOG(1) << "VideoCaptureHost::OnGetDeviceFormats, capture_session_id " | 301 DVLOG(1) << "VideoCaptureHost::OnGetDeviceFormats, capture_session_id " |
| 294 << capture_session_id; | 302 << capture_session_id; |
| 295 media::VideoCaptureFormats device_supported_formats; | 303 media::VideoCaptureFormats device_supported_formats; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 return; | 337 return; |
| 330 | 338 |
| 331 if (it->second) { | 339 if (it->second) { |
| 332 media_stream_manager_->video_capture_manager()->StopCaptureForClient( | 340 media_stream_manager_->video_capture_manager()->StopCaptureForClient( |
| 333 it->second.get(), controller_id, this, on_error); | 341 it->second.get(), controller_id, this, on_error); |
| 334 } | 342 } |
| 335 entries_.erase(it); | 343 entries_.erase(it); |
| 336 } | 344 } |
| 337 | 345 |
| 338 } // namespace content | 346 } // namespace content |
| OLD | NEW |