1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 2003 VideoLAN (Centrale Réseaux) and its contributors
7 * Authors: Cyril Deguet <asmax@via.ecp.fr>
8 * Olivier Teulière <ipkiss@via.ecp.fr>
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.
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.
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 *****************************************************************************/
30 #include "../vars/playlist.hpp"
31 #include "../vars/time.hpp"
32 #include "../vars/volume.hpp"
33 #include "../utils/var_text.hpp"
39 /// Singleton object handling VLC internal state and playlist
40 class VlcProc: public SkinObject
43 /// Get the instance of VlcProc
44 /// Returns NULL if the initialization of the object failed
45 static VlcProc *instance( intf_thread_t *pIntf );
47 /// Delete the instance of VlcProc
48 static void destroy( intf_thread_t *pIntf );
50 /// Getter for the playlist variable
51 Playlist &getPlaylistVar() { return *((Playlist*)m_cPlaylist.get()); }
53 /// Getter for the time variable
54 StreamTime &getTimeVar() { return *((StreamTime*)(m_cVarTime.get())); }
56 /// Getter for the volume variable
57 Volume &getVolumeVar() { return *((Volume*)(m_cVarVolume.get())); }
59 /// Getter for the stream name variable
60 VarText &getStreamNameVar()
61 { return *((VarText*)(m_cVarStreamName.get())); }
63 /// Getter for the stream URI variable
64 VarText &getStreamURIVar()
65 { return *((VarText*)(m_cVarStreamURI.get())); }
67 /// Set the vout window handle
68 void registerVoutWindow( void *pVoutWindow );
70 /// Unset the vout window handle
71 void unregisterVoutWindow( void *pVoutWindow );
73 /// Indicate whether the embedded video output is currently used
74 bool isVoutUsed() const { return m_pVout; }
76 /// If an embedded video output is used, drop it (i.e. tell it to stop
77 /// using our window handle)
81 // Protected because it is a singleton
82 VlcProc( intf_thread_t *pIntf );
86 /// Timer to call manage() regularly (via doManage())
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;
108 /// Set of handles of vout windows
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).
113 set<void *> m_handleSet;
115 vout_thread_t *m_pVout;
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
126 /// Update the stream name variable
127 void updateStreamName( playlist_t *p_playlist );
129 /// This function directly calls manage(), because it's boring to
130 /// always write "pThis->"
131 static void doManage( SkinObject *pObj );
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,
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,
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,
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,
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,
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 );
164 /// Callback to release a vout window
165 static void releaseWindow( intf_thread_t *pIntf, void *pWindow );
167 /// Callback to change a vout window
168 static int controlWindow( intf_thread_t *pIntf, void *pWindow,
169 int query, va_list args );