vlcproc.hpp 8.91 KB
Newer Older
1 2 3
/*****************************************************************************
 * vlcproc.hpp
 *****************************************************************************
4
 * Copyright (C) 2003 the VideoLAN team
5
 * $Id$
6 7
 *
 * Authors: Cyril Deguet     <asmax@via.ecp.fr>
8
 *          Olivier Teuli�e <ipkiss@via.ecp.fr>
9 10 11 12 13 14 15 16 17 18 19 20 21
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
Antoine Cellerier's avatar
Antoine Cellerier committed
22
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 24 25 26 27
 *****************************************************************************/

#ifndef VLCPROC_HPP
#define VLCPROC_HPP

28 29
#include <set>

30
#include "../vars/equalizer.hpp"
31
#include "../vars/playlist.hpp"
32
#include "../vars/playtree.hpp"
33 34
#include "../vars/time.hpp"
#include "../vars/volume.hpp"
35
#include "../utils/position.hpp"
36
#include "../utils/var_text.hpp"
37
#include "../commands/cmd_generic.hpp"
38 39

class OSTimer;
40
class VarBool;
41
struct aout_instance_t;
42 43


44
/// Singleton object handling VLC internal state and playlist
45 46 47 48 49 50 51 52 53 54 55
class VlcProc: public SkinObject
{
    public:
        /// Get the instance of VlcProc
        /// Returns NULL if the initialization of the object failed
        static VlcProc *instance( intf_thread_t *pIntf );

        /// Delete the instance of VlcProc
        static void destroy( intf_thread_t *pIntf );

        /// Getter for the playlist variable
Cyril Deguet's avatar
Cyril Deguet committed
56
        Playlist &getPlaylistVar() { return *((Playlist*)m_cPlaylist.get()); }
57

58 59 60
        /// Getter for the playtree variable
        Playtree &getPlaytreeVar() { return *((Playtree*)m_cPlaytree.get()); }

61
        /// Getter for the time variable
62
        StreamTime &getTimeVar() { return *((StreamTime*)(m_cVarTime.get())); }
63 64

        /// Getter for the volume variable
Cyril Deguet's avatar
Cyril Deguet committed
65
        Volume &getVolumeVar() { return *((Volume*)(m_cVarVolume.get())); }
66

67 68 69 70 71 72 73
        /// Getter for the stream name variable
        VarText &getStreamNameVar()
           { return *((VarText*)(m_cVarStreamName.get())); }

        /// Getter for the stream URI variable
        VarText &getStreamURIVar()
            { return *((VarText*)(m_cVarStreamURI.get())); }
74

75 76 77 78
        /// Getter for the stream bitrate variable
        VarText &getStreamBitRateVar()
            { return *((VarText*)(m_cVarStreamBitRate.get())); }

79 80 81 82
        /// Getter for the stream sample rate variable
        VarText &getStreamSampleRateVar()
            { return *((VarText*)(m_cVarStreamSampleRate.get())); }

83 84 85
        /// Getter for the vout size variable
        VarBox &getVoutSizeVar() { return m_varVoutSize; }

86
        /// Set the vout window handle
87 88 89 90
        void registerVoutWindow( void *pVoutWindow );

        /// Unset the vout window handle
        void unregisterVoutWindow( void *pVoutWindow );
91

92
        /// Indicate whether the embedded video output is currently used
93
        bool isVoutUsed() const { return m_pVout != NULL; }
94

95 96 97
        /// If an embedded video output is used, drop it (i.e. tell it to stop
        /// using our window handle)
        void dropVout();
98

99 100 101 102 103 104 105 106 107
    protected:
        // Protected because it is a singleton
        VlcProc( intf_thread_t *pIntf );
        virtual ~VlcProc();

    private:
        /// Timer to call manage() regularly (via doManage())
        OSTimer *m_pTimer;
        /// Playlist variable
Cyril Deguet's avatar
Cyril Deguet committed
108
        VariablePtr m_cPlaylist;
109 110
        /// Playtree variable FIXME
        VariablePtr m_cPlaytree;
111
        VariablePtr m_cVarRandom;
112
        VariablePtr m_cVarLoop;
113
        VariablePtr m_cVarRepeat;
Cyril Deguet's avatar
Cyril Deguet committed
114 115
        /// Variable for current position of the stream
        VariablePtr m_cVarTime;
116
        /// Variable for audio volume
Cyril Deguet's avatar
Cyril Deguet committed
117
        VariablePtr m_cVarVolume;
118 119 120
        /// Variable for current stream properties
        VariablePtr m_cVarStreamName;
        VariablePtr m_cVarStreamURI;
121
        VariablePtr m_cVarStreamBitRate;
122
        VariablePtr m_cVarStreamSampleRate;
123
        /// Variable for the "mute" state
Cyril Deguet's avatar
Cyril Deguet committed
124
        VariablePtr m_cVarMute;
125
        /// Variables related to the input
Cyril Deguet's avatar
Cyril Deguet committed
126
        VariablePtr m_cVarPlaying;
127 128 129
        VariablePtr m_cVarStopped;
        VariablePtr m_cVarPaused;
        VariablePtr m_cVarSeekable;
130 131
        /// Variables related to the vout
        VariablePtr m_cVarFullscreen;
132
        VarBox m_varVoutSize;
133
        VariablePtr m_cVarHasVout;
134
        /// Equalizer variables
135
        EqualizerBands m_varEqBands;
136
        VariablePtr m_cVarEqPreamp;
137
        VariablePtr m_cVarEqualizer;
138 139
        /// Variable for DVD detection
        VariablePtr m_cVarDvdActive;
140 141 142 143 144 145 146

