Problem with gstreamer using the tsdemux

Torben t.wiggerich at airrobot.de
Tue Oct 6 11:02:19 UTC 2020


Hi all,

I have a problem to get the srcipt running in my application. So at first I
tried to compile the following:

gst-launch-1.0 -v udpsrc multicast-group=224.10.10.10 port=8008 ! tsdemux !
h264parse ! avdec_h264 ! d3dvideosink sync=false

It worked and displays the correct video.

But if I try to do this in my application than happens nothing. I think the
problem is that the event linkElements does not get called. So it comes from
the pad-added signal of the tsdemux. I do not get any errors, or at least I
cannot see them. So it seems for me that everything is ok. But the signal is
not getting called...

I run the following code with GST_DEBUG level 4.  gstdebug(4).txt
<http://gstreamer-devel.966125.n4.nabble.com/file/t379676/gstdebug%284%29.txt>  

Can you please tell me what I am doing wrong?

#include <QCoreApplication>
#include <gst/gst.h>
#include <iostream>

typedef struct
{
  GstElement * pipeline = nullptr;
  GstElement * source = nullptr;
  GstElement * tsDemux = nullptr;
  GstElement * h264parse = nullptr;
  GstElement * avdecH264 = nullptr;
  GstElement * sinkVideo = nullptr;
} VideoData;

static void linkElements(GstElement* element,GstPad* sourcePad, gpointer
sinkElement);

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
    GMainLoop *loop;

    if (!g_thread_supported ())
        g_thread_init (nullptr);

    gst_init ( 0, 0 );

    loop = g_main_loop_new (nullptr, FALSE);

    VideoData m_data;

    m_data.pipeline = gst_pipeline_new ("player");
    m_data.source = gst_element_factory_make ("udpsrc", nullptr);
    m_data.tsDemux = gst_element_factory_make("tsdemux", nullptr);
    m_data.h264parse = gst_element_factory_make("h264parse", nullptr);
    m_data.avdecH264 = gst_element_factory_make("avdec_h264", nullptr);
    m_data.sinkVideo = gst_element_factory_make("d3dvideosink", nullptr);

    g_object_set(G_OBJECT (m_data.source), "multicast-group",
"224.10.10.10", nullptr);
    g_object_set(G_OBJECT (m_data.source), "port", 8008, nullptr);
    g_object_set(G_OBJECT (m_data.sinkVideo), "sync", false, nullptr);

    gst_bin_add_many(GST_BIN(m_data.pipeline), m_data.source,
m_data.tsDemux, m_data.h264parse, m_data.avdecH264, m_data.sinkVideo,
nullptr);

    std::cout << "Start linking all elements..." << std::endl;

    if ( gst_element_link (m_data.source, m_data.tsDemux ) != TRUE )
    {
        std::cout << "1: Element could not be linked." << std::endl;
        gst_object_unref (m_data.pipeline);
        return 0;
    }

    g_signal_connect(m_data.tsDemux, "pad-added", G_CALLBACK(linkElements),
nullptr); //nullptr //&m_data

    if ( gst_element_link_many(m_data.h264parse, m_data.avdecH264,
m_data.sinkVideo, nullptr) != TRUE )
    {
        std::cout << "2: Element could not be linked." << std::endl;
        gst_object_unref (m_data.pipeline);
        return 0;
    }

    std::cout << "Linked all elements!" << std::endl;

    GstStateChangeReturn ret = gst_element_set_state(m_data.sinkVideo,
GST_STATE_READY);

    ret = gst_element_set_state (m_data.pipeline, GST_STATE_PLAYING);
    if (ret == GST_STATE_CHANGE_FAILURE)
    {
        std::cout << "Unable to set the pipeline to the playing state." <<
std::endl;
        gst_object_unref (m_data.pipeline);
        return 0;
    }

    g_main_loop_run (loop);

    return a.exec();
}

static void linkElements(GstElement* element,GstPad* sourcePad, gpointer
sinkElement){
    std::cout << "Got here linkElements!" << std::endl; // It will never get
here!
    GstPad*
sinkPad=gst_element_get_static_pad((GstElement*)sinkElement,"sink");
    gst_pad_link(sourcePad,sinkPad);
    gst_object_unref(sinkPad);
}




--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/


More information about the gstreamer-devel mailing list