Iván Pérez
Iván Pérez

Reputation: 2539

GStreamer - Emit a signal to an element

I have a pipeline written into a C program which redirects a video stream from stdin to multiple UDP clients. I want those clients to be added or removed dynamically, so it's not possible to define at compile time which of them and how many there will be. This is my pipeline (if I add a fixed clients parameter it works fine):

fdsrc name=origin \
! video/x-h264,width=320,height=240,framerate=30/1,profile=baseline,stream-format=avc,alignment=au \
! h264parse \
! rtph264pay \
    config-interval=1 \
    pt=96 \
! multiudpsink name=dest \
     sync=false

According to the GStreamer docs, I can achieve it by sending a signal in order to add or remove clients dynamically. In this case, it should be the add signal.

But I can't find any information about sending a signal to an element (in this case, to the multiudpsink element). It's easy to get the reference to my element:

GstElement *sink = gst_bin_get_by_name(GST_BIN(pipeline), "dest");
/* TODO: send a signal to add a client */
g_object_unref(sink);

But now how can I emit a signal to that element?

Upvotes: 2

Views: 3999

Answers (1)

Iván Pérez
Iván Pérez

Reputation: 2539

Finally I got it. Using g_signal_emit_by_name you can send to any GStreamer element a message.

The code looks like:

GstElement *sink = gst_bin_get_by_name(GST_BIN(pipeline), "dest");
g_signal_emit_by_name(sink, "add", "192.168.1.25", 5004, NULL);
g_object_unref(sink);

Thanks to Tim Müller, from the GStreamer-devel mailing list, who gave me the right example on how to proceed.

Upvotes: 7

Related Questions