]> git.sesse.net Git - vlc/blob - modules/gui/skins2/src/vlcproc.hpp
aef2f50a9ef22da2d06590f4587ed8f7715b962c
[vlc] / modules / gui / skins2 / src / vlcproc.hpp
1 /*****************************************************************************
2  * vlcproc.hpp
3  *****************************************************************************
4  * Copyright (C) 2003 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
8  *          Olivier Teuli�e <ipkiss@via.ecp.fr>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23  *****************************************************************************/
24
25 #ifndef VLCPROC_HPP
26 #define VLCPROC_HPP
27
28 #include <set>
29
30 #include "../vars/equalizer.hpp"
31 #include "../vars/playlist.hpp"
32 #include "../vars/playtree.hpp"
33 #include "../vars/time.hpp"
34 #include "../vars/volume.hpp"
35 #include "../utils/position.hpp"
36 #include "../utils/var_text.hpp"
37 #include "../commands/cmd_generic.hpp"
38
39 class OSTimer;
40 class VarBool;
41 struct aout_instance_t;
42
43
44 /// Singleton object handling VLC internal state and playlist
45 class VlcProc: public SkinObject
46 {
47     public:
48         /// Get the instance of VlcProc
49         /// Returns NULL if the initialization of the object failed
50         static VlcProc *instance( intf_thread_t *pIntf );
51
52         /// Delete the instance of VlcProc
53         static void destroy( intf_thread_t *pIntf );
54
55         /// Getter for the playlist variable
56         Playlist &getPlaylistVar() { return *((Playlist*)m_cPlaylist.get()); }
57
58         /// Getter for the playtree variable
59         Playtree &getPlaytreeVar() { return *((Playtree*)m_cPlaytree.get()); }
60
61         /// Getter for the time variable
62         StreamTime &getTimeVar() { return *((StreamTime*)(m_cVarTime.get())); }
63
64         /// Getter for the volume variable
65         Volume &getVolumeVar() { return *((Volume*)(m_cVarVolume.get())); }
66
67         /// Getter for the stream name variable
68         VarText &getStreamNameVar()
69            { return *((VarText*)(m_cVarStreamName.get())); }
70
71         /// Getter for the stream URI variable
72         VarText &getStreamURIVar()
73             { return *((VarText*)(m_cVarStreamURI.get())); }
74
75         /// Getter for the vout size variable
76         VarBox &getVoutSizeVar() { return m_varVoutSize; }
77
78         /// Set the vout window handle
79         void registerVoutWindow( void *pVoutWindow );
80
81         /// Unset the vout window handle
82         void unregisterVoutWindow( void *pVoutWindow );
83
84         /// Indicate whether the embedded video output is currently used
85         bool isVoutUsed() const { return m_pVout != NULL; }
86
87         /// If an embedded video output is used, drop it (i.e. tell it to stop
88         /// using our window handle)
89         void dropVout();
90
91     protected:
92         // Protected because it is a singleton
93         VlcProc( intf_thread_t *pIntf );
94         virtual ~VlcProc();
95
96     private:
97         /// Timer to call manage() regularly (via doManage())
98         OSTimer *m_pTimer;
99         /// Playlist variable
100         VariablePtr m_cPlaylist;
101         /// Playtree variable FIXME
102         VariablePtr m_cPlaytree;
103         VariablePtr m_cVarRandom;
104         VariablePtr m_cVarLoop;
105         VariablePtr m_cVarRepeat;
106         /// Variable for current position of the stream
107         VariablePtr m_cVarTime;
108         /// Variable for audio volume
109         VariablePtr m_cVarVolume;
110         /// Variable for current stream properties
111         VariablePtr m_cVarStreamName;
112         VariablePtr m_cVarStreamURI;
113         /// Variable for the "mute" state
114         VariablePtr m_cVarMute;
115         /// Variables related to the input
116         VariablePtr m_cVarPlaying;
117         VariablePtr m_cVarStopped;
118         VariablePtr m_cVarPaused;
119         VariablePtr m_cVarSeekable;
120         /// Variables related to the vout
121         VariablePtr m_cVarFullscreen;
122         VarBox m_varVoutSize;
123         /// Equalizer variables
124         EqualizerBands m_varEqBands;
125         VariablePtr m_cVarEqPreamp;
126         VariablePtr m_cVarEqualizer;
127         /// Variable for DVD detection
128         VariablePtr m_cVarDvdActive;
129
130         /// Set of handles of vout windows
131         /**
132          * When changing the skin, the handles of the 2 skins coexist in the
133          * set (but this is temporary, until the old theme is destroyed).
134          */
135         set<void *> m_handleSet;
136         /// Vout thread
137         vout_thread_t *m_pVout;
138         /// Audio output
139         aout_instance_t *m_pAout;
140
141         /**
142          * Poll VLC internals to update the status (volume, current time in
143          * the stream, current filename, play/pause/stop status, ...)
144          * This function should be called regurlarly, since there is no
145          * callback mechanism (yet?) to automatically update a variable when
146          * the internal status changes
147          */
148         void manage();
149
150         /// Define the command that calls manage()
151         DEFINE_CALLBACK( VlcProc, Manage );
152
153         /// Refresh audio variables
154         void refreshAudio();
155
156         /// Update the stream name variable
157         void updateStreamName( playlist_t *p_playlist );
158
159         /// Callback for intf-change variable
160         static int onIntfChange( vlc_object_t *pObj, const char *pVariable,
161                                  vlc_value_t oldVal, vlc_value_t newVal,
162                                  void *pParam );
163
164         /// Callback for intf-show variable
165         static int onIntfShow( vlc_object_t *pObj, const char *pVariable,
166                                vlc_value_t oldVal, vlc_value_t newVal,
167                                void *pParam );
168
169         /// Callback for item-change variable
170         static int onItemChange( vlc_object_t *pObj, const char *pVariable,
171                                  vlc_value_t oldVal, vlc_value_t newVal,
172                                  void *pParam );
173
174         /// Callback for item-change variable
175         static int onItemAppend( vlc_object_t *pObj, const char *pVariable,
176                                  vlc_value_t oldVal, vlc_value_t newVal,
177                                  void *pParam );
178
179         /// Callback for item-change variable
180         static int onItemDelete( vlc_object_t *pObj, const char *pVariable,
181                                  vlc_value_t oldVal, vlc_value_t newVal,
182                                  void *pParam );
183
184
185         /// Callback for playlist-current variable
186         static int onPlaylistChange( vlc_object_t *pObj, const char *pVariable,
187                                      vlc_value_t oldVal, vlc_value_t newVal,
188                                      void *pParam );
189
190         /// Callback for skins2-to-load variable
191         static int onSkinToLoad( vlc_object_t *pObj, const char *pVariable,
192                                  vlc_value_t oldVal, vlc_value_t newVal,
193                                  void *pParam );
194
195         /// Callback for interaction variable
196         static int onInteraction( vlc_object_t *pObj, const char *pVariable,
197                                   vlc_value_t oldVal, vlc_value_t newVal,
198                                   void *pParam );
199
200         /// Callback to request a vout window
201         static void *getWindow( intf_thread_t *pIntf, vout_thread_t *pVout,
202                                 int *pXHint, int *pYHint,
203                                 unsigned int *pWidthHint,
204                                 unsigned int *pHeightHint );
205
206         /// Callback to release a vout window
207         static void releaseWindow( intf_thread_t *pIntf, void *pWindow );
208
209         /// Callback to change a vout window
210         static int controlWindow( intf_thread_t *pIntf, void *pWindow,
211                                   int query, va_list args );
212
213         /// Callback for equalizer-bands variable
214         static int onEqBandsChange( vlc_object_t *pObj, const char *pVariable,
215                                     vlc_value_t oldVal, vlc_value_t newVal,
216                                     void *pParam );
217
218         /// Callback for equalizer-preamp variable
219         static int onEqPreampChange( vlc_object_t *pObj, const char *pVariable,
220                                      vlc_value_t oldVal, vlc_value_t newVal,
221                                      void *pParam );
222 };
223
224
225 #endif