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