1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "content/browser/media/capture/desktop_capture_device_aura.h"
7 #include "base/logging.h"
8 #include "base/timer/timer.h"
9 #include "content/browser/media/capture/aura_window_capture_machine.h"
10 #include "content/public/browser/browser_thread.h"
11 #include "ui/aura/window.h"
17 void SetCaptureSource(AuraWindowCaptureMachine
* machine
,
18 const DesktopMediaID
& source
) {
19 DCHECK_CURRENTLY_ON(BrowserThread::UI
);
21 aura::Window
* window
= DesktopMediaID::GetAuraWindowById(source
);
23 machine
->SetWindow(window
);
28 DesktopCaptureDeviceAura::DesktopCaptureDeviceAura(
29 const DesktopMediaID
& source
) {
30 AuraWindowCaptureMachine
* machine
= new AuraWindowCaptureMachine();
31 core_
.reset(new media::ScreenCaptureDeviceCore(make_scoped_ptr(machine
)));
32 // |core_| owns |machine| and deletes it on UI thread so passing the raw
33 // pointer to the UI thread is safe here.
34 BrowserThread::PostTask(BrowserThread::UI
, FROM_HERE
,
35 base::Bind(&SetCaptureSource
, machine
, source
));
38 DesktopCaptureDeviceAura::~DesktopCaptureDeviceAura() {
39 DVLOG(2) << "DesktopCaptureDeviceAura@" << this << " destroying.";
43 scoped_ptr
<media::VideoCaptureDevice
> DesktopCaptureDeviceAura::Create(
44 const DesktopMediaID
& source
) {
45 if (source
.aura_id
== DesktopMediaID::kNullId
)
47 return scoped_ptr
<media::VideoCaptureDevice
>(
48 new DesktopCaptureDeviceAura(source
));
51 void DesktopCaptureDeviceAura::AllocateAndStart(
52 const media::VideoCaptureParams
& params
,
53 scoped_ptr
<Client
> client
) {
54 DVLOG(1) << "Allocating " << params
.requested_format
.frame_size
.ToString();
55 core_
->AllocateAndStart(params
, client
.Pass());
58 void DesktopCaptureDeviceAura::StopAndDeAllocate() {
59 core_
->StopAndDeAllocate();
62 } // namespace content