From dbe92c9147f9476b5f6479e9cc9ba6101531af64 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 4 Mar 2014 11:34:39 +0100 Subject: [PATCH] rtspsrc: refactor payload handling --- gst/rtsp/gstrtspsrc.c | 63 +++++++++++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 27 deletions(-) diff --git a/gst/rtsp/gstrtspsrc.c b/gst/rtsp/gstrtspsrc.c index 6a26768..bf032dc 100644 --- a/gst/rtsp/gstrtspsrc.c +++ b/gst/rtsp/gstrtspsrc.c @@ -1299,6 +1299,41 @@ gst_rtspsrc_collect_connections (GstRTSPSrc * src, const GstSDPMessage * sdp, } } +static void +gst_rtspsrc_collect_payloads (GstRTSPSrc * src, const GstSDPMessage * sdp, + const GstSDPMedia * media, GstRTSPStream * stream) +{ + const gchar *payload; + + /* we must have a payload. No payload means we cannot create caps */ + /* FIXME, handle multiple formats. The problem here is that we just want to + * take the first available format that we can handle but in order to do that + * we need to scan for depayloader plugins. Scanning for payloader plugins is + * also suboptimal because the user maybe just wants to save the raw stream + * and then we don't care. */ + if ((payload = gst_sdp_media_get_format (media, 0))) { + stream->pt = atoi (payload); + /* convert caps */ + stream->caps = gst_rtspsrc_media_to_caps (stream->pt, media); + + GST_DEBUG ("mapping sdp session level attributes to caps"); + gst_rtspsrc_sdp_attributes_to_caps (sdp->attributes, stream->caps); + GST_DEBUG ("mapping sdp media level attributes to caps"); + gst_rtspsrc_sdp_attributes_to_caps (media->attributes, stream->caps); + + if (stream->pt >= 96) { + /* If we have a dynamic payload type, see if we have a stream with the + * same payload number. If there is one, they are part of the same + * container and we only need to add one pad. */ + if (find_stream (src, &stream->pt, (gpointer) find_stream_by_pt)) { + stream->container = TRUE; + GST_DEBUG ("found another stream with pt %d, marking as container", + stream->pt); + } + } + } +} + static const gchar * get_aggregate_control (GstRTSPSrc * src) { @@ -1321,7 +1356,6 @@ gst_rtspsrc_create_stream (GstRTSPSrc * src, GstSDPMessage * sdp, gint idx) { GstRTSPStream *stream; const gchar *control_url; - const gchar *payload; const GstSDPMedia *media; /* get media, should not return NULL */ @@ -1349,33 +1383,8 @@ gst_rtspsrc_create_stream (GstRTSPSrc * src, GstSDPMessage * sdp, gint idx) /* collect connection info */ gst_rtspsrc_collect_connections (src, sdp, media, stream); - /* we must have a payload. No payload means we cannot create caps */ - /* FIXME, handle multiple formats. The problem here is that we just want to - * take the first available format that we can handle but in order to do that - * we need to scan for depayloader plugins. Scanning for payloader plugins is - * also suboptimal because the user maybe just wants to save the raw stream - * and then we don't care. */ - if ((payload = gst_sdp_media_get_format (media, 0))) { - stream->pt = atoi (payload); - /* convert caps */ - stream->caps = gst_rtspsrc_media_to_caps (stream->pt, media); - - GST_DEBUG ("mapping sdp session level attributes to caps"); - gst_rtspsrc_sdp_attributes_to_caps (sdp->attributes, stream->caps); - GST_DEBUG ("mapping sdp media level attributes to caps"); - gst_rtspsrc_sdp_attributes_to_caps (media->attributes, stream->caps); + gst_rtspsrc_collect_payloads (src, sdp, media, stream); - if (stream->pt >= 96) { - /* If we have a dynamic payload type, see if we have a stream with the - * same payload number. If there is one, they are part of the same - * container and we only need to add one pad. */ - if (find_stream (src, &stream->pt, (gpointer) find_stream_by_pt)) { - stream->container = TRUE; - GST_DEBUG ("found another stream with pt %d, marking as container", - stream->pt); - } - } - } /* collect port number */ stream->port = gst_sdp_media_get_port (media); -- 2.7.4