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 // Notes about usage of this object by VideoCaptureImplManager. | 5 // Notes about usage of this object by VideoCaptureImplManager. |
6 // | 6 // |
7 // VideoCaptureImplManager access this object by using a Unretained() | 7 // VideoCaptureImplManager access this object by using a Unretained() |
8 // binding and tasks on the IO thread. It is then important that | 8 // binding and tasks on the IO thread. It is then important that |
9 // VideoCaptureImpl never post task to itself. All operations must be | 9 // VideoCaptureImpl never post task to itself. All operations must be |
10 // synchronous. | 10 // synchronous. |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 Send(new VideoCaptureHostMsg_BufferReady(device_id_, buffer_id, 0)); | 271 Send(new VideoCaptureHostMsg_BufferReady(device_id_, buffer_id, 0)); |
272 return; | 272 return; |
273 } | 273 } |
274 | 274 |
275 last_frame_format_ = format; | 275 last_frame_format_ = format; |
276 if (first_frame_timestamp_.is_null()) | 276 if (first_frame_timestamp_.is_null()) |
277 first_frame_timestamp_ = timestamp; | 277 first_frame_timestamp_ = timestamp; |
278 | 278 |
279 scoped_refptr<media::VideoFrame> frame = media::VideoFrame::WrapNativeTexture( | 279 scoped_refptr<media::VideoFrame> frame = media::VideoFrame::WrapNativeTexture( |
280 make_scoped_ptr(new gpu::MailboxHolder(mailbox_holder)), | 280 make_scoped_ptr(new gpu::MailboxHolder(mailbox_holder)), |
281 media::BindToCurrentLoop( | 281 media::BindToCurrentLoop(base::Bind( |
282 base::Bind(&VideoCaptureImpl::OnClientBufferFinished, | 282 &VideoCaptureImpl::OnClientBufferFinished, weak_factory_.GetWeakPtr(), |
283 weak_factory_.GetWeakPtr(), | 283 buffer_id, scoped_refptr<ClientBuffer>())), |
284 buffer_id, | 284 last_frame_format_.frame_size, gfx::Rect(last_frame_format_.frame_size), |
285 scoped_refptr<ClientBuffer>())), | 285 last_frame_format_.frame_size, timestamp - first_frame_timestamp_, |
286 last_frame_format_.frame_size, | 286 base::Bind(&NullReadPixelsCB), false); |
287 gfx::Rect(last_frame_format_.frame_size), | |
288 last_frame_format_.frame_size, | |
289 timestamp - first_frame_timestamp_, | |
290 base::Bind(&NullReadPixelsCB)); | |
291 | 287 |
292 for (ClientInfoMap::iterator it = clients_.begin(); it != clients_.end(); | 288 for (ClientInfoMap::iterator it = clients_.begin(); it != clients_.end(); |
293 ++it) { | 289 ++it) { |
294 it->second.deliver_frame_cb.Run(frame, format, timestamp); | 290 it->second.deliver_frame_cb.Run(frame, format, timestamp); |
295 } | 291 } |
296 } | 292 } |
297 | 293 |
298 void VideoCaptureImpl::OnClientBufferFinished( | 294 void VideoCaptureImpl::OnClientBufferFinished( |
299 int buffer_id, | 295 int buffer_id, |
300 const scoped_refptr<ClientBuffer>& /* ignored_buffer */, | 296 const scoped_refptr<ClientBuffer>& /* ignored_buffer */, |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 ClientInfoMap::iterator it = clients->find(client_id); | 433 ClientInfoMap::iterator it = clients->find(client_id); |
438 if (it != clients->end()) { | 434 if (it != clients->end()) { |
439 it->second.state_update_cb.Run(VIDEO_CAPTURE_STATE_STOPPED); | 435 it->second.state_update_cb.Run(VIDEO_CAPTURE_STATE_STOPPED); |
440 clients->erase(it); | 436 clients->erase(it); |
441 found = true; | 437 found = true; |
442 } | 438 } |
443 return found; | 439 return found; |
444 } | 440 } |
445 | 441 |
446 } // namespace content | 442 } // namespace content |
OLD | NEW |