rtspserver how to dispose correctly

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

rtspserver how to dispose correctly

Serj TorresSoldado
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.

Thanks,
Serj.

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: rtspserver how to dispose correctly

Prabhakar Lad
Hi,

On Thu, Mar 10, 2016 at 10:02 AM, Serj TorresSoldado
<[hidden email]> 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
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: rtspserver how to dispose correctly

Serj TorresSoldado
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 <[hidden email]> wrote:
Hi,

On Thu, Mar 10, 2016 at 10:02 AM, Serj TorresSoldado
<[hidden email]> 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
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: rtspserver how to dispose correctly

Sebastian Dröge-3
On Do, 2016-03-10 at 14:49 +0000, Serj TorresSoldado wrote:
> 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.
> [...]
>   gst_rtsp_server_attach(server, NULL);

attach() is returning a GSource id, which you have to detach/destroy
from the main context again.

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

I'm surprised anything works at all then :)

--
Sebastian Dröge, Centricular Ltd · http://www.centricular.com


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

signature.asc (968 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: rtspserver how to dispose correctly

Serj TorresSoldado
I'm afraid I wasn't removing the source with g_source_remove().

Thank you for you help.

On 11 March 2016 at 06:44, Sebastian Dröge <[hidden email]> wrote:
On Do, 2016-03-10 at 14:49 +0000, Serj TorresSoldado wrote:
> 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.
> [...]
>   gst_rtsp_server_attach(server, NULL);

attach() is returning a GSource id, which you have to detach/destroy
from the main context again.

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

I'm surprised anything works at all then :)

--
Sebastian Dröge, Centricular Ltd · http://www.centricular.com


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel



_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel