Qt-gstreamer and QML sink

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Qt-gstreamer and QML sink

xargon
I will begin by describing a simple gstreamer pipeline which works from the console. I am using gstreamer 1.0.

gst-launch-1.0 -v v4l2src ! xvimagesink -e --gst-debug-level=3 sync=false 

This works fine and I see the camera output on a window. I am now trying to do the same inside my Qt application using QML and Qt-GStreamer.

Now, I can use videotestsrc and display this on a QML window as follows:

C++ side:
m_pipeline = QGst::Pipeline::create();
QGst::ElementPtr videoSourceElement = QGst::ElementFactory::make("videotestsrc");
m_pipeline->add(videoSourceElement);
m_pipeline->add(m_videoSink);  // Add video sink (QML)

if(videoSourceElement->link(m_videoSink) == false) {
    qDebug("videoScaleElement -> videoSink Link failed");
}
else {
    QGst::BusPtr bus = m_pipeline->bus();
    bus->addSignalWatch();
    QGlib::connect(bus, "message", this, &Recorder::onBusMessage);
    qDebug("Calling start...");
    m_pipeline->setState(QGst::StatePlaying);
}

QML side:
ControlView {
    id: recorderWindow
    color: "#000000"
    border.width: 5
    property bool recording: false
    //anchors.centerIn: parent
    VideoItem {
        id: recorderSurface
        surface: videoSurface1  // This is set from the main app
        width: parent.width
        height: parent.height
    }
}

The connection is done via:

QGst::Quick::VideoSurface * surface1 = new QGst::Quick::VideoSurface;
view.rootContext()->setContextProperty("videoSurface1", surface1);

Now this works perfectly fine and I see the test video perfectly fine rendered on my QML window. Now, if I change the line:

QGst::ElementPtr videoSourceElement = QGst::ElementFactory::make("videotestsrc");

to
QGst::ElementPtr videoSourceElement = QGst::ElementFactory::make("v4l2src");

then it does not work.

Setting the GST_DEBUG level to 3, I get:

0:00:02.326885730  7552   0x5a6660 WARN                 basesrc gstbasesrc.c:2865:gst_base_src_loop:<v4l2src0> error: Internal data flow error.
0:00:02.327321891  7552   0x5a6660 WARN                 basesrc gstbasesrc.c:2865:gst_base_src_loop:<v4l2src0> error: streaming task paused, reason not-negotiated (-4)
"Internal data flow error."

I have been struggling with this for months now! Any help would be greatly appreciated!