summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/gstreamer/camerabin/camerabin.pro2
-rw-r--r--src/plugins/gstreamer/camerabin/camerabincontrol.cpp1
-rw-r--r--src/plugins/gstreamer/camerabin/camerabinservice.cpp18
-rw-r--r--src/plugins/gstreamer/camerabin/camerabinservice.h5
-rw-r--r--src/plugins/gstreamer/camerabin/camerabinsession.cpp296
-rw-r--r--src/plugins/gstreamer/camerabin/camerabinsession.h29
-rw-r--r--src/plugins/gstreamer/camerabin/camerabinviewfindersettings.cpp53
-rw-r--r--src/plugins/gstreamer/camerabin/camerabinviewfindersettings.h15
-rw-r--r--src/plugins/gstreamer/camerabin/camerabinviewfindersettings2.cpp67
-rw-r--r--src/plugins/gstreamer/camerabin/camerabinviewfindersettings2.h61
10 files changed, 410 insertions, 137 deletions
diff --git a/src/plugins/gstreamer/camerabin/camerabin.pro b/src/plugins/gstreamer/camerabin/camerabin.pro
index 64fee3e41..bfbb35733 100644
--- a/src/plugins/gstreamer/camerabin/camerabin.pro
+++ b/src/plugins/gstreamer/camerabin/camerabin.pro
@@ -31,6 +31,7 @@ HEADERS += \
$$PWD/camerabincapturedestination.h \
$$PWD/camerabincapturebufferformat.h \
$$PWD/camerabinviewfindersettings.h \
+ $$PWD/camerabinviewfindersettings2.h \
$$PWD/camerabininfocontrol.h
SOURCES += \
@@ -49,6 +50,7 @@ SOURCES += \
$$PWD/camerabinresourcepolicy.cpp \
$$PWD/camerabincapturedestination.cpp \
$$PWD/camerabinviewfindersettings.cpp \
+ $$PWD/camerabinviewfindersettings2.cpp \
$$PWD/camerabincapturebufferformat.cpp \
$$PWD/camerabininfocontrol.cpp
diff --git a/src/plugins/gstreamer/camerabin/camerabincontrol.cpp b/src/plugins/gstreamer/camerabin/camerabincontrol.cpp
index cd7e37628..8d1f9fd42 100644
--- a/src/plugins/gstreamer/camerabin/camerabincontrol.cpp
+++ b/src/plugins/gstreamer/camerabin/camerabincontrol.cpp
@@ -256,6 +256,7 @@ bool CameraBinControl::canChangeProperty(PropertyChangeType changeType, QCamera:
case QCameraControl::VideoEncodingSettings:
case QCameraControl::Viewfinder:
return true;
+ case QCameraControl::ViewfinderSettings:
default:
return false;
}
diff --git a/src/plugins/gstreamer/camerabin/camerabinservice.cpp b/src/plugins/gstreamer/camerabin/camerabinservice.cpp
index 4bcddb3cb..706907ec7 100644
--- a/src/plugins/gstreamer/camerabin/camerabinservice.cpp
+++ b/src/plugins/gstreamer/camerabin/camerabinservice.cpp
@@ -55,6 +55,7 @@
#include "camerabincapturebufferformat.h"
#include "camerabincapturedestination.h"
#include "camerabinviewfindersettings.h"
+#include "camerabinviewfindersettings2.h"
#include <private/qgstreamerbushelper_p.h>
#include <private/qgstutils_p.h>
@@ -84,7 +85,9 @@ QT_BEGIN_NAMESPACE
CameraBinService::CameraBinService(GstElementFactory *sourceFactory, QObject *parent):
QMediaService(parent),
- m_cameraInfoControl(0)
+ m_cameraInfoControl(0),
+ m_viewfinderSettingsControl(0),
+ m_viewfinderSettingsControl2(0)
{
m_captureSession = 0;
m_metaDataControl = 0;
@@ -224,8 +227,17 @@ QMediaControl *CameraBinService::requestControl(const char *name)
if (qstrcmp(name, QCameraCaptureBufferFormatControl_iid) == 0)
return m_captureSession->captureBufferFormatControl();
- if (qstrcmp(name, QCameraViewfinderSettingsControl_iid) == 0)
- return m_captureSession->viewfinderSettingsControl();
+ if (qstrcmp(name, QCameraViewfinderSettingsControl_iid) == 0) {
+ if (!m_viewfinderSettingsControl)
+ m_viewfinderSettingsControl = new CameraBinViewfinderSettings(m_captureSession);
+ return m_viewfinderSettingsControl;
+ }
+
+ if (qstrcmp(name, QCameraViewfinderSettingsControl2_iid) == 0) {
+ if (!m_viewfinderSettingsControl2)
+ m_viewfinderSettingsControl2 = new CameraBinViewfinderSettings2(m_captureSession);
+ return m_viewfinderSettingsControl2;
+ }
if (qstrcmp(name, QCameraInfoControl_iid) == 0) {
if (!m_cameraInfoControl)
diff --git a/src/plugins/gstreamer/camerabin/camerabinservice.h b/src/plugins/gstreamer/camerabin/camerabinservice.h
index 10fe18e26..ed181eef9 100644
--- a/src/plugins/gstreamer/camerabin/camerabinservice.h
+++ b/src/plugins/gstreamer/camerabin/camerabinservice.h
@@ -53,6 +53,8 @@ class QGstreamerElementFactory;
class CameraBinMetaData;
class CameraBinImageCapture;
class CameraBinMetaData;
+class CameraBinViewfinderSettings;
+class CameraBinViewfinderSettings2;
class CameraBinService : public QMediaService
{
@@ -85,6 +87,9 @@ private:
#endif
CameraBinImageCapture *m_imageCaptureControl;
QMediaControl *m_cameraInfoControl;
+
+ CameraBinViewfinderSettings *m_viewfinderSettingsControl;
+ CameraBinViewfinderSettings2 *m_viewfinderSettingsControl2;
};
QT_END_NAMESPACE
diff --git a/src/plugins/gstreamer/camerabin/camerabinsession.cpp b/src/plugins/gstreamer/camerabin/camerabinsession.cpp
index 72d72fdef..0ed8dcb67 100644
--- a/src/plugins/gstreamer/camerabin/camerabinsession.cpp
+++ b/src/plugins/gstreamer/camerabin/camerabinsession.cpp
@@ -55,6 +55,7 @@
#include <private/qgstreamervideorendererinterface_p.h>
#include <private/qgstutils_p.h>
#include <qmediarecorder.h>
+#include <qvideosurfaceformat.h>
#ifdef HAVE_GST_PHOTOGRAPHY
#include <gst/interfaces/photography.h>
@@ -120,11 +121,14 @@ CameraBinSession::CameraBinSession(GstElementFactory *sourceFactory, QObject *pa
m_videoInputFactory(0),
m_viewfinder(0),
m_viewfinderInterface(0),
+ m_cameraSrc(0),
m_videoSrc(0),
m_viewfinderElement(0),
m_sourceFactory(sourceFactory),
m_viewfinderHasChanged(true),
- m_videoInputHasChanged(true),
+ m_inputDeviceHasChanged(true),
+ m_usingWrapperCameraBinSrc(false),
+ m_viewfinderProbe(this),
m_audioSrc(0),
m_audioConvert(0),
m_capsFilter(0),
@@ -164,7 +168,6 @@ CameraBinSession::CameraBinSession(GstElementFactory *sourceFactory, QObject *pa
m_imageProcessingControl = new CameraBinImageProcessing(this);
m_captureDestinationControl = new CameraBinCaptureDestination(this);
m_captureBufferFormatControl = new CameraBinCaptureBufferFormat(this);
- m_viewfinderSettingsControl = new CameraBinViewfinderSettings(this);
QByteArray envFlags = qgetenv("QT_GSTREAMER_CAMERABIN_FLAGS");
if (!envFlags.isEmpty())
@@ -231,8 +234,12 @@ bool CameraBinSession::setupCameraBin()
return false;
if (m_viewfinderHasChanged) {
- if (m_viewfinderElement)
+ if (m_viewfinderElement) {
+ GstPad *pad = gst_element_get_static_pad(m_viewfinderElement, "sink");
+ m_viewfinderProbe.removeProbeFromPad(pad);
+ gst_object_unref(GST_OBJECT(pad));
gst_object_unref(GST_OBJECT(m_viewfinderElement));
+ }
m_viewfinderElement = m_viewfinderInterface ? m_viewfinderInterface->videoSink() : 0;
#if CAMERABIN_DEBUG
@@ -244,6 +251,11 @@ bool CameraBinSession::setupCameraBin()
qWarning() << "Starting camera without viewfinder available";
m_viewfinderElement = gst_element_factory_make("fakesink", NULL);
}
+
+ GstPad *pad = gst_element_get_static_pad(m_viewfinderElement, "sink");
+ m_viewfinderProbe.addProbeToPad(pad);
+ gst_object_unref(GST_OBJECT(pad));
+
g_object_set(G_OBJECT(m_viewfinderElement), "sync", FALSE, NULL);
qt_gst_object_ref_sink(GST_OBJECT(m_viewfinderElement));
gst_element_set_state(m_camerabin, GST_STATE_NULL);
@@ -253,9 +265,15 @@ bool CameraBinSession::setupCameraBin()
return true;
}
-static GstCaps *resolutionToCaps(const QSize &resolution, qreal frameRate = 0.0)
+static GstCaps *resolutionToCaps(const QSize &resolution,
+ qreal frameRate = 0.0,
+ QVideoFrame::PixelFormat pixelFormat = QVideoFrame::Format_Invalid)
{
- GstCaps *caps = QGstUtils::videoFilterCaps();
+ GstCaps *caps = 0;
+ if (pixelFormat == QVideoFrame::Format_Invalid)
+ caps = QGstUtils::videoFilterCaps();
+ else
+ caps = QGstUtils::capsForFormats(QList<QVideoFrame::PixelFormat>() << pixelFormat);
if (!resolution.isEmpty()) {
gst_caps_set_simple(
@@ -281,75 +299,92 @@ static GstCaps *resolutionToCaps(const QSize &resolution, qreal frameRate = 0.0)
void CameraBinSession::setupCaptureResolution()
{
- QSize resolution = m_imageEncodeControl->imageSettings().resolution();
- {
- GstCaps *caps = resolutionToCaps(resolution);
-#if CAMERABIN_DEBUG
- qDebug() << Q_FUNC_INFO << "set image resolution" << resolution << caps;
-#endif
- g_object_set(m_camerabin, IMAGE_CAPTURE_CAPS_PROPERTY, caps, NULL);
- if (caps)
- gst_caps_unref(caps);
- }
+ QSize viewfinderResolution = m_viewfinderSettings.resolution();
+ qreal viewfinderFrameRate = m_viewfinderSettings.maximumFrameRate();
+ QVideoFrame::PixelFormat viewfinderPixelFormat = m_viewfinderSettings.pixelFormat();
+ const QSize imageResolution = m_imageEncodeControl->imageSettings().resolution();
+ const QSize videoResolution = m_videoEncodeControl->actualVideoSettings().resolution();
+
+ // WrapperCameraBinSrc cannot have different caps on its imgsrc, vidsrc and vfsrc pads.
+ // If capture resolution is specified, use it also for the viewfinder to avoid caps negotiation
+ // to fail.
+ if (m_usingWrapperCameraBinSrc) {
+ if (m_captureMode == QCamera::CaptureStillImage && !imageResolution.isEmpty())
+ viewfinderResolution = imageResolution;
+ else if (m_captureMode == QCamera::CaptureVideo && !videoResolution.isEmpty())
+ viewfinderResolution = videoResolution;
+
+ // Make sure we don't use incompatible frame rate and pixel format with the new resolution
+ if (viewfinderResolution != m_viewfinderSettings.resolution() &&
+ (!qFuzzyIsNull(viewfinderFrameRate) || viewfinderPixelFormat != QVideoFrame::Format_Invalid)) {
+
+ enum {
+ Nothing = 0x0,
+ OnlyFrameRate = 0x1,
+ OnlyPixelFormat = 0x2,
+ Both = 0x4
+ };
+ quint8 found = Nothing;
+
+ for (int i = 0; i < m_supportedViewfinderSettings.count() && !(found & Both); ++i) {
+ const QCameraViewfinderSettings &s = m_supportedViewfinderSettings.at(i);
+ if (s.resolution() == viewfinderResolution) {
+ if ((qFuzzyIsNull(viewfinderFrameRate) || s.maximumFrameRate() == viewfinderFrameRate)
+ && (viewfinderPixelFormat == QVideoFrame::Format_Invalid || s.pixelFormat() == viewfinderPixelFormat))
+ found |= Both;
+ else if (s.maximumFrameRate() == viewfinderFrameRate)
+ found |= OnlyFrameRate;
+ else if (s.pixelFormat() == viewfinderPixelFormat)
+ found |= OnlyPixelFormat;
+ }
+ }
- const QSize viewfinderResolution = m_viewfinderSettingsControl->resolution();
- resolution = m_videoEncodeControl->actualVideoSettings().resolution();
- qreal framerate = m_videoEncodeControl->videoSettings().frameRate();
- {
- GstCaps *caps = resolutionToCaps(
- !resolution.isEmpty() ? resolution : viewfinderResolution, framerate);
-#if CAMERABIN_DEBUG
- qDebug() << Q_FUNC_INFO << "set video resolution" << resolution << caps;
-#endif
- g_object_set(m_camerabin, VIDEO_CAPTURE_CAPS_PROPERTY, caps, NULL);
- if (caps)
- gst_caps_unref(caps);
+ if (found & Both) {
+ // no-op
+ } else if (found & OnlyPixelFormat) {
+ viewfinderFrameRate = qreal(0);
+ } else if (found & OnlyFrameRate) {
+ viewfinderPixelFormat = QVideoFrame::Format_Invalid;
+ } else {
+ viewfinderPixelFormat = QVideoFrame::Format_Invalid;
+ viewfinderFrameRate = qreal(0);
+ }
+ }
}
- if (!viewfinderResolution.isEmpty())
- resolution = viewfinderResolution;
+ GstCaps *caps = resolutionToCaps(imageResolution);
+ g_object_set(m_camerabin, IMAGE_CAPTURE_CAPS_PROPERTY, caps, NULL);
+ gst_caps_unref(caps);
- {
- GstCaps *caps = resolutionToCaps(resolution);
-#if CAMERABIN_DEBUG
- qDebug() << Q_FUNC_INFO << "set viewfinder resolution" << resolution << caps;
-#endif
- g_object_set(m_camerabin, VIEWFINDER_CAPS_PROPERTY, caps, NULL);
- if (caps)
- gst_caps_unref(caps);
-
- GstElement *mfw_v4lsrc = 0;
- if (g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSrc), "video-source")) {
- GstElement *videoSrc = 0;
- g_object_get(G_OBJECT(m_videoSrc), "video-source", &videoSrc, NULL);
- if (videoSrc) {
- const char *name = gst_plugin_feature_get_name(GST_PLUGIN_FEATURE(gst_element_get_factory(videoSrc)));
- if (!qstrcmp(name, "mfw_v4lsrc"))
- mfw_v4lsrc = videoSrc;
- }
- }
+ qreal framerate = m_videoEncodeControl->videoSettings().frameRate();
+ caps = resolutionToCaps(videoResolution, framerate);
+ g_object_set(m_camerabin, VIDEO_CAPTURE_CAPS_PROPERTY, caps, NULL);
+ gst_caps_unref(caps);
- if (mfw_v4lsrc) {
- int capMode = 0;
- if (resolution == QSize(320, 240))
- capMode = 1;
- else if (resolution == QSize(720, 480))
- capMode = 2;
- else if (resolution == QSize(720, 576))
- capMode = 3;
- else if (resolution == QSize(1280, 720))
- capMode = 4;
- else if (resolution == QSize(1920, 1080))
- capMode = 5;
- g_object_set(G_OBJECT(mfw_v4lsrc), "capture-mode", capMode, NULL);
-
- const qreal maxFps = m_viewfinderSettingsControl->maximumFrameRate();
- if (!qFuzzyIsNull(maxFps)) {
- int n, d;
- gst_util_double_to_fraction(maxFps, &n, &d);
- g_object_set(G_OBJECT(mfw_v4lsrc), "fps-n", n, NULL);
- g_object_set(G_OBJECT(mfw_v4lsrc), "fps-d", d, NULL);
- }
+ caps = resolutionToCaps(viewfinderResolution, viewfinderFrameRate, viewfinderPixelFormat);
+ g_object_set(m_camerabin, VIEWFINDER_CAPS_PROPERTY, caps, NULL);
+ gst_caps_unref(caps);
+
+ // Special case when using mfw_v4lsrc
+ if (m_videoSrc && qstrcmp(gst_plugin_feature_get_name(GST_PLUGIN_FEATURE(gst_element_get_factory(m_videoSrc))), "mfw_v4lsrc") == 0) {
+ int capMode = 0;
+ if (viewfinderResolution == QSize(320, 240))
+ capMode = 1;
+ else if (viewfinderResolution == QSize(720, 480))
+ capMode = 2;
+ else if (viewfinderResolution == QSize(720, 576))
+ capMode = 3;
+ else if (viewfinderResolution == QSize(1280, 720))
+ capMode = 4;
+ else if (viewfinderResolution == QSize(1920, 1080))
+ capMode = 5;
+ g_object_set(G_OBJECT(m_videoSrc), "capture-mode", capMode, NULL);
+
+ if (!qFuzzyIsNull(viewfinderFrameRate)) {
+ int n, d;
+ gst_util_double_to_fraction(viewfinderFrameRate, &n, &d);
+ g_object_set(G_OBJECT(m_videoSrc), "fps-n", n, NULL);
+ g_object_set(G_OBJECT(m_videoSrc), "fps-d", d, NULL);
}
}
@@ -395,28 +430,31 @@ GstElement *CameraBinSession::buildCameraSource()
#if CAMERABIN_DEBUG
qDebug() << Q_FUNC_INFO;
#endif
- if (!m_videoInputHasChanged)
- return m_videoSrc;
- m_videoInputHasChanged = false;
+ if (!m_inputDeviceHasChanged)
+ return m_cameraSrc;
- GstElement *videoSrc = 0;
+ m_inputDeviceHasChanged = false;
+ m_usingWrapperCameraBinSrc = false;
- if (!videoSrc)
- g_object_get(G_OBJECT(m_camerabin), CAMERA_SOURCE_PROPERTY, &videoSrc, NULL);
+ GstElement *camSrc = 0;
+ g_object_get(G_OBJECT(m_camerabin), CAMERA_SOURCE_PROPERTY, &camSrc, NULL);
if (m_sourceFactory)
- m_videoSrc = gst_element_factory_create(m_sourceFactory, "camera_source");
+ m_cameraSrc = gst_element_factory_create(m_sourceFactory, "camera_source");
// If gstreamer has set a default source use it.
- if (!m_videoSrc)
- m_videoSrc = videoSrc;
+ if (!m_cameraSrc)
+ m_cameraSrc = camSrc;
- if (m_videoSrc && !m_inputDevice.isEmpty()) {
+ if (m_cameraSrc && !m_inputDevice.isEmpty()) {
#if CAMERABIN_DEBUG
qDebug() << "set camera device" << m_inputDevice;
#endif
+ const char *const cameraSrcName = gst_plugin_feature_get_name(
+ GST_PLUGIN_FEATURE(gst_element_get_factory(m_cameraSrc)));
+ m_usingWrapperCameraBinSrc = qstrcmp(cameraSrcName, "wrappercamerabinsrc") == 0;
- if (g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSrc), "video-source")) {
+ if (g_object_class_find_property(G_OBJECT_GET_CLASS(m_cameraSrc), "video-source")) {
GstElement *src = 0;
/* QT_GSTREAMER_CAMERABIN_VIDEOSRC can be used to set the video source element.
@@ -458,24 +496,25 @@ GstElement *CameraBinSession::buildCameraSource()
if (src) {
g_object_set(G_OBJECT(src), "device", m_inputDevice.toUtf8().constData(), NULL);
- g_object_set(G_OBJECT(m_videoSrc), "video-source", src, NULL);
+ g_object_set(G_OBJECT(m_cameraSrc), "video-source", src, NULL);
+ m_videoSrc = src;
}
- } else if (g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSrc), "camera-device")) {
+ } else if (g_object_class_find_property(G_OBJECT_GET_CLASS(m_cameraSrc), "camera-device")) {
if (m_inputDevice == QLatin1String("secondary")) {
- g_object_set(G_OBJECT(m_videoSrc), "camera-device", 1, NULL);
+ g_object_set(G_OBJECT(m_cameraSrc), "camera-device", 1, NULL);
} else {
- g_object_set(G_OBJECT(m_videoSrc), "camera-device", 0, NULL);
+ g_object_set(G_OBJECT(m_cameraSrc), "camera-device", 0, NULL);
}
}
}
- if (m_videoSrc != videoSrc)
- g_object_set(G_OBJECT(m_camerabin), CAMERA_SOURCE_PROPERTY, m_videoSrc, NULL);
+ if (m_cameraSrc != camSrc)
+ g_object_set(G_OBJECT(m_camerabin), CAMERA_SOURCE_PROPERTY, m_cameraSrc, NULL);
- if (videoSrc)
- gst_object_unref(GST_OBJECT(videoSrc));
+ if (camSrc)
+ gst_object_unref(GST_OBJECT(camSrc));
- return m_videoSrc;
+ return m_cameraSrc;
}
void CameraBinSession::captureImage(int requestId, const QString &fileName)
@@ -588,7 +627,7 @@ void CameraBinSession::setDevice(const QString &device)
{
if (m_inputDevice != device) {
m_inputDevice = device;
- m_videoInputHasChanged = true;
+ m_inputDeviceHasChanged = true;
}
}
@@ -600,7 +639,7 @@ void CameraBinSession::setAudioInput(QGstreamerElementFactory *audioInput)
void CameraBinSession::setVideoInput(QGstreamerElementFactory *videoInput)
{
m_videoInputFactory = videoInput;
- m_videoInputHasChanged = true;
+ m_inputDeviceHasChanged = true;
}
bool CameraBinSession::isReady() const
@@ -648,6 +687,28 @@ void CameraBinSession::setViewfinder(QObject *viewfinder)
}
}
+QList<QCameraViewfinderSettings> CameraBinSession::supportedViewfinderSettings() const
+{
+ return m_supportedViewfinderSettings;
+}
+
+QCameraViewfinderSettings CameraBinSession::viewfinderSettings() const
+{
+ return m_status == QCamera::ActiveStatus ? m_actualViewfinderSettings : m_viewfinderSettings;
+}
+
+void CameraBinSession::ViewfinderProbe::probeCaps(GstCaps *caps)
+{
+ // Update actual viewfinder settings on viewfinder caps change
+ const GstStructure *s = gst_caps_get_structure(caps, 0);
+ const QPair<qreal, qreal> frameRate = QGstUtils::structureFrameRateRange(s);
+ session->m_actualViewfinderSettings.setResolution(QGstUtils::structureResolution(s));
+ session->m_actualViewfinderSettings.setMinimumFrameRate(frameRate.first);
+ session->m_actualViewfinderSettings.setMaximumFrameRate(frameRate.second);
+ session->m_actualViewfinderSettings.setPixelFormat(QGstUtils::structurePixelFormat(s));
+ session->m_actualViewfinderSettings.setPixelAspectRatio(QGstUtils::structurePixelAspectRatio(s));
+}
+
void CameraBinSession::handleViewfinderChange()
{
//the viewfinder will be reloaded
@@ -755,6 +816,8 @@ void CameraBinSession::unload()
if (m_busy)
emit busyChanged(m_busy = false);
+ m_supportedViewfinderSettings.clear();
+
setStatus(QCamera::UnloadedStatus);
}
@@ -1010,6 +1073,9 @@ bool CameraBinSession::processBusMessage(const QGstreamerMessage &message)
setStatus(QCamera::UnloadedStatus);
break;
case GST_STATE_READY:
+ if (oldState == GST_STATE_NULL)
+ updateSupportedViewfinderSettings();
+
setMetaData(m_metaData);
setStatus(QCamera::LoadedStatus);
break;
@@ -1329,6 +1395,54 @@ QList<QSize> CameraBinSession::supportedResolutions(QPair<int,int> rate,
return res;
}
+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);
+
+ // Convert caps to QCameraViewfinderSettings
+ if (supportedCaps) {
+ supportedCaps = qt_gst_caps_normalize(supportedCaps);
+
+ for (uint i = 0; i < gst_caps_get_size(supportedCaps); i++) {
+ const GstStructure *structure = gst_caps_get_structure(supportedCaps, i);
+
+ QCameraViewfinderSettings s;
+ s.setResolution(QGstUtils::structureResolution(structure));
+ s.setPixelFormat(QGstUtils::structurePixelFormat(structure));
+ s.setPixelAspectRatio(QGstUtils::structurePixelAspectRatio(structure));
+
+ QPair<qreal, qreal> frameRateRange = QGstUtils::structureFrameRateRange(structure);
+ s.setMinimumFrameRate(frameRateRange.first);
+ s.setMaximumFrameRate(frameRateRange.second);
+
+ if (!s.resolution().isEmpty()
+ && s.pixelFormat() != QVideoFrame::Format_Invalid
+ && !m_supportedViewfinderSettings.contains(s)) {
+
+ m_supportedViewfinderSettings.append(s);
+ }
+ }
+
+ gst_caps_unref(supportedCaps);
+ }
+}
+
void CameraBinSession::elementAdded(GstBin *, GstElement *element, CameraBinSession *session)
{
GstElementFactory *factory = gst_element_get_factory(element);
diff --git a/src/plugins/gstreamer/camerabin/camerabinsession.h b/src/plugins/gstreamer/camerabin/camerabinsession.h
index d4214a620..fa9dba989 100644
--- a/src/plugins/gstreamer/camerabin/camerabinsession.h
+++ b/src/plugins/gstreamer/camerabin/camerabinsession.h
@@ -45,6 +45,7 @@
#endif
#include <private/qgstreamerbushelper_p.h>
+#include <private/qgstreamerbufferprobe_p.h>
#include "qcamera.h"
QT_BEGIN_NAMESPACE
@@ -74,7 +75,6 @@ public:
virtual GstElement *buildElement() = 0;
};
-
class CameraBinSession : public QObject,
public QGstreamerBusMessageFilter,
public QGstreamerSyncMessageFilter
@@ -131,7 +131,6 @@ public:
CameraBinImageProcessing *imageProcessingControl() const { return m_imageProcessingControl; }
CameraBinCaptureDestination *captureDestinationControl() const { return m_captureDestinationControl; }
CameraBinCaptureBufferFormat *captureBufferFormatControl() const { return m_captureBufferFormatControl; }
- CameraBinViewfinderSettings *viewfinderSettingsControl() const { return m_viewfinderSettingsControl; }
CameraBinRecorder *recorderControl() const { return m_recorderControl; }
CameraBinContainer *mediaContainerControl() const { return m_mediaContainerControl; }
@@ -146,6 +145,10 @@ public:
QObject *viewfinder() const { return m_viewfinder; }
void setViewfinder(QObject *viewfinder);
+ QList<QCameraViewfinderSettings> supportedViewfinderSettings() const;
+ QCameraViewfinderSettings viewfinderSettings() const;
+ void setViewfinderSettings(const QCameraViewfinderSettings &settings) { m_viewfinderSettings = settings; }
+
void captureImage(int requestId, const QString &fileName);
QCamera::Status status() const;
@@ -197,6 +200,7 @@ private:
bool setupCameraBin();
void setupCaptureResolution();
void setAudioCaptureCaps();
+ void updateSupportedViewfinderSettings();
static void updateBusyStatus(GObject *o, GParamSpec *p, gpointer d);
static void elementAdded(GstBin *bin, GstElement *element, CameraBinSession *session);
@@ -219,6 +223,9 @@ private:
QGstreamerElementFactory *m_videoInputFactory;
QObject *m_viewfinder;
QGstreamerVideoRendererInterface *m_viewfinderInterface;
+ QList<QCameraViewfinderSettings> m_supportedViewfinderSettings;
+ QCameraViewfinderSettings m_viewfinderSettings;
+ QCameraViewfinderSettings m_actualViewfinderSettings;
CameraBinControl *m_cameraControl;
CameraBinAudioEncoder *m_audioEncodeControl;
@@ -237,16 +244,30 @@ private:
CameraBinImageProcessing *m_imageProcessingControl;
CameraBinCaptureDestination *m_captureDestinationControl;
CameraBinCaptureBufferFormat *m_captureBufferFormatControl;
- CameraBinViewfinderSettings *m_viewfinderSettingsControl;
QGstreamerBusHelper *m_busHelper;
GstBus* m_bus;
GstElement *m_camerabin;
+ GstElement *m_cameraSrc;
GstElement *m_videoSrc;
GstElement *m_viewfinderElement;
GstElementFactory *m_sourceFactory;
bool m_viewfinderHasChanged;
- bool m_videoInputHasChanged;
+ bool m_inputDeviceHasChanged;
+ bool m_usingWrapperCameraBinSrc;
+
+ class ViewfinderProbe : public QGstreamerBufferProbe {
+ public:
+ ViewfinderProbe(CameraBinSession *s)
+ : QGstreamerBufferProbe(QGstreamerBufferProbe::ProbeCaps)
+ , session(s)
+ {}
+
+ void probeCaps(GstCaps *caps);
+
+ private:
+ CameraBinSession * const session;
+ } m_viewfinderProbe;
GstElement *m_audioSrc;
GstElement *m_audioConvert;
diff --git a/src/plugins/gstreamer/camerabin/camerabinviewfindersettings.cpp b/src/plugins/gstreamer/camerabin/camerabinviewfindersettings.cpp
index 6b2236c2f..8155c182a 100644
--- a/src/plugins/gstreamer/camerabin/camerabinviewfindersettings.cpp
+++ b/src/plugins/gstreamer/camerabin/camerabinviewfindersettings.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2013 Jolla Ltd.
+** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the Qt Toolkit.
@@ -33,14 +34,14 @@
#include "camerabinviewfindersettings.h"
-
+#include "camerabinsession.h"
QT_BEGIN_NAMESPACE
-CameraBinViewfinderSettings::CameraBinViewfinderSettings(QObject *parent)
- : QCameraViewfinderSettingsControl(parent),
- m_minimumFrameRate(0),
- m_maximumFrameRate(0)
+
+CameraBinViewfinderSettings::CameraBinViewfinderSettings(CameraBinSession *session)
+ : QCameraViewfinderSettingsControl(session)
+ , m_session(session)
{
}
@@ -52,11 +53,11 @@ bool CameraBinViewfinderSettings::isViewfinderParameterSupported(ViewfinderParam
{
switch (parameter) {
case Resolution:
+ case PixelAspectRatio:
case MinimumFrameRate:
case MaximumFrameRate:
- return true;
- case PixelAspectRatio:
case PixelFormat:
+ return true;
case UserParameter:
return false;
}
@@ -67,13 +68,15 @@ QVariant CameraBinViewfinderSettings::viewfinderParameter(ViewfinderParameter pa
{
switch (parameter) {
case Resolution:
- return m_resolution;
+ return m_session->viewfinderSettings().resolution();
+ case PixelAspectRatio:
+ return m_session->viewfinderSettings().pixelAspectRatio();
case MinimumFrameRate:
- return m_minimumFrameRate;
+ return m_session->viewfinderSettings().minimumFrameRate();
case MaximumFrameRate:
- return m_maximumFrameRate;
- case PixelAspectRatio:
+ return m_session->viewfinderSettings().maximumFrameRate();
case PixelFormat:
+ return m_session->viewfinderSettings().pixelFormat();
case UserParameter:
return QVariant();
}
@@ -82,36 +85,28 @@ QVariant CameraBinViewfinderSettings::viewfinderParameter(ViewfinderParameter pa
void CameraBinViewfinderSettings::setViewfinderParameter(ViewfinderParameter parameter, const QVariant &value)
{
+ QCameraViewfinderSettings settings = m_session->viewfinderSettings();
+
switch (parameter) {
case Resolution:
- m_resolution = value.toSize();
+ settings.setResolution(value.toSize());
+ break;
+ case PixelAspectRatio:
+ settings.setPixelAspectRatio(value.toSize());
break;
case MinimumFrameRate:
- m_minimumFrameRate = value.toFloat();
+ settings.setMinimumFrameRate(value.toReal());
break;
case MaximumFrameRate:
- m_maximumFrameRate = value.toFloat();
+ settings.setMaximumFrameRate(value.toReal());
break;
- case PixelAspectRatio:
case PixelFormat:
+ settings.setPixelFormat(qvariant_cast<QVideoFrame::PixelFormat>(value));
case UserParameter:
break;
}
-}
-
-QSize CameraBinViewfinderSettings::resolution() const
-{
- return m_resolution;
-}
-qreal CameraBinViewfinderSettings::minimumFrameRate() const
-{
- return m_minimumFrameRate;
-}
-
-qreal CameraBinViewfinderSettings::maximumFrameRate() const
-{
- return m_maximumFrameRate;
+ m_session->setViewfinderSettings(settings);
}
QT_END_NAMESPACE
diff --git a/src/plugins/gstreamer/camerabin/camerabinviewfindersettings.h b/src/plugins/gstreamer/camerabin/camerabinviewfindersettings.h
index eea1df23b..0180e6f40 100644
--- a/src/plugins/gstreamer/camerabin/camerabinviewfindersettings.h
+++ b/src/plugins/gstreamer/camerabin/camerabinviewfindersettings.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2013 Jolla Ltd.
+** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the Qt Toolkit.
@@ -36,29 +37,23 @@
#include <qcameraviewfindersettingscontrol.h>
-#include <QtCore/qsize.h>
-
QT_BEGIN_NAMESPACE
+class CameraBinSession;
+
class CameraBinViewfinderSettings : public QCameraViewfinderSettingsControl
{
Q_OBJECT
public:
- CameraBinViewfinderSettings(QObject *parent);
+ CameraBinViewfinderSettings(CameraBinSession *session);
~CameraBinViewfinderSettings();
bool isViewfinderParameterSupported(ViewfinderParameter parameter) const;
QVariant viewfinderParameter(ViewfinderParameter parameter) const;
void setViewfinderParameter(ViewfinderParameter parameter, const QVariant &value);
- QSize resolution() const;
- qreal minimumFrameRate() const;
- qreal maximumFrameRate() const;
-
private:
- QSize m_resolution;
- qreal m_minimumFrameRate;
- qreal m_maximumFrameRate;
+ CameraBinSession *m_session;
};
QT_END_NAMESPACE
diff --git a/src/plugins/gstreamer/camerabin/camerabinviewfindersettings2.cpp b/src/plugins/gstreamer/camerabin/camerabinviewfindersettings2.cpp
new file mode 100644
index 000000000..9e3c43fb4
--- /dev/null
+++ b/src/plugins/gstreamer/camerabin/camerabinviewfindersettings2.cpp
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "camerabinviewfindersettings2.h"
+#include "camerabinsession.h"
+
+QT_BEGIN_NAMESPACE
+
+CameraBinViewfinderSettings2::CameraBinViewfinderSettings2(CameraBinSession *session)
+ : QCameraViewfinderSettingsControl2(session)
+ , m_session(session)
+{
+
+}
+
+CameraBinViewfinderSettings2::~CameraBinViewfinderSettings2()
+{
+
+}
+
+QList<QCameraViewfinderSettings> CameraBinViewfinderSettings2::supportedViewfinderSettings() const
+{
+ return m_session->supportedViewfinderSettings();
+}
+
+QCameraViewfinderSettings CameraBinViewfinderSettings2::viewfinderSettings() const
+{
+ return m_session->viewfinderSettings();
+}
+
+void CameraBinViewfinderSettings2::setViewfinderSettings(const QCameraViewfinderSettings &settings)
+{
+ m_session->setViewfinderSettings(settings);
+}
+
+QT_END_NAMESPACE
+
diff --git a/src/plugins/gstreamer/camerabin/camerabinviewfindersettings2.h b/src/plugins/gstreamer/camerabin/camerabinviewfindersettings2.h
new file mode 100644
index 000000000..9a0efd0bb
--- /dev/null
+++ b/src/plugins/gstreamer/camerabin/camerabinviewfindersettings2.h
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef CAMERABINVIEWFINDERSETTINGS2_H
+#define CAMERABINVIEWFINDERSETTINGS2_H
+
+#include <qcameraviewfindersettingscontrol.h>
+
+QT_BEGIN_NAMESPACE
+
+class CameraBinSession;
+
+class CameraBinViewfinderSettings2 : public QCameraViewfinderSettingsControl2
+{
+ Q_OBJECT
+public:
+ CameraBinViewfinderSettings2(CameraBinSession *session);
+ ~CameraBinViewfinderSettings2();
+
+ QList<QCameraViewfinderSettings> supportedViewfinderSettings() const;
+
+ QCameraViewfinderSettings viewfinderSettings() const;
+ void setViewfinderSettings(const QCameraViewfinderSettings &settings);
+
+private:
+ CameraBinSession *m_session;
+};
+
+QT_END_NAMESPACE
+
+#endif // CAMERABINVIEWFINDERSETTINGS2_H