Provide face and orientation info from gstreamer camera backend.

Cleans up duplicate device enumeration code so the devices listed by
the QMediaServiceProviderPlugin are the same as those in the
QVideoInputDeviceControl and includes face and orientation information
if available.

Change-Id: Iaa4c303c973bcf3e0f7c8c2fd7a7de629bccec86
Reviewed-by: Yoann Lopes <yoann.lopes@digia.com>
This commit is contained in:
Andrew den Exter
2014-07-08 15:56:05 +10:00
committed by Andrew den Exter
parent 074bd6ab37
commit cddbe8736d
15 changed files with 445 additions and 283 deletions

View File

@@ -119,7 +119,7 @@
QT_BEGIN_NAMESPACE
CameraBinSession::CameraBinSession(QObject *parent)
CameraBinSession::CameraBinSession(GstElementFactory *sourceFactory, QObject *parent)
:QObject(parent),
m_recordingActive(false),
m_state(QCamera::UnloadedState),
@@ -133,6 +133,7 @@ CameraBinSession::CameraBinSession(QObject *parent)
m_viewfinderInterface(0),
m_videoSrc(0),
m_viewfinderElement(0),
m_sourceFactory(sourceFactory),
m_viewfinderHasChanged(true),
m_videoInputHasChanged(true),
m_audioSrc(0),
@@ -142,6 +143,9 @@ CameraBinSession::CameraBinSession(QObject *parent)
m_audioEncoder(0),
m_muxer(0)
{
if (m_sourceFactory)
gst_object_ref(GST_OBJECT(m_sourceFactory));
m_camerabin = gst_element_factory_make("camerabin2", "camerabin2");
g_signal_connect(G_OBJECT(m_camerabin), "notify::idle", G_CALLBACK(updateBusyStatus), this);
qt_gst_object_ref_sink(m_camerabin);
@@ -195,6 +199,9 @@ CameraBinSession::~CameraBinSession()
}
if (m_viewfinderElement)
gst_object_unref(GST_OBJECT(m_viewfinderElement));
if (m_sourceFactory)
gst_object_unref(GST_OBJECT(m_sourceFactory));
}
#ifdef HAVE_GST_PHOTOGRAPHY
@@ -383,32 +390,17 @@ GstElement *CameraBinSession::buildCameraSource()
m_videoInputHasChanged = false;
GstElement *videoSrc = 0;
if (!videoSrc)
g_object_get(G_OBJECT(m_camerabin), CAMERA_SOURCE_PROPERTY, &videoSrc, NULL);
// If the QT_GSTREAMER_CAMERABIN_SRC environment variable has been set use the source
// it recommends.
const QByteArray envCandidate = qgetenv("QT_GSTREAMER_CAMERABIN_SRC");
if (!m_videoSrc && !envCandidate.isEmpty()) {
m_videoSrc = gst_element_factory_make(envCandidate.constData(), "camera_source");
}
if (m_sourceFactory)
m_videoSrc = gst_element_factory_create(m_sourceFactory, "camera_source");
// If gstreamer has set a default source use it.
if (!m_videoSrc)
m_videoSrc = videoSrc;
// If there's no better guidance try the names of some known camera source elements.
if (!m_videoSrc) {
const QList<QByteArray> candidates = QList<QByteArray>()
<< "subdevsrc"
<< "wrappercamerabinsrc";
foreach (const QByteArray &sourceElementName, candidates) {
m_videoSrc = gst_element_factory_make(sourceElementName.constData(), "camera_source");
if (m_videoSrc)
break;
}
}
if (m_videoSrc && !m_inputDevice.isEmpty()) {
#if CAMERABIN_DEBUG
qDebug() << "set camera device" << m_inputDevice;