- case HTTPD_MSG_SETUP:
- {
- const char *psz_transport = httpd_MsgGet( query, "Transport" );
-
- //fprintf( stderr, "HTTPD_MSG_SETUP: transport=%s\n", psz_transport );
-
- if( strstr( psz_transport, "multicast" ) && id->psz_destination )
- {
- //fprintf( stderr, "HTTPD_MSG_SETUP: multicast\n" );
- answer->i_status = 200;
- answer->psz_status = strdup( "OK" );
- answer->i_body = 0;
- answer->p_body = NULL;
-
- psz_session = httpd_MsgGet( query, "Session" );
- if( !psz_session )
- psz_session = psz_session_init;
-
- httpd_MsgAdd( answer, "Transport",
- "RTP/AVP/UDP;destination=%s;port=%d-%d;ttl=%d",
- id->psz_destination, id->i_port,id->i_port+1,
- p_sys->i_ttl > 0 ? p_sys->i_ttl : 1);
- }
- else if( strstr( psz_transport, "unicast" ) && strstr( psz_transport, "client_port=" ) )
- {
- int i_port = atoi( strstr( psz_transport, "client_port=" ) + strlen("client_port=") );
- char ip[NI_MAXNUMERICHOST], psz_access[17], psz_url[NI_MAXNUMERICHOST + 8];
-
- sout_access_out_t *p_access;
-
- rtsp_client_t *rtsp = NULL;
-
- if( httpd_ClientIP( cl, ip ) == NULL )
- {
- answer->i_status = 500;
- answer->psz_status = strdup( "Internal server error" );
- answer->i_body = 0;
- answer->p_body = NULL;
- break;
- }
-
- //fprintf( stderr, "HTTPD_MSG_SETUP: unicast ip=%s port=%d\n", ip, i_port );
-
- psz_session = httpd_MsgGet( query, "Session" );
- if( !psz_session )
- {
- psz_session = psz_session_init;
- rtsp = RtspClientNew( p_stream, psz_session_init );
- }
- else
- {
- rtsp = RtspClientGet( p_stream, psz_session );
- if( rtsp == NULL )
- {
- answer->i_status = 454;
- answer->psz_status = strdup( "Unknown session id" );
- answer->i_body = 0;
- answer->p_body = NULL;
- break;
- }
- }
-
- /* first try to create the access out */
- if( p_sys->i_ttl )
- snprintf( psz_access, sizeof( psz_access ),
- "udp{raw,ttl=%d}", p_sys->i_ttl );
- else
- strlcpy( psz_access, "udp{raw}", sizeof( psz_access ) );
-
- snprintf( psz_url, sizeof( psz_url ),
- ( strchr( ip, ':' ) != NULL ) ? "[%s]:%d" : "%s:%d",
- ip, i_port );
-
- if( ( p_access = sout_AccessOutNew( p_stream->p_sout, psz_access, psz_url ) ) == NULL )
- {
- msg_Err( p_stream, "cannot create the access out for %s://%s",
- psz_access, psz_url );
- answer->i_status = 500;
- answer->psz_status = strdup( "Internal server error" );
- answer->i_body = 0;
- answer->p_body = NULL;
- break;
- }
-
- TAB_APPEND( rtsp->i_id, rtsp->id, id );
- TAB_APPEND( rtsp->i_access, rtsp->access, p_access );
-
- answer->i_status = 200;
- answer->psz_status = strdup( "OK" );
- answer->i_body = 0;
- answer->p_body = NULL;
-
- httpd_MsgAdd( answer, "Transport",
- "RTP/AVP/UDP;client_port=%d-%d", i_port, i_port + 1 );
- }
- else /* TODO strstr( psz_transport, "interleaved" ) ) */
- {
- answer->i_status = 461;
- answer->psz_status = strdup( "Unsupported Transport" );
- answer->i_body = 0;
- answer->p_body = NULL;
- }