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>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -121,9 +121,23 @@ CameraBinService::CameraBinService(GstElementFactory *sourceFactory, QObject *pa
|
||||
#else
|
||||
m_videoWindow = new QGstreamerVideoWindow(this);
|
||||
#endif
|
||||
// If the GStreamer sink element is not available (xvimagesink), don't provide
|
||||
// the video window control since it won't work anyway.
|
||||
if (!m_videoWindow->videoSink()) {
|
||||
delete m_videoWindow;
|
||||
m_videoWindow = 0;
|
||||
}
|
||||
|
||||
#if defined(HAVE_WIDGETS)
|
||||
m_videoWidgetControl = new QGstreamerVideoWidgetControl(this);
|
||||
|
||||
// If the GStreamer sink element is not available (xvimagesink or ximagesink), don't provide
|
||||
// the video widget control since it won't work anyway.
|
||||
// QVideoWidget will fall back to QVideoRendererControl in that case.
|
||||
if (!m_videoWidgetControl->videoSink()) {
|
||||
delete m_videoWidgetControl;
|
||||
m_videoWidgetControl = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
m_audioInputSelector = new QGstreamerAudioInputSelector(this);
|
||||
|
||||
@@ -48,6 +48,7 @@ class CameraBinControl;
|
||||
class QGstreamerMessage;
|
||||
class QGstreamerBusHelper;
|
||||
class QGstreamerVideoRenderer;
|
||||
class QGstreamerVideoWindow;
|
||||
class QGstreamerVideoWidgetControl;
|
||||
class QGstreamerElementFactory;
|
||||
class CameraBinMetaData;
|
||||
@@ -79,7 +80,7 @@ private:
|
||||
QMediaControl *m_videoOutput;
|
||||
|
||||
QMediaControl *m_videoRenderer;
|
||||
QMediaControl *m_videoWindow;
|
||||
QGstreamerVideoWindow *m_videoWindow;
|
||||
#if defined(HAVE_WIDGETS)
|
||||
QGstreamerVideoWidgetControl *m_videoWidgetControl;
|
||||
#endif
|
||||
|
||||
@@ -102,10 +102,25 @@ QGstreamerCaptureService::QGstreamerCaptureService(const QString &service, QObje
|
||||
m_videoInput->setDevice(m_videoInputDevice->deviceName(m_videoInputDevice->selectedDevice()));
|
||||
|
||||
m_videoRenderer = new QGstreamerVideoRenderer(this);
|
||||
|
||||
m_videoWindow = new QGstreamerVideoWindow(this);
|
||||
// If the GStreamer sink element is not available (xvimagesink), don't provide
|
||||
// the video window control since it won't work anyway.
|
||||
if (!m_videoWindow->videoSink()) {
|
||||
delete m_videoWindow;
|
||||
m_videoWindow = 0;
|
||||
}
|
||||
|
||||
#if defined(HAVE_WIDGETS)
|
||||
m_videoWidgetControl = new QGstreamerVideoWidgetControl(this);
|
||||
|
||||
// If the GStreamer sink element is not available (xvimagesink or ximagesink), don't provide
|
||||
// the video widget control since it won't work anyway.
|
||||
// QVideoWidget will fall back to QVideoRendererControl in that case.
|
||||
if (!m_videoWidgetControl->videoSink()) {
|
||||
delete m_videoWidgetControl;
|
||||
m_videoWidgetControl = 0;
|
||||
}
|
||||
#endif
|
||||
m_imageCaptureControl = new QGstreamerImageCaptureControl(m_captureSession);
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@ class QGstreamerCameraControl;
|
||||
class QGstreamerMessage;
|
||||
class QGstreamerBusHelper;
|
||||
class QGstreamerVideoRenderer;
|
||||
class QGstreamerVideoWindow;
|
||||
class QGstreamerVideoWidgetControl;
|
||||
class QGstreamerElementFactory;
|
||||
class QGstreamerCaptureMetaDataControl;
|
||||
@@ -81,9 +82,9 @@ private:
|
||||
QMediaControl *m_videoOutput;
|
||||
|
||||
QGstreamerVideoRenderer *m_videoRenderer;
|
||||
QMediaControl *m_videoWindow;
|
||||
QGstreamerVideoWindow *m_videoWindow;
|
||||
#if defined(HAVE_WIDGETS)
|
||||
QMediaControl *m_videoWidgetControl;
|
||||
QGstreamerVideoWidgetControl *m_videoWidgetControl;
|
||||
#endif
|
||||
QGstreamerImageCaptureControl *m_imageCaptureControl;
|
||||
};
|
||||
|
||||
@@ -91,9 +91,23 @@ QGstreamerPlayerService::QGstreamerPlayerService(QObject *parent):
|
||||
#else
|
||||
m_videoWindow = new QGstreamerVideoWindow(this);
|
||||
#endif
|
||||
// If the GStreamer sink element is not available (xvimagesink), don't provide
|
||||
// the video window control since it won't work anyway.
|
||||
if (!m_videoWindow->videoSink()) {
|
||||
delete m_videoWindow;
|
||||
m_videoWindow = 0;
|
||||
}
|
||||
|
||||
#if defined(HAVE_WIDGETS)
|
||||
m_videoWidget = new QGstreamerVideoWidgetControl(this);
|
||||
|
||||
// If the GStreamer sink element is not available (xvimagesink or ximagesink), don't provide
|
||||
// the video widget control since it won't work anyway.
|
||||
// QVideoWidget will fall back to QVideoRendererControl in that case.
|
||||
if (!m_videoWidget->videoSink()) {
|
||||
delete m_videoWidget;
|
||||
m_videoWidget = 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -50,6 +50,7 @@ class QGstreamerPlayerSession;
|
||||
class QGstreamerMetaDataProvider;
|
||||
class QGstreamerStreamsControl;
|
||||
class QGstreamerVideoRenderer;
|
||||
class QGstreamerVideoWindow;
|
||||
class QGstreamerVideoWidgetControl;
|
||||
class QGStreamerAvailabilityControl;
|
||||
|
||||
@@ -72,9 +73,9 @@ private:
|
||||
|
||||
QMediaControl *m_videoOutput;
|
||||
QMediaControl *m_videoRenderer;
|
||||
QMediaControl *m_videoWindow;
|
||||
QGstreamerVideoWindow *m_videoWindow;
|
||||
#if defined(HAVE_WIDGETS)
|
||||
QMediaControl *m_videoWidget;
|
||||
QGstreamerVideoWidgetControl *m_videoWidget;
|
||||
#endif
|
||||
|
||||
void increaseVideoRef();
|
||||
|
||||
Reference in New Issue
Block a user