]> git.sesse.net Git - vlc/blobdiff - modules/misc/rtsp.c
Remove unused parameter
[vlc] / modules / misc / rtsp.c
index 561e110cae0a647b6a087abcd47642e3bfef78f6..164021e0dd3da75cac6771ca7c698c94d3ce2f44 100644 (file)
@@ -79,22 +79,22 @@ static void Close( vlc_object_t * );
     "the timeout option entirely. This is needed by some IPTV STBs (such as " \
     "those made by HansunTech) which get confused by it. The default is 5." )
 
-vlc_module_begin();
-    set_shortname( N_("RTSP VoD" ) );
-    set_description( N_("RTSP VoD server") );
-    set_category( CAT_SOUT );
-    set_subcategory( SUBCAT_SOUT_VOD );
-    set_capability( "vod server", 1 );
-    set_callbacks( Open, Close );
-    add_shortcut( "rtsp" );
-    add_string ( "rtsp-host", NULL, NULL, HOST_TEXT, HOST_LONGTEXT, true );
+vlc_module_begin ()
+    set_shortname( N_("RTSP VoD" ) )
+    set_description( N_("RTSP VoD server") )
+    set_category( CAT_SOUT )
+    set_subcategory( SUBCAT_SOUT_VOD )
+    set_capability( "vod server", 1 )
+    set_callbacks( Open, Close )
+    add_shortcut( "rtsp" )
+    add_string ( "rtsp-host", NULL, NULL, HOST_TEXT, HOST_LONGTEXT, true )
     add_string( "rtsp-raw-mux", "ts", NULL, RAWMUX_TEXT,
                 RAWMUX_TEXT, true );
     add_integer( "rtsp-throttle-users", 0, NULL, THROTLE_TEXT,
                                            THROTLE_LONGTEXT, true );
     add_integer( "rtsp-session-timeout", 5, NULL, SESSION_TIMEOUT_TEXT,
                  SESSION_TIMEOUT_LONGTEXT, true );
-vlc_module_end();
+vlc_module_end ()
 
 /*****************************************************************************
  * Exported prototypes
@@ -260,8 +260,8 @@ static void sprintf_hexa( char *s, uint8_t *p_data, int i_data )
 static int Open( vlc_object_t *p_this )
 {
     vod_t *p_vod = (vod_t *)p_this;
-    vod_sys_t *p_sys = 0;
-    char *psz_url = 0;
+    vod_sys_t *p_sys = NULL;
+    char *psz_url = NULL;
     vlc_url_t url;
 
     psz_url = config_GetPsz( p_vod, "rtsp-host" );
@@ -308,7 +308,7 @@ static int Open( vlc_object_t *p_this )
 
     p_sys->p_fifo_cmd = block_FifoNew();
     if( vlc_thread_create( p_vod, "rtsp vod thread", CommandThread,
-                           VLC_THREAD_PRIORITY_LOW, false ) )
+                           VLC_THREAD_PRIORITY_LOW ) )
     {
         msg_Err( p_vod, "cannot spawn rtsp vod thread" );
         block_FifoRelease( p_sys->p_fifo_cmd );
@@ -368,17 +368,16 @@ static void Close( vlc_object_t * p_this )
 static vod_media_t *MediaNew( vod_t *p_vod, const char *psz_name,
                               input_item_t *p_item )
 {
-    vod_sys_t *p_sys = p_vod->p_sys;
-    vod_media_t *p_media = malloc( sizeof(vod_media_t) );
     int i;
+    vod_sys_t *p_sys = p_vod->p_sys;
 
+    vod_media_t *p_media = calloc( 1, sizeof(vod_media_t) );
     if( !p_media )
         return NULL;
 
-    memset( p_media, 0, sizeof(vod_media_t) );
     p_media->id = p_sys->i_media_id++;
     TAB_INIT( p_media->i_es, p_media->es );
-    p_media->psz_mux = 0;
+    p_media->psz_mux = NULL;
     TAB_INIT( p_media->i_rtsp, p_media->rtsp );
     p_media->b_raw = false;
 
@@ -498,11 +497,10 @@ static void MediaDel( vod_t *p_vod, vod_media_t *p_media )
 
 static int MediaAddES( vod_t *p_vod, vod_media_t *p_media, es_format_t *p_fmt )
 {
-    media_es_t *p_es = malloc( sizeof(media_es_t) );
     char *psz_urlc;
-
-    if( !p_es ) return VLC_ENOMEM;
-    memset( p_es, 0, sizeof(media_es_t) );
+    media_es_t *p_es = calloc( 1, sizeof(media_es_t) );
+    if( !p_es )
+        return VLC_ENOMEM;
 
     free( p_media->psz_mux );
     p_media->psz_mux = NULL;
@@ -593,11 +591,13 @@ static int MediaAddES( vod_t *p_vod, vod_media_t *p_media, es_format_t *p_fmt )
                     }
                     if( i_nal_type == 7 )
                     {
+                        free( p_64_sps );
                         p_64_sps = vlc_b64_encode_binary( &p_buffer[4], i_size - 4 );
                         sprintf_hexa( hexa, &p_buffer[5], 3 );
                     }
                     else if( i_nal_type == 8 )
                     {
+                        free( p_64_pps );
                         p_64_pps = vlc_b64_encode_binary( &p_buffer[4], i_size - 4 );
                     }
                     i_buffer -= i_size;
@@ -816,6 +816,7 @@ static void* CommandThread( vlc_object_t *p_this )
 {
     vod_t *p_vod = (vod_t*)p_this;
     vod_sys_t *p_sys = p_vod->p_sys;
+    int canc = vlc_savecancel ();
 
     while( vlc_object_alive (p_vod) )
     {
@@ -883,6 +884,8 @@ static void* CommandThread( vlc_object_t *p_this )
         free( cmd.psz_session );
         free( cmd.psz_arg );
     }
+
+    vlc_restorecancel (canc);
     return NULL;
 }
 
@@ -891,10 +894,10 @@ static void* CommandThread( vlc_object_t *p_this )
  ****************************************************************************/
 static rtsp_client_t *RtspClientNew( vod_media_t *p_media, char *psz_session )
 {
-    rtsp_client_t *p_rtsp = malloc( sizeof(rtsp_client_t) );
+    rtsp_client_t *p_rtsp = calloc( 1, sizeof(rtsp_client_t) );
 
-    if( !p_rtsp ) return NULL;
-    memset( p_rtsp, 0, sizeof(rtsp_client_t) );
+    if( !p_rtsp )
+        return NULL;
     p_rtsp->es = 0;
 
     p_rtsp->psz_session = psz_session;
@@ -926,12 +929,13 @@ static void RtspClientDel( vod_media_t *p_media, rtsp_client_t *p_rtsp )
     msg_Dbg( p_media->p_vod, "closing session: %s, connections: %d",
              p_rtsp->psz_session, p_media->p_vod->p_sys->i_throttle_users );
 
-    while( p_rtsp->i_es-- )
+    while( p_rtsp->i_es )
     {
+        p_rtsp->i_es--;
         free( p_rtsp->es[p_rtsp->i_es]->psz_ip );
         free( p_rtsp->es[p_rtsp->i_es] );
-        if( !p_rtsp->i_es ) free( p_rtsp->es );
     }
+    free( p_rtsp->es );
 
     TAB_REMOVE( p_media->i_rtsp, p_media->rtsp, p_rtsp );