Remove ScreenCapturer and WindowCapturer
This change removes ScreenCapturer and WindowCapturer from WebRTC. BUG=webrtc:6513 Review-Url: https://codereview.webrtc.org/2490063002 Cr-Commit-Position: refs/heads/master@{#15033}
This commit is contained in:
@ -8,11 +8,10 @@
|
||||
|
||||
import("../build/webrtc.gni")
|
||||
import("audio_coding/audio_coding.gni")
|
||||
import("desktop_capture/desktop_capture.gni")
|
||||
|
||||
declare_args() {
|
||||
# Desktop capturer is supported only on Windows, OSX and Linux.
|
||||
rtc_desktop_capture_supported = rtc_desktop_capture_supported
|
||||
rtc_desktop_capture_supported = is_win || is_mac || is_linux
|
||||
}
|
||||
|
||||
group("modules") {
|
||||
@ -561,7 +560,6 @@ if (rtc_include_tests) {
|
||||
"desktop_capture/desktop_capturer_differ_wrapper_unittest.cc",
|
||||
"desktop_capture/mouse_cursor_monitor_unittest.cc",
|
||||
"desktop_capture/rgba_color_unittest.cc",
|
||||
"desktop_capture/screen_capturer_differ_wrapper_unittest.cc",
|
||||
"desktop_capture/screen_capturer_helper_unittest.cc",
|
||||
"desktop_capture/screen_capturer_mac_unittest.cc",
|
||||
"desktop_capture/screen_capturer_mock_objects.h",
|
||||
|
||||
@ -8,7 +8,6 @@
|
||||
|
||||
import("//build/config/ui.gni")
|
||||
import("../../build/webrtc.gni")
|
||||
import("desktop_capture.gni")
|
||||
|
||||
use_desktop_capture_differ_sse2 =
|
||||
!is_ios && (current_cpu == "x86" || current_cpu == "x64")
|
||||
@ -72,9 +71,8 @@ if (rtc_include_tests) {
|
||||
sources = [
|
||||
"desktop_frame_generator.cc",
|
||||
"desktop_frame_generator.h",
|
||||
"fake_desktop_capturer.cc",
|
||||
"fake_desktop_capturer.h",
|
||||
"fake_screen_capturer.cc",
|
||||
"fake_screen_capturer.h",
|
||||
"mock_desktop_capturer_callback.h",
|
||||
"screen_capturer_mock_objects.h",
|
||||
]
|
||||
@ -112,8 +110,6 @@ rtc_static_library("desktop_capture") {
|
||||
"mouse_cursor_monitor_mac.mm",
|
||||
"mouse_cursor_monitor_win.cc",
|
||||
"screen_capture_frame_queue.h",
|
||||
"screen_capturer.cc",
|
||||
"screen_capturer.h",
|
||||
"screen_capturer_helper.cc",
|
||||
"screen_capturer_helper.h",
|
||||
"screen_capturer_mac.mm",
|
||||
@ -151,8 +147,6 @@ rtc_static_library("desktop_capture") {
|
||||
"win/screen_capturer_win_magnifier.h",
|
||||
"win/window_capture_utils.cc",
|
||||
"win/window_capture_utils.h",
|
||||
"window_capturer.cc",
|
||||
"window_capturer.h",
|
||||
"window_capturer_mac.mm",
|
||||
"window_capturer_win.cc",
|
||||
]
|
||||
@ -186,8 +180,6 @@ rtc_static_library("desktop_capture") {
|
||||
"desktop_capturer_differ_wrapper.h",
|
||||
"differ_block.cc",
|
||||
"differ_block.h",
|
||||
"screen_capturer_differ_wrapper.cc",
|
||||
"screen_capturer_differ_wrapper.h",
|
||||
]
|
||||
}
|
||||
|
||||
@ -215,10 +207,6 @@ rtc_static_library("desktop_capture") {
|
||||
if (use_desktop_capture_differ_sse2) {
|
||||
deps += [ ":desktop_capture_differ_sse2" ]
|
||||
}
|
||||
|
||||
if (rtc_desktop_capture_supported) {
|
||||
defines = [ "RTC_DESKTOP_CAPTURE_SUPPORTED" ]
|
||||
}
|
||||
}
|
||||
|
||||
if (use_desktop_capture_differ_sse2) {
|
||||
|
||||
@ -21,8 +21,7 @@ CroppingWindowCapturer::CroppingWindowCapturer(
|
||||
callback_(NULL),
|
||||
window_capturer_(DesktopCapturer::CreateRawWindowCapturer(options)),
|
||||
selected_window_(kNullWindowId),
|
||||
excluded_window_(kNullWindowId) {
|
||||
}
|
||||
excluded_window_(kNullWindowId) {}
|
||||
|
||||
CroppingWindowCapturer::~CroppingWindowCapturer() {}
|
||||
|
||||
@ -103,9 +102,9 @@ void CroppingWindowCapturer::OnCaptureResult(
|
||||
|
||||
#if !defined(WEBRTC_WIN)
|
||||
// static
|
||||
WindowCapturer*
|
||||
CroppingWindowCapturer::Create(const DesktopCaptureOptions& options) {
|
||||
return WindowCapturer::Create(options);
|
||||
DesktopCapturer* CroppingWindowCapturer::Create(
|
||||
const DesktopCaptureOptions& options) {
|
||||
return DesktopCapturer::CreateWindowCapturer(options).release();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@ -13,19 +13,18 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "webrtc/modules/desktop_capture/desktop_capturer.h"
|
||||
#include "webrtc/modules/desktop_capture/desktop_capture_options.h"
|
||||
#include "webrtc/modules/desktop_capture/screen_capturer.h"
|
||||
#include "webrtc/modules/desktop_capture/window_capturer.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
// WindowCapturer implementation that uses a screen capturer to capture the
|
||||
// whole screen and crops the video frame to the window area when the captured
|
||||
// window is on top.
|
||||
class CroppingWindowCapturer : public WindowCapturer,
|
||||
class CroppingWindowCapturer : public DesktopCapturer,
|
||||
public DesktopCapturer::Callback {
|
||||
public:
|
||||
static WindowCapturer* Create(const DesktopCaptureOptions& options);
|
||||
static DesktopCapturer* Create(const DesktopCaptureOptions& options);
|
||||
~CroppingWindowCapturer() override;
|
||||
|
||||
// DesktopCapturer implementation.
|
||||
|
||||
@ -210,8 +210,8 @@ DesktopRect CroppingWindowCapturerWin::GetWindowRectInVirtualScreen() {
|
||||
} // namespace
|
||||
|
||||
// static
|
||||
WindowCapturer*
|
||||
CroppingWindowCapturer::Create(const DesktopCaptureOptions& options) {
|
||||
DesktopCapturer* CroppingWindowCapturer::Create(
|
||||
const DesktopCaptureOptions& options) {
|
||||
return new CroppingWindowCapturerWin(options);
|
||||
}
|
||||
|
||||
|
||||
@ -11,14 +11,13 @@
|
||||
#include <memory>
|
||||
|
||||
#include "webrtc/modules/desktop_capture/desktop_and_cursor_composer.h"
|
||||
|
||||
#include "webrtc/test/gtest.h"
|
||||
#include "webrtc/modules/desktop_capture/desktop_capturer.h"
|
||||
#include "webrtc/modules/desktop_capture/desktop_capture_options.h"
|
||||
#include "webrtc/modules/desktop_capture/desktop_frame.h"
|
||||
#include "webrtc/modules/desktop_capture/mouse_cursor.h"
|
||||
#include "webrtc/modules/desktop_capture/shared_desktop_frame.h"
|
||||
#include "webrtc/modules/desktop_capture/window_capturer.h"
|
||||
#include "webrtc/system_wrappers/include/logging.h"
|
||||
#include "webrtc/test/gtest.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
|
||||
@ -1,11 +0,0 @@
|
||||
# Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
|
||||
#
|
||||
# Use of this source code is governed by a BSD-style license
|
||||
# that can be found in the LICENSE file in the root of the source
|
||||
# tree. An additional intellectual property rights grant can be found
|
||||
# in the file PATENTS. All contributing project authors may
|
||||
# be found in the AUTHORS file in the root of the source tree.
|
||||
|
||||
import("../../build/webrtc.gni")
|
||||
|
||||
rtc_desktop_capture_supported = is_win || is_mac || is_linux
|
||||
@ -59,7 +59,6 @@
|
||||
'mouse_cursor_monitor_mac.mm',
|
||||
'mouse_cursor_monitor_win.cc',
|
||||
'screen_capture_frame_queue.h',
|
||||
'screen_capturer.h',
|
||||
'screen_capturer_helper.cc',
|
||||
'screen_capturer_helper.h',
|
||||
'screen_capturer_mac.mm',
|
||||
@ -99,7 +98,6 @@
|
||||
'win/screen_capturer_win_magnifier.h',
|
||||
'win/window_capture_utils.cc',
|
||||
'win/window_capture_utils.h',
|
||||
'window_capturer.h',
|
||||
'window_capturer_mac.mm',
|
||||
'window_capturer_win.cc',
|
||||
],
|
||||
@ -145,8 +143,6 @@
|
||||
'desktop_capturer_differ_wrapper.h',
|
||||
'differ_block.cc',
|
||||
'differ_block.h',
|
||||
'screen_capturer_differ_wrapper.cc',
|
||||
'screen_capturer_differ_wrapper.h',
|
||||
],
|
||||
}],
|
||||
['OS=="mac"', {
|
||||
|
||||
@ -34,11 +34,6 @@ bool DesktopCapturer::FocusOnSelectedSource() {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Some platforms, such as ChromeOS, have their DesktopCapturer implementations
|
||||
// in Chromium. So even we do not have CreateRawWindowCapturer() or
|
||||
// CreateRawScreenCapturer() implemented in WebRTC, we still need to build other
|
||||
// DesktopCapturer components when RTC_DESKTOP_CAPTURE_SUPPORTED is not defined.
|
||||
#if defined(RTC_DESKTOP_CAPTURE_SUPPORTED)
|
||||
// static
|
||||
std::unique_ptr<DesktopCapturer> DesktopCapturer::CreateWindowCapturer(
|
||||
const DesktopCaptureOptions& options) {
|
||||
@ -60,6 +55,5 @@ std::unique_ptr<DesktopCapturer> DesktopCapturer::CreateScreenCapturer(
|
||||
|
||||
return capturer;
|
||||
}
|
||||
#endif // defined(RTC_DESKTOP_CAPTURE_SUPPORTED)
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
#include "webrtc/modules/desktop_capture/desktop_geometry.h"
|
||||
#include "webrtc/modules/desktop_capture/desktop_region.h"
|
||||
#include "webrtc/modules/desktop_capture/differ_block.h"
|
||||
#include "webrtc/modules/desktop_capture/fake_screen_capturer.h"
|
||||
#include "webrtc/modules/desktop_capture/fake_desktop_capturer.h"
|
||||
#include "webrtc/modules/desktop_capture/mock_desktop_capturer_callback.h"
|
||||
#include "webrtc/system_wrappers/include/cpu_features_wrapper.h"
|
||||
#include "webrtc/test/gtest.h"
|
||||
@ -159,7 +159,7 @@ void ExecuteDifferWrapperTest(bool with_hints,
|
||||
BlackWhiteDesktopFramePainter frame_painter;
|
||||
PainterDesktopFrameGenerator frame_generator;
|
||||
frame_generator.set_desktop_frame_painter(&frame_painter);
|
||||
std::unique_ptr<FakeDesktopCapturer<>> fake(new FakeDesktopCapturer<>());
|
||||
std::unique_ptr<FakeDesktopCapturer> fake(new FakeDesktopCapturer());
|
||||
fake->set_frame_generator(&frame_generator);
|
||||
DesktopCapturerDifferWrapper capturer(std::move(fake));
|
||||
MockDesktopCapturerCallback callback;
|
||||
|
||||
70
webrtc/modules/desktop_capture/fake_desktop_capturer.cc
Normal file
70
webrtc/modules/desktop_capture/fake_desktop_capturer.cc
Normal file
@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "webrtc/modules/desktop_capture/fake_desktop_capturer.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
FakeDesktopCapturer::FakeDesktopCapturer()
|
||||
: callback_(nullptr),
|
||||
result_(DesktopCapturer::Result::SUCCESS),
|
||||
generator_(nullptr) {}
|
||||
|
||||
FakeDesktopCapturer::~FakeDesktopCapturer() = default;
|
||||
|
||||
void FakeDesktopCapturer::set_result(DesktopCapturer::Result result) {
|
||||
result_ = result;
|
||||
}
|
||||
|
||||
// Uses the |generator| provided as DesktopFrameGenerator, FakeDesktopCapturer
|
||||
// does
|
||||
// not take the ownership of |generator|.
|
||||
void FakeDesktopCapturer::set_frame_generator(
|
||||
DesktopFrameGenerator* generator) {
|
||||
generator_ = generator;
|
||||
}
|
||||
|
||||
void FakeDesktopCapturer::Start(DesktopCapturer::Callback* callback) {
|
||||
callback_ = callback;
|
||||
}
|
||||
|
||||
void FakeDesktopCapturer::CaptureFrame() {
|
||||
if (generator_) {
|
||||
std::unique_ptr<DesktopFrame> frame(
|
||||
generator_->GetNextFrame(shared_memory_factory_.get()));
|
||||
if (frame) {
|
||||
callback_->OnCaptureResult(result_, std::move(frame));
|
||||
} else {
|
||||
callback_->OnCaptureResult(DesktopCapturer::Result::ERROR_TEMPORARY,
|
||||
nullptr);
|
||||
}
|
||||
return;
|
||||
}
|
||||
callback_->OnCaptureResult(DesktopCapturer::Result::ERROR_PERMANENT, nullptr);
|
||||
}
|
||||
|
||||
void FakeDesktopCapturer::SetSharedMemoryFactory(
|
||||
std::unique_ptr<SharedMemoryFactory> shared_memory_factory) {
|
||||
shared_memory_factory_ = std::move(shared_memory_factory);
|
||||
}
|
||||
|
||||
bool FakeDesktopCapturer::GetSourceList(DesktopCapturer::SourceList* sources) {
|
||||
sources->push_back({kWindowId, "A-Fake-DesktopCapturer-Window"});
|
||||
sources->push_back({kScreenId});
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FakeDesktopCapturer::SelectSource(DesktopCapturer::SourceId id) {
|
||||
return id == kWindowId || id == kScreenId || id == kFullDesktopScreenId;
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
@ -12,12 +12,10 @@
|
||||
#define WEBRTC_MODULES_DESKTOP_CAPTURE_FAKE_DESKTOP_CAPTURER_H_
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#include "webrtc/modules/desktop_capture/desktop_capturer.h"
|
||||
#include "webrtc/modules/desktop_capture/desktop_capture_types.h"
|
||||
#include "webrtc/modules/desktop_capture/desktop_frame_generator.h"
|
||||
#include "webrtc/modules/desktop_capture/shared_desktop_frame.h"
|
||||
#include "webrtc/modules/desktop_capture/shared_memory.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -33,66 +31,25 @@ namespace webrtc {
|
||||
// Double buffering is guaranteed by the FrameGenerator. FrameGenerator
|
||||
// implements in desktop_frame_generator.h guarantee double buffering, they
|
||||
// creates a new instance of DesktopFrame each time.
|
||||
//
|
||||
// T must be DesktopCapturer or its derived interfaces.
|
||||
//
|
||||
// TODO(zijiehe): Remove template T once we merge ScreenCapturer and
|
||||
// WindowCapturer.
|
||||
template <typename T = DesktopCapturer>
|
||||
class FakeDesktopCapturer : public T {
|
||||
class FakeDesktopCapturer : public DesktopCapturer {
|
||||
public:
|
||||
FakeDesktopCapturer()
|
||||
: callback_(nullptr),
|
||||
result_(DesktopCapturer::Result::SUCCESS),
|
||||
generator_(nullptr) {}
|
||||
|
||||
~FakeDesktopCapturer() override {}
|
||||
FakeDesktopCapturer();
|
||||
~FakeDesktopCapturer() override;
|
||||
|
||||
// Decides the result which will be returned in next Capture() callback.
|
||||
void set_result(DesktopCapturer::Result result) { result_ = result; }
|
||||
void set_result(DesktopCapturer::Result result);
|
||||
|
||||
// Uses the |generator| provided as DesktopFrameGenerator, FakeDesktopCapturer
|
||||
// does
|
||||
// not take the ownership of |generator|.
|
||||
void set_frame_generator(DesktopFrameGenerator* generator) {
|
||||
generator_ = generator;
|
||||
}
|
||||
// does not take the ownership of |generator|.
|
||||
void set_frame_generator(DesktopFrameGenerator* generator);
|
||||
|
||||
// DesktopCapturer interface
|
||||
void Start(DesktopCapturer::Callback* callback) override {
|
||||
callback_ = callback;
|
||||
}
|
||||
|
||||
void CaptureFrame() override {
|
||||
if (generator_) {
|
||||
std::unique_ptr<DesktopFrame> frame(
|
||||
generator_->GetNextFrame(shared_memory_factory_.get()));
|
||||
if (frame) {
|
||||
callback_->OnCaptureResult(result_, std::move(frame));
|
||||
} else {
|
||||
callback_->OnCaptureResult(DesktopCapturer::Result::ERROR_TEMPORARY,
|
||||
nullptr);
|
||||
}
|
||||
return;
|
||||
}
|
||||
callback_->OnCaptureResult(DesktopCapturer::Result::ERROR_PERMANENT,
|
||||
nullptr);
|
||||
}
|
||||
|
||||
void Start(DesktopCapturer::Callback* callback) override;
|
||||
void CaptureFrame() override;
|
||||
void SetSharedMemoryFactory(
|
||||
std::unique_ptr<SharedMemoryFactory> shared_memory_factory) override {
|
||||
shared_memory_factory_ = std::move(shared_memory_factory);
|
||||
}
|
||||
|
||||
bool GetSourceList(DesktopCapturer::SourceList* sources) override {
|
||||
sources->push_back({kWindowId, "A-Fake-DesktopCapturer-Window"});
|
||||
sources->push_back({kScreenId});
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SelectSource(DesktopCapturer::SourceId id) override {
|
||||
return id == kWindowId || id == kScreenId || id == kFullDesktopScreenId;
|
||||
}
|
||||
std::unique_ptr<SharedMemoryFactory> shared_memory_factory) override;
|
||||
bool GetSourceList(DesktopCapturer::SourceList* sources) override;
|
||||
bool SelectSource(DesktopCapturer::SourceId id) override;
|
||||
|
||||
private:
|
||||
static constexpr DesktopCapturer::SourceId kWindowId = 1378277495;
|
||||
|
||||
@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "webrtc/modules/desktop_capture/fake_screen_capturer.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
FakeScreenCapturer::FakeScreenCapturer()
|
||||
: FakeDesktopCapturer(),
|
||||
// A random number for the fake screen.
|
||||
id_(1378277498) {}
|
||||
FakeScreenCapturer::~FakeScreenCapturer() {}
|
||||
|
||||
bool FakeScreenCapturer::GetScreenList(ScreenList* list) {
|
||||
list->push_back(Screen{id_});
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FakeScreenCapturer::SelectScreen(ScreenId id) {
|
||||
return id == kFullDesktopScreenId || id == id_;
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
@ -1,35 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef WEBRTC_MODULES_DESKTOP_CAPTURE_FAKE_SCREEN_CAPTURER_H_
|
||||
#define WEBRTC_MODULES_DESKTOP_CAPTURE_FAKE_SCREEN_CAPTURER_H_
|
||||
|
||||
#include "webrtc/modules/desktop_capture/fake_desktop_capturer.h"
|
||||
#include "webrtc/modules/desktop_capture/screen_capturer.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class FakeScreenCapturer : public FakeDesktopCapturer<ScreenCapturer> {
|
||||
public:
|
||||
FakeScreenCapturer();
|
||||
~FakeScreenCapturer() override;
|
||||
|
||||
// ScreenCapturer interface.
|
||||
bool GetScreenList(ScreenList* list) override;
|
||||
bool SelectScreen(ScreenId id) override;
|
||||
|
||||
private:
|
||||
// A random ScreenId.
|
||||
const ScreenId id_;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // WEBRTC_MODULES_DESKTOP_CAPTURE_FAKE_SCREEN_CAPTURER_H_
|
||||
@ -11,13 +11,12 @@
|
||||
#include <memory>
|
||||
|
||||
#include "webrtc/modules/desktop_capture/mouse_cursor_monitor.h"
|
||||
|
||||
#include "webrtc/test/gtest.h"
|
||||
#include "webrtc/modules/desktop_capture/desktop_capturer.h"
|
||||
#include "webrtc/modules/desktop_capture/desktop_capture_options.h"
|
||||
#include "webrtc/modules/desktop_capture/desktop_frame.h"
|
||||
#include "webrtc/modules/desktop_capture/mouse_cursor.h"
|
||||
#include "webrtc/modules/desktop_capture/window_capturer.h"
|
||||
#include "webrtc/system_wrappers/include/logging.h"
|
||||
#include "webrtc/test/gtest.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
|
||||
@ -1,53 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "webrtc/modules/desktop_capture/screen_capturer.h"
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
ScreenCapturer::~ScreenCapturer() = default;
|
||||
|
||||
bool ScreenCapturer::GetScreenList(ScreenList* screens) {
|
||||
SourceList sources;
|
||||
if (!GetSourceList(&sources)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (const Source& source : sources) {
|
||||
screens->push_back({source.id});
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ScreenCapturer::SelectScreen(ScreenId id) {
|
||||
return SelectSource(id);
|
||||
}
|
||||
|
||||
bool ScreenCapturer::GetSourceList(SourceList* sources) {
|
||||
ScreenList screens;
|
||||
if (!GetScreenList(&screens)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (const Screen& screen : screens) {
|
||||
sources->push_back({screen.id});
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ScreenCapturer::SelectSource(SourceId id) {
|
||||
return SelectScreen(id);
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
@ -1,75 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef WEBRTC_MODULES_DESKTOP_CAPTURE_SCREEN_CAPTURER_H_
|
||||
#define WEBRTC_MODULES_DESKTOP_CAPTURE_SCREEN_CAPTURER_H_
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/modules/desktop_capture/desktop_capture_types.h"
|
||||
#include "webrtc/modules/desktop_capture/desktop_capturer.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class DesktopCaptureOptions;
|
||||
|
||||
// TODO(zijiehe): Remove this class.
|
||||
// Class used to capture video frames asynchronously.
|
||||
//
|
||||
// The full capture sequence is as follows:
|
||||
//
|
||||
// (1) Start
|
||||
// This is when pre-capture steps are executed, such as flagging the
|
||||
// display to prevent it from sleeping during a session.
|
||||
//
|
||||
// (2) CaptureFrame
|
||||
// This is where the bits for the invalid rects are packaged up and sent
|
||||
// to the encoder.
|
||||
// A screen capture is performed if needed. For example, Windows requires
|
||||
// a capture to calculate the diff from the previous screen, whereas the
|
||||
// Mac version does not.
|
||||
//
|
||||
// Implementation has to ensure the following guarantees:
|
||||
// 1. Double buffering
|
||||
// Since data can be read while another capture action is happening.
|
||||
class ScreenCapturer : public DesktopCapturer {
|
||||
public:
|
||||
// Use a struct to represent a screen although it has only an id for now,
|
||||
// because we may want to add more fields (e.g. description) in the future.
|
||||
struct Screen {
|
||||
ScreenId id;
|
||||
};
|
||||
typedef std::vector<Screen> ScreenList;
|
||||
|
||||
~ScreenCapturer() override;
|
||||
|
||||
// Creates a platform-specific capturer.
|
||||
static ScreenCapturer* Create(const DesktopCaptureOptions& options);
|
||||
|
||||
// Deprecated, use GetSourceList().
|
||||
// Get the list of screens (not containing kFullDesktopScreenId). Returns
|
||||
// false in case of a failure.
|
||||
virtual bool GetScreenList(ScreenList* screens);
|
||||
|
||||
// Deprecated, use SelectSource().
|
||||
// Select the screen to be captured. Returns false in case of a failure (e.g.
|
||||
// if there is no screen with the specified id). If this is never called, the
|
||||
// full desktop is captured.
|
||||
virtual bool SelectScreen(ScreenId id);
|
||||
|
||||
// DesktopCapturer interfaces.
|
||||
bool GetSourceList(SourceList* sources) override;
|
||||
bool SelectSource(SourceId id) override;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // WEBRTC_MODULES_DESKTOP_CAPTURE_SCREEN_CAPTURER_H_
|
||||
@ -1,216 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "webrtc/modules/desktop_capture/screen_capturer_differ_wrapper.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <utility>
|
||||
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/base/timeutils.h"
|
||||
#include "webrtc/modules/desktop_capture/desktop_geometry.h"
|
||||
#include "webrtc/modules/desktop_capture/differ_block.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
namespace {
|
||||
|
||||
// Returns true if (0, 0) - (|width|, |height|) vector in |old_buffer| and
|
||||
// |new_buffer| are equal. |width| should be less than 32
|
||||
// (defined by kBlockSize), otherwise BlockDifference() should be used.
|
||||
bool PartialBlockDifference(const uint8_t* old_buffer,
|
||||
const uint8_t* new_buffer,
|
||||
int width,
|
||||
int height,
|
||||
int stride) {
|
||||
RTC_DCHECK_LT(width, kBlockSize);
|
||||
const int width_bytes = width * DesktopFrame::kBytesPerPixel;
|
||||
for (int i = 0; i < height; i++) {
|
||||
if (memcmp(old_buffer, new_buffer, width_bytes) != 0) {
|
||||
return true;
|
||||
}
|
||||
old_buffer += stride;
|
||||
new_buffer += stride;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Compares columns in the range of [|left|, |right|), in a row in the
|
||||
// range of [|top|, |top| + |height|), starts from |old_buffer| and
|
||||
// |new_buffer|, and outputs updated regions into |output|. |stride| is the
|
||||
// DesktopFrame::stride().
|
||||
void CompareRow(const uint8_t* old_buffer,
|
||||
const uint8_t* new_buffer,
|
||||
const int left,
|
||||
const int right,
|
||||
const int top,
|
||||
const int bottom,
|
||||
const int stride,
|
||||
DesktopRegion* const output) {
|
||||
const int block_x_offset = kBlockSize * DesktopFrame::kBytesPerPixel;
|
||||
const int width = right - left;
|
||||
const int height = bottom - top;
|
||||
const int block_count = (width - 1) / kBlockSize;
|
||||
const int last_block_width = width - block_count * kBlockSize;
|
||||
RTC_DCHECK(last_block_width <= kBlockSize && last_block_width > 0);
|
||||
|
||||
// The first block-column in a continuous dirty area in current block-row.
|
||||
int first_dirty_x_block = -1;
|
||||
|
||||
// We always need to add dirty area into |output| in the last block, so handle
|
||||
// it separatedly.
|
||||
for (int x = 0; x < block_count; x++) {
|
||||
if (BlockDifference(old_buffer, new_buffer, height, stride)) {
|
||||
if (first_dirty_x_block == -1) {
|
||||
// This is the first dirty block in a continuous dirty area.
|
||||
first_dirty_x_block = x;
|
||||
}
|
||||
} else if (first_dirty_x_block != -1) {
|
||||
// The block on the left is the last dirty block in a continuous
|
||||
// dirty area.
|
||||
output->AddRect(DesktopRect::MakeLTRB(
|
||||
first_dirty_x_block * kBlockSize + left, top,
|
||||
x * kBlockSize + left, bottom));
|
||||
first_dirty_x_block = -1;
|
||||
}
|
||||
old_buffer += block_x_offset;
|
||||
new_buffer += block_x_offset;
|
||||
}
|
||||
|
||||
bool last_block_diff;
|
||||
if (last_block_width < kBlockSize) {
|
||||
// The last one is a partial vector.
|
||||
last_block_diff = PartialBlockDifference(
|
||||
old_buffer, new_buffer, last_block_width, height, stride);
|
||||
} else {
|
||||
last_block_diff =
|
||||
BlockDifference(old_buffer, new_buffer, height, stride);
|
||||
}
|
||||
if (last_block_diff) {
|
||||
if (first_dirty_x_block == -1) {
|
||||
first_dirty_x_block = block_count;
|
||||
}
|
||||
output->AddRect(
|
||||
DesktopRect::MakeLTRB(first_dirty_x_block * kBlockSize + left,
|
||||
top, right, bottom));
|
||||
} else if (first_dirty_x_block != -1) {
|
||||
output->AddRect(DesktopRect::MakeLTRB(
|
||||
first_dirty_x_block * kBlockSize + left, top,
|
||||
block_count * kBlockSize + left, bottom));
|
||||
}
|
||||
}
|
||||
|
||||
// Compares |rect| area in |old_frame| and |new_frame|, and outputs dirty
|
||||
// regions into |output|.
|
||||
void CompareFrames(const DesktopFrame& old_frame,
|
||||
const DesktopFrame& new_frame,
|
||||
DesktopRect rect,
|
||||
DesktopRegion* const output) {
|
||||
RTC_DCHECK(old_frame.size().equals(new_frame.size()));
|
||||
RTC_DCHECK_EQ(old_frame.stride(), new_frame.stride());
|
||||
rect.IntersectWith(DesktopRect::MakeSize(old_frame.size()));
|
||||
|
||||
const int y_block_count = (rect.height() - 1) / kBlockSize;
|
||||
const int last_y_block_height = rect.height() - y_block_count * kBlockSize;
|
||||
// Offset from the start of one block-row to the next.
|
||||
const int block_y_stride = old_frame.stride() * kBlockSize;
|
||||
const uint8_t* prev_block_row_start =
|
||||
old_frame.GetFrameDataAtPos(rect.top_left());
|
||||
const uint8_t* curr_block_row_start =
|
||||
new_frame.GetFrameDataAtPos(rect.top_left());
|
||||
|
||||
int top = rect.top();
|
||||
// The last row may have a different height, so we handle it separately.
|
||||
for (int y = 0; y < y_block_count; y++) {
|
||||
CompareRow(prev_block_row_start, curr_block_row_start, rect.left(),
|
||||
rect.right(), top, top + kBlockSize,
|
||||
old_frame.stride(), output);
|
||||
top += kBlockSize;
|
||||
prev_block_row_start += block_y_stride;
|
||||
curr_block_row_start += block_y_stride;
|
||||
}
|
||||
CompareRow(prev_block_row_start, curr_block_row_start, rect.left(),
|
||||
rect.right(), top, top + last_y_block_height,
|
||||
old_frame.stride(), output);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
ScreenCapturerDifferWrapper::ScreenCapturerDifferWrapper(
|
||||
std::unique_ptr<ScreenCapturer> base_capturer)
|
||||
: base_capturer_(std::move(base_capturer)) {
|
||||
RTC_DCHECK(base_capturer_);
|
||||
}
|
||||
|
||||
ScreenCapturerDifferWrapper::~ScreenCapturerDifferWrapper() {}
|
||||
|
||||
void ScreenCapturerDifferWrapper::Start(DesktopCapturer::Callback* callback) {
|
||||
callback_ = callback;
|
||||
base_capturer_->Start(this);
|
||||
}
|
||||
|
||||
void ScreenCapturerDifferWrapper::SetSharedMemoryFactory(
|
||||
std::unique_ptr<SharedMemoryFactory> shared_memory_factory) {
|
||||
base_capturer_->SetSharedMemoryFactory(std::move(shared_memory_factory));
|
||||
}
|
||||
|
||||
void ScreenCapturerDifferWrapper::CaptureFrame() {
|
||||
base_capturer_->CaptureFrame();
|
||||
}
|
||||
|
||||
bool ScreenCapturerDifferWrapper::GetScreenList(ScreenList* screens) {
|
||||
return base_capturer_->GetScreenList(screens);
|
||||
}
|
||||
|
||||
bool ScreenCapturerDifferWrapper::SelectScreen(ScreenId id) {
|
||||
return base_capturer_->SelectScreen(id);
|
||||
}
|
||||
|
||||
void ScreenCapturerDifferWrapper::OnCaptureResult(
|
||||
Result result,
|
||||
std::unique_ptr<DesktopFrame> input_frame) {
|
||||
int64_t start_time_nanos = rtc::TimeNanos();
|
||||
if (!input_frame) {
|
||||
callback_->OnCaptureResult(result, nullptr);
|
||||
return;
|
||||
}
|
||||
RTC_DCHECK(result == Result::SUCCESS);
|
||||
|
||||
std::unique_ptr<SharedDesktopFrame> frame =
|
||||
SharedDesktopFrame::Wrap(std::move(input_frame));
|
||||
if (last_frame_ &&
|
||||
(last_frame_->size().width() != frame->size().width() ||
|
||||
last_frame_->size().height() != frame->size().height() ||
|
||||
last_frame_->stride() != frame->stride())) {
|
||||
last_frame_.reset();
|
||||
}
|
||||
|
||||
if (last_frame_) {
|
||||
DesktopRegion hints;
|
||||
hints.Swap(frame->GetUnderlyingFrame()->mutable_updated_region());
|
||||
for (DesktopRegion::Iterator it(hints); !it.IsAtEnd(); it.Advance()) {
|
||||
CompareFrames(*last_frame_, *frame, it.rect(),
|
||||
frame->mutable_updated_region());
|
||||
}
|
||||
} else {
|
||||
frame->mutable_updated_region()->SetRect(
|
||||
DesktopRect::MakeSize(frame->size()));
|
||||
}
|
||||
last_frame_ = frame->Share();
|
||||
|
||||
frame->set_capture_time_ms(frame->GetUnderlyingFrame()->capture_time_ms() +
|
||||
(rtc::TimeNanos() - start_time_nanos) /
|
||||
rtc::kNumNanosecsPerMillisec);
|
||||
callback_->OnCaptureResult(result, std::move(frame));
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
@ -1,59 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef WEBRTC_MODULES_DESKTOP_CAPTURE_SCREEN_CAPTURER_DIFFER_WRAPPER_H_
|
||||
#define WEBRTC_MODULES_DESKTOP_CAPTURE_SCREEN_CAPTURER_DIFFER_WRAPPER_H_
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "webrtc/modules/desktop_capture/screen_capturer.h"
|
||||
#include "webrtc/modules/desktop_capture/shared_desktop_frame.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
// TODO(zijiehe): Remove, use DesktopCapturerDifferWrapper.
|
||||
// ScreenCapturer wrapper that calculates updated_region() by comparing frames
|
||||
// content. This class always expects the underlying ScreenCapturer
|
||||
// implementation returns a superset of updated regions in DestkopFrame. If a
|
||||
// ScreenCapturer implementation does not know the updated region, it should
|
||||
// set updated_region() to full frame.
|
||||
//
|
||||
// This class marks entire frame as updated if the frame size or frame stride
|
||||
// has been changed.
|
||||
class ScreenCapturerDifferWrapper : public ScreenCapturer,
|
||||
public DesktopCapturer::Callback {
|
||||
public:
|
||||
// Creates a ScreenCapturerDifferWrapper with a ScreenCapturer implementation,
|
||||
// and takes its ownership.
|
||||
explicit ScreenCapturerDifferWrapper(
|
||||
std::unique_ptr<ScreenCapturer> base_capturer);
|
||||
~ScreenCapturerDifferWrapper() override;
|
||||
|
||||
// ScreenCapturer interface.
|
||||
void Start(DesktopCapturer::Callback* callback) override;
|
||||
void SetSharedMemoryFactory(
|
||||
std::unique_ptr<SharedMemoryFactory> shared_memory_factory) override;
|
||||
void CaptureFrame() override;
|
||||
bool GetScreenList(ScreenList* screens) override;
|
||||
bool SelectScreen(ScreenId id) override;
|
||||
|
||||
private:
|
||||
// DesktopCapturer::Callback interface.
|
||||
void OnCaptureResult(Result result,
|
||||
std::unique_ptr<DesktopFrame> frame) override;
|
||||
|
||||
const std::unique_ptr<ScreenCapturer> base_capturer_;
|
||||
DesktopCapturer::Callback* callback_;
|
||||
std::unique_ptr<SharedDesktopFrame> last_frame_;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // WEBRTC_MODULES_DESKTOP_CAPTURE_SCREEN_CAPTURER_DIFFER_WRAPPER_H_
|
||||
@ -1,291 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "webrtc/modules/desktop_capture/screen_capturer_differ_wrapper.h"
|
||||
|
||||
#include <initializer_list>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/base/random.h"
|
||||
#include "webrtc/base/timeutils.h"
|
||||
#include "webrtc/modules/desktop_capture/desktop_geometry.h"
|
||||
#include "webrtc/modules/desktop_capture/desktop_region.h"
|
||||
#include "webrtc/modules/desktop_capture/differ_block.h"
|
||||
#include "webrtc/modules/desktop_capture/fake_screen_capturer.h"
|
||||
#include "webrtc/modules/desktop_capture/screen_capturer_mock_objects.h"
|
||||
#include "webrtc/system_wrappers/include/cpu_features_wrapper.h"
|
||||
#include "webrtc/test/gtest.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
namespace {
|
||||
|
||||
// Compares and asserts |frame|.updated_region() equals to |rects|. This
|
||||
// function does not care about the order of the |rects| and it does not expect
|
||||
// DesktopRegion to return an exact area for each rectangle in |rects|.
|
||||
template <template <typename, typename...> class T = std::initializer_list,
|
||||
typename... Rect>
|
||||
void AssertUpdatedRegionIs(const DesktopFrame& frame,
|
||||
const T<DesktopRect, Rect...>& rects) {
|
||||
DesktopRegion region;
|
||||
for (const auto& rect : rects) {
|
||||
region.AddRect(rect);
|
||||
}
|
||||
ASSERT_TRUE(frame.updated_region().Equals(region));
|
||||
}
|
||||
|
||||
// Compares and asserts |frame|.updated_region() covers all rectangles in
|
||||
// |rects|, but does not cover areas other than a kBlockSize expansion. This
|
||||
// function does not care about the order of the |rects|, and it does not expect
|
||||
// DesktopRegion to return an exact area of each rectangle in |rects|.
|
||||
template <template <typename, typename...> class T = std::initializer_list,
|
||||
typename... Rect>
|
||||
void AssertUpdatedRegionCovers(const DesktopFrame& frame,
|
||||
const T<DesktopRect, Rect...>& rects) {
|
||||
DesktopRegion region;
|
||||
for (const auto& rect : rects) {
|
||||
region.AddRect(rect);
|
||||
}
|
||||
|
||||
// Intersect of |rects| and |frame|.updated_region() should be |rects|. i.e.
|
||||
// |frame|.updated_region() should be a superset of |rects|.
|
||||
DesktopRegion intersect(region);
|
||||
intersect.IntersectWith(frame.updated_region());
|
||||
ASSERT_TRUE(region.Equals(intersect));
|
||||
|
||||
// Difference between |rects| and |frame|.updated_region() should not cover
|
||||
// areas which have larger than twice of kBlockSize width and height.
|
||||
//
|
||||
// Explanation of the 'twice' of kBlockSize (indeed kBlockSize * 2 - 2) is
|
||||
// following,
|
||||
// (Each block in the following grid is a 8 x 8 pixels area. X means the real
|
||||
// updated area, m means the updated area marked by
|
||||
// ScreenCapturerDifferWrapper.)
|
||||
// +---+---+---+---+---+---+---+---+
|
||||
// | X | m | m | m | m | m | m | m |
|
||||
// +---+---+---+---+---+---+---+---+
|
||||
// | m | m | m | m | m | m | m | m |
|
||||
// +---+---+---+---+---+---+---+---+
|
||||
// | m | m | m | m | m | m | m | m |
|
||||
// +---+---+---+---+---+---+---+---+
|
||||
// | m | m | m | m | m | m | m | X |
|
||||
// +---+---+---+---+---+---+---+---+
|
||||
// The top left [0, 0] - [8, 8] and right bottom [56, 24] - [64, 32] blocks of
|
||||
// this area are updated. But since ScreenCapturerDifferWrapper compares
|
||||
// 32 x 32 blocks by default, this entire area is marked as updated. So the
|
||||
// [8, 8] - [56, 32] is expected to be covered in the difference.
|
||||
//
|
||||
// But if [0, 0] - [8, 8] and [64, 24] - [72, 32] blocks are updated,
|
||||
// +---+---+---+---+---+---+---+---+---+---+---+---+
|
||||
// | X | m | m | m | | | | | m | m | m | m |
|
||||
// +---+---+---+---+---+---+---+---+---+---+---+---+
|
||||
// | m | m | m | m | | | | | m | m | m | m |
|
||||
// +---+---+---+---+---+---+---+---+---+---+---+---+
|
||||
// | m | m | m | m | | | | | m | m | m | m |
|
||||
// +---+---+---+---+---+---+---+---+---+---+---+---+
|
||||
// | m | m | m | m | | | | | X | m | m | m |
|
||||
// +---+---+---+---+---+---+---+---+---+---+---+---+
|
||||
// the [8, 8] - [64, 32] is not expected to be covered in the difference. As
|
||||
// ScreenCapturerDifferWrapper should only mark [0, 0] - [32, 32] and
|
||||
// [64, 0] - [96, 32] as updated.
|
||||
DesktopRegion differ(frame.updated_region());
|
||||
differ.Subtract(region);
|
||||
for (DesktopRegion::Iterator it(differ); !it.IsAtEnd(); it.Advance()) {
|
||||
ASSERT_TRUE(it.rect().width() <= kBlockSize * 2 - 2 ||
|
||||
it.rect().height() <= kBlockSize * 2 - 2);
|
||||
}
|
||||
}
|
||||
|
||||
// Executes a ScreenCapturerDifferWrapper::Capture() and compares its output
|
||||
// DesktopFrame::updated_region() with |updated_region| if |check_result| is
|
||||
// true. If |exactly_match| is true, AssertUpdatedRegionIs() will be used,
|
||||
// otherwise AssertUpdatedRegionCovers() will be used.
|
||||
template <template <typename, typename...> class T = std::initializer_list,
|
||||
typename... Rect>
|
||||
void ExecuteDifferWrapperCase(BlackWhiteDesktopFramePainter* frame_painter,
|
||||
ScreenCapturerDifferWrapper* capturer,
|
||||
MockScreenCapturerCallback* callback,
|
||||
const T<DesktopRect, Rect...>& updated_region,
|
||||
bool check_result,
|
||||
bool exactly_match) {
|
||||
EXPECT_CALL(*callback,
|
||||
OnCaptureResultPtr(DesktopCapturer::Result::SUCCESS, testing::_))
|
||||
.Times(1)
|
||||
.WillOnce(testing::Invoke([&updated_region, check_result, exactly_match](
|
||||
DesktopCapturer::Result result,
|
||||
std::unique_ptr<DesktopFrame>* frame) {
|
||||
ASSERT_EQ(result, DesktopCapturer::Result::SUCCESS);
|
||||
if (check_result) {
|
||||
if (exactly_match) {
|
||||
AssertUpdatedRegionIs(**frame, updated_region);
|
||||
} else {
|
||||
AssertUpdatedRegionCovers(**frame, updated_region);
|
||||
}
|
||||
}
|
||||
}));
|
||||
for (const auto& rect : updated_region) {
|
||||
frame_painter->updated_region()->AddRect(rect);
|
||||
}
|
||||
capturer->CaptureFrame();
|
||||
}
|
||||
|
||||
// Executes a ScreenCapturerDifferWrapper::Capture(), if updated_region() is not
|
||||
// set, this function will reset ScreenCapturerDifferWrapper internal
|
||||
// DesktopFrame into white.
|
||||
void ExecuteCapturer(ScreenCapturerDifferWrapper* capturer,
|
||||
MockScreenCapturerCallback* callback) {
|
||||
EXPECT_CALL(*callback,
|
||||
OnCaptureResultPtr(DesktopCapturer::Result::SUCCESS, testing::_))
|
||||
.Times(1);
|
||||
capturer->CaptureFrame();
|
||||
}
|
||||
|
||||
void ExecuteDifferWrapperTest(bool with_hints,
|
||||
bool enlarge_updated_region,
|
||||
bool random_updated_region,
|
||||
bool check_result) {
|
||||
const bool updated_region_should_exactly_match =
|
||||
with_hints && !enlarge_updated_region && !random_updated_region;
|
||||
BlackWhiteDesktopFramePainter frame_painter;
|
||||
PainterDesktopFrameGenerator frame_generator;
|
||||
frame_generator.set_desktop_frame_painter(&frame_painter);
|
||||
std::unique_ptr<FakeScreenCapturer> fake(new FakeScreenCapturer());
|
||||
fake->set_frame_generator(&frame_generator);
|
||||
ScreenCapturerDifferWrapper capturer(std::move(fake));
|
||||
MockScreenCapturerCallback callback;
|
||||
frame_generator.set_provide_updated_region_hints(with_hints);
|
||||
frame_generator.set_enlarge_updated_region(enlarge_updated_region);
|
||||
frame_generator.set_add_random_updated_region(random_updated_region);
|
||||
|
||||
capturer.Start(&callback);
|
||||
|
||||
EXPECT_CALL(callback,
|
||||
OnCaptureResultPtr(DesktopCapturer::Result::SUCCESS, testing::_))
|
||||
.Times(1)
|
||||
.WillOnce(testing::Invoke([](DesktopCapturer::Result result,
|
||||
std::unique_ptr<DesktopFrame>* frame) {
|
||||
ASSERT_EQ(result, DesktopCapturer::Result::SUCCESS);
|
||||
AssertUpdatedRegionIs(**frame,
|
||||
{DesktopRect::MakeSize((*frame)->size())});
|
||||
}));
|
||||
capturer.CaptureFrame();
|
||||
|
||||
ExecuteDifferWrapperCase(&frame_painter, &capturer, &callback,
|
||||
{DesktopRect::MakeLTRB(100, 100, 200, 200),
|
||||
DesktopRect::MakeLTRB(300, 300, 400, 400)},
|
||||
check_result, updated_region_should_exactly_match);
|
||||
ExecuteCapturer(&capturer, &callback);
|
||||
|
||||
ExecuteDifferWrapperCase(
|
||||
&frame_painter, &capturer, &callback,
|
||||
{DesktopRect::MakeLTRB(0, 0, 40, 40),
|
||||
DesktopRect::MakeLTRB(0, frame_generator.size()->height() - 40, 40,
|
||||
frame_generator.size()->height()),
|
||||
DesktopRect::MakeLTRB(frame_generator.size()->width() - 40, 0,
|
||||
frame_generator.size()->width(), 40),
|
||||
DesktopRect::MakeLTRB(frame_generator.size()->width() - 40,
|
||||
frame_generator.size()->height() - 40,
|
||||
frame_generator.size()->width(),
|
||||
frame_generator.size()->height())},
|
||||
check_result, updated_region_should_exactly_match);
|
||||
|
||||
Random random(rtc::TimeMillis());
|
||||
// Fuzzing tests.
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
if (enlarge_updated_region) {
|
||||
frame_generator.set_enlarge_range(random.Rand(1, 50));
|
||||
}
|
||||
frame_generator.size()->set(random.Rand(500, 2000), random.Rand(500, 2000));
|
||||
ExecuteCapturer(&capturer, &callback);
|
||||
std::vector<DesktopRect> updated_region;
|
||||
for (int j = random.Rand(50); j >= 0; j--) {
|
||||
// At least a 1 x 1 updated region.
|
||||
const int left = random.Rand(0, frame_generator.size()->width() - 2);
|
||||
const int top = random.Rand(0, frame_generator.size()->height() - 2);
|
||||
const int right = random.Rand(left + 1, frame_generator.size()->width());
|
||||
const int bottom = random.Rand(top + 1, frame_generator.size()->height());
|
||||
updated_region.push_back(DesktopRect::MakeLTRB(left, top, right, bottom));
|
||||
}
|
||||
ExecuteDifferWrapperCase(&frame_painter, &capturer, &callback,
|
||||
updated_region, check_result,
|
||||
updated_region_should_exactly_match);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
TEST(ScreenCapturerDifferWrapperTest, CaptureWithoutHints) {
|
||||
ExecuteDifferWrapperTest(false, false, false, true);
|
||||
}
|
||||
|
||||
TEST(ScreenCapturerDifferWrapperTest, CaptureWithHints) {
|
||||
ExecuteDifferWrapperTest(true, false, false, true);
|
||||
}
|
||||
|
||||
TEST(ScreenCapturerDifferWrapperTest, CaptureWithEnlargedHints) {
|
||||
ExecuteDifferWrapperTest(true, true, false, true);
|
||||
}
|
||||
|
||||
TEST(ScreenCapturerDifferWrapperTest, CaptureWithRandomHints) {
|
||||
ExecuteDifferWrapperTest(true, false, true, true);
|
||||
}
|
||||
|
||||
TEST(ScreenCapturerDifferWrapperTest, CaptureWithEnlargedAndRandomHints) {
|
||||
ExecuteDifferWrapperTest(true, true, true, true);
|
||||
}
|
||||
|
||||
// When hints are provided, ScreenCapturerDifferWrapper has a slightly better
|
||||
// performance in current configuration, but not so significant. Following is
|
||||
// one run result.
|
||||
// [ RUN ] DISABLED_CaptureWithoutHintsPerf
|
||||
// [ OK ] DISABLED_CaptureWithoutHintsPerf (7118 ms)
|
||||
// [ RUN ] DISABLED_CaptureWithHintsPerf
|
||||
// [ OK ] DISABLED_CaptureWithHintsPerf (5580 ms)
|
||||
// [ RUN ] DISABLED_CaptureWithEnlargedHintsPerf
|
||||
// [ OK ] DISABLED_CaptureWithEnlargedHintsPerf (5974 ms)
|
||||
// [ RUN ] DISABLED_CaptureWithRandomHintsPerf
|
||||
// [ OK ] DISABLED_CaptureWithRandomHintsPerf (6184 ms)
|
||||
// [ RUN ] DISABLED_CaptureWithEnlargedAndRandomHintsPerf
|
||||
// [ OK ] DISABLED_CaptureWithEnlargedAndRandomHintsPerf (6347 ms)
|
||||
TEST(ScreenCapturerDifferWrapperTest, DISABLED_CaptureWithoutHintsPerf) {
|
||||
int64_t started = rtc::TimeMillis();
|
||||
ExecuteDifferWrapperTest(false, false, false, false);
|
||||
ASSERT_LE(rtc::TimeMillis() - started, 15000);
|
||||
}
|
||||
|
||||
TEST(ScreenCapturerDifferWrapperTest, DISABLED_CaptureWithHintsPerf) {
|
||||
int64_t started = rtc::TimeMillis();
|
||||
ExecuteDifferWrapperTest(true, false, false, false);
|
||||
ASSERT_LE(rtc::TimeMillis() - started, 15000);
|
||||
}
|
||||
|
||||
TEST(ScreenCapturerDifferWrapperTest, DISABLED_CaptureWithEnlargedHintsPerf) {
|
||||
int64_t started = rtc::TimeMillis();
|
||||
ExecuteDifferWrapperTest(true, true, false, false);
|
||||
ASSERT_LE(rtc::TimeMillis() - started, 15000);
|
||||
}
|
||||
|
||||
TEST(ScreenCapturerDifferWrapperTest, DISABLED_CaptureWithRandomHintsPerf) {
|
||||
int64_t started = rtc::TimeMillis();
|
||||
ExecuteDifferWrapperTest(true, false, true, false);
|
||||
ASSERT_LE(rtc::TimeMillis() - started, 15000);
|
||||
}
|
||||
|
||||
TEST(ScreenCapturerDifferWrapperTest,
|
||||
DISABLED_CaptureWithEnlargedAndRandomHintsPerf) {
|
||||
int64_t started = rtc::TimeMillis();
|
||||
ExecuteDifferWrapperTest(true, true, true, false);
|
||||
ASSERT_LE(rtc::TimeMillis() - started, 15000);
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
@ -15,19 +15,18 @@
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#include "webrtc/modules/desktop_capture/screen_capturer.h"
|
||||
|
||||
#include "webrtc/test/gmock.h"
|
||||
#include "webrtc/test/gtest.h"
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/base/constructormagic.h"
|
||||
#include "webrtc/base/logging.h"
|
||||
#include "webrtc/modules/desktop_capture/rgba_color.h"
|
||||
#include "webrtc/modules/desktop_capture/desktop_capturer.h"
|
||||
#include "webrtc/modules/desktop_capture/desktop_capture_options.h"
|
||||
#include "webrtc/modules/desktop_capture/desktop_frame.h"
|
||||
#include "webrtc/modules/desktop_capture/desktop_region.h"
|
||||
#include "webrtc/modules/desktop_capture/mock_desktop_capturer_callback.h"
|
||||
#include "webrtc/modules/desktop_capture/rgba_color.h"
|
||||
#include "webrtc/modules/desktop_capture/screen_drawer.h"
|
||||
#include "webrtc/test/gmock.h"
|
||||
#include "webrtc/test/gtest.h"
|
||||
|
||||
#if defined(WEBRTC_WIN)
|
||||
#include "webrtc/modules/desktop_capture/win/screen_capturer_win_directx.h"
|
||||
|
||||
@ -8,8 +8,6 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "webrtc/modules/desktop_capture/screen_capturer.h"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include <memory>
|
||||
@ -27,6 +25,7 @@
|
||||
#include "webrtc/base/constructormagic.h"
|
||||
#include "webrtc/base/macutils.h"
|
||||
#include "webrtc/base/timeutils.h"
|
||||
#include "webrtc/modules/desktop_capture/desktop_capturer.h"
|
||||
#include "webrtc/modules/desktop_capture/desktop_capture_options.h"
|
||||
#include "webrtc/modules/desktop_capture/desktop_frame.h"
|
||||
#include "webrtc/modules/desktop_capture/desktop_geometry.h"
|
||||
@ -35,7 +34,6 @@
|
||||
#include "webrtc/modules/desktop_capture/mac/desktop_configuration_monitor.h"
|
||||
#include "webrtc/modules/desktop_capture/mac/scoped_pixel_buffer_object.h"
|
||||
#include "webrtc/modules/desktop_capture/screen_capture_frame_queue.h"
|
||||
#include "webrtc/modules/desktop_capture/screen_capturer_differ_wrapper.h"
|
||||
#include "webrtc/modules/desktop_capture/screen_capturer_helper.h"
|
||||
#include "webrtc/modules/desktop_capture/shared_desktop_frame.h"
|
||||
#include "webrtc/system_wrappers/include/logging.h"
|
||||
@ -275,7 +273,7 @@ CGImageRef CreateExcludedWindowRegionImage(const DesktopRect& pixel_bounds,
|
||||
}
|
||||
|
||||
// A class to perform video frame capturing for mac.
|
||||
class ScreenCapturerMac : public ScreenCapturer {
|
||||
class ScreenCapturerMac : public DesktopCapturer {
|
||||
public:
|
||||
explicit ScreenCapturerMac(
|
||||
rtc::scoped_refptr<DesktopConfigurationMonitor> desktop_config_monitor);
|
||||
@ -283,12 +281,12 @@ class ScreenCapturerMac : public ScreenCapturer {
|
||||
|
||||
bool Init();
|
||||
|
||||
// Overridden from ScreenCapturer:
|
||||
// DesktopCapturer interface.
|
||||
void Start(Callback* callback) override;
|
||||
void CaptureFrame() override;
|
||||
void SetExcludedWindow(WindowId window) override;
|
||||
bool GetScreenList(ScreenList* screens) override;
|
||||
bool SelectScreen(ScreenId id) override;
|
||||
bool GetSourceList(SourceList* screens) override;
|
||||
bool SelectSource(SourceId id) override;
|
||||
|
||||
private:
|
||||
void GlBlitFast(const DesktopFrame& frame,
|
||||
@ -499,26 +497,22 @@ void ScreenCapturerMac::SetExcludedWindow(WindowId window) {
|
||||
excluded_window_ = window;
|
||||
}
|
||||
|
||||
bool ScreenCapturerMac::GetScreenList(ScreenList* screens) {
|
||||
bool ScreenCapturerMac::GetSourceList(SourceList* screens) {
|
||||
assert(screens->size() == 0);
|
||||
if (rtc::GetOSVersionName() < rtc::kMacOSLion) {
|
||||
// Single monitor cast is not supported on pre OS X 10.7.
|
||||
Screen screen;
|
||||
screen.id = kFullDesktopScreenId;
|
||||
screens->push_back(screen);
|
||||
screens->push_back({kFullDesktopScreenId});
|
||||
return true;
|
||||
}
|
||||
|
||||
for (MacDisplayConfigurations::iterator it = desktop_config_.displays.begin();
|
||||
it != desktop_config_.displays.end(); ++it) {
|
||||
Screen screen;
|
||||
screen.id = static_cast<ScreenId>(it->id);
|
||||
screens->push_back(screen);
|
||||
screens->push_back({it->id});
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ScreenCapturerMac::SelectScreen(ScreenId id) {
|
||||
bool ScreenCapturerMac::SelectSource(SourceId id) {
|
||||
if (rtc::GetOSVersionName() < rtc::kMacOSLion) {
|
||||
// Ignore the screen selection on unsupported OS.
|
||||
assert(!current_display_);
|
||||
@ -1019,33 +1013,15 @@ std::unique_ptr<DesktopFrame> ScreenCapturerMac::CreateFrame() {
|
||||
|
||||
} // namespace
|
||||
|
||||
// static
|
||||
ScreenCapturer* ScreenCapturer::Create(const DesktopCaptureOptions& options) {
|
||||
if (!options.configuration_monitor())
|
||||
return nullptr;
|
||||
|
||||
std::unique_ptr<ScreenCapturer> capturer(
|
||||
new ScreenCapturerMac(options.configuration_monitor()));
|
||||
if (!static_cast<ScreenCapturerMac*>(capturer.get())->Init()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (options.detect_updated_region()) {
|
||||
capturer.reset(new ScreenCapturerDifferWrapper(std::move(capturer)));
|
||||
}
|
||||
|
||||
return capturer.release();
|
||||
}
|
||||
|
||||
// static
|
||||
std::unique_ptr<DesktopCapturer> DesktopCapturer::CreateRawScreenCapturer(
|
||||
const DesktopCaptureOptions& options) {
|
||||
if (!options.configuration_monitor())
|
||||
return nullptr;
|
||||
|
||||
std::unique_ptr<ScreenCapturer> capturer(
|
||||
std::unique_ptr<ScreenCapturerMac> capturer(
|
||||
new ScreenCapturerMac(options.configuration_monitor()));
|
||||
if (!static_cast<ScreenCapturerMac*>(capturer.get())->Init()) {
|
||||
if (!capturer.get()->Init()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@ -8,13 +8,12 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "webrtc/modules/desktop_capture/screen_capturer.h"
|
||||
|
||||
#include <ApplicationServices/ApplicationServices.h>
|
||||
|
||||
#include <memory>
|
||||
#include <ostream>
|
||||
|
||||
#include "webrtc/modules/desktop_capture/desktop_capturer.h"
|
||||
#include "webrtc/modules/desktop_capture/desktop_capture_options.h"
|
||||
#include "webrtc/modules/desktop_capture/desktop_frame.h"
|
||||
#include "webrtc/modules/desktop_capture/desktop_geometry.h"
|
||||
|
||||
@ -12,14 +12,14 @@
|
||||
#define WEBRTC_MODULES_DESKTOP_CAPTURE_SCREEN_CAPTURER_MOCK_OBJECTS_H_
|
||||
|
||||
#include "webrtc/base/constructormagic.h"
|
||||
#include "webrtc/modules/desktop_capture/screen_capturer.h"
|
||||
#include "webrtc/modules/desktop_capture/desktop_capturer.h"
|
||||
#include "webrtc/test/gmock.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
// Deprecated.
|
||||
// Use webrtc/modules/desktop_capture/mock_desktop_capturer_callback.h.
|
||||
class MockScreenCapturerCallback : public ScreenCapturer::Callback {
|
||||
class MockScreenCapturerCallback : public DesktopCapturer::Callback {
|
||||
public:
|
||||
MockScreenCapturerCallback() {}
|
||||
~MockScreenCapturerCallback() override {}
|
||||
|
||||
@ -8,15 +8,10 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "webrtc/modules/desktop_capture/screen_capturer.h"
|
||||
#include "webrtc/modules/desktop_capture/desktop_capturer.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
// static
|
||||
ScreenCapturer* ScreenCapturer::Create(const DesktopCaptureOptions& options) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// static
|
||||
std::unique_ptr<DesktopCapturer> DesktopCapturer::CreateRawScreenCapturer(
|
||||
const DesktopCaptureOptions& options) {
|
||||
|
||||
@ -10,16 +10,15 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "webrtc/modules/desktop_capture/screen_capturer.h"
|
||||
|
||||
#include "webrtc/test/gmock.h"
|
||||
#include "webrtc/test/gtest.h"
|
||||
#include "webrtc/base/constructormagic.h"
|
||||
#include "webrtc/base/logging.h"
|
||||
#include "webrtc/modules/desktop_capture/desktop_capturer.h"
|
||||
#include "webrtc/modules/desktop_capture/desktop_capture_options.h"
|
||||
#include "webrtc/modules/desktop_capture/desktop_frame.h"
|
||||
#include "webrtc/modules/desktop_capture/desktop_region.h"
|
||||
#include "webrtc/modules/desktop_capture/screen_capturer_mock_objects.h"
|
||||
#include "webrtc/test/gmock.h"
|
||||
#include "webrtc/test/gtest.h"
|
||||
|
||||
#if defined(WEBRTC_WIN)
|
||||
#include "webrtc/modules/desktop_capture/win/screen_capturer_win_directx.h"
|
||||
|
||||
@ -8,40 +8,17 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "webrtc/modules/desktop_capture/screen_capturer.h"
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#include "webrtc/modules/desktop_capture/desktop_capturer.h"
|
||||
#include "webrtc/modules/desktop_capture/desktop_capture_options.h"
|
||||
#include "webrtc/modules/desktop_capture/screen_capturer_differ_wrapper.h"
|
||||
#include "webrtc/modules/desktop_capture/win/screen_capturer_win_directx.h"
|
||||
#include "webrtc/modules/desktop_capture/win/screen_capturer_win_gdi.h"
|
||||
#include "webrtc/modules/desktop_capture/win/screen_capturer_win_magnifier.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
// static
|
||||
ScreenCapturer* ScreenCapturer::Create(const DesktopCaptureOptions& options) {
|
||||
std::unique_ptr<ScreenCapturer> capturer;
|
||||
if (options.allow_directx_capturer() &&
|
||||
ScreenCapturerWinDirectx::IsSupported()) {
|
||||
capturer.reset(new ScreenCapturerWinDirectx(options));
|
||||
} else {
|
||||
capturer.reset(new ScreenCapturerWinGdi(options));
|
||||
}
|
||||
|
||||
if (options.allow_use_magnification_api()) {
|
||||
capturer.reset(new ScreenCapturerWinMagnifier(std::move(capturer)));
|
||||
}
|
||||
|
||||
if (options.detect_updated_region()) {
|
||||
capturer.reset(new ScreenCapturerDifferWrapper(std::move(capturer)));
|
||||
}
|
||||
|
||||
return capturer.release();
|
||||
}
|
||||
|
||||
// static
|
||||
std::unique_ptr<DesktopCapturer> DesktopCapturer::CreateRawScreenCapturer(
|
||||
const DesktopCaptureOptions& options) {
|
||||
|
||||
@ -8,8 +8,6 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "webrtc/modules/desktop_capture/screen_capturer.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <memory>
|
||||
@ -24,10 +22,10 @@
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/base/constructormagic.h"
|
||||
#include "webrtc/base/timeutils.h"
|
||||
#include "webrtc/modules/desktop_capture/desktop_capturer.h"
|
||||
#include "webrtc/modules/desktop_capture/desktop_capture_options.h"
|
||||
#include "webrtc/modules/desktop_capture/desktop_frame.h"
|
||||
#include "webrtc/modules/desktop_capture/screen_capture_frame_queue.h"
|
||||
#include "webrtc/modules/desktop_capture/screen_capturer_differ_wrapper.h"
|
||||
#include "webrtc/modules/desktop_capture/screen_capturer_helper.h"
|
||||
#include "webrtc/modules/desktop_capture/shared_desktop_frame.h"
|
||||
#include "webrtc/modules/desktop_capture/x11/x_server_pixel_buffer.h"
|
||||
@ -43,7 +41,7 @@ namespace {
|
||||
// DesktopFrame::updated_region(), the field is always set to the entire frame
|
||||
// rectangle. ScreenCapturerDifferWrapper should be used if that functionality
|
||||
// is necessary.
|
||||
class ScreenCapturerLinux : public ScreenCapturer,
|
||||
class ScreenCapturerLinux : public DesktopCapturer,
|
||||
public SharedXDisplay::XEventHandler {
|
||||
public:
|
||||
ScreenCapturerLinux();
|
||||
@ -403,31 +401,14 @@ void ScreenCapturerLinux::DeinitXlib() {
|
||||
|
||||
} // namespace
|
||||
|
||||
// static
|
||||
ScreenCapturer* ScreenCapturer::Create(const DesktopCaptureOptions& options) {
|
||||
if (!options.x_display())
|
||||
return nullptr;
|
||||
|
||||
std::unique_ptr<ScreenCapturer> capturer(new ScreenCapturerLinux());
|
||||
if (!static_cast<ScreenCapturerLinux*>(capturer.get())->Init(options)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (options.detect_updated_region()) {
|
||||
capturer.reset(new ScreenCapturerDifferWrapper(std::move(capturer)));
|
||||
}
|
||||
|
||||
return capturer.release();
|
||||
}
|
||||
|
||||
// static
|
||||
std::unique_ptr<DesktopCapturer> DesktopCapturer::CreateRawScreenCapturer(
|
||||
const DesktopCaptureOptions& options) {
|
||||
if (!options.x_display())
|
||||
return nullptr;
|
||||
|
||||
std::unique_ptr<ScreenCapturer> capturer(new ScreenCapturerLinux());
|
||||
if (!static_cast<ScreenCapturerLinux*>(capturer.get())->Init(options)) {
|
||||
std::unique_ptr<ScreenCapturerLinux> capturer(new ScreenCapturerLinux());
|
||||
if (!capturer.get()->Init(options)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@ -11,13 +11,12 @@
|
||||
#ifndef WEBRTC_MODULES_DESKTOP_CAPTURE_WIN_SCREEN_CAPTURER_WIN_DIRECTX_H_
|
||||
#define WEBRTC_MODULES_DESKTOP_CAPTURE_WIN_SCREEN_CAPTURER_WIN_DIRECTX_H_
|
||||
|
||||
#include "webrtc/modules/desktop_capture/screen_capturer.h"
|
||||
|
||||
#include <D3DCommon.h>
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/modules/desktop_capture/desktop_capturer.h"
|
||||
#include "webrtc/modules/desktop_capture/desktop_capture_options.h"
|
||||
#include "webrtc/modules/desktop_capture/desktop_region.h"
|
||||
#include "webrtc/modules/desktop_capture/screen_capture_frame_queue.h"
|
||||
@ -27,7 +26,7 @@
|
||||
namespace webrtc {
|
||||
|
||||
// ScreenCapturerWinDirectx captures 32bit RGBA using DirectX.
|
||||
class ScreenCapturerWinDirectx : public ScreenCapturer {
|
||||
class ScreenCapturerWinDirectx : public DesktopCapturer {
|
||||
public:
|
||||
using D3dInfo = DxgiDuplicatorController::D3dInfo;
|
||||
|
||||
|
||||
@ -13,11 +13,10 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "webrtc/modules/desktop_capture/screen_capturer.h"
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include "webrtc/base/constructormagic.h"
|
||||
#include "webrtc/modules/desktop_capture/desktop_capturer.h"
|
||||
#include "webrtc/modules/desktop_capture/screen_capture_frame_queue.h"
|
||||
#include "webrtc/modules/desktop_capture/shared_desktop_frame.h"
|
||||
#include "webrtc/modules/desktop_capture/win/scoped_thread_desktop.h"
|
||||
@ -30,7 +29,7 @@ namespace webrtc {
|
||||
// This class does not detect DesktopFrame::updated_region(), the field is
|
||||
// always set to the entire frame rectangle. ScreenCapturerDifferWrapper should
|
||||
// be used if that functionality is necessary.
|
||||
class ScreenCapturerWinGdi : public ScreenCapturer {
|
||||
class ScreenCapturerWinGdi : public DesktopCapturer {
|
||||
public:
|
||||
explicit ScreenCapturerWinGdi(const DesktopCaptureOptions& options);
|
||||
~ScreenCapturerWinGdi() override;
|
||||
|
||||
@ -18,8 +18,8 @@
|
||||
#include <wincodec.h>
|
||||
|
||||
#include "webrtc/base/constructormagic.h"
|
||||
#include "webrtc/modules/desktop_capture/desktop_capturer.h"
|
||||
#include "webrtc/modules/desktop_capture/screen_capture_frame_queue.h"
|
||||
#include "webrtc/modules/desktop_capture/screen_capturer.h"
|
||||
#include "webrtc/modules/desktop_capture/screen_capturer_helper.h"
|
||||
#include "webrtc/modules/desktop_capture/shared_desktop_frame.h"
|
||||
#include "webrtc/modules/desktop_capture/win/scoped_thread_desktop.h"
|
||||
@ -38,7 +38,7 @@ class DesktopRect;
|
||||
// This class does not detect DesktopFrame::updated_region(), the field is
|
||||
// always set to the entire frame rectangle. ScreenCapturerDifferWrapper should
|
||||
// be used if that functionality is necessary.
|
||||
class ScreenCapturerWinMagnifier : public ScreenCapturer {
|
||||
class ScreenCapturerWinMagnifier : public DesktopCapturer {
|
||||
public:
|
||||
// |fallback_capturer| will be used to capture the screen if a non-primary
|
||||
// screen is being captured, or the OS does not support Magnification API, or
|
||||
|
||||
@ -1,61 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "webrtc/modules/desktop_capture/window_capturer.h"
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
WindowCapturer::~WindowCapturer() = default;
|
||||
|
||||
bool WindowCapturer::GetWindowList(WindowList* windows) {
|
||||
SourceList sources;
|
||||
if (!GetSourceList(&sources)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (const Source& source : sources) {
|
||||
windows->push_back({source.id, std::move(source.title)});
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WindowCapturer::SelectWindow(WindowId id) {
|
||||
return SelectSource(id);
|
||||
}
|
||||
|
||||
bool WindowCapturer::BringSelectedWindowToFront() {
|
||||
return FocusOnSelectedSource();
|
||||
}
|
||||
|
||||
bool WindowCapturer::GetSourceList(SourceList* sources) {
|
||||
WindowList windows;
|
||||
if (!GetWindowList(&windows)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (const Window& window : windows) {
|
||||
sources->push_back({window.id, std::move(window.title)});
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WindowCapturer::SelectSource(SourceId id) {
|
||||
return SelectWindow(id);
|
||||
}
|
||||
|
||||
bool WindowCapturer::FocusOnSelectedSource() {
|
||||
return BringSelectedWindowToFront();
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
@ -1,68 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef WEBRTC_MODULES_DESKTOP_CAPTURE_WINDOW_CAPTURER_H_
|
||||
#define WEBRTC_MODULES_DESKTOP_CAPTURE_WINDOW_CAPTURER_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/base/constructormagic.h"
|
||||
#include "webrtc/modules/desktop_capture/desktop_capture_types.h"
|
||||
#include "webrtc/modules/desktop_capture/desktop_capturer.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class DesktopCaptureOptions;
|
||||
|
||||
// TODO(zijiehe): Remove this class.
|
||||
class WindowCapturer : public DesktopCapturer {
|
||||
public:
|
||||
typedef webrtc::WindowId WindowId;
|
||||
|
||||
struct Window {
|
||||
WindowId id;
|
||||
|
||||
// Title of the window in UTF-8 encoding.
|
||||
std::string title;
|
||||
};
|
||||
|
||||
typedef std::vector<Window> WindowList;
|
||||
|
||||
// Consumers should use DesktopCapturer::CreateWindowCapturer.
|
||||
static WindowCapturer* Create(const DesktopCaptureOptions& options);
|
||||
|
||||
~WindowCapturer() override;
|
||||
|
||||
// Deprecated, use GetSourceList().
|
||||
// Get list of windows. Returns false in case of a failure.
|
||||
virtual bool GetWindowList(WindowList* windows);
|
||||
|
||||
// Deprecated, use SelectSource().
|
||||
// Select window to be captured. Returns false in case of a failure (e.g. if
|
||||
// there is no window with the specified id).
|
||||
virtual bool SelectWindow(WindowId id);
|
||||
|
||||
// Deprecated, use FocusOnSelectedSource().
|
||||
// Bring the selected window to the front. Returns false in case of a
|
||||
// failure or no window selected.
|
||||
virtual bool BringSelectedWindowToFront();
|
||||
|
||||
// DesktopCapturer interfaces.
|
||||
bool GetSourceList(SourceList* sources) override;
|
||||
bool SelectSource(SourceId id) override;
|
||||
bool FocusOnSelectedSource() override;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // WEBRTC_MODULES_DESKTOP_CAPTURE_WINDOW_CAPTURER_H_
|
||||
|
||||
@ -8,8 +8,6 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "webrtc/modules/desktop_capture/window_capturer.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <ApplicationServices/ApplicationServices.h>
|
||||
#include <Cocoa/Cocoa.h>
|
||||
@ -18,6 +16,7 @@
|
||||
#include "webrtc/base/constructormagic.h"
|
||||
#include "webrtc/base/macutils.h"
|
||||
#include "webrtc/base/scoped_ref_ptr.h"
|
||||
#include "webrtc/modules/desktop_capture/desktop_capturer.h"
|
||||
#include "webrtc/modules/desktop_capture/desktop_capture_options.h"
|
||||
#include "webrtc/modules/desktop_capture/desktop_frame.h"
|
||||
#include "webrtc/modules/desktop_capture/mac/desktop_configuration.h"
|
||||
@ -42,7 +41,7 @@ bool IsWindowValid(CGWindowID id) {
|
||||
return valid;
|
||||
}
|
||||
|
||||
class WindowCapturerMac : public WindowCapturer {
|
||||
class WindowCapturerMac : public DesktopCapturer {
|
||||
public:
|
||||
explicit WindowCapturerMac(rtc::scoped_refptr<FullScreenChromeWindowDetector>
|
||||
full_screen_chrome_window_detector);
|
||||
@ -189,11 +188,6 @@ void WindowCapturerMac::CaptureFrame() {
|
||||
|
||||
} // namespace
|
||||
|
||||
// static
|
||||
WindowCapturer* WindowCapturer::Create(const DesktopCaptureOptions& options) {
|
||||
return new WindowCapturerMac(options.full_screen_chrome_window_detector());
|
||||
}
|
||||
|
||||
// static
|
||||
std::unique_ptr<DesktopCapturer> DesktopCapturer::CreateRawWindowCapturer(
|
||||
const DesktopCaptureOptions& options) {
|
||||
|
||||
@ -8,18 +8,17 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "webrtc/modules/desktop_capture/window_capturer.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "webrtc/base/constructormagic.h"
|
||||
#include "webrtc/modules/desktop_capture/desktop_capturer.h"
|
||||
#include "webrtc/modules/desktop_capture/desktop_frame.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
namespace {
|
||||
|
||||
class WindowCapturerNull : public WindowCapturer {
|
||||
class WindowCapturerNull : public DesktopCapturer {
|
||||
public:
|
||||
WindowCapturerNull();
|
||||
~WindowCapturerNull() override;
|
||||
@ -63,11 +62,6 @@ void WindowCapturerNull::CaptureFrame() {
|
||||
|
||||
} // namespace
|
||||
|
||||
// static
|
||||
WindowCapturer* WindowCapturer::Create(const DesktopCaptureOptions& options) {
|
||||
return new WindowCapturerNull();
|
||||
}
|
||||
|
||||
// static
|
||||
std::unique_ptr<DesktopCapturer> DesktopCapturer::CreateRawWindowCapturer(
|
||||
const DesktopCaptureOptions& options) {
|
||||
|
||||
@ -10,13 +10,12 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "webrtc/modules/desktop_capture/window_capturer.h"
|
||||
|
||||
#include "webrtc/test/gtest.h"
|
||||
#include "webrtc/modules/desktop_capture/desktop_capturer.h"
|
||||
#include "webrtc/modules/desktop_capture/desktop_capture_options.h"
|
||||
#include "webrtc/modules/desktop_capture/desktop_frame.h"
|
||||
#include "webrtc/modules/desktop_capture/desktop_region.h"
|
||||
#include "webrtc/system_wrappers/include/logging.h"
|
||||
#include "webrtc/test/gtest.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
|
||||
@ -8,8 +8,6 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "webrtc/modules/desktop_capture/window_capturer.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include <memory>
|
||||
@ -17,6 +15,7 @@
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/base/constructormagic.h"
|
||||
#include "webrtc/base/win32.h"
|
||||
#include "webrtc/modules/desktop_capture/desktop_capturer.h"
|
||||
#include "webrtc/modules/desktop_capture/desktop_frame_win.h"
|
||||
#include "webrtc/modules/desktop_capture/win/window_capture_utils.h"
|
||||
#include "webrtc/system_wrappers/include/logging.h"
|
||||
@ -80,7 +79,7 @@ BOOL CALLBACK WindowsEnumerationHandler(HWND hwnd, LPARAM param) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
class WindowCapturerWin : public WindowCapturer {
|
||||
class WindowCapturerWin : public DesktopCapturer {
|
||||
public:
|
||||
WindowCapturerWin();
|
||||
~WindowCapturerWin() override;
|
||||
@ -263,11 +262,6 @@ void WindowCapturerWin::CaptureFrame() {
|
||||
|
||||
} // namespace
|
||||
|
||||
// static
|
||||
WindowCapturer* WindowCapturer::Create(const DesktopCaptureOptions& options) {
|
||||
return new WindowCapturerWin();
|
||||
}
|
||||
|
||||
// static
|
||||
std::unique_ptr<DesktopCapturer> DesktopCapturer::CreateRawWindowCapturer(
|
||||
const DesktopCaptureOptions& options) {
|
||||
|
||||
@ -8,8 +8,6 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "webrtc/modules/desktop_capture/window_capturer.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <X11/Xatom.h>
|
||||
@ -21,6 +19,7 @@
|
||||
|
||||
#include "webrtc/base/constructormagic.h"
|
||||
#include "webrtc/base/scoped_ref_ptr.h"
|
||||
#include "webrtc/modules/desktop_capture/desktop_capturer.h"
|
||||
#include "webrtc/modules/desktop_capture/desktop_capture_options.h"
|
||||
#include "webrtc/modules/desktop_capture/desktop_frame.h"
|
||||
#include "webrtc/modules/desktop_capture/x11/shared_x_display.h"
|
||||
@ -82,7 +81,7 @@ class XWindowProperty {
|
||||
RTC_DISALLOW_COPY_AND_ASSIGN(XWindowProperty);
|
||||
};
|
||||
|
||||
class WindowCapturerLinux : public WindowCapturer,
|
||||
class WindowCapturerLinux : public DesktopCapturer,
|
||||
public SharedXDisplay::XEventHandler {
|
||||
public:
|
||||
WindowCapturerLinux(const DesktopCaptureOptions& options);
|
||||
@ -421,13 +420,6 @@ bool WindowCapturerLinux::GetWindowTitle(::Window window, std::string* title) {
|
||||
|
||||
} // namespace
|
||||
|
||||
// static
|
||||
WindowCapturer* WindowCapturer::Create(const DesktopCaptureOptions& options) {
|
||||
if (!options.x_display())
|
||||
return nullptr;
|
||||
return new WindowCapturerLinux(options);
|
||||
}
|
||||
|
||||
// static
|
||||
std::unique_ptr<DesktopCapturer> DesktopCapturer::CreateRawWindowCapturer(
|
||||
const DesktopCaptureOptions& options) {
|
||||
|
||||
Reference in New Issue
Block a user