mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 20:21:24 +00:00
sdp: pass multicast connection for multicast-only stream
Pass the multicast address of the stream in the connection info in the SDP so that clients try a multicast connection first. Only allow multicast connections in the test-multicast example. Also increase the TTL a little.
This commit is contained in:
parent
21144cb6e2
commit
2bd90b539c
2 changed files with 39 additions and 4 deletions
|
@ -70,8 +70,11 @@ main (int argc, char *argv[])
|
||||||
/* make a new address pool */
|
/* make a new address pool */
|
||||||
pool = gst_rtsp_address_pool_new ();
|
pool = gst_rtsp_address_pool_new ();
|
||||||
gst_rtsp_address_pool_add_range (pool,
|
gst_rtsp_address_pool_add_range (pool,
|
||||||
"224.3.0.0", "224.3.0.10", 5000, 5010, 1);
|
"224.3.0.0", "224.3.0.10", 5000, 5010, 16);
|
||||||
gst_rtsp_media_factory_set_address_pool (factory, pool);
|
gst_rtsp_media_factory_set_address_pool (factory, pool);
|
||||||
|
/* only allow multicast */
|
||||||
|
gst_rtsp_media_factory_set_protocols (factory,
|
||||||
|
GST_RTSP_LOWER_TRANS_UDP_MCAST);
|
||||||
g_object_unref (pool);
|
g_object_unref (pool);
|
||||||
|
|
||||||
/* attach the test factory to the /test url */
|
/* attach the test factory to the /test url */
|
||||||
|
|
|
@ -108,6 +108,11 @@ gst_rtsp_sdp_from_media (GstSDPMessage * sdp, GstSDPInfo * info,
|
||||||
gboolean first;
|
gboolean first;
|
||||||
GString *fmtp;
|
GString *fmtp;
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
|
GstRTSPLowerTrans ltrans;
|
||||||
|
GSocketFamily family;
|
||||||
|
const gchar *addrtype;
|
||||||
|
gchar *address;
|
||||||
|
guint ttl;
|
||||||
|
|
||||||
stream = gst_rtsp_media_get_stream (media, i);
|
stream = gst_rtsp_media_get_stream (media, i);
|
||||||
caps = gst_rtsp_stream_get_caps (stream);
|
caps = gst_rtsp_stream_get_caps (stream);
|
||||||
|
@ -138,13 +143,40 @@ gst_rtsp_sdp_from_media (GstSDPMessage * sdp, GstSDPInfo * info,
|
||||||
gst_sdp_media_set_port_info (smedia, 0, 1);
|
gst_sdp_media_set_port_info (smedia, 0, 1);
|
||||||
gst_sdp_media_set_proto (smedia, "RTP/AVP");
|
gst_sdp_media_set_proto (smedia, "RTP/AVP");
|
||||||
|
|
||||||
/* for the c= line */
|
|
||||||
if (info->is_ipv6) {
|
if (info->is_ipv6) {
|
||||||
gst_sdp_media_add_connection (smedia, "IN", "IP6", "::", 16, 0);
|
addrtype = "IP6";
|
||||||
|
family = G_SOCKET_FAMILY_IPV6;
|
||||||
} else {
|
} else {
|
||||||
gst_sdp_media_add_connection (smedia, "IN", "IP4", "0.0.0.0", 16, 0);
|
addrtype = "IP4";
|
||||||
|
family = G_SOCKET_FAMILY_IPV4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ltrans = gst_rtsp_stream_get_protocols (stream);
|
||||||
|
if (ltrans == GST_RTSP_LOWER_TRANS_UDP_MCAST) {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
address = g_strdup (addr->address);
|
||||||
|
ttl = addr->ttl;
|
||||||
|
gst_rtsp_address_free (addr);
|
||||||
|
} else {
|
||||||
|
ttl = 16;
|
||||||
|
if (info->is_ipv6)
|
||||||
|
address = g_strdup ("::");
|
||||||
|
else
|
||||||
|
address = g_strdup ("0.0.0.0");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* for the c= line */
|
||||||
|
gst_sdp_media_add_connection (smedia, "IN", addrtype, address, ttl, 1);
|
||||||
|
g_free (address);
|
||||||
|
|
||||||
/* get clock-rate, media type and params for the rtpmap attribute */
|
/* get clock-rate, media type and params for the rtpmap attribute */
|
||||||
gst_structure_get_int (s, "clock-rate", &caps_rate);
|
gst_structure_get_int (s, "clock-rate", &caps_rate);
|
||||||
caps_enc = gst_structure_get_string (s, "encoding-name");
|
caps_enc = gst_structure_get_string (s, "encoding-name");
|
||||||
|
|
Loading…
Reference in a new issue