sdp: make 1 media line per profile

If we have multiple profiles (AVP or AVPF) for a stream, make one m=
line in the SDP for each profile. The client is then supposed to pick
one of the profiles in the SETUP request. Because the m= lines have the
same pt, the client also knows that only 1 option is possible.
This commit is contained in:
Wim Taymans 2014-03-03 16:56:53 +01:00
parent 4b74afcc78
commit dffdbbf090

View file

@ -70,65 +70,23 @@ update_sdp_from_tags (GstRTSPStream * stream, GstSDPMedia * stream_media)
gst_object_unref (src_pad);
}
/**
* gst_rtsp_sdp_from_media:
* @sdp: a #GstSDPMessage
* @info: info
* @media: a #GstRTSPMedia
*
* Add @media specific info to @sdp. @info is used to configure the connection
* information in the SDP.
*
* Returns: TRUE on success.
*/
gboolean
gst_rtsp_sdp_from_media (GstSDPMessage * sdp, GstSDPInfo * info,
GstRTSPMedia * media)
static void
make_media (GstSDPMessage * sdp, GstSDPInfo * info, GstRTSPMedia * media,
GstRTSPStream * stream, GstStructure * s, GstRTSPProfile profile)
{
guint i, n_streams;
gchar *rangestr;
n_streams = gst_rtsp_media_n_streams (media);
rangestr = gst_rtsp_media_get_range_string (media, FALSE, GST_RTSP_RANGE_NPT);
if (rangestr == NULL)
goto not_prepared;
gst_sdp_message_add_attribute (sdp, "range", rangestr);
g_free (rangestr);
for (i = 0; i < n_streams; i++) {
GstRTSPStream *stream;
GstSDPMedia *smedia;
GstStructure *s;
const gchar *caps_str, *caps_enc, *caps_params;
gchar *tmp;
gint caps_pt, caps_rate;
guint n_fields, j;
gboolean first;
GString *fmtp;
GstCaps *caps;
GstRTSPLowerTrans ltrans;
GSocketFamily family;
const gchar *addrtype;
const gchar *addrtype, *proto;
gchar *address;
guint ttl;
stream = gst_rtsp_media_get_stream (media, i);
caps = gst_rtsp_stream_get_caps (stream);
if (caps == NULL) {
g_warning ("ignoring stream %d without media type", i);
continue;
}
s = gst_caps_get_structure (caps, 0);
if (s == NULL) {
gst_caps_unref (caps);
g_warning ("ignoring stream %d without media type", i);
continue;
}
gst_sdp_media_new (&smedia);
/* get media type and payload for the m= line */
@ -141,7 +99,25 @@ gst_rtsp_sdp_from_media (GstSDPMessage * sdp, GstSDPInfo * info,
g_free (tmp);
gst_sdp_media_set_port_info (smedia, 0, 1);
gst_sdp_media_set_proto (smedia, "RTP/AVP");
switch (profile) {
case GST_RTSP_PROFILE_AVP:
proto = "RTP/AVP";
break;
case GST_RTSP_PROFILE_AVPF:
proto = "RTP/AVPF";
break;
case GST_RTSP_PROFILE_SAVP:
proto = "RTP/SAVP";
break;
case GST_RTSP_PROFILE_SAVPF:
proto = "RTP/SAVPF";
break;
default:
proto = "udp";
break;
}
gst_sdp_media_set_proto (smedia, proto);
if (info->is_ipv6) {
addrtype = "IP6";
@ -156,12 +132,9 @@ gst_rtsp_sdp_from_media (GstSDPMessage * sdp, GstSDPInfo * info,
GstRTSPAddress *addr;
addr = gst_rtsp_stream_get_multicast_address (stream, family);
if (addr == NULL) {
gst_sdp_media_free (smedia);
gst_caps_unref (caps);
g_warning ("ignoring stream %d without multicast address", i);
continue;
}
if (addr == NULL)
goto no_multicast;
address = g_strdup (addr->address);
ttl = addr->ttl;
gst_rtsp_address_free (addr);
@ -256,6 +229,79 @@ gst_rtsp_sdp_from_media (GstSDPMessage * sdp, GstSDPInfo * info,
gst_sdp_message_add_media (sdp, smedia);
gst_sdp_media_free (smedia);
return;
/* ERRORS */
no_multicast:
{
gst_sdp_media_free (smedia);
g_warning ("ignoring stream %d without multicast address",
gst_rtsp_stream_get_index (stream));
return;
}
}
/**
* gst_rtsp_sdp_from_media:
* @sdp: a #GstSDPMessage
* @info: info
* @media: a #GstRTSPMedia
*
* Add @media specific info to @sdp. @info is used to configure the connection
* information in the SDP.
*
* Returns: TRUE on success.
*/
gboolean
gst_rtsp_sdp_from_media (GstSDPMessage * sdp, GstSDPInfo * info,
GstRTSPMedia * media)
{
guint i, n_streams;
gchar *rangestr;
n_streams = gst_rtsp_media_n_streams (media);
rangestr = gst_rtsp_media_get_range_string (media, FALSE, GST_RTSP_RANGE_NPT);
if (rangestr == NULL)
goto not_prepared;
gst_sdp_message_add_attribute (sdp, "range", rangestr);
g_free (rangestr);
for (i = 0; i < n_streams; i++) {
GstRTSPStream *stream;
GstCaps *caps;
GstStructure *s;
GstRTSPProfile profiles;
guint mask;
stream = gst_rtsp_media_get_stream (media, i);
caps = gst_rtsp_stream_get_caps (stream);
if (caps == NULL) {
g_warning ("ignoring stream %d without media type", i);
continue;
}
s = gst_caps_get_structure (caps, 0);
if (s == NULL) {
gst_caps_unref (caps);
g_warning ("ignoring stream %d without media type", i);
continue;
}
/* make a new media for each profile */
profiles = gst_rtsp_stream_get_profiles (stream);
mask = 1;
while (profiles >= mask) {
GstRTSPProfile prof = profiles & mask;
if (prof)
make_media (sdp, info, media, stream, s, prof);
mask <<= 1;
}
gst_caps_unref (caps);
}