Changeset e2dedca13cdfff43592c0fc5065446f11d248307
- Timestamp:
- 31/05/05 21:48:21 (4 years ago)
- git-parent:
- Files:
-
- include/stream_output.h (modified) (1 diff)
- modules/stream_out/rtp.c (modified) (2 diffs)
- modules/stream_out/standard.c (modified) (5 diffs)
- src/stream_output/announce.c (modified) (1 diff)
- src/stream_output/sap.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
include/stream_output.h
r97704de re2dedca 260 260 261 261 /* For SAP */ 262 int i_ip_version;263 262 char *psz_address; /* If we use a custom address */ 264 char sz_ipv6_scope; 265 }; 266 267 268 /* SAP Specific structures */ 269 270 /* 100ms */ 271 #define SAP_IDLE ((mtime_t)(0.100*CLOCK_FREQ)) 272 #define SAP_MAX_BUFFER 65534 273 #define MIN_INTERVAL 2 274 #define MAX_INTERVAL 300 275 276 /* A SAP announce address. For each of these, we run the 277 * control flow algorithm */ 278 struct sap_address_t 279 { 280 char *psz_address; 281 int i_ip_version; 282 int i_port; 283 int i_rfd; /* Read socket */ 284 int i_wfd; /* Write socket */ 285 286 /* Used for flow control */ 287 mtime_t t1; 288 vlc_bool_t b_enabled; 289 vlc_bool_t b_ready; 290 int i_interval; 291 int i_buff; 292 int i_limit; 293 }; 263 }; 264 294 265 295 266 /* A SAP session descriptor, enqueued in the SAP handler queue */ modules/stream_out/rtp.c
rfb751f6 re2dedca 1235 1235 sout_stream_sys_t *p_sys = p_stream->p_sys; 1236 1236 sout_instance_t *p_sout = p_stream->p_sout; 1237 /* FIXME: use sout_AnnounceMethodCreate */ 1237 1238 announce_method_t *p_method = (announce_method_t *) 1238 1239 malloc(sizeof(announce_method_t)); … … 1247 1248 p_method->i_type = METHOD_TYPE_SAP; 1248 1249 p_method->psz_address = NULL; /* FIXME */ 1249 p_method->i_ip_version = 4; /* FIXME ! */1250 1250 1251 1251 if( p_sys->i_es > 0 && p_sys->psz_sdp && *p_sys->psz_sdp ) modules/stream_out/standard.c
rcdce7f8 re2dedca 64 64 #define SAP_LONGTEXT N_("Announce this session with SAP") 65 65 66 #define SAPv6_TEXT N_("SAP IPv6 announcing")67 #define SAPv6_LONGTEXT N_("Use IPv6 to announce this session with SAP")68 69 66 #define SLP_TEXT N_("SLP announcing") 70 67 #define SLP_LONGTEXT N_("Announce this session with SLP") … … 96 93 add_string( SOUT_CFG_PREFIX "group", "", NULL, GROUP_TEXT, GROUP_LONGTEXT, 97 94 VLC_TRUE ); 98 add_bool( SOUT_CFG_PREFIX "sap-ipv6", 0, NULL, SAPv6_TEXT, SAPv6_LONGTEXT, 99 VLC_TRUE ); 95 add_deprecated( SOUT_CFG_PREFIX "sap-ipv6", VLC_FALSE ); 100 96 101 97 add_bool( SOUT_CFG_PREFIX "slp", 0, NULL, SLP_TEXT, SLP_LONGTEXT, VLC_TRUE ); … … 110 106 static const char *ppsz_sout_options[] = { 111 107 "access", "mux", "url", 112 "sap", "name", "sap-ipv6", "group", 113 "slp", NULL 108 "sap", "name", "group", "slp", NULL 114 109 }; 115 110 116 #define DEFAULT_IPV6_SCOPE '8'117 111 #define DEFAULT_PORT 1234 118 112 … … 350 344 free( val.psz_string ); 351 345 352 var_Get( p_stream, SOUT_CFG_PREFIX "sap-ipv6", &val );353 p_method->i_ip_version = val.b_bool ? 6 : 4;354 355 346 /* Now, parse the URL to extract host and port */ 356 347 vlc_UrlParse( &url, psz_url , 0); … … 370 361 371 362 sout_AnnounceRegister( p_sout, p_session, p_method ); 372 373 /* FIXME: Free p_method */374 375 363 p_stream->p_sys->p_session = p_session; 376 364 } 377 365 vlc_UrlClean( &url ); 378 366 367 /* FIXME: Free p_method */ 379 368 if( p_method->psz_address) free( p_method->psz_address ); 380 369 free( p_method ); src/stream_output/announce.c
r97704de re2dedca 205 205 p_method->i_type = i_type; 206 206 if( i_type == METHOD_TYPE_SAP ) 207 { 208 /* Default values */ 207 /* Default value */ 209 208 p_method->psz_address = NULL; 210 p_method->i_ip_version = 4 ;211 p_method->sz_ipv6_scope = '\0';212 }213 209 } 214 210 return p_method; src/stream_output/sap.c
r97704de re2dedca 2 2 * sap.c : SAP announce handler 3 3 ***************************************************************************** 4 * Copyright (C) 2002-200 4VideoLAN4 * Copyright (C) 2002-2005 VideoLAN 5 5 * $Id$ 6 6 * … … 28 28 #include <stdio.h> /* sprintf() */ 29 29 #include <string.h> /* strerror() */ 30 #include <ctype.h> /* tolower(), isxdigit() */ 30 31 31 32 #include <vlc/vlc.h> 32 33 #include <vlc/sout.h> 33 34 34 #include <network.h> 35 #include "network.h" 36 #if defined( WIN32 ) || defined( UNDER_CE ) 37 # if defined(UNDER_CE) && defined(sockaddr_storage) 38 # undef sockaddr_storage 39 # endif 40 # include <winsock2.h> 41 # include <ws2tcpip.h> 42 #else 43 # include <netdb.h> 44 #endif 35 45 #include "charset.h" 36 46 37 #define SAP_IPV4_ADDR "224.2.127.254" /* Standard port and address for SAP*/47 /* SAP is always on that port */ 38 48 #define SAP_PORT 9875 39 49 40 #define SAP_IPV6_ADDR_1 "FF0"41 #define SAP_IPV6_ADDR_2 "::2:7FFE"42 43 #define DEFAULT_IPV6_SCOPE '8'44 45 50 #define DEFAULT_PORT "1234" 46 51 47 52 #undef EXTRA_DEBUG 53 54 /* SAP Specific structures */ 55 56 /* 100ms */ 57 #define SAP_IDLE ((mtime_t)(0.100*CLOCK_FREQ)) 58 #define SAP_MAX_BUFFER 65534 59 #define MIN_INTERVAL 2 60 #define MAX_INTERVAL 300 61 62 /* A SAP announce address. For each of these, we run the 63 * control flow algorithm */ 64 struct sap_address_t 65 { 66 char *psz_address; 67 int i_port; 68 int i_rfd; /* Read socket */ 69 int i_wfd; /* Write socket */ 70 71 /* Used for flow control */ 72 mtime_t t1; 73 vlc_bool_t b_enabled; 74 vlc_bool_t b_ready; 75 int i_interval; 76 int i_buff; 77 int i_limit; 78 }; 48 79 49 80 /***************************************************************************** … … 228 259 int i_header_size; 229 260 char *psz_head; 230 vlc_bool_t b_found = VLC_FALSE ;261 vlc_bool_t b_found = VLC_FALSE, b_ipv6; 231 262 sap_session_t *p_sap_session; 232 263 mtime_t i_hash; … … 244 275 } 245 276 246 if( !p_method->psz_address ) 247 { 248 if( p_method->i_ip_version == 6 ) 249 { 250 char sz_scope; 251 if( p_method->sz_ipv6_scope ) 277 if( p_method->psz_address == NULL ) 278 { 279 /* Determine SAP multicast address automatically */ 280 char psz_buf[NI_MAXHOST]; 281 const char *psz_addr; 282 struct addrinfo hints, *res; 283 284 if( p_session->psz_uri == NULL ) 285 { 286 msg_Err( p_sap, "*FIXME* Unexpected NULL URI for SAP announce" ); 287 msg_Err( p_sap, "This should not happen. VLC needs fixing." ); 288 vlc_mutex_unlock( &p_sap->object_lock ); 289 return VLC_EGENERIC; 290 } 291 292 /* Canonicalize IP address (e.g. 224.00.010.1 => 224.0.10.1) */ 293 memset( &hints, 0, sizeof( hints ) ); 294 hints.ai_socktype = SOCK_DGRAM; 295 hints.ai_flags = AI_NUMERICHOST; 296 297 i = vlc_getaddrinfo( (vlc_object_t *)p_sap, p_session->psz_uri, NULL, 298 &hints, &res ); 299 if( i == 0 ) 300 i = vlc_getnameinfo( (vlc_object_t *)p_sap, res->ai_addr, 301 res->ai_addrlen, psz_buf, sizeof( psz_buf ), 302 NULL, 0, NI_NUMERICHOST ); 303 if( i ) 304 { 305 msg_Err( p_sap, "Invalid URI for SAP announce : %s : %s", 306 p_session->psz_uri, vlc_gai_strerror( i ) ); 307 vlc_mutex_unlock( &p_sap->object_lock ); 308 return VLC_EGENERIC; 309 } 310 311 if( strchr( psz_buf, ':' ) != NULL ) 312 { 313 b_ipv6 = VLC_TRUE; 314 315 /* See RFC3513 for list of valid IPv6 scopes */ 316 if( ( tolower( psz_buf[0] ) == 'f' ) 317 && ( tolower( psz_buf[1] ) == 'f' ) 318 && isxdigit( psz_buf[2] ) && isxdigit( psz_buf[3] ) ) 252 319 { 253 sz_scope = p_method->sz_ipv6_scope; 320 /* Multicast IPv6 */ 321 psz_buf[2] = '0'; /* force flags to zero */ 322 /* keep scope in psz_addr[3] */ 323 memcpy( &psz_buf[4], "::2:7ffe", sizeof( "::2:7ffe" ) ); 324 psz_addr = psz_buf; 254 325 } 255 326 else 256 { 257 sz_scope = DEFAULT_IPV6_SCOPE; 258 } 259 p_method->psz_address = (char*)malloc( 30*sizeof(char )); 260 sprintf( p_method->psz_address, "%s%c%s", 261 SAP_IPV6_ADDR_1, sz_scope, SAP_IPV6_ADDR_2 ); 327 /* Unicast IPv6 - assume global scope */ 328 psz_addr = "ff0e::2:7ffe"; 262 329 } 263 330 else 264 331 { 265 /* IPv4 */ 266 p_method->psz_address = (char*)malloc( 15*sizeof(char) ); 267 snprintf(p_method->psz_address, 15, SAP_IPV4_ADDR ); 268 } 269 } 270 msg_Dbg( p_sap, "using SAP address: %s",p_method->psz_address); 332 b_ipv6 = VLC_FALSE; 333 334 /* See RFC2365 for IPv4 scopes */ 335 if( memcmp( psz_buf, "224.0.0.", 8 ) == 0 ) 336 psz_addr = "224.0.0.255"; 337 else 338 if( memcmp( psz_buf, "239.255.", 8 ) == 0 ) 339 psz_addr = "239.255.255.255"; 340 else 341 if( ( memcmp( psz_buf, "239.19", 6 ) == 0 ) 342 && ( ( psz_buf[6] >= '2' ) && ( psz_buf[6] <= '5' ) ) ) 343 psz_addr = "239.195.255.255"; 344 else 345 /* assume global scope */ 346 psz_addr = "224.2.127.254"; 347 } 348 349 p_method->psz_address = strdup( psz_addr ); 350 } 351 else 352 b_ipv6 == (strchr( p_method->psz_address, ':' ) != NULL); 353 354 msg_Dbg( p_sap, "using SAP address: %s", p_method->psz_address); 271 355 272 356 /* XXX: Check for dupes */ … … 297 381 } 298 382 p_address->psz_address = strdup( p_method->psz_address ); 299 p_address->i_ip_version = p_method->i_ip_version;300 383 p_address->i_port = 9875; 301 384 p_address->i_wfd = net_OpenUDP( p_sap, "", 0, … … 337 420 338 421 /* Build the SAP Headers */ 339 i_header_size = ( p_method->i_ip_version ==6 ? 20 : 8 ) + strlen( psz_type ) + 1;422 i_header_size = ( b_ipv6 ? 20 : 8 ) + strlen( psz_type ) + 1; 340 423 psz_head = (char *) malloc( i_header_size * sizeof( char ) ); 341 424 if( ! psz_head ) … … 352 435 psz_head[3] = (i_hash & 0xFF); /* Msg id hash 2 */ 353 436 354 if( p_method->i_ip_version ==6 )437 if( b_ipv6 ) 355 438 { 356 439 /* in_addr_t ip_server = inet_addr( ip ); */ … … 499 582 int i_sdp_version = 1 + p_sap->i_sessions + (rand()&0xfff); 500 583 char *psz_group, *psz_name; 584 char ipv; 501 585 502 586 psz_group = convert_to_utf8( p_sap, p_session->psz_group ); 503 587 psz_name = convert_to_utf8( p_sap, p_session->psz_name ); 588 589 ipv = ( strchr( p_session->psz_uri, ':' ) != NULL) ? '6' : '4'; 504 590 505 591 /* see the lists in modules/stream_out/rtp.c for compliance stuff */ … … 529 615 "s=%s\r\n" 530 616 "t=0 0\r\n" 531 "c=IN IP 4%s/%d\r\n"617 "c=IN IP%c %s/%d\r\n" 532 618 "m=video %d udp %d\r\n" 533 619 "a=tool:"PACKAGE_STRING"\r\n" 534 620 "a=type:broadcast\r\n", 535 621 i_sdp_id, i_sdp_version, 536 psz_name, 622 psz_name, ipv, 537 623 p_session->psz_uri, p_session->i_ttl, 538 624 p_session->i_port, p_session->i_payload );
