Use AVFoundation to request media permissions on start if there are not accepted.

This commit is contained in:
Julien Wadel 2020-04-07 15:37:07 +02:00
parent 5182bc6921
commit 0e8d3e06b6
6 changed files with 17 additions and 1 deletions

View file

@ -218,6 +218,7 @@ if (APPLE)
src/app/single-application/SingleApplication.cpp
src/components/core/event-count-notifier/EventCountNotifierMacOs.m
src/components/other/desktop-tools/DesktopToolsMacOs.cpp
src/components/other/desktop-tools/DesktopToolsMacOs.mm
src/components/other/desktop-tools/screen-saver/ScreenSaverMacOs.m
src/components/other/desktop-tools/state-process/StateProcessMacOs.mm
)
@ -435,7 +436,7 @@ foreach (package ${QT5_PACKAGES_OPTIONAL})
endforeach ()
if (APPLE)
list(APPEND LIBRARIES "-framework Cocoa -framework IOKit")
list(APPEND LIBRARIES "-framework Cocoa -framework IOKit -framework AVFoundation")
# -framework linphone") #This doesn't work yet
endif ()

View file

@ -209,6 +209,7 @@ App::App (int &argc, char *argv[]) : SingleApplication(argc, argv, true, Mode::U
qInfo() << QStringLiteral("Starting " APPLICATION_NAME " (bin: " EXECUTABLE_NAME ")");
qInfo() << QStringLiteral("Use locale: %1").arg(mLocale);
DesktopTools::initialize();
}
App::~App () {

View file

@ -38,6 +38,7 @@ public:
bool getScreenSaverStatus () const;
void setScreenSaverStatus (bool status);
static void initialization(){}
static void applicationStateChanged(Qt::ApplicationState){};
signals:

View file

@ -36,8 +36,10 @@ public:
bool getScreenSaverStatus () const;
void setScreenSaverStatus (bool status);
static void initialize(); // Do first initialization
static void applicationStateChanged(Qt::ApplicationState currentState);
signals:
void screenSaverStatusChanged (bool status);

View file

@ -0,0 +1,10 @@
#include "DesktopToolsMacOs.hpp"
#import <AVFoundation/AVFoundation.h>
void DesktopTools::initialize(){
// Request permissions
if([AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo] != AVAuthorizationStatusAuthorized)
[AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL) {}];
if([AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeAudio] != AVAuthorizationStatusAuthorized)
[AVCaptureDevice requestAccessForMediaType:AVMediaTypeAudio completionHandler:^(BOOL) {}];
}

View file

@ -37,6 +37,7 @@ public:
bool getScreenSaverStatus () const;
void setScreenSaverStatus (bool status);
static void initialization(){}
static void applicationStateChanged(Qt::ApplicationState){};
signals: