1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 2003 the VideoLAN team
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 along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
30 #include <vlc_common.h>
31 #include <vlc_input.h>
33 #include "../vars/equalizer.hpp"
34 #include "../vars/playtree.hpp"
35 #include "../vars/time.hpp"
36 #include "../vars/volume.hpp"
37 #include "../utils/position.hpp"
38 #include "../utils/var_text.hpp"
39 #include "../utils/var_string.hpp"
40 #include "../commands/cmd_generic.hpp"
41 #include "../controls/ctrl_video.hpp"
48 /// Singleton object handling VLC internal state and playlist
49 class VlcProc: public SkinObject
52 /// Get the instance of VlcProc
53 /// Returns NULL if the initialization of the object failed
54 static VlcProc *instance( intf_thread_t *pIntf );
56 /// Delete the instance of VlcProc
57 static void destroy( intf_thread_t *pIntf );
59 /// Getter for the playtree variable
60 Playtree &getPlaytreeVar() { return *((Playtree*)m_cPlaytree.get()); }
62 /// Getter for the time variable
63 StreamTime &getTimeVar() { return *((StreamTime*)(m_cVarTime.get())); }
65 /// Getter for the volume variable
66 Volume &getVolumeVar() { return *((Volume*)(m_cVarVolume.get())); }
68 /// Getter for the current playback speed
69 VarText &getSpeedVar()
70 { return *((VarText*)(m_cVarSpeed.get())); }
72 /// Getter for the stream name variable
73 VarText &getStreamNameVar()
74 { return *((VarText*)(m_cVarStreamName.get())); }
76 /// Getter for the stream URI variable
77 VarText &getStreamURIVar()
78 { return *((VarText*)(m_cVarStreamURI.get())); }
80 /// Getter for the stream bitrate variable
81 VarText &getStreamBitRateVar()
82 { return *((VarText*)(m_cVarStreamBitRate.get())); }
84 /// Getter for the stream sample rate variable
85 VarText &getStreamSampleRateVar()
86 { return *((VarText*)(m_cVarStreamSampleRate.get())); }
88 /// Getter for the stream Art url variable
89 VarString &getStreamArtVar()
90 { return *((VarString*)(m_cVarStreamArt.get())); }
92 /// Getter/Setter for the fullscreen variable
93 VarBool &getFullscreenVar() { return *((VarBool*)(m_cVarFullscreen.get())); }
94 void setFullscreenVar( bool );
96 /// Indicate whether the embedded video output is currently used
97 bool isVoutUsed() const { return m_pVout != NULL; }
100 void update_equalizer( );
102 void on_item_current_changed( vlc_object_t* p_obj, vlc_value_t newVal );
103 void on_intf_event_changed( vlc_object_t* p_obj, vlc_value_t newVal );
104 void on_bit_rate_changed( vlc_object_t* p_obj, vlc_value_t newVal );
105 void on_sample_rate_changed( vlc_object_t* p_obj, vlc_value_t newVal );
106 void on_can_record_changed( vlc_object_t* p_obj, vlc_value_t newVal );
108 void on_random_changed( vlc_object_t* p_obj, vlc_value_t newVal );
109 void on_loop_changed( vlc_object_t* p_obj, vlc_value_t newVal );
110 void on_repeat_changed( vlc_object_t* p_obj, vlc_value_t newVal );
112 void on_volume_changed( vlc_object_t* p_obj, vlc_value_t newVal );
113 void on_audio_filter_changed( vlc_object_t* p_obj, vlc_value_t newVal );
115 void on_intf_show_changed( vlc_object_t* p_obj, vlc_value_t newVal );
117 void on_mouse_moved_changed( vlc_object_t* p_obj, vlc_value_t newVal );
120 // Protected because it is a singleton
121 VlcProc( intf_thread_t *pIntf );
125 /// Timer to call manage() regularly (via doManage())
127 /// Playtree variable
128 VariablePtr m_cPlaytree;
129 VariablePtr m_cVarRandom;
130 VariablePtr m_cVarLoop;
131 VariablePtr m_cVarRepeat;
132 /// Variable for current position of the stream
133 VariablePtr m_cVarTime;
134 /// Variable for audio volume
135 VariablePtr m_cVarVolume;
136 /// Variable for speed playback
137 VariablePtr m_cVarSpeed;
138 /// Variable for current stream properties
139 VariablePtr m_cVarStreamName;
140 VariablePtr m_cVarStreamURI;
141 VariablePtr m_cVarStreamBitRate;
142 VariablePtr m_cVarStreamSampleRate;
143 VariablePtr m_cVarStreamArt;
144 /// Variable for the "mute" state
145 VariablePtr m_cVarMute;
146 /// Variables related to the input
147 VariablePtr m_cVarPlaying;
148 VariablePtr m_cVarStopped;
149 VariablePtr m_cVarPaused;
150 VariablePtr m_cVarSeekable;
151 VariablePtr m_cVarRecordable;
152 VariablePtr m_cVarRecording;
153 /// Variables related to the vout
154 VariablePtr m_cVarFullscreen;
155 VariablePtr m_cVarHasVout;
156 /// Variables related to audio
157 VariablePtr m_cVarHasAudio;
158 /// Equalizer variables
159 EqualizerBands m_varEqBands;
160 VariablePtr m_cVarEqPreamp;
161 VariablePtr m_cVarEqualizer;
162 /// Variable for DVD detection
163 VariablePtr m_cVarDvdActive;
166 vout_thread_t *m_pVout;
168 audio_output_t *m_pAout;
169 bool m_bEqualizer_started;
172 * Poll VLC internals to update the status (volume, current time in
173 * the stream, current filename, play/pause/stop status, ...)
174 * This function should be called regurlarly, since there is no
175 * callback mechanism (yet?) to automatically update a variable when
176 * the internal status changes
180 // reset variables when input is over
183 // init variables (libvlc and playlist levels)
184 void init_variables();
186 /// Define the command that calls manage()
187 DEFINE_CALLBACK( VlcProc, Manage );
189 /// Callback for intf-show variable
190 static int onIntfShow( vlc_object_t *pObj, const char *pVariable,
191 vlc_value_t oldVal, vlc_value_t newVal,
194 /// Callback for input-current variable
195 static int onInputNew( vlc_object_t *pObj, const char *pVariable,
196 vlc_value_t oldVal, vlc_value_t newVal,
199 /// Callback for item-change variable
200 static int onItemChange( vlc_object_t *pObj, const char *pVariable,
201 vlc_value_t oldVal, vlc_value_t newVal,
204 /// Callback for item-change variable
205 static int onItemAppend( vlc_object_t *pObj, const char *pVariable,
206 vlc_value_t oldVal, vlc_value_t newVal,
209 /// Callback for item-change variable
210 static int onItemDelete( vlc_object_t *pObj, const char *pVariable,
211 vlc_value_t oldVal, vlc_value_t newVal,
214 static int onInteraction( vlc_object_t *pObj, const char *pVariable,
215 vlc_value_t oldVal, vlc_value_t newVal,
218 static int onEqBandsChange( vlc_object_t *pObj, const char *pVariable,
219 vlc_value_t oldVal, vlc_value_t newVal,
222 static int onEqPreampChange( vlc_object_t *pObj, const char *pVariable,
223 vlc_value_t oldVal, vlc_value_t newVal,
227 static int onGenericCallback( vlc_object_t *pObj, const char *pVariable,
228 vlc_value_t oldVal, vlc_value_t newVal,
231 /// Generic Callback for intf-event
232 static int onGenericCallback2( vlc_object_t *pObj, const char *pVariable,
233 vlc_value_t oldVal, vlc_value_t newVal,