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