[gst-rtsp-server] connecting rtsp server to live stream on the fly

anton at angri.ch anton at angri.ch
Wed Sep 12 04:01:19 PDT 2012


Hello all,

I'm trying to do the following: create a pipeline and set it to
PLAYING, use tee element in the middle and have branching to rtsp
server from it. Something like this:

source
 |
 v
tee -> queue -> RTSPMedia
 |
 v
sink

The "source -> sink" part should be always playing, even when there
are no clients connected to rtsp server. I tried to override
"get_element()" method of the GstRTSPMediaFactory class and made it
look like this:

  GstElement *stream = gst_bin_get_by_name (GST_BIN (pipeline), "stream");
  GstPad *src = gst_element_get_static_pad (stream, "src");
  g_object_unref (stream);

  GstBin *streambin = GST_BIN (gst_pipeline_new ("streambin"));
  GstElement *queue = gst_element_factory_make ("queue", "pay0");
  if (FALSE == gst_bin_add (streambin, queue)) {
    printf ("couldn't add queue to streambin\n");
    return NULL;
  }

  GstPad *ghost_pad;
  GstPad *queue_sinkpad = gst_element_get_static_pad (queue, "sink");
  if (NULL == (ghost_pad = gst_ghost_pad_new (NULL, queue_sinkpad))) {
    printf ("couldn't create ghost pad\n");
    return NULL;
  }
  g_object_unref (queue_sinkpad);

  if (GST_PAD_LINK_OK != gst_pad_link (src, ghost_pad)) {
    g_printerr ("couldn't link src and ghost pad\n");
    return NULL;
  }

  return GST_ELEMENT (streambin);

Unfortunately this doesn't work. I can make the main pipeline play,
but gst_rtsp_media_prepare() hangs at gst_rtsp_media_get_status(). It
waits for media to become prepared for 20 seconds and then assumes
failure. Here is how log output looks like: http://pastie.org/4707192

Complete code is here: https://gist.github.com/3705883
It can be compiled like this: cc -Wall rtsp-live.c -o rtsp-live
`pkg-config --cflags --libs gstreamer-rtsp-server-1.0`
I run it with this command line: ./rtsp-live --gst-debug=rtsp\*:5
videotestsrc ! video/x-raw,framerate=1/4 ! x264enc ! tee name=t !
queue ! rtph264pay name=stream t. ! queue ! fakesink

What am I doing wrong? Is it at all possible to connect rtsp server to
live stream?

Thanks!

--
Anton Gritsay


More information about the gstreamer-devel mailing list