1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Implemented listing and setting video modes on Mac OS X

This commit is contained in:
Andrew Novikov 2015-12-21 00:50:51 +03:00 committed by tux3
parent 9d43062639
commit cc64db3f27
No known key found for this signature in database
GPG Key ID: 7E086DD661263264
3 changed files with 41 additions and 2 deletions

View File

@ -160,7 +160,7 @@ win32 {
QMAKE_INFO_PLIST = osx/info.plist QMAKE_INFO_PLIST = osx/info.plist
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7 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 += -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 LIBS += -framework AVFoundation -framework Foundation -framework CoreMedia
LIBS += -lqrencode -lsqlcipher LIBS += -lqrencode -lsqlcipher
contains(DEFINES, QTOX_PLATFORM_EXT) { LIBS += -framework IOKit -framework CoreFoundation } contains(DEFINES, QTOX_PLATFORM_EXT) { LIBS += -framework IOKit -framework CoreFoundation }
contains(DEFINES, QTOX_FILTER_AUDIO) { LIBS += -lfilteraudio } contains(DEFINES, QTOX_FILTER_AUDIO) { LIBS += -lfilteraudio }

View File

@ -28,7 +28,7 @@ QVector<QPair<QString, QString> > avfoundation::getDeviceList()
NSArray* devices = [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo]; NSArray* devices = [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo];
for (AVCaptureDevice* device in devices) { for (AVCaptureDevice* device in devices) {
result.append({ QString::number([devices indexOfObject:device]), [[device localizedName] UTF8String] }); result.append({ QString::fromUtf8([[device uniqueID] UTF8String]), QString::fromUtf8([[device localizedName] UTF8String]) });
} }
return result; return result;
@ -38,5 +38,33 @@ QVector<VideoMode> avfoundation::getDeviceModes(QString devName)
{ {
QVector<VideoMode> result; QVector<VideoMode> result;
NSArray* devices = [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo];
AVCaptureDevice* device = nil;
for (AVCaptureDevice* dev in devices) {
if (devName == QString::fromUtf8([[dev uniqueID] UTF8String])) {
device = dev;
break;
}
}
if (device == nil) {
return result;
}
for (AVCaptureDeviceFormat* format in [device formats]) {
CMFormatDescriptionRef formatDescription;
CMVideoDimensions dimensions;
formatDescription = (CMFormatDescriptionRef)[format performSelector:@selector(formatDescription)];
dimensions = CMVideoFormatDescriptionGetDimensions(formatDescription);
for (AVFrameRateRange* range in format.videoSupportedFrameRateRanges) {
VideoMode mode;
mode.width = dimensions.width;
mode.height = dimensions.height;
mode.FPS = range.maxFrameRate;
result.append(mode);
}
}
return result; return result;
} }

View File

@ -165,6 +165,13 @@ CameraDevice* CameraDevice::open(QString devName, VideoMode mode)
av_dict_set(&options, "video_size", QString("%1x%2").arg(mode.width).arg(mode.height).toStdString().c_str(), 0); 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); av_dict_set(&options, "framerate", QString().setNum(mode.FPS).toStdString().c_str(), 0);
} }
#endif
#ifdef Q_OS_OSX
else if (iformat->name == QString("avfoundation") && 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);
}
#endif #endif
else if (mode) else if (mode)
{ {
@ -331,6 +338,10 @@ QVector<VideoMode> CameraDevice::getVideoModes(QString devName)
#ifdef Q_OS_LINUX #ifdef Q_OS_LINUX
else if (iformat->name == QString("video4linux2,v4l2")) else if (iformat->name == QString("video4linux2,v4l2"))
return v4l2::getDeviceModes(devName); return v4l2::getDeviceModes(devName);
#endif
#ifdef Q_OS_OSX
else if (iformat->name == QString("avfoundation"))
return avfoundation::getDeviceModes(devName);
#endif #endif
else else
qWarning() << "Video mode listing not implemented for input "<<iformat->name; qWarning() << "Video mode listing not implemented for input "<<iformat->name;