00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
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,
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
00066
00067 FullscreenControlToggle_Type = QEvent::User + IMEventType + 20,
00068 FullscreenControlShow_Type,
00069 FullscreenControlHide_Type,
00070 FullscreenControlPlanHide_Type,
00071 };
00072
00073 enum { NORMAL,
00074 REPEAT_ONE,
00075 REPEAT_ALL,
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
00127 && !p_input->b_dead
00128 && !p_input->b_eof
00129 && vlc_object_alive (p_input);
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 * );
00176 void sliderUpdate( float );
00177
00178 void reverse();
00179 void slower();
00180 void faster();
00181 void littlefaster();
00182 void littleslower();
00183 void normalRate();
00184 void setRate( int );
00185
00186 void jumpFwd();
00187 void jumpBwd();
00188
00189 void sectionNext();
00190 void sectionPrev();
00191 void sectionMenu();
00192
00193 void telexSetPage( int );
00194 void telexSetTransparency( bool );
00195 void activateTeletext( bool );
00196
00197 void setAtoB();
00198
00199 private slots:
00200 void togglePlayPause();
00201 void AtoBLoop( float, int64_t, int );
00202
00203 signals:
00204
00205 void positionUpdated( float , int64_t, int );
00206 void seekRequested( float pos );
00207 void rateChanged( float );
00208 void nameChanged( const QString& );
00209
00210 void titleChanged( bool );
00211 void chapterChanged( bool );
00212
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
00219 void statusChanged( int );
00220 void recordingStateChanged( bool );
00221
00222 void teletextPossible( bool );
00223 void teletextActivated( bool );
00224 void teletextTransparencyActivated( bool );
00225 void newTelexPageSet( int );
00226
00227 void AtoBchanged( bool, bool );
00228
00229 void voutChanged( bool );
00230 void voutListChanged( vout_thread_t **pp_vout, int i_vout );
00231
00232 void synchroChanged();
00233 void bookmarksChanged();
00234 void cachingChanged( float );
00235
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