1 /***************************************************************************** 2 * vout_manager.hpp 3 ***************************************************************************** 4 * Copyright (C) 2009 the VideoLAN team 5 * $Id: 4cf3522b40d5af6a8fa5b6ded943ddc277ed649f $ 6 * 7 * Authors: Erwan Tulou < brezhoneg1 at yahoo.fr r> 8 * 9 * This program is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License as published by 11 * the Free Software Foundation; either version 2 of the License, or 12 * (at your option) any later version. 13 * 14 * This program is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public License along 20 * with this program; if not, write to the Free Software Foundation, Inc., 21 * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. 22 *****************************************************************************/ 23 24 #ifndef VOUTMANAGER_HPP 25 #define VOUTMANAGER_HPP 26 27 #include <vector> 28 29 #include <vlc_vout.h> 30 #include <vlc_vout_window.h> 31 #include <vlc_actions.h> 32 #include "../utils/position.hpp" 33 #include "../commands/cmd_generic.hpp" 34 #include "../controls/ctrl_video.hpp" 35 #include "../events/evt_key.hpp" 36 #include "../events/evt_scroll.hpp" 37 #include "../src/fsc_window.hpp" 38 39 class VarBool; 40 class GenericWindow; 41 class FscWindow; 42 43 #include <stdio.h> 44 45 class SavedWnd 46 { 47 public: SavedWnd(vout_window_t * pWnd,VoutWindow * pVoutWindow=NULL,CtrlVideo * pCtrlVideo=NULL,int height=-1,int width=-1)48 SavedWnd( vout_window_t* pWnd, VoutWindow* pVoutWindow = NULL, 49 CtrlVideo* pCtrlVideo = NULL, int height = -1, int width = -1 ) 50 : pWnd( pWnd ), pVoutWindow( pVoutWindow ), 51 pCtrlVideo( pCtrlVideo ), height( height ), width( width ) { } ~SavedWnd()52 ~SavedWnd() { } 53 54 vout_window_t* pWnd; 55 VoutWindow *pVoutWindow; 56 CtrlVideo *pCtrlVideo; 57 int height; 58 int width; 59 }; 60 61 class VoutMainWindow: public GenericWindow 62 { 63 public: 64 VoutMainWindow(intf_thread_t * pIntf,int left=0,int top=0)65 VoutMainWindow( intf_thread_t *pIntf, int left = 0, int top = 0 ) : 66 GenericWindow( pIntf, left, top, false, false, NULL, 67 GenericWindow::FullscreenWindow ) 68 { 69 resize( 10, 10 ); 70 move( -50, -50 ); 71 } ~VoutMainWindow()72 virtual ~VoutMainWindow() { } 73 74 #if defined( _WIN32 ) || defined( __OS2__ ) 75 processEvent(EvtKey & rEvtKey)76 virtual void processEvent( EvtKey &rEvtKey ) 77 { 78 // Only do the action when the key is down 79 if( rEvtKey.getKeyState() == EvtKey::kDown ) 80 getIntf()->p_sys->p_dialogs->sendKey( rEvtKey.getModKey() ); 81 } 82 processEvent(EvtScroll & rEvtScroll)83 virtual void processEvent( EvtScroll &rEvtScroll ) 84 { 85 // scroll events sent to core as hotkeys 86 int i_vlck = 0; 87 i_vlck |= rEvtScroll.getMod(); 88 i_vlck |= ( rEvtScroll.getDirection() == EvtScroll::kUp ) ? 89 KEY_MOUSEWHEELUP : KEY_MOUSEWHEELDOWN; 90 91 getIntf()->p_sys->p_dialogs->sendKey( i_vlck ); 92 } 93 94 #endif 95 }; 96 97 98 /// Singleton object handling VLC internal state and playlist 99 class VoutManager: public SkinObject, public Observer<VarBool> 100 { 101 public: 102 /// Get the instance of VoutManager 103 /// Returns NULL if the initialization of the object failed 104 static VoutManager *instance( intf_thread_t *pIntf ); 105 106 /// Delete the instance of VoutManager 107 static void destroy( intf_thread_t *pIntf ); 108 109 /// accept window request (vout window provider) 110 void acceptWnd( vout_window_t *pWnd, int width, int height ); 111 112 // release window (vout window provider) 113 void releaseWnd( vout_window_t *pWnd ); 114 115 /// set window size (vout window provider) 116 void setSizeWnd( vout_window_t* pWnd, int width, int height ); 117 118 /// set fullscreen mode (vout window provider) 119 void setFullscreenWnd( vout_window_t* pWnd, bool b_fullscreen ); 120 121 /// hide mouse (vout window provider) 122 void hideMouseWnd( vout_window_t* pWnd, bool hide ); 123 124 // Register Video Controls (when building theme) 125 void registerCtrlVideo( CtrlVideo* p_CtrlVideo ); 126 127 // Register Video Controls (when building theme) 128 void registerFSC( FscWindow* p_Win ); 129 130 // get the fullscreen controller window getFscWindow()131 FscWindow* getFscWindow( ) { return m_pFscWindow; } 132 133 // save and restore vouts (when changing theme) 134 void saveVoutConfig( ); 135 void restoreVoutConfig( bool b_success ); 136 137 // save and restore vouts (when swapping Layout) 138 void discardVout( CtrlVideo* pCtrlVideo ); 139 void requestVout( CtrlVideo* pCtrlVideo ); 140 141 // get a useable video Control 142 CtrlVideo* getBestCtrlVideo( ); 143 144 // get the VoutMainWindow getVoutMainWindow()145 VoutMainWindow* getVoutMainWindow() { return m_pVoutMainWindow; } 146 147 // test if vout are running hasVout()148 bool hasVout() { return ( m_SavedWndVec.size() != 0 ) ; } 149 150 /// called when fullscreen variable changed 151 virtual void onUpdate( Subject<VarBool> &rVariable , void* ); 152 153 /// reconfigure fullscreen (multiple screens) 154 virtual void configureFullscreen( VoutWindow& rWindow ); 155 156 protected: 157 // Protected because it is a singleton 158 VoutManager( intf_thread_t *pIntf ); 159 virtual ~VoutManager(); 160 161 private: 162 163 std::vector<CtrlVideo *> m_pCtrlVideoVec; 164 std::vector<CtrlVideo *> m_pCtrlVideoVecBackup; 165 std::vector<SavedWnd> m_SavedWndVec; 166 167 VoutMainWindow* m_pVoutMainWindow; 168 169 FscWindow* m_pFscWindow; 170 }; 171 172 173 #endif 174