summaryrefslogtreecommitdiffstats
path: root/src/plugins/gstreamer
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/gstreamer')
-rw-r--r--src/plugins/gstreamer/camerabin/camerabinserviceplugin.cpp16
-rw-r--r--src/plugins/gstreamer/camerabin/camerabinserviceplugin.h4
-rw-r--r--src/plugins/gstreamer/mediacapture/qgstreamercaptureserviceplugin.cpp16
-rw-r--r--src/plugins/gstreamer/mediacapture/qgstreamercaptureserviceplugin.h4
4 files changed, 40 insertions, 0 deletions
diff --git a/src/plugins/gstreamer/camerabin/camerabinserviceplugin.cpp b/src/plugins/gstreamer/camerabin/camerabinserviceplugin.cpp
index 4d530d66f..37641b001 100644
--- a/src/plugins/gstreamer/camerabin/camerabinserviceplugin.cpp
+++ b/src/plugins/gstreamer/camerabin/camerabinserviceplugin.cpp
@@ -90,6 +90,18 @@ QMediaServiceProviderHint::Features CameraBinServicePlugin::supportedFeatures(
return QMediaServiceProviderHint::Features();
}
+QByteArray CameraBinServicePlugin::defaultDevice(const QByteArray &service) const
+{
+ if (service == Q_MEDIASERVICE_CAMERA) {
+ if (m_cameraDevices.isEmpty())
+ updateDevices();
+
+ return m_defaultCameraDevice;
+ }
+
+ return QByteArray();
+}
+
QList<QByteArray> CameraBinServicePlugin::devices(const QByteArray &service) const
{
if (service == Q_MEDIASERVICE_CAMERA) {
@@ -126,6 +138,7 @@ QVariant CameraBinServicePlugin::deviceProperty(const QByteArray &service, const
void CameraBinServicePlugin::updateDevices() const
{
+ m_defaultCameraDevice.clear();
m_cameraDevices.clear();
m_cameraDescriptions.clear();
@@ -167,6 +180,9 @@ void CameraBinServicePlugin::updateDevices() const
}
::close(fd);
}
+
+ if (!m_cameraDevices.isEmpty())
+ m_defaultCameraDevice = m_cameraDevices.first();
}
QT_END_NAMESPACE
diff --git a/src/plugins/gstreamer/camerabin/camerabinserviceplugin.h b/src/plugins/gstreamer/camerabin/camerabinserviceplugin.h
index f0aea0b3a..50ffc59b2 100644
--- a/src/plugins/gstreamer/camerabin/camerabinserviceplugin.h
+++ b/src/plugins/gstreamer/camerabin/camerabinserviceplugin.h
@@ -51,10 +51,12 @@ QT_BEGIN_NAMESPACE
class CameraBinServicePlugin
: public QMediaServiceProviderPlugin
, public QMediaServiceSupportedDevicesInterface
+ , public QMediaServiceDefaultDeviceInterface
, public QMediaServiceFeaturesInterface
{
Q_OBJECT
Q_INTERFACES(QMediaServiceSupportedDevicesInterface)
+ Q_INTERFACES(QMediaServiceDefaultDeviceInterface)
Q_INTERFACES(QMediaServiceFeaturesInterface)
Q_PLUGIN_METADATA(IID "org.qt-project.qt.mediaserviceproviderfactory/5.0" FILE "camerabin.json")
public:
@@ -63,6 +65,7 @@ public:
QMediaServiceProviderHint::Features supportedFeatures(const QByteArray &service) const;
+ QByteArray defaultDevice(const QByteArray &service) const;
QList<QByteArray> devices(const QByteArray &service) const;
QString deviceDescription(const QByteArray &service, const QByteArray &device);
QVariant deviceProperty(const QByteArray &service, const QByteArray &device, const QByteArray &property);
@@ -70,6 +73,7 @@ public:
private:
void updateDevices() const;
+ mutable QByteArray m_defaultCameraDevice;
mutable QList<QByteArray> m_cameraDevices;
mutable QStringList m_cameraDescriptions;
};
diff --git a/src/plugins/gstreamer/mediacapture/qgstreamercaptureserviceplugin.cpp b/src/plugins/gstreamer/mediacapture/qgstreamercaptureserviceplugin.cpp
index dbb7649f4..de07d2707 100644
--- a/src/plugins/gstreamer/mediacapture/qgstreamercaptureserviceplugin.cpp
+++ b/src/plugins/gstreamer/mediacapture/qgstreamercaptureserviceplugin.cpp
@@ -95,6 +95,18 @@ QMediaServiceProviderHint::Features QGstreamerCaptureServicePlugin::supportedFea
return QMediaServiceProviderHint::Features();
}
+QByteArray QGstreamerCaptureServicePlugin::defaultDevice(const QByteArray &service) const
+{
+ if (service == Q_MEDIASERVICE_CAMERA) {
+ if (m_cameraDevices.isEmpty())
+ updateDevices();
+
+ return m_defaultCameraDevice;
+ }
+
+ return QByteArray();
+}
+
QList<QByteArray> QGstreamerCaptureServicePlugin::devices(const QByteArray &service) const
{
if (service == Q_MEDIASERVICE_CAMERA) {
@@ -131,6 +143,7 @@ QVariant QGstreamerCaptureServicePlugin::deviceProperty(const QByteArray &servic
void QGstreamerCaptureServicePlugin::updateDevices() const
{
+ m_defaultCameraDevice.clear();
m_cameraDevices.clear();
m_cameraDescriptions.clear();
@@ -174,6 +187,9 @@ void QGstreamerCaptureServicePlugin::updateDevices() const
}
::close(fd);
}
+
+ if (!m_cameraDevices.isEmpty())
+ m_defaultCameraDevice = m_cameraDevices.first();
}
#endif
diff --git a/src/plugins/gstreamer/mediacapture/qgstreamercaptureserviceplugin.h b/src/plugins/gstreamer/mediacapture/qgstreamercaptureserviceplugin.h
index 3003cbbcc..a1141d324 100644
--- a/src/plugins/gstreamer/mediacapture/qgstreamercaptureserviceplugin.h
+++ b/src/plugins/gstreamer/mediacapture/qgstreamercaptureserviceplugin.h
@@ -53,6 +53,7 @@ class QGstreamerCaptureServicePlugin
: public QMediaServiceProviderPlugin
#if defined(USE_GSTREAMER_CAMERA)
, public QMediaServiceSupportedDevicesInterface
+ , public QMediaServiceDefaultDeviceInterface
, public QMediaServiceFeaturesInterface
#endif
, public QMediaServiceSupportedFormatsInterface
@@ -60,6 +61,7 @@ class QGstreamerCaptureServicePlugin
Q_OBJECT
#if defined(USE_GSTREAMER_CAMERA)
Q_INTERFACES(QMediaServiceSupportedDevicesInterface)
+ Q_INTERFACES(QMediaServiceDefaultDeviceInterface)
Q_INTERFACES(QMediaServiceFeaturesInterface)
#endif
Q_INTERFACES(QMediaServiceSupportedFormatsInterface)
@@ -75,6 +77,7 @@ public:
#if defined(USE_GSTREAMER_CAMERA)
QMediaServiceProviderHint::Features supportedFeatures(const QByteArray &service) const;
+ QByteArray defaultDevice(const QByteArray &service) const;
QList<QByteArray> devices(const QByteArray &service) const;
QString deviceDescription(const QByteArray &service, const QByteArray &device);
QVariant deviceProperty(const QByteArray &service, const QByteArray &device, const QByteArray &property);
@@ -87,6 +90,7 @@ private:
#if defined(USE_GSTREAMER_CAMERA)
void updateDevices() const;
+ mutable QByteArray m_defaultCameraDevice;
mutable QList<QByteArray> m_cameraDevices;
mutable QStringList m_cameraDescriptions;
#endif