- int64_t i_sdp_id = mdate();
- int i_sdp_version = 1 + p_sap->i_sessions + (rand()&0xfff);
- char *psz_group, *psz_name, psz_uribuf[NI_MAXNUMERICHOST], *psz_uri;
- char ipv;
-
- psz_group = convert_to_utf8( p_sap, p_session->psz_group );
- psz_name = convert_to_utf8( p_sap, p_session->psz_name );
-
- /* FIXME: really check that psz_uri is a real IP address
- * FIXME: make a common function to obtain a canonical IP address */
- ipv = ( strchr( p_session->psz_uri, ':' ) != NULL) ? '6' : '4';
- if( *p_session->psz_uri == '[' )
- {
- char *ptr;
-
- strncpy( psz_uribuf, p_session->psz_uri + 1, sizeof( psz_uribuf ) );
- psz_uribuf[sizeof( psz_uribuf ) - 1] = '\0';
- ptr = strchr( psz_uribuf, '%' );
- if( ptr != NULL)
- *ptr = '\0';
- ptr = strchr( psz_uribuf, ']' );
- if( ptr != NULL)
- *ptr = '\0';
- psz_uri = psz_uribuf;
- }
- else
- psz_uri = p_session->psz_uri;
-
- /* see the lists in modules/stream_out/rtp.c for compliance stuff */
- p_session->psz_sdp = (char *)malloc(
- sizeof("v=0\r\n"
- "o=- 45383436098 45398 IN IP4 127.0.0.1\r\n" /* FIXME */
- "s=\r\n"
- "t=0 0\r\n"
- "c=IN IP4 /\r\n"
- "m=video udp\r\n"
- "a=tool:"PACKAGE_STRING"\r\n"
- "a=type:broadcast\r\n")
- + strlen( psz_name )
- + strlen( psz_uri ) + 300
- + ( psz_group ? strlen( psz_group ) : 0 ) );
-
- if( p_session->psz_sdp == NULL || psz_name == NULL )
- {
- msg_Err( p_sap, "out of memory" );
- FREE( psz_name );
- FREE( psz_group );
- return VLC_ENOMEM;
- }
-
- sprintf( p_session->psz_sdp,
- "v=0\r\n"
- "o=- "I64Fd" %d IN IP4 127.0.0.1\r\n"
- "s=%s\r\n"
- "t=0 0\r\n"
- "c=IN IP%c %s/%d\r\n"
- "m=video %d udp %d\r\n"
- "a=tool:"PACKAGE_STRING"\r\n"
- "a=type:broadcast\r\n",
- i_sdp_id, i_sdp_version,
- psz_name, ipv,
- psz_uri, p_session->i_ttl,
- p_session->i_port, p_session->i_payload );
- free( psz_name );
-
- if( psz_group )
- {
- sprintf( p_session->psz_sdp, "%sa=x-plgroup:%s\r\n",
- p_session->psz_sdp, psz_group );
- free( psz_group );
- }
-
- msg_Dbg( p_sap, "Generated SDP (%i bytes):\n%s", strlen(p_session->psz_sdp),
- p_session->psz_sdp );
- return VLC_SUCCESS;
-}
-
-static int CalculateRate( sap_handler_t *p_sap, sap_address_t *p_address )
-{
- int i_read;
- char buffer[SAP_MAX_BUFFER];
- int i_tot = 0;