diff options
author | Yoann Lopes <yoann.lopes@theqtcompany.com> | 2015-02-05 16:37:58 +0100 |
---|---|---|
committer | Yoann Lopes <yoann.lopes@theqtcompany.com> | 2015-02-18 13:15:45 +0000 |
commit | 178c0401685a56541995ca1ac9b5f6a4b543626d (patch) | |
tree | 701b9c4c0691930fcce98981e4d71194cdfc872c /src/plugins | |
parent | 656da3d4d60f21914e7f5ea004e8ec924f79ef03 (diff) | |
download | qtmultimedia-178c0401685a56541995ca1ac9b5f6a4b543626d.tar.gz |
GStreamer: some improvements with the camerabin's capture settings.
- Don't pretend we support changing the image or video capture
settings while the camera is active. The pipeline needs to be
restarted in order to renegotiate caps.
- Improved retrieving the supported capture resolutions and frame
rates when using wrappercamerabinsrc. We now always get the
supported values directly from the video source.
Change-Id: I107193288e370af105a25d16568a8f5a76022ada
Reviewed-by: Christian Stromme <christian.stromme@theqtcompany.com>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/gstreamer/camerabin/camerabincontrol.cpp | 8 | ||||
-rw-r--r-- | src/plugins/gstreamer/camerabin/camerabinsession.cpp | 63 | ||||
-rw-r--r-- | src/plugins/gstreamer/camerabin/camerabinsession.h | 3 |
3 files changed, 44 insertions, 30 deletions
diff --git a/src/plugins/gstreamer/camerabin/camerabincontrol.cpp b/src/plugins/gstreamer/camerabin/camerabincontrol.cpp index 8d1f9fd42..bc60d3a58 100644 --- a/src/plugins/gstreamer/camerabin/camerabincontrol.cpp +++ b/src/plugins/gstreamer/camerabin/camerabincontrol.cpp @@ -249,16 +249,14 @@ bool CameraBinControl::canChangeProperty(PropertyChangeType changeType, QCamera: Q_UNUSED(status); switch (changeType) { + case QCameraControl::Viewfinder: + return true; case QCameraControl::CaptureMode: - return status != QCamera::ActiveStatus; - break; case QCameraControl::ImageEncodingSettings: case QCameraControl::VideoEncodingSettings: - case QCameraControl::Viewfinder: - return true; case QCameraControl::ViewfinderSettings: default: - return false; + return status != QCamera::ActiveStatus; } } diff --git a/src/plugins/gstreamer/camerabin/camerabinsession.cpp b/src/plugins/gstreamer/camerabin/camerabinsession.cpp index 356ad8dbd..ed7e7d415 100644 --- a/src/plugins/gstreamer/camerabin/camerabinsession.cpp +++ b/src/plugins/gstreamer/camerabin/camerabinsession.cpp @@ -1174,14 +1174,47 @@ static bool rateLessThan(const QPair<int,int> &r1, const QPair<int,int> &r2) return r1.first*r2.second < r2.first*r1.second; } +GstCaps *CameraBinSession::supportedCaps(QCamera::CaptureModes mode) const +{ + GstCaps *supportedCaps = 0; + + // When using wrappercamerabinsrc, get the supported caps directly from the video source element. + // This makes sure we only get the caps actually supported by the video source element. + if (m_videoSrc) { + GstPad *pad = gst_element_get_static_pad(m_videoSrc, "src"); + if (pad) { + supportedCaps = qt_gst_pad_get_caps(pad); + gst_object_unref(GST_OBJECT(pad)); + } + } + + // Otherwise, let the camerabin handle this. + if (!supportedCaps) { + const gchar *prop; + switch (mode) { + case QCamera::CaptureStillImage: + prop = SUPPORTED_IMAGE_CAPTURE_CAPS_PROPERTY; + break; + case QCamera::CaptureVideo: + prop = SUPPORTED_VIDEO_CAPTURE_CAPS_PROPERTY; + break; + case QCamera::CaptureViewfinder: + default: + prop = SUPPORTED_VIEWFINDER_CAPS_PROPERTY; + break; + } + + g_object_get(G_OBJECT(m_camerabin), prop, &supportedCaps, NULL); + } + + return supportedCaps; +} + QList< QPair<int,int> > CameraBinSession::supportedFrameRates(const QSize &frameSize, bool *continuous) const { QList< QPair<int,int> > res; - GstCaps *supportedCaps = 0; - g_object_get(G_OBJECT(m_camerabin), - SUPPORTED_VIDEO_CAPTURE_CAPS_PROPERTY, - &supportedCaps, NULL); + GstCaps *supportedCaps = this->supportedCaps(QCamera::CaptureVideo); if (!supportedCaps) return res; @@ -1284,11 +1317,7 @@ QList<QSize> CameraBinSession::supportedResolutions(QPair<int,int> rate, if (continuous) *continuous = false; - GstCaps *supportedCaps = 0; - g_object_get(G_OBJECT(m_camerabin), - (mode == QCamera::CaptureStillImage) ? - SUPPORTED_IMAGE_CAPTURE_CAPS_PROPERTY : SUPPORTED_VIDEO_CAPTURE_CAPS_PROPERTY, - &supportedCaps, NULL); + GstCaps *supportedCaps = this->supportedCaps(mode); #if CAMERABIN_DEBUG qDebug() << "Source caps:" << supportedCaps; @@ -1422,21 +1451,7 @@ void CameraBinSession::updateSupportedViewfinderSettings() { m_supportedViewfinderSettings.clear(); - GstCaps *supportedCaps = 0; - - // When using wrappercamerabinsrc, get the supported caps directly from the video source element. - // This makes sure we only get the caps actually supported by the video source element. - if (m_videoSrc) { - GstPad *pad = gst_element_get_static_pad(m_videoSrc, "src"); - if (pad) { - supportedCaps = qt_gst_pad_get_caps(pad); - gst_object_unref(GST_OBJECT(pad)); - } - } - - // Otherwise, let the camerabin handle this. - if (!supportedCaps) - g_object_get(G_OBJECT(m_camerabin), SUPPORTED_VIEWFINDER_CAPS_PROPERTY, &supportedCaps, NULL); + GstCaps *supportedCaps = this->supportedCaps(QCamera::CaptureViewfinder); // Convert caps to QCameraViewfinderSettings if (supportedCaps) { diff --git a/src/plugins/gstreamer/camerabin/camerabinsession.h b/src/plugins/gstreamer/camerabin/camerabinsession.h index f957c55de..71590a7dc 100644 --- a/src/plugins/gstreamer/camerabin/camerabinsession.h +++ b/src/plugins/gstreamer/camerabin/camerabinsession.h @@ -179,6 +179,7 @@ public slots: private slots: void handleViewfinderChange(); + void setupCaptureResolution(); private: void load(); @@ -191,8 +192,8 @@ private: void setError(int error, const QString &errorString); bool setupCameraBin(); - void setupCaptureResolution(); void setAudioCaptureCaps(); + GstCaps *supportedCaps(QCamera::CaptureModes mode) const; void updateSupportedViewfinderSettings(); static void updateBusyStatus(GObject *o, GParamSpec *p, gpointer d); |