Commit 73207625 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Backport [17603]: include source-filter in SAP depending on group address

parent b4188eda
...@@ -76,7 +76,7 @@ static void RunThread( vlc_object_t *p_this); ...@@ -76,7 +76,7 @@ static void RunThread( vlc_object_t *p_this);
static int CalculateRate( sap_handler_t *p_sap, sap_address_t *p_address ); static int CalculateRate( sap_handler_t *p_sap, sap_address_t *p_address );
static char *SDPGenerate( sap_handler_t *p_sap, static char *SDPGenerate( sap_handler_t *p_sap,
const session_descriptor_t *p_session, const session_descriptor_t *p_session,
const sap_address_t *p_addr ); const sap_address_t *p_addr, vlc_bool_t b_ssm );
static int announce_SendSAPAnnounce( sap_handler_t *p_sap, static int announce_SendSAPAnnounce( sap_handler_t *p_sap,
sap_session_t *p_session ); sap_session_t *p_session );
...@@ -235,7 +235,7 @@ static int announce_SAPAnnounceAdd( sap_handler_t *p_sap, ...@@ -235,7 +235,7 @@ static int announce_SAPAnnounceAdd( sap_handler_t *p_sap,
{ {
int i_header_size, i; int i_header_size, i;
char *psz_head, psz_addr[NI_MAXNUMERICHOST]; char *psz_head, psz_addr[NI_MAXNUMERICHOST];
vlc_bool_t b_ipv6 = VLC_FALSE; vlc_bool_t b_ipv6 = VLC_FALSE, b_ssm = VLC_FALSE;
sap_session_t *p_sap_session; sap_session_t *p_sap_session;
mtime_t i_hash; mtime_t i_hash;
struct addrinfo hints, *res; struct addrinfo hints, *res;
...@@ -288,8 +288,13 @@ static int announce_SAPAnnounceAdd( sap_handler_t *p_sap, ...@@ -288,8 +288,13 @@ static int announce_SAPAnnounceAdd( sap_handler_t *p_sap,
memcpy( a6->s6_addr + 2, "\x00\x00\x00\x00\x00\x00" memcpy( a6->s6_addr + 2, "\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x02\x7f\xfe", 14 ); "\x00\x00\x00\x00\x00\x02\x7f\xfe", 14 );
if( IN6_IS_ADDR_MULTICAST( a6 ) ) if( IN6_IS_ADDR_MULTICAST( a6 ) )
{
/* force flags to zero, preserve scope */ /* force flags to zero, preserve scope */
a6->s6_addr[1] &= 0xf; a6->s6_addr[1] &= 0xf;
/* SSM <=> ff3x::/32 */
b_ssm = (GetDWLE (a6->s6_addr) & 0xfff0ffff) == 0xff300000;
}
else else
/* Unicast IPv6 - assume global scope */ /* Unicast IPv6 - assume global scope */
memcpy( a6->s6_addr, "\xff\x0e", 2 ); memcpy( a6->s6_addr, "\xff\x0e", 2 );
...@@ -321,8 +326,13 @@ static int announce_SAPAnnounceAdd( sap_handler_t *p_sap, ...@@ -321,8 +326,13 @@ static int announce_SAPAnnounceAdd( sap_handler_t *p_sap,
ipv4 = 0; ipv4 = 0;
else else
/* other addresses => 224.2.127.254 */ /* other addresses => 224.2.127.254 */
{
ipv4 = 0xe0027ffe; ipv4 = 0xe0027ffe;
/* SSM: 232.0.0.0/8 */
b_ssm = (ipv4 >> 24) == 232;
}
if( ipv4 == 0 ) if( ipv4 == 0 )
{ {
msg_Err( p_sap, "Out-of-scope multicast address " msg_Err( p_sap, "Out-of-scope multicast address "
...@@ -468,7 +478,7 @@ static int announce_SAPAnnounceAdd( sap_handler_t *p_sap, ...@@ -468,7 +478,7 @@ static int announce_SAPAnnounceAdd( sap_handler_t *p_sap,
if( p_session->psz_sdp == NULL ) if( p_session->psz_sdp == NULL )
{ {
p_session->psz_sdp = SDPGenerate( p_sap, p_session, p_session->psz_sdp = SDPGenerate( p_sap, p_session,
p_sap_session->p_address ); p_sap_session->p_address, b_ssm );
if( p_session->psz_sdp == NULL ) if( p_session->psz_sdp == NULL )
{ {
vlc_mutex_unlock( &p_sap->object_lock ); vlc_mutex_unlock( &p_sap->object_lock );
...@@ -584,7 +594,7 @@ static int announce_SendSAPAnnounce( sap_handler_t *p_sap, ...@@ -584,7 +594,7 @@ static int announce_SendSAPAnnounce( sap_handler_t *p_sap,
static char *SDPGenerate( sap_handler_t *p_sap, static char *SDPGenerate( sap_handler_t *p_sap,
const session_descriptor_t *p_session, const session_descriptor_t *p_session,
const sap_address_t *p_addr ) const sap_address_t *p_addr, vlc_bool_t b_ssm )
{ {
int64_t i_sdp_id = mdate(); int64_t i_sdp_id = mdate();
int i_sdp_version = 1 + p_sap->i_sessions + (rand()&0xfff); int i_sdp_version = 1 + p_sap->i_sessions + (rand()&0xfff);
...@@ -614,8 +624,16 @@ static char *SDPGenerate( sap_handler_t *p_sap, ...@@ -614,8 +624,16 @@ static char *SDPGenerate( sap_handler_t *p_sap,
else else
psz_uri = p_session->psz_uri; psz_uri = p_session->psz_uri;
char *sfilter = NULL;
if (b_ssm)
{
if (asprintf (&sfilter, "a=source-filter: incl IN IP%c * %s\r\n",
ipv, p_addr->psz_machine) == -1)
return NULL;
}
/* see the lists in modules/stream_out/rtp.c for compliance stuff */ /* see the lists in modules/stream_out/rtp.c for compliance stuff */
if( asprintf( &psz_sdp, int res = asprintf (&psz_sdp,
"v=0\r\n" "v=0\r\n"
"o=- "I64Fd" %d IN IP%c %s\r\n" "o=- "I64Fd" %d IN IP%c %s\r\n"
"s=%s\r\n" "s=%s\r\n"
...@@ -624,7 +642,7 @@ static char *SDPGenerate( sap_handler_t *p_sap, ...@@ -624,7 +642,7 @@ static char *SDPGenerate( sap_handler_t *p_sap,
"a=tool:"PACKAGE_STRING"\r\n" "a=tool:"PACKAGE_STRING"\r\n"
"a=recvonly\r\n" "a=recvonly\r\n"
"a=type:broadcast\n" "a=type:broadcast\n"
"a=source-filter: incl IN IP%c * %s\r\n" "%s"
"m=video %d %s %d\r\n" "m=video %d %s %d\r\n"
"%s%s%s", "%s%s%s",
i_sdp_id, i_sdp_version, i_sdp_id, i_sdp_version,
...@@ -632,12 +650,16 @@ static char *SDPGenerate( sap_handler_t *p_sap, ...@@ -632,12 +650,16 @@ static char *SDPGenerate( sap_handler_t *p_sap,
psz_name, ipv, psz_uri, psz_name, ipv, psz_uri,
/* FIXME: 1 is IPv4 default TTL, not that of IPv6 */ /* FIXME: 1 is IPv4 default TTL, not that of IPv6 */
p_session->i_ttl ?: (config_GetInt( p_sap, "ttl" ) ?: 1), p_session->i_ttl ?: (config_GetInt( p_sap, "ttl" ) ?: 1),
ipv, p_addr->psz_machine, (sfilter != NULL) ? sfilter : "",
p_session->i_port, p_session->i_port,
p_session->b_rtp ? "RTP/AVP" : "udp", p_session->b_rtp ? "RTP/AVP" : "udp",
p_session->i_payload, p_session->i_payload,
psz_group ? "a=x-plgroup:" : "", psz_group ? "a=x-plgroup:" : "",
psz_group ? psz_group : "", psz_group ? "\r\n" : "" ) == -1 ) psz_group ? psz_group : "", psz_group ? "\r\n" : "");
if (sfilter != NULL)
free (sfilter);
if (res == -1)
return NULL; return NULL;
msg_Dbg( p_sap, "Generated SDP (%i bytes):\n%s", strlen(psz_sdp), msg_Dbg( p_sap, "Generated SDP (%i bytes):\n%s", strlen(psz_sdp),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment