diff options
Diffstat (limited to 'src/plugins/gstreamer/camerabin/camerabinsession.cpp')
-rw-r--r-- | src/plugins/gstreamer/camerabin/camerabinsession.cpp | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/src/plugins/gstreamer/camerabin/camerabinsession.cpp b/src/plugins/gstreamer/camerabin/camerabinsession.cpp index a835b1ce5..b18e9c93c 100644 --- a/src/plugins/gstreamer/camerabin/camerabinsession.cpp +++ b/src/plugins/gstreamer/camerabin/camerabinsession.cpp @@ -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; |