mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Implemented screen capturing support for Mac OS X
This commit is contained in:
parent
bd8a2c84ef
commit
985def25ff
2
qtox.pro
2
qtox.pro
|
@ -160,7 +160,7 @@ win32 {
|
|||
QMAKE_INFO_PLIST = osx/info.plist
|
||||
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7
|
||||
LIBS += -L$$PWD/libs/lib/ -ltoxcore -ltoxav -ltoxencryptsave -ltoxdns -lsodium -lvpx -lopus -framework OpenAL -lavformat -lavdevice -lavcodec -lavutil -lswscale -mmacosx-version-min=10.7
|
||||
LIBS += -framework AVFoundation -framework Foundation -framework CoreMedia
|
||||
LIBS += -framework AVFoundation -framework Foundation -framework CoreMedia -framework ApplicationServices
|
||||
LIBS += -lqrencode -lsqlcipher
|
||||
contains(DEFINES, QTOX_PLATFORM_EXT) { LIBS += -framework IOKit -framework CoreFoundation }
|
||||
contains(DEFINES, QTOX_FILTER_AUDIO) { LIBS += -lfilteraudio }
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
|
||||
namespace avfoundation
|
||||
{
|
||||
const QString CAPTURE_SCREEN{"Capture screen"};
|
||||
|
||||
QVector<VideoMode> getDeviceModes(QString devName);
|
||||
QVector<QPair<QString, QString>> getDeviceList();
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
*/
|
||||
|
||||
#include "avfoundation.h"
|
||||
#include <QObject>
|
||||
|
||||
#import <AVFoundation/AVFoundation.h>
|
||||
|
||||
|
@ -31,6 +32,16 @@ QVector<QPair<QString, QString> > avfoundation::getDeviceList()
|
|||
result.append({ QString::fromNSString([device uniqueID]), QString::fromNSString([device localizedName]) });
|
||||
}
|
||||
|
||||
uint32_t numScreens = 0;
|
||||
CGGetActiveDisplayList(0, NULL, &numScreens);
|
||||
if (numScreens > 0) {
|
||||
CGDirectDisplayID screens[numScreens];
|
||||
CGGetActiveDisplayList(numScreens, screens, &numScreens);
|
||||
for (uint32_t i = 0; i < numScreens; i++) {
|
||||
result.append({ QString("%1 %2").arg(CAPTURE_SCREEN).arg(i), QObject::tr("Capture screen %1").arg(i) });
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -38,6 +49,10 @@ QVector<VideoMode> avfoundation::getDeviceModes(QString devName)
|
|||
{
|
||||
QVector<VideoMode> result;
|
||||
|
||||
if (devName.startsWith(CAPTURE_SCREEN)) {
|
||||
return result;
|
||||
}
|
||||
else {
|
||||
NSString* deviceName = [NSString stringWithCString:devName.toUtf8() encoding:NSUTF8StringEncoding];
|
||||
AVCaptureDevice* device = [AVCaptureDevice deviceWithUniqueID:deviceName];
|
||||
|
||||
|
@ -59,6 +74,7 @@ QVector<VideoMode> avfoundation::getDeviceModes(QString devName)
|
|||
result.append(mode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -167,11 +167,20 @@ CameraDevice* CameraDevice::open(QString devName, VideoMode mode)
|
|||
}
|
||||
#endif
|
||||
#ifdef Q_OS_OSX
|
||||
else if (iformat->name == QString("avfoundation") && mode)
|
||||
else if (iformat->name == QString("avfoundation"))
|
||||
{
|
||||
if (mode)
|
||||
{
|
||||
av_dict_set(&options, "video_size", QString("%1x%2").arg(mode.width).arg(mode.height).toStdString().c_str(), 0);
|
||||
av_dict_set(&options, "framerate", QString().setNum(mode.FPS).toStdString().c_str(), 0);
|
||||
}
|
||||
else if (devName.startsWith(avfoundation::CAPTURE_SCREEN))
|
||||
{
|
||||
av_dict_set(&options, "framerate", QString().setNum(5).toStdString().c_str(), 0);
|
||||
av_dict_set_int(&options, "capture_cursor", 1, 0);
|
||||
av_dict_set_int(&options, "capture_mouse_clicks", 1, 0);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
else if (mode)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user