]> git.sesse.net Git - vlc/blobdiff - src/input/stream.c
fix --no-stats in a few cases (there are more remaining)
[vlc] / src / input / stream.c
index 26276f59ab4aa993401aefc507532d0f240b89d0..905248ff07ce7b5be7dcf844ae6722d37b2fac51 100644 (file)
@@ -18,7 +18,7 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 #include <stdlib.h>
@@ -1465,6 +1465,7 @@ char * stream_ReadLine( stream_t *s )
             /* Open the converter if we need it */
             if( psz_encoding != NULL )
             {
+                input_thread_t *p_input;
                 msg_Dbg( s, "%s BOM detected", psz_encoding );
                 if( s->i_char_width > 1 )
                 {
@@ -1473,6 +1474,15 @@ char * stream_ReadLine( stream_t *s )
                     {
                         msg_Err( s, "iconv_open failed" );
                     }
+                    var_Create( s->p_parent->p_parent, "subsdec-encoding", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
+                    var_SetString( s->p_parent->p_parent, "subsdec-encoding", "UTF-8" );
+                }
+                p_input = (input_thread_t *)vlc_object_find( s, VLC_OBJECT_INPUT, FIND_PARENT );
+                if( p_input != NULL)
+                {
+                    var_Create( p_input, "subsdec-encoding", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
+                    var_SetString( p_input, "subsdec-encoding", "UTF-8" );
+                    vlc_object_release( p_input );
                 }
                 if( psz_encoding ) free( psz_encoding );
             }
@@ -1565,10 +1575,17 @@ static int AReadStream( stream_t *s, void *p_read, int i_read )
     stream_sys_t *p_sys = s->p_sys;
     access_t *p_access = p_sys->p_access;
     int i_read_orig = i_read;
+    int i_total;
 
     if( !p_sys->i_list )
     {
         i_read = p_access->pf_read( p_access, p_read, i_read );
+        stats_UpdateInteger( s->p_parent->p_parent , "read_bytes", i_read );
+        stats_GetInteger( s, s->p_parent->p_parent->i_object_id,
+                          "read_bytes", &i_total );
+        stats_UpdateFloat( s->p_parent->p_parent , "input_bitrate",
+                          (float)i_total );
+        stats_UpdateInteger( s->p_parent->p_parent , "read_packets", 1 );
         return i_read;
     }
 
@@ -1596,6 +1613,13 @@ static int AReadStream( stream_t *s, void *p_read, int i_read )
         return AReadStream( s, p_read, i_read_orig );
     }
 
+    /* Update read bytes in input */
+    stats_UpdateInteger( s->p_parent->p_parent , "read_bytes", i_read );
+    stats_GetInteger( s, s->p_parent->p_parent->i_object_id,
+                      "read_bytes", &i_total );
+    stats_UpdateFloat( s->p_parent->p_parent , "input_bitrate",
+                      (float)i_total );
+    stats_UpdateInteger( s->p_parent->p_parent , "read_packets", 1 );
     return i_read;
 }
 
@@ -1605,11 +1629,22 @@ static block_t *AReadBlock( stream_t *s, vlc_bool_t *pb_eof )
     access_t *p_access = p_sys->p_access;
     block_t *p_block;
     vlc_bool_t b_eof;
+    int i_total;
 
     if( !p_sys->i_list )
     {
         p_block = p_access->pf_block( p_access );
         if( pb_eof ) *pb_eof = p_access->info.b_eof;
+        if( p_block && p_access->p_libvlc->b_stats )
+        {
+            stats_UpdateInteger( s->p_parent->p_parent, "read_bytes",
+                                 p_block->i_buffer );
+            stats_GetInteger( s, s->p_parent->p_parent->i_object_id,
+                              "read_bytes", &i_total );
+            stats_UpdateFloat( s->p_parent->p_parent , "input_bitrate",
+                              (float)i_total );
+            stats_UpdateInteger( s->p_parent->p_parent , "read_packets", 1 );
+        }
         return p_block;
     }
 
@@ -1637,6 +1672,16 @@ static block_t *AReadBlock( stream_t *s, vlc_bool_t *pb_eof )
         /* We have to read some data */
         return AReadBlock( s, pb_eof );
     }
+    if( p_block )
+    {
+        stats_UpdateInteger( s->p_parent->p_parent, "read_bytes",
+                             p_block->i_buffer );
+        stats_GetInteger( s, s->p_parent->p_parent->i_object_id,
+                          "read_bytes", &i_total );
+        stats_UpdateFloat( s->p_parent->p_parent , "input_bitrate",
+                          (float)i_total );
+        stats_UpdateInteger( s->p_parent->p_parent , "read_packets", 1 );
+    }
 
     return p_block;
 }