0

Greeting,

In our IMX8mp based board we are using yocto image based on wayland display server the board is linked to a LVDS screen where we want to display frames from our cameras with gstreamer .

As a first step our QT application is developed to show a dummy video (the src comes from videotestsrc). but whenever I try to launch the qt application in the board, it opens up an additional window where it stream the videotestsrc rather than streaming it inside my widget.

Any tips to how fix this problem ?

Thanks

Zsabhi

my .pro is as followed

QT       += core gui multimedia multimediawidgets concurrent

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

CONFIG += c++11

# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0

SOURCES += \
    camstream.cpp \
    cusbutton.cpp \
    main.cpp \
    widget.cpp

HEADERS += \
    camstream.h \
    cusbutton.h \
    widget.h

FORMS += \
    widget.ui

CONFIG += link_pkgconfig
PKGCONFIG += gstreamer-1.0
PKGCONFIG += gstreamer-video-1.0


# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target


RESOURCES += \
    icones.qrc

and this is where i link the video stream to the widget ( or try to do )

#include "camstream.h"

CamStream::CamStream(QObject *parent,QWidget *ui):QObject(parent),
                               camID(-1),
                               video_sink(nullptr),
                               pipe_display(nullptr)

{
    Q_UNUSED(ui);
    /***  ***/
    gst_init (nullptr, nullptr);
}


GError * CamStream::parse_gst_launch(gchar * cmd)
{
    GError * error = nullptr;
    //qDebug() << ""<<cmd ;
    pipe_display = gst_parse_launch (cmd, &error);
    return error;
}

GstStateChangeReturn CamStream::set_video_sink()
{
    GstStateChangeReturn status ;
    status = gst_element_set_state (this->pipe_display, GST_STATE_READY);
    //this is the call to overlay the gstreamer's output to the Qt Widgets...
    this->video_sink = (gst_bin_get_by_interface(GST_BIN(this->pipe_display), GST_TYPE_VIDEO_OVERLAY));
    gst_video_overlay_set_window_handle (GST_VIDEO_OVERLAY (this->video_sink), this->camID);
    return status;


}

GstStateChangeReturn CamStream::run_pipline()
{
    GstStateChangeReturn status ;
    status = gst_element_set_state (this->pipe_display, GST_STATE_PLAYING);
    return status ;
}

void CamStream::set_cam_id(WId cam_id)
{
    this->camID = cam_id ;
}

  • Problem solved ( after quite some time and bunch of coffee ) , for those who ahave a similar problem, and if your linux distribution is based on Xwayland (not wayland), you need to add the following instructions to your code : ` setenv("DISPLAY",":0",1); setenv("GDK_BACKEND","X11",1); setenv("QT_QPA_PLATFORM","xcb",1);` – sabhi zakaria Jun 14 '23 at 08:22

0 Answers0