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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 int buffer_id) { | 69 int buffer_id) { |
70 BrowserThread::PostTask( | 70 BrowserThread::PostTask( |
71 BrowserThread::IO, FROM_HERE, | 71 BrowserThread::IO, FROM_HERE, |
72 base::Bind(&VideoCaptureHost::DoSendFreeBufferOnIOThread, | 72 base::Bind(&VideoCaptureHost::DoSendFreeBufferOnIOThread, |
73 this, controller_id, buffer_id)); | 73 this, controller_id, buffer_id)); |
74 } | 74 } |
75 | 75 |
76 void VideoCaptureHost::OnBufferReady( | 76 void VideoCaptureHost::OnBufferReady( |
77 const VideoCaptureControllerID& controller_id, | 77 const VideoCaptureControllerID& controller_id, |
78 int buffer_id, | 78 int buffer_id, |
79 base::TimeTicks timestamp, | 79 const media::VideoCaptureFormat& frame_format, |
80 const media::VideoCaptureFormat& frame_format) { | 80 base::TimeTicks timestamp) { |
81 BrowserThread::PostTask( | 81 BrowserThread::PostTask( |
82 BrowserThread::IO, FROM_HERE, | 82 BrowserThread::IO, |
| 83 FROM_HERE, |
83 base::Bind(&VideoCaptureHost::DoSendFilledBufferOnIOThread, | 84 base::Bind(&VideoCaptureHost::DoSendFilledBufferOnIOThread, |
84 this, controller_id, buffer_id, timestamp, | 85 this, |
85 frame_format)); | 86 controller_id, |
| 87 buffer_id, |
| 88 frame_format, |
| 89 timestamp)); |
| 90 } |
| 91 |
| 92 void VideoCaptureHost::OnMailboxBufferReady( |
| 93 const VideoCaptureControllerID& controller_id, |
| 94 int buffer_id, |
| 95 const gpu::MailboxHolder& mailbox_holder, |
| 96 const media::VideoCaptureFormat& frame_format, |
| 97 base::TimeTicks timestamp) { |
| 98 BrowserThread::PostTask( |
| 99 BrowserThread::IO, |
| 100 FROM_HERE, |
| 101 base::Bind(&VideoCaptureHost::DoSendFilledMailboxBufferOnIOThread, |
| 102 this, |
| 103 controller_id, |
| 104 buffer_id, |
| 105 mailbox_holder, |
| 106 frame_format, |
| 107 timestamp)); |
86 } | 108 } |
87 | 109 |
88 void VideoCaptureHost::OnEnded(const VideoCaptureControllerID& controller_id) { | 110 void VideoCaptureHost::OnEnded(const VideoCaptureControllerID& controller_id) { |
89 DVLOG(1) << "VideoCaptureHost::OnEnded"; | 111 DVLOG(1) << "VideoCaptureHost::OnEnded"; |
90 BrowserThread::PostTask( | 112 BrowserThread::PostTask( |
91 BrowserThread::IO, FROM_HERE, | 113 BrowserThread::IO, FROM_HERE, |
92 base::Bind(&VideoCaptureHost::DoEndedOnIOThread, this, controller_id)); | 114 base::Bind(&VideoCaptureHost::DoEndedOnIOThread, this, controller_id)); |
93 } | 115 } |
94 | 116 |
95 void VideoCaptureHost::DoSendNewBufferOnIOThread( | 117 void VideoCaptureHost::DoSendNewBufferOnIOThread( |
(...skipping 17 matching lines...) Expand all Loading... |
113 | 135 |
114 if (entries_.find(controller_id) == entries_.end()) | 136 if (entries_.find(controller_id) == entries_.end()) |
115 return; | 137 return; |
116 | 138 |
117 Send(new VideoCaptureMsg_FreeBuffer(controller_id.device_id, buffer_id)); | 139 Send(new VideoCaptureMsg_FreeBuffer(controller_id.device_id, buffer_id)); |
118 } | 140 } |
119 | 141 |
120 void VideoCaptureHost::DoSendFilledBufferOnIOThread( | 142 void VideoCaptureHost::DoSendFilledBufferOnIOThread( |
121 const VideoCaptureControllerID& controller_id, | 143 const VideoCaptureControllerID& controller_id, |
122 int buffer_id, | 144 int buffer_id, |
123 base::TimeTicks timestamp, | 145 const media::VideoCaptureFormat& format, |
124 const media::VideoCaptureFormat& format) { | 146 base::TimeTicks timestamp) { |
125 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 147 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
126 | 148 |
127 if (entries_.find(controller_id) == entries_.end()) | 149 if (entries_.find(controller_id) == entries_.end()) |
128 return; | 150 return; |
129 | 151 |
130 Send(new VideoCaptureMsg_BufferReady(controller_id.device_id, buffer_id, | 152 Send(new VideoCaptureMsg_BufferReady( |
131 timestamp, format)); | 153 controller_id.device_id, buffer_id, format, timestamp)); |
| 154 } |
| 155 |
| 156 void VideoCaptureHost::DoSendFilledMailboxBufferOnIOThread( |
| 157 const VideoCaptureControllerID& controller_id, |
| 158 int buffer_id, |
| 159 const gpu::MailboxHolder& mailbox_holder, |
| 160 const media::VideoCaptureFormat& format, |
| 161 base::TimeTicks timestamp) { |
| 162 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 163 |
| 164 if (entries_.find(controller_id) == entries_.end()) |
| 165 return; |
| 166 |
| 167 Send(new VideoCaptureMsg_MailboxBufferReady( |
| 168 controller_id.device_id, buffer_id, mailbox_holder, format, timestamp)); |
132 } | 169 } |
133 | 170 |
134 void VideoCaptureHost::DoHandleErrorOnIOThread( | 171 void VideoCaptureHost::DoHandleErrorOnIOThread( |
135 const VideoCaptureControllerID& controller_id) { | 172 const VideoCaptureControllerID& controller_id) { |
136 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 173 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
137 | 174 |
138 if (entries_.find(controller_id) == entries_.end()) | 175 if (entries_.find(controller_id) == entries_.end()) |
139 return; | 176 return; |
140 | 177 |
141 Send(new VideoCaptureMsg_StateChanged(controller_id.device_id, | 178 Send(new VideoCaptureMsg_StateChanged(controller_id.device_id, |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 DeleteVideoCaptureControllerOnIOThread(controller_id); | 288 DeleteVideoCaptureControllerOnIOThread(controller_id); |
252 } | 289 } |
253 | 290 |
254 void VideoCaptureHost::OnPauseCapture(int device_id) { | 291 void VideoCaptureHost::OnPauseCapture(int device_id) { |
255 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 292 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
256 DVLOG(1) << "VideoCaptureHost::OnPauseCapture, device_id " << device_id; | 293 DVLOG(1) << "VideoCaptureHost::OnPauseCapture, device_id " << device_id; |
257 // Not used. | 294 // Not used. |
258 Send(new VideoCaptureMsg_StateChanged(device_id, VIDEO_CAPTURE_STATE_ERROR)); | 295 Send(new VideoCaptureMsg_StateChanged(device_id, VIDEO_CAPTURE_STATE_ERROR)); |
259 } | 296 } |
260 | 297 |
261 void VideoCaptureHost::OnReceiveEmptyBuffer(int device_id, int buffer_id) { | 298 void VideoCaptureHost::OnReceiveEmptyBuffer(int device_id, |
| 299 int buffer_id, |
| 300 uint32 sync_point) { |
262 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 301 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
263 | 302 |
264 VideoCaptureControllerID controller_id(device_id); | 303 VideoCaptureControllerID controller_id(device_id); |
265 EntryMap::iterator it = entries_.find(controller_id); | 304 EntryMap::iterator it = entries_.find(controller_id); |
266 if (it != entries_.end()) { | 305 if (it != entries_.end()) { |
267 const base::WeakPtr<VideoCaptureController>& controller = it->second; | 306 const base::WeakPtr<VideoCaptureController>& controller = it->second; |
268 if (controller) | 307 if (controller) |
269 controller->ReturnBuffer(controller_id, this, buffer_id); | 308 controller->ReturnBuffer(controller_id, this, buffer_id, sync_point); |
270 } | 309 } |
271 } | 310 } |
272 | 311 |
273 void VideoCaptureHost::OnGetDeviceSupportedFormats( | 312 void VideoCaptureHost::OnGetDeviceSupportedFormats( |
274 int device_id, | 313 int device_id, |
275 media::VideoCaptureSessionId capture_session_id) { | 314 media::VideoCaptureSessionId capture_session_id) { |
276 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 315 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
277 DVLOG(1) << "VideoCaptureHost::OnGetDeviceFormats, capture_session_id " | 316 DVLOG(1) << "VideoCaptureHost::OnGetDeviceFormats, capture_session_id " |
278 << capture_session_id; | 317 << capture_session_id; |
279 media::VideoCaptureFormats device_supported_formats; | 318 media::VideoCaptureFormats device_supported_formats; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 return; | 352 return; |
314 | 353 |
315 if (it->second) { | 354 if (it->second) { |
316 media_stream_manager_->video_capture_manager()->StopCaptureForClient( | 355 media_stream_manager_->video_capture_manager()->StopCaptureForClient( |
317 it->second.get(), controller_id, this); | 356 it->second.get(), controller_id, this); |
318 } | 357 } |
319 entries_.erase(it); | 358 entries_.erase(it); |
320 } | 359 } |
321 | 360 |
322 } // namespace content | 361 } // namespace content |
OLD | NEW |