Requesting for a Solution

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

Requesting for a Solution



I am newbie for gstreamer and QT. I got stuck while doing some coding. I hope you will solve my problem . I am using gstreamer[1.16.0] . In my code, I am overlaying the video on the qwidget. Now I am trying to overlay text and clock on the video through gstreamer but I am getting either text or clock overlay. 

My code is below, Thank You in advance.

#include <QApplication>

#include <QtWidgets/QWidget>
#include <QObject>
#include <QTimer>
#include <gst/gst.h>
#include <gst/video/videooverlay.h>
#include <QDebug>

int main(int argc, char *argv[])
         gst_init (&argc, &argv);
        QApplication app(argc, argv);
        app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit ()));

    // prepare the pipeline

    QString uri = "udp://";

    GstElement *pipeline = gst_pipeline_new ("pipeline");
    GstElement *src = gst_element_factory_make("udpsrc","source");
    GstElement *depay=gst_element_factory_make("rtph264depay","depay");
    GstElement *parse=gst_element_factory_make("h264parse","parse");
    GstElement *queue=gst_element_factory_make("queue","queue");
    GstElement *clkoverlay=gst_element_factory_make("clockoverlay","clockoverlay");
    GstElement *textOverlay = gst_element_factory_make ("textoverlay", nullptr);
    GstElement *decode=gst_element_factory_make("avdec_h264","decode");
    GstElement *sink = gst_element_factory_make ("glimagesink", "sink");

    if (!textOverlay) {
       GST_WARNING ("need textoverlay from gst-plugins-base");
    g_object_set (textOverlay,"text", "GStreamer","font-desc", "Sans, 30", nullptr);
    //Creating and linking pipeline
    GstCaps *caps=gst_caps_new_simple("application/x-rtp","encoding-name",G_TYPE_STRING,"H264","payload",G_TYPE_INT,26,nullptr);
    g_object_set(G_OBJECT(src), "uri", uri.toLatin1().data(), "caps",caps, nullptr);
    gst_bin_add_many(GST_BIN (pipeline), src, depay, parse, decode, clkoverlay, textOverlay, queue, sink, nullptr);
    // prepare the ui

    QWidget window;
    window.resize(320, 240);;

    WId xwinid = window.winId();
    if(gst_element_link_many(src, depay, parse, decode, clkoverlay, textOverlay, queue, sink, nullptr)!= true)
        qDebug()<<"Element could not be linked";
        gst_video_overlay_set_window_handle (GST_VIDEO_OVERLAY (sink), xwinid);

        // run the pipeline
        GstStateChangeReturn sret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
        if (sret == GST_STATE_CHANGE_FAILURE) {
          gst_element_set_state (pipeline, GST_STATE_NULL);
          gst_object_unref (pipeline);
          // Exit application
          QTimer::singleShot(0, QApplication::activeWindow(), SLOT(quit()));

    int ret = app.exec();
    //releasing the resources
    gst_element_set_state (pipeline, GST_STATE_NULL);
    gst_object_unref (pipeline);

    return ret;

gstreamer-devel mailing list
[hidden email]