Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Launch GstRTSPServer from GstElement pipeline

I'm doing a Gstreamer 1.0 application in C. The pipeline is built, based on user configuration and system "state" during runtime. Therefore I'm using multiple GstElements which are later added and linked to a "GstElement pipeline". Here's a minimal example for a better understanding:

GstElement *pipeline = gst_pipeline_new("mypipeline");
...
GstElement *src = gst_element_factory_make("videotestsrc", NULL);
...
gst_bin_add_many(GST_BIN(pipeline), src, enc, pay, NULL);
gst_element_link_many(src, enc, pay, NULL);
...

This pipeline should then be launched by a GstRTSPMediaFactory. The problem I'm facing here is that the gst_rtsp_media_factory_set_launch function is only accepting a const gchar * pipeline.

Therefore my question is, if anybody of you is aware of a function for either

  • transforming the GstElement *pipeline to a const gchar* representation (kinda reverse gst_parse)
  • or launching the GstRTSPMediaFactory from a GstElement *pipeline (see edit #1 below)

Any help is much appreciated! Thank you.


EDIT #1:

From the gst-rtsp-server documentation:

The default implementation of GstRTSPMediaFactory allows you to easily create GStreamer pipelines using the gst-launch syntax. It is possible to create a GstRTSPMediaFactory subclass that uses different methods for constructing pipelines.

Therefore launching a GstRTSPMediaFactory from a GstElement is technically possible. Additional question to this approach: Is anybody aware of such an GstRTSPMediaFactory subclass implementation?

like image 629
g0hl1n Avatar asked Nov 13 '17 16:11

g0hl1n


1 Answers

Yes, the gst-rtsp-server repository has an example in its subfolder examples. To summarise: make a subclass of GstRTSPMediaFactory and override the create_element() virtual method.

As an aside, this also means the 2 options you provided before were incorrect;

  • transforming the GstElement pipeline to a const gchar representation (kinda reverse gst_parse)

This is not possible, since the programmatic API is more expressive and allows you to do more (even a simple example: registering callbacks) than the declarative launch API.

  • or launching the GstRTSPMediaFactory from a GstElement *pipeline (see edit #1 below)

You're thinking the other way around: when the GStreamer RTSP server gets the request to start playing, it will use the GstRTSPMediaFactory to launch a GstPipeline based on your get_element() implementation. Not the other way around, where each pipeline launches its own RTSP server.

like image 182
nielsdg Avatar answered Nov 18 '22 17:11

nielsdg