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 "../controls/ctrl_video.hpp"
47 /// Singleton object handling VLC internal state and playlist
48 class VlcProc: public SkinObject
51 /// Get the instance of VlcProc
52 /// Returns NULL if the initialization of the object failed
53 static VlcProc *instance( intf_thread_t *pIntf );
55 /// Delete the instance of VlcProc
56 static void destroy( intf_thread_t *pIntf );
58 /// Getter for the playtree variable
59 Playtree &getPlaytreeVar() { return *((Playtree*)m_cPlaytree.get()); }
61 /// Getter for the time variable
62 StreamTime &getTimeVar() { return *((StreamTime*)(m_cVarTime.get())); }
64 /// Getter for the volume variable
65 Volume &getVolumeVar() { return *((Volume*)(m_cVarVolume.get())); }
67 /// Getter for the current playback speed
68 VarText &getSpeedVar()
69 { return *((VarText*)(m_cVarSpeed.get())); }
71 /// Getter for the stream name variable
72 VarText &getStreamNameVar()
73 { return *((VarText*)(m_cVarStreamName.get())); }
75 /// Getter for the stream URI variable
76 VarText &getStreamURIVar()
77 { return *((VarText*)(m_cVarStreamURI.get())); }
79 /// Getter for the stream bitrate variable
80 VarText &getStreamBitRateVar()
81 { return *((VarText*)(m_cVarStreamBitRate.get())); }
83 /// Getter for the stream sample rate variable
84 VarText &getStreamSampleRateVar()
85 { return *((VarText*)(m_cVarStreamSampleRate.get())); }
87 /// Getter for the stream Art url variable
88 VarString &getStreamArtVar()
89 { return *((VarString*)(m_cVarStreamArt.get())); }
91 /// Getter/Setter for the fullscreen variable
92 VarBool &getFullscreenVar() { return *((VarBool*)(m_cVarFullscreen.get())); }
93 void setFullscreenVar( bool );
95 /// Indicate whether the embedded video output is currently used
96 bool isVoutUsed() const { return m_pVout != NULL; }
99 void update_equalizer( );
101 void on_intf_event_changed( vlc_object_t* p_obj, vlc_value_t newVal );
102 void on_bit_rate_changed( vlc_object_t* p_obj, vlc_value_t newVal );
103 void on_sample_rate_changed( vlc_object_t* p_obj, vlc_value_t newVal );
104 void on_can_record_changed( vlc_object_t* p_obj, vlc_value_t newVal );
106 void on_random_changed( vlc_object_t* p_obj, vlc_value_t newVal );
107 void on_loop_changed( vlc_object_t* p_obj, vlc_value_t newVal );
108 void on_repeat_changed( vlc_object_t* p_obj, vlc_value_t newVal );
110 void on_volume_changed( vlc_object_t* p_obj, vlc_value_t newVal );
111 void on_audio_filter_changed( vlc_object_t* p_obj, vlc_value_t newVal );
113 void on_intf_show_changed( vlc_object_t* p_obj, vlc_value_t newVal );
115 void on_mouse_moved_changed( vlc_object_t* p_obj, vlc_value_t newVal );
118 // Protected because it is a singleton
119 VlcProc( intf_thread_t *pIntf );
123 /// Playtree variable
124 VariablePtr m_cPlaytree;
125 VariablePtr m_cVarRandom;
126 VariablePtr m_cVarLoop;
127 VariablePtr m_cVarRepeat;
128 /// Variable for current position of the stream
129 VariablePtr m_cVarTime;
130 /// Variable for audio volume
131 VariablePtr m_cVarVolume;
132 /// Variable for speed playback
133 VariablePtr m_cVarSpeed;
134 /// Variable for current stream properties
135 VariablePtr m_cVarStreamName;
136 VariablePtr m_cVarStreamURI;
137 VariablePtr m_cVarStreamBitRate;
138 VariablePtr m_cVarStreamSampleRate;
139 VariablePtr m_cVarStreamArt;
140 /// Variable for the "mute" state
141 VariablePtr m_cVarMute;
142 /// Variables related to the input
143 VariablePtr m_cVarPlaying;
144 VariablePtr m_cVarStopped;
145 VariablePtr m_cVarPaused;
146 VariablePtr m_cVarSeekable;
147 VariablePtr m_cVarRecordable;
148 VariablePtr m_cVarRecording;
149 /// Variables related to the vout
150 VariablePtr m_cVarFullscreen;
151 VariablePtr m_cVarHasVout;
152 /// Variables related to audio
153 VariablePtr m_cVarHasAudio;
154 /// Equalizer variables
155 EqualizerBands m_varEqBands;
156 VariablePtr m_cVarEqPreamp;
157 VariablePtr m_cVarEqualizer;
158 /// Variable for DVD detection
159 VariablePtr m_cVarDvdActive;
162 vout_thread_t *m_pVout;
164 audio_output_t *m_pAout;
165 bool m_bEqualizer_started;
167 // reset variables when input is over
170 // init variables (libvlc and playlist levels)
171 void init_variables();
173 /// Callback for intf-show variable
174 static int onIntfShow( vlc_object_t *pObj, const char *pVariable,
175 vlc_value_t oldVal, vlc_value_t newVal,
178 /// Callback for input-current variable
179 static int onInputNew( vlc_object_t *pObj, const char *pVariable,
180 vlc_value_t oldVal, vlc_value_t newVal,
183 /// Callback for item-change variable
184 static int onItemChange( vlc_object_t *pObj, const char *pVariable,
185 vlc_value_t oldVal, vlc_value_t newVal,
188 /// Callback for item-change variable
189 static int onItemAppend( vlc_object_t *pObj, const char *pVariable,
190 vlc_value_t oldVal, vlc_value_t newVal,
193 /// Callback for item-change variable
194 static int onItemDelete( vlc_object_t *pObj, const char *pVariable,
195 vlc_value_t oldVal, vlc_value_t newVal,
198 static int onInteraction( vlc_object_t *pObj, const char *pVariable,
199 vlc_value_t oldVal, vlc_value_t newVal,
202 static int onEqBandsChange( vlc_object_t *pObj, const char *pVariable,
203 vlc_value_t oldVal, vlc_value_t newVal,
206 static int onEqPreampChange( vlc_object_t *pObj, const char *pVariable,
207 vlc_value_t oldVal, vlc_value_t newVal,
211 static int onGenericCallback( vlc_object_t *pObj, const char *pVariable,
212 vlc_value_t oldVal, vlc_value_t newVal,
215 /// Generic Callback for intf-event
216 static int onGenericCallback2( vlc_object_t *pObj, const char *pVariable,
217 vlc_value_t oldVal, vlc_value_t newVal,