summaryrefslogtreecommitdiffstats
path: root/src/plugins/avfoundation/camera/avfcamerasession.mm
diff options
context:
space:
mode:
authorYoann Lopes <yoann.lopes@theqtcompany.com>2015-04-21 18:07:19 +0200
committerJani Heikkinen <jani.heikkinen@theqtcompany.com>2015-04-23 18:39:08 +0000
commitbcaec9624c9124dc256ad963d5735496e219414a (patch)
tree61a759b0699674db0caf82e0021486ca45faf847 /src/plugins/avfoundation/camera/avfcamerasession.mm
parent6fe3061c1f6b7438d20c7bfb92c7652cedc5b049 (diff)
AVFoundation: fix microphone permission when using the camera.
The microphone permission was always requested when using the camera, even when not actually using the microphone, which can only happen when recording a video. The permission request is triggered by adding an audio AVCaptureDeviceInput to the AVCaptureSession, which was done when setting the camera to LoadedState. This is now done when setting the camera mode to CaptureVideo. Task-number: QTBUG-45659 Change-Id: I3692797128cfb70ba5ccbc7a36b6955471039e80 Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com>
Diffstat (limited to 'src/plugins/avfoundation/camera/avfcamerasession.mm')
-rw-r--r--src/plugins/avfoundation/camera/avfcamerasession.mm38
1 files changed, 4 insertions, 34 deletions
diff --git a/src/plugins/avfoundation/camera/avfcamerasession.mm b/src/plugins/avfoundation/camera/avfcamerasession.mm
index 4d4b2f657..d0bb0e51a 100644
--- a/src/plugins/avfoundation/camera/avfcamerasession.mm
+++ b/src/plugins/avfoundation/camera/avfcamerasession.mm
@@ -147,7 +147,6 @@ AVFCameraSession::AVFCameraSession(AVFCameraService *service, QObject *parent)
, m_state(QCamera::UnloadedState)
, m_active(false)
, m_videoInput(nil)
- , m_audioInput(nil)
{
m_captureSession = [[AVCaptureSession alloc] init];
m_observer = [[AVFCameraSessionObserver alloc] initWithCameraSession:this];
@@ -163,11 +162,6 @@ AVFCameraSession::~AVFCameraSession()
[m_videoInput release];
}
- if (m_audioInput) {
- [m_captureSession removeInput:m_audioInput];
- [m_audioInput release];
- }
-
[m_observer release];
[m_captureSession release];
}
@@ -286,10 +280,9 @@ void AVFCameraSession::setState(QCamera::State newState)
QCamera::State oldState = m_state;
m_state = newState;
- //attach audio and video inputs during Unloaded->Loaded transition
- if (oldState == QCamera::UnloadedState) {
- attachInputDevices();
- }
+ //attach video input during Unloaded->Loaded transition
+ if (oldState == QCamera::UnloadedState)
+ attachVideoInputDevice();
if (m_state == QCamera::ActiveState) {
Q_EMIT readyToConfigureConnections();
@@ -331,7 +324,7 @@ void AVFCameraSession::processSessionStopped()
}
}
-void AVFCameraSession::attachInputDevices()
+void AVFCameraSession::attachVideoInputDevice()
{
//Attach video input device:
if (m_service->videoDeviceControl()->isDirty()) {
@@ -359,29 +352,6 @@ void AVFCameraSession::attachInputDevices()
}
}
}
-
- //Attach audio input device:
- if (m_service->audioInputSelectorControl()->isDirty()) {
- if (m_audioInput) {
- [m_captureSession removeInput:m_audioInput];
- [m_audioInput release];
- m_audioInput = 0;
- }
-
- AVCaptureDevice *audioDevice = m_service->audioInputSelectorControl()->createCaptureDevice();
-
- NSError *error = nil;
- m_audioInput = [AVCaptureDeviceInput
- deviceInputWithDevice:audioDevice
- error:&error];
-
- if (!m_audioInput) {
- qWarning() << "Failed to create audio device input";
- } else {
- [m_audioInput retain];
- [m_captureSession addInput:m_audioInput];
- }
- }
}
#include "moc_avfcamerasession.cpp"