OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_device_client.h" | 5 #include "content/browser/renderer_host/media/video_capture_device_client.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
10 #include "content/browser/compositor/image_transport_factory.h" | 10 #include "content/browser/compositor/image_transport_factory.h" |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 << " Rotation must be a multiple of 90, now: " << rotation; | 236 << " Rotation must be a multiple of 90, now: " << rotation; |
237 libyuv::RotationMode rotation_mode = libyuv::kRotate0; | 237 libyuv::RotationMode rotation_mode = libyuv::kRotate0; |
238 if (rotation == 90) | 238 if (rotation == 90) |
239 rotation_mode = libyuv::kRotate90; | 239 rotation_mode = libyuv::kRotate90; |
240 else if (rotation == 180) | 240 else if (rotation == 180) |
241 rotation_mode = libyuv::kRotate180; | 241 rotation_mode = libyuv::kRotate180; |
242 else if (rotation == 270) | 242 else if (rotation == 270) |
243 rotation_mode = libyuv::kRotate270; | 243 rotation_mode = libyuv::kRotate270; |
244 | 244 |
245 const gfx::Size dimensions(destination_width, destination_height); | 245 const gfx::Size dimensions(destination_width, destination_height); |
246 if (!VideoFrame::IsValidConfig(VideoFrame::I420, | 246 if (!VideoFrame::IsValidConfig(VideoFrame::I420, VideoFrame::TEXTURE_NONE, |
247 dimensions, | 247 dimensions, gfx::Rect(dimensions), |
248 gfx::Rect(dimensions), | |
249 dimensions)) { | 248 dimensions)) { |
250 return; | 249 return; |
251 } | 250 } |
252 | 251 |
253 scoped_ptr<Buffer> buffer( | 252 scoped_ptr<Buffer> buffer( |
254 ReserveOutputBuffer(media::PIXEL_FORMAT_I420, dimensions)); | 253 ReserveOutputBuffer(media::PIXEL_FORMAT_I420, dimensions)); |
255 if (!buffer.get()) | 254 if (!buffer.get()) |
256 return; | 255 return; |
257 | 256 |
258 uint8* const yplane = reinterpret_cast<uint8*>(buffer->data()); | 257 uint8* const yplane = reinterpret_cast<uint8*>(buffer->data()); |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 GL_BGRA_EXT); | 541 GL_BGRA_EXT); |
543 DCHECK(image_id); | 542 DCHECK(image_id); |
544 | 543 |
545 GLuint texture_id = gl_helper_->CreateTexture(); | 544 GLuint texture_id = gl_helper_->CreateTexture(); |
546 DCHECK(texture_id); | 545 DCHECK(texture_id); |
547 { | 546 { |
548 content::ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(gl, texture_id); | 547 content::ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(gl, texture_id); |
549 gl->BindTexImage2DCHROMIUM(GL_TEXTURE_2D, image_id); | 548 gl->BindTexImage2DCHROMIUM(GL_TEXTURE_2D, image_id); |
550 } | 549 } |
551 | 550 |
552 scoped_ptr<gpu::MailboxHolder> mailbox_holder(new gpu::MailboxHolder( | 551 const gpu::MailboxHolder& mailbox_holder( |
553 gl_helper_->ProduceMailboxHolderFromTexture(texture_id))); | 552 gl_helper_->ProduceMailboxHolderFromTexture(texture_id)); |
554 DCHECK(!mailbox_holder->mailbox.IsZero()); | 553 DCHECK(!mailbox_holder.mailbox.IsZero()); |
555 DCHECK(mailbox_holder->mailbox.Verify()); | 554 DCHECK(mailbox_holder.mailbox.Verify()); |
556 DCHECK(mailbox_holder->texture_target); | 555 DCHECK(mailbox_holder.texture_target); |
557 DCHECK(mailbox_holder->sync_point); | 556 DCHECK(mailbox_holder.sync_point); |
558 | 557 |
559 scoped_refptr<media::VideoFrame> video_frame = | 558 scoped_refptr<media::VideoFrame> video_frame = |
560 media::VideoFrame::WrapNativeTexture( | 559 media::VideoFrame::WrapNativeTexture( |
561 mailbox_holder.Pass(), | 560 mailbox_holder, |
562 media::BindToCurrentLoop( | 561 media::BindToCurrentLoop(base::Bind( |
563 base::Bind(&VideoCaptureDeviceClient::TextureWrapHelper:: | 562 &VideoCaptureDeviceClient::TextureWrapHelper::ReleaseCallback, |
564 ReleaseCallback, | 563 this, image_id, texture_id)), |
565 this, image_id, texture_id)), | 564 frame_format.frame_size, gfx::Rect(frame_format.frame_size), |
566 frame_format.frame_size, | 565 frame_format.frame_size, base::TimeDelta(), true /* allow_overlay */); |
567 gfx::Rect(frame_format.frame_size), | |
568 frame_format.frame_size, | |
569 base::TimeDelta(), | |
570 true /* allow_overlay */); | |
571 video_frame->metadata()->SetDouble(media::VideoFrameMetadata::FRAME_RATE, | 566 video_frame->metadata()->SetDouble(media::VideoFrameMetadata::FRAME_RATE, |
572 frame_format.frame_rate); | 567 frame_format.frame_rate); |
573 | 568 |
574 BrowserThread::PostTask( | 569 BrowserThread::PostTask( |
575 BrowserThread::IO, FROM_HERE, | 570 BrowserThread::IO, FROM_HERE, |
576 base::Bind( | 571 base::Bind( |
577 &VideoCaptureController::DoIncomingCapturedVideoFrameOnIOThread, | 572 &VideoCaptureController::DoIncomingCapturedVideoFrameOnIOThread, |
578 controller_, base::Passed(&buffer), video_frame, timestamp)); | 573 controller_, base::Passed(&buffer), video_frame, timestamp)); |
579 } | 574 } |
580 | 575 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
664 void VideoCaptureDeviceClient::TextureWrapHelper::OnError( | 659 void VideoCaptureDeviceClient::TextureWrapHelper::OnError( |
665 const std::string& message) { | 660 const std::string& message) { |
666 DCHECK(capture_task_runner_->BelongsToCurrentThread()); | 661 DCHECK(capture_task_runner_->BelongsToCurrentThread()); |
667 DLOG(ERROR) << message; | 662 DLOG(ERROR) << message; |
668 BrowserThread::PostTask( | 663 BrowserThread::PostTask( |
669 BrowserThread::IO, FROM_HERE, | 664 BrowserThread::IO, FROM_HERE, |
670 base::Bind(&VideoCaptureController::DoErrorOnIOThread, controller_)); | 665 base::Bind(&VideoCaptureController::DoErrorOnIOThread, controller_)); |
671 } | 666 } |
672 | 667 |
673 } // namespace content | 668 } // namespace content |
OLD | NEW |