rtspserver how to dispose correctly

Serj TorresSoldado torres.soldado at gmail.com
Thu Mar 10 14:49:20 UTC 2016


Thank you Prabhakar.

I couldn't get it to cleanly close down the server. The following is the
simplest example I could make to reproduce this.

#include <gst/gst.h>

#include <gst/rtsp-server/rtsp-server.h>

static gboolean timeout(GMainLoop *loop) {
  g_main_loop_quit(loop);
  return FALSE;
}

int main(int argc, char *argv[]) {
  GMainLoop *loop;
  GstRTSPServer *server;

  gst_init(NULL, NULL);

  loop = g_main_loop_new(NULL, FALSE);
  server = gst_rtsp_server_new();
  g_object_set(server, "service", "8555", NULL);
  gst_rtsp_server_attach(server, NULL);
  g_timeout_add_seconds(2, (GSourceFunc) timeout, loop);
  g_main_loop_run(loop);
  gst_object_unref(server);
  g_main_loop_unref(loop);

  loop = g_main_loop_new(NULL, FALSE);
  server = gst_rtsp_server_new();
  g_object_set(server, "service", "8555", NULL);
  gst_rtsp_server_attach(server, NULL);
  g_timeout_add_seconds(2, (GSourceFunc) timeout, loop);
  g_main_loop_run(loop);
  gst_object_unref(server);
  g_main_loop_unref(loop);

  return 0;
}

The weird thing I found out is that commenting the gst_init() resolves the
issue..


On 10 March 2016 at 13:08, Lad, Prabhakar <prabhakar.csengg at gmail.com>
wrote:

> Hi,
>
> On Thu, Mar 10, 2016 at 10:02 AM, Serj TorresSoldado
> <torres.soldado at gmail.com> wrote:
> > Hi,
> >
> >  I am using a rtspserver with an appsink element.
> >
> >  I am currently having issues when trying to dispose and recreate a
> > rtspserver. To delete the server I am doing to following operations:
> >
> > g_main_loop_quit()
> > g_source_remove() to remove the source from attaching the server.
> > g_main_loop_unref()
> > g_object_unref(server)
> >
> > I can create a new server on the same port but I cant connect to it with
> a
> > client.
> >
> > Also I had an issue when trying to delete the server while a client is
> > connected, it would crash because a udpsrc element was stuck in the play
> > state. As a workaround I am stopping the appsink "need-data" callback
> before
> > destroying the server.
> >
> > I can't find any example of how to properly dispose of a server because
> the
> > existing examples seem to depend on the main process exit.
> >
> Make sure you send a EOS first (if you have a queue in a pipeline have
> flush-on-eos=true),
> catch it on the bus handler then later do a mail_loop quit unref that
> object,
> remove the factory (gst_rtsp_mount_points_remove_factory ()), unref
> the mounts object,
> unref the factory object and lastly unref the server object.
>
> Cheers,
> --Prabhakar Lad
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20160310/c320b7d8/attachment.html>


More information about the gstreamer-devel mailing list