diff options
Diffstat (limited to 'src/plugins')
14 files changed, 216 insertions, 473 deletions
diff --git a/src/plugins/avfoundation/camera/avfcameraservice.mm b/src/plugins/avfoundation/camera/avfcameraservice.mm index a1213be3b..7fd04250e 100644 --- a/src/plugins/avfoundation/camera/avfcameraservice.mm +++ b/src/plugins/avfoundation/camera/avfcameraservice.mm @@ -37,9 +37,9 @@ ** ****************************************************************************/ +#include <QtCore/qoperatingsystemversion.h> #include <QtCore/qvariant.h> #include <QtCore/qdebug.h> -#include <QtCore/qsysinfo.h> #include "avfcameraservice.h" #include "avfcameracontrol.h" @@ -96,7 +96,7 @@ AVFCameraService::AVFCameraService(QObject *parent): m_cameraFocusControl = new AVFCameraFocusControl(this); m_cameraExposureControl = 0; #if defined(Q_OS_IOS) && QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_8_0) - if (QSysInfo::MacintoshVersion >= QSysInfo::MV_IOS_8_0) + if (QOperatingSystemVersion::current() >= QOperatingSystemVersion(QOperatingSystemVersion::IOS, 8)) m_cameraExposureControl = new AVFCameraExposureControl(this); #endif diff --git a/src/plugins/avfoundation/camera/avfcamerasession.mm b/src/plugins/avfoundation/camera/avfcamerasession.mm index c32b072ef..0b7c0e9d8 100644 --- a/src/plugins/avfoundation/camera/avfcamerasession.mm +++ b/src/plugins/avfoundation/camera/avfcamerasession.mm @@ -432,18 +432,12 @@ void AVFCameraSession::removeProbe(AVFMediaVideoProbeControl *probe) FourCharCode AVFCameraSession::defaultCodec() { if (!m_defaultCodec) { -#if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_7, __IPHONE_7_0) - if (QSysInfo::MacintoshVersion >= qt_OS_limit(QSysInfo::MV_10_7, QSysInfo::MV_IOS_7_0)) { - if (AVCaptureDevice *device = videoCaptureDevice()) { - AVCaptureDeviceFormat *format = device.activeFormat; - if (!format || !format.formatDescription) - return m_defaultCodec; - m_defaultCodec = CMVideoFormatDescriptionGetCodecType(format.formatDescription); - } + if (AVCaptureDevice *device = videoCaptureDevice()) { + AVCaptureDeviceFormat *format = device.activeFormat; + if (!format || !format.formatDescription) + return m_defaultCodec; + m_defaultCodec = CMVideoFormatDescriptionGetCodecType(format.formatDescription); } -#else - // TODO: extract media subtype. -#endif } return m_defaultCodec; } diff --git a/src/plugins/avfoundation/camera/avfcamerautility.h b/src/plugins/avfoundation/camera/avfcamerautility.h index 4da5f751e..ba1bd3861 100644 --- a/src/plugins/avfoundation/camera/avfcamerautility.h +++ b/src/plugins/avfoundation/camera/avfcamerautility.h @@ -40,7 +40,6 @@ #ifndef AVFCAMERAUTILITY_H #define AVFCAMERAUTILITY_H -#include <QtCore/qsysinfo.h> #include <QtCore/qglobal.h> #include <QtCore/qvector.h> #include <QtCore/qdebug.h> @@ -152,23 +151,9 @@ private: Q_DISABLE_COPY(AVFScopedPointer); }; -inline QSysInfo::MacVersion qt_OS_limit(QSysInfo::MacVersion osxVersion, - QSysInfo::MacVersion iosVersion) -{ -#ifdef Q_OS_OSX - Q_UNUSED(iosVersion) - return osxVersion; -#else - Q_UNUSED(osxVersion) - return iosVersion; -#endif -} - typedef QPair<qreal, qreal> AVFPSRange; AVFPSRange qt_connection_framerates(AVCaptureConnection *videoConnection); -#if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_7, __IPHONE_7_0) - QVector<AVCaptureDeviceFormat *> qt_unique_device_formats(AVCaptureDevice *captureDevice, FourCharCode preferredFormat); QSize qt_device_format_resolution(AVCaptureDeviceFormat *format); @@ -185,8 +170,6 @@ AVFrameRateRange *qt_find_supported_framerate_range(AVCaptureDeviceFormat *forma bool qt_formats_are_equal(AVCaptureDeviceFormat *f1, AVCaptureDeviceFormat *f2); bool qt_set_active_format(AVCaptureDevice *captureDevice, AVCaptureDeviceFormat *format, bool preserveFps); -#endif - AVFPSRange qt_current_framerates(AVCaptureDevice *captureDevice, AVCaptureConnection *videoConnection); void qt_set_framerate_limits(AVCaptureDevice *captureDevice, AVCaptureConnection *videoConnection, qreal minFPS, qreal maxFPS); diff --git a/src/plugins/avfoundation/camera/avfcamerautility.mm b/src/plugins/avfoundation/camera/avfcamerautility.mm index 279642e4f..872075e0f 100644 --- a/src/plugins/avfoundation/camera/avfcamerautility.mm +++ b/src/plugins/avfoundation/camera/avfcamerautility.mm @@ -40,6 +40,7 @@ #include "avfcamerautility.h" #include "avfcameradebug.h" +#include <QtCore/qoperatingsystemversion.h> #include <QtCore/qvector.h> #include <QtCore/qpair.h> #include <private/qmultimediautils_p.h> @@ -66,26 +67,17 @@ AVFPSRange qt_connection_framerates(AVCaptureConnection *videoConnection) } } -#if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_9, __IPHONE_5_0) -#if QT_OSX_DEPLOYMENT_TARGET_BELOW(__MAC_10_9) - if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_9) -#endif - { - if (videoConnection.supportsVideoMaxFrameDuration) { - const CMTime cmMax = videoConnection.videoMaxFrameDuration; - if (CMTimeCompare(cmMax, kCMTimeInvalid)) { - if (const Float64 maxSeconds = CMTimeGetSeconds(cmMax)) - newRange.first = 1. / maxSeconds; - } + if (videoConnection.supportsVideoMaxFrameDuration) { + const CMTime cmMax = videoConnection.videoMaxFrameDuration; + if (CMTimeCompare(cmMax, kCMTimeInvalid)) { + if (const Float64 maxSeconds = CMTimeGetSeconds(cmMax)) + newRange.first = 1. / maxSeconds; } } -#endif return newRange; } -#if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_7, __IPHONE_7_0) - namespace { inline bool qt_area_sane(const QSize &size) @@ -189,7 +181,7 @@ QSize qt_device_format_high_resolution(AVCaptureDeviceFormat *format) Q_ASSERT(format); QSize res; #if defined(Q_OS_IOS) && QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_8_0) - if (QSysInfo::MacintoshVersion >= QSysInfo::MV_IOS_8_0) { + if (QOperatingSystemVersion::current() >= QOperatingSystemVersion(QOperatingSystemVersion::IOS, 8)) { const CMVideoDimensions hrDim(format.highResolutionStillImageDimensions); res.setWidth(hrDim.width); res.setHeight(hrDim.height); @@ -436,8 +428,6 @@ bool qt_set_active_format(AVCaptureDevice *captureDevice, AVCaptureDeviceFormat return true; } -#endif // SDK - void qt_set_framerate_limits(AVCaptureConnection *videoConnection, qreal minFPS, qreal maxFPS) { Q_ASSERT(videoConnection); @@ -458,32 +448,17 @@ void qt_set_framerate_limits(AVCaptureConnection *videoConnection, qreal minFPS, if (videoConnection.supportsVideoMinFrameDuration) videoConnection.videoMinFrameDuration = minDuration; -#if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_9, __IPHONE_5_0) -#if QT_OSX_DEPLOYMENT_TARGET_BELOW(__MAC_10_9) - if (QSysInfo::MacintoshVersion < QSysInfo::MV_10_9) { - if (minFPS > 0.) + CMTime maxDuration = kCMTimeInvalid; + if (minFPS > 0.) { + if (!videoConnection.supportsVideoMaxFrameDuration) qDebugCamera() << Q_FUNC_INFO << "minimum framerate is not supported"; - } else -#endif - { - CMTime maxDuration = kCMTimeInvalid; - if (minFPS > 0.) { - if (!videoConnection.supportsVideoMaxFrameDuration) - qDebugCamera() << Q_FUNC_INFO << "minimum framerate is not supported"; - else - maxDuration = CMTimeMake(1, minFPS); - } - if (videoConnection.supportsVideoMaxFrameDuration) - videoConnection.videoMaxFrameDuration = maxDuration; + else + maxDuration = CMTimeMake(1, minFPS); } -#else - if (minFPS > 0.) - qDebugCamera() << Q_FUNC_INFO << "minimum framerate is not supported"; -#endif + if (videoConnection.supportsVideoMaxFrameDuration) + videoConnection.videoMaxFrameDuration = maxDuration; } -#if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_7, __IPHONE_7_0) - CMTime qt_adjusted_frame_duration(AVFrameRateRange *range, qreal fps) { Q_ASSERT(range); @@ -549,7 +524,7 @@ void qt_set_framerate_limits(AVCaptureDevice *captureDevice, qreal minFPS, qreal #ifdef Q_OS_IOS [captureDevice setActiveVideoMinFrameDuration:minFrameDuration]; [captureDevice setActiveVideoMaxFrameDuration:maxFrameDuration]; -#else // Q_OS_OSX +#elif defined(Q_OS_MACOS) if (CMTimeCompare(minFrameDuration, kCMTimeInvalid) == 0 && CMTimeCompare(maxFrameDuration, kCMTimeInvalid) == 0) { AVFrameRateRange *range = captureDevice.activeFormat.videoSupportedFrameRateRanges.firstObject; @@ -560,32 +535,16 @@ void qt_set_framerate_limits(AVCaptureDevice *captureDevice, qreal minFPS, qreal if (CMTimeCompare(minFrameDuration, kCMTimeInvalid)) [captureDevice setActiveVideoMinFrameDuration:minFrameDuration]; -#if QT_OSX_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_9) -#if QT_OSX_DEPLOYMENT_TARGET_BELOW(__MAC_10_9) - if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_9) -#endif - { - if (CMTimeCompare(maxFrameDuration, kCMTimeInvalid)) - [captureDevice setActiveVideoMaxFrameDuration:maxFrameDuration]; - } -#endif // QT_OSX_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_9) -#endif // Q_OS_OSX + if (CMTimeCompare(maxFrameDuration, kCMTimeInvalid)) + [captureDevice setActiveVideoMaxFrameDuration:maxFrameDuration]; +#endif // Q_OS_MACOS } -#endif // Platform SDK >= 10.9, >= 7.0. - void qt_set_framerate_limits(AVCaptureDevice *captureDevice, AVCaptureConnection *videoConnection, qreal minFPS, qreal maxFPS) { Q_ASSERT(captureDevice); -#if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_7, __IPHONE_7_0) - if (QSysInfo::MacintoshVersion >= qt_OS_limit(QSysInfo::MV_10_9, QSysInfo::MV_IOS_7_0)) - qt_set_framerate_limits(captureDevice, minFPS, maxFPS); - else -#endif - if (videoConnection) - qt_set_framerate_limits(videoConnection, minFPS, maxFPS); - + qt_set_framerate_limits(captureDevice, minFPS, maxFPS); } AVFPSRange qt_current_framerates(AVCaptureDevice *captureDevice, AVCaptureConnection *videoConnection) @@ -593,33 +552,16 @@ AVFPSRange qt_current_framerates(AVCaptureDevice *captureDevice, AVCaptureConnec Q_ASSERT(captureDevice); AVFPSRange fps; -#if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_7, __IPHONE_7_0) - if (QSysInfo::MacintoshVersion >= qt_OS_limit(QSysInfo::MV_10_7, QSysInfo::MV_IOS_7_0)) { - const CMTime minDuration = captureDevice.activeVideoMinFrameDuration; - if (CMTimeCompare(minDuration, kCMTimeInvalid)) { - if (const Float64 minSeconds = CMTimeGetSeconds(minDuration)) - fps.second = 1. / minSeconds; // Max FPS = 1 / MinDuration. - } - -#if QT_OSX_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_9) -#if QT_OSX_DEPLOYMENT_TARGET_BELOW(__MAC_10_9) - if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_9) -#endif - { - const CMTime maxDuration = captureDevice.activeVideoMaxFrameDuration; - if (CMTimeCompare(maxDuration, kCMTimeInvalid)) { - if (const Float64 maxSeconds = CMTimeGetSeconds(maxDuration)) - fps.first = 1. / maxSeconds; // Min FPS = 1 / MaxDuration. - } - } -#endif // QT_OSX_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_9) + const CMTime minDuration = captureDevice.activeVideoMinFrameDuration; + if (CMTimeCompare(minDuration, kCMTimeInvalid)) { + if (const Float64 minSeconds = CMTimeGetSeconds(minDuration)) + fps.second = 1. / minSeconds; // Max FPS = 1 / MinDuration. + } - } else { -#else // OSX < 10.7 or iOS < 7.0 - { -#endif // QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_7, __IPHONE_7_0) - if (videoConnection) - fps = qt_connection_framerates(videoConnection); + const CMTime maxDuration = captureDevice.activeVideoMaxFrameDuration; + if (CMTimeCompare(maxDuration, kCMTimeInvalid)) { + if (const Float64 maxSeconds = CMTimeGetSeconds(maxDuration)) + fps.first = 1. / maxSeconds; // Min FPS = 1 / MaxDuration. } return fps; diff --git a/src/plugins/avfoundation/camera/avfcameraviewfindersettingscontrol.mm b/src/plugins/avfoundation/camera/avfcameraviewfindersettingscontrol.mm index 23dd2a4aa..0054a8d01 100644 --- a/src/plugins/avfoundation/camera/avfcameraviewfindersettingscontrol.mm +++ b/src/plugins/avfoundation/camera/avfcameraviewfindersettingscontrol.mm @@ -47,7 +47,6 @@ #include <QtMultimedia/qabstractvideosurface.h> #include <QtCore/qvariant.h> -#include <QtCore/qsysinfo.h> #include <QtCore/qvector.h> #include <QtCore/qdebug.h> #include <QtCore/qlist.h> @@ -97,57 +96,36 @@ QList<QCameraViewfinderSettings> AVFCameraViewfinderSettingsControl2::supportedV if (!pixelFormats.size()) pixelFormats << QVideoFrame::Format_Invalid; // The default value. -#if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_7, __IPHONE_7_0) - if (QSysInfo::MacintoshVersion >= qt_OS_limit(QSysInfo::MV_10_7, QSysInfo::MV_IOS_7_0)) { - if (!captureDevice.formats || !captureDevice.formats.count) { - qDebugCamera() << Q_FUNC_INFO << "no capture device formats found"; - return supportedSettings; - } + if (!captureDevice.formats || !captureDevice.formats.count) { + qDebugCamera() << Q_FUNC_INFO << "no capture device formats found"; + return supportedSettings; + } - const QVector<AVCaptureDeviceFormat *> formats(qt_unique_device_formats(captureDevice, - m_service->session()->defaultCodec())); - for (int i = 0; i < formats.size(); ++i) { - AVCaptureDeviceFormat *format = formats[i]; - - const QSize res(qt_device_format_resolution(format)); - if (res.isNull() || !res.isValid()) - continue; - const QSize par(qt_device_format_pixel_aspect_ratio(format)); - if (par.isNull() || !par.isValid()) - continue; - - framerates = qt_device_format_framerates(format); - if (!framerates.size()) - framerates << AVFPSRange(); // The default value. - - for (int i = 0; i < pixelFormats.size(); ++i) { - for (int j = 0; j < framerates.size(); ++j) { - QCameraViewfinderSettings newSet; - newSet.setResolution(res); - newSet.setPixelAspectRatio(par); - newSet.setPixelFormat(pixelFormats[i]); - newSet.setMinimumFrameRate(framerates[j].first); - newSet.setMaximumFrameRate(framerates[j].second); - supportedSettings << newSet; - } - } - } - } else { -#else - { -#endif - AVCaptureConnection *connection = videoConnection(); - if (connection) { - // TODO: resolution and PAR. - framerates << qt_connection_framerates(connection); - for (int i = 0; i < pixelFormats.size(); ++i) { - for (int j = 0; j < framerates.size(); ++j) { - QCameraViewfinderSettings newSet; - newSet.setPixelFormat(pixelFormats[i]); - newSet.setMinimumFrameRate(framerates[j].first); - newSet.setMaximumFrameRate(framerates[j].second); - supportedSettings << newSet; - } + const QVector<AVCaptureDeviceFormat *> formats(qt_unique_device_formats(captureDevice, + m_service->session()->defaultCodec())); + for (int i = 0; i < formats.size(); ++i) { + AVCaptureDeviceFormat *format = formats[i]; + + const QSize res(qt_device_format_resolution(format)); + if (res.isNull() || !res.isValid()) + continue; + const QSize par(qt_device_format_pixel_aspect_ratio(format)); + if (par.isNull() || !par.isValid()) + continue; + + framerates = qt_device_format_framerates(format); + if (!framerates.size()) + framerates << AVFPSRange(); // The default value. + + for (int i = 0; i < pixelFormats.size(); ++i) { + for (int j = 0; j < framerates.size(); ++j) { + QCameraViewfinderSettings newSet; + newSet.setResolution(res); + newSet.setPixelAspectRatio(par); + newSet.setPixelFormat(pixelFormats[i]); + newSet.setMinimumFrameRate(framerates[j].first); + newSet.setMaximumFrameRate(framerates[j].second); + supportedSettings << newSet; } } } @@ -170,25 +148,21 @@ QCameraViewfinderSettings AVFCameraViewfinderSettingsControl2::viewfinderSetting return settings; } -#if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_7, __IPHONE_7_0) - if (QSysInfo::MacintoshVersion >= qt_OS_limit(QSysInfo::MV_10_7, QSysInfo::MV_IOS_7_0)) { - if (!captureDevice.activeFormat) { - qDebugCamera() << Q_FUNC_INFO << "no active capture device format"; - return settings; - } - - const QSize res(qt_device_format_resolution(captureDevice.activeFormat)); - const QSize par(qt_device_format_pixel_aspect_ratio(captureDevice.activeFormat)); - if (res.isNull() || !res.isValid() || par.isNull() || !par.isValid()) { - qDebugCamera() << Q_FUNC_INFO << "failed to obtain resolution/pixel aspect ratio"; - return settings; - } + if (!captureDevice.activeFormat) { + qDebugCamera() << Q_FUNC_INFO << "no active capture device format"; + return settings; + } - settings.setResolution(res); - settings.setPixelAspectRatio(par); + const QSize res(qt_device_format_resolution(captureDevice.activeFormat)); + const QSize par(qt_device_format_pixel_aspect_ratio(captureDevice.activeFormat)); + if (res.isNull() || !res.isValid() || par.isNull() || !par.isValid()) { + qDebugCamera() << Q_FUNC_INFO << "failed to obtain resolution/pixel aspect ratio"; + return settings; } -#endif - // TODO: resolution and PAR before 7.0. + + settings.setResolution(res); + settings.setPixelAspectRatio(par); + const AVFPSRange fps = qt_current_framerates(captureDevice, videoConnection()); settings.setMinimumFrameRate(fps.first); settings.setMaximumFrameRate(fps.second); @@ -285,35 +259,30 @@ AVCaptureDeviceFormat *AVFCameraViewfinderSettingsControl2::findBestFormatMatch( if (!captureDevice || settings.isNull()) return nil; -#if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_7, __IPHONE_7_0) - if (QSysInfo::MacintoshVersion >= qt_OS_limit(QSysInfo::MV_10_7, QSysInfo::MV_IOS_7_0)) { - - const QSize &resolution = settings.resolution(); - if (!resolution.isNull() && resolution.isValid()) { - // Either the exact match (including high resolution for images on iOS) - // or a format with a resolution close to the requested one. - return qt_find_best_resolution_match(captureDevice, resolution, - m_service->session()->defaultCodec()); - } - - // No resolution requested, what about framerates? - if (!qt_framerates_sane(settings)) { - qDebugCamera() << Q_FUNC_INFO << "invalid framerate requested (min/max):" - << settings.minimumFrameRate() << settings.maximumFrameRate(); - return nil; - } + const QSize &resolution = settings.resolution(); + if (!resolution.isNull() && resolution.isValid()) { + // Either the exact match (including high resolution for images on iOS) + // or a format with a resolution close to the requested one. + return qt_find_best_resolution_match(captureDevice, resolution, + m_service->session()->defaultCodec()); + } - const qreal minFPS(settings.minimumFrameRate()); - const qreal maxFPS(settings.maximumFrameRate()); - if (minFPS || maxFPS) - return qt_find_best_framerate_match(captureDevice, - m_service->session()->defaultCodec(), - maxFPS ? maxFPS : minFPS); - // Ignore PAR for the moment (PAR without resolution can - // pick a format with really bad resolution). - // No need to test pixel format, just return settings. + // No resolution requested, what about framerates? + if (!qt_framerates_sane(settings)) { + qDebugCamera() << Q_FUNC_INFO << "invalid framerate requested (min/max):" + << settings.minimumFrameRate() << settings.maximumFrameRate(); + return nil; } -#endif + + const qreal minFPS(settings.minimumFrameRate()); + const qreal maxFPS(settings.maximumFrameRate()); + if (minFPS || maxFPS) + return qt_find_best_framerate_match(captureDevice, + m_service->session()->defaultCodec(), + maxFPS ? maxFPS : minFPS); + // Ignore PAR for the moment (PAR without resolution can + // pick a format with really bad resolution). + // No need to test pixel format, just return settings. return nil; } @@ -395,7 +364,6 @@ bool AVFCameraViewfinderSettingsControl2::applySettings(const QCameraViewfinderS bool activeFormatChanged = false; -#if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_7, __IPHONE_7_0) AVCaptureDeviceFormat *match = findBestFormatMatch(settings); if (match) { activeFormatChanged = qt_set_active_format(captureDevice, match, false); @@ -403,7 +371,6 @@ bool AVFCameraViewfinderSettingsControl2::applySettings(const QCameraViewfinderS qDebugCamera() << Q_FUNC_INFO << "matching device format not found"; // We still can update the pixel format at least. } -#endif AVCaptureVideoDataOutput *videoOutput = m_service->videoOutput() ? m_service->videoOutput()->videoDataOutput() : 0; if (videoOutput) { diff --git a/src/plugins/avfoundation/camera/avfcamerazoomcontrol.mm b/src/plugins/avfoundation/camera/avfcamerazoomcontrol.mm index 2662793f8..47dc736a1 100644 --- a/src/plugins/avfoundation/camera/avfcamerazoomcontrol.mm +++ b/src/plugins/avfoundation/camera/avfcamerazoomcontrol.mm @@ -44,7 +44,6 @@ #include "avfcameracontrol.h" #include "avfcameradebug.h" -#include <QtCore/qsysinfo.h> #include <QtCore/qglobal.h> #include <QtCore/qdebug.h> @@ -98,9 +97,6 @@ void AVFCameraZoomControl::zoomTo(qreal optical, qreal digital) { Q_UNUSED(optical) Q_UNUSED(digital) -#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_7_0) - if (QSysInfo::MacintoshVersion < QSysInfo::MV_IOS_7_0) - return; if (qFuzzyCompare(CGFloat(digital), m_requestedZoomFactor)) return; @@ -109,15 +105,10 @@ void AVFCameraZoomControl::zoomTo(qreal optical, qreal digital) Q_EMIT requestedDigitalZoomChanged(digital); zoomToRequestedDigital(); -#endif } void AVFCameraZoomControl::cameraStateChanged() { -#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_7_0) - if (QSysInfo::MacintoshVersion < QSysInfo::MV_IOS_7_0) - return; - const QCamera::State state = m_session->state(); if (state != QCamera::ActiveState) { if (state == QCamera::UnloadedState && m_maxZoomFactor > 1.) { @@ -146,15 +137,10 @@ void AVFCameraZoomControl::cameraStateChanged() } zoomToRequestedDigital(); -#endif } void AVFCameraZoomControl::zoomToRequestedDigital() { -#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_7_0) - if (QSysInfo::MacintoshVersion < QSysInfo::MV_IOS_7_0) - return; - AVCaptureDevice *captureDevice = m_session->videoCaptureDevice(); if (!captureDevice || !captureDevice.activeFormat) return; @@ -186,7 +172,6 @@ void AVFCameraZoomControl::zoomToRequestedDigital() m_zoomFactor = clampedZoom; Q_EMIT currentDigitalZoomChanged(clampedZoom); } -#endif } QT_END_NAMESPACE diff --git a/src/plugins/avfoundation/camera/avfimageencodercontrol.mm b/src/plugins/avfoundation/camera/avfimageencodercontrol.mm index e5aa8a4c2..8384ce6ae 100644 --- a/src/plugins/avfoundation/camera/avfimageencodercontrol.mm +++ b/src/plugins/avfoundation/camera/avfimageencodercontrol.mm @@ -48,7 +48,7 @@ #include <QtMultimedia/qmediaencodersettings.h> -#include <QtCore/qsysinfo.h> +#include <QtCore/qoperatingsystemversion.h> #include <QtCore/qdebug.h> #include <AVFoundation/AVFoundation.h> @@ -84,36 +84,28 @@ QList<QSize> AVFImageEncoderControl::supportedResolutions(const QImageEncoderSet if (!videoCaptureDeviceIsValid()) return resolutions; -#if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_7, __IPHONE_7_0) - if (QSysInfo::MacintoshVersion >= qt_OS_limit(QSysInfo::MV_10_7, QSysInfo::MV_IOS_7_0)) { - AVCaptureDevice *captureDevice = m_service->session()->videoCaptureDevice(); - const QVector<AVCaptureDeviceFormat *> formats(qt_unique_device_formats(captureDevice, - m_service->session()->defaultCodec())); + AVCaptureDevice *captureDevice = m_service->session()->videoCaptureDevice(); + const QVector<AVCaptureDeviceFormat *> formats(qt_unique_device_formats(captureDevice, + m_service->session()->defaultCodec())); - for (int i = 0; i < formats.size(); ++i) { - AVCaptureDeviceFormat *format = formats[i]; + for (int i = 0; i < formats.size(); ++i) { + AVCaptureDeviceFormat *format = formats[i]; - const QSize res(qt_device_format_resolution(format)); - if (!res.isNull() && res.isValid()) - resolutions << res; + const QSize res(qt_device_format_resolution(format)); + if (!res.isNull() && res.isValid()) + resolutions << res; #if defined(Q_OS_IOS) && QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_8_0) - if (QSysInfo::MacintoshVersion >= QSysInfo::MV_IOS_8_0) { - // From Apple's docs (iOS): - // By default, AVCaptureStillImageOutput emits images with the same dimensions as - // its source AVCaptureDevice instance’s activeFormat.formatDescription. However, - // if you set this property to YES, the receiver emits still images at the capture - // device’s highResolutionStillImageDimensions value. - const QSize hrRes(qt_device_format_high_resolution(format)); - if (!hrRes.isNull() && hrRes.isValid()) - resolutions << res; - } -#endif + if (QOperatingSystemVersion::current() >= QOperatingSystemVersion(QOperatingSystemVersion::IOS, 8)) { + // From Apple's docs (iOS): + // By default, AVCaptureStillImageOutput emits images with the same dimensions as + // its source AVCaptureDevice instance’s activeFormat.formatDescription. However, + // if you set this property to YES, the receiver emits still images at the capture + // device’s highResolutionStillImageDimensions value. + const QSize hrRes(qt_device_format_high_resolution(format)); + if (!hrRes.isNull() && hrRes.isValid()) + resolutions << res; } - } else { -#else - { #endif - // TODO: resolutions without AVCaptureDeviceFormat ... } if (continuous) @@ -134,40 +126,32 @@ QImageEncoderSettings AVFImageEncoderControl::imageSettings() const if (!videoCaptureDeviceIsValid()) return settings; -#if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_7, __IPHONE_7_0) - if (QSysInfo::MacintoshVersion >= qt_OS_limit(QSysInfo::MV_10_7, QSysInfo::MV_IOS_7_0)) { - AVCaptureDevice *captureDevice = m_service->session()->videoCaptureDevice(); - if (!captureDevice.activeFormat) { - qDebugCamera() << Q_FUNC_INFO << "no active format"; - return settings; - } + AVCaptureDevice *captureDevice = m_service->session()->videoCaptureDevice(); + if (!captureDevice.activeFormat) { + qDebugCamera() << Q_FUNC_INFO << "no active format"; + return settings; + } - QSize res(qt_device_format_resolution(captureDevice.activeFormat)); + QSize res(qt_device_format_resolution(captureDevice.activeFormat)); #if defined(Q_OS_IOS) && QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_8_0) - if (QSysInfo::MacintoshVersion >= QSysInfo::MV_IOS_8_0) { - if (!m_service->imageCaptureControl() || !m_service->imageCaptureControl()->stillImageOutput()) { - qDebugCamera() << Q_FUNC_INFO << "no still image output"; - return settings; - } - - AVCaptureStillImageOutput *stillImageOutput = m_service->imageCaptureControl()->stillImageOutput(); - if (stillImageOutput.highResolutionStillImageOutputEnabled) - res = qt_device_format_high_resolution(captureDevice.activeFormat); - } -#endif - if (res.isNull() || !res.isValid()) { - qDebugCamera() << Q_FUNC_INFO << "failed to exctract the image resolution"; + if (QOperatingSystemVersion::current() >= QOperatingSystemVersion(QOperatingSystemVersion::IOS, 8)) { + if (!m_service->imageCaptureControl() || !m_service->imageCaptureControl()->stillImageOutput()) { + qDebugCamera() << Q_FUNC_INFO << "no still image output"; return settings; } - settings.setResolution(res); - } else { -#else - { + AVCaptureStillImageOutput *stillImageOutput = m_service->imageCaptureControl()->stillImageOutput(); + if (stillImageOutput.highResolutionStillImageOutputEnabled) + res = qt_device_format_high_resolution(captureDevice.activeFormat); + } #endif - // TODO: resolution without AVCaptureDeviceFormat. + if (res.isNull() || !res.isValid()) { + qDebugCamera() << Q_FUNC_INFO << "failed to exctract the image resolution"; + return settings; } + settings.setResolution(res); + settings.setCodec(QLatin1String("jpeg")); return settings; @@ -222,34 +206,26 @@ bool AVFImageEncoderControl::applySettings() bool activeFormatChanged = false; -#if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_7, __IPHONE_7_0) - if (QSysInfo::MacintoshVersion >= qt_OS_limit(QSysInfo::MV_10_7, QSysInfo::MV_IOS_7_0)) { - AVCaptureDevice *captureDevice = m_service->session()->videoCaptureDevice(); - AVCaptureDeviceFormat *match = qt_find_best_resolution_match(captureDevice, res, - m_service->session()->defaultCodec()); + AVCaptureDevice *captureDevice = m_service->session()->videoCaptureDevice(); + AVCaptureDeviceFormat *match = qt_find_best_resolution_match(captureDevice, res, + m_service->session()->defaultCodec()); - if (!match) { - qDebugCamera() << Q_FUNC_INFO << "unsupported resolution:" << res; - return false; - } + if (!match) { + qDebugCamera() << Q_FUNC_INFO << "unsupported resolution:" << res; + return false; + } - activeFormatChanged = qt_set_active_format(captureDevice, match, true); + activeFormatChanged = qt_set_active_format(captureDevice, match, true); #if defined(Q_OS_IOS) && QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_8_0) - if (QSysInfo::MacintoshVersion >= QSysInfo::MV_IOS_8_0) { - AVCaptureStillImageOutput *imageOutput = m_service->imageCaptureControl()->stillImageOutput(); - if (res == qt_device_format_high_resolution(captureDevice.activeFormat)) - imageOutput.highResolutionStillImageOutputEnabled = YES; - else - imageOutput.highResolutionStillImageOutputEnabled = NO; - } -#endif - } else { -#else - { -#endif - // TODO: resolution without capture device format ... + if (QOperatingSystemVersion::current() >= QOperatingSystemVersion(QOperatingSystemVersion::IOS, 8)) { + AVCaptureStillImageOutput *imageOutput = m_service->imageCaptureControl()->stillImageOutput(); + if (res == qt_device_format_high_resolution(captureDevice.activeFormat)) + imageOutput.highResolutionStillImageOutputEnabled = YES; + else + imageOutput.highResolutionStillImageOutputEnabled = NO; } +#endif return activeFormatChanged; } diff --git a/src/plugins/avfoundation/camera/avfmediaassetwriter.mm b/src/plugins/avfoundation/camera/avfmediaassetwriter.mm index 28735bc6a..5a1257f6c 100644 --- a/src/plugins/avfoundation/camera/avfmediaassetwriter.mm +++ b/src/plugins/avfoundation/camera/avfmediaassetwriter.mm @@ -47,7 +47,6 @@ #include "avfmediacontainercontrol.h" #include <QtCore/qmetaobject.h> -#include <QtCore/qsysinfo.h> QT_USE_NAMESPACE diff --git a/src/plugins/avfoundation/camera/avfvideoencodersettingscontrol.mm b/src/plugins/avfoundation/camera/avfvideoencodersettingscontrol.mm index b478ba321..bbb16e709 100644 --- a/src/plugins/avfoundation/camera/avfvideoencodersettingscontrol.mm +++ b/src/plugins/avfoundation/camera/avfvideoencodersettingscontrol.mm @@ -56,7 +56,6 @@ Q_GLOBAL_STATIC_WITH_ARGS(QStringList, supportedCodecs, (QStringList() << QLatin #endif )) -#if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_7, __IPHONE_7_0) static bool format_supports_framerate(AVCaptureDeviceFormat *format, qreal fps) { if (format && fps > qreal(0)) { @@ -74,7 +73,6 @@ static bool format_supports_framerate(AVCaptureDeviceFormat *format, qreal fps) return false; } -#endif static bool real_list_contains(const QList<qreal> &list, qreal value) { @@ -107,24 +105,20 @@ QList<QSize> AVFVideoEncoderSettingsControl::supportedResolutions(const QVideoEn QList<QSize> resolutions; resolutions.append(QSize(32, 32)); -#if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_7, __IPHONE_7_0) - if (QSysInfo::MacintoshVersion >= qt_OS_limit(QSysInfo::MV_10_7, QSysInfo::MV_IOS_7_0)) { - AVCaptureDevice *device = m_service->session()->videoCaptureDevice(); - if (device) { - int maximumWidth = 0; - const QVector<AVCaptureDeviceFormat *> formats(qt_unique_device_formats(device, - m_service->session()->defaultCodec())); - for (int i = 0; i < formats.size(); ++i) { - const QSize res(qt_device_format_resolution(formats[i])); - if (res.width() > maximumWidth) - maximumWidth = res.width(); - } - - if (maximumWidth > 0) - resolutions.append(QSize(maximumWidth, maximumWidth)); + AVCaptureDevice *device = m_service->session()->videoCaptureDevice(); + if (device) { + int maximumWidth = 0; + const QVector<AVCaptureDeviceFormat *> formats(qt_unique_device_formats(device, + m_service->session()->defaultCodec())); + for (int i = 0; i < formats.size(); ++i) { + const QSize res(qt_device_format_resolution(formats[i])); + if (res.width() > maximumWidth) + maximumWidth = res.width(); } + + if (maximumWidth > 0) + resolutions.append(QSize(maximumWidth, maximumWidth)); } -#endif if (resolutions.count() == 1) resolutions.append(QSize(3840, 3840)); @@ -135,45 +129,39 @@ QList<QSize> AVFVideoEncoderSettingsControl::supportedResolutions(const QVideoEn QList<qreal> AVFVideoEncoderSettingsControl::supportedFrameRates(const QVideoEncoderSettings &settings, bool *continuous) const { -#if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_7, __IPHONE_7_0) QList<qreal> uniqueFrameRates; - if (QSysInfo::MacintoshVersion >= qt_OS_limit(QSysInfo::MV_10_7, QSysInfo::MV_IOS_7_0)) { - AVCaptureDevice *device = m_service->session()->videoCaptureDevice(); - if (!device) - return uniqueFrameRates; + AVCaptureDevice *device = m_service->session()->videoCaptureDevice(); + if (!device) + return uniqueFrameRates; - if (continuous) - *continuous = false; + if (continuous) + *continuous = false; - QVector<AVFPSRange> allRates; + QVector<AVFPSRange> allRates; - if (!settings.resolution().isValid()) { - const QVector<AVCaptureDeviceFormat *> formats(qt_unique_device_formats(device, 0)); - for (int i = 0; i < formats.size(); ++i) { - AVCaptureDeviceFormat *format = formats.at(i); - allRates += qt_device_format_framerates(format); - } - } else { - AVCaptureDeviceFormat *format = qt_find_best_resolution_match(device, - settings.resolution(), - m_service->session()->defaultCodec()); - if (format) - allRates = qt_device_format_framerates(format); + if (!settings.resolution().isValid()) { + const QVector<AVCaptureDeviceFormat *> formats(qt_unique_device_formats(device, 0)); + for (int i = 0; i < formats.size(); ++i) { + AVCaptureDeviceFormat *format = formats.at(i); + allRates += qt_device_format_framerates(format); } + } else { + AVCaptureDeviceFormat *format = qt_find_best_resolution_match(device, + settings.resolution(), + m_service->session()->defaultCodec()); + if (format) + allRates = qt_device_format_framerates(format); + } - for (int j = 0; j < allRates.size(); ++j) { - if (!real_list_contains(uniqueFrameRates, allRates[j].first)) - uniqueFrameRates.append(allRates[j].first); - if (!real_list_contains(uniqueFrameRates, allRates[j].second)) - uniqueFrameRates.append(allRates[j].second); - } + for (int j = 0; j < allRates.size(); ++j) { + if (!real_list_contains(uniqueFrameRates, allRates[j].first)) + uniqueFrameRates.append(allRates[j].first); + if (!real_list_contains(uniqueFrameRates, allRates[j].second)) + uniqueFrameRates.append(allRates[j].second); } return uniqueFrameRates; -#else - return QList<qreal>(); -#endif } QStringList AVFVideoEncoderSettingsControl::supportedVideoCodecs() const @@ -243,7 +231,6 @@ NSDictionary *AVFVideoEncoderSettingsControl::applySettings(AVCaptureConnection int w = m_requestedSettings.resolution().width(); int h = m_requestedSettings.resolution().height(); -#if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_7, __IPHONE_7_0) if (AVCaptureDeviceFormat *currentFormat = device.activeFormat) { CMFormatDescriptionRef formatDesc = currentFormat.formatDescription; CMVideoDimensions dim = CMVideoFormatDescriptionGetDimensions(formatDesc); @@ -300,7 +287,6 @@ NSDictionary *AVFVideoEncoderSettingsControl::applySettings(AVCaptureConnection h = qMin(h, dim.height); } } -#endif if (w > 0 && h > 0) { // Width and height must be divisible by 2 @@ -382,13 +368,11 @@ void AVFVideoEncoderSettingsControl::unapplySettings(AVCaptureConnection *connec const bool needFpsChanged = m_restoreFps.first || m_restoreFps.second; -#if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_7, __IPHONE_7_0) if (m_restoreFormat) { qt_set_active_format(device, m_restoreFormat, !needFpsChanged); [m_restoreFormat release]; m_restoreFormat = nil; } -#endif if (needFpsChanged) { qt_set_framerate_limits(device, connection, m_restoreFps.first, m_restoreFps.second); diff --git a/src/plugins/avfoundation/mediaplayer/avfmediaplayerservice.h b/src/plugins/avfoundation/mediaplayer/avfmediaplayerservice.h index b18862b55..4460a4867 100644 --- a/src/plugins/avfoundation/mediaplayer/avfmediaplayerservice.h +++ b/src/plugins/avfoundation/mediaplayer/avfmediaplayerservice.h @@ -63,7 +63,6 @@ private: AVFMediaPlayerControl *m_control; QMediaControl *m_videoOutput; AVFMediaPlayerMetaDataControl *m_playerMetaDataControl; - bool m_enableRenderControl; }; QT_END_NAMESPACE diff --git a/src/plugins/avfoundation/mediaplayer/avfmediaplayerservice.mm b/src/plugins/avfoundation/mediaplayer/avfmediaplayerservice.mm index 526c36cc6..6218401b3 100644 --- a/src/plugins/avfoundation/mediaplayer/avfmediaplayerservice.mm +++ b/src/plugins/avfoundation/mediaplayer/avfmediaplayerservice.mm @@ -48,32 +48,19 @@ #endif #include "avfvideowindowcontrol.h" -#if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_8, __IPHONE_6_0) #import <AVFoundation/AVFoundation.h> -#endif QT_USE_NAMESPACE AVFMediaPlayerService::AVFMediaPlayerService(QObject *parent) : QMediaService(parent) , m_videoOutput(0) - , m_enableRenderControl(true) { m_session = new AVFMediaPlayerSession(this); m_control = new AVFMediaPlayerControl(this); m_control->setSession(m_session); m_playerMetaDataControl = new AVFMediaPlayerMetaDataControl(m_session, this); -#if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_8, __IPHONE_6_0) - // AVPlayerItemVideoOutput is available in SDK - #if QT_MAC_DEPLOYMENT_TARGET_BELOW(__MAC_10_8, __IPHONE_6_0) - // might not be available at runtime - #if defined(Q_OS_IOS) || defined(Q_OS_TVOS) - m_enableRenderControl = [AVPlayerItemVideoOutput class] != 0; - #endif - #endif -#endif - connect(m_control, SIGNAL(mediaChanged(QMediaContent)), m_playerMetaDataControl, SLOT(updateTags())); } @@ -98,7 +85,7 @@ QMediaControl *AVFMediaPlayerService::requestControl(const char *name) return m_playerMetaDataControl; - if (m_enableRenderControl && (qstrcmp(name, QVideoRendererControl_iid) == 0)) { + if (qstrcmp(name, QVideoRendererControl_iid) == 0) { if (!m_videoOutput) m_videoOutput = new AVFVideoRendererControl(this); diff --git a/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.h b/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.h index f0cb46aaa..5696faf15 100644 --- a/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.h +++ b/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.h @@ -86,8 +86,6 @@ public: qreal playbackRate() const; - inline bool isVolumeSupported() const { return m_volumeSupported; } - public Q_SLOTS: void setPlaybackRate(qreal rate); @@ -169,7 +167,6 @@ private: QMediaContent m_resources; ResourceHandler m_resourceHandler; - const bool m_volumeSupported; bool m_muted; bool m_tryingAsync; int m_volume; diff --git a/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.mm b/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.mm index 473a18884..e15c2e44a 100644 --- a/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.mm +++ b/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.mm @@ -233,7 +233,7 @@ static void *AVFMediaPlayerSessionObserverCurrentItemObservationContext = &AVFMe [m_player retain]; //Set the initial volume on new player object - if (self.session && self.session->isVolumeSupported()) { + if (self.session) { [m_player setVolume:m_session->volume() / 100.0f]; [m_player setMuted:m_session->isMuted()]; } @@ -380,11 +380,6 @@ AVFMediaPlayerSession::AVFMediaPlayerSession(AVFMediaPlayerService *service, QOb , m_state(QMediaPlayer::StoppedState) , m_mediaStatus(QMediaPlayer::NoMedia) , m_mediaStream(0) -#ifdef Q_OS_IOS - , m_volumeSupported(QSysInfo::MacintoshVersion >= QSysInfo::MV_IOS_7_0) -#else - , m_volumeSupported(true) -#endif , m_muted(false) , m_tryingAsync(false) , m_volume(100) @@ -749,11 +744,6 @@ void AVFMediaPlayerSession::setVolume(int volume) qDebug() << Q_FUNC_INFO << volume; #endif - if (!m_volumeSupported) { - qWarning("%s not implemented, requires iOS 7 or later", Q_FUNC_INFO); - return; - } - if (m_volume == volume) return; @@ -772,11 +762,6 @@ void AVFMediaPlayerSession::setMuted(bool muted) qDebug() << Q_FUNC_INFO << muted; #endif - if (!m_volumeSupported) { - qWarning("%s not implemented, requires iOS 7 or later", Q_FUNC_INFO); - return; - } - if (m_muted == muted) return; diff --git a/src/plugins/coreaudio/coreaudiosessionmanager.mm b/src/plugins/coreaudio/coreaudiosessionmanager.mm index d381b82c0..923a1942f 100644 --- a/src/plugins/coreaudio/coreaudiosessionmanager.mm +++ b/src/plugins/coreaudio/coreaudiosessionmanager.mm @@ -42,10 +42,6 @@ #import <AVFoundation/AVAudioSession.h> #import <Foundation/Foundation.h> -#if QT_IOS_DEPLOYMENT_TARGET_BELOW(__IPHONE_6_0) -#include <AudioToolbox/AudioToolbox.h> -#endif - QT_BEGIN_NAMESPACE @interface CoreAudioSessionObserver : NSObject @@ -81,24 +77,19 @@ QT_BEGIN_NAMESPACE self->m_sessionManager = sessionManager; self->m_audioSession = [AVAudioSession sharedInstance]; -#if QT_IOS_DEPLOYMENT_TARGET_BELOW(__IPHONE_6_0) - if (QSysInfo::MacintoshVersion >= QSysInfo::MV_IOS_6_0) -#endif - { - //Set up observers - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(audioSessionInterruption:) - name:AVAudioSessionInterruptionNotification - object:self->m_audioSession]; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(audioSessionMediaServicesWereReset:) - name:AVAudioSessionMediaServicesWereResetNotification - object:self->m_audioSession]; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(audioSessionRouteChange:) - name:AVAudioSessionRouteChangeNotification - object:self->m_audioSession]; - } + //Set up observers + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(audioSessionInterruption:) + name:AVAudioSessionInterruptionNotification + object:self->m_audioSession]; + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(audioSessionMediaServicesWereReset:) + name:AVAudioSessionMediaServicesWereResetNotification + object:self->m_audioSession]; + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(audioSessionRouteChange:) + name:AVAudioSessionRouteChangeNotification + object:self->m_audioSession]; return self; } @@ -109,20 +100,15 @@ QT_BEGIN_NAMESPACE qDebug() << Q_FUNC_INFO; #endif -#if QT_IOS_DEPLOYMENT_TARGET_BELOW(__IPHONE_6_0) - if (QSysInfo::MacintoshVersion >= QSysInfo::MV_IOS_6_0) -#endif - { - [[NSNotificationCenter defaultCenter] removeObserver:self - name:AVAudioSessionInterruptionNotification - object:self->m_audioSession]; - [[NSNotificationCenter defaultCenter] removeObserver:self - name:AVAudioSessionMediaServicesWereResetNotification - object:self->m_audioSession]; - [[NSNotificationCenter defaultCenter] removeObserver:self - name:AVAudioSessionRouteChangeNotification - object:self->m_audioSession]; - } + [[NSNotificationCenter defaultCenter] removeObserver:self + name:AVAudioSessionInterruptionNotification + object:self->m_audioSession]; + [[NSNotificationCenter defaultCenter] removeObserver:self + name:AVAudioSessionMediaServicesWereResetNotification + object:self->m_audioSession]; + [[NSNotificationCenter defaultCenter] removeObserver:self + name:AVAudioSessionRouteChangeNotification + object:self->m_audioSession]; [super dealloc]; } @@ -285,9 +271,6 @@ bool CoreAudioSessionManager::setCategory(CoreAudioSessionManager::AudioSessionC #endif break; case CoreAudioSessionManager::MultiRoute: -#if QT_IOS_DEPLOYMENT_TARGET_BELOW(__IPHONE_6_0) - if (QSysInfo::MacintoshVersion >= QSysInfo::MV_IOS_6_0) -#endif targetCategory = AVAudioSessionCategoryMultiRoute; break; } @@ -295,16 +278,9 @@ bool CoreAudioSessionManager::setCategory(CoreAudioSessionManager::AudioSessionC if (targetCategory == nil) return false; -#if QT_IOS_DEPLOYMENT_TARGET_BELOW(__IPHONE_6_0) - if (QSysInfo::MacintoshVersion < QSysInfo::MV_IOS_6_0) { - return [[m_sessionObserver audioSession] setCategory:targetCategory error:nil]; - } else -#endif - { - return [[m_sessionObserver audioSession] setCategory:targetCategory - withOptions:(AVAudioSessionCategoryOptions)options - error:nil]; - } + return [[m_sessionObserver audioSession] setCategory:targetCategory + withOptions:(AVAudioSessionCategoryOptions)options + error:nil]; } bool CoreAudioSessionManager::setMode(CoreAudioSessionManager::AudioSessionModes mode) @@ -327,9 +303,6 @@ bool CoreAudioSessionManager::setMode(CoreAudioSessionManager::AudioSessionModes targetMode = AVAudioSessionModeMeasurement; break; case CoreAudioSessionManager::MoviePlayback: -#if QT_IOS_DEPLOYMENT_TARGET_BELOW(__IPHONE_6_0) - if (QSysInfo::MacintoshVersion >= QSysInfo::MV_IOS_6_0) -#endif targetMode = AVAudioSessionModeMoviePlayback; break; } @@ -360,11 +333,7 @@ CoreAudioSessionManager::AudioSessionCategorys CoreAudioSessionManager::category } else if (category == AVAudioSessionCategoryAudioProcessing) { localCategory = AudioProcessing; #endif - } else if ( -#if QT_IOS_DEPLOYMENT_TARGET_BELOW(__IPHONE_6_0) - QSysInfo::MacintoshVersion >= QSysInfo::MV_IOS_6_0 && -#endif - category == AVAudioSessionCategoryMultiRoute) { + } else if (category == AVAudioSessionCategoryMultiRoute) { localCategory = MultiRoute; } @@ -386,11 +355,7 @@ CoreAudioSessionManager::AudioSessionModes CoreAudioSessionManager::mode() localMode = VideoRecording; } else if (mode == AVAudioSessionModeMeasurement) { localMode = Measurement; - } else if ( -#if QT_IOS_DEPLOYMENT_TARGET_BELOW(__IPHONE_6_0) - QSysInfo::MacintoshVersion >= QSysInfo::MV_IOS_6_0 && -#endif - mode == AVAudioSessionModeMoviePlayback) { + } else if (mode == AVAudioSessionModeMoviePlayback) { localMode = MoviePlayback; } @@ -419,32 +384,12 @@ QList<QByteArray> CoreAudioSessionManager::outputDevices() float CoreAudioSessionManager::currentIOBufferDuration() { -#if QT_IOS_DEPLOYMENT_TARGET_BELOW(__IPHONE_6_0) - if (QSysInfo::MacintoshVersion < QSysInfo::MV_IOS_6_0) { - Float32 duration; - UInt32 size = sizeof(duration); - AudioSessionGetProperty(kAudioSessionProperty_CurrentHardwareIOBufferDuration, &size, &duration); - return duration; - } else -#endif - { - return [[m_sessionObserver audioSession] IOBufferDuration]; - } + return [[m_sessionObserver audioSession] IOBufferDuration]; } float CoreAudioSessionManager::preferredSampleRate() { -#if QT_IOS_DEPLOYMENT_TARGET_BELOW(__IPHONE_6_0) - if (QSysInfo::MacintoshVersion < QSysInfo::MV_IOS_6_0) { - Float64 sampleRate; - UInt32 size = sizeof(sampleRate); - AudioSessionGetProperty(kAudioSessionProperty_PreferredHardwareSampleRate, &size, &sampleRate); - return sampleRate; - } else -#endif - { - return [[m_sessionObserver audioSession] preferredSampleRate]; - } + return [[m_sessionObserver audioSession] preferredSampleRate]; } #ifdef QT_DEBUG_COREAUDIO |