static int Open ( vlc_object_t * );
static void Close( vlc_object_t * );
-vlc_module_begin();
- set_description( N_("RTMP input") );
- set_shortname( N_("RTMP") );
- set_category( CAT_INPUT );
- set_subcategory( SUBCAT_INPUT_ACCESS );
+vlc_module_begin ()
+ set_description( N_("RTMP input") )
+ set_shortname( N_("RTMP") )
+ set_category( CAT_INPUT )
+ set_subcategory( SUBCAT_INPUT_ACCESS )
add_integer( "rtmp-caching", DEFAULT_PTS_DELAY / 1000, NULL, CACHING_TEXT,
CACHING_LONGTEXT, true );
- set_capability( "access", 10 );
- set_callbacks( Open, Close );
- add_shortcut( "rtmp" );
-vlc_module_end();
+ set_capability( "access", 0 )
+ set_callbacks( Open, Close )
+ add_shortcut( "rtmp" )
+vlc_module_end ()
/*****************************************************************************
* Local prototypes
*****************************************************************************/
-static int Read( access_t *, uint8_t *, size_t ); /*DOWN: last parameter int */
+static ssize_t Read( access_t *, uint8_t *, size_t );
static int Seek( access_t *, int64_t );
static int Control( access_t *, int, va_list );
-static void ThreadControl( vlc_object_t * );
+static void* ThreadControl( vlc_object_t * );
/*****************************************************************************
* Open: open the rtmp connection
p_sys->p_thread =
vlc_object_create( p_access, sizeof( rtmp_control_thread_t ) );
if( !p_sys->p_thread )
- {
- msg_Err( p_access, "out of memory" );
return VLC_ENOMEM;
- }
vlc_object_attach( p_sys->p_thread, p_access );
/* Parse URI - remove spaces */
}
length_path = strlen( p_sys->p_thread->url.psz_path );
- length_media_name = strlen( strrchr( p_sys->p_thread->url.psz_path, '/' ) ) - 1;
+ char* psz_tmp = strrchr( p_sys->p_thread->url.psz_path, '/' );
+ if( !psz_tmp )
+ goto error;
+ length_media_name = strlen( psz_tmp ) - 1;
p_sys->p_thread->psz_application = strndup( p_sys->p_thread->url.psz_path + 1, length_path - length_media_name - 2 );
p_sys->p_thread->psz_media = strdup( p_sys->p_thread->url.psz_path + ( length_path - length_media_name ) );
p_sys->p_thread->p_base_object = p_this;
- vlc_cond_init( p_sys->p_thread, &p_sys->p_thread->wait );
+ vlc_cond_init( &p_sys->p_thread->wait );
vlc_mutex_init( &p_sys->p_thread->lock );
}
if( vlc_thread_create( p_sys->p_thread, "rtmp control thread", ThreadControl,
- VLC_THREAD_PRIORITY_INPUT, false ) )
+ VLC_THREAD_PRIORITY_INPUT ) )
{
msg_Err( p_access, "cannot spawn rtmp control thread" );
goto error2;
net_Close( p_sys->p_thread->fd );
error:
+ vlc_UrlClean( &p_sys->p_thread->url );
+
vlc_object_detach( p_sys->p_thread );
vlc_object_release( p_sys->p_thread );
- vlc_UrlClean( &p_sys->p_thread->url );
free( p_sys );
return VLC_EGENERIC;
/* p_sys->p_thread->b_die = true;*/
vlc_object_kill( p_sys->p_thread );
block_FifoWake( p_sys->p_thread->p_fifo_input );
- block_FifoWake( p_sys->p_thread->p_empty_blocks );
vlc_thread_join( p_sys->p_thread );
var_Destroy( p_access, "rtmp-caching" );
- vlc_object_detach( p_sys->p_thread );
- vlc_object_release( p_sys->p_thread );
-
vlc_UrlClean( &p_sys->p_thread->url );
free( p_sys->p_thread->psz_application );
free( p_sys->p_thread->psz_media );
+
+ vlc_object_detach( p_sys->p_thread );
+ vlc_object_release( p_sys->p_thread );
free( p_sys );
}
/*****************************************************************************
* Read: standard read on a file descriptor.
*****************************************************************************/
-static int Read( access_t *p_access, uint8_t *p_buffer, size_t i_len )
+static ssize_t Read( access_t *p_access, uint8_t *p_buffer, size_t i_len )
{
access_sys_t *p_sys = p_access->p_sys;
rtmp_packet_t *rtmp_packet;
while( i_len_tmp < i_len )
{
- if( p_sys->p_thread->result_stop || p_access->info.b_eof || p_access->b_die )
+ if( p_sys->p_thread->result_stop || p_access->info.b_eof || !vlc_object_alive (p_access) )
{
p_access->info.b_eof = true;
return 0;
static int Control( access_t *p_access, int i_query, va_list args )
{
bool *pb_bool;
- int *pi_int;
int64_t *pi_64;
switch( i_query )
break;
/* */
- case ACCESS_GET_MTU:
- pi_int = (int*) va_arg( args, int * );
- *pi_int = 0;
- break;
-
case ACCESS_GET_PTS_DELAY:
pi_64 = (int64_t*) va_arg( args, int64_t * );
*pi_64 = var_GetInteger( p_access, "rtmp-caching" ) * INT64_C(1000);
/*****************************************************************************
* ThreadControl: manage control messages and pipe media to Read
*****************************************************************************/
-static void ThreadControl( vlc_object_t *p_this )
+static void* ThreadControl( vlc_object_t *p_this )
{
rtmp_control_thread_t *p_thread = (rtmp_control_thread_t *) p_this;
rtmp_packet_t *rtmp_packet;
+ int canc = vlc_savecancel ();
rtmp_init_handler( p_thread->rtmp_handler );
- while( !p_thread->b_die )
+ while( vlc_object_alive (p_thread) )
{
rtmp_packet = rtmp_read_net_packet( p_thread );
if( rtmp_packet != NULL )
block_FifoWake( p_thread->p_fifo_input );
}
}
+ vlc_restorecancel (canc);
+ return NULL;
}