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: a85d2940f1f8f0202bda4a64fd727e1f30808804 $
00006  *
00007  * Authors: Clément Stenac <zorglub@videolan.org>
00008  *          Jean-Baptiste <jb@videolan.org>
00009  *
00010  * This program is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2 of the License, or
00013  * (at your option) any later version.
00014  *
00015  * This program is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  * GNU General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License
00021  * along with this program; if not, write to the Free Software
00022  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
00023  *****************************************************************************/
00024 
00025 #ifndef QVLC_INPUT_MANAGER_H_
00026 #define QVLC_INPUT_MANAGER_H_
00027 
00028 #ifdef HAVE_CONFIG_H
00029 # include "config.h"
00030 #endif
00031 
00032 #include <vlc_input.h>
00033 
00034 #include "qt4.hpp"
00035 
00036 #include <QObject>
00037 #include <QEvent>
00038 
00039 
00040 enum {
00041     PositionUpdate_Type = QEvent::User + IMEventType + 1,
00042     ItemChanged_Type,
00043     ItemStateChanged_Type,
00044     ItemTitleChanged_Type,
00045     ItemRateChanged_Type,
00046     VolumeChanged_Type,
00047     SoundMuteChanged_Type,
00048     ItemEsChanged_Type,
00049     ItemTeletextChanged_Type,
00050     InterfaceVoutUpdate_Type,
00051     StatisticsUpdate_Type, /*10*/
00052     InterfaceAoutUpdate_Type,
00053     MetaChanged_Type,
00054     NameChanged_Type,
00055     InfoChanged_Type,
00056     SynchroChanged_Type,
00057     CachingEvent_Type,
00058     BookmarksChanged_Type,
00059     RecordingEvent_Type,
00060     ProgramChanged_Type,
00061     RandomChanged_Type,
00062     LoopChanged_Type,
00063     RepeatChanged_Type,
00064     LeafToParent_Type,
00065 /*    SignalChanged_Type, */
00066 
00067     FullscreenControlToggle_Type = QEvent::User + IMEventType + 20,
00068     FullscreenControlShow_Type,
00069     FullscreenControlHide_Type,
00070     FullscreenControlPlanHide_Type,
00071 };
00072 
00073 enum { NORMAL,    /* loop: 0, repeat: 0 */
00074        REPEAT_ONE,/* loop: 1, repeat: 0 */
00075        REPEAT_ALL,/* loop: 0, repeat: 1 */
00076 };
00077 
00078 class IMEvent : public QEvent
00079 {
00080 friend class InputManager;
00081 friend class MainInputManager;
00082     public:
00083     IMEvent( int type, input_item_t *p_input = NULL )
00084         : QEvent( (QEvent::Type)(type) )
00085     {
00086         if( (p_item = p_input) != NULL )
00087             vlc_gc_incref( p_item );
00088     }
00089     virtual ~IMEvent()
00090     {
00091         if( p_item )
00092             vlc_gc_decref( p_item );
00093     }
00094 
00095 private:
00096     input_item_t *p_item;
00097 };
00098 
00099 enum PLEventTypes
00100 {
00101     PLItemAppended_Type = QEvent::User + PLEventType + 1,
00102     PLItemRemoved_Type
00103 };
00104 
00105 class PLEvent : public QEvent
00106 {
00107 public:
00108     PLEvent( PLEventTypes t, int i, int p )
00109         : QEvent( (QEvent::Type)t ), i_item(i), i_parent(p) {}
00110     int i_item;
00111     int i_parent;
00112 };
00113 
00114 class InputManager : public QObject
00115 {
00116     Q_OBJECT
00117     friend class MainInputManager;
00118 
00119 public:
00120     InputManager( QObject *, intf_thread_t * );
00121     virtual ~InputManager();
00122 
00123     void delInput();
00124     bool hasInput()
00125     {
00126         return p_input /* We have an input */
00127             && !p_input->b_dead /* not dead yet, */
00128             && !p_input->b_eof  /* not EOF either, */
00129             && vlc_object_alive (p_input); /* and the VLC object is alive */
00130     }
00131 
00132     bool hasAudio();
00133     bool hasVideo() { return hasInput() && b_video; }
00134     void requestArtUpdate();
00135 
00136     QString getName() { return oldName; }
00137     static const QString decodeArtURL( input_item_t *p_item );
00138 
00139 private:
00140     intf_thread_t  *p_intf;
00141     input_thread_t *p_input;
00142     vlc_object_t   *p_input_vbi;
00143     input_item_t   *p_item;
00144     int             i_old_playing_status;
00145     QString         oldName;
00146     QString         artUrl;
00147     float           f_rate;
00148     float           f_cache;
00149     bool            b_video;
00150     mtime_t         timeA, timeB;
00151 
00152     void customEvent( QEvent * );
00153 
00154     void addCallbacks();
00155     void delCallbacks();
00156 
00157     void UpdateRate();
00158     void UpdateName();
00159     void UpdateStatus();
00160     void UpdateNavigation();
00161     void UpdatePosition();
00162     void UpdateTeletext();
00163     void UpdateArt();
00164     void UpdateInfo();
00165     void UpdateMeta();
00166     void UpdateMeta(input_item_t *);
00167     void UpdateVout();
00168     void UpdateAout();
00169     void UpdateStats();
00170     void UpdateCaching();
00171     void UpdateRecord();
00172     void UpdateProgramEvent();
00173 
00174 public slots:
00175     void setInput( input_thread_t * ); ///< Our controlled input changed
00176     void sliderUpdate( float ); ///< User dragged the slider. We get new pos
00177     /* SpeedRate Rate Management */
00178     void reverse();
00179     void slower();
00180     void faster();
00181     void littlefaster();
00182     void littleslower();
00183     void normalRate();
00184     void setRate( int );
00185     /* Jumping */
00186     void jumpFwd();
00187     void jumpBwd();
00188     /* Menus */
00189     void sectionNext();
00190     void sectionPrev();
00191     void sectionMenu();
00192     /* Teletext */
00193     void telexSetPage( int );          ///< Goto teletext page
00194     void telexSetTransparency( bool ); ///< Transparency on teletext background
00195     void activateTeletext( bool );     ///< Toggle buttons after click
00196     /* A to B Loop */
00197     void setAtoB();
00198 
00199 private slots:
00200     void togglePlayPause();
00201     void AtoBLoop( float, int64_t, int );
00202 
00203 signals:
00204     /// Send new position, new time and new length
00205     void positionUpdated( float , int64_t, int );
00206     void seekRequested( float pos );
00207     void rateChanged( float );
00208     void nameChanged( const QString& );
00209     /// Used to signal whether we should show navigation buttons
00210     void titleChanged( bool );
00211     void chapterChanged( bool );
00212     /// Statistics are updated
00213     void statisticsUpdated( input_item_t* );
00214     void infoChanged( input_item_t* );
00215     void currentMetaChanged( input_item_t* );
00216     void metaChanged( input_item_t *);
00217     void artChanged( QString );
00218     /// Play/pause status
00219     void statusChanged( int );
00220     void recordingStateChanged( bool );
00221     /// Teletext
00222     void teletextPossible( bool );
00223     void teletextActivated( bool );
00224     void teletextTransparencyActivated( bool );
00225     void newTelexPageSet( int );
00226     /// Advanced buttons
00227     void AtoBchanged( bool, bool );
00228     /// Vout
00229     void voutChanged( bool );
00230     void voutListChanged( vout_thread_t **pp_vout, int i_vout );
00231     /// Other
00232     void synchroChanged();
00233     void bookmarksChanged();
00234     void cachingChanged( float );
00235     /// Program Event changes
00236     void encryptionChanged( bool );
00237 };
00238 
00239 class MainInputManager : public QObject
00240 {
00241     Q_OBJECT
00242 public:
00243     static MainInputManager *getInstance( intf_thread_t *_p_intf )
00244     {
00245         if( !instance )
00246             instance = new MainInputManager( _p_intf );
00247         return instance;
00248     }
00249     static void killInstance()
00250     {
00251         delete instance;
00252         instance = NULL;
00253     }
00254 
00255     input_thread_t *getInput() { return p_input; }
00256     InputManager *getIM() { return im; }
00257     inline input_item_t *currentInputItem()
00258     {
00259         return ( p_input ? input_GetItem( p_input ) : NULL );
00260     }
00261 
00262     vout_thread_t* getVout();
00263     aout_instance_t *getAout();
00264 
00265 private:
00266     MainInputManager( intf_thread_t * );
00267     virtual ~MainInputManager();
00268 
00269     static MainInputManager *instance;
00270 
00271     void customEvent( QEvent * );
00272 
00273     InputManager            *im;
00274     input_thread_t          *p_input;
00275     intf_thread_t           *p_intf;
00276 
00277     void notifyRepeatLoop();
00278 public slots:
00279     void togglePlayPause();
00280     void play();
00281     void pause();
00282     void toggleRandom();
00283     void stop();
00284     void next();
00285     void prev();
00286     void activatePlayQuit( bool );
00287 
00288     void loopRepeatLoopStatus();
00289 
00290 signals:
00291     void inputChanged( input_thread_t * );
00292     void volumeChanged();
00293     void soundMuteChanged();
00294     void playlistItemAppended( int itemId, int parentId );
00295     void playlistItemRemoved( int itemId );
00296     void randomChanged( bool );
00297     void repeatLoopChanged( int );
00298     void leafBecameParent( input_item_t * );
00299 };
00300 
00301 #endif

Generated on Tue May 25 08:04:57 2010 for VLC by  doxygen 1.5.6