00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #include <vlc/vlc.h>
00029 #include <vlc/vout.h>
00030 #include <vlc/intf.h>
00031
00032 #include "wince.h"
00033
00034 static void *GetWindow( intf_thread_t *p_intf, vout_thread_t *,
00035 int *pi_x_hint, int *pi_y_hint,
00036 unsigned int *pi_width_hint,
00037 unsigned int *pi_height_hint );
00038 static void ReleaseWindow( intf_thread_t *p_intf, void *p_window );
00039
00040 static int ControlWindow( intf_thread_t *p_intf, void *p_window,
00041 int i_query, va_list args );
00042
00043
00044 enum
00045 {
00046 UpdateSize_Event = 1000 + 1,
00047 UpdateHide_Event
00048 };
00049
00050
00051 class VideoWindow : public CBaseWindow
00052 {
00053 public:
00054
00055 VideoWindow( intf_thread_t *_p_intf, HWND _p_parent );
00056 virtual ~VideoWindow();
00057
00058 void *GetWindow( vout_thread_t *, int *, int *, unsigned int *,
00059 unsigned int * );
00060 void ReleaseWindow( void * );
00061 int ControlWindow( void *, int, va_list );
00062
00063 HWND p_child_window;
00064
00065 private:
00066 intf_thread_t *p_intf;
00067 vout_thread_t *p_vout;
00068 HWND p_parent;
00069 vlc_mutex_t lock;
00070
00071 virtual LRESULT WndProc( HWND, UINT, WPARAM, LPARAM );
00072 };
00073
00074
00075
00076
00077 CBaseWindow *CreateVideoWindow( intf_thread_t *p_intf, HWND p_parent )
00078 {
00079 return new VideoWindow( p_intf, p_parent );
00080 }
00081
00082
00083
00084
00085 VideoWindow::VideoWindow( intf_thread_t *_p_intf, HWND _p_parent )
00086 {
00087 RECT rect;
00088 WNDCLASS wc;
00089
00090
00091 p_intf = _p_intf;
00092 p_parent = _p_parent;
00093 p_child_window = NULL;
00094
00095 vlc_mutex_init( p_intf, &lock );
00096
00097 p_vout = NULL;
00098
00099 p_intf->pf_request_window = ::GetWindow;
00100 p_intf->pf_release_window = ::ReleaseWindow;
00101 p_intf->pf_control_window = ::ControlWindow;
00102
00103 p_intf->p_sys->p_video_window = this;
00104
00105 GetClientRect( p_parent, &rect );
00106
00107 wc.style = CS_HREDRAW | CS_VREDRAW ;
00108 wc.lpfnWndProc = (WNDPROC)BaseWndProc;
00109 wc.cbClsExtra = 0;
00110 wc.cbWndExtra = 0;
00111 wc.hIcon = NULL;
00112 wc.hInstance = GetModuleHandle(0);
00113 wc.hCursor = NULL;
00114 wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
00115 wc.lpszMenuName = NULL;
00116 wc.lpszClassName = _T("VIDEOWINDOW");
00117 RegisterClass( &wc );
00118
00119 p_child_window = CreateWindow (
00120 _T("VIDEOWINDOW"), _T(""),
00121 WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | WS_BORDER,
00122 0, 20, rect.right - rect.left,
00123 rect.bottom - rect.top - 2*(MENU_HEIGHT-1) - SLIDER_HEIGHT - 20,
00124 p_parent, NULL, GetModuleHandle(0), (void *)this );
00125
00126 ShowWindow( p_child_window, SW_SHOW );
00127 UpdateWindow( p_child_window );
00128
00129 ReleaseWindow( (void*)p_child_window );
00130 }
00131
00132 VideoWindow::~VideoWindow()
00133 {
00134 vlc_mutex_destroy( &lock );
00135 }
00136
00137
00138
00139
00140 static void *GetWindow( intf_thread_t *p_intf, vout_thread_t *p_vout,
00141 int *pi_x_hint, int *pi_y_hint,
00142 unsigned int *pi_width_hint,
00143 unsigned int *pi_height_hint )
00144 {
00145 return p_intf->p_sys->p_video_window->GetWindow( p_vout, pi_x_hint,
00146 pi_y_hint, pi_width_hint, pi_height_hint );
00147 }
00148
00149 void *VideoWindow::GetWindow( vout_thread_t *_p_vout,
00150 int *pi_x_hint, int *pi_y_hint,
00151 unsigned int *pi_width_hint,
00152 unsigned int *pi_height_hint )
00153 {
00154 vlc_mutex_lock( &lock );
00155
00156 if( p_vout )
00157 {
00158 vlc_mutex_unlock( &lock );
00159 msg_Dbg( p_intf, "Video window already in use" );
00160 return NULL;
00161 }
00162
00163 p_vout = _p_vout;
00164
00165 vlc_mutex_unlock( &lock );
00166
00167 ShowWindow( (HWND)p_child_window, SW_SHOW );
00168 return p_child_window;
00169 }
00170
00171 static void ReleaseWindow( intf_thread_t *p_intf, void *p_window )
00172 {
00173 p_intf->p_sys->p_video_window->ReleaseWindow( p_window );
00174 }
00175
00176 void VideoWindow::ReleaseWindow( void *p_window )
00177 {
00178 vlc_mutex_lock( &lock );
00179 p_vout = NULL;
00180 vlc_mutex_unlock( &lock );
00181
00182 ShowWindow( (HWND)p_window, SW_HIDE );
00183 SetForegroundWindow( p_parent );
00184 }
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195 LRESULT VideoWindow::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
00196 {
00197 switch( msg )
00198 {
00199 case WM_KILLFOCUS:
00200 if( p_vout )
00201 vout_Control( p_vout, VOUT_SET_FOCUS, (vlc_bool_t)VLC_FALSE );
00202 return TRUE;
00203
00204 case WM_SETFOCUS:
00205 if( p_vout )
00206 vout_Control( p_vout, VOUT_SET_FOCUS, (vlc_bool_t)VLC_TRUE );
00207 return TRUE;
00208
00209 default:
00210 return DefWindowProc( hwnd, msg, wp, lp );
00211 }
00212
00213 }
00214
00215 static int ControlWindow( intf_thread_t *p_intf, void *p_window,
00216 int i_query, va_list args )
00217 {
00218 return p_intf->p_sys->p_video_window->ControlWindow( p_window, i_query,
00219 args );
00220 }
00221
00222 int VideoWindow::ControlWindow( void *p_window, int i_query, va_list args )
00223 {
00224 int i_ret = VLC_EGENERIC;
00225
00226 vlc_mutex_lock( &lock );
00227
00228 switch( i_query )
00229 {
00230 case VOUT_SET_ZOOM:
00231 break;
00232
00233 case VOUT_SET_STAY_ON_TOP:
00234 break;
00235
00236 default:
00237 msg_Dbg( p_intf, "control query not supported" );
00238 break;
00239 }
00240
00241 vlc_mutex_unlock( &lock );
00242
00243 return i_ret;
00244 }