| Index: webrtc/modules/desktop_capture/screen_capturer_mac.mm
|
| diff --git a/webrtc/modules/desktop_capture/screen_capturer_mac.mm b/webrtc/modules/desktop_capture/screen_capturer_mac.mm
|
| index 2c22ee5e46fb43745fdd175d97330fbe2133f9fe..c41dc4d7a3b4ba59e4ebe6880f1e090dae5386b5 100644
|
| --- a/webrtc/modules/desktop_capture/screen_capturer_mac.mm
|
| +++ b/webrtc/modules/desktop_capture/screen_capturer_mac.mm
|
| @@ -22,9 +22,7 @@
|
| #include <OpenGL/CGLMacro.h>
|
| #include <OpenGL/OpenGL.h>
|
|
|
| -#include "webrtc/base/checks.h"
|
| #include "webrtc/base/macutils.h"
|
| -#include "webrtc/base/thread_checker.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"
|
| @@ -190,6 +188,8 @@
|
| rtc::scoped_refptr<DesktopConfigurationMonitor> desktop_config_monitor);
|
| virtual ~ScreenCapturerMac();
|
|
|
| + bool Init();
|
| +
|
| // Overridden from ScreenCapturer:
|
| void Start(Callback* callback) override;
|
| void Capture(const DesktopRegion& region) override;
|
| @@ -198,8 +198,6 @@
|
| bool SelectScreen(ScreenId id) override;
|
|
|
| private:
|
| - bool Initialize();
|
| -
|
| void GlBlitFast(const DesktopFrame& frame,
|
| const DesktopRegion& region);
|
| void GlBlitSlow(const DesktopFrame& frame);
|
| @@ -230,11 +228,9 @@
|
|
|
| DesktopFrame* CreateFrame();
|
|
|
| - rtc::ThreadChecker thread_checker_;
|
| -
|
| - Callback* callback_ = nullptr;
|
| -
|
| - CGLContextObj cgl_context_ = nullptr;
|
| + Callback* callback_;
|
| +
|
| + CGLContextObj cgl_context_;
|
| ScopedPixelBufferObject pixel_buffer_object_;
|
|
|
| // Queue of the frames buffers.
|
| @@ -245,13 +241,13 @@
|
|
|
| // Currently selected display, or 0 if the full desktop is selected. On OS X
|
| // 10.6 and before, this is always 0.
|
| - CGDirectDisplayID current_display_ = 0;
|
| + CGDirectDisplayID current_display_;
|
|
|
| // The physical pixel bounds of the current screen.
|
| DesktopRect screen_pixel_bounds_;
|
|
|
| // The dip to physical pixel scale of the current screen.
|
| - float dip_to_pixel_scale_ = 1.0f;
|
| + float dip_to_pixel_scale_;
|
|
|
| // A thread-safe list of invalid rectangles, and the size of the most
|
| // recently captured screen.
|
| @@ -264,20 +260,20 @@
|
| rtc::scoped_refptr<DesktopConfigurationMonitor> desktop_config_monitor_;
|
|
|
| // Power management assertion to prevent the screen from sleeping.
|
| - IOPMAssertionID power_assertion_id_display_ = kIOPMNullAssertionID;
|
| + IOPMAssertionID power_assertion_id_display_;
|
|
|
| // Power management assertion to indicate that the user is active.
|
| - IOPMAssertionID power_assertion_id_user_ = kIOPMNullAssertionID;
|
| + IOPMAssertionID power_assertion_id_user_;
|
|
|
| // Dynamically link to deprecated APIs for Mac OS X 10.6 support.
|
| - void* app_services_library_ = nullptr;
|
| - CGDisplayBaseAddressFunc cg_display_base_address_ = nullptr;
|
| - CGDisplayBytesPerRowFunc cg_display_bytes_per_row_ = nullptr;
|
| - CGDisplayBitsPerPixelFunc cg_display_bits_per_pixel_ = nullptr;
|
| - void* opengl_library_ = nullptr;
|
| - CGLSetFullScreenFunc cgl_set_full_screen_ = nullptr;
|
| -
|
| - CGWindowID excluded_window_ = 0;
|
| + void* app_services_library_;
|
| + CGDisplayBaseAddressFunc cg_display_base_address_;
|
| + CGDisplayBytesPerRowFunc cg_display_bytes_per_row_;
|
| + CGDisplayBitsPerPixelFunc cg_display_bits_per_pixel_;
|
| + void* opengl_library_;
|
| + CGLSetFullScreenFunc cgl_set_full_screen_;
|
| +
|
| + CGWindowID excluded_window_;
|
|
|
| RTC_DISALLOW_COPY_AND_ASSIGN(ScreenCapturerMac);
|
| };
|
| @@ -307,15 +303,23 @@
|
|
|
| ScreenCapturerMac::ScreenCapturerMac(
|
| rtc::scoped_refptr<DesktopConfigurationMonitor> desktop_config_monitor)
|
| - : desktop_config_monitor_(desktop_config_monitor) {
|
| - // ScreenCapturer can be used on a thread different from the thread on which
|
| - // it's created.
|
| - thread_checker_.DetachFromThread();
|
| + : callback_(NULL),
|
| + cgl_context_(NULL),
|
| + current_display_(0),
|
| + dip_to_pixel_scale_(1.0f),
|
| + desktop_config_monitor_(desktop_config_monitor),
|
| + power_assertion_id_display_(kIOPMNullAssertionID),
|
| + power_assertion_id_user_(kIOPMNullAssertionID),
|
| + app_services_library_(NULL),
|
| + cg_display_base_address_(NULL),
|
| + cg_display_bytes_per_row_(NULL),
|
| + cg_display_bits_per_pixel_(NULL),
|
| + opengl_library_(NULL),
|
| + cgl_set_full_screen_(NULL),
|
| + excluded_window_(0) {
|
| }
|
|
|
| ScreenCapturerMac::~ScreenCapturerMac() {
|
| - RTC_DCHECK(thread_checker_.CalledOnValidThread());
|
| -
|
| if (power_assertion_id_display_ != kIOPMNullAssertionID) {
|
| IOPMAssertionRelease(power_assertion_id_display_);
|
| power_assertion_id_display_ = kIOPMNullAssertionID;
|
| @@ -331,7 +335,7 @@
|
| dlclose(opengl_library_);
|
| }
|
|
|
| -bool ScreenCapturerMac::Initialize() {
|
| +bool ScreenCapturerMac::Init() {
|
| if (!RegisterRefreshAndMoveHandlers()) {
|
| return false;
|
| }
|
| @@ -355,16 +359,10 @@
|
| }
|
|
|
| void ScreenCapturerMac::Start(Callback* callback) {
|
| - RTC_DCHECK(thread_checker_.CalledOnValidThread());
|
| - RTC_DCHECK(!callback_);
|
| - RTC_DCHECK(callback);
|
| + assert(!callback_);
|
| + assert(callback);
|
|
|
| callback_ = callback;
|
| -
|
| - if (!Initialize()) {
|
| - callback_->OnInitializationFailed();
|
| - return;
|
| - }
|
|
|
| // Create power management assertions to wake the display and prevent it from
|
| // going to sleep on user idle.
|
| @@ -383,8 +381,6 @@
|
| }
|
|
|
| void ScreenCapturerMac::Capture(const DesktopRegion& region_to_capture) {
|
| - RTC_DCHECK(thread_checker_.CalledOnValidThread());
|
| -
|
| TickTime capture_start_time = TickTime::Now();
|
|
|
| queue_.MoveToNextFrame();
|
| @@ -453,14 +449,11 @@
|
| }
|
|
|
| void ScreenCapturerMac::SetExcludedWindow(WindowId window) {
|
| - RTC_DCHECK(thread_checker_.CalledOnValidThread());
|
| excluded_window_ = window;
|
| }
|
|
|
| bool ScreenCapturerMac::GetScreenList(ScreenList* screens) {
|
| - RTC_DCHECK(thread_checker_.CalledOnValidThread());
|
| - RTC_DCHECK(screens->size() == 0);
|
| -
|
| + assert(screens->size() == 0);
|
| if (rtc::GetOSVersionName() < rtc::kMacOSLion) {
|
| // Single monitor cast is not supported on pre OS X 10.7.
|
| Screen screen;
|
| @@ -479,8 +472,6 @@
|
| }
|
|
|
| bool ScreenCapturerMac::SelectScreen(ScreenId id) {
|
| - RTC_DCHECK(thread_checker_.CalledOnValidThread());
|
| -
|
| if (rtc::GetOSVersionName() < rtc::kMacOSLion) {
|
| // Ignore the screen selection on unsupported OS.
|
| assert(!current_display_);
|
| @@ -989,7 +980,11 @@
|
| if (!options.configuration_monitor())
|
| return NULL;
|
|
|
| - return new ScreenCapturerMac(options.configuration_monitor());
|
| + std::unique_ptr<ScreenCapturerMac> capturer(
|
| + new ScreenCapturerMac(options.configuration_monitor()));
|
| + if (!capturer->Init())
|
| + capturer.reset();
|
| + return capturer.release();
|
| }
|
|
|
| } // namespace webrtc
|
|
|