]> git.sesse.net Git - vlc/blobdiff - modules/control/http/http.c
Control interfaces first string review.
[vlc] / modules / control / http / http.c
index d2a6276550a7976dadd0cd5364190e377b71ce73..255ca0da327a40ab06bf2a9abfbcd7529090643d 100644 (file)
@@ -33,16 +33,16 @@ static void Close( vlc_object_t * );
 
 #define HOST_TEXT N_( "Host address" )
 #define HOST_LONGTEXT N_( \
-    "You can set the address and port the http interface will bind to." )
+    "Address and port the http interface will bind to" )
 #define SRC_TEXT N_( "Source directory" )
 #define SRC_LONGTEXT N_( "Source directory" )
 #define CHARSET_TEXT N_( "Charset" )
 #define CHARSET_LONGTEXT N_( \
-        "Charset declared in Content-Type header (default UTF-8)." )
+        "Charset declared in Content-Type header (default UTF-8)" )
 #define HANDLERS_TEXT N_( "Handlers" )
 #define HANDLERS_LONGTEXT N_( \
-        "List of extensions and executable paths (for instance: " \
-        "php=/usr/bin/php,pl=/usr/bin/perl)." )
+        "List of handler extensions and executable paths (for instance: " \
+        "php=/usr/bin/php,pl=/usr/bin/perl)" )
 #define CERT_TEXT N_( "Certificate file" )
 #define CERT_LONGTEXT N_( "HTTP interface x509 PEM certificate file " \
                           "(enables SSL)" )
@@ -58,7 +58,7 @@ vlc_module_begin();
     set_shortname( _("HTTP"));
     set_description( _("HTTP remote control interface") );
     set_category( CAT_INTERFACE );
-    set_subcategory( SUBCAT_INTERFACE_GENERAL );
+    set_subcategory( SUBCAT_INTERFACE_MAIN );
         add_string ( "http-host", NULL, NULL, HOST_TEXT, HOST_LONGTEXT, VLC_TRUE );
         add_string ( "http-src",  NULL, NULL, SRC_TEXT,  SRC_LONGTEXT,  VLC_TRUE );
         add_string ( "http-charset", "UTF-8", NULL, CHARSET_TEXT, CHARSET_LONGTEXT, VLC_TRUE );
@@ -167,10 +167,13 @@ static int Open( vlc_object_t *p_this )
 
     if( strcmp( psz_src, "UTF-8" ) )
     {
-        p_sys->iconv_from_utf8 = vlc_iconv_open( psz_src, "UTF-8" );
+        char psz_encoding[strlen( psz_src ) + sizeof( "//translit")];
+        sprintf( psz_encoding, "%s//translit", psz_src);
+
+        p_sys->iconv_from_utf8 = vlc_iconv_open( psz_encoding, "UTF-8" );
         if( p_sys->iconv_from_utf8 == (vlc_iconv_t)-1 )
             msg_Warn( p_intf, "unable to perform charset conversion to %s",
-                      psz_src );
+                      psz_encoding );
         else
         {
             p_sys->iconv_to_utf8 = vlc_iconv_open( "UTF-8", psz_src );
@@ -185,7 +188,7 @@ static int Open( vlc_object_t *p_this )
         p_sys->iconv_from_utf8 = p_sys->iconv_to_utf8 = (vlc_iconv_t)-1;
     }
 
-    p_sys->psz_charset = strdup( psz_src );
+    p_sys->psz_charset = psz_src;
     psz_src = NULL;
 
     /* determine file handler associations */
@@ -302,7 +305,7 @@ static int Open( vlc_object_t *p_this )
 
     if( !psz_src || *psz_src == '\0' )
     {
-        msg_Err( p_intf, "invalid src dir" );
+        msg_Err( p_intf, "invalid web interface source directory" );
         goto failed;
     }
 
@@ -318,7 +321,7 @@ static int Open( vlc_object_t *p_this )
 
     if( p_sys->i_files <= 0 )
     {
-        msg_Err( p_intf, "cannot find any files (%s)", psz_src );
+        msg_Err( p_intf, "cannot find any file in directory %s", psz_src );
         goto failed;
     }
     p_intf->pf_run = Run;
@@ -486,6 +489,7 @@ static void ParseExecute( httpd_file_sys_t *p_args, char *p_buffer,
     audio_volume_t i_volume;
     char volume[5];
     char state[8];
+    char stats[20];
 
 #define p_sys p_args->p_intf->p_sys
     if( p_sys->p_input )
@@ -545,6 +549,38 @@ static void ParseExecute( httpd_file_sys_t *p_args, char *p_buffer,
     E_(mvar_AppendNewVar)( p_args->vars, "stream_state", state );
     E_(mvar_AppendNewVar)( p_args->vars, "charset", ((intf_sys_t *)p_args->p_intf->p_sys)->psz_charset );
 
+    /* Stats */
+#define p_sys p_args->p_intf->p_sys
+    if( p_sys->p_input )
+    {
+        input_item_t *p_item = p_sys->p_input->input.p_item;
+        if( p_item )
+        {
+            vlc_mutex_lock( &p_item->p_stats->lock );
+#define STATS_INT( n ) sprintf( stats, "%d", p_item->p_stats->i_ ## n ); \
+                       E_(mvar_AppendNewVar)( p_args->vars, #n, stats );
+#define STATS_FLOAT( n ) sprintf( stats, "%f", p_item->p_stats->f_ ## n ); \
+                       E_(mvar_AppendNewVar)( p_args->vars, #n, stats );
+            STATS_INT( read_bytes )
+            STATS_FLOAT( input_bitrate )
+            STATS_INT( demux_read_bytes )
+            STATS_FLOAT( demux_bitrate )
+            STATS_INT( decoded_video )
+            STATS_INT( displayed_pictures )
+            STATS_INT( lost_pictures )
+            STATS_INT( decoded_audio )
+            STATS_INT( played_abuffers )
+            STATS_INT( lost_abuffers )
+            STATS_INT( sent_packets )
+            STATS_INT( sent_bytes )
+            STATS_FLOAT( send_bitrate )
+#undef STATS_INT
+#undef STATS_FLOAT
+            vlc_mutex_unlock( &p_item->p_stats->lock );
+        }
+    }
+#undef p_sys
+
     E_(SSInit)( &p_args->stack );
 
     /* allocate output */