]> git.sesse.net Git - vlc/blob - modules/gui/skins2/src/vlcproc.hpp
da70a5e8b7460ba8261c353dac1e54a161715f01
[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ère <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 <vlc_vout.h>
31 #include "../vars/equalizer.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 #include "../controls/ctrl_video.hpp"
39
40 class OSTimer;
41 class VarBool;
42 struct aout_instance_t;
43 struct vout_window_t;
44
45
46 /// Singleton object handling VLC internal state and playlist
47 class VlcProc: public SkinObject
48 {
49     public:
50         /// Get the instance of VlcProc
51         /// Returns NULL if the initialization of the object failed
52         static VlcProc *instance( intf_thread_t *pIntf );
53
54         /// Delete the instance of VlcProc
55         static void destroy( intf_thread_t *pIntf );
56
57         /// Getter for the playtree variable
58         Playtree &getPlaytreeVar() { return *((Playtree*)m_cPlaytree.get()); }
59
60         /// Getter for the time variable
61         StreamTime &getTimeVar() { return *((StreamTime*)(m_cVarTime.get())); }
62
63         /// Getter for the volume variable
64         Volume &getVolumeVar() { return *((Volume*)(m_cVarVolume.get())); }
65
66         /// Getter for the stream name variable
67         VarText &getStreamNameVar()
68            { return *((VarText*)(m_cVarStreamName.get())); }
69
70         /// Getter for the stream URI variable
71         VarText &getStreamURIVar()
72             { return *((VarText*)(m_cVarStreamURI.get())); }
73
74         /// Getter for the stream bitrate variable
75         VarText &getStreamBitRateVar()
76             { return *((VarText*)(m_cVarStreamBitRate.get())); }
77
78         /// Getter for the stream sample rate variable
79         VarText &getStreamSampleRateVar()
80             { return *((VarText*)(m_cVarStreamSampleRate.get())); }
81
82         /// Getter for the vout size variable
83         VarBox &getVoutSizeVar() { return m_varVoutSize; }
84
85         /// Indicate whether the embedded video output is currently used
86         bool isVoutUsed() const { return m_pVout != NULL; }
87
88         /// Refresh Volume
89         void refreshVolume();
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         /// Playtree variable
100         VariablePtr m_cPlaytree;
101         VariablePtr m_cVarRandom;
102         VariablePtr m_cVarLoop;
103         VariablePtr m_cVarRepeat;
104         /// Variable for current position of the stream
105         VariablePtr m_cVarTime;
106         /// Variable for audio volume
107         VariablePtr m_cVarVolume;
108         /// Variable for current stream properties
109         VariablePtr m_cVarStreamName;
110         VariablePtr m_cVarStreamURI;
111         VariablePtr m_cVarStreamBitRate;
112         VariablePtr m_cVarStreamSampleRate;
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         VariablePtr m_cVarHasVout;
124         /// Variables related to audio
125         VariablePtr m_cVarHasAudio;
126         /// Equalizer variables
127         EqualizerBands m_varEqBands;
128         VariablePtr m_cVarEqPreamp;
129         VariablePtr m_cVarEqualizer;
130         /// Variable for DVD detection
131         VariablePtr m_cVarDvdActive;
132
133         /// Vout thread
134         vout_thread_t *m_pVout;
135         /// Audio output
136         aout_instance_t *m_pAout;
137
138         /**
139          * Poll VLC internals to update the status (volume, current time in
140          * the stream, current filename, play/pause/stop status, ...)
141          * This function should be called regurlarly, since there is no
142          * callback mechanism (yet?) to automatically update a variable when
143          * the internal status changes
144          */
145         void manage();
146
147         /// Define the command that calls manage()
148         DEFINE_CALLBACK( VlcProc, Manage );
149
150         /// Refresh audio variables
151         void refreshAudio();
152         /// Refresh playlist variables
153         void refreshPlaylist();
154         /// Refresh input variables
155         void refreshInput();
156
157         /// Update the stream name variable
158         void updateStreamName();
159
160         /// Callback for volume variable
161         static int onVolumeChanged( vlc_object_t *pObj, const char *pVariable,
162                                     vlc_value_t oldVal, vlc_value_t newVal,
163                                     void *pParam );
164
165         /// Callback for intf-change variable
166         static int onIntfChange( vlc_object_t *pObj, const char *pVariable,
167                                  vlc_value_t oldVal, vlc_value_t newVal,
168                                  void *pParam );
169
170         /// Callback for intf-show variable
171         static int onIntfShow( vlc_object_t *pObj, const char *pVariable,
172                                vlc_value_t oldVal, vlc_value_t newVal,
173                                void *pParam );
174
175         /// Callback for item-change variable
176         static int onItemChange( vlc_object_t *pObj, const char *pVariable,
177                                  vlc_value_t oldVal, vlc_value_t newVal,
178                                  void *pParam );
179
180         /// Callback for item-change variable
181         static int onItemAppend( vlc_object_t *pObj, const char *pVariable,
182                                  vlc_value_t oldVal, vlc_value_t newVal,
183                                  void *pParam );
184
185         /// Callback for item-change variable
186         static int onItemDelete( vlc_object_t *pObj, const char *pVariable,
187                                  vlc_value_t oldVal, vlc_value_t newVal,
188                                  void *pParam );
189
190
191         /// Callback for playlist-current variable
192         static int onPlaylistChange( vlc_object_t *pObj, const char *pVariable,
193                                      vlc_value_t oldVal, vlc_value_t newVal,
194                                      void *pParam );
195
196         /// Callback for skins2-to-load variable
197         static int onSkinToLoad( vlc_object_t *pObj, const char *pVariable,
198                                  vlc_value_t oldVal, vlc_value_t newVal,
199                                  void *pParam );
200
201         /// Callback for interaction variable
202         static int onInteraction( vlc_object_t *pObj, const char *pVariable,
203                                   vlc_value_t oldVal, vlc_value_t newVal,
204                                   void *pParam );
205
206         /// Callback for equalizer-bands variable
207         static int onEqBandsChange( vlc_object_t *pObj, const char *pVariable,
208                                     vlc_value_t oldVal, vlc_value_t newVal,
209                                     void *pParam );
210
211         /// Callback for equalizer-preamp variable
212         static int onEqPreampChange( vlc_object_t *pObj, const char *pVariable,
213                                      vlc_value_t oldVal, vlc_value_t newVal,
214                                      void *pParam );
215 };
216
217
218 #endif