Bug 1409018 - Remove ifdefs for OS X 10.7 from webrtc; r=pehrsons

MozReview-Commit-ID: Ahc7KPlY8uW

--HG--
extra : rebase_source : e1038ef18daf2f6e680a2c54aeaedcb179eaf671
This commit is contained in:
Dan Minor 2018-06-05 08:11:56 -04:00
Родитель 7566d43604
Коммит 33e28e7269
3 изменённых файлов: 0 добавлений и 167 удалений

Просмотреть файл

@ -31,11 +31,6 @@
#ifdef WEBRTC_MAC
#include <AvailabilityMacros.h>
#endif
#if defined(MAC_OS_X_VERSION_10_8) && \
(MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8)
// XXX not available in Mac 10.7 SDK
#include "webrtc/common_video/include/corevideo_frame_buffer.h"
#endif
@ -1907,16 +1902,12 @@ WebrtcVideoConduit::SendVideoFrame(const webrtc::VideoFrame& frame)
buffer = frame.video_frame_buffer();
// XXX Bug 1367651 - Use nativehandles where possible instead of software scaling
#ifdef WEBRTC_MAC
#if defined(MAC_OS_X_VERSION_10_8) && \
(MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8)
// XXX not available in Mac 10.7 SDK
// code adapted from objvideotracksource.mm
} else if (frame.video_frame_buffer()->native_handle()) {
// Adapted CVPixelBuffer frame.
buffer = new rtc::RefCountedObject<webrtc::CoreVideoFrameBuffer>(
static_cast<CVPixelBufferRef>(frame.video_frame_buffer()->native_handle()), adapted_width, adapted_height,
crop_width, crop_height, crop_x, crop_y);
#endif
#elif WEBRTC_WIN
// XX FIX
#elif WEBRTC_LINUX

Просмотреть файл

@ -16,16 +16,6 @@
#include "webrtc/system_wrappers/include/logging.h"
#if !defined(MAC_OS_X_VERSION_10_7) || \
MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_7
@interface NSScreen (LionAPI)
- (CGFloat)backingScaleFactor;
- (NSRect)convertRectToBacking:(NSRect)aRect;
@end
#endif // MAC_OS_X_VERSION_10_7
namespace webrtc {
namespace {

Просмотреть файл

@ -16,11 +16,7 @@
#include <ApplicationServices/ApplicationServices.h>
#include <Cocoa/Cocoa.h>
#if defined(MAC_OS_X_VERSION_10_8) && \
MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8
// 10.8 and above
#include <CoreGraphics/CoreGraphics.h>
#endif
#include <dlfcn.h>
#include <IOKit/pwr_mgt/IOPMLib.h>
#include <OpenGL/CGLMacro.h>
@ -48,8 +44,6 @@
// preprocessor block can be removed. https://crbug.com/579255
#if !defined(MAC_OS_X_VERSION_10_9) || \
MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_9
#if defined(MAC_OS_X_VERSION_10_8) && \
MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8
CG_EXTERN const CGRect* CGDisplayStreamUpdateGetRects(
CGDisplayStreamUpdateRef updateRef,
CGDisplayStreamUpdateRectType rectType,
@ -66,14 +60,11 @@ CGDisplayStreamCreate(CGDirectDisplayID display,
CFDictionaryRef properties,
CGDisplayStreamFrameAvailableHandler handler);
#endif
#endif
namespace webrtc {
namespace {
#if defined(MAC_OS_X_VERSION_10_8) && \
(MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8)
// CGDisplayStreamRefs need to be destroyed asynchronously after receiving a
// kCGDisplayStreamFrameStatusStopped callback from CoreGraphics. This may
// happen after the ScreenCapturerMac has been destroyed. DisplayStreamManager
@ -140,7 +131,6 @@ class DisplayStreamManager {
int unique_id_generator_ = 0;
bool ready_for_self_destruction_ = false;
};
#endif
// Definitions used to dynamic-link to deprecated OS 10.6 functions.
const char* kApplicationServicesLibraryName =
@ -320,28 +310,6 @@ class ScreenCapturerMac : public DesktopCapturer {
void ScreenRefresh(CGRectCount count, const CGRect *rect_array);
void ReleaseBuffers();
#if !defined(MAC_OS_X_VERSION_10_8) || \
(MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_8)
void ScreenUpdateMove(CGScreenUpdateMoveDelta delta,
size_t count,
const CGRect *rect_array);
static void ScreenRefreshCallback(CGRectCount count,
const CGRect *rect_array,
void *user_parameter);
static void ScreenUpdateMoveCallback(CGScreenUpdateMoveDelta delta,
size_t count,
const CGRect *rect_array,
void *user_parameter);
struct ScreenCallbackData {
explicit ScreenCallbackData(ScreenCapturerMac* capturer)
: capturer(capturer) {}
rtc::CriticalSection crit_sect_;
ScreenCapturerMac* capturer;
};
ScreenCallbackData* screen_callback_data_;
#endif
std::unique_ptr<DesktopFrame> CreateFrame();
Callback* callback_ = nullptr;
@ -391,12 +359,9 @@ class ScreenCapturerMac : public DesktopCapturer {
CGWindowID excluded_window_ = 0;
#if defined(MAC_OS_X_VERSION_10_8) && \
(MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8)
// A self-owned object that will destroy itself after ScreenCapturerMac and
// all display streams have been destroyed..
DisplayStreamManager* display_stream_manager_;
#endif
RTC_DISALLOW_COPY_AND_ASSIGN(ScreenCapturerMac);
};
@ -427,25 +392,12 @@ class InvertedDesktopFrame : public DesktopFrame {
ScreenCapturerMac::ScreenCapturerMac(
rtc::scoped_refptr<DesktopConfigurationMonitor> desktop_config_monitor)
: desktop_config_monitor_(desktop_config_monitor) {
#if defined(MAC_OS_X_VERSION_10_8) && \
(MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8)
display_stream_manager_ = new DisplayStreamManager;
#else
screen_callback_data_ = new ScreenCallbackData(this);
#endif
}
ScreenCapturerMac::~ScreenCapturerMac() {
ReleaseBuffers();
#if defined(MAC_OS_X_VERSION_10_8) && \
(MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8)
display_stream_manager_->PrepareForSelfDestruction();
#else
{
rtc::CritScope lock(&screen_callback_data_->crit_sect_);
screen_callback_data_->capturer = nullptr;
}
#endif
dlclose(app_services_library_);
dlclose(opengl_library_);
}
@ -997,8 +949,6 @@ void ScreenCapturerMac::ScreenConfigurationChanged() {
}
bool ScreenCapturerMac::RegisterRefreshAndMoveHandlers() {
#if defined(MAC_OS_X_VERSION_10_8) && \
(MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8)
desktop_config_ = desktop_config_monitor_->desktop_configuration();
for (const auto& config : desktop_config_.displays) {
size_t pixel_width = config.pixel_bounds.width();
@ -1047,35 +997,12 @@ bool ScreenCapturerMac::RegisterRefreshAndMoveHandlers() {
display_stream_manager_->SaveStream(unique_id, display_stream);
}
}
#else
CGError err = CGRegisterScreenRefreshCallback(
ScreenCapturerMac::ScreenRefreshCallback, screen_callback_data_);
if (err != kCGErrorSuccess) {
LOG(LS_ERROR) << "CGRegisterScreenRefreshCallback " << err;
return false;
}
err = CGScreenRegisterMoveCallback(
ScreenCapturerMac::ScreenUpdateMoveCallback, screen_callback_data_);
if (err != kCGErrorSuccess) {
LOG(LS_ERROR) << "CGScreenRegisterMoveCallback " << err;
return false;
}
#endif
return true;
}
void ScreenCapturerMac::UnregisterRefreshAndMoveHandlers() {
#if defined(MAC_OS_X_VERSION_10_8) && \
(MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8)
display_stream_manager_->UnregisterActiveStreams();
#else
CGUnregisterScreenRefreshCallback(
ScreenCapturerMac::ScreenRefreshCallback, this);
CGScreenUnregisterMoveCallback(
ScreenCapturerMac::ScreenUpdateMoveCallback, this);
#endif
}
void ScreenCapturerMac::ScreenRefresh(CGRectCount count,
@ -1084,8 +1011,6 @@ void ScreenCapturerMac::ScreenRefresh(CGRectCount count,
ScreenConfigurationChanged();
DesktopRegion region;
#if defined(MAC_OS_X_VERSION_10_8) && \
(MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8)
for (CGRectCount i = 0; i < count; ++i) {
// All rects are already in physical pixel coordinates.
DesktopRect rect = DesktopRect::MakeXYWH(
@ -1093,82 +1018,9 @@ void ScreenCapturerMac::ScreenRefresh(CGRectCount count,
rect_array[i].size.width, rect_array[i].size.height);
region.AddRect(rect);
}
#else
DesktopVector translate_vector =
DesktopVector().subtract(screen_pixel_bounds_.top_left());
for (CGRectCount i = 0; i < count; ++i) {
// Convert from Density-Independent Pixel to physical pixel coordinates.
DesktopRect rect = ScaleAndRoundCGRect(rect_array[i], dip_to_pixel_scale_);
// Translate from local desktop to capturer framebuffer coordinates.
rect.Translate(translate_vector);
region.AddRect(rect);
}
#endif
helper_.InvalidateRegion(region);
}
#if !defined(MAC_OS_X_VERSION_10_8) || \
(MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_8)
void ScreenCapturerMac::ScreenUpdateMove(CGScreenUpdateMoveDelta delta,
size_t count,
const CGRect* rect_array) {
// Translate |rect_array| to identify the move's destination.
CGRect refresh_rects[count];
for (CGRectCount i = 0; i < count; ++i) {
refresh_rects[i] = CGRectOffset(rect_array[i], delta.dX, delta.dY);
}
// Currently we just treat move events the same as refreshes.
ScreenRefresh(count, refresh_rects);
}
void ScreenCapturerMac::ScreenRefreshCallback(CGRectCount count,
const CGRect* rect_array,
void* user_parameter) {
ScreenCallbackData* screen_callback_data =
reinterpret_cast<ScreenCallbackData*>(user_parameter);
screen_callback_data->crit_sect_.Enter();
if (!screen_callback_data->capturer) {
CGUnregisterScreenRefreshCallback(
ScreenCapturerMac::ScreenRefreshCallback, screen_callback_data);
CGScreenUnregisterMoveCallback(
ScreenCapturerMac::ScreenUpdateMoveCallback, screen_callback_data);
screen_callback_data->crit_sect_.Leave();
delete screen_callback_data;
return;
}
if (screen_callback_data->capturer->screen_pixel_bounds_.is_empty())
screen_callback_data->capturer->ScreenConfigurationChanged();
screen_callback_data->capturer->ScreenRefresh(count, rect_array);
screen_callback_data->crit_sect_.Leave();
}
void ScreenCapturerMac::ScreenUpdateMoveCallback(
CGScreenUpdateMoveDelta delta,
size_t count,
const CGRect* rect_array,
void* user_parameter) {
ScreenCallbackData* screen_callback_data =
reinterpret_cast<ScreenCallbackData*>(user_parameter);
screen_callback_data->crit_sect_.Enter();
if (!screen_callback_data->capturer) {
CGUnregisterScreenRefreshCallback(
ScreenCapturerMac::ScreenRefreshCallback, screen_callback_data);
CGScreenUnregisterMoveCallback(
ScreenCapturerMac::ScreenUpdateMoveCallback, screen_callback_data);
screen_callback_data->crit_sect_.Leave();
delete screen_callback_data;
return;
}
screen_callback_data->capturer->ScreenUpdateMove(delta, count, rect_array);
screen_callback_data->crit_sect_.Leave();
}
#endif
std::unique_ptr<DesktopFrame> ScreenCapturerMac::CreateFrame() {
std::unique_ptr<DesktopFrame> frame(
new BasicDesktopFrame(screen_pixel_bounds_.size()));