]> git.sesse.net Git - vlc/blobdiff - modules/access_output/shout.c
fix addition of multiple meta pairs adding the first one repeatedly
[vlc] / modules / access_output / shout.c
index 58171afbcfa3435de32938c10a7de14fdea24c18..f2e2e67c7f1bfb885ebc7d976ccd0f16e3d21c90 100644 (file)
@@ -106,36 +106,36 @@ static void Close( vlc_object_t * );
                            "website. Requires the bitrate information specified for " \
                            "shoutcast. Requires Ogg streaming for icecast." )
 
-vlc_module_begin();
-    set_description( N_("IceCAST output") );
-    set_shortname( "Shoutcast" );
-    set_capability( "sout access", 50 );
-    set_category( CAT_SOUT );
-    set_subcategory( SUBCAT_SOUT_ACO );
-    add_shortcut( "shout" );
+vlc_module_begin ()
+    set_description( N_("IceCAST output") )
+    set_shortname( "Shoutcast" )
+    set_capability( "sout access", 50 )
+    set_category( CAT_SOUT )
+    set_subcategory( SUBCAT_SOUT_ACO )
+    add_shortcut( "shout" )
     add_string( SOUT_CFG_PREFIX "name", "VLC media player - Live stream", NULL,
-                NAME_TEXT, NAME_LONGTEXT, false );
+                NAME_TEXT, NAME_LONGTEXT, false )
     add_string( SOUT_CFG_PREFIX "description",
                  "Live stream from VLC media player", NULL,
-                DESCRIPTION_TEXT, DESCRIPTION_LONGTEXT, false );
+                DESCRIPTION_TEXT, DESCRIPTION_LONGTEXT, false )
     add_bool(   SOUT_CFG_PREFIX "mp3", false, NULL,
-                MP3_TEXT, MP3_LONGTEXT, true );
+                MP3_TEXT, MP3_LONGTEXT, true )
     add_string( SOUT_CFG_PREFIX "genre", "Alternative", NULL,
-                GENRE_TEXT, GENRE_LONGTEXT, false );
+                GENRE_TEXT, GENRE_LONGTEXT, false )
     add_string( SOUT_CFG_PREFIX "url", "http://www.videolan.org/vlc", NULL,
-                URL_TEXT, URL_LONGTEXT, false );
+                URL_TEXT, URL_LONGTEXT, false )
     add_string( SOUT_CFG_PREFIX "bitrate", "", NULL,
-                BITRATE_TEXT, BITRATE_LONGTEXT, false );
+                BITRATE_TEXT, BITRATE_LONGTEXT, false )
     add_string( SOUT_CFG_PREFIX "samplerate", "", NULL,
-                SAMPLERATE_TEXT, SAMPLERATE_LONGTEXT, false );
+                SAMPLERATE_TEXT, SAMPLERATE_LONGTEXT, false )
     add_string( SOUT_CFG_PREFIX "channels", "", NULL,
-                CHANNELS_TEXT, CHANNELS_LONGTEXT, false );
+                CHANNELS_TEXT, CHANNELS_LONGTEXT, false )
     add_string( SOUT_CFG_PREFIX "quality", "", NULL,
-                QUALITY_TEXT, QUALITY_LONGTEXT, false );
+                QUALITY_TEXT, QUALITY_LONGTEXT, false )
     add_bool(   SOUT_CFG_PREFIX "public", false, NULL,
-                PUBLIC_TEXT, PUBLIC_LONGTEXT, true );
-    set_callbacks( Open, Close );
-vlc_module_end();
+                PUBLIC_TEXT, PUBLIC_LONGTEXT, true )
+    set_callbacks( Open, Close )
+vlc_module_end ()
 
 /*****************************************************************************
  * Exported prototypes
@@ -151,6 +151,7 @@ static const char *const ppsz_sout_options[] = {
  *****************************************************************************/
 static ssize_t Write( sout_access_out_t *, block_t * );
 static int Seek ( sout_access_out_t *, off_t  );
