input_manager.hpp

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * input_manager.hpp : Manage an input and interact with its GUI elements
00003  ****************************************************************************
00004  * Copyright (C) 2006-2008 the VideoLAN team
00005  * $Id$
00006  *
00007  * Authors: Clément Stenac <zorglub@videolan.org>
00008  *
00009  * This program is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2 of the License, or
00012  * (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
00022  *****************************************************************************/
00023 
00024 #ifndef _INPUT_MANAGER_H_
00025 #define _INPUT_MANAGER_H_
00026 
00027 #ifdef HAVE_CONFIG_H
00028 # include "config.h"
00029 #endif
00030 
00031 #include <vlc_common.h>
00032 #include <vlc_input.h>
00033 
00034 #include "qt4.hpp"
00035 
00036 #include <QObject>
00037 #include <QEvent>
00038 
00039 static int const PositionUpdate_Type     = QEvent::User + IMEventType + 1;
00040 static int const ItemChanged_Type        = QEvent::User + IMEventType + 2;
00041 static int const ItemStateChanged_Type   = QEvent::User + IMEventType + 3;
00042 static int const ItemTitleChanged_Type   = QEvent::User + IMEventType + 4;
00043 static int const ItemRateChanged_Type    = QEvent::User + IMEventType + 5;
00044 static int const VolumeChanged_Type      = QEvent::User + IMEventType + 6;
00045 static int const ItemSpuChanged_Type     = QEvent::User + IMEventType + 7;
00046 static int const ItemTeletextChanged_Type= QEvent::User + IMEventType + 8;
00047 
00048 static int const FullscreenControlShow_Type = QEvent::User + IMEventType + 10;
00049 static int const FullscreenControlHide_Type = QEvent::User + IMEventType + 11;
00050 static int const FullscreenControlPlanHide_Type = QEvent::User + IMEventType + 12;
00051 
00052 class IMEvent : public QEvent
00053 {
00054 public:
00055     IMEvent( int type, int id ) : QEvent( (QEvent::Type)(type) )
00056     { i_id = id ; } ;
00057     virtual ~IMEvent() {};
00058 
00059     int i_id;
00060 };
00061 
00062 class InputManager : public QObject
00063 {
00064     Q_OBJECT;
00065 public:
00066     InputManager( QObject *, intf_thread_t * );
00067     virtual ~InputManager();
00068 
00069     void delInput();
00070     bool hasInput() { return p_input && !p_input->b_dead && vlc_object_alive (p_input); }
00071     bool hasAudio();
00072     bool hasVideo();
00073 
00074 private:
00075     intf_thread_t  *p_intf;
00076     input_thread_t *p_input;
00077     int             i_input_id;
00078     int             i_old_playing_status;
00079     QString         old_name;
00080     QString         artUrl;
00081     int             i_rate;
00082     bool            b_transparentTelextext;
00083 
00084     void customEvent( QEvent * );
00085     void addCallbacks();
00086     void delCallbacks();
00087     void UpdateRate();
00088     void UpdateMeta();
00089     void UpdateStatus();
00090     void UpdateNavigation();
00091     void UpdatePosition();
00092     void UpdateSPU();
00093     void UpdateTeletext();
00094     void UpdateArt();
00095 
00096 public slots:
00097     void setInput( input_thread_t * ); ///< Our controlled input changed
00098     void sliderUpdate( float ); ///< User dragged the slider. We get new pos
00099     void togglePlayPause();
00100     void slower();
00101     void faster();
00102     void normalRate();
00103     void setRate( int );
00104     void sectionNext();
00105     void sectionPrev();
00106     void sectionMenu();
00107     void telexGotoPage( int ); ///< Goto teletext page
00108     void telexToggle( bool );  ///< Enable disable teletext buttons
00109     void telexToggleButtons(); ///< Toggle buttons after click
00110     void telexSetTransparency(); ///< Set transparency on teletext background
00111 
00112 signals:
00113     /// Send new position, new time and new length
00114     void positionUpdated( float , int, int );
00115     void rateChanged( int );
00116     void nameChanged( QString );
00117     /// Used to signal whether we should show navigation buttons
00118     void navigationChanged( int );
00119     /// Play/pause status
00120     void statusChanged( int );
00121     void artChanged( QString );
00122     /// Teletext
00123     void teletextEnabled( bool );
00124     void toggleTelexButtons();
00125     void toggleTelexTransparency();
00126     void setNewTelexPage( int );
00127     /// Advanced buttons
00128     void advControlsSetIcon();
00129 };
00130 
00131 class MainInputManager : public QObject
00132 {
00133     Q_OBJECT;
00134 public:
00135     static MainInputManager *getInstance( intf_thread_t *_p_intf )
00136     {
00137         if( !instance )
00138             instance = new MainInputManager( _p_intf );
00139         return instance;
00140     }
00141     static void killInstance()
00142     {
00143         if( instance ) delete instance;
00144     }
00145     virtual ~MainInputManager();
00146 
00147     input_thread_t *getInput() { return p_input; };
00148     InputManager *getIM() { return im; };
00149 
00150 private:
00151     MainInputManager( intf_thread_t * );
00152     void customEvent( QEvent * );
00153 
00154     InputManager            *im;
00155     input_thread_t          *p_input;
00156 
00157     intf_thread_t           *p_intf;
00158     static MainInputManager *instance;
00159 public slots:
00160     bool teletextState();
00161     void togglePlayPause();
00162     void stop();
00163     void next();
00164     void prev();
00165 signals:
00166     void inputChanged( input_thread_t * );
00167     void volumeChanged();
00168 };
00169 
00170 #endif

Generated on Wed Aug 13 08:02:38 2008 for VLC by  doxygen 1.5.1