summaryrefslogtreecommitdiffstats
path: root/src/gsttools/qgstreamervideowidget.cpp
diff options
context:
space:
mode:
authorYoann Lopes <yoann.lopes@theqtcompany.com>2015-02-11 12:40:10 +0100
committerYoann Lopes <yoann.lopes@theqtcompany.com>2015-02-18 11:38:34 +0000
commitfcf5d826a0e2d3ea6a01bf4c962e0d4fe096d321 (patch)
treed64b1517af8754c56acd6a248799e70061099da4 /src/gsttools/qgstreamervideowidget.cpp
parent14b2b53edc14f36ad15afadbd5254e9260118db5 (diff)
GStreamer: improved logic for window and widget controls usage.
Provide these controls only when the xvimagesink gstreamer element is available. This allows QVideoWidget to fallback to QVideoRendererControl when xvimagesink is not available. Task-number: QTBUG-41618 Change-Id: I59f90ea8857c7ec0ffa08be9804e5458d95b79c4 Reviewed-by: Christian Stromme <christian.stromme@theqtcompany.com>
Diffstat (limited to 'src/gsttools/qgstreamervideowidget.cpp')
-rw-r--r--src/gsttools/qgstreamervideowidget.cpp39
1 files changed, 17 insertions, 22 deletions
diff --git a/src/gsttools/qgstreamervideowidget.cpp b/src/gsttools/qgstreamervideowidget.cpp
index aa2e2a30..49601874 100644
--- a/src/gsttools/qgstreamervideowidget.cpp
+++ b/src/gsttools/qgstreamervideowidget.cpp
@@ -93,6 +93,22 @@ QGstreamerVideoWidgetControl::QGstreamerVideoWidgetControl(QObject *parent)
, m_widget(0)
, m_fullScreen(false)
{
+ m_videoSink = gst_element_factory_make ("xvimagesink", NULL);
+
+ if (!m_videoSink)
+ m_videoSink = gst_element_factory_make ("ximagesink", NULL);
+
+ if (m_videoSink) {
+ // Check if the xv sink is usable
+ if (gst_element_set_state(m_videoSink, GST_STATE_READY) != GST_STATE_CHANGE_SUCCESS) {
+ gst_object_unref(GST_OBJECT(m_videoSink));
+ m_videoSink = 0;
+ } else {
+ gst_element_set_state(m_videoSink, GST_STATE_NULL);
+ g_object_set(G_OBJECT(m_videoSink), "force-aspect-ratio", 1, (const char*)NULL);
+ qt_gst_object_ref_sink(GST_OBJECT (m_videoSink)); //Take ownership
+ }
+ }
}
QGstreamerVideoWidgetControl::~QGstreamerVideoWidgetControl()
@@ -105,38 +121,17 @@ QGstreamerVideoWidgetControl::~QGstreamerVideoWidgetControl()
void QGstreamerVideoWidgetControl::createVideoWidget()
{
- if (m_widget)
+ if (!m_videoSink || m_widget)
return;
m_widget = new QGstreamerVideoWidget;
m_widget->installEventFilter(this);
m_windowId = m_widget->winId();
-
- m_videoSink = gst_element_factory_make ("xvimagesink", NULL);
- if (m_videoSink) {
- // Check if the xv sink is usable
- if (gst_element_set_state(m_videoSink, GST_STATE_READY) != GST_STATE_CHANGE_SUCCESS) {
- gst_object_unref(GST_OBJECT(m_videoSink));
- m_videoSink = 0;
- } else {
- gst_element_set_state(m_videoSink, GST_STATE_NULL);
-
- g_object_set(G_OBJECT(m_videoSink), "force-aspect-ratio", 1, (const char*)NULL);
- }
- }
-
- if (!m_videoSink)
- m_videoSink = gst_element_factory_make ("ximagesink", NULL);
-
- qt_gst_object_ref_sink(GST_OBJECT (m_videoSink)); //Take ownership
-
-
}
GstElement *QGstreamerVideoWidgetControl::videoSink()
{
- createVideoWidget();
return m_videoSink;
}