| 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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_Pause, OnPauseCapture) | 157 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_Pause, OnPauseCapture) |
| 158 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_Stop, OnStopCapture) | 158 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_Stop, OnStopCapture) |
| 159 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_BufferReady, OnReceiveEmptyBuffer) | 159 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_BufferReady, OnReceiveEmptyBuffer) |
| 160 IPC_MESSAGE_UNHANDLED(handled = false) | 160 IPC_MESSAGE_UNHANDLED(handled = false) |
| 161 IPC_END_MESSAGE_MAP_EX() | 161 IPC_END_MESSAGE_MAP_EX() |
| 162 | 162 |
| 163 return handled; | 163 return handled; |
| 164 } | 164 } |
| 165 | 165 |
| 166 void VideoCaptureHost::OnStartCapture(int device_id, | 166 void VideoCaptureHost::OnStartCapture(int device_id, |
| 167 media::VideoCaptureSessionId session_id, |
| 167 const media::VideoCaptureParams& params) { | 168 const media::VideoCaptureParams& params) { |
| 168 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 169 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 169 DVLOG(1) << "VideoCaptureHost::OnStartCapture, device_id " << device_id | 170 DVLOG(1) << "VideoCaptureHost::OnStartCapture:" |
| 170 << ", (" << params.requested_format.width | 171 << " session_id=" << session_id |
| 171 << ", " << params.requested_format.height | 172 << ", device_id=" << device_id |
| 172 << ", " << params.requested_format.frame_rate | 173 << ", format=" << params.requested_format.frame_size.ToString() |
| 173 << ", " << params.session_id << ", variable resolution device:" | 174 << "@" << params.requested_format.frame_rate |
| 174 << ((params.requested_format.frame_size_type == | 175 << " (" << (params.allow_resolution_change ? "variable" : "constant") |
| 175 media::VariableResolutionVideoCaptureDevice) ? "yes" : "no") | |
| 176 << ")"; | 176 << ")"; |
| 177 VideoCaptureControllerID controller_id(device_id); | 177 VideoCaptureControllerID controller_id(device_id); |
| 178 DCHECK(entries_.find(controller_id) == entries_.end()); | 178 DCHECK(entries_.find(controller_id) == entries_.end()); |
| 179 | 179 |
| 180 entries_[controller_id] = base::WeakPtr<VideoCaptureController>(); | 180 entries_[controller_id] = base::WeakPtr<VideoCaptureController>(); |
| 181 media_stream_manager_->video_capture_manager()->StartCaptureForClient( | 181 media_stream_manager_->video_capture_manager()->StartCaptureForClient( |
| 182 params, PeerHandle(), controller_id, this, base::Bind( | 182 session_id, |
| 183 &VideoCaptureHost::OnControllerAdded, this, device_id, params)); | 183 params, |
| 184 PeerHandle(), |
| 185 controller_id, |
| 186 this, |
| 187 base::Bind(&VideoCaptureHost::OnControllerAdded, this, device_id)); |
| 184 } | 188 } |
| 185 | 189 |
| 186 void VideoCaptureHost::OnControllerAdded( | 190 void VideoCaptureHost::OnControllerAdded( |
| 187 int device_id, const media::VideoCaptureParams& params, | 191 int device_id, |
| 188 const base::WeakPtr<VideoCaptureController>& controller) { | 192 const base::WeakPtr<VideoCaptureController>& controller) { |
| 189 BrowserThread::PostTask( | 193 BrowserThread::PostTask( |
| 190 BrowserThread::IO, FROM_HERE, | 194 BrowserThread::IO, |
| 195 FROM_HERE, |
| 191 base::Bind(&VideoCaptureHost::DoControllerAddedOnIOThread, | 196 base::Bind(&VideoCaptureHost::DoControllerAddedOnIOThread, |
| 192 this, device_id, params, controller)); | 197 this, |
| 198 device_id, |
| 199 controller)); |
| 193 } | 200 } |
| 194 | 201 |
| 195 void VideoCaptureHost::DoControllerAddedOnIOThread( | 202 void VideoCaptureHost::DoControllerAddedOnIOThread( |
| 196 int device_id, const media::VideoCaptureParams& params, | 203 int device_id, |
| 197 const base::WeakPtr<VideoCaptureController>& controller) { | 204 const base::WeakPtr<VideoCaptureController>& controller) { |
| 198 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 205 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 199 VideoCaptureControllerID controller_id(device_id); | 206 VideoCaptureControllerID controller_id(device_id); |
| 200 EntryMap::iterator it = entries_.find(controller_id); | 207 EntryMap::iterator it = entries_.find(controller_id); |
| 201 if (it == entries_.end()) { | 208 if (it == entries_.end()) { |
| 202 if (controller) { | 209 if (controller) { |
| 203 media_stream_manager_->video_capture_manager()->StopCaptureForClient( | 210 media_stream_manager_->video_capture_manager()->StopCaptureForClient( |
| 204 controller.get(), controller_id, this); | 211 controller.get(), controller_id, this); |
| 205 } | 212 } |
| 206 return; | 213 return; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 return; | 263 return; |
| 257 | 264 |
| 258 if (it->second) { | 265 if (it->second) { |
| 259 media_stream_manager_->video_capture_manager()->StopCaptureForClient( | 266 media_stream_manager_->video_capture_manager()->StopCaptureForClient( |
| 260 it->second.get(), controller_id, this); | 267 it->second.get(), controller_id, this); |
| 261 } | 268 } |
| 262 entries_.erase(it); | 269 entries_.erase(it); |
| 263 } | 270 } |
| 264 | 271 |
| 265 } // namespace content | 272 } // namespace content |
| OLD | NEW |