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
This commit is contained in:
Aleix Conchillo Flaque 2012-09-03 17:33:17 -07:00 committed by Wim Taymans
parent bef57648b8
commit c6cce4a6b9

View file

@ -361,7 +361,7 @@ collect_media_stats (GstRTSPMedia * media)
* gst_rtsp_media_new: * gst_rtsp_media_new:
* *
* Create a new #GstRTSPMedia instance. The #GstRTSPMedia object contains the * 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. * streams.
* *
* Returns: a new #GstRTSPMedia object. * Returns: a new #GstRTSPMedia object.
@ -1078,7 +1078,8 @@ find_transport (GstRTSPMediaStream * stream, const gchar * rtcp_from)
port = atoi (tmp + 1); port = atoi (tmp + 1);
dest = g_strndup (rtcp_from, tmp - rtcp_from); 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)) { for (walk = stream->transports; walk; walk = g_list_next (walk)) {
GstRTSPMediaTrans *trans = walk->data; GstRTSPMediaTrans *trans = walk->data;
@ -1098,14 +1099,12 @@ find_transport (GstRTSPMediaStream * stream, const gchar * rtcp_from)
return result; return result;
} }
static void static GstRTSPMediaTrans *
on_new_ssrc (GObject * session, GObject * source, GstRTSPMediaStream * stream) check_transport (GObject * source, GstRTSPMediaStream * stream)
{ {
GstStructure *stats; GstStructure *stats;
GstRTSPMediaTrans *trans; 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 */ /* 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); trans = g_object_get_qdata (source, ssrc_stream_map_key);
if (trans == NULL) { if (trans == NULL) {
@ -1127,9 +1126,22 @@ on_new_ssrc (GObject * session, GObject * source, GstRTSPMediaStream * stream)
} }
gst_structure_free (stats); 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 static void
@ -1144,9 +1156,10 @@ on_ssrc_active (GObject * session, GObject * source,
{ {
GstRTSPMediaTrans *trans; 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) if (trans && trans->keep_alive)
trans->keep_alive (trans->ka_user_data); trans->keep_alive (trans->ka_user_data);