| 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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 buffer_id, | 252 buffer_id, |
| 253 buffer, | 253 buffer, |
| 254 0))); | 254 0))); |
| 255 | 255 |
| 256 for (ClientInfoMap::iterator it = clients_.begin(); it != clients_.end(); | 256 for (ClientInfoMap::iterator it = clients_.begin(); it != clients_.end(); |
| 257 ++it) { | 257 ++it) { |
| 258 it->second.deliver_frame_cb.Run(frame, format, timestamp); | 258 it->second.deliver_frame_cb.Run(frame, format, timestamp); |
| 259 } | 259 } |
| 260 } | 260 } |
| 261 | 261 |
| 262 static void NullReadPixelsCB(const SkBitmap& bitmap) { NOTIMPLEMENTED(); } | |
| 263 | |
| 264 void VideoCaptureImpl::OnMailboxBufferReceived( | 262 void VideoCaptureImpl::OnMailboxBufferReceived( |
| 265 int buffer_id, | 263 int buffer_id, |
| 266 const gpu::MailboxHolder& mailbox_holder, | 264 const gpu::MailboxHolder& mailbox_holder, |
| 267 const media::VideoCaptureFormat& format, | 265 const media::VideoCaptureFormat& format, |
| 268 base::TimeTicks timestamp) { | 266 base::TimeTicks timestamp) { |
| 269 DCHECK(thread_checker_.CalledOnValidThread()); | 267 DCHECK(thread_checker_.CalledOnValidThread()); |
| 270 | 268 |
| 271 if (state_ != VIDEO_CAPTURE_STATE_STARTED || suspended_) { | 269 if (state_ != VIDEO_CAPTURE_STATE_STARTED || suspended_) { |
| 272 Send(new VideoCaptureHostMsg_BufferReady(device_id_, buffer_id, 0)); | 270 Send(new VideoCaptureHostMsg_BufferReady(device_id_, buffer_id, 0)); |
| 273 return; | 271 return; |
| 274 } | 272 } |
| 275 | 273 |
| 276 last_frame_format_ = format; | 274 last_frame_format_ = format; |
| 277 if (first_frame_timestamp_.is_null()) | 275 if (first_frame_timestamp_.is_null()) |
| 278 first_frame_timestamp_ = timestamp; | 276 first_frame_timestamp_ = timestamp; |
| 279 | 277 |
| 280 scoped_refptr<media::VideoFrame> frame = media::VideoFrame::WrapNativeTexture( | 278 scoped_refptr<media::VideoFrame> frame = media::VideoFrame::WrapNativeTexture( |
| 281 make_scoped_ptr(new gpu::MailboxHolder(mailbox_holder)), | 279 make_scoped_ptr(new gpu::MailboxHolder(mailbox_holder)), |
| 282 media::BindToCurrentLoop(base::Bind( | 280 media::BindToCurrentLoop(base::Bind( |
| 283 &VideoCaptureImpl::OnClientBufferFinished, weak_factory_.GetWeakPtr(), | 281 &VideoCaptureImpl::OnClientBufferFinished, weak_factory_.GetWeakPtr(), |
| 284 buffer_id, scoped_refptr<ClientBuffer>())), | 282 buffer_id, scoped_refptr<ClientBuffer>())), |
| 285 last_frame_format_.frame_size, gfx::Rect(last_frame_format_.frame_size), | 283 last_frame_format_.frame_size, gfx::Rect(last_frame_format_.frame_size), |
| 286 last_frame_format_.frame_size, timestamp - first_frame_timestamp_, | 284 last_frame_format_.frame_size, timestamp - first_frame_timestamp_, false); |
| 287 base::Bind(&NullReadPixelsCB), false); | |
| 288 | 285 |
| 289 for (ClientInfoMap::iterator it = clients_.begin(); it != clients_.end(); | 286 for (ClientInfoMap::iterator it = clients_.begin(); it != clients_.end(); |
| 290 ++it) { | 287 ++it) { |
| 291 it->second.deliver_frame_cb.Run(frame, format, timestamp); | 288 it->second.deliver_frame_cb.Run(frame, format, timestamp); |
| 292 } | 289 } |
| 293 } | 290 } |
| 294 | 291 |
| 295 void VideoCaptureImpl::OnClientBufferFinished( | 292 void VideoCaptureImpl::OnClientBufferFinished( |
| 296 int buffer_id, | 293 int buffer_id, |
| 297 const scoped_refptr<ClientBuffer>& /* ignored_buffer */, | 294 const scoped_refptr<ClientBuffer>& /* ignored_buffer */, |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 ClientInfoMap::iterator it = clients->find(client_id); | 431 ClientInfoMap::iterator it = clients->find(client_id); |
| 435 if (it != clients->end()) { | 432 if (it != clients->end()) { |
| 436 it->second.state_update_cb.Run(VIDEO_CAPTURE_STATE_STOPPED); | 433 it->second.state_update_cb.Run(VIDEO_CAPTURE_STATE_STOPPED); |
| 437 clients->erase(it); | 434 clients->erase(it); |
| 438 found = true; | 435 found = true; |
| 439 } | 436 } |
| 440 return found; | 437 return found; |
| 441 } | 438 } |
| 442 | 439 |
| 443 } // namespace content | 440 } // namespace content |
| OLD | NEW |