/* Default client mode is FILE, use these to change it */
VLC_API void httpd_ClientModeStream( httpd_client_t *cl );
VLC_API void httpd_ClientModeBidir( httpd_client_t *cl );
-VLC_API char* httpd_ClientIP( const httpd_client_t *cl, char *psz_ip );
-VLC_API char* httpd_ServerIP( const httpd_client_t *cl, char *psz_ip );
+VLC_API char* httpd_ClientIP( const httpd_client_t *cl, char *, int * );
+VLC_API char* httpd_ServerIP( const httpd_client_t *cl, char *, int * );
/* High level */
{
/* RTSP server */
httpd_host_t *p_rtsp_host;
- int i_port;
int i_throttle_users;
int i_connections;
goto error;
}
- p_sys->i_port = 554;
-
TAB_INIT( p_sys->i_media, p_sys->media );
p_sys->i_media_id = 0;
msg_Dbg( p_vod, "created RTSP url: %s", p_media->psz_rtsp_path );
if( asprintf( &p_media->psz_rtsp_control_v4,
- "rtsp://%%s:%d%s/trackID=%%d",
- p_sys->i_port, p_media->psz_rtsp_path ) < 0 )
+ "rtsp://%%s:%%d%s/trackID=%%d",
+ p_media->psz_rtsp_path ) < 0 )
{
httpd_UrlDelete( p_media->p_rtsp_url );
free( p_media->psz_rtsp_path );
return NULL;
}
if( asprintf( &p_media->psz_rtsp_control_v6,
- "rtsp://[%%s]:%d%s/trackID=%%d",
- p_sys->i_port, p_media->psz_rtsp_path ) < 0 )
+ "rtsp://[%%s]:%%d%s/trackID=%%d",
+ p_media->psz_rtsp_path ) < 0 )
{
httpd_UrlDelete( p_media->p_rtsp_url );
free( p_media->psz_rtsp_path );
httpd_UrlCatch( p_media->p_rtsp_url, HTTPD_MSG_GETPARAMETER,
RtspCallback, (void*)p_media );
httpd_UrlCatch( p_media->p_rtsp_url, HTTPD_MSG_TEARDOWN,
+
RtspCallback, (void*)p_media );
p_media->p_vod = p_vod;
p_media->b_raw = true;
}
- if( httpd_ClientIP( cl, ip ) == NULL )
+ if( httpd_ClientIP( cl, ip, NULL ) == NULL )
{
answer->i_status = 500;
answer->i_body = 0;
break;
}
- if( httpd_ClientIP( cl, ip ) == NULL ) break;
+ if( httpd_ClientIP( cl, ip, NULL ) == NULL ) break;
p_rtsp->b_playing = true;
int i_port = atoi( strstr( psz_transport, "client_port=" ) +
strlen("client_port=") );
- if( httpd_ClientIP( cl, ip ) == NULL )
+ if( httpd_ClientIP( cl, ip, NULL ) == NULL )
{
answer->i_status = 500;
answer->i_body = 0;
{
char *psz_sdp, ip[NI_MAXNUMERICHOST];
const char *psz_control;
+ int port;
- if( httpd_ServerIP( cl, ip ) == NULL )
+ if( httpd_ServerIP( cl, ip, &port ) == NULL )
return NULL;
bool ipv6 = ( strchr( ip, ':' ) != NULL );
p_es->psz_ptname, p_es->i_clock_rate, p_es->i_channels,
p_es->psz_fmtp );
- sdp_AddAttribute( &psz_sdp, "control", psz_control, ip, i );
+ sdp_AddAttribute( &psz_sdp, "control", psz_control, ip, port, i );
}
return psz_sdp;
httpd_url_t *url;
char *psz_path;
unsigned track_id;
- unsigned port;
int sessionc;
rtsp_session_t **sessionv;
goto error;
}
- rtsp->port = (url->i_port > 0) ? url->i_port : 554;
+ int port = (url->i_port > 0) ? url->i_port : 554;
rtsp->psz_path = strdup( ( url->psz_path != NULL ) ? url->psz_path : "/" );
if( rtsp->psz_path == NULL )
goto error;
- msg_Dbg( owner, "RTSP stream: port %d at %s", rtsp->port, rtsp->psz_path );
+ msg_Dbg( owner, "RTSP stream: port %d at %s", port, rtsp->psz_path );
- rtsp->host = vlc_rtsp_HostNew( VLC_OBJECT(owner), rtsp->port );
+ rtsp->host = vlc_rtsp_HostNew( VLC_OBJECT(owner), port );
if( rtsp->host == NULL )
goto error;
{
/* Build self-referential control URL */
char ip[NI_MAXNUMERICHOST], *ptr;
+ int port;
- httpd_ServerIP( cl, ip );
+ httpd_ServerIP( cl, ip, &port );
ptr = strchr( ip, '%' );
if( ptr != NULL )
*ptr = '\0';
if( strchr( ip, ':' ) != NULL )
- sprintf( control, "rtsp://[%s]:%u%s", ip, rtsp->port,
- rtsp->psz_path );
+ sprintf( control, "rtsp://[%s]:%d%s", ip, port, rtsp->psz_path );
else
- sprintf( control, "rtsp://%s:%u%s", ip, rtsp->port,
- rtsp->psz_path );
+ sprintf( control, "rtsp://%s:%d%s", ip, port, rtsp->psz_path );
}
/* */
int fd, sport;
uint32_t ssrc;
- if( httpd_ClientIP( cl, ip ) == NULL )
+ if( httpd_ClientIP( cl, ip, NULL ) == NULL )
{
answer->i_status = 500;
continue;
}
vlc_mutex_unlock( &rtsp->lock );
- httpd_ServerIP( cl, ip );
+ httpd_ServerIP( cl, ip, NULL );
/* Specify source IP only if it is different from the
* RTSP control connection server address */
#ifndef ENABLE_HTTPD
# include <vlc_httpd.h>
-char *httpd_ClientIP (const httpd_client_t *cl, char *psz_ip)
+char *httpd_ClientIP (const httpd_client_t *cl, char *psz_ip, int *port)
{
- (void) cl; (void) psz_ip;
+ (void) cl; (void) psz_ip; (void) port
assert (0);
}
assert (0);
}
-char *httpd_ServerIP (const httpd_client_t *client, char *ip)
+char *httpd_ServerIP (const httpd_client_t *client, char *ip, int *port)
{
- (void) client; (void) ip;
+ (void) client; (void) ip; (void) port;
assert (0);
}
/* We do it ourselves, thanks */
answer->i_status = 0;
- if( httpd_ClientIP( cl, psz_remote_addr ) == NULL )
+ if( httpd_ClientIP( cl, psz_remote_addr, NULL ) == NULL )
*psz_remote_addr = '\0';
uint8_t *psz_args = query->psz_args;
cl->i_mode = HTTPD_CLIENT_BIDIR;
}
-char* httpd_ClientIP( const httpd_client_t *cl, char *psz_ip )
+char* httpd_ClientIP( const httpd_client_t *cl, char *ip, int *port )
{
- return net_GetPeerAddress( cl->fd, psz_ip, NULL ) ? NULL : psz_ip;
+ return net_GetPeerAddress( cl->fd, ip, port ) ? NULL : ip;
}
-char* httpd_ServerIP( const httpd_client_t *cl, char *psz_ip )
+char* httpd_ServerIP( const httpd_client_t *cl, char *ip, int *port )
{
- return net_GetSockAddress( cl->fd, psz_ip, NULL ) ? NULL : psz_ip;
+ return net_GetSockAddress( cl->fd, ip, port ) ? NULL : ip;
}
static void httpd_ClientClean( httpd_client_t *cl )
{
char ip[NI_MAXNUMERICHOST];
- if( ( httpd_ClientIP( cl, ip ) == NULL )
+ if( ( httpd_ClientIP( cl, ip, NULL ) == NULL )
|| ACL_Check( url->p_acl, ip ) )
{
b_hosts_failed = true;