Chromium Code Reviews| Index: content/browser/media/capture/desktop_capture_device_aura.cc |
| diff --git a/content/browser/media/capture/desktop_capture_device_aura.cc b/content/browser/media/capture/desktop_capture_device_aura.cc |
| index 2c7d196531b121795f84848105a6603edba4bf54..a4aa46da412ead0e6ec1d2a47bfdbd25eed1ea2a 100644 |
| --- a/content/browser/media/capture/desktop_capture_device_aura.cc |
| +++ b/content/browser/media/capture/desktop_capture_device_aura.cc |
| @@ -95,8 +95,8 @@ class DesktopVideoCaptureMachine |
| virtual ~DesktopVideoCaptureMachine(); |
| // VideoCaptureFrameSource overrides. |
| - virtual bool Start( |
| - const scoped_refptr<ThreadSafeCaptureOracle>& oracle_proxy) OVERRIDE; |
| + virtual bool Start(const scoped_refptr<ThreadSafeCaptureOracle>& oracle_proxy, |
| + const media::VideoCaptureParams& params) OVERRIDE; |
| virtual void Stop(const base::Closure& callback) OVERRIDE; |
| // Implements aura::WindowObserver. |
| @@ -152,6 +152,9 @@ class DesktopVideoCaptureMachine |
| // Makes all the decisions about which frames to copy, and how. |
| scoped_refptr<ThreadSafeCaptureOracle> oracle_proxy_; |
| + // The capture parameters for this capture. |
| + media::VideoCaptureParams capture_params_; |
| + |
| // YUV readback pipeline. |
| scoped_ptr<content::ReadbackYUVInterface> yuv_readback_pipeline_; |
| @@ -173,7 +176,8 @@ DesktopVideoCaptureMachine::DesktopVideoCaptureMachine( |
| DesktopVideoCaptureMachine::~DesktopVideoCaptureMachine() {} |
| bool DesktopVideoCaptureMachine::Start( |
| - const scoped_refptr<ThreadSafeCaptureOracle>& oracle_proxy) { |
| + const scoped_refptr<ThreadSafeCaptureOracle>& oracle_proxy, |
| + const media::VideoCaptureParams& params) { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| desktop_window_ = content::DesktopMediaID::GetAuraWindowById(window_id_); |
| @@ -187,6 +191,7 @@ bool DesktopVideoCaptureMachine::Start( |
| DCHECK(oracle_proxy.get()); |
| oracle_proxy_ = oracle_proxy; |
| + capture_params_ = params; |
| // Update capture size. |
| UpdateCaptureSize(); |
| @@ -284,7 +289,12 @@ void CopyOutputFinishedForVideo( |
| if (!cursor_bitmap.isNull()) |
| RenderCursorOnVideoFrame(target, cursor_bitmap, cursor_position); |
| release_callback->Run(0, false); |
| - capture_frame_cb.Run(start_time, result); |
| + capture_frame_cb.Run(target, start_time, result); |
| +} |
| + |
| +void RunSingleReleaseCallback(scoped_ptr<cc::SingleReleaseCallback> cb, |
| + scoped_ptr<gpu::MailboxHolder> mailbox_holder) { |
| + cb->Run(mailbox_holder->sync_point, false); |
| } |
| void DesktopVideoCaptureMachine::DidCopyOutput( |
| @@ -295,6 +305,29 @@ void DesktopVideoCaptureMachine::DidCopyOutput( |
| if (result->IsEmpty() || result->size().IsEmpty() || !desktop_layer_) |
| return; |
| + if (capture_params_.requested_format.pixel_format == |
| + media::PIXEL_FORMAT_TEXTURE) { |
| + DCHECK(!video_frame); |
| + cc::TextureMailbox texture_mailbox; |
| + scoped_ptr<cc::SingleReleaseCallback> release_callback; |
| + result->TakeTexture(&texture_mailbox, &release_callback); |
| + DCHECK(texture_mailbox.IsTexture()); |
| + if (!texture_mailbox.IsTexture()) |
| + return; |
| + video_frame = media::VideoFrame::WrapNativeTexture( |
| + make_scoped_ptr(new gpu::MailboxHolder(texture_mailbox.mailbox(), |
| + texture_mailbox.target(), |
| + texture_mailbox.sync_point())), |
| + base::Bind(&RunSingleReleaseCallback, base::Passed(&release_callback)), |
| + result->size(), |
| + gfx::Rect(result->size()), |
| + result->size(), |
| + base::TimeDelta(), |
|
Ami GONE FROM CHROMIUM
2014/04/01 18:03:38
Why the empty TimeDelta?
sheu
2014/04/21 20:39:39
Just stubbed for now. It would be better to have
|
| + media::VideoFrame::ReadPixelsCB()); |
|
Ami GONE FROM CHROMIUM
2014/04/01 18:03:38
Why the empty ReadPixelsCB?
sheu
2014/04/21 20:39:39
Not expecting this frame to be read back to softwa
|
| + capture_frame_cb.Run(video_frame, start_time, true); |
| + return; |
|
sheu
2014/04/01 00:11:26
Cursor compositing doesn't happen, of course.
|
| + } |
| + |
| // Compute the dest size we want after the letterboxing resize. Make the |
| // coordinates and sizes even because we letterbox in YUV space |
| // (see CopyRGBToVideoFrame). They need to be even for the UV samples to |
| @@ -439,7 +472,11 @@ void DesktopCaptureDeviceAura::AllocateAndStart( |
| const media::VideoCaptureParams& params, |
| scoped_ptr<Client> client) { |
| DVLOG(1) << "Allocating " << params.requested_format.frame_size.ToString(); |
| - core_->AllocateAndStart(params, client.Pass()); |
| + media::VideoCaptureParams new_params = params; |
| + // Desktop capture devices ignore the requested size and return the actual |
| + // captured desktop size. |
| + new_params.requested_format.frame_size.SetSize(0, 0); |
| + core_->AllocateAndStart(new_params, client.Pass()); |
| } |
| void DesktopCaptureDeviceAura::StopAndDeAllocate() { |