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

Side by Side Diff: content/renderer/media/video_capture_impl.cc

Issue 850993002: gpu video: optimize HW video to SW canvas and implement it for WebRTC. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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 // 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 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 buffer_id, 251 buffer_id,
252 buffer, 252 buffer,
253 0))); 253 0)));
254 254
255 for (ClientInfoMap::iterator it = clients_.begin(); it != clients_.end(); 255 for (ClientInfoMap::iterator it = clients_.begin(); it != clients_.end();
256 ++it) { 256 ++it) {
257 it->second.deliver_frame_cb.Run(frame, format, timestamp); 257 it->second.deliver_frame_cb.Run(frame, format, timestamp);
258 } 258 }
259 } 259 }
260 260
261 static void NullReadPixelsCB(const SkBitmap& bitmap) { NOTIMPLEMENTED(); }
262
263 void VideoCaptureImpl::OnMailboxBufferReceived( 261 void VideoCaptureImpl::OnMailboxBufferReceived(
264 int buffer_id, 262 int buffer_id,
265 const gpu::MailboxHolder& mailbox_holder, 263 const gpu::MailboxHolder& mailbox_holder,
266 const media::VideoCaptureFormat& format, 264 const media::VideoCaptureFormat& format,
267 base::TimeTicks timestamp) { 265 base::TimeTicks timestamp) {
268 DCHECK(thread_checker_.CalledOnValidThread()); 266 DCHECK(thread_checker_.CalledOnValidThread());
269 267
270 if (state_ != VIDEO_CAPTURE_STATE_STARTED || suspended_) { 268 if (state_ != VIDEO_CAPTURE_STATE_STARTED || suspended_) {
271 Send(new VideoCaptureHostMsg_BufferReady(device_id_, buffer_id, 0)); 269 Send(new VideoCaptureHostMsg_BufferReady(device_id_, buffer_id, 0));
272 return; 270 return;
273 } 271 }
274 272
275 last_frame_format_ = format; 273 last_frame_format_ = format;
276 if (first_frame_timestamp_.is_null()) 274 if (first_frame_timestamp_.is_null())
277 first_frame_timestamp_ = timestamp; 275 first_frame_timestamp_ = timestamp;
278 276
279 scoped_refptr<media::VideoFrame> frame = media::VideoFrame::WrapNativeTexture( 277 scoped_refptr<media::VideoFrame> frame = media::VideoFrame::WrapNativeTexture(
280 make_scoped_ptr(new gpu::MailboxHolder(mailbox_holder)), 278 make_scoped_ptr(new gpu::MailboxHolder(mailbox_holder)),
281 media::BindToCurrentLoop( 279 media::BindToCurrentLoop(base::Bind(
282 base::Bind(&VideoCaptureImpl::OnClientBufferFinished, 280 &VideoCaptureImpl::OnClientBufferFinished, weak_factory_.GetWeakPtr(),
283 weak_factory_.GetWeakPtr(), 281 buffer_id, scoped_refptr<ClientBuffer>())),
284 buffer_id, 282 last_frame_format_.frame_size, gfx::Rect(last_frame_format_.frame_size),
285 scoped_refptr<ClientBuffer>())), 283 last_frame_format_.frame_size, timestamp - first_frame_timestamp_);
286 last_frame_format_.frame_size,
287 gfx::Rect(last_frame_format_.frame_size),
288 last_frame_format_.frame_size,
289 timestamp - first_frame_timestamp_,
290 base::Bind(&NullReadPixelsCB));
291 284
292 for (ClientInfoMap::iterator it = clients_.begin(); it != clients_.end(); 285 for (ClientInfoMap::iterator it = clients_.begin(); it != clients_.end();
293 ++it) { 286 ++it) {
294 it->second.deliver_frame_cb.Run(frame, format, timestamp); 287 it->second.deliver_frame_cb.Run(frame, format, timestamp);
295 } 288 }
296 } 289 }
297 290
298 void VideoCaptureImpl::OnClientBufferFinished( 291 void VideoCaptureImpl::OnClientBufferFinished(
299 int buffer_id, 292 int buffer_id,
300 const scoped_refptr<ClientBuffer>& /* ignored_buffer */, 293 const scoped_refptr<ClientBuffer>& /* ignored_buffer */,
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 ClientInfoMap::iterator it = clients->find(client_id); 430 ClientInfoMap::iterator it = clients->find(client_id);
438 if (it != clients->end()) { 431 if (it != clients->end()) {
439 it->second.state_update_cb.Run(VIDEO_CAPTURE_STATE_STOPPED); 432 it->second.state_update_cb.Run(VIDEO_CAPTURE_STATE_STOPPED);
440 clients->erase(it); 433 clients->erase(it);
441 found = true; 434 found = true;
442 } 435 }
443 return found; 436 return found;
444 } 437 }
445 438
446 } // namespace content 439 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698