Tom Atix
Tom Atix

Reputation: 401

GStreamer: Pipeline working in gst-launch-1.0 command, but not in c++ code

I have a pipeline running on my client:

gst-launch-1.0 tcpclientsrc port=3344 host=10.0.0.7 ! tsdemux ! h264parse ! avdec_h264 ! autovideosink

which is working perfectly. Now I am trying to transform it to a c++ program, which displays it in a Qt widget using qmlglsink.

I figured out the following, test code, which is working for me:

GstElement *pipeline = gst_pipeline_new(NULL);
GstElement *src = gst_element_factory_make("videotestsrc",NULL);
GstElement *glupload = gst_element_factory_make("glupload",NULL);
GstElement *qmlglsink = gst_element_factory_make("qmlglsink",NULL);

g_assert(src && glupload && qmlglsink);

gst_bin_add_many(GST_BIN(pipeline), src, glupload, sink);
gst_element_link_many(src, glupload, sink, NULL);

Now I tried to convert the other pipeline that way:

GstElement *pipeline = gst_pipeline_new(NULL);
GstElement *src = gst_element_factory_make("tcpclientsrc",NULL);
GstElement *demuxer = gst_element_factory_make("tsdemux",NULL);
GstElement *parser = gst_element_factory_make("h264parse",NULL);
GstElement *decoder = gst_element_factory_make("avdec_h264",NULL);
GstElement *glupload = gst_element_factory_make("glupload",NULL);
GstElement *qmlglsink = gst_element_factory_make("qmlglsink",NULL);

g_assert(src && demuxer && parser && decoder && glupload && qmlglsink);

g_object_set(G_OBJECT(src), "host", "10.0.0.7", NULL);
g_object_set(G_OBJECT(src), "port", 3344, NULL);

gst_bin_add_many(GST_BIN(pipeline), src, demuxer, parser, decoder, glupload, sink);
gst_element_link_many(src, demuxer, parser, decoder, glupload, sink, NULL);

But when I run the latter pipeline, it does nothing. No error, but no video stream as well. I think I missed something with the link commands. Please help and tell me what I am doing wrong.

Upvotes: 3

Views: 1817

Answers (1)

Florian Zwoch
Florian Zwoch

Reputation: 7373

No error? Do you poll the pipeline bus for error messages? Have you run the app with GST_DEBUG=3 to check for hints?

But just from looking at it - I assume avdec_h264 will have I420 as output video format and qmlglsink requires RGBA format. So you are missing a color space converter. Since you are uploading to GL anyway I would recommend to use glcolorconvert.

So change your code to create a pipeline like this: .. ! glupload ! glcolorconvert ! qmlglsink

Upvotes: 1

Related Questions