Changeset 226344134ee28d50d5e29d19f5b7ffe4b4df40fd
- 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
| ra1e597b |
r2263441 |
|
| 78 | 78 | { |
|---|
| 79 | 79 | int i_mode; |
|---|
| | 80 | FILE *p_rrd; |
|---|
| | 81 | mtime_t last_update; |
|---|
| 80 | 82 | |
|---|
| 81 | 83 | FILE * p_file; /* The log file */ |
|---|
| … | … | |
| 96 | 98 | static void SyslogPrint ( const msg_item_t *); |
|---|
| 97 | 99 | #endif |
|---|
| | 100 | |
|---|
| | 101 | static void DoRRD( intf_thread_t *p_intf ); |
|---|
| 98 | 102 | |
|---|
| 99 | 103 | /***************************************************************************** |
|---|
| … | … | |
| 128 | 132 | change_string_list( mode_list, mode_list_text, 0 ); |
|---|
| 129 | 133 | |
|---|
| | 134 | add_string( "rrd-file", NULL, NULL, N_("RRD output file") , |
|---|
| | 135 | N_("Output data for RRDTool in this file" ), VLC_TRUE ); |
|---|
| | 136 | |
|---|
| 130 | 137 | set_capability( "interface", 0 ); |
|---|
| 131 | 138 | set_callbacks( Open, Close ); |
|---|
| … | … | |
| 138 | 145 | { |
|---|
| 139 | 146 | 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; |
|---|
| 141 | 148 | |
|---|
| 142 | 149 | CONSOLE_INTRO_MSG; |
|---|
| … | … | |
| 262 | 269 | } |
|---|
| 263 | 270 | |
|---|
| | 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 | |
|---|
| 264 | 280 | p_intf->p_sys->p_sub = msg_Subscribe( p_intf , MSG_QUEUE_NORMAL ); |
|---|
| 265 | 281 | p_intf->pf_run = Run; |
|---|
| … | … | |
| 316 | 332 | FlushQueue( p_intf->p_sys->p_sub, p_intf->p_sys->p_file, |
|---|
| 317 | 333 | p_intf->p_sys->i_mode ); |
|---|
| | 334 | |
|---|
| | 335 | if( p_intf->p_sys->p_rrd ) |
|---|
| | 336 | DoRRD( p_intf ); |
|---|
| 318 | 337 | |
|---|
| 319 | 338 | msleep( INTF_IDLE_SLEEP ); |
|---|
| … | … | |
| 401 | 420 | } |
|---|
| 402 | 421 | |
|---|
| | 422 | static 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 | } |
|---|