- Remove unsued ScopedPixelBufferObject that was used for the capture using OpenGL. - Also remove InvertedDesktopFrame for the same reason. - Replace several occurrences of assert by RTC_DCHECK Bug: webrtc:8652 Change-Id: I262db0a445f2211cde7476a6cadfb1c19a3e814f Reviewed-on: https://webrtc-review.googlesource.com/64883 Commit-Queue: Zijie He <zijiehe@chromium.org> Reviewed-by: Zijie He <zijiehe@chromium.org> Cr-Commit-Position: refs/heads/master@{#22632}
110 lines
3.6 KiB
C++
110 lines
3.6 KiB
C++
/*
|
|
* Copyright (c) 2018 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 MODULES_DESKTOP_CAPTURE_MAC_SCREEN_CAPTURER_MAC_H_
|
|
#define MODULES_DESKTOP_CAPTURE_MAC_SCREEN_CAPTURER_MAC_H_
|
|
|
|
#include <CoreGraphics/CoreGraphics.h>
|
|
|
|
#include <memory>
|
|
|
|
#include "modules/desktop_capture/desktop_capture_options.h"
|
|
#include "modules/desktop_capture/desktop_capturer.h"
|
|
#include "modules/desktop_capture/desktop_frame.h"
|
|
#include "modules/desktop_capture/desktop_geometry.h"
|
|
#include "modules/desktop_capture/desktop_region.h"
|
|
#include "modules/desktop_capture/mac/desktop_configuration.h"
|
|
#include "modules/desktop_capture/mac/desktop_configuration_monitor.h"
|
|
#include "modules/desktop_capture/screen_capture_frame_queue.h"
|
|
#include "modules/desktop_capture/screen_capturer_helper.h"
|
|
#include "modules/desktop_capture/shared_desktop_frame.h"
|
|
|
|
namespace webrtc {
|
|
|
|
class DisplayStreamManager;
|
|
|
|
// A class to perform video frame capturing for mac.
|
|
class ScreenCapturerMac final : public DesktopCapturer {
|
|
public:
|
|
explicit ScreenCapturerMac(
|
|
rtc::scoped_refptr<DesktopConfigurationMonitor> desktop_config_monitor,
|
|
bool detect_updated_region);
|
|
~ScreenCapturerMac() override;
|
|
|
|
// TODO(julien.isorce): Remove Init() or make it private.
|
|
bool Init();
|
|
|
|
// DesktopCapturer interface.
|
|
void Start(Callback* callback) override;
|
|
void CaptureFrame() override;
|
|
void SetExcludedWindow(WindowId window) override;
|
|
bool GetSourceList(SourceList* screens) override;
|
|
bool SelectSource(SourceId id) override;
|
|
|
|
private:
|
|
// Returns false if the selected screen is no longer valid.
|
|
bool CgBlit(const DesktopFrame& frame, const DesktopRegion& region);
|
|
|
|
// Called when the screen configuration is changed.
|
|
void ScreenConfigurationChanged();
|
|
|
|
bool RegisterRefreshAndMoveHandlers();
|
|
void UnregisterRefreshAndMoveHandlers();
|
|
|
|
void ScreenRefresh(CGRectCount count,
|
|
const CGRect* rect_array,
|
|
DesktopVector display_origin);
|
|
void ReleaseBuffers();
|
|
|
|
std::unique_ptr<DesktopFrame> CreateFrame();
|
|
|
|
const bool detect_updated_region_;
|
|
|
|
Callback* callback_ = nullptr;
|
|
|
|
// Queue of the frames buffers.
|
|
ScreenCaptureFrameQueue<SharedDesktopFrame> queue_;
|
|
|
|
// Current display configuration.
|
|
MacDesktopConfiguration desktop_config_;
|
|
|
|
// 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;
|
|
|
|
// 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;
|
|
|
|
// A thread-safe list of invalid rectangles, and the size of the most
|
|
// recently captured screen.
|
|
ScreenCapturerHelper helper_;
|
|
|
|
// Contains an invalid region from the previous capture.
|
|
DesktopRegion last_invalid_region_;
|
|
|
|
// Monitoring display reconfiguration.
|
|
rtc::scoped_refptr<DesktopConfigurationMonitor> desktop_config_monitor_;
|
|
|
|
CGWindowID excluded_window_ = 0;
|
|
|
|
// A self-owned object that will destroy itself after ScreenCapturerMac and
|
|
// all display streams have been destroyed..
|
|
DisplayStreamManager* display_stream_manager_;
|
|
|
|
RTC_DISALLOW_COPY_AND_ASSIGN(ScreenCapturerMac);
|
|
};
|
|
|
|
} // namespace webrtc
|
|
|
|
#endif // MODULES_DESKTOP_CAPTURE_MAC_SCREEN_CAPTURER_MAC_H_
|