After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 749227 - rtsp-server: gst_rtsp_server_attach() is misleading
rtsp-server: gst_rtsp_server_attach() is misleading
Product: GStreamer
Classification: Platform
Component: gst-rtsp-server
git master
Other Linux
: Normal normal
: 1.5.90
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Reported: 2015-05-11 14:18 UTC by Xavier Claessens
Modified: 2015-08-16 13:39 UTC
See Also:
GNOME target: ---
GNOME version: ---

Document that source keeps a ref on server until it's destroyed (1.51 KB, patch)
2015-07-23 18:54 UTC, Xavier Claessens
none Details | Review

Description Xavier Claessens 2015-05-11 14:18:12 UTC
gst_rtsp_server_attach() returns a source ID which mislead to using g_source_remove() on it, but that will fail if the source was not attached to the default main context.

Also if I understand correctly the code, the GSource keeps a ref on the GstRTSPServer object, so the server will be leaked until caller explicitly destroy the source. The doc should tell it.

What I suggest is:

1) Deprecate gst_rtsp_server_attach() since it's just a small helper around gst_rtsp_server_create_source() that just creates more confusion.

2) Add a note in gst_rtsp_server_create_source() that it will keep a ref on the server until the source is destroyed. I'm not sure if we should suggest g_source_unref() or g_source_destroy() here though.
Comment 1 Nicolas Dufresne (ndufresne) 2015-07-22 19:31:21 UTC
I think a comment similarly to what was added to core. The way around if it's not the default context is:

  sig = gst_rtsp_server_attach (watch, context)
  source = g_main_context_find_source_by_id (context, sig);
  ... when done ..
  g_source_destroy (source);

This is equivalent and uglier compare to creating a source and then using usual method to attach the source to the context. Note that GstRtspWatch does not have a mean to create a source.
Comment 2 Xavier Claessens 2015-07-23 18:54:35 UTC
Created attachment 308025 [details] [review]
Document that source keeps a ref on server until it's destroyed
Comment 3 Nicolas Dufresne (ndufresne) 2015-08-10 16:19:47 UTC
Attachment 308025 [details] pushed as 8511ffe - Document that source keeps a ref on server until it's destroyed