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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 if (iter == client_buffers_.end()) | 199 if (iter == client_buffers_.end()) |
200 return; | 200 return; |
201 | 201 |
202 DCHECK(!iter->second.get() || iter->second->HasOneRef()) | 202 DCHECK(!iter->second.get() || iter->second->HasOneRef()) |
203 << "Instructed to delete buffer we are still using."; | 203 << "Instructed to delete buffer we are still using."; |
204 client_buffers_.erase(iter); | 204 client_buffers_.erase(iter); |
205 } | 205 } |
206 | 206 |
207 void VideoCaptureImpl::OnBufferReceived(int buffer_id, | 207 void VideoCaptureImpl::OnBufferReceived(int buffer_id, |
208 const media::VideoCaptureFormat& format, | 208 const media::VideoCaptureFormat& format, |
| 209 const gfx::Rect& visible_rect, |
209 base::TimeTicks timestamp) { | 210 base::TimeTicks timestamp) { |
210 DCHECK(thread_checker_.CalledOnValidThread()); | 211 DCHECK(thread_checker_.CalledOnValidThread()); |
211 | 212 |
212 // The capture pipeline supports only I420 for now. | 213 // The capture pipeline supports only I420 for now. |
213 DCHECK_EQ(format.pixel_format, media::PIXEL_FORMAT_I420); | 214 DCHECK_EQ(format.pixel_format, media::PIXEL_FORMAT_I420); |
214 | 215 |
215 if (state_ != VIDEO_CAPTURE_STATE_STARTED || suspended_) { | 216 if (state_ != VIDEO_CAPTURE_STATE_STARTED || suspended_) { |
216 Send(new VideoCaptureHostMsg_BufferReady(device_id_, buffer_id, 0)); | 217 Send(new VideoCaptureHostMsg_BufferReady(device_id_, buffer_id, 0)); |
217 return; | 218 return; |
218 } | 219 } |
219 | 220 |
220 last_frame_format_ = format; | 221 last_frame_format_ = format; |
221 if (first_frame_timestamp_.is_null()) | 222 if (first_frame_timestamp_.is_null()) |
222 first_frame_timestamp_ = timestamp; | 223 first_frame_timestamp_ = timestamp; |
223 | 224 |
224 // Used by chrome/browser/extension/api/cast_streaming/performance_test.cc | 225 // Used by chrome/browser/extension/api/cast_streaming/performance_test.cc |
225 TRACE_EVENT_INSTANT2( | 226 TRACE_EVENT_INSTANT2( |
226 "cast_perf_test", "OnBufferReceived", | 227 "cast_perf_test", "OnBufferReceived", |
227 TRACE_EVENT_SCOPE_THREAD, | 228 TRACE_EVENT_SCOPE_THREAD, |
228 "timestamp", timestamp.ToInternalValue(), | 229 "timestamp", timestamp.ToInternalValue(), |
229 "time_delta", (timestamp - first_frame_timestamp_).ToInternalValue()); | 230 "time_delta", (timestamp - first_frame_timestamp_).ToInternalValue()); |
230 | 231 |
231 ClientBufferMap::iterator iter = client_buffers_.find(buffer_id); | 232 ClientBufferMap::iterator iter = client_buffers_.find(buffer_id); |
232 DCHECK(iter != client_buffers_.end()); | 233 DCHECK(iter != client_buffers_.end()); |
233 scoped_refptr<ClientBuffer> buffer = iter->second; | 234 scoped_refptr<ClientBuffer> buffer = iter->second; |
234 scoped_refptr<media::VideoFrame> frame = | 235 scoped_refptr<media::VideoFrame> frame = |
235 media::VideoFrame::WrapExternalPackedMemory( | 236 media::VideoFrame::WrapExternalPackedMemory( |
236 media::VideoFrame::I420, | 237 media::VideoFrame::I420, |
237 last_frame_format_.frame_size, | 238 last_frame_format_.frame_size, |
238 gfx::Rect(last_frame_format_.frame_size), | 239 visible_rect, |
239 last_frame_format_.frame_size, | 240 gfx::Size(visible_rect.width(), visible_rect.height()), |
240 reinterpret_cast<uint8*>(buffer->buffer->memory()), | 241 reinterpret_cast<uint8*>(buffer->buffer->memory()), |
241 buffer->buffer_size, | 242 buffer->buffer_size, |
242 buffer->buffer->handle(), | 243 buffer->buffer->handle(), |
243 timestamp - first_frame_timestamp_, | 244 timestamp - first_frame_timestamp_, |
244 media::BindToCurrentLoop( | 245 media::BindToCurrentLoop( |
245 base::Bind(&VideoCaptureImpl::OnClientBufferFinished, | 246 base::Bind(&VideoCaptureImpl::OnClientBufferFinished, |
246 weak_factory_.GetWeakPtr(), | 247 weak_factory_.GetWeakPtr(), |
247 buffer_id, | 248 buffer_id, |
248 buffer, | 249 buffer, |
249 0))); | 250 0))); |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 ClientInfoMap::iterator it = clients->find(client_id); | 434 ClientInfoMap::iterator it = clients->find(client_id); |
434 if (it != clients->end()) { | 435 if (it != clients->end()) { |
435 it->second.state_update_cb.Run(VIDEO_CAPTURE_STATE_STOPPED); | 436 it->second.state_update_cb.Run(VIDEO_CAPTURE_STATE_STOPPED); |
436 clients->erase(it); | 437 clients->erase(it); |
437 found = true; | 438 found = true; |
438 } | 439 } |
439 return found; | 440 return found; |
440 } | 441 } |
441 | 442 |
442 } // namespace content | 443 } // namespace content |
OLD | NEW |