Commit 75a951ba authored by Yuri Wiitala's avatar Yuri Wiitala Committed by Commit Bot

Remove now-dead code: AuraWindowCaptureMachine and DesktopCaptureDeviceAura

The new implementations have been live for a bit more than a milestone.
It's safe now to delete the old ones.

TBR=jam@chromium.org

Bug: 806366
Change-Id: Icde37e386f975dcc0cee70c17ef482191e74ceba
Reviewed-on: https://chromium-review.googlesource.com/1137453
Commit-Queue: Yuri Wiitala <miu@chromium.org>
Reviewed-by: default avatarJohn Abd-El-Malek <jam@chromium.org>
Reviewed-by: default avatarXiangjun Zhang <xjz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#575451}
parent 85726dfc
...@@ -1890,8 +1890,6 @@ jumbo_source_set("browser") { ...@@ -1890,8 +1890,6 @@ jumbo_source_set("browser") {
"media/capture/cursor_renderer.h", "media/capture/cursor_renderer.h",
"media/capture/desktop_capture_device.cc", "media/capture/desktop_capture_device.cc",
"media/capture/desktop_capture_device.h", "media/capture/desktop_capture_device.h",
"media/capture/fake_webcontent_capture_machine.cc",
"media/capture/fake_webcontent_capture_machine.h",
"media/capture/frame_sink_video_capture_device.cc", "media/capture/frame_sink_video_capture_device.cc",
"media/capture/frame_sink_video_capture_device.h", "media/capture/frame_sink_video_capture_device.h",
"media/capture/web_contents_video_capture_device.cc", "media/capture/web_contents_video_capture_device.cc",
...@@ -1901,14 +1899,10 @@ jumbo_source_set("browser") { ...@@ -1901,14 +1899,10 @@ jumbo_source_set("browser") {
deps += [ "//third_party/webrtc/modules/desktop_capture" ] deps += [ "//third_party/webrtc/modules/desktop_capture" ]
if (use_aura) { if (use_aura) {
sources += [ sources += [
"media/capture/aura_window_capture_machine.cc",
"media/capture/aura_window_capture_machine.h",
"media/capture/aura_window_video_capture_device.cc", "media/capture/aura_window_video_capture_device.cc",
"media/capture/aura_window_video_capture_device.h", "media/capture/aura_window_video_capture_device.h",
"media/capture/cursor_renderer_aura.cc", "media/capture/cursor_renderer_aura.cc",
"media/capture/cursor_renderer_aura.h", "media/capture/cursor_renderer_aura.h",
"media/capture/desktop_capture_device_aura.cc",
"media/capture/desktop_capture_device_aura.h",
] ]
} }
if (is_chromeos) { if (is_chromeos) {
......
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_BROWSER_MEDIA_CAPTURE_AURA_WINDOW_CAPTURE_MACHINE_H_
#define CONTENT_BROWSER_MEDIA_CAPTURE_AURA_WINDOW_CAPTURE_MACHINE_H_
#include <memory>
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "content/browser/media/capture/cursor_renderer_aura.h"
#include "media/capture/content/screen_capture_device_core.h"
#include "services/device/public/mojom/wake_lock.mojom.h"
#include "ui/aura/window.h"
#include "ui/aura/window_observer.h"
#include "ui/base/cursor/cursors_aura.h"
#include "ui/compositor/compositor.h"
#include "ui/compositor/compositor_animation_observer.h"
namespace viz {
class CopyOutputResult;
class ReadbackYUVInterface;
}
namespace content {
// AuraWindowCaptureMachine uses the compositor to capture Aura windows.
//
// It is used for browser window capture on platforms that use Aura (Windows,
// Linux, and Chrome OS) and additionally for desktop capture on Chrome OS.
class AuraWindowCaptureMachine : public media::VideoCaptureMachine,
public aura::WindowObserver,
public ui::ContextFactoryObserver,
public ui::CompositorAnimationObserver {
public:
AuraWindowCaptureMachine();
~AuraWindowCaptureMachine() override;
// VideoCaptureMachine overrides.
void Start(const scoped_refptr<media::ThreadSafeCaptureOracle>& oracle_proxy,
const media::VideoCaptureParams& params,
const base::Callback<void(bool)> callback) override;
void Suspend() override;
void Resume() override;
void Stop(const base::Closure& callback) override;
void MaybeCaptureForRefresh() override;
// Implements aura::WindowObserver.
void OnWindowBoundsChanged(aura::Window* window,
const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds,
ui::PropertyChangeReason reason) override;
void OnWindowDestroying(aura::Window* window) override;
void OnWindowAddedToRootWindow(aura::Window* window) override;
void OnWindowRemovingFromRootWindow(aura::Window* window,
aura::Window* new_root) override;
// ui::CompositorAnimationObserver implementation.
void OnAnimationStep(base::TimeTicks timestamp) override;
void OnCompositingShuttingDown(ui::Compositor* compositor) override;
// Sets the window to use for capture.
void SetWindow(aura::Window* window);
private:
bool InternalStart(
const scoped_refptr<media::ThreadSafeCaptureOracle>& oracle_proxy,
const media::VideoCaptureParams& params);
void InternalSuspend();
void InternalResume();
void InternalStop(const base::Closure& callback);
// Captures a frame. |event_time| is provided by the compositor, or is null
// for refresh requests.
void Capture(base::TimeTicks event_time);
// Update capture size. Must be called on the UI thread.
void UpdateCaptureSize();
using CaptureFrameCallback =
media::ThreadSafeCaptureOracle::CaptureFrameCallback;
// Response callback for cc::Layer::RequestCopyOfOutput().
void DidCopyOutput(scoped_refptr<media::VideoFrame> video_frame,
base::TimeTicks event_time,
base::TimeTicks start_time,
const CaptureFrameCallback& capture_frame_cb,
std::unique_ptr<viz::CopyOutputResult> result);
// A helper which does the real work for DidCopyOutput. Returns true if
// succeeded and |capture_frame_cb| will be run at some future point. Returns
// false on error, and |capture_frame_cb| should be run by the caller (with
// failure status).
bool ProcessCopyOutputResponse(scoped_refptr<media::VideoFrame> video_frame,
base::TimeTicks event_time,
const CaptureFrameCallback& capture_frame_cb,
std::unique_ptr<viz::CopyOutputResult> result);
// ui::ContextFactoryObserver implementation.
void OnLostResources() override;
// Renders the cursor if needed and then delivers the captured frame.
static void CopyOutputFinishedForVideo(
base::WeakPtr<AuraWindowCaptureMachine> machine,
base::TimeTicks event_time,
const CaptureFrameCallback& capture_frame_cb,
scoped_refptr<media::VideoFrame> target,
const gfx::Rect& region_in_frame,
std::unique_ptr<viz::SingleReleaseCallback> release_callback,
bool result);
// The window associated with the desktop.
aura::Window* desktop_window_;
// Whether screen capturing or window capture.
bool screen_capture_;
// Makes all the decisions about which frames to copy, and how.
scoped_refptr<media::ThreadSafeCaptureOracle> oracle_proxy_;
// The capture parameters for this capture.
media::VideoCaptureParams capture_params_;
// YUV readback pipeline.
std::unique_ptr<viz::ReadbackYUVInterface> yuv_readback_pipeline_;
// Renders mouse cursor on frame.
std::unique_ptr<content::CursorRendererAura> cursor_renderer_;
// TODO(jiayl): Remove wake_lock_ when there is an API to keep the
// screen from sleeping for the drive-by web.
device::mojom::WakeLockPtr wake_lock_;
// False while frame capture has been suspended. All other aspects of the
// machine are maintained.
bool frame_capture_active_;
// WeakPtrs are used for the asynchronous capture callbacks passed to external
// modules. They are only valid on the UI thread and become invalidated
// immediately when InternalStop() is called to ensure that no more captured
// frames will be delivered to the client.
base::WeakPtrFactory<AuraWindowCaptureMachine> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(AuraWindowCaptureMachine);
};
} // namespace content
#endif // CONTENT_BROWSER_MEDIA_CAPTURE_AURA_WINDOW_CAPTURE_MACHINE_H_
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/browser/media/capture/desktop_capture_device_aura.h"
#include <utility>
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/timer/timer.h"
#include "content/browser/media/capture/aura_window_capture_machine.h"
#include "content/browser/media/capture/desktop_capture_device_uma_types.h"
#include "content/public/browser/browser_thread.h"
#include "ui/aura/window.h"
namespace content {
namespace {
void SetCaptureSource(AuraWindowCaptureMachine* machine,
const DesktopMediaID& source) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
aura::Window* window = DesktopMediaID::GetAuraWindowById(source);
if (window) {
machine->SetWindow(window);
if (source.type == DesktopMediaID::TYPE_SCREEN) {
if (source.audio_share)
IncrementDesktopCaptureCounter(SCREEN_CAPTURER_CREATED_WITH_AUDIO);
else
IncrementDesktopCaptureCounter(SCREEN_CAPTURER_CREATED_WITHOUT_AUDIO);
}
}
}
} // namespace
DesktopCaptureDeviceAura::DesktopCaptureDeviceAura(
const DesktopMediaID& source) {
AuraWindowCaptureMachine* machine = new AuraWindowCaptureMachine();
core_.reset(new media::ScreenCaptureDeviceCore(base::WrapUnique(machine)));
// |core_| owns |machine| and deletes it on UI thread so passing the raw
// pointer to the UI thread is safe here.
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::BindOnce(&SetCaptureSource, machine, source));
}
DesktopCaptureDeviceAura::~DesktopCaptureDeviceAura() {
DVLOG(2) << "DesktopCaptureDeviceAura@" << this << " destroying.";
}
// static
std::unique_ptr<media::VideoCaptureDevice> DesktopCaptureDeviceAura::Create(
const DesktopMediaID& source) {
if (source.aura_id == DesktopMediaID::kNullId)
return nullptr;
return std::unique_ptr<media::VideoCaptureDevice>(
new DesktopCaptureDeviceAura(source));
}
void DesktopCaptureDeviceAura::AllocateAndStart(
const media::VideoCaptureParams& params,
std::unique_ptr<Client> client) {
DVLOG(1) << "Allocating " << params.requested_format.frame_size.ToString();
core_->AllocateAndStart(params, std::move(client));
}
void DesktopCaptureDeviceAura::RequestRefreshFrame() {
core_->RequestRefreshFrame();
}
void DesktopCaptureDeviceAura::StopAndDeAllocate() {
core_->StopAndDeAllocate();
}
void DesktopCaptureDeviceAura::OnUtilizationReport(int frame_feedback_id,
double utilization) {
core_->OnConsumerReportingUtilization(frame_feedback_id, utilization);
}
} // namespace content
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_BROWSER_MEDIA_CAPTURE_DESKTOP_CAPTURE_DEVICE_AURA_H_
#define CONTENT_BROWSER_MEDIA_CAPTURE_DESKTOP_CAPTURE_DEVICE_AURA_H_
#include <memory>
#include <string>
#include "base/macros.h"
#include "content/common/content_export.h"
#include "content/public/browser/desktop_media_id.h"
#include "media/capture/content/screen_capture_device_core.h"
#include "media/capture/video/video_capture_device.h"
namespace content {
// An implementation of VideoCaptureDevice that mirrors an Aura window.
class CONTENT_EXPORT DesktopCaptureDeviceAura
: public media::VideoCaptureDevice {
public:
// Creates a VideoCaptureDevice for the Aura desktop. If |source| does not
// reference a registered aura window, returns nullptr instead.
static std::unique_ptr<media::VideoCaptureDevice> Create(
const DesktopMediaID& source);
~DesktopCaptureDeviceAura() override;
// VideoCaptureDevice implementation.
void AllocateAndStart(const media::VideoCaptureParams& params,
std::unique_ptr<Client> client) override;
void RequestRefreshFrame() override;
void StopAndDeAllocate() override;
void OnUtilizationReport(int frame_feedback_id, double utilization) override;
private:
explicit DesktopCaptureDeviceAura(const DesktopMediaID& source);
std::unique_ptr<media::ScreenCaptureDeviceCore> core_;
DISALLOW_COPY_AND_ASSIGN(DesktopCaptureDeviceAura);
};
} // namespace content
#endif // CONTENT_BROWSER_MEDIA_CAPTURE_DESKTOP_CAPTURE_DEVICE_AURA_H_
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/browser/media/capture/desktop_capture_device_aura.h"
#include <stddef.h>
#include <stdint.h>
#include <utility>
#include "base/location.h"
#include "base/macros.h"
#include "base/run_loop.h"
#include "base/synchronization/waitable_event.h"
#include "content/browser/compositor/test/test_image_transport_factory.h"
#include "content/public/browser/desktop_media_id.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "media/capture/video_capture_types.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/aura/client/window_parenting_client.h"
#include "ui/aura/test/aura_test_helper.h"
#include "ui/aura/test/test_window_delegate.h"
#include "ui/aura/window.h"
#include "ui/wm/core/default_activation_client.h"
using ::testing::_;
using ::testing::AnyNumber;
using ::testing::AtMost;
using ::testing::DoAll;
using ::testing::Expectation;
using ::testing::InvokeWithoutArgs;
using ::testing::SaveArg;
namespace media {
class VideoFrame;
} // namespace media
namespace content {
namespace {
const int kFrameRate = 30;
class MockDeviceClient : public media::VideoCaptureDevice::Client {
public:
MOCK_METHOD7(OnIncomingCapturedData,
void(const uint8_t* data,
int length,
const media::VideoCaptureFormat& frame_format,
int rotation,
base::TimeTicks reference_time,
base::TimeDelta tiemstamp,
int frame_feedback_id));
MOCK_METHOD6(OnIncomingCapturedGfxBuffer,
void(gfx::GpuMemoryBuffer* buffer,
const media::VideoCaptureFormat& frame_format,
int clockwise_rotation,
base::TimeTicks reference_time,
base::TimeDelta timestamp,
int frame_feedback_id));
MOCK_METHOD0(DoReserveOutputBuffer, void(void));
MOCK_METHOD0(DoOnIncomingCapturedBuffer, void(void));
MOCK_METHOD0(DoOnIncomingCapturedVideoFrame, void(void));
MOCK_METHOD0(DoResurrectLastOutputBuffer, void(void));
MOCK_METHOD2(OnError,
void(const base::Location& from_here,
const std::string& reason));
MOCK_METHOD0(OnStarted, void(void));
// Trampoline methods to workaround GMOCK problems with std::unique_ptr<>.
Buffer ReserveOutputBuffer(const gfx::Size& dimensions,
media::VideoPixelFormat format,
int frame_feedback_id) override {
EXPECT_EQ(media::PIXEL_FORMAT_I420, format);
DoReserveOutputBuffer();
return Buffer();
}
void OnIncomingCapturedBuffer(Buffer buffer,
const media::VideoCaptureFormat& frame_format,
base::TimeTicks reference_time,
base::TimeDelta timestamp) override {
DoOnIncomingCapturedBuffer();
}
void OnIncomingCapturedBufferExt(
Buffer buffer,
const media::VideoCaptureFormat& format,
base::TimeTicks reference_time,
base::TimeDelta timestamp,
gfx::Rect visible_rect,
const media::VideoFrameMetadata& additional_metadata) override {
DoOnIncomingCapturedVideoFrame();
}
Buffer ResurrectLastOutputBuffer(const gfx::Size& dimensions,
media::VideoPixelFormat format,
int frame_feedback_id) override {
EXPECT_EQ(media::PIXEL_FORMAT_I420, format);
DoResurrectLastOutputBuffer();
return Buffer();
}
double GetBufferPoolUtilization() const override { return 0.0; }
};
// Test harness that sets up a minimal environment with necessary stubs.
class DesktopCaptureDeviceAuraTest : public testing::Test {
public:
DesktopCaptureDeviceAuraTest() = default;
~DesktopCaptureDeviceAuraTest() override = default;
protected:
void SetUp() override {
// The ContextFactory must exist before any Compositors are created.
ImageTransportFactory::SetFactory(
std::make_unique<TestImageTransportFactory>());
helper_.reset(new aura::test::AuraTestHelper());
helper_->SetUp(
ImageTransportFactory::GetInstance()->GetContextFactory(),
ImageTransportFactory::GetInstance()->GetContextFactoryPrivate());
new wm::DefaultActivationClient(helper_->root_window());
// We need a window to cover desktop area so that DesktopCaptureDeviceAura
// can use gfx::NativeWindow::GetWindowAtScreenPoint() to locate the
// root window associated with the primary display.
gfx::Rect desktop_bounds = root_window()->bounds();
window_delegate_.reset(new aura::test::TestWindowDelegate());
desktop_window_.reset(new aura::Window(window_delegate_.get()));
desktop_window_->Init(ui::LAYER_TEXTURED);
desktop_window_->SetBounds(desktop_bounds);
aura::client::ParentWindowWithContext(
desktop_window_.get(), root_window(), desktop_bounds);
desktop_window_->Show();
}
void TearDown() override {
helper_->RunAllPendingInMessageLoop();
root_window()->RemoveChild(desktop_window_.get());
desktop_window_.reset();
window_delegate_.reset();
helper_->TearDown();
base::RunLoop().RunUntilIdle();
ImageTransportFactory::Terminate();
}
aura::Window* root_window() { return helper_->root_window(); }
private:
TestBrowserThreadBundle thread_bundle_;
std::unique_ptr<aura::test::AuraTestHelper> helper_;
std::unique_ptr<aura::Window> desktop_window_;
std::unique_ptr<aura::test::TestWindowDelegate> window_delegate_;
DISALLOW_COPY_AND_ASSIGN(DesktopCaptureDeviceAuraTest);
};
TEST_F(DesktopCaptureDeviceAuraTest, StartAndStop) {
std::unique_ptr<media::VideoCaptureDevice> capture_device =
DesktopCaptureDeviceAura::Create(
content::DesktopMediaID::RegisterAuraWindow(
content::DesktopMediaID::TYPE_SCREEN, root_window()));
ASSERT_TRUE(capture_device);
std::unique_ptr<MockDeviceClient> client(new MockDeviceClient());
EXPECT_CALL(*client, OnError(_, _)).Times(0);
// |STARTED| is reported asynchronously, which may not be received if capture
// is stopped immediately.
EXPECT_CALL(*client, OnStarted()).Times(AtMost(1));
media::VideoCaptureParams capture_params;
capture_params.requested_format.frame_size.SetSize(640, 480);
capture_params.requested_format.frame_rate = kFrameRate;
capture_params.requested_format.pixel_format = media::PIXEL_FORMAT_I420;
capture_device->AllocateAndStart(capture_params, std::move(client));
capture_device->StopAndDeAllocate();
}
} // namespace
} // namespace content
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/browser/media/capture/fake_webcontent_capture_machine.h"
#include "base/logging.h"
namespace content {
FakeWebContentCaptureMachine::FakeWebContentCaptureMachine(
bool enable_auto_throttling)
: enable_auto_throttling_(enable_auto_throttling) {
DVLOG(2) << "FakeWebContentCaptureMachine";
}
FakeWebContentCaptureMachine::~FakeWebContentCaptureMachine() {
DVLOG(2) << "FakeWebContentCaptureMachine@" << this << " destroying.";
}
void FakeWebContentCaptureMachine::Start(
const scoped_refptr<media::ThreadSafeCaptureOracle>& oracle_proxy,
const media::VideoCaptureParams& params,
const base::Callback<void(bool)> callback) {
callback.Run(true);
}
void FakeWebContentCaptureMachine::Suspend() {}
void FakeWebContentCaptureMachine::Resume() {}
void FakeWebContentCaptureMachine::Stop(const base::Closure& callback) {}
bool FakeWebContentCaptureMachine::IsAutoThrottlingEnabled() const {
return enable_auto_throttling_;
}
void FakeWebContentCaptureMachine::MaybeCaptureForRefresh() {}
} // namespace content
\ No newline at end of file
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_BROWSER_MEDIA_CAPTURE_FAKE_WEBCONTENT_CAPTURE_MACHINE_H_
#define CONTENT_BROWSER_MEDIA_CAPTURE_FAKE_WEBCONTENT_CAPTURE_MACHINE_H_
#include "base/callback_helpers.h"
#include "content/common/content_export.h"
#include "media/capture/content/screen_capture_device_core.h"
#include "media/capture/content/thread_safe_capture_oracle.h"
#include "media/capture/video_capture_types.h"
namespace content {
// An implementation of VideoCaptureDevice that fakes a desktop capturer.
class CONTENT_EXPORT FakeWebContentCaptureMachine
: public media::VideoCaptureMachine {
public:
FakeWebContentCaptureMachine(bool enable_auto_throttling);
~FakeWebContentCaptureMachine() override;
// VideoCaptureMachine overrides.
void Start(const scoped_refptr<media::ThreadSafeCaptureOracle>& oracle_proxy,
const media::VideoCaptureParams& params,
const base::Callback<void(bool)> callback) override;
void Suspend() override;
void Resume() override;
void Stop(const base::Closure& callback) override;
bool IsAutoThrottlingEnabled() const override;
void MaybeCaptureForRefresh() override;
private:
bool enable_auto_throttling_;
DISALLOW_COPY_AND_ASSIGN(FakeWebContentCaptureMachine);
};
} // namespace content
#endif // CONTENT_BROWSER_MEDIA_CAPTURE_DESKTOP_FAKE_CAPTURE_DEVICE_H_
\ No newline at end of file
...@@ -1957,10 +1957,6 @@ test("content_unittests") { ...@@ -1957,10 +1957,6 @@ test("content_unittests") {
if (is_mac) { if (is_mac) {
sources += [ "../browser/media/capture/cursor_renderer_mac_unittest.mm" ] sources += [ "../browser/media/capture/cursor_renderer_mac_unittest.mm" ]
} }
if (is_chromeos) {
sources +=
[ "../browser/media/capture/desktop_capture_device_aura_unittest.cc" ]
}
} }
if (is_linux) { if (is_linux) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment