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 "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "content/browser/browser_main_loop.h" | 10 #include "content/browser/browser_main_loop.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 BrowserThread::IO, | 88 BrowserThread::IO, |
89 FROM_HERE, | 89 FROM_HERE, |
90 base::Bind(&VideoCaptureHost::DoSendFrameInfoOnIOThread, | 90 base::Bind(&VideoCaptureHost::DoSendFrameInfoOnIOThread, |
91 this, controller_id, format)); | 91 this, controller_id, format)); |
92 } | 92 } |
93 | 93 |
94 void VideoCaptureHost::OnFrameInfoChanged( | 94 void VideoCaptureHost::OnFrameInfoChanged( |
95 const VideoCaptureControllerID& controller_id, | 95 const VideoCaptureControllerID& controller_id, |
96 int width, | 96 int width, |
97 int height, | 97 int height, |
98 int frame_per_second) { | 98 int frame_rate) { |
99 BrowserThread::PostTask( | 99 BrowserThread::PostTask( |
100 BrowserThread::IO, FROM_HERE, | 100 BrowserThread::IO, FROM_HERE, |
101 base::Bind(&VideoCaptureHost::DoSendFrameInfoChangedOnIOThread, | 101 base::Bind(&VideoCaptureHost::DoSendFrameInfoChangedOnIOThread, |
102 this, controller_id, width, height, frame_per_second)); | 102 this, controller_id, width, height, frame_rate)); |
103 } | 103 } |
104 | 104 |
105 void VideoCaptureHost::OnEnded(const VideoCaptureControllerID& controller_id) { | 105 void VideoCaptureHost::OnEnded(const VideoCaptureControllerID& controller_id) { |
106 DVLOG(1) << "VideoCaptureHost::OnEnded"; | 106 DVLOG(1) << "VideoCaptureHost::OnEnded"; |
107 BrowserThread::PostTask( | 107 BrowserThread::PostTask( |
108 BrowserThread::IO, FROM_HERE, | 108 BrowserThread::IO, FROM_HERE, |
109 base::Bind(&VideoCaptureHost::DoEndedOnIOThread, this, controller_id)); | 109 base::Bind(&VideoCaptureHost::DoEndedOnIOThread, this, controller_id)); |
110 } | 110 } |
111 | 111 |
112 void VideoCaptureHost::DoSendNewBufferOnIOThread( | 112 void VideoCaptureHost::DoSendNewBufferOnIOThread( |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 const VideoCaptureControllerID& controller_id, | 163 const VideoCaptureControllerID& controller_id, |
164 const media::VideoCaptureCapability& format) { | 164 const media::VideoCaptureCapability& format) { |
165 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 165 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
166 | 166 |
167 if (entries_.find(controller_id) == entries_.end()) | 167 if (entries_.find(controller_id) == entries_.end()) |
168 return; | 168 return; |
169 | 169 |
170 media::VideoCaptureParams params; | 170 media::VideoCaptureParams params; |
171 params.width = format.width; | 171 params.width = format.width; |
172 params.height = format.height; | 172 params.height = format.height; |
173 params.frame_per_second = format.frame_rate; | 173 params.frame_rate = format.frame_rate; |
174 params.frame_size_type = format.frame_size_type; | 174 params.frame_size_type = format.frame_size_type; |
175 Send(new VideoCaptureMsg_DeviceInfo(controller_id.device_id, params)); | 175 Send(new VideoCaptureMsg_DeviceInfo(controller_id.device_id, params)); |
176 Send(new VideoCaptureMsg_StateChanged(controller_id.device_id, | 176 Send(new VideoCaptureMsg_StateChanged(controller_id.device_id, |
177 VIDEO_CAPTURE_STATE_STARTED)); | 177 VIDEO_CAPTURE_STATE_STARTED)); |
178 } | 178 } |
179 | 179 |
180 void VideoCaptureHost::DoSendFrameInfoChangedOnIOThread( | 180 void VideoCaptureHost::DoSendFrameInfoChangedOnIOThread( |
181 const VideoCaptureControllerID& controller_id, | 181 const VideoCaptureControllerID& controller_id, |
182 int width, | 182 int width, |
183 int height, | 183 int height, |
184 int frame_per_second) { | 184 int frame_rate) { |
185 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 185 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
186 | 186 |
187 if (entries_.find(controller_id) == entries_.end()) | 187 if (entries_.find(controller_id) == entries_.end()) |
188 return; | 188 return; |
189 | 189 |
190 media::VideoCaptureParams params; | 190 media::VideoCaptureParams params; |
191 params.width = width; | 191 params.width = width; |
192 params.height = height; | 192 params.height = height; |
193 params.frame_per_second = frame_per_second; | 193 params.frame_rate = frame_rate; |
194 Send(new VideoCaptureMsg_DeviceInfoChanged(controller_id.device_id, params)); | 194 Send(new VideoCaptureMsg_DeviceInfoChanged(controller_id.device_id, params)); |
195 } | 195 } |
196 | 196 |
197 /////////////////////////////////////////////////////////////////////////////// | 197 /////////////////////////////////////////////////////////////////////////////// |
198 // IPC Messages handler. | 198 // IPC Messages handler. |
199 bool VideoCaptureHost::OnMessageReceived(const IPC::Message& message, | 199 bool VideoCaptureHost::OnMessageReceived(const IPC::Message& message, |
200 bool* message_was_ok) { | 200 bool* message_was_ok) { |
201 bool handled = true; | 201 bool handled = true; |
202 IPC_BEGIN_MESSAGE_MAP_EX(VideoCaptureHost, message, *message_was_ok) | 202 IPC_BEGIN_MESSAGE_MAP_EX(VideoCaptureHost, message, *message_was_ok) |
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_Stop, OnStopCapture) | 205 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_Stop, OnStopCapture) |
206 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_BufferReady, OnReceiveEmptyBuffer) | 206 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_BufferReady, OnReceiveEmptyBuffer) |
207 IPC_MESSAGE_UNHANDLED(handled = false) | 207 IPC_MESSAGE_UNHANDLED(handled = false) |
208 IPC_END_MESSAGE_MAP_EX() | 208 IPC_END_MESSAGE_MAP_EX() |
209 | 209 |
210 return handled; | 210 return handled; |
211 } | 211 } |
212 | 212 |
213 void VideoCaptureHost::OnStartCapture(int device_id, | 213 void VideoCaptureHost::OnStartCapture(int device_id, |
214 const media::VideoCaptureParams& params) { | 214 const media::VideoCaptureParams& params) { |
215 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 215 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
216 DVLOG(1) << "VideoCaptureHost::OnStartCapture, device_id " << device_id | 216 DVLOG(1) << "VideoCaptureHost::OnStartCapture, device_id " << device_id |
217 << ", (" << params.width << ", " << params.height << ", " | 217 << ", (" << params.width << ", " << params.height << ", " |
218 << params.frame_per_second << ", " << params.session_id | 218 << params.frame_rate << ", " << params.session_id |
219 << ", variable resolution device:" | 219 << ", variable resolution device:" |
220 << ((params.frame_size_type == | 220 << ((params.frame_size_type == |
221 media::VariableResolutionVideoCaptureDevice) ? "yes" : "no") | 221 media::VariableResolutionVideoCaptureDevice) ? "yes" : "no") |
222 << ")"; | 222 << ")"; |
223 VideoCaptureControllerID controller_id(device_id); | 223 VideoCaptureControllerID controller_id(device_id); |
224 DCHECK(entries_.find(controller_id) == entries_.end()); | 224 DCHECK(entries_.find(controller_id) == entries_.end()); |
225 | 225 |
226 entries_[controller_id] = new Entry(NULL); | 226 entries_[controller_id] = new Entry(NULL); |
227 media_stream_manager_->video_capture_manager()->AddController( | 227 media_stream_manager_->video_capture_manager()->AddController( |
228 params, this, base::Bind(&VideoCaptureHost::OnControllerAdded, this, | 228 params, this, base::Bind(&VideoCaptureHost::OnControllerAdded, this, |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 if (controller) { | 306 if (controller) { |
307 controller->StopCapture(controller_id, this); | 307 controller->StopCapture(controller_id, this); |
308 media_stream_manager_->video_capture_manager()->RemoveController( | 308 media_stream_manager_->video_capture_manager()->RemoveController( |
309 controller, this); | 309 controller, this); |
310 } | 310 } |
311 delete it->second; | 311 delete it->second; |
312 entries_.erase(controller_id); | 312 entries_.erase(controller_id); |
313 } | 313 } |
314 | 314 |
315 } // namespace content | 315 } // namespace content |
OLD | NEW |