From 35cc837acf78625bcfbf19a2ff22451da1fc1047 Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Wed, 8 May 2019 17:58:45 +0200 Subject: [PATCH] [camera] Emit imageExposed signal at the right time. JB#45747 Droidmedia supports a callback to indicate the exact moment when the shutter fires, and this is passed on as a GstMessage by Gst-droid. There is already an imageExposed signal being emitted from QGstreamerCaptureSession, but it's only sent when the image is finished, right before imageCaptured. This class already parses GstMessages, so we can move the imageExposed signal to be sent when the shutter actually fires. This can trigger the shutter sound and animation in camera apps as intended. --- .../gstreamer/camerabin/camerabinsession.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/plugins/gstreamer/camerabin/camerabinsession.cpp b/src/plugins/gstreamer/camerabin/camerabinsession.cpp index a8108c66..b1a0b76c 100644 --- a/src/plugins/gstreamer/camerabin/camerabinsession.cpp +++ b/src/plugins/gstreamer/camerabin/camerabinsession.cpp @@ -960,11 +960,6 @@ bool CameraBinSession::processSyncMessage(const QGstreamerMessage &message) gst_buffer_unref(buffer); #endif if (!image.isNull()) { - static QMetaMethod exposedSignal = QMetaMethod::fromSignal(&CameraBinSession::imageExposed); - exposedSignal.invoke(this, - Qt::QueuedConnection, - Q_ARG(int,m_requestId)); - static QMetaMethod capturedSignal = QMetaMethod::fromSignal(&CameraBinSession::imageCaptured); capturedSignal.invoke(this, Qt::QueuedConnection, @@ -987,6 +982,15 @@ bool CameraBinSession::processBusMessage(const QGstreamerMessage &message) GstMessage* gm = message.rawMessage(); if (gm) { + if (GST_MESSAGE_TYPE(gm) == GST_MESSAGE_ELEMENT && + gst_structure_has_name(gst_message_get_structure(gm), "photo-capture-start")) { + static QMetaMethod exposedSignal = + QMetaMethod::fromSignal(&CameraBinSession::imageExposed); + exposedSignal.invoke(this, + Qt::QueuedConnection, + Q_ARG(int,m_requestId)); + } + if (GST_MESSAGE_TYPE(gm) == GST_MESSAGE_ERROR) { GError *err; gchar *debug;