]> git.sesse.net Git - vlc/blobdiff - modules/access_output/rtmp.c
Trailing ;
[vlc] / modules / access_output / rtmp.c
index 08a9387a6688b06b892f056269909e3e2f95d57d..0b464581010688cfab93486c8dfb3ed453bf0f79 100644 (file)
@@ -51,24 +51,24 @@ static void Close( vlc_object_t * );
 
 #define SOUT_CFG_PREFIX "sout-rtmp-"
 
-vlc_module_begin();
-    set_description( N_("RTMP stream output") );
-    set_shortname( N_("RTMP" ) );
-    set_capability( "sout access", 50 );
-    set_category( CAT_SOUT );
-    set_subcategory( SUBCAT_SOUT_STREAM );
-    add_shortcut( "rtmp" );
-    set_callbacks( Open, Close );
+vlc_module_begin ()
+    set_description( N_("RTMP stream output") )
+    set_shortname( N_("RTMP" ) )
+    set_capability( "sout access", 50 )
+    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 );
-vlc_module_end();
+              RTMP_CONNECT_LONGTEXT, false )
+vlc_module_end ()
 
 /*****************************************************************************
  * Local prototypes
  *****************************************************************************/
 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( vlc_object_t * );
 
 struct sout_access_out_sys_t
 {
@@ -90,19 +90,13 @@ static int Open( vlc_object_t *p_this )
     int i;
 
     if( !( p_sys = calloc ( 1, sizeof( sout_access_out_sys_t ) ) ) )
-    {
-        msg_Err( p_access, "not enough memory" );
         return VLC_ENOMEM;
-    }
     p_access->p_sys = p_sys;
 
     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 */
@@ -129,7 +123,10 @@ static int Open( vlc_object_t *p_this )
     }
 
     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 ) );
@@ -173,7 +170,7 @@ static int Open( vlc_object_t *p_this )
         p_sys->p_thread->rtmp_headers_send[i].body = NULL;
     }
 
-    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 );
 
     p_sys->p_thread->result_connect = 1;
@@ -221,7 +218,7 @@ 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 ) )
+                           VLC_THREAD_PRIORITY_INPUT ) )
     {
         msg_Err( p_access, "cannot spawn rtmp control thread" );
         goto error2;
@@ -272,7 +269,6 @@ static void Close( vlc_object_t * p_this )
 //    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 );
 
@@ -334,7 +330,8 @@ p_buffer->p_buffer[i], p_buffer->p_buffer[i+1], p_buffer->p_buffer[i+2], p_buffe
 p_buffer->p_buffer[i+8], p_buffer->p_buffer[i+9], p_buffer->p_buffer[i+10], p_buffer->p_buffer[i+11], p_buffer->p_buffer[i+12], p_buffer->p_buffer[i+13], p_buffer->p_buffer[i+14], p_buffer->p_buffer[i+15]);
 }*/
 ////////////////////////
-msg_Warn(p_access, "rtmp.c:360 i_dts %d i_pts %d", p_buffer->i_dts, p_buffer->i_pts);
+        msg_Warn(p_access, "rtmp.c:360 i_dts %"PRIu64" i_pts %"PRIu64,
+                 p_buffer->i_dts, p_buffer->i_pts);
         rtmp_packet = rtmp_build_flv_over_rtmp( p_access->p_sys->p_thread, p_buffer );
 
         if( rtmp_packet )
@@ -370,6 +367,7 @@ msg_Warn(p_access, "rtmp.c:360 i_dts %d i_pts %d", p_buffer->i_dts, p_buffer->i_
  *****************************************************************************/
 static int Seek( sout_access_out_t *p_access, off_t i_pos )
 {
+    (void)i_pos;
     msg_Err( p_access, "RTMP sout access cannot seek" );
     return -1;
 }
@@ -377,14 +375,15 @@ 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( 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 )
@@ -414,4 +413,6 @@ static void ThreadControl( vlc_object_t *p_this )
             p_thread->b_die = 1;
         }
     }
+    vlc_restorecancel (canc);
+    return NULL;
 }