GNOME Bugzilla – Bug 749227
rtsp-server: gst_rtsp_server_attach() is misleading
Last modified: 2015-08-16 13:39:49 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.
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 ..
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.
Created attachment 308025 [details] [review]
Document that source keeps a ref on server until it's destroyed
Attachment 308025 [details] pushed as 8511ffe - Document that source keeps a ref on server until it's destroyed