Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(347)

Side by Side Diff: content/browser/renderer_host/media/video_capture_host.cc

Issue 2400443006: VideoCapture: moar VideoCapture renderer-->host messages to mojo, part 3 (Closed)
Patch Set: minor rebase Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <memory> 7 #include <memory>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 DeleteVideoCaptureController(controller_id, false); 137 DeleteVideoCaptureController(controller_id, false);
138 } 138 }
139 139
140 /////////////////////////////////////////////////////////////////////////////// 140 ///////////////////////////////////////////////////////////////////////////////
141 // IPC Messages handler. 141 // IPC Messages handler.
142 bool VideoCaptureHost::OnMessageReceived(const IPC::Message& message) { 142 bool VideoCaptureHost::OnMessageReceived(const IPC::Message& message) {
143 bool handled = true; 143 bool handled = true;
144 IPC_BEGIN_MESSAGE_MAP(VideoCaptureHost, message) 144 IPC_BEGIN_MESSAGE_MAP(VideoCaptureHost, message)
145 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_BufferReady, 145 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_BufferReady,
146 OnRendererFinishedWithBuffer) 146 OnRendererFinishedWithBuffer)
147 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_GetDeviceSupportedFormats,
148 OnGetDeviceSupportedFormats)
149 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_GetDeviceFormatsInUse,
150 OnGetDeviceFormatsInUse)
151 IPC_MESSAGE_UNHANDLED(handled = false) 147 IPC_MESSAGE_UNHANDLED(handled = false)
152 IPC_END_MESSAGE_MAP() 148 IPC_END_MESSAGE_MAP()
153 149
154 return handled; 150 return handled;
155 } 151 }
156 152
157 void VideoCaptureHost::OnRendererFinishedWithBuffer( 153 void VideoCaptureHost::OnRendererFinishedWithBuffer(
158 int device_id, 154 int device_id,
159 int buffer_id, 155 int buffer_id,
160 const gpu::SyncToken& sync_token, 156 const gpu::SyncToken& sync_token,
161 double consumer_resource_utilization) { 157 double consumer_resource_utilization) {
162 DCHECK_CURRENTLY_ON(BrowserThread::IO); 158 DCHECK_CURRENTLY_ON(BrowserThread::IO);
163 159
164 VideoCaptureControllerID controller_id(device_id); 160 VideoCaptureControllerID controller_id(device_id);
165 auto it = controllers_.find(controller_id); 161 auto it = controllers_.find(controller_id);
166 if (it != controllers_.end()) { 162 if (it != controllers_.end()) {
167 const base::WeakPtr<VideoCaptureController>& controller = it->second; 163 const base::WeakPtr<VideoCaptureController>& controller = it->second;
168 if (controller) { 164 if (controller) {
169 controller->ReturnBuffer(controller_id, this, buffer_id, sync_token, 165 controller->ReturnBuffer(controller_id, this, buffer_id, sync_token,
170 consumer_resource_utilization); 166 consumer_resource_utilization);
171 } 167 }
172 } 168 }
173 } 169 }
174 170
175 void VideoCaptureHost::OnGetDeviceSupportedFormats(
176 int device_id,
177 media::VideoCaptureSessionId session_id) {
178 DVLOG(1) << __func__ << " " << device_id;
179 DCHECK_CURRENTLY_ON(BrowserThread::IO);
180 media::VideoCaptureFormats device_supported_formats;
181 if (!media_stream_manager_->video_capture_manager()
182 ->GetDeviceSupportedFormats(session_id,
183 &device_supported_formats)) {
184 DLOG(WARNING)
185 << "Could not retrieve device supported formats for device_id="
186 << device_id << " session_id=" << session_id;
187 }
188 Send(new VideoCaptureMsg_DeviceSupportedFormatsEnumerated(
189 device_id, device_supported_formats));
190 }
191
192 void VideoCaptureHost::OnGetDeviceFormatsInUse(
193 int device_id,
194 media::VideoCaptureSessionId session_id) {
195 DVLOG(1) << __func__ << " " << device_id;
196 DCHECK_CURRENTLY_ON(BrowserThread::IO);
197 media::VideoCaptureFormats formats_in_use;
198 if (!media_stream_manager_->video_capture_manager()->GetDeviceFormatsInUse(
199 session_id, &formats_in_use)) {
200 DVLOG(1) << "Could not retrieve device format(s) in use for device_id="
201 << device_id << " session_id=" << session_id;
202 }
203 Send(new VideoCaptureMsg_DeviceFormatsInUseReceived(device_id,
204 formats_in_use));
205 }
206
207 void VideoCaptureHost::Start(int32_t device_id, 171 void VideoCaptureHost::Start(int32_t device_id,
208 int32_t session_id, 172 int32_t session_id,
209 const media::VideoCaptureParams& params) { 173 const media::VideoCaptureParams& params) {
210 DVLOG(1) << __func__ << " session_id=" << session_id 174 DVLOG(1) << __func__ << " session_id=" << session_id
211 << ", device_id=" << device_id << ", format=" 175 << ", device_id=" << device_id << ", format="
212 << media::VideoCaptureFormat::ToString(params.requested_format); 176 << media::VideoCaptureFormat::ToString(params.requested_format);
213 DCHECK_CURRENTLY_ON(BrowserThread::IO); 177 DCHECK_CURRENTLY_ON(BrowserThread::IO);
214 const VideoCaptureControllerID controller_id(device_id); 178 const VideoCaptureControllerID controller_id(device_id);
215 if (controllers_.find(controller_id) != controllers_.end()) { 179 if (controllers_.find(controller_id) != controllers_.end()) {
216 Send(new VideoCaptureMsg_StateChanged(device_id, 180 Send(new VideoCaptureMsg_StateChanged(device_id,
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 auto it = controllers_.find(controller_id); 242 auto it = controllers_.find(controller_id);
279 if (it == controllers_.end()) 243 if (it == controllers_.end())
280 return; 244 return;
281 245
282 if (VideoCaptureController* controller = it->second.get()) { 246 if (VideoCaptureController* controller = it->second.get()) {
283 media_stream_manager_->video_capture_manager() 247 media_stream_manager_->video_capture_manager()
284 ->RequestRefreshFrameForClient(controller); 248 ->RequestRefreshFrameForClient(controller);
285 } 249 }
286 } 250 }
287 251
252 void VideoCaptureHost::GetDeviceSupportedFormats(
253 int32_t device_id,
254 int32_t session_id,
255 const GetDeviceSupportedFormatsCallback& callback) {
256 DVLOG(1) << __func__ << " " << device_id;
257 DCHECK_CURRENTLY_ON(BrowserThread::IO);
258 media::VideoCaptureFormats supported_formats;
259 if (!media_stream_manager_->video_capture_manager()
260 ->GetDeviceSupportedFormats(session_id, &supported_formats)) {
261 DLOG(WARNING) << "Could not retrieve device supported formats";
262 }
263 callback.Run(supported_formats);
264 }
265
266 void VideoCaptureHost::GetDeviceFormatsInUse(
267 int32_t device_id,
268 int32_t session_id,
269 const GetDeviceFormatsInUseCallback& callback) {
270 DVLOG(1) << __func__ << " " << device_id;
271 DCHECK_CURRENTLY_ON(BrowserThread::IO);
272 media::VideoCaptureFormats formats_in_use;
273 if (!media_stream_manager_->video_capture_manager()->GetDeviceFormatsInUse(
274 session_id, &formats_in_use)) {
275 DLOG(WARNING) << "Could not retrieve device format(s) in use";
276 }
277 callback.Run(formats_in_use);
278 }
279
288 void VideoCaptureHost::OnControllerAdded( 280 void VideoCaptureHost::OnControllerAdded(
289 int device_id, 281 int device_id,
290 const base::WeakPtr<VideoCaptureController>& controller) { 282 const base::WeakPtr<VideoCaptureController>& controller) {
291 DCHECK_CURRENTLY_ON(BrowserThread::IO); 283 DCHECK_CURRENTLY_ON(BrowserThread::IO);
292 VideoCaptureControllerID controller_id(device_id); 284 VideoCaptureControllerID controller_id(device_id);
293 auto it = controllers_.find(controller_id); 285 auto it = controllers_.find(controller_id);
294 if (it == controllers_.end()) { 286 if (it == controllers_.end()) {
295 if (controller) { 287 if (controller) {
296 media_stream_manager_->video_capture_manager()->StopCaptureForClient( 288 media_stream_manager_->video_capture_manager()->StopCaptureForClient(
297 controller.get(), controller_id, this, false); 289 controller.get(), controller_id, this, false);
(...skipping 21 matching lines...) Expand all
319 return; 311 return;
320 312
321 if (it->second) { 313 if (it->second) {
322 media_stream_manager_->video_capture_manager()->StopCaptureForClient( 314 media_stream_manager_->video_capture_manager()->StopCaptureForClient(
323 it->second.get(), controller_id, this, on_error); 315 it->second.get(), controller_id, this, on_error);
324 } 316 }
325 controllers_.erase(it); 317 controllers_.erase(it);
326 } 318 }
327 319
328 } // namespace content 320 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/media/video_capture_host.h ('k') | content/common/media/video_capture_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698