rtsp-server: fix for creating backchannel stream dynamically

If collecting the backchannel stream after the stream has begun
preparing, make sure to join it to the RTSP media bin, as is
done for dynamic payloaders in the pad-added handler. Add a
new internal stream creation method for it, that could be
publically exposed later if it proves useful.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8378>
This commit is contained in:
Jan Schmidt 2025-01-27 09:33:48 +11:00 committed by GStreamer Marge Bot
parent 6921405f40
commit d2dcfea052
3 changed files with 36 additions and 1 deletions

View file

@ -2747,6 +2747,35 @@ gst_rtsp_media_create_stream (GstRTSPMedia * media, GstElement * payloader,
return stream;
}
GstRTSPStream *
gst_rtsp_media_create_and_join_stream (GstRTSPMedia * media,
GstElement * payloader, GstPad * pad)
{
GstRTSPStream *stream = gst_rtsp_media_create_stream (media, payloader, pad);
GstRTSPMediaPrivate *priv = media->priv;
if (stream == NULL) {
return NULL;
}
g_rec_mutex_lock (&priv->state_lock);
if (priv->status == GST_RTSP_MEDIA_STATUS_PREPARING) {
/* join the element in the PAUSED state because this callback is
* called from the streaming thread and it is PAUSED */
if (!gst_rtsp_stream_join_bin (stream, GST_BIN (priv->pipeline),
priv->rtpbin, GST_STATE_PAUSED)) {
GST_WARNING ("failed to join bin element");
}
if (priv->blocked)
gst_rtsp_stream_set_blocked (stream, TRUE);
}
g_rec_mutex_unlock (&priv->state_lock);
return stream;
}
static void
gst_rtsp_media_remove_stream (GstRTSPMedia * media, GstRTSPStream * stream)
{

View file

@ -43,6 +43,7 @@
#include "rtsp-onvif-media.h"
#include "rtsp-latency-bin.h"
#include "rtsp-server-internal.h"
GST_DEBUG_CATEGORY_STATIC (rtsp_onvif_media_debug);
#define GST_CAT_DEFAULT rtsp_onvif_media_debug
@ -317,7 +318,8 @@ gst_rtsp_onvif_media_collect_backchannel (GstRTSPOnvifMedia * media)
goto out;
GST_LOG_OBJECT (media, "Creating backchannel stream");
gst_rtsp_media_create_stream (GST_RTSP_MEDIA (media), latency_bin, pad);
gst_rtsp_media_create_and_join_stream (GST_RTSP_MEDIA (media), latency_bin,
pad);
ret = TRUE;
out:

View file

@ -67,6 +67,10 @@ void gst_rtsp_stream_set_drop_delta_units (GstRTSPStream * s
gboolean gst_rtsp_stream_install_drop_probe (GstRTSPStream * stream);
GstRTSPStream * gst_rtsp_media_create_and_join_stream (GstRTSPMedia * media,
GstElement * payloader,
GstPad * pad);
G_END_DECLS
#endif /* __GST_RTSP_SERVER_INTERNAL_H__ */