Changeset 226344134ee28d50d5e29d19f5b7ffe4b4df40fd

Show
Ignore:
Timestamp:
28/01/06 11:56:47 (3 years ago)
Author:
Clément Stenac <zorglub@videolan.org>
git-committer:
Clément Stenac <zorglub@videolan.org> 1138445807 +0000
git-parent:

[1ab90751c095b208a87e37d4d0fdbd765f0f4923]

git-author:
Clément Stenac <zorglub@videolan.org> 1138445807 +0000
Message:

RRD output (Refs:#473)
This is a quick hack, which should in the end be merged in a way to expose stats

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/misc/logger.c

    ra1e597b r2263441  
    7878{ 
    7979    int i_mode; 
     80    FILE *p_rrd; 
     81    mtime_t last_update; 
    8082 
    8183    FILE *    p_file; /* The log file */ 
     
    9698static void SyslogPrint       ( const msg_item_t *); 
    9799#endif 
     100 
     101static void DoRRD( intf_thread_t *p_intf ); 
    98102 
    99103/***************************************************************************** 
     
    128132        change_string_list( mode_list, mode_list_text, 0 ); 
    129133 
     134    add_string( "rrd-file", NULL, NULL, N_("RRD output file") , 
     135                    N_("Output data for RRDTool in this file" ), VLC_TRUE ); 
     136 
    130137    set_capability( "interface", 0 ); 
    131138    set_callbacks( Open, Close ); 
     
    138145{ 
    139146    intf_thread_t *p_intf = (intf_thread_t *)p_this; 
    140     char *psz_mode, *psz_file
     147    char *psz_mode, *psz_file, *psz_rrd_file
    141148 
    142149    CONSOLE_INTRO_MSG; 
     
    262269    } 
    263270 
     271    p_intf->p_sys->last_update = 0; 
     272    p_intf->p_sys->p_rrd = NULL; 
     273 
     274    psz_rrd_file = config_GetPsz( p_intf, "rrd-file" ); 
     275    if( psz_rrd_file && *psz_rrd_file ) 
     276    { 
     277        p_intf->p_sys->p_rrd = fopen( psz_rrd_file, "w" ); 
     278    } 
     279 
    264280    p_intf->p_sys->p_sub = msg_Subscribe( p_intf , MSG_QUEUE_NORMAL ); 
    265281    p_intf->pf_run = Run; 
     
    316332        FlushQueue( p_intf->p_sys->p_sub, p_intf->p_sys->p_file, 
    317333                    p_intf->p_sys->i_mode ); 
     334 
     335        if( p_intf->p_sys->p_rrd ) 
     336            DoRRD( p_intf ); 
    318337 
    319338        msleep( INTF_IDLE_SLEEP ); 
     
    401420} 
    402421 
     422static void DoRRD( intf_thread_t *p_intf ) 
     423{ 
     424    playlist_t *p_playlist; 
     425    float f_input_bitrate; 
     426    if( mdate() - p_intf->p_sys->last_update < 1000000 ) 
     427        return; 
     428    p_intf->p_sys->last_update = mdate(); 
     429 
     430    p_playlist = (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, 
     431                                                FIND_ANYWHERE ); 
     432    if( p_playlist && p_playlist->p_stats ) 
     433    { 
     434        fprintf( p_intf->p_sys->p_rrd, I64Fi":%f:%f:%f\n", 
     435                   p_intf->p_sys->last_update/1000000, 
     436                   (float)(p_playlist->p_stats->f_input_bitrate)*1000, 
     437                   (float)(p_playlist->p_stats->f_demux_bitrate)*1000, 
     438                   (float)(p_playlist->p_stats->f_output_bitrate)*1000 ); 
     439        fflush( p_intf->p_sys->p_rrd ); 
     440        vlc_object_release( p_playlist ); 
     441    } 
     442}