Changeset e7d9e5601fe3603405749091d0eef49630ac7ee8

Show
Ignore:
Timestamp:
21/10/07 01:22:48 (1 year ago)
Author:
Laurent Aimar <fenrir@videolan.org>
git-committer:
Laurent Aimar <fenrir@videolan.org> 1192922568 +0000
git-parent:

[9b62d7452507c8cbdd6c83fb137da9b6a0e3016d]

git-author:
Laurent Aimar <fenrir@videolan.org> 1192922568 +0000
Message:

Added sout_UpdateStatistic and fixed transcode module to use it.
As a side effect, it fixed a potential segfault (race condition) when using

sout-keep (but I am not sure if we have a stream_out module that can show the
problem)

sout_UpdateStatistic still uses input internal data and that need to

be fixed. Audio output need such a clean too.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • include/vlc_sout.h

    r8da8aa9 re7d9e56  
    5858    sout_instance_sys_t *p_sys; 
    5959}; 
     60 
     61/** Stream output statistics */ 
     62typedef enum 
     63{ 
     64    SOUT_STATISTIC_DECODED_VIDEO, 
     65    SOUT_STATISTIC_DECODED_AUDIO, 
     66    SOUT_STATISTIC_DECODED_SUBTITLE, 
     67 
     68    /* Use them only if you do not goes through a access_out module */ 
     69    SOUT_STATISTIC_SENT_PACKET, 
     70    SOUT_STATISTIC_SENT_BYTE, 
     71 
     72} sout_statistic_t; 
     73 
     74VLC_EXPORT( void, sout_UpdateStatistic, ( sout_instance_t *p_sout, sout_statistic_t, int ) ); 
    6075 
    6176/**************************************************************************** 
  • modules/stream_out/transcode.c

    r646e343 re7d9e56  
    4040 
    4141#define MASTER_SYNC_MAX_DRIFT 100000 
    42  
    43 /* FIXME Ugly, needed for (disabled) stats updates  */ 
    44 #if 0 
    45 #include "../../src/input/input_internal.h" 
    46 #endif 
    4742 
    4843/***************************************************************************** 
     
    13201315    id->p_decoder->fmt_out.i_extra = 0; 
    13211316    id->p_decoder->fmt_out.p_extra = 0; 
    1322     id->p_decoder->pf_decode_audio = 0
     1317    id->p_decoder->pf_decode_audio = NULL
    13231318    id->p_decoder->pf_aout_buffer_new = audio_new_buffer; 
    13241319    id->p_decoder->pf_aout_buffer_del = audio_del_buffer; 
     
    15521547    int i; 
    15531548    *out = NULL; 
    1554     input_thread_t *p_input = NULL; 
    1555  
    1556     if( p_stream->p_parent->p_parent && p_stream->p_parent->p_parent-> 
    1557                                 i_object_type == VLC_OBJECT_INPUT ) 
    1558         p_input = (input_thread_t *)p_stream->p_parent->p_parent; 
    15591549 
    15601550    while( (p_audio_buf = id->p_decoder->pf_decode_audio( id->p_decoder, 
    15611551                                                          &in )) ) 
    15621552    { 
    1563 #warning Stats not implemented! 
    1564 #if 0 
    1565         if( p_input ) 
    1566             stats_UpdateInteger( p_input, p_input->p->counters.p_decoded_audio, 
    1567                                  1, NULL ); 
    1568 #endif 
     1553        sout_UpdateStatistic( p_stream->p_sout, SOUT_STATISTIC_DECODED_AUDIO, 1 ); 
    15691554        if( p_sys->b_master_sync ) 
    15701555        { 
     
    16841669    id->p_decoder->fmt_out.i_extra = 0; 
    16851670    id->p_decoder->fmt_out.p_extra = 0; 
    1686     id->p_decoder->pf_decode_video = 0; 
     1671    id->p_decoder->pf_decode_video = NULL; 
     1672    id->p_decoder->pf_get_cc = NULL; 
    16871673    id->p_decoder->pf_get_cc = 0; 
    16881674    id->p_decoder->pf_vout_buffer_new = video_new_buffer_decoder; 
     
    21562142    picture_t *p_pic, *p_pic2 = NULL; 
    21572143    *out = NULL; 
    2158     input_thread_t *p_input = NULL; 
    2159  
    2160     if( p_stream->p_parent->p_parent && p_stream->p_parent->p_parent-> 
    2161                                 i_object_type == VLC_OBJECT_INPUT ) 
    2162         p_input = (input_thread_t *)p_stream->p_parent->p_parent; 
    21632144 
    21642145    while( (p_pic = id->p_decoder->pf_decode_video( id->p_decoder, &in )) ) 
    21652146    { 
    21662147        subpicture_t *p_subpic = NULL; 
    2167 #warning Stats not implemented! 
    2168 #if 0 
    2169         if( p_input ) 
    2170             stats_UpdateInteger( p_input, p_input->p->counters.p_decoded_video, 
    2171                                  1, NULL ); 
    2172 #endif 
     2148 
     2149        sout_UpdateStatistic( p_stream->p_sout, SOUT_STATISTIC_DECODED_VIDEO, 1 ); 
    21732150 
    21742151        if( p_stream->p_sout->i_out_pace_nocontrol && p_sys->b_hurry_up ) 
     
    27092686 
    27102687    /* Initialization of decoder structures */ 
     2688    id->p_decoder->pf_decode_sub = NULL; 
    27112689    id->p_decoder->pf_spu_buffer_new = spu_new_buffer; 
    27122690    id->p_decoder->pf_spu_buffer_del = spu_del_buffer; 
     
    27722750 
    27732751    p_subpic = id->p_decoder->pf_decode_sub( id->p_decoder, &in ); 
    2774     if( !p_subpic ) return VLC_EGENERIC; 
     2752    if( !p_subpic ) 
     2753        return VLC_EGENERIC; 
     2754 
     2755    sout_UpdateStatistic( p_stream->p_sout, SOUT_STATISTIC_DECODED_SUBTITLE, 1 ); 
    27752756 
    27762757    if( p_sys->b_master_sync && p_sys->i_master_drift ) 
  • src/stream_output/stream_output.c

    rc4d19b8 re7d9e56  
    149149 
    150150/***************************************************************************** 
     151 *  
     152 *****************************************************************************/ 
     153void sout_UpdateStatistic( sout_instance_t *p_sout, sout_statistic_t i_type, int i_delta ) 
     154{ 
     155    input_thread_t *p_input; 
     156    int i_bytes; /* That's pretty stupid to define it as an integer, it will overflow 
     157                    really fast ... */ 
     158 
     159    if( !p_sout->p_libvlc->b_stats ) 
     160        return; 
     161 
     162    /* FIXME that's ugly 
     163     * TODO add a private (ie not VLC_EXPORTed) input_UpdateStatistic for that */ 
     164    p_input = vlc_object_find( p_sout, VLC_OBJECT_INPUT, FIND_PARENT ); 
     165    if( !p_input || p_input->i_state == INIT_S || p_input->i_state == ERROR_S ) 
     166        return; 
     167 
     168    switch( i_type ) 
     169    { 
     170#define I(c) stats_UpdateInteger( p_input, p_input->p->counters.c, i_delta, NULL ) 
     171    case SOUT_STATISTIC_DECODED_VIDEO: 
     172        I(p_decoded_video); 
     173        break; 
     174    case SOUT_STATISTIC_DECODED_AUDIO: 
     175        I(p_decoded_audio); 
     176        break; 
     177    case SOUT_STATISTIC_DECODED_SUBTITLE: 
     178        I(p_decoded_sub); 
     179        break; 
     180#if 0 
     181    case SOUT_STATISTIC_ENCODED_VIDEO: 
     182    case SOUT_STATISTIC_ENCODED_AUDIO: 
     183    case SOUT_STATISTIC_ENCODED_SUBTITLE: 
     184        msg_Warn( p_sout, "Not yet supported statistic type %d", i_type ); 
     185        break; 
     186#endif 
     187 
     188    case SOUT_STATISTIC_SENT_PACKET: 
     189        I(p_sout_sent_packets); 
     190        break; 
     191#undef I 
     192    case SOUT_STATISTIC_SENT_BYTE: 
     193        if( !stats_UpdateInteger( p_input, p_input->p->counters.p_sout_sent_bytes, i_delta, &i_bytes ) ) 
     194            stats_UpdateFloat( p_input, p_input->p->counters.p_sout_send_bitrate, i_bytes, NULL ); 
     195        break; 
     196 
     197    default: 
     198        msg_Err( p_sout, "Invalid statistic type %d (internal error)", i_type ); 
     199        break; 
     200    } 
     201    vlc_object_release( p_input ); 
     202} 
     203/***************************************************************************** 
    151204 * Packetizer/Input 
    152205 *****************************************************************************/ 
     
    324377int sout_AccessOutWrite( sout_access_out_t *p_access, block_t *p_buffer ) 
    325378{ 
    326     int i_total = 0; 
     379    const int i_packets_gather = 30; 
    327380    p_access->i_writes++; 
    328381    p_access->i_sent_bytes += p_buffer->i_buffer; 
    329     if( p_access->p_libvlc->b_stats && p_access->i_writes % 30 == 0 ) 
    330     { 
    331         /* Access_out -> sout_instance -> input_thread_t */ 
    332         input_thread_t *p_input = 
    333             (input_thread_t *)vlc_object_find( p_access, VLC_OBJECT_INPUT, 
    334                                                FIND_PARENT ); 
    335         if( p_input ) 
    336         { 
    337             stats_UpdateInteger( p_input, p_input->p->counters.p_sout_sent_packets, 
    338                      30, NULL ); 
    339             stats_UpdateInteger( p_input, p_input->p->counters.p_sout_sent_bytes, 
    340                                  p_access->i_sent_bytes, &i_total ); 
    341             stats_UpdateFloat( p_input, p_input->p->counters.p_sout_send_bitrate, 
    342                     (float)i_total, NULL ); 
    343             p_access->i_sent_bytes = 0; 
    344             vlc_object_release( p_input ); 
    345         } 
     382    if( (p_access->i_writes % i_packets_gather) == 0 ) 
     383    { 
     384        sout_UpdateStatistic( p_access->p_sout, SOUT_STATISTIC_SENT_PACKET, i_packets_gather ); 
     385        sout_UpdateStatistic( p_access->p_sout, SOUT_STATISTIC_SENT_BYTE, p_access->i_sent_bytes ); 
     386        p_access->i_sent_bytes = 0; 
    346387    } 
    347388    return p_access->pf_write( p_access, p_buffer );