+static int Control( sout_access_out_t *, int, va_list );
 
 struct sout_access_out_sys_t
 {
@@ -183,10 +184,6 @@ static int Open( vlc_object_t *p_this )
 
     config_ChainParse( p_access, SOUT_CFG_PREFIX, ppsz_sout_options, p_access->p_cfg );
 
-    psz_accessname = psz_parser = strdup( p_access->psz_path );
-    if( !psz_parser )
-        return VLC_ENOMEM;
-
     if( !p_access->psz_path )
     {
         msg_Err( p_access,
@@ -194,6 +191,10 @@ static int Open( vlc_object_t *p_this )
         return VLC_EGENERIC;
     }
 
+    psz_accessname = psz_parser = strdup( p_access->psz_path );
+    if( !psz_parser )
+        return VLC_ENOMEM;
+
     /* Parse connection data user:pwd@host:port/mountpoint */
     psz_user = psz_parser;
     while( psz_parser[0] && psz_parser[0] != ':' ) psz_parser++;
@@ -262,6 +263,10 @@ static int Open( vlc_object_t *p_this )
                  psz_host, i_port, psz_mount );
         free( p_access->p_sys );
         free( psz_accessname );
+        free( psz_name );
+        free( psz_description );
+        free( psz_genre );
+        free( psz_url );
         return VLC_EGENERIC;
     }
 
@@ -293,6 +298,7 @@ static int Open( vlc_object_t *p_this )
         if( i_ret != SHOUTERR_SUCCESS )
         {
             msg_Err( p_access, "failed to set the information about the bitrate" );
+            free( val.psz_string );
             free( p_access->p_sys );
             free( psz_accessname );
             return VLC_EGENERIC;
@@ -318,6 +324,7 @@ static int Open( vlc_object_t *p_this )
         if( i_ret != SHOUTERR_SUCCESS )
         {
             msg_Err( p_access, "failed to set the information about the samplerate" );
+            free( val.psz_string );
             free( p_access->p_sys );
             free( psz_accessname );
             return VLC_EGENERIC;
@@ -333,6 +340,7 @@ static int Open( vlc_object_t *p_this )
         if( i_ret != SHOUTERR_SUCCESS )
         {
             msg_Err( p_access, "failed to set the information about the number of channels" );
+            free( val.psz_string );
             free( p_access->p_sys );
             free( psz_accessname );
             return VLC_EGENERIC;
@@ -348,6 +356,7 @@ static int Open( vlc_object_t *p_this )
         if( i_ret != SHOUTERR_SUCCESS )
         {
             msg_Err( p_access, "failed to set the information about Ogg Vorbis quality" );
+            free( val.psz_string );
             free( p_access->p_sys );
             free( psz_accessname );
             return VLC_EGENERIC;
@@ -451,16 +460,10 @@ static int Open( vlc_object_t *p_this )
 
     p_access->pf_write = Write;
     p_access->pf_seek  = Seek;
+    p_access->pf_control = Control;
 
     msg_Dbg( p_access, "shout access output opened (%s@%s:%i/%s)",
              psz_user, psz_host, i_port, psz_mount );
-
-    /* Update pace control flag */
-    if( p_access->psz_access && !strcmp( p_access->psz_access, "stream" ) )
-    {
-        p_access->p_sout->i_out_pace_nocontrol++;
-    }
-
     free( psz_accessname );
 
     return VLC_SUCCESS;
@@ -479,14 +482,24 @@ static void Close( vlc_object_t * p_this )
         shout_shutdown();
     }
     free( p_access->p_sys );
+    msg_Dbg( p_access, "shout access output closed" );
+}
 
-    /* Update pace control flag */
-    if( p_access->psz_access && !strcmp( p_access->psz_access, "stream" ) )
+static int Control( sout_access_out_t *p_access, int i_query, va_list args )
+{
+    switch( i_query )
     {
-        p_access->p_sout->i_out_pace_nocontrol--;
-    }
+        case ACCESS_OUT_CONTROLS_PACE:
+        {
+            bool *pb = va_arg( args, bool * );
+            *pb = strcmp( p_access->psz_access, "stream" );
+            break;
+        }
 
-    msg_Dbg( p_access, "shout access output closed" );
+        default:
+            return VLC_EGENERIC;
+    }
+    return VLC_SUCCESS;
 }
 
 /*****************************************************************************
@@ -527,6 +540,8 @@ static ssize_t Write( sout_access_out_t *p_access, block_t *p_buffer )
             else
             {
                 msg_Err( p_access, "failed to reconnect to server" );
+                block_ChainRelease (p_buffer);
+                return VLC_EGENERIC;
             }
 
         }