vout_manager.hpp

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * vout_manager.hpp
00003  *****************************************************************************
00004  * Copyright (C) 2009 the VideoLAN team
00005  * $Id: 999990d6a6a34c5bda6f1a5918b9d16a46e2a816 $
00006  *
00007  * Authors: Erwan Tulou < brezhoneg1 at yahoo.fr r>
00008  *
00009  * This program is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2 of the License, or
00012  * (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License along
00020  * with this program; if not, write to the Free Software Foundation, Inc.,
00021  * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
00022  *****************************************************************************/
00023 
00024 #ifndef VOUTMANAGER_HPP
00025 #define VOUTMANAGER_HPP
00026 
00027 #include <vector>
00028 
00029 #include <vlc_vout.h>
00030 #include <vlc_vout_window.h>
00031 #include "../utils/position.hpp"
00032 #include "../commands/cmd_generic.hpp"
00033 #include "../controls/ctrl_video.hpp"
00034 #include "../events/evt_key.hpp"
00035 
00036 class VarBool;
00037 class GenericWindow;
00038 
00039 #include <stdio.h>
00040 
00041 class SavedWnd
00042 {
00043 public:
00044     SavedWnd( vout_window_t* pWnd, VoutWindow* pVoutWindow = NULL,
00045                CtrlVideo* pCtrlVideo = NULL, int height = 0, int width = 0 )
00046             : pWnd( pWnd ), pVoutWindow( pVoutWindow ),
00047               pCtrlVideo( pCtrlVideo ), height( height ), width( width ) { }
00048     ~SavedWnd() { }
00049 
00050     vout_window_t* pWnd;
00051     VoutWindow *pVoutWindow;
00052     CtrlVideo *pCtrlVideo;
00053     int height;
00054     int width;
00055 };
00056 
00057 class VoutMainWindow: public GenericWindow
00058 {
00059 public:
00060 
00061     VoutMainWindow( intf_thread_t *pIntf, int left = 0, int top = 0 ) :
00062             GenericWindow( pIntf, left, top, false, false, NULL,
00063                            GenericWindow::FullscreenWindow )
00064     {
00065         resize( 10, 10 );
00066         move( -50, -50 );
00067     }
00068     virtual ~VoutMainWindow() { }
00069 
00070     virtual void processEvent( EvtKey &rEvtKey )
00071     {
00072         // Only do the action when the key is down
00073         if( rEvtKey.getKeyState() == EvtKey::kDown )
00074             var_SetInteger( getIntf()->p_libvlc, "key-pressed",
00075                              rEvtKey.getModKey() );
00076     }
00077 };
00078 
00079 
00080 /// Singleton object handling VLC internal state and playlist
00081 class VoutManager: public SkinObject
00082 {
00083 public:
00084     /// Get the instance of VoutManager
00085     /// Returns NULL if the initialization of the object failed
00086     static VoutManager *instance( intf_thread_t *pIntf );
00087 
00088     /// Delete the instance of VoutManager
00089     static void destroy( intf_thread_t *pIntf );
00090 
00091     /// Accept Wnd
00092     void* acceptWnd( vout_window_t* pWnd );
00093 
00094     /// Release Wnd
00095     void releaseWnd( vout_window_t* pWnd );
00096 
00097     /// set size Wnd
00098     void setSizeWnd( vout_window_t* pWnd, int width, int height );
00099 
00100     /// set fullscreen Wnd
00101     void setFullscreenWnd( vout_window_t* pWnd, bool b_fullscreen );
00102 
00103     /// Callback to request a vout window
00104     static void *getWindow( intf_thread_t *pIntf, vout_window_t *pWnd );
00105 
00106     // Window provider (release)
00107     static void releaseWindow( intf_thread_t *pIntf, vout_window_t *pWnd  );
00108 
00109     /// Callback to change a vout window
00110     static int controlWindow( struct vout_window_t *pWnd,
00111                               int query, va_list args );
00112 
00113     // Register Video Controls (when building theme)
00114     void registerCtrlVideo( CtrlVideo* p_CtrlVideo );
00115 
00116     // Register Video Controls (when building theme)
00117     void registerFSC( TopWindow* p_Win );
00118 
00119     // save and restore vouts (when changing theme)
00120     void saveVoutConfig( );
00121     void restoreVoutConfig( bool b_success );
00122 
00123     // save and restore vouts (when swapping Layout)
00124     void discardVout( CtrlVideo* pCtrlVideo );
00125     void requestVout( CtrlVideo* pCtrlVideo );
00126 
00127     // get a useable video Control
00128     CtrlVideo* getBestCtrlVideo( );
00129 
00130     // get the VoutMainWindow
00131     VoutMainWindow* getVoutMainWindow() { return m_pVoutMainWindow; }
00132 
00133     // test if vout are running
00134     bool hasVout() { return ( m_SavedWndVec.size() != 0 ) ; }
00135 
00136 protected:
00137     // Protected because it is a singleton
00138     VoutManager( intf_thread_t *pIntf );
00139     virtual ~VoutManager();
00140 
00141 private:
00142 
00143     vector<CtrlVideo *> m_pCtrlVideoVec;
00144     vector<CtrlVideo *> m_pCtrlVideoVecBackup;
00145     vector<SavedWnd> m_SavedWndVec;
00146 
00147     VoutMainWindow* m_pVoutMainWindow;
00148 
00149     TopWindow* m_pFscWindow;
00150 };
00151 
00152 
00153 #endif

Generated on Tue May 25 08:04:58 2010 for VLC by  doxygen 1.5.6