Changeset fc3815a7114f9fef7eb47e38903f33bfb10597b7

Show
Ignore:
Timestamp:
03/16/08 03:47:07 (6 months ago)
Author:
Rafaël Carré <funman@videolan.org>
git-committer:
Rafaël Carré <funman@videolan.org> 1205635627 +0100
git-parent:

[ba7e4ce0f12026c1736097f43cfbd96096b98f23]

git-author:
Rafaël Carré <funman@videolan.org> 1205635627 +0100
Message:

Better stats box in ncurses

Fix scrolling
Use ACS_* characters to be nicer
Only show video & audio if there is an es (or show both if there is no es, mp3 has no es)
TODO: show sout only when needed

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/gui/ncurses.c

    r6cf973e rfc3815a  
    5252#include <vlc_charset.h> 
    5353#include <vlc_input.h> 
     54#include <vlc_es.h> 
    5455#include <vlc_playlist.h> 
    5556#include <vlc_meta.h> 
     
    20022003            vlc_mutex_lock( &p_item->p_stats->lock ); 
    20032004 
     2005            int i_audio = 0; 
     2006            int i_video = 0; 
     2007            int i; 
     2008 
     2009            if( !p_item->i_es ) 
     2010                i_video = i_audio = 1; 
     2011            else 
     2012                for( i = 0; i < p_item->i_es ; i++ ) 
     2013                { 
     2014                    printf( "XXX %d\n", p_item->es[i]->i_cat ); 
     2015                    i_audio += ( p_item->es[i]->i_cat == AUDIO_ES ); 
     2016                    i_video += ( p_item->es[i]->i_cat == VIDEO_ES ); 
     2017                } 
     2018 
     2019            int l = 0; 
     2020 
     2021#define SHOW_ACS(x,c) \ 
     2022    if(l >= p_sys->i_box_start && l - p_sys->i_box_start < p_sys->i_box_lines) \ 
     2023        mvaddch( p_sys->i_box_y - p_sys->i_box_start + l, x, c ) 
     2024 
    20042025            /* Input */ 
    20052026            if( p_sys->b_color ) wcolor_set( p_sys->w, C_CATEGORY, NULL ); 
    2006             mvnprintw( y++, 1, COLS-2, _("+-[Incoming]")); 
     2027            MainBoxWrite( p_intf, l, 1, _("+-[Incoming]")); 
     2028            SHOW_ACS( 1, ACS_ULCORNER );  SHOW_ACS( 2, ACS_HLINE ); l++; 
    20072029            if( p_sys->b_color ) wcolor_set( p_sys->w, C_DEFAULT, NULL ); 
    2008             mvnprintw( y++, 1, COLS-2, _("| input bytes read : %8.0f kB"), 
     2030            MainBoxWrite( p_intf, l, 1, _("| input bytes read : %8.0f kB"), 
    20092031                    (float)(p_item->p_stats->i_read_bytes)/1000 ); 
    2010             mvnprintw( y++, 1, COLS-2, _("| input bitrate    :   %6.0f kb/s"), 
     2032            SHOW_ACS( 1, ACS_VLINE ); l++; 
     2033            MainBoxWrite( p_intf, l, 1, _("| input bitrate    :   %6.0f kb/s"), 
    20112034                    (float)(p_item->p_stats->f_input_bitrate)*8000 ); 
    2012             mvnprintw( y++, 1, COLS-2,_("| demux bytes read : %8.0f kB"), 
     2035            MainBoxWrite( p_intf, l, 1, _("| demux bytes read : %8.0f kB"), 
    20132036                    (float)(p_item->p_stats->i_demux_read_bytes)/1000 ); 
    2014             mvnprintw( y++, 1, COLS-2,_("| demux bitrate    :   %6.0f kb/s"), 
     2037            SHOW_ACS( 1, ACS_VLINE ); l++; 
     2038            MainBoxWrite( p_intf, l, 1, _("| demux bitrate    :   %6.0f kb/s"), 
    20152039                    (float)(p_item->p_stats->f_demux_bitrate)*8000 ); 
    2016             mvnprintw( y++, 1, COLS-2,"|"); 
     2040            SHOW_ACS( 1, ACS_VLINE ); l++; SHOW_ACS( 1, ACS_VLINE ); l++; 
     2041 
    20172042            /* Video */ 
    2018             if( p_sys->b_color ) wcolor_set( p_sys->w, C_CATEGORY, NULL ); 
    2019             mvnprintw( y++, 1, COLS-2,_("+-[Video Decoding]")); 
    2020             if( p_sys->b_color ) wcolor_set( p_sys->w, C_DEFAULT, NULL ); 
    2021             mvnprintw( y++, 1, COLS-2,_("| video decoded    :    %5i"), 
    2022                     p_item->p_stats->i_decoded_video ); 
    2023             mvnprintw( y++, 1, COLS-2,_("| frames displayed :    %5i"), 
    2024                     p_item->p_stats->i_displayed_pictures ); 
    2025             mvnprintw( y++, 1, COLS-2,_("| frames lost      :    %5i"), 
    2026                     p_item->p_stats->i_lost_pictures ); 
    2027             mvnprintw( y++, 1, COLS-2,"|"); 
     2043            if( i_video ) 
     2044            { 
     2045                if( p_sys->b_color ) wcolor_set( p_sys->w, C_CATEGORY, NULL ); 
     2046                MainBoxWrite( p_intf, l, 1, _("+-[Video Decoding]")); 
     2047                SHOW_ACS( 1, ACS_LTEE );  SHOW_ACS( 2, ACS_HLINE ); l++; 
     2048                if( p_sys->b_color ) wcolor_set( p_sys->w, C_DEFAULT, NULL ); 
     2049                MainBoxWrite( p_intf, l, 1, _("| video decoded    :    %5i"), 
     2050                        p_item->p_stats->i_decoded_video ); 
     2051                SHOW_ACS( 1, ACS_VLINE ); l++; 
     2052                MainBoxWrite( p_intf, l, 1, _("| frames displayed :    %5i"), 
     2053                        p_item->p_stats->i_displayed_pictures ); 
     2054                SHOW_ACS( 1, ACS_VLINE ); l++; 
     2055                MainBoxWrite( p_intf, l, 1, _("| frames lost      :    %5i"), 
     2056                        p_item->p_stats->i_lost_pictures ); 
     2057                SHOW_ACS( 1, ACS_VLINE ); l++; SHOW_ACS( 1, ACS_VLINE ); l++; 
     2058            } 
    20282059            /* Audio*/ 
    2029             if( p_sys->b_color ) wcolor_set( p_sys->w, C_CATEGORY, NULL ); 
    2030             mvnprintw( y++, 1, COLS-2,_("+-[Audio Decoding]")); 
    2031             if( p_sys->b_color ) wcolor_set( p_sys->w, C_DEFAULT, NULL ); 
    2032             mvnprintw( y++, 1, COLS-2,_("| audio decoded    :    %5i"), 
    2033                     p_item->p_stats->i_decoded_audio ); 
    2034             mvnprintw( y++, 1, COLS-2,_("| buffers played   :    %5i"), 
    2035                     p_item->p_stats->i_played_abuffers ); 
    2036             mvnprintw( y++, 1, COLS-2,_("| buffers lost     :    %5i"), 
    2037                     p_item->p_stats->i_lost_abuffers ); 
    2038             mvnprintw( y++, 1, COLS-2,"|"); 
     2060            if( i_audio ) 
     2061            { 
     2062                if( p_sys->b_color ) wcolor_set( p_sys->w, C_CATEGORY, NULL ); 
     2063                MainBoxWrite( p_intf, l, 1, _("+-[Audio Decoding]")); 
     2064                SHOW_ACS( 1, ACS_LTEE );  SHOW_ACS( 2, ACS_HLINE ); l++; 
     2065                if( p_sys->b_color ) wcolor_set( p_sys->w, C_DEFAULT, NULL ); 
     2066                MainBoxWrite( p_intf, l, 1, _("| audio decoded    :    %5i"), 
     2067                        p_item->p_stats->i_decoded_audio ); 
     2068                SHOW_ACS( 1, ACS_VLINE ); l++; 
     2069                MainBoxWrite( p_intf, l, 1, _("| buffers played   :    %5i"), 
     2070                        p_item->p_stats->i_played_abuffers ); 
     2071                SHOW_ACS( 1, ACS_VLINE ); l++; 
     2072                MainBoxWrite( p_intf, l, 1, _("| buffers lost     :    %5i"), 
     2073                        p_item->p_stats->i_lost_abuffers ); 
     2074                SHOW_ACS( 1, ACS_VLINE ); l++; SHOW_ACS( 1, ACS_VLINE ); l++; 
     2075            } 
    20392076            /* Sout */ 
    20402077            if( p_sys->b_color ) wcolor_set( p_sys->w, C_CATEGORY, NULL ); 
    2041             mvnprintw( y++, 1, COLS-2,_("+-[Streaming]")); 
     2078            MainBoxWrite( p_intf, l, 1, _("+-[Streaming]")); 
     2079            SHOW_ACS( 1, ACS_LTEE );  SHOW_ACS( 2, ACS_HLINE ); l++; 
    20422080            if( p_sys->b_color ) wcolor_set( p_sys->w, C_DEFAULT, NULL ); 
    2043             mvnprintw( y++, 1, COLS-2,_("| packets sent     :    %5i"), p_item->p_stats->i_sent_packets ); 
    2044             mvnprintw( y++, 1, COLS-2,_("| bytes sent       : %8.0f kB"), 
     2081            MainBoxWrite( p_intf, l, 1, _("| packets sent     :    %5i"), p_item->p_stats->i_sent_packets ); 
     2082            SHOW_ACS( 1, ACS_VLINE ); l++; 
     2083            MainBoxWrite( p_intf, l, 1, _("| bytes sent       : %8.0f kB"), 
    20452084                    (float)(p_item->p_stats->i_sent_bytes)/1000 ); 
    2046             mvnprintw( y++, 1, COLS-2,_("| sending bitrate  :   %6.0f kb/s"), 
     2085            SHOW_ACS( 1, ACS_VLINE ); l++; 
     2086            MainBoxWrite( p_intf, l, 1, _("\\ sending bitrate  :   %6.0f kb/s"), 
    20472087                    (float)(p_item->p_stats->f_send_bitrate*8)*1000 ); 
     2088            SHOW_ACS( 1, ACS_LLCORNER ); l++; 
    20482089            if( p_sys->b_color ) wcolor_set( p_sys->w, C_DEFAULT, NULL ); 
     2090 
     2091#undef SHOW_ACS 
     2092 
     2093            p_sys->i_box_lines_total = l; 
     2094            if( p_sys->i_box_start >= p_sys->i_box_lines_total ) 
     2095                p_sys->i_box_start = p_sys->i_box_lines_total - 1; 
     2096 
     2097            if( l - p_sys->i_box_start < p_sys->i_box_lines ) 
     2098                y += l - p_sys->i_box_start; 
     2099            else 
     2100                y += p_sys->i_box_lines; 
    20492101 
    20502102            vlc_mutex_unlock( &p_item->p_stats->lock ); 
    20512103            vlc_mutex_unlock( &p_item->lock ); 
     2104 
    20522105        } 
    20532106    }