Commit 06f5e605 authored by Derk-Jan Hartman's avatar Derk-Jan Hartman

* include/stream_output.h: add a ip_version field to sap_address_t

  This way we can later on set IP6 instead of IP4 in a SDP.
* modules/stream_out/rtp.c: accept sdp=sap as a valid option.
* src/stream_output/sap.c: 
  - Set the SAP packet Hash headerfield to a unique value based on mtime
    Patch by Philippe van Hecke <philippe at belnet dot be>
  - Set SAP packet IPv6 field to 1 if we are a ipv6 session
  - Made some preperations for setting the origin ip address in the header as well,
    anyone any ideas on how to retrieve the current origin IP address???
parent 46c00c6b
...@@ -72,6 +72,7 @@ Olivier Aubert <oaubert@bat710.univ-lyon1.fr> - clone list patch ...@@ -72,6 +72,7 @@ Olivier Aubert <oaubert@bat710.univ-lyon1.fr> - clone list patch
Olivier Pomel <pomel@via.ecp.fr> - original VLC code Olivier Pomel <pomel@via.ecp.fr> - original VLC code
yvind Kolbu <oyvindk@world-online.no> - FreeBSD patches yvind Kolbu <oyvindk@world-online.no> - FreeBSD patches
Paul Mackerras <paulus@linuxcare.com.au> - AltiVec IDCT and motion Paul Mackerras <paulus@linuxcare.com.au> - AltiVec IDCT and motion
Philippe Van Hecke <philippe at belnet dot be> - SAP header hash patch
Rgis Duchesne <regis@via.ecp.fr> - original VLC code Rgis Duchesne <regis@via.ecp.fr> - original VLC code
Remco Poortinga <poortinga@telin.nl> - IPv6 multicast patch Remco Poortinga <poortinga@telin.nl> - IPv6 multicast patch
Rene Gollent <rgollent@u.arizona.edu> - BeOS interface fix Rene Gollent <rgollent@u.arizona.edu> - BeOS interface fix
......
...@@ -276,6 +276,7 @@ struct announce_method_t ...@@ -276,6 +276,7 @@ struct announce_method_t
struct sap_address_t struct sap_address_t
{ {
char *psz_address; char *psz_address;
int i_ip_version;
int i_port; int i_port;
int i_rfd; /* Read socket */ int i_rfd; /* Read socket */
int i_wfd; /* Write socket */ int i_wfd; /* Write socket */
......
...@@ -654,7 +654,8 @@ static void SDPHandleUrl( sout_stream_t *p_stream, char *psz_url ) ...@@ -654,7 +654,8 @@ static void SDPHandleUrl( sout_stream_t *p_stream, char *psz_url )
msg_Err( p_stream, "cannot export sdp as rtsp" ); msg_Err( p_stream, "cannot export sdp as rtsp" );
} }
} }
else if( url.psz_protocol && !strcasecmp( url.psz_protocol, "sap" ) ) else if( ( url.psz_protocol && !strcasecmp( url.psz_protocol, "sap" ) ) ||
( url.psz_host && !strcasecmp( url.psz_host, "sap" ) ) )
{ {
p_sys->b_export_sap = VLC_TRUE; p_sys->b_export_sap = VLC_TRUE;
SapSetup( p_stream ); SapSetup( p_stream );
......
...@@ -215,6 +215,7 @@ static int announce_SAPAnnounceAdd( sap_handler_t *p_sap, ...@@ -215,6 +215,7 @@ static int announce_SAPAnnounceAdd( sap_handler_t *p_sap,
char *psz_head; char *psz_head;
vlc_bool_t b_found = VLC_FALSE; vlc_bool_t b_found = VLC_FALSE;
sap_session_t *p_sap_session; sap_session_t *p_sap_session;
mtime_t i_hash;
vlc_mutex_lock( &p_sap->object_lock ); vlc_mutex_lock( &p_sap->object_lock );
...@@ -281,6 +282,7 @@ static int announce_SAPAnnounceAdd( sap_handler_t *p_sap, ...@@ -281,6 +282,7 @@ static int announce_SAPAnnounceAdd( sap_handler_t *p_sap,
return VLC_ENOMEM; return VLC_ENOMEM;
} }
p_address->psz_address = strdup( p_method->psz_address ); p_address->psz_address = strdup( p_method->psz_address );
p_address->i_ip_version = p_method->i_ip_version;
p_address->i_port = 9875; p_address->i_port = 9875;
p_address->i_wfd = net_OpenUDP( p_sap, "", 0, p_address->i_wfd = net_OpenUDP( p_sap, "", 0,
p_address->psz_address, p_address->psz_address,
...@@ -319,7 +321,7 @@ static int announce_SAPAnnounceAdd( sap_handler_t *p_sap, ...@@ -319,7 +321,7 @@ static int announce_SAPAnnounceAdd( sap_handler_t *p_sap,
} }
/* Build the SAP Headers */ /* Build the SAP Headers */
i_header_size = 8 + strlen( psz_type ) + 1; i_header_size = ( p_method->i_ip_version == 6 ? 20 : 8 ) + strlen( psz_type ) + 1;
psz_head = (char *) malloc( i_header_size * sizeof( char ) ); psz_head = (char *) malloc( i_header_size * sizeof( char ) );
if( ! psz_head ) if( ! psz_head )
{ {
...@@ -327,17 +329,52 @@ static int announce_SAPAnnounceAdd( sap_handler_t *p_sap, ...@@ -327,17 +329,52 @@ static int announce_SAPAnnounceAdd( sap_handler_t *p_sap,
return VLC_ENOMEM; return VLC_ENOMEM;
} }
psz_head[0] = 0x20; /* Means IPv4, not encrypted, not compressed */ psz_head[0] = 0x20; /* Means SAPv1, IPv4, not encrypted, not compressed */
psz_head[1] = 0x00; /* No authentification */ psz_head[1] = 0x00; /* No authentification length */
psz_head[2] = 0x42; /* Msg id hash */
psz_head[3] = 0x12; /* Msg id hash 2 */
psz_head[4] = 0x01; /* Source IP FIXME: we should get the real address */ i_hash = mdate();
psz_head[5] = 0x02; /* idem */ psz_head[2] = (i_hash & 0xFF00) >> 8; /* Msg id hash */
psz_head[6] = 0x03; /* idem */ psz_head[3] = (i_hash & 0xFF); /* Msg id hash 2 */
psz_head[7] = 0x04; /* idem */
if( p_method->i_ip_version == 6 )
{
/* in_addr_t ip_server = inet_addr( ip ); */
psz_head[0] |= 0x10; /* Set IPv6 */
psz_head[4] = 0x01; /* Source IP FIXME: we should get the real address */
psz_head[5] = 0x02; /* idem */
psz_head[6] = 0x03; /* idem */
psz_head[7] = 0x04; /* idem */
psz_head[8] = 0x01; /* Source IP FIXME: we should get the real address */
psz_head[9] = 0x02; /* idem */
psz_head[10] = 0x03; /* idem */
psz_head[11] = 0x04; /* idem */
psz_head[12] = 0x01; /* Source IP FIXME: we should get the real address */
psz_head[13] = 0x02; /* idem */
psz_head[14] = 0x03; /* idem */
psz_head[15] = 0x04; /* idem */
psz_head[16] = 0x01; /* Source IP FIXME: we should get the real address */
psz_head[17] = 0x02; /* idem */
psz_head[18] = 0x03; /* idem */
psz_head[19] = 0x04; /* idem */
strncpy( psz_head + 20, psz_type, 15 );
}
else
{
/* in_addr_t ip_server = inet_addr( ip) */
/* Source IP FIXME: we should get the real address */
psz_head[4] = 0x01; /* ip_server */
psz_head[5] = 0x02; /* ip_server>>8 */
psz_head[6] = 0x03; /* ip_server>>16 */
psz_head[7] = 0x04; /* ip_server>>24 */
strncpy( psz_head + 8, psz_type, 15 );
}
strncpy( psz_head + 8, psz_type, 15 );
psz_head[ i_header_size-1 ] = '\0'; psz_head[ i_header_size-1 ] = '\0';
p_sap_session->i_length = i_header_size + strlen( p_sap_session->psz_sdp); p_sap_session->i_length = i_header_size + strlen( p_sap_session->psz_sdp);
...@@ -386,8 +423,9 @@ static int announce_SAPAnnounceDel( sap_handler_t *p_sap, ...@@ -386,8 +423,9 @@ static int announce_SAPAnnounceDel( sap_handler_t *p_sap,
} }
} }
/* XXX: Dequeue the adress too if it is not used anymore /* XXX: Dequeue the address too if it is not used anymore
* TODO: address refcount */ * TODO: - address refcount
- send a SAP deletion packet */
msg_Dbg( p_sap,"%i announces remaining", p_sap->i_sessions ); msg_Dbg( p_sap,"%i announces remaining", p_sap->i_sessions );
......
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