diff options
author | Ihor Dutchak <ihor.youw@gmail.com> | 2018-07-08 16:58:55 +0300 |
---|---|---|
committer | Ihor Dutchak <ihor.youw@gmail.com> | 2020-03-23 16:48:02 +0200 |
commit | 00ae18f986cadc4c888625fb63b2ca89da1f986f (patch) | |
tree | 307a702aa5af133f3c5919c2ef163b742bf94863 /src/plugins/avfoundation/camera/avfcameraservice.mm | |
parent | 8ef57db9729b714239ad507488e1c8a011a5163a (diff) | |
download | qtmultimedia-00ae18f986cadc4c888625fb63b2ca89da1f986f.tar.gz |
Add AVFCameraWindowControl as QVideoWindowControl_iid implementation
AVFCameraWindowControl is a renderer backend,
when QCamera viewfinder output set to QVideoWidget on macOS or iOS.
As it uses native API and lets the OS handle rendering pipeline,
it is an efficient alternative to default renderer backend.
Task-number: QTBUG-68779
Change-Id: I4d27022655a7d9f4ad7cf99c84b570a0c48cf10a
Reviewed-by: VaL Doroshchuk <valentyn.doroshchuk@qt.io>
Diffstat (limited to 'src/plugins/avfoundation/camera/avfcameraservice.mm')
-rw-r--r-- | src/plugins/avfoundation/camera/avfcameraservice.mm | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/plugins/avfoundation/camera/avfcameraservice.mm b/src/plugins/avfoundation/camera/avfcameraservice.mm index 33b4b72aa..627ecf67c 100644 --- a/src/plugins/avfoundation/camera/avfcameraservice.mm +++ b/src/plugins/avfoundation/camera/avfcameraservice.mm @@ -61,6 +61,7 @@ #include "avfaudioencodersettingscontrol.h" #include "avfvideoencodersettingscontrol.h" #include "avfmediacontainercontrol.h" +#include "avfcamerawindowcontrol.h" #ifdef Q_OS_IOS #include "avfcamerazoomcontrol.h" @@ -74,7 +75,8 @@ QT_USE_NAMESPACE AVFCameraService::AVFCameraService(QObject *parent): QMediaService(parent), - m_videoOutput(nullptr) + m_videoOutput(nullptr), + m_captureWindowControl(nullptr) { m_session = new AVFCameraSession(this); m_cameraControl = new AVFCameraControl(this); @@ -119,6 +121,12 @@ AVFCameraService::~AVFCameraService() delete m_recorderControl; #endif + if (m_captureWindowControl) { + m_session->setCapturePreviewOutput(nullptr); + delete m_captureWindowControl; + m_captureWindowControl = nullptr; + } + if (m_videoOutput) { m_session->setVideoOutput(nullptr); delete m_videoOutput; @@ -210,6 +218,14 @@ QMediaControl *AVFCameraService::requestControl(const char *name) return m_cameraZoomControl; #endif + if (!m_captureWindowControl) { + if (qstrcmp(name, QVideoWindowControl_iid) == 0) { + m_captureWindowControl = new AVFCameraWindowControl(this); + m_session->setCapturePreviewOutput(m_captureWindowControl); + return m_captureWindowControl; + } + } + if (!m_videoOutput) { if (qstrcmp(name, QVideoRendererControl_iid) == 0) m_videoOutput = new AVFCameraRendererControl(this); @@ -234,6 +250,11 @@ void AVFCameraService::releaseControl(QMediaControl *control) delete m_videoOutput; m_videoOutput = nullptr; } + else if (m_captureWindowControl == control) { + m_session->setCapturePreviewOutput(nullptr); + delete m_captureWindowControl; + m_captureWindowControl = nullptr; + } } |