diff options
Diffstat (limited to 'src/multimedia/platform')
-rw-r--r-- | src/multimedia/platform/darwin/avfvideosink_p.h | 2 | ||||
-rw-r--r-- | src/multimedia/platform/darwin/camera/avfmediaencoder.mm | 26 |
2 files changed, 19 insertions, 9 deletions
diff --git a/src/multimedia/platform/darwin/avfvideosink_p.h b/src/multimedia/platform/darwin/avfvideosink_p.h index d25efdfc7..85295e4c2 100644 --- a/src/multimedia/platform/darwin/avfvideosink_p.h +++ b/src/multimedia/platform/darwin/avfvideosink_p.h @@ -105,7 +105,7 @@ public: void updateLayerBounds(); void nativeSizeChanged() { updateLayerBounds(); } - QSize nativeSize() const { return m_sink->nativeSize(); } + QSize nativeSize() const { return m_sink ? m_sink->nativeSize() : QSize(); } CVMetalTextureCacheRef cvMetalTextureCache = nullptr; #if defined(Q_OS_MACOS) diff --git a/src/multimedia/platform/darwin/camera/avfmediaencoder.mm b/src/multimedia/platform/darwin/camera/avfmediaencoder.mm index 6761c1d8d..2e081108e 100644 --- a/src/multimedia/platform/darwin/camera/avfmediaencoder.mm +++ b/src/multimedia/platform/darwin/camera/avfmediaencoder.mm @@ -305,6 +305,12 @@ NSDictionary *avfVideoSettings(QMediaEncoderSettings &encoderSettings, AVCapture dim = CMVideoFormatDescriptionGetDimensions(formatDesc); } + if (w < 0 || h < 0) { + w = dim.width; + h = dim.height; + } + + if (w > 0 && h > 0) { // Make sure the recording resolution has the same aspect ratio as the device's // current resolution @@ -403,6 +409,8 @@ NSDictionary *avfVideoSettings(QMediaEncoderSettings &encoderSettings, AVCapture void AVFMediaEncoder::applySettings(QMediaEncoderSettings &settings) { + unapplySettings(); + AVFCameraSession *session = m_service->session(); // audio settings @@ -601,20 +609,22 @@ void AVFMediaEncoder::assetWriterStarted() void AVFMediaEncoder::assetWriterFinished() { - Q_ASSERT(m_service && m_service->session()); - AVFCameraSession *session = m_service->session(); const QMediaRecorder::RecorderState lastState = m_state; unapplySettings(); - if (session->videoOutput()) { - session->videoOutput()->resetCaptureDelegate(); - } - if (session->audioPreviewDelegate()) { - [session->audioPreviewDelegate() resetAudioPreviewDelegate]; + if (m_service) { + AVFCameraSession *session = m_service->session(); + + if (session->videoOutput()) { + session->videoOutput()->resetCaptureDelegate(); + } + if (session->audioPreviewDelegate()) { + [session->audioPreviewDelegate() resetAudioPreviewDelegate]; + } + [session->captureSession() startRunning]; } - [session->captureSession() startRunning]; m_state = QMediaRecorder::StoppedState; if (m_state != lastState) |