]> git.sesse.net Git - vlc/blob - modules/gui/skins2/src/vlcproc.hpp
* skins2: Fixed 2 bugs related with embedded vout and skins switching:
[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 <set>
29
30 #include "../vars/playlist.hpp"
31 #include "../vars/time.hpp"
32 #include "../vars/volume.hpp"
33 #include "../utils/var_text.hpp"
34
35 class OSTimer;
36 class VarBool;
37
38
39 /// Singleton object handling VLC internal state and playlist
40 class VlcProc: public SkinObject
41 {
42     public:
43         /// Get the instance of VlcProc
44         /// Returns NULL if the initialization of the object failed
45         static VlcProc *instance( intf_thread_t *pIntf );
46
47         /// Delete the instance of VlcProc
48         static void destroy( intf_thread_t *pIntf );
49
50         /// Getter for the playlist variable
51         Playlist &getPlaylistVar() { return *((Playlist*)m_cPlaylist.get()); }
52
53         /// Getter for the time variable
54         StreamTime &getTimeVar() { return *((StreamTime*)(m_cVarTime.get())); }
55
56         /// Getter for the volume variable
57         Volume &getVolumeVar() { return *((Volume*)(m_cVarVolume.get())); }
58
59         /// Getter for the stream name variable
60         VarText &getStreamNameVar()
61            { return *((VarText*)(m_cVarStreamName.get())); }
62
63         /// Getter for the stream URI variable
64         VarText &getStreamURIVar()
65             { return *((VarText*)(m_cVarStreamURI.get())); }
66
67         /// Set the vout window handle
68         void registerVoutWindow( void *pVoutWindow );
69
70         /// Unset the vout window handle
71         void unregisterVoutWindow( void *pVoutWindow );
72
73         /// Indicate whether the embedded video output is currently used
74         bool isVoutUsed() const { return m_pVout; }
75
76         /// If an embedded video output is used, drop it (i.e. tell it to stop
77         /// using our window handle)
78         void dropVout();
79
80     protected:
81         // Protected because it is a singleton
82         VlcProc( intf_thread_t *pIntf );
83         virtual ~VlcProc();
84
85     private:
86         /// Timer to call manage() regularly (via doManage())
87         OSTimer *m_pTimer;
88         /// Playlist variable
89         VariablePtr m_cPlaylist;
90         VariablePtr m_cVarRandom;
91         VariablePtr m_cVarLoop;
92         VariablePtr m_cVarRepeat;
93         /// Variable for current position of the stream
94         VariablePtr m_cVarTime;
95         /// Variable for audio volume
96         VariablePtr m_cVarVolume;
97         /// Variable for current stream properties
98         VariablePtr m_cVarStreamName;
99         VariablePtr m_cVarStreamURI;
100         /// Variable for the "mute" state
101         VariablePtr m_cVarMute;
102         /// Variables related to the input
103         VariablePtr m_cVarPlaying;
104         VariablePtr m_cVarStopped;
105         VariablePtr m_cVarPaused;
106         VariablePtr m_cVarSeekable;
107
108         /// Set of handles of vout windows
109         /**
110          * When changing the skin, the handles of the 2 skins coexist in the
111          * set (but this is temporary, until the old theme is destroyed).
112          */
113         set<void *> m_handleSet;
114         /// Vout thread
115         vout_thread_t *m_pVout;
116
117         /**
118          * Poll VLC internals to update the status (volume, current time in
119          * the stream, current filename, play/pause/stop status, ...)
120          * This function should be called regurlarly, since there is no
121          * callback mechanism (yet?) to automatically update a variable when
122          * the internal status changes
123          */
124         void manage();
125
126         /// Update the stream name variable
127         void updateStreamName( playlist_t *p_playlist );
128
129         /// This function directly calls manage(), because it's boring to
130         /// always write "pThis->"
131         static void doManage( SkinObject *pObj );
132
133         /// Callback for intf-change variable
134         static int onIntfChange( vlc_object_t *pObj, const char *pVariable,
135                                  vlc_value_t oldVal, vlc_value_t newVal,
136                                  void *pParam );
137
138         /// Callback for intf-show variable
139         static int onIntfShow( vlc_object_t *pObj, const char *pVariable,
140                                vlc_value_t oldVal, vlc_value_t newVal,
141                                void *pParam );
142
143         /// Callback for item-change variable
144         static int onItemChange( vlc_object_t *pObj, const char *pVariable,
145                                  vlc_value_t oldVal, vlc_value_t newVal,
146                                  void *pParam );
147
148         /// Callback for playlist-current variable
149         static int onPlaylistChange( vlc_object_t *pObj, const char *pVariable,
150                                      vlc_value_t oldVal, vlc_value_t newVal,
151                                      void *pParam );
152
153         /// Callback for skins2-to-load variable
154         static int onSkinToLoad( vlc_object_t *pObj, const char *pVariable,
155                                  vlc_value_t oldVal, vlc_value_t newVal,
156                                  void *pParam );
157
158         /// Callback to request a vout window
159         static void *getWindow( intf_thread_t *pIntf, vout_thread_t *pVout,
160                                 int *pXHint, int *pYHint,
161                                 unsigned int *pWidthHint,
162                                 unsigned int *pHeightHint );
163
164         /// Callback to release a vout window
165         static void releaseWindow( intf_thread_t *pIntf, void *pWindow );
166
167         /// Callback to change a vout window
168         static int controlWindow( intf_thread_t *pIntf, void *pWindow,
169                                   int query, va_list args );
170 };
171
172
173 #endif