From c6cce4a6b9a61e24574ee54ca5c89cec5f93eb40 Mon Sep 17 00:00:00 2001 From: Aleix Conchillo Flaque Date: Mon, 3 Sep 2012 17:33:17 -0700 Subject: [PATCH] rtsp-media: also initialize transports in on_ssrc_active (bug #683304) * gst/rtsp-server/rtsp-media.c: GstRTSPMediaStream transports might not be available in "on_new_ssrc". The transports are added in gst_rtsp_media_set_state when going to PLAYING state. However, "on_new_ssrc" might be called before this happens. https://bugzilla.gnome.org/show_bug.cgi?id=683304 --- gst/rtsp-server/rtsp-media.c | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/gst/rtsp-server/rtsp-media.c b/gst/rtsp-server/rtsp-media.c index 18f2e85..2bd81eb 100644 --- a/gst/rtsp-server/rtsp-media.c +++ b/gst/rtsp-server/rtsp-media.c @@ -361,7 +361,7 @@ collect_media_stats (GstRTSPMedia * media) * gst_rtsp_media_new: * * Create a new #GstRTSPMedia instance. The #GstRTSPMedia object contains the - * element to produde RTP data for one or more related (audio/video/..) + * element to produce RTP data for one or more related (audio/video/..) * streams. * * Returns: a new #GstRTSPMedia object. @@ -1078,7 +1078,8 @@ find_transport (GstRTSPMediaStream * stream, const gchar * rtcp_from) port = atoi (tmp + 1); dest = g_strndup (rtcp_from, tmp - rtcp_from); - GST_INFO ("finding %s:%d", dest, port); + GST_INFO ("finding %s:%d in %d transports", dest, port, + g_list_length (stream->transports)); for (walk = stream->transports; walk; walk = g_list_next (walk)) { GstRTSPMediaTrans *trans = walk->data; @@ -1098,14 +1099,12 @@ find_transport (GstRTSPMediaStream * stream, const gchar * rtcp_from) return result; } -static void -on_new_ssrc (GObject * session, GObject * source, GstRTSPMediaStream * stream) +static GstRTSPMediaTrans * +check_transport (GObject * source, GstRTSPMediaStream * stream) { GstStructure *stats; GstRTSPMediaTrans *trans; - GST_INFO ("%p: new source %p", stream, source); - /* see if we have a stream to match with the origin of the RTCP packet */ trans = g_object_get_qdata (source, ssrc_stream_map_key); if (trans == NULL) { @@ -1127,9 +1126,22 @@ on_new_ssrc (GObject * session, GObject * source, GstRTSPMediaStream * stream) } gst_structure_free (stats); } - } else { - GST_INFO ("%p: source %p for transport %p", stream, source, trans); } + + return trans; +} + +static void +on_new_ssrc (GObject * session, GObject * source, GstRTSPMediaStream * stream) +{ + GstRTSPMediaTrans *trans; + + GST_INFO ("%p: new source %p", stream, source); + + trans = check_transport (source, stream); + + if (trans) + GST_INFO ("%p: source %p for transport %p", stream, source, trans); } static void @@ -1144,9 +1156,10 @@ on_ssrc_active (GObject * session, GObject * source, { GstRTSPMediaTrans *trans; - trans = g_object_get_qdata (source, ssrc_stream_map_key); + trans = check_transport (source, stream); - GST_INFO ("%p: source %p in transport %p is active", stream, source, trans); + if (trans) + GST_INFO ("%p: source %p in transport %p is active", stream, source, trans); if (trans && trans->keep_alive) trans->keep_alive (trans->ka_user_data); -- 2.7.4