+/*****************************************************************************
+ *
+ *****************************************************************************/
+void sout_UpdateStatistic( sout_instance_t *p_sout, sout_statistic_t i_type, int i_delta )
+{
+ input_thread_t *p_input;
+ int i_bytes; /* That's pretty stupid to define it as an integer, it will overflow
+ really fast ... */
+
+ if( !p_sout->p_libvlc->b_stats )
+ return;
+
+ /* FIXME that's ugly
+ * TODO add a private (ie not VLC_EXPORTed) input_UpdateStatistic for that */
+ p_input = vlc_object_find( p_sout, VLC_OBJECT_INPUT, FIND_PARENT );
+ if( !p_input || p_input->i_state == INIT_S || p_input->i_state == ERROR_S )
+ return;
+
+ switch( i_type )
+ {
+#define I(c) stats_UpdateInteger( p_input, p_input->p->counters.c, i_delta, NULL )
+ case SOUT_STATISTIC_DECODED_VIDEO:
+ I(p_decoded_video);
+ break;
+ case SOUT_STATISTIC_DECODED_AUDIO:
+ I(p_decoded_audio);
+ break;
+ case SOUT_STATISTIC_DECODED_SUBTITLE:
+ I(p_decoded_sub);
+ break;
+#if 0
+ case SOUT_STATISTIC_ENCODED_VIDEO:
+ case SOUT_STATISTIC_ENCODED_AUDIO:
+ case SOUT_STATISTIC_ENCODED_SUBTITLE:
+ msg_Warn( p_sout, "Not yet supported statistic type %d", i_type );
+ break;
+#endif
+
+ case SOUT_STATISTIC_SENT_PACKET:
+ I(p_sout_sent_packets);
+ break;
+#undef I
+ case SOUT_STATISTIC_SENT_BYTE:
+ if( !stats_UpdateInteger( p_input, p_input->p->counters.p_sout_sent_bytes, i_delta, &i_bytes ) )
+ stats_UpdateFloat( p_input, p_input->p->counters.p_sout_send_bitrate, i_bytes, NULL );
+ break;
+
+ default:
+ msg_Err( p_sout, "Invalid statistic type %d (internal error)", i_type );
+ break;
+ }
+ vlc_object_release( p_input );
+}