1 /*****************************************************************************
2 * infopanels.cpp : Information panels (general info, stats, ...)
3 *****************************************************************************
4 * Copyright (C) 2000-2004 the VideoLAN team
5 * $Id: iteminfo.cpp 13905 2006-01-12 23:10:04Z dionoea $
7 * Authors: Clément Stenac <zorglub@videolan.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 #include "dialogs/infopanels.hpp"
25 #include <wx/combobox.h>
26 #include <wx/statline.h>
29 # define wxRB_SINGLE 0
32 /*****************************************************************************
34 *****************************************************************************/
35 BEGIN_EVENT_TABLE( ItemInfoPanel, wxPanel )
38 ItemInfoPanel::ItemInfoPanel( intf_thread_t *_p_intf,
41 wxPanel( _p_parent, -1 )
43 int flags= wxTE_PROCESS_ENTER;
47 b_modifiable = _b_modifiable;
49 SetAutoLayout( TRUE );
51 wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL );
53 wxFlexGridSizer *sizer = new wxFlexGridSizer(2,8,20);
54 sizer->AddGrowableCol(1);
57 flags |= wxTE_READONLY;
60 wxStaticText *uri_static =
61 new wxStaticText( this, -1, wxU(_("URI")) );
62 sizer->Add( uri_static, 0 , wxALL , 0 );
64 uri_text = new wxTextCtrl( this, -1,
65 wxU(""), wxDefaultPosition, wxSize( 300, -1 ), flags );
66 sizer->Add( uri_text, 1 , wxALL|wxEXPAND , 0 );
69 wxStaticText *name_static =
70 new wxStaticText( this, -1, wxU(_("Name")) );
71 sizer->Add( name_static, 0 , wxALL , 0 );
73 name_text = new wxTextCtrl( this, -1,
74 wxU(""), wxDefaultPosition, wxSize( 300, -1 ), flags );
75 sizer->Add( name_text, 1 , wxALL|wxEXPAND , 0 );
78 info_tree = new wxTreeCtrl( this, -1, wxDefaultPosition,
80 wxSUNKEN_BORDER |wxTR_HAS_BUTTONS |
82 info_root = info_tree->AddRoot( wxU( "" ) );
85 panel_sizer->Add( sizer, 0, wxEXPAND | wxALL, 15 );
86 panel_sizer->Add( info_tree, 1, wxEXPAND | wxALL, 5 );
87 panel_sizer->Layout();
88 SetSizerAndFit( panel_sizer );
91 ItemInfoPanel::~ItemInfoPanel()
95 void ItemInfoPanel::Update( input_item_t *p_item )
97 /* Rebuild the tree */
100 uri_text->SetValue( wxU( p_item->psz_uri ) );
101 name_text->SetValue( wxU( p_item->psz_name ) );
103 for( int i = 0; i< p_item->i_categories ; i++)
105 wxTreeItemId cat = info_tree->AppendItem( info_root,
106 wxU( p_item->pp_categories[i]->psz_name) );
108 for( int j = 0 ; j < p_item->pp_categories[i]->i_infos ; j++ )
110 info_tree->AppendItem( cat , (wxString)
111 wxU(p_item->pp_categories[i]->pp_infos[j]->psz_name) +
113 wxU(p_item->pp_categories[i]->pp_infos[j]->psz_value) );
116 info_tree->Expand( cat );
120 char* ItemInfoPanel::GetURI( )
122 return strdup( uri_text->GetLineText(0).mb_str() );
125 char* ItemInfoPanel::GetName( )
127 return strdup( name_text->GetLineText(0).mb_str() );
130 void ItemInfoPanel::Clear()
132 info_tree->DeleteChildren( info_root );
135 void ItemInfoPanel::OnOk( )
139 void ItemInfoPanel::OnCancel( )
143 /*****************************************************************************
144 * Statistics info panel
145 *****************************************************************************/
146 BEGIN_EVENT_TABLE( InputStatsInfoPanel, wxPanel )
149 InputStatsInfoPanel::InputStatsInfoPanel( intf_thread_t *_p_intf,
150 wxWindow* _p_parent ):
151 wxPanel( _p_parent, -1 )
153 /* Initializations */
155 p_parent = _p_parent;
157 SetAutoLayout( TRUE );
159 panel_sizer = new wxBoxSizer( wxVERTICAL );
161 sizer = new wxFlexGridSizer( 2,2,20 );
164 wxStaticBox *input_box = new wxStaticBox( this, -1,
166 input_box->SetAutoLayout( TRUE );
167 input_bsizer = new wxStaticBoxSizer( input_box, wxVERTICAL );
168 input_sizer = new wxFlexGridSizer( 2,2, 20 );
170 #define INPUT_ADD(txt,widget,dflt) \
171 { input_sizer->Add ( new wxStaticText( this, -1, wxU(_( txt ) ) ), \
172 0, wxEXPAND| wxRIGHT, 5 ); \
173 widget = new wxStaticText( this, -1, wxU( dflt ) ); \
174 input_sizer->Add( widget, 0, wxEXPAND| wxLEFT, 5 ); \
177 INPUT_ADD( "Read at media", read_bytes_text, "0" );
178 INPUT_ADD( "Input bitrate", input_bitrate_text, "0" );
180 INPUT_ADD( "Demuxed", demux_bytes_text ,"0");
181 /* Hack to get enough size */
182 INPUT_ADD( "Stream bitrate", demux_bitrate_text, "0 " );
184 input_sizer->Layout();
185 input_bsizer->Add( input_sizer, 0, wxALL | wxGROW, 5 );
186 input_bsizer->Layout();
187 sizer->Add( input_bsizer, 0, wxALL|wxGROW, 5 );
190 wxStaticBox *video_box = new wxStaticBox( this, -1,
191 wxU( _("Video" ) ) );
192 video_box->SetAutoLayout( TRUE );
193 video_bsizer = new wxStaticBoxSizer( video_box,
195 video_sizer = new wxFlexGridSizer( 2,3, 20 );
197 #define VIDEO_ADD(txt,widget,dflt) \
198 { video_sizer->Add ( new wxStaticText( this, -1, wxU(_( txt ) ) ), \
199 0, wxEXPAND|wxLEFT , 5 ); \
200 widget = new wxStaticText( this, -1, wxU( dflt ) ); \
201 video_sizer->Add( widget, 0, wxEXPAND|wxRIGHT, 5 ); \
203 VIDEO_ADD( "Decoded blocks", video_decoded_text, "0" );
204 /* Hack to get enough size */
205 VIDEO_ADD( "Displayed frames", displayed_text, "0 " );
206 VIDEO_ADD( "Lost frames", lost_frames_text, "0" );
209 video_sizer->Layout();
210 video_bsizer->Add( video_sizer, 0, wxALL | wxGROW, 5 );
211 video_bsizer->Layout();
212 sizer->Add( video_bsizer , 0, wxALL| wxGROW, 5 );
215 wxStaticBox *sout_box = new wxStaticBox( this, -1,
216 wxU( _("Streaming" ) ) );
217 sout_box->SetAutoLayout( TRUE );
218 sout_bsizer = new wxStaticBoxSizer( sout_box, wxVERTICAL );
219 sout_sizer = new wxFlexGridSizer( 2,3, 20 );
221 #define SOUT_ADD(txt,widget,dflt) \
222 { sout_sizer->Add ( new wxStaticText( this, -1, wxU(_( txt ) ) ), \
223 0, wxEXPAND|wxLEFT|wxALIGN_LEFT , 5 ); \
224 widget = new wxStaticText( this, -1, wxU( dflt ) ); \
225 sout_sizer->Add( widget, 0, wxEXPAND|wxRIGHT|wxALIGN_RIGHT, 5 ); \
227 SOUT_ADD( "Sent packets", sout_sent_packets_text, "0" );
228 SOUT_ADD( "Sent bytes", sout_sent_bytes_text, "0 " );
229 SOUT_ADD( "Send rate", sout_send_bitrate_text, "0 " );
230 sout_sizer->Layout();
231 sout_bsizer->Add( sout_sizer, 0, wxALL | wxGROW, 5 );
232 sout_bsizer->Layout();
233 sizer->Add( sout_bsizer , 0, wxALL| wxGROW, 5 );
236 wxStaticBox *audio_box = new wxStaticBox( this, -1,
237 wxU( _("Audio" ) ) );
238 audio_box->SetAutoLayout( TRUE );
239 audio_bsizer = new wxStaticBoxSizer( audio_box, wxVERTICAL );
240 audio_sizer = new wxFlexGridSizer( 2,3, 20 );
242 #define AUDIO_ADD(txt,widget,dflt) \
243 { audio_sizer->Add ( new wxStaticText( this, -1, wxU(_( txt ) ) ), \
244 0, wxEXPAND|wxLEFT , 5 ); \
245 widget = new wxStaticText( this, -1, wxU( dflt ) ); \
246 audio_sizer->Add( widget, 0, wxEXPAND|wxRIGHT, 5 ); \
248 AUDIO_ADD( "Decoded blocks", audio_decoded_text, "0" );
249 /* Hack to get enough size */
250 AUDIO_ADD( "Played buffers", played_abuffers_text,
252 AUDIO_ADD( "Lost buffers", lost_abuffers_text, "0" );
253 audio_sizer->Layout();
254 audio_bsizer->Add( audio_sizer, 0, wxALL | wxGROW, 5 );
255 audio_bsizer->Layout();
256 sizer->Add( audio_bsizer , 0, wxALL| wxGROW, 5 );
259 panel_sizer->Add( sizer, 0, wxEXPAND, 5 );
260 panel_sizer->Layout();
261 SetSizerAndFit( panel_sizer );
264 InputStatsInfoPanel::~InputStatsInfoPanel()
268 void InputStatsInfoPanel::Update( input_item_t *p_item )
270 vlc_mutex_lock( &p_item->p_stats->lock );
273 #define UPDATE( widget,format, calc... ) \
275 wxString formatted; \
276 formatted.Printf( wxString( wxT(format) ), ## calc ); \
277 widget->SetLabel( formatted ); \
279 UPDATE( read_bytes_text, "%8.0f kB",(float)(p_item->p_stats->i_read_bytes)/1000 );
280 UPDATE( input_bitrate_text, "%6.0f kB/s", (float)(p_item->p_stats->f_input_bitrate)*1000 );
281 UPDATE( demux_bytes_text, "%8.0f kB", (float)(p_item->p_stats->i_demux_read_bytes)/1000 );
282 UPDATE( demux_bitrate_text, "%6.0f kB/s", (float)(p_item->p_stats->f_demux_bitrate)*1000 );
285 UPDATE( video_decoded_text, "%5i", p_item->p_stats->i_decoded_video );
286 UPDATE( displayed_text, "%5i", p_item->p_stats->i_displayed_pictures );
287 UPDATE( lost_frames_text, "%5i", p_item->p_stats->i_lost_pictures );
290 UPDATE( sout_sent_packets_text, "%5i", p_item->p_stats->i_sent_packets );
291 UPDATE( sout_sent_bytes_text, "%8.0f kB",
292 (float)(p_item->p_stats->i_sent_bytes)/1000 );
293 UPDATE( sout_send_bitrate_text, "%6.0f kB/S",
294 (float)(p_item->p_stats->f_send_bitrate)*1000 );
297 UPDATE( audio_decoded_text, "%5i", p_item->p_stats->i_decoded_audio );
298 UPDATE( played_abuffers_text, "%5i", p_item->p_stats->i_played_abuffers );
299 UPDATE( lost_abuffers_text, "%5i", p_item->p_stats->i_lost_abuffers );
301 vlc_mutex_unlock( &p_item->p_stats->lock );
303 input_sizer->Layout();
304 video_sizer->Layout();
307 panel_sizer->Layout();
308 SetSizerAndFit( panel_sizer );
311 void InputStatsInfoPanel::Clear()
314 void InputStatsInfoPanel::OnOk( )
317 void InputStatsInfoPanel::OnCancel( )