summaryrefslogtreecommitdiffstats
path: root/src/plugins/avfoundation/camera/avfcamerasession.mm
diff options
context:
space:
mode:
authorTimur Pocheptsov <Timur.Pocheptsov@digia.com>2015-03-04 16:34:32 +0100
committerTimur Pocheptsov <Timur.Pocheptsov@digia.com>2015-03-10 16:35:59 +0000
commitf839f9e3eb2cd89f2b458349a08f9e5444744f1b (patch)
treea39c78e2fe3541da7dfd8e2e2197faf1d039769c /src/plugins/avfoundation/camera/avfcamerasession.mm
parentdbcf44247d41fa456329da30ae378a69de19e3cd (diff)
AVCaptureDeviceFormat - avoid duplicates (OS X/iOS)
Excluding video range (iOS) is not the right way to avoid "duplicates" - with other devices there can be also duplicates (formats with the same resolutions), but completely different pixel formats. Since we do not know what they will be in advance, we take the media subtype from the initial preset for a capture device and use it as a filter. Update viewfinder and image encoder settings controls. Change-Id: If20aea24b19b43574d5c3e9bf2ba85f50fc08916 Reviewed-by: Yoann Lopes <yoann.lopes@theqtcompany.com>
Diffstat (limited to 'src/plugins/avfoundation/camera/avfcamerasession.mm')
-rw-r--r--src/plugins/avfoundation/camera/avfcamerasession.mm23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/plugins/avfoundation/camera/avfcamerasession.mm b/src/plugins/avfoundation/camera/avfcamerasession.mm
index 98fbb9865..af30dd312 100644
--- a/src/plugins/avfoundation/camera/avfcamerasession.mm
+++ b/src/plugins/avfoundation/camera/avfcamerasession.mm
@@ -41,6 +41,7 @@
#include "avfmediavideoprobecontrol.h"
#include "avfcameraviewfindersettingscontrol.h"
#include "avfimageencodercontrol.h"
+#include "avfcamerautility.h"
#include <CoreFoundation/CoreFoundation.h>
#include <Foundation/Foundation.h>
@@ -143,6 +144,7 @@ AVFCameraSession::AVFCameraSession(AVFCameraService *service, QObject *parent)
, m_active(false)
, m_videoInput(nil)
, m_audioInput(nil)
+ , m_defaultCodec(0)
{
m_captureSession = [[AVCaptureSession alloc] init];
m_observer = [[AVFCameraSessionObserver alloc] initWithCameraSession:this];
@@ -277,6 +279,8 @@ void AVFCameraSession::setState(QCamera::State newState)
Q_EMIT readyToConfigureConnections();
[m_captureSession commitConfiguration];
[m_captureSession startRunning];
+ m_defaultCodec = 0;
+ defaultCodec();
applyImageEncoderSettings();
applyViewfinderSettings();
}
@@ -407,6 +411,25 @@ void AVFCameraSession::removeProbe(AVFMediaVideoProbeControl *probe)
m_videoProbesMutex.unlock();
}
+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);
+ }
+ }
+#else
+ // TODO: extract media subtype.
+#endif
+ }
+ return m_defaultCodec;
+}
+
void AVFCameraSession::onCameraFrameFetched(const QVideoFrame &frame)
{
m_videoProbesMutex.lock();