Requesting for a Solution

deepthimj deepthimj at rangsons-ds.com
Thu Mar 11 06:50:06 UTC 2021


Hello,

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>

intmain(intargc,char*argv[])

{

          gst_init(&argc,&argv);
QApplicationapp(argc,argv);
app.connect(&app,SIGNAL(lastWindowClosed()),&app,SLOT(quit()));

//preparethepipeline

QStringuri="udp://192.169.25.88:500";

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("needtextoverlayfromgst-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);

//preparetheui

QWidgetwindow;

window.resize(320,240);

window.show();

WIdxwinid=window.winId();

if(gst_element_link_many(src,depay,parse,decode,clkoverlay,textOverlay,queue,sink,nullptr)!=true)

{

qDebug()<<"Elementcouldnotbelinked";

}

else{

gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(sink),xwinid);

//runthepipeline

GstStateChangeReturnsret=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);

//Exitapplication

QTimer::singleShot(0,QApplication::activeWindow(),SLOT(quit()));

}

}

intret=app.exec();
     //releasing the resources

window.hide();

gst_element_set_state(pipeline,GST_STATE_NULL);

gst_object_unref(pipeline);

returnret;
}

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20210311/640c24fe/attachment-0001.htm>


More information about the gstreamer-devel mailing list