Allow the camerabin source selection to be overridden.

Prefer the default camera-source element if there is one or an element
identified by an environment variable to a static list of possible
elements which may not be appropriate for the target environment.

Change-Id: I53816c949307953780f9046eb11e09effe059be0
Reviewed-by: John Brooks <john.brooks@dereferenced.net>
Reviewed-by: Andy Nichols <andy.nichols@digia.com>
Reviewed-by: Yoann Lopes <yoann.lopes@digia.com>
This commit is contained in:
Andrew den Exter
2013-12-10 13:11:07 +10:00
committed by The Qt Project
parent 817c548df4
commit 4d3f740795
5 changed files with 81 additions and 51 deletions

View File

@@ -57,13 +57,24 @@
#include <linux/videodev2.h>
QGstreamerVideoInputDeviceControl::QGstreamerVideoInputDeviceControl(QObject *parent)
:QVideoDeviceSelectorControl(parent), m_selectedDevice(0)
:QVideoDeviceSelectorControl(parent), m_source(0), m_selectedDevice(0)
{
update();
}
QGstreamerVideoInputDeviceControl::QGstreamerVideoInputDeviceControl(GstElement *source, QObject *parent)
:QVideoDeviceSelectorControl(parent), m_source(source), m_selectedDevice(0)
{
if (m_source)
gst_object_ref(GST_OBJECT(m_source));
update();
}
QGstreamerVideoInputDeviceControl::~QGstreamerVideoInputDeviceControl()
{
if (m_source)
gst_object_unref(GST_OBJECT(m_source));
}
int QGstreamerVideoInputDeviceControl::deviceCount() const
@@ -107,10 +118,15 @@ void QGstreamerVideoInputDeviceControl::update()
m_names.clear();
m_descriptions.clear();
#ifdef Q_WS_MAEMO_6
m_names << QLatin1String("primary") << QLatin1String("secondary");
m_descriptions << tr("Main camera") << tr("Front camera");
#else
// subdevsrc and the like have a camera-device property that takes an enumeration
// identifying a primary or secondary camera, so return identifiers that map to those
// instead of a list of actual devices.
if (m_source && g_object_class_find_property(G_OBJECT_GET_CLASS(m_source), "camera-device")) {
m_names << QLatin1String("primary") << QLatin1String("secondary");
m_descriptions << tr("Main camera") << tr("Front camera");
return;
}
QDir devDir("/dev");
devDir.setFilter(QDir::System);
@@ -151,5 +167,4 @@ void QGstreamerVideoInputDeviceControl::update()
}
::close(fd);
}
#endif
}