static int Open ( vlc_object_t * );
static void Close( vlc_object_t * );
-#define HOST_TEXT N_( "RTSP host address" )
-#define HOST_LONGTEXT N_( \
- "This defines the address, port and path the RTSP VOD server will listen " \
- "on.\nSyntax is address:port/path. The default is to listen on all "\
- "interfaces (address 0.0.0.0), on port 554, with no path.\nTo listen " \
- "only on the local interface, use \"localhost\" as address." )
-
#define THROTTLE_TEXT N_( "Maximum number of connections" )
#define THROTTLE_LONGTEXT N_( "This limits the maximum number of clients " \
"that can connect to the RTSP VOD. 0 means no limit." )
set_capability( "vod server", 1 )
set_callbacks( Open, Close )
add_shortcut( "rtsp" )
- add_string ( "rtsp-host", NULL, HOST_TEXT, HOST_LONGTEXT, true )
add_string( "rtsp-raw-mux", "ts", RAWMUX_TEXT,
RAWMUX_TEXT, true )
add_integer( "rtsp-throttle-users", 0, THROTTLE_TEXT,
/* RTSP server */
httpd_host_t *p_rtsp_host;
char *psz_path;
- int i_port;
int i_throttle_users;
int i_connections;
vod_media_t **media;
/* */
+ vlc_thread_t thread;
block_fifo_t *p_fifo_cmd;
};
static int MediaAddES( vod_t *, vod_media_t *, es_format_t * );
static void MediaDelES( vod_t *, vod_media_t *, es_format_t * );
-static void* CommandThread( vlc_object_t *p_this );
+static void* CommandThread( void * );
static void CommandPush( vod_t *, rtsp_cmd_type_t, vod_media_t *,
const char *psz_session, int64_t i_arg,
double f_arg, const char *psz_arg );
vlc_UrlParse( &url, psz_url, 0 );
free( psz_url );
- if( url.i_port <= 0 ) url.i_port = 554;
-
p_vod->p_sys = p_sys = malloc( sizeof( vod_sys_t ) );
if( !p_sys ) goto error;
p_sys->p_rtsp_host = 0;
p_sys->psz_raw_mux = var_CreateGetString( p_this, "rtsp-raw-mux" );
- p_sys->p_rtsp_host =
- httpd_HostNew( VLC_OBJECT(p_vod), url.psz_host, url.i_port );
+ var_Create( p_vod, "rtsp-host", VLC_VAR_STRING );
+ var_SetString( p_vod, "rtsp-host", url.psz_host );
+
+ if( url.i_port <= 0 ) url.i_port = 554;
+ var_Create( p_vod, "rtsp-port", VLC_VAR_INTEGER );
+ var_SetInteger( p_vod, "rtsp-port", url.i_port );
+
+ p_sys->p_rtsp_host = vlc_rtsp_HostNew( VLC_OBJECT(p_vod) );
if( !p_sys->p_rtsp_host )
{
- msg_Err( p_vod, "cannot create RTSP server (%s:%i)",
- url.psz_host, url.i_port );
+ msg_Err( p_vod, "cannot create RTSP server" );
goto error;
}
p_sys->psz_path = strdup( url.psz_path ? url.psz_path : "/" );
- p_sys->i_port = url.i_port;
vlc_UrlClean( &url );
p_vod->pf_media_del = MediaAskDel;
p_sys->p_fifo_cmd = block_FifoNew();
- if( vlc_thread_create( p_vod, CommandThread, VLC_THREAD_PRIORITY_LOW ) )
+ if( vlc_clone( &p_sys->thread, CommandThread, p_vod, VLC_THREAD_PRIORITY_LOW ) )
{
msg_Err( p_vod, "cannot spawn rtsp vod thread" );
block_FifoRelease( p_sys->p_fifo_cmd );
vod_sys_t *p_sys = p_vod->p_sys;
/* Stop command thread */
- vlc_object_kill( p_vod );
CommandPush( p_vod, RTSP_CMD_TYPE_NONE, NULL, NULL, 0, 0.0, NULL );
- vlc_thread_join( p_vod );
+ vlc_join( p_sys->thread, NULL );
while( block_FifoCount( p_sys->p_fifo_cmd ) > 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 );
block_FifoPut( p_vod->p_sys->p_fifo_cmd, p_cmd );
}
-static void* CommandThread( vlc_object_t *p_this )
+static void* CommandThread( void *obj )
{
- vod_t *p_vod = (vod_t*)p_this;
+ vod_t *p_vod = (vod_t*)obj;
vod_sys_t *p_sys = p_vod->p_sys;
int canc = vlc_savecancel ();
- while( vlc_object_alive (p_vod) )
+ for( ;; )
{
block_t *p_block_cmd = block_FifoGet( p_sys->p_fifo_cmd );
rtsp_cmd_t cmd;
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;