X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Faccess_output%2Frtmp.c;h=7e880ea6c2ad01fdaa394c415affbcbf28c54dab;hb=5de1345f2c547e4eb1ca1231f3353f8987f3f201;hp=f2155c714ae85931e80c321d0f7b989527da7893;hpb=05492281965ed211badf7e1f4c2220be720d3356;p=vlc diff --git a/modules/access_output/rtmp.c b/modules/access_output/rtmp.c index f2155c714a..7e880ea6c2 100644 --- a/modules/access_output/rtmp.c +++ b/modules/access_output/rtmp.c @@ -54,13 +54,13 @@ static void Close( vlc_object_t * ); vlc_module_begin () set_description( N_("RTMP stream output") ) set_shortname( N_("RTMP" ) ) - set_capability( "sout access", 50 ) + set_capability( "sout access", 0 ) set_category( CAT_SOUT ) set_subcategory( SUBCAT_SOUT_STREAM ) add_shortcut( "rtmp" ) set_callbacks( Open, Close ) add_bool( "rtmp-connect", false, NULL, RTMP_CONNECT_TEXT, - RTMP_CONNECT_LONGTEXT, false ); + RTMP_CONNECT_LONGTEXT, false ) vlc_module_end () /***************************************************************************** @@ -68,7 +68,7 @@ vlc_module_end () *****************************************************************************/ static ssize_t Write( sout_access_out_t *, block_t * ); static int Seek ( sout_access_out_t *, off_t ); -static void* ThreadControl( vlc_object_t * ); +static void* ThreadControl( void * ); struct sout_access_out_sys_t { @@ -96,7 +96,10 @@ static int Open( vlc_object_t *p_this ) p_sys->p_thread = vlc_object_create( p_access, sizeof( rtmp_control_thread_t ) ); if( !p_sys->p_thread ) + { + free( p_sys ); return VLC_ENOMEM; + } vlc_object_attach( p_sys->p_thread, p_access ); /* Parse URI - remove spaces */ @@ -136,12 +139,10 @@ static int Open( vlc_object_t *p_this ) if( p_sys->p_thread->url.psz_username && *p_sys->p_thread->url.psz_username ) { - msg_Dbg( p_access, " user='%s', pwd='%s'", - p_sys->p_thread->url.psz_username, p_sys->p_thread->url.psz_password ); + msg_Dbg( p_access, " user='%s'", p_sys->p_thread->url.psz_username ); } /* Initialize thread variables */ - p_sys->p_thread->b_die = 0; p_sys->p_thread->b_error= 0; p_sys->p_thread->p_fifo_input = block_FifoNew(); p_sys->p_thread->p_empty_blocks = block_FifoNew(); @@ -206,7 +207,7 @@ static int Open( vlc_object_t *p_this ) } do - p_sys->p_thread->fd = net_Accept( p_access, p_fd_listen, -1 ); + p_sys->p_thread->fd = net_Accept( p_access, p_fd_listen ); while( p_sys->p_thread->fd == -1 ); net_ListenClose( p_fd_listen ); @@ -217,8 +218,8 @@ static int Open( vlc_object_t *p_this ) } } - if( vlc_thread_create( p_sys->p_thread, "rtmp control thread", ThreadControl, - VLC_THREAD_PRIORITY_INPUT, false ) ) + if( vlc_clone( &p_sys->p_thread->thread, ThreadControl, p_sys->p_thread, + VLC_THREAD_PRIORITY_INPUT ) ) { msg_Err( p_access, "cannot spawn rtmp control thread" ); goto error2; @@ -229,6 +230,8 @@ static int Open( vlc_object_t *p_this ) if( rtmp_connect_passive( p_sys->p_thread ) < 0 ) { msg_Err( p_access, "connect passive failed"); + vlc_cancel( p_sys->p_thread->thread ); + vlc_join( p_sys->p_thread->thread, NULL ); goto error2; } } @@ -248,10 +251,9 @@ error2: if( p_sys->p_thread->fd != -1 ) 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; @@ -266,11 +268,8 @@ static void Close( vlc_object_t * p_this ) sout_access_out_sys_t *p_sys = p_access->p_sys; int i; -// p_sys->p_thread->b_die = true; - vlc_object_kill( p_sys->p_thread ); - block_FifoWake( p_sys->p_thread->p_fifo_input ); - - vlc_thread_join( p_sys->p_thread ); + vlc_cancel( p_sys->p_thread->thread ); + vlc_join( p_sys->p_thread->thread, NULL ); vlc_cond_destroy( &p_sys->p_thread->wait ); vlc_mutex_destroy( &p_sys->p_thread->lock ); @@ -375,17 +374,19 @@ static int Seek( sout_access_out_t *p_access, off_t i_pos ) /***************************************************************************** * ThreadControl: manage control messages and pipe media to Read *****************************************************************************/ -static void* ThreadControl( vlc_object_t *p_this ) +static void* ThreadControl( void *p_this ) { - rtmp_control_thread_t *p_thread = (rtmp_control_thread_t *) p_this; + rtmp_control_thread_t *p_thread = p_this; rtmp_packet_t *rtmp_packet; int canc = vlc_savecancel (); rtmp_init_handler( p_thread->rtmp_handler ); - while( vlc_object_alive (p_thread) ) + for( ;; ) { + vlc_restorecancel( canc ); rtmp_packet = rtmp_read_net_packet( p_thread ); + canc = vlc_savecancel( ); if( rtmp_packet != NULL ) { if( rtmp_packet->content_type < 0x01 /* RTMP_CONTENT_TYPE_CHUNK_SIZE */ @@ -403,14 +404,14 @@ static void* ThreadControl( vlc_object_t *p_this ) else { /* Sometimes server close connection too soon */ +#warning Locking bug here. if( p_thread->result_connect ) { vlc_mutex_lock( &p_thread->lock ); vlc_cond_signal( &p_thread->wait ); vlc_mutex_unlock( &p_thread->lock ); } - - p_thread->b_die = 1; + break; } } vlc_restorecancel (canc);