1 /*****************************************************************************
2 * streaminfo.cpp : Information about an item
3 ****************************************************************************
4 * Copyright (C) 2006 the VideoLAN team
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. *****************************************************************************/
24 #include <QGridLayout>
26 #include "dialogs/streaminfo.hpp"
27 #include "input_manager.hpp"
28 #include "dialogs_provider.hpp"
29 #include "util/qvlcframe.hpp"
30 #include "components/infopanels.hpp"
33 static int ItemChanged( vlc_object_t *p_this, const char *psz_var,
34 vlc_value_t oldval, vlc_value_t newval, void *param );
35 StreamInfoDialog *StreamInfoDialog::instance = NULL;
37 StreamInfoDialog::StreamInfoDialog( intf_thread_t *_p_intf ) :QVLCFrame( _p_intf )
40 setWindowTitle( _("Stream information" ) );
41 QGridLayout *layout = new QGridLayout(this);
43 IT = new InfoTab( this, p_intf, true ) ;
44 QPushButton *closeButton = new QPushButton(qtr("&Close"));
45 layout->addWidget(IT,0,0,1,3);
46 layout->addWidget(closeButton,1,2);
48 BUTTONACT( closeButton, close() );
49 ON_TIMEOUT( update() );
52 var_AddCallback( THEPL, "item-change", ItemChanged, this );
54 readSettings( "StreamInfo" , QSize( 470, 450 ) );
57 StreamInfoDialog::~StreamInfoDialog()
59 var_DelCallback( THEPL, "item-change", ItemChanged, this );
60 writeSettings( "StreamInfo" );
63 static int ItemChanged( vlc_object_t *p_this, const char *psz_var,
64 vlc_value_t oldval, vlc_value_t newval, void *param )
66 StreamInfoDialog *p_d = (StreamInfoDialog *)param;
67 p_d->need_update = VLC_TRUE;
71 void StreamInfoDialog::update()
73 // Timer runs at 150 ms, dont' update more than 2 times per second
75 if( i_runs % 3 != 0 ) return;
77 input_thread_t *p_input = MainInputManager::getInstance( p_intf )->getInput();
78 if( !p_input || p_input->b_dead )
84 vlc_object_yield( p_input );
85 vlc_mutex_lock( &p_input->input.p_item->lock );
87 IT->update( p_input->input.p_item, need_update, need_update );
90 vlc_mutex_unlock( &p_input->input.p_item->lock );
91 vlc_object_release( p_input );
94 void StreamInfoDialog::close()
96 this->toggleVisible();