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);
42 setGeometry(0,0,470,550);
44 IT = new InfoTab( this, p_intf, true ) ;
45 QPushButton *closeButton = new QPushButton(qtr("&Close"));
46 layout->addWidget(IT,0,0,1,3);
47 layout->addWidget(closeButton,1,2);
49 BUTTONACT( closeButton, close() );
50 ON_TIMEOUT( update() );
53 var_AddCallback( THEPL, "item-change", ItemChanged, this );
56 StreamInfoDialog::~StreamInfoDialog()
58 var_DelCallback( THEPL, "item-change", ItemChanged, this );
61 static int ItemChanged( vlc_object_t *p_this, const char *psz_var,
62 vlc_value_t oldval, vlc_value_t newval, void *param )
64 StreamInfoDialog *p_d = (StreamInfoDialog *)param;
65 p_d->need_update = VLC_TRUE;
69 void StreamInfoDialog::update()
71 // Timer runs at 150 ms, dont' update more than 2 times per second
73 if( i_runs % 3 != 0 ) return;
75 input_thread_t *p_input = MainInputManager::getInstance( p_intf )->getInput();
76 if( !p_input || p_input->b_dead )
82 vlc_object_yield( p_input );
83 vlc_mutex_lock( &p_input->input.p_item->lock );
85 IT->update( p_input->input.p_item, need_update, need_update );
88 vlc_mutex_unlock( &p_input->input.p_item->lock );
89 vlc_object_release( p_input );
92 void StreamInfoDialog::close()
94 this->toggleVisible();