        /// Set of handles of vout windows
        /**
         * When changing the skin, the handles of the 2 skins coexist in the
         * set (but this is temporary, until the old theme is destroyed).
         */
        set<void *> m_handleSet;
147 148
        /// Vout thread
        vout_thread_t *m_pVout;
149 150
        /// Audio output
        aout_instance_t *m_pAout;
151

152 153 154 155 156 157 158
        /**
         * Poll VLC internals to update the status (volume, current time in
         * the stream, current filename, play/pause/stop status, ...)
         * This function should be called regurlarly, since there is no
         * callback mechanism (yet?) to automatically update a variable when
         * the internal status changes
         */
159 160
        void manage();

161 162 163
        /// Define the command that calls manage()
        DEFINE_CALLBACK( VlcProc, Manage );

164 165 166
        /// Refresh audio variables
        void refreshAudio();

167 168 169
        /// Update the stream name variable
        void updateStreamName( playlist_t *p_playlist );

170 171 172 173 174
        /// Callback for intf-change variable
        static int onIntfChange( vlc_object_t *pObj, const char *pVariable,
                                 vlc_value_t oldVal, vlc_value_t newVal,
                                 void *pParam );

175 176 177 178 179
        /// Callback for intf-show variable
        static int onIntfShow( vlc_object_t *pObj, const char *pVariable,
                               vlc_value_t oldVal, vlc_value_t newVal,
                               void *pParam );

180 181 182 183 184
        /// Callback for item-change variable
        static int onItemChange( vlc_object_t *pObj, const char *pVariable,
                                 vlc_value_t oldVal, vlc_value_t newVal,
                                 void *pParam );

Clément Stenac's avatar
Clément Stenac committed
185 186 187 188 189
        /// Callback for item-change variable
        static int onItemAppend( vlc_object_t *pObj, const char *pVariable,
                                 vlc_value_t oldVal, vlc_value_t newVal,
                                 void *pParam );

190 191 192 193 194 195
        /// Callback for item-change variable
        static int onItemDelete( vlc_object_t *pObj, const char *pVariable,
                                 vlc_value_t oldVal, vlc_value_t newVal,
                                 void *pParam );


196
        /// Callback for playlist-current variable
197 198 199
        static int onPlaylistChange( vlc_object_t *pObj, const char *pVariable,
                                     vlc_value_t oldVal, vlc_value_t newVal,
                                     void *pParam );
200

201 202 203 204 205
        /// Callback for skins2-to-load variable
        static int onSkinToLoad( vlc_object_t *pObj, const char *pVariable,
                                 vlc_value_t oldVal, vlc_value_t newVal,
                                 void *pParam );

206 207 208 209 210
        /// Callback for interaction variable
        static int onInteraction( vlc_object_t *pObj, const char *pVariable,
                                  vlc_value_t oldVal, vlc_value_t newVal,
                                  void *pParam );

211 212 213 214 215 216 217 218 219 220 221 222
        /// Callback to request a vout window
        static void *getWindow( intf_thread_t *pIntf, vout_thread_t *pVout,
                                int *pXHint, int *pYHint,
                                unsigned int *pWidthHint,
                                unsigned int *pHeightHint );

        /// Callback to release a vout window
        static void releaseWindow( intf_thread_t *pIntf, void *pWindow );

        /// Callback to change a vout window
        static int controlWindow( intf_thread_t *pIntf, void *pWindow,
                                  int query, va_list args );
223 224 225 226 227

        /// Callback for equalizer-bands variable
        static int onEqBandsChange( vlc_object_t *pObj, const char *pVariable,
                                    vlc_value_t oldVal, vlc_value_t newVal,
                                    void *pParam );
228 229 230 231 232

        /// Callback for equalizer-preamp variable
        static int onEqPreampChange( vlc_object_t *pObj, const char *pVariable,
                                     vlc_value_t oldVal, vlc_value_t newVal,
                                     void *pParam );
233 234 235 236
};


#endif