]> git.sesse.net Git - vlc/blob - modules/gui/skins2/src/vlcproc.hpp
44057a46d017f980fb287cf154a96d1f742f80cb
[vlc] / modules / gui / skins2 / src / vlcproc.hpp
1 /*****************************************************************************
2  * vlcproc.hpp
3  *****************************************************************************
4  * Copyright (C) 2003 VideoLAN
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., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
23  *****************************************************************************/
24
25 #ifndef VLCPROC_HPP
26 #define VLCPROC_HPP
27
28 #include "../vars/playlist.hpp"
29 #include "../vars/time.hpp"
30 #include "../vars/volume.hpp"
31 #include "../vars/stream.hpp"
32
33 class OSTimer;
34 class VarBool;
35
36
37 /// Singleton object handling VLC internal state and playlist
38 class VlcProc: public SkinObject
39 {
40     public:
41         /// Get the instance of VlcProc
42         /// Returns NULL if the initialization of the object failed
43         static VlcProc *instance( intf_thread_t *pIntf );
44
45         /// Delete the instance of VlcProc
46         static void destroy( intf_thread_t *pIntf );
47
48         /// Getter for the playlist variable
49         Playlist &getPlaylistVar() { return *((Playlist*)m_cPlaylist.get()); }
50
51         /// Getter for the time variable
52         StreamTime &getTimeVar() { return *((StreamTime*)(m_cVarTime.get())); }
53
54         /// Getter for the volume variable
55         Volume &getVolumeVar() { return *((Volume*)(m_cVarVolume.get())); }
56
57         /// Getter for the stream variable
58         Stream &getStreamVar() { return *((Stream*)(m_cVarStream.get())); }
59
60         /// Getter for the mute variable
61         VarBool &getIsMuteVar() { return *((VarBool*)(m_cVarMute.get())); }
62
63         /// Getter for the playing variable
64         VarBool &getIsPlayingVar() { return *((VarBool*)(m_cVarPlaying.get())); }
65
66         /// Getter for the stopped variable
67         VarBool &getIsStoppedVar() { return *((VarBool*)(m_cVarStopped.get())); }
68
69         /// Getter for the paused variable
70         VarBool &getIsPausedVar() { return *((VarBool*)(m_cVarPaused.get())); }
71
72         /// Getter for the seekable variable
73         VarBool &getIsSeekableVar() { return *((VarBool*)(m_cVarSeekable.get())); }
74
75         /// Set the vout window handle
76         void setVoutWindow( void *pVoutWindow );
77
78     protected:
79         // Protected because it is a singleton
80         VlcProc( intf_thread_t *pIntf );
81         virtual ~VlcProc();
82
83     private:
84         /// Timer to call manage() regularly (via doManage())
85         OSTimer *m_pTimer;
86         /// Playlist variable
87         VariablePtr m_cPlaylist;
88         VariablePtr m_cVarRandom;
89         VariablePtr m_cVarLoop;
90         VariablePtr m_cVarRepeat;
91         /// Variable for current position of the stream
92         VariablePtr m_cVarTime;
93         /// Variable for audio volume
94         VariablePtr m_cVarVolume;
95         /// Variable for current stream properties (only name, currently)
96         VariablePtr m_cVarStream;
97         /// Variable for the "mute" state
98         VariablePtr m_cVarMute;
99         /// Variables related to the input
100         VariablePtr m_cVarPlaying;
101         VariablePtr m_cVarStopped;
102         VariablePtr m_cVarPaused;
103         VariablePtr m_cVarSeekable;
104         /// Vout window hanlde
105         void *m_pVoutWindow;
106         /// Vout thread
107         vout_thread_t *m_pVout;
108
109         /// Poll VLC internals to update the status (volume, current time in
110         /// the stream, current filename, play/pause/stop status, ...)
111         /// This function should be called regurlarly, since there is no
112         /// callback mechanism (yet?) to automatically update a variable when
113         /// the internal status changes
114         void manage();
115
116         /// This function directly calls manage(), because it's boring to
117         /// always write "pThis->"
118         static void doManage( SkinObject *pObj );
119
120         /// Callback for intf-change variable
121         static int onIntfChange( vlc_object_t *pObj, const char *pVariable,
122                                  vlc_value_t oldVal, vlc_value_t newVal,
123                                  void *pParam );
124
125         /// Callback for item-change variable
126         static int onItemChange( vlc_object_t *pObj, const char *pVariable,
127                                  vlc_value_t oldVal, vlc_value_t newVal,
128                                  void *pParam );
129
130         /// Callback for playlist-current variable
131         static int onPlaylistChange( vlc_object_t *pObj, const char *pVariable,
132                                      vlc_value_t oldVal, vlc_value_t newVal,
133                                      void *pParam );
134
135         /// Callback for skins2-to-load variable
136         static int onSkinToLoad( vlc_object_t *pObj, const char *pVariable,
137                                  vlc_value_t oldVal, vlc_value_t newVal,
138                                  void *pParam );
139
140         /// Callback to request a vout window
141         static void *getWindow( intf_thread_t *pIntf, vout_thread_t *pVout,
142                                 int *pXHint, int *pYHint,
143                                 unsigned int *pWidthHint,
144                                 unsigned int *pHeightHint );
145
146         /// Callback to release a vout window
147         static void releaseWindow( intf_thread_t *pIntf, void *pWindow );
148
149         /// Callback to change a vout window
150         static int controlWindow( intf_thread_t *pIntf, void *pWindow,
151                                   int query, va_list args );
152 };
153
154
155 #endif