1 ///////////////////////////////////////////////////////////////////////////// 
   2 // Name:        msw/mediactrl.cpp 
   3 // Purpose:     Built-in Media Backends for Windows 
   4 // Author:      Ryan Norton <wxprojects@comcast.net> 
   8 // Copyright:   (c) Ryan Norton 
   9 // Licence:     wxWindows licence 
  10 ///////////////////////////////////////////////////////////////////////////// 
  12 //=========================================================================== 
  14 //=========================================================================== 
  16 //--------------------------------------------------------------------------- 
  17 // Pre-compiled header stuff 
  18 //--------------------------------------------------------------------------- 
  20 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) 
  21 #pragma implementation "mediactrl.h" 
  24 // For compilers that support precompilation, includes "wx.h". 
  25 #include "wx/wxprec.h" 
  30 #define wxUSE_DIRECTSHOW 0 
  31 #define wxUSE_QUICKTIME 0 
  33 //--------------------------------------------------------------------------- 
  35 //--------------------------------------------------------------------------- 
  36 #include "wx/mediactrl.h" 
  38 //--------------------------------------------------------------------------- 
  40 //--------------------------------------------------------------------------- 
  43 //--------------------------------------------------------------------------- 
  44 // Externals (somewhere in src/msw/app.cpp) 
  45 //--------------------------------------------------------------------------- 
  46 extern "C" WXDLLIMPEXP_BASE HINSTANCE 
wxGetInstance(void); 
  48 extern WXDLLIMPEXP_CORE       wxChar 
*wxCanvasClassName
; 
  50 extern WXDLLIMPEXP_CORE 
const wxChar 
*wxCanvasClassName
; 
  53 //=========================================================================== 
  54 //  BACKEND DECLARATIONS 
  55 //=========================================================================== 
  57 //--------------------------------------------------------------------------- 
  61 //--------------------------------------------------------------------------- 
  63 //--------------------------------------------------------------------------- 
  64 //  Compilation guard for DirectShow 
  65 //--------------------------------------------------------------------------- 
  68 //--------------------------------------------------------------------------- 
  70 //--------------------------------------------------------------------------- 
  71 #include "wx/msw/ole/oleutils.h" //wxBasicString, IID etc. 
  72 #include "wx/msw/ole/uuid.h" //IID etc.. 
  74 //--------------------------------------------------------------------------- 
  75 //  IIDS - used by CoCreateInstance and IUnknown::QueryInterface 
  76 //--------------------------------------------------------------------------- 
  77 const IID LIBID_QuartzTypeLib 
= {0x56A868B0,0x0AD4,0x11CE,{0xB0,0x3A,0x00,0x20,0xAF,0x0B,0xA7,0x70}}; 
  78 const IID IID_IAMCollection 
= {0x56A868B9,0x0AD4,0x11CE,{0xB0,0x3A,0x00,0x20,0xAF,0x0B,0xA7,0x70}}; 
  79 const IID IID_IMediaControl 
= {0x56A868B1,0x0AD4,0x11CE,{0xB0,0x3A,0x00,0x20,0xAF,0x0B,0xA7,0x70}}; 
  80 const IID IID_IMediaEvent 
= {0x56A868B6,0x0AD4,0x11CE,{0xB0,0x3A,0x00,0x20,0xAF,0x0B,0xA7,0x70}}; 
  81 const IID IID_IMediaEventEx 
= {0x56A868C0,0x0AD4,0x11CE,{0xB0,0x3A,0x00,0x20,0xAF,0x0B,0xA7,0x70}}; 
  82 const IID IID_IMediaPosition 
= {0x56A868B2,0x0AD4,0x11CE,{0xB0,0x3A,0x00,0x20,0xAF,0x0B,0xA7,0x70}}; 
  83 const IID IID_IBasicAudio 
= {0x56A868B3,0x0AD4,0x11CE,{0xB0,0x3A,0x00,0x20,0xAF,0x0B,0xA7,0x70}}; 
  84 const IID IID_IVideoWindow 
= {0x56A868B4,0x0AD4,0x11CE,{0xB0,0x3A,0x00,0x20,0xAF,0x0B,0xA7,0x70}}; 
  85 const IID IID_IBasicVideo 
= {0x56A868B5,0x0AD4,0x11CE,{0xB0,0x3A,0x00,0x20,0xAF,0x0B,0xA7,0x70}}; 
  86 const IID IID_IBasicVideo2 
= {0x329BB360,0xF6EA,0x11D1,{0x90,0x38,0x00,0xA0,0xC9,0x69,0x72,0x98}}; 
  87 const IID IID_IDeferredCommand 
= {0x56A868B8,0x0AD4,0x11CE,{0xB0,0x3A,0x00,0x20,0xAF,0x0B,0xA7,0x70}}; 
  88 const IID IID_IQueueCommand 
= {0x56A868B7,0x0AD4,0x11CE,{0xB0,0x3A,0x00,0x20,0xAF,0x0B,0xA7,0x70}}; 
  89 const IID IID_IFilterInfo 
= {0x56A868BA,0x0AD4,0x11CE,{0xB0,0x3A,0x00,0x20,0xAF,0x0B,0xA7,0x70}}; 
  90 const IID IID_IRegFilterInfo 
= {0x56A868BB,0x0AD4,0x11CE,{0xB0,0x3A,0x00,0x20,0xAF,0x0B,0xA7,0x70}}; 
  91 const IID IID_IMediaTypeInfo 
= {0x56A868BC,0x0AD4,0x11CE,{0xB0,0x3A,0x00,0x20,0xAF,0x0B,0xA7,0x70}}; 
  92 const IID IID_IPinInfo 
= {0x56A868BD,0x0AD4,0x11CE,{0xB0,0x3A,0x00,0x20,0xAF,0x0B,0xA7,0x70}}; 
  93 const IID IID_IAMStats 
= {0xBC9BCF80,0xDCD2,0x11D2,{0xAB,0xF6,0x00,0xA0,0xC9,0x05,0xF3,0x75}}; 
  95 //TODO:  These 4 lines needed? 
  99 #endif // CLSID_DEFINED 
 102 const CLSID CLSID_FilgraphManager 
= {0xE436EBB3,0x524F,0x11CE,{0x9F,0x53,0x00,0x20,0xAF,0x0B,0xA7,0x70}}; 
 104 //--------------------------------------------------------------------------- 
 105 //  COM INTERFACES (dumped from midl from quartz.idl from MSVC COM Browser) 
 106 //--------------------------------------------------------------------------- 
 107 MIDL_INTERFACE("56A868B9-0AD4-11CE-B03A-0020AF0BA770") 
 108 IAMCollection 
: public IDispatch
 
 111     virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE 
get_Count(  
 112         /* [retval][out] */ long __RPC_FAR 
*plCount
) = 0; 
 114     virtual /* [id] */ HRESULT STDMETHODCALLTYPE 
Item(  
 115         /* [in] */ long lItem
, 
 116         /* [out] */ IUnknown __RPC_FAR 
*__RPC_FAR 
*ppUnk
) = 0; 
 118     virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE 
get__NewEnum(  
 119         /* [retval][out] */ IUnknown __RPC_FAR 
*__RPC_FAR 
*ppUnk
) = 0; 
 123 MIDL_INTERFACE("56A868B1-0AD4-11CE-B03A-0020AF0BA770") 
 124 IMediaControl 
: public IDispatch
 
 127     virtual /* [id] */ HRESULT STDMETHODCALLTYPE 
Run( void) = 0; 
 129     virtual /* [id] */ HRESULT STDMETHODCALLTYPE 
Pause( void) = 0; 
 131     virtual /* [id] */ HRESULT STDMETHODCALLTYPE 
Stop( void) = 0; 
 133     virtual /* [id] */ HRESULT STDMETHODCALLTYPE 
GetState(  
 134         /* [in] */ long msTimeout
, 
 135         /* [out] */ long __RPC_FAR 
*pfs
) = 0; 
 137     virtual /* [id] */ HRESULT STDMETHODCALLTYPE 
RenderFile(  
 138         /* [in] */ BSTR strFilename
) = 0; 
 140     virtual /* [id] */ HRESULT STDMETHODCALLTYPE 
AddSourceFilter(  
 141         /* [in] */ BSTR strFilename
, 
 142         /* [out] */ IDispatch __RPC_FAR 
*__RPC_FAR 
*ppUnk
) = 0; 
 144     virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE 
get_FilterCollection(  
 145         /* [retval][out] */ IDispatch __RPC_FAR 
*__RPC_FAR 
*ppUnk
) = 0; 
 147     virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE 
get_RegFilterCollection(  
 148         /* [retval][out] */ IDispatch __RPC_FAR 
*__RPC_FAR 
*ppUnk
) = 0; 
 150     virtual /* [id] */ HRESULT STDMETHODCALLTYPE 
StopWhenReady( void) = 0; 
 154 MIDL_INTERFACE("56A868B6-0AD4-11CE-B03A-0020AF0BA770") 
 155 IMediaEvent 
: public IDispatch
 
 158     virtual /* [id] */ HRESULT STDMETHODCALLTYPE 
GetEventHandle(  
 159         /* [out] */ LONG_PTR __RPC_FAR 
*hEvent
) = 0; 
 161     virtual /* [id] */ HRESULT STDMETHODCALLTYPE 
GetEvent(  
 162         /* [out] */ long __RPC_FAR 
*lEventCode
, 
 163         /* [out] */ LONG_PTR __RPC_FAR 
*lParam1
, 
 164         /* [out] */ LONG_PTR __RPC_FAR 
*lParam2
, 
 165         /* [in] */ long msTimeout
) = 0; 
 167     virtual /* [id] */ HRESULT STDMETHODCALLTYPE 
WaitForCompletion(  
 168         /* [in] */ long msTimeout
, 
 169         /* [out] */ long __RPC_FAR 
*pEvCode
) = 0; 
 171     virtual /* [id] */ HRESULT STDMETHODCALLTYPE 
CancelDefaultHandling(  
 172         /* [in] */ long lEvCode
) = 0; 
 174     virtual /* [id] */ HRESULT STDMETHODCALLTYPE 
RestoreDefaultHandling(  
 175         /* [in] */ long lEvCode
) = 0; 
 177     virtual /* [id] */ HRESULT STDMETHODCALLTYPE 
FreeEventParams(  
 178         /* [in] */ long lEvCode
, 
 179         /* [in] */ LONG_PTR lParam1
, 
 180         /* [in] */ LONG_PTR lParam2
) = 0; 
 184 MIDL_INTERFACE("56A868C0-0AD4-11CE-B03A-0020AF0BA770") 
 185 IMediaEventEx 
: public IMediaEvent
 
 188     virtual HRESULT __stdcall 
SetNotifyWindow(  
 189         /* [in] */ LONG_PTR hwnd
, 
 190         /* [in] */ long lMsg
, 
 191         /* [in] */ LONG_PTR lInstanceData
) = 0; 
 193     virtual HRESULT __stdcall 
SetNotifyFlags(  
 194         /* [in] */ long lNoNotifyFlags
) = 0; 
 196     virtual HRESULT __stdcall 
GetNotifyFlags(  
 197         /* [out] */ long __RPC_FAR 
*lplNoNotifyFlags
) = 0; 
 201 MIDL_INTERFACE("56A868B2-0AD4-11CE-B03A-0020AF0BA770") 
 202 IMediaPosition 
: public IDispatch
 
 205     virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE 
get_Duration(  
 206         /* [retval][out] */ double __RPC_FAR 
*plength
) = 0; 
 208     virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE 
put_CurrentPosition(  
 209         /* [in] */ double pllTime
) = 0; 
 211     virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE 
get_CurrentPosition(  
 212         /* [retval][out] */ double __RPC_FAR 
*pllTime
) = 0; 
 214     virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE 
get_StopTime(  
 215         /* [retval][out] */ double __RPC_FAR 
*pllTime
) = 0; 
 217     virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE 
put_StopTime(  
 218         /* [in] */ double pllTime
) = 0; 
 220     virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE 
get_PrerollTime(  
 221         /* [retval][out] */ double __RPC_FAR 
*pllTime
) = 0; 
 223     virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE 
put_PrerollTime(  
 224         /* [in] */ double pllTime
) = 0; 
 226     virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE 
put_Rate(  
 227         /* [in] */ double pdRate
) = 0; 
 229     virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE 
get_Rate(  
 230         /* [retval][out] */ double __RPC_FAR 
*pdRate
) = 0; 
 232     virtual /* [id] */ HRESULT STDMETHODCALLTYPE 
CanSeekForward(  
 233         /* [retval][out] */ long __RPC_FAR 
*pCanSeekForward
) = 0; 
 235     virtual /* [id] */ HRESULT STDMETHODCALLTYPE 
CanSeekBackward(  
 236         /* [retval][out] */ long __RPC_FAR 
*pCanSeekBackward
) = 0; 
 240 MIDL_INTERFACE("56A868B3-0AD4-11CE-B03A-0020AF0BA770") 
 241 IBasicAudio 
: public IDispatch
 
 244     virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE 
put_Volume(  
 245         /* [in] */ long plVolume
) = 0; 
 247     virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE 
get_Volume(  
 248         /* [retval][out] */ long __RPC_FAR 
*plVolume
) = 0; 
 250     virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE 
put_Balance(  
 251         /* [in] */ long plBalance
) = 0; 
 253     virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE 
get_Balance(  
 254         /* [retval][out] */ long __RPC_FAR 
*plBalance
) = 0; 
 258 MIDL_INTERFACE("56A868B4-0AD4-11CE-B03A-0020AF0BA770") 
 259 IVideoWindow 
: public IDispatch
 
 262     virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE 
put_Caption(  
 263         /* [in] */ BSTR strCaption
) = 0; 
 265     virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE 
get_Caption(  
 266         /* [retval][out] */ BSTR __RPC_FAR 
*strCaption
) = 0; 
 268     virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE 
put_WindowStyle(  
 269         /* [in] */ long WindowStyle
) = 0; 
 271     virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE 
get_WindowStyle(  
 272         /* [retval][out] */ long __RPC_FAR 
*WindowStyle
) = 0; 
 274     virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE 
put_WindowStyleEx(  
 275         /* [in] */ long WindowStyleEx
) = 0; 
 277     virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE 
get_WindowStyleEx(  
 278         /* [retval][out] */ long __RPC_FAR 
*WindowStyleEx
) = 0; 
 280     virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE 
put_AutoShow(  
 281         /* [in] */ long AutoShow
) = 0; 
 283     virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE 
get_AutoShow(  
 284         /* [retval][out] */ long __RPC_FAR 
*AutoShow
) = 0; 
 286     virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE 
put_WindowState(  
 287         /* [in] */ long WindowState
) = 0; 
 289     virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE 
get_WindowState(  
 290         /* [retval][out] */ long __RPC_FAR 
*WindowState
) = 0; 
 292     virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE 
put_BackgroundPalette(  
 293         /* [in] */ long pBackgroundPalette
) = 0; 
 295     virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE 
get_BackgroundPalette(  
 296         /* [retval][out] */ long __RPC_FAR 
*pBackgroundPalette
) = 0; 
 298     virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE 
put_Visible(  
 299         /* [in] */ long pVisible
) = 0; 
 301     virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE 
get_Visible(  
 302         /* [retval][out] */ long __RPC_FAR 
*pVisible
) = 0; 
 304     virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE 
put_Left(  
 305         /* [in] */ long pLeft
) = 0; 
 307     virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE 
get_Left(  
 308         /* [retval][out] */ long __RPC_FAR 
*pLeft
) = 0; 
 310     virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE 
put_Width(  
 311         /* [in] */ long pWidth
) = 0; 
 313     virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE 
get_Width(  
 314         /* [retval][out] */ long __RPC_FAR 
*pWidth
) = 0; 
 316     virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE 
put_Top(  
 317         /* [in] */ long pTop
) = 0; 
 319     virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE 
get_Top(  
 320         /* [retval][out] */ long __RPC_FAR 
*pTop
) = 0; 
 322     virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE 
put_Height(  
 323         /* [in] */ long pHeight
) = 0; 
 325     virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE 
get_Height(  
 326         /* [retval][out] */ long __RPC_FAR 
*pHeight
) = 0; 
 328     virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE 
put_Owner(  
 329         /* [in] */ LONG_PTR Owner
) = 0; 
 331     virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE 
get_Owner(  
 332         /* [retval][out] */ LONG_PTR __RPC_FAR 
*Owner
) = 0; 
 334     virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE 
put_MessageDrain(  
 335         /* [in] */ LONG_PTR Drain
) = 0; 
 337     virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE 
get_MessageDrain(  
 338         /* [retval][out] */ LONG_PTR __RPC_FAR 
*Drain
) = 0; 
 340     virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE 
get_BorderColor(  
 341         /* [retval][out] */ long __RPC_FAR 
*Color
) = 0; 
 343     virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE 
put_BorderColor(  
 344         /* [in] */ long Color
) = 0; 
 346     virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE 
get_FullScreenMode(  
 347         /* [retval][out] */ long __RPC_FAR 
*FullScreenMode
) = 0; 
 349     virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE 
put_FullScreenMode(  
 350         /* [in] */ long FullScreenMode
) = 0; 
 352     virtual /* [id] */ HRESULT STDMETHODCALLTYPE 
SetWindowForeground(  
 353         /* [in] */ long Focus
) = 0; 
 355     virtual /* [id] */ HRESULT STDMETHODCALLTYPE 
NotifyOwnerMessage(  
 356         /* [in] */ LONG_PTR hwnd
, 
 357         /* [in] */ long uMsg
, 
 358         /* [in] */ LONG_PTR wParam
, 
 359         /* [in] */ LONG_PTR lParam
) = 0; 
 361     virtual /* [id] */ HRESULT STDMETHODCALLTYPE 
SetWindowPosition(  
 362         /* [in] */ long Left
, 
 364         /* [in] */ long Width
, 
 365         /* [in] */ long Height
) = 0; 
 367     virtual /* [id] */ HRESULT STDMETHODCALLTYPE 
GetWindowPosition(  
 368         /* [out] */ long __RPC_FAR 
*pLeft
, 
 369         /* [out] */ long __RPC_FAR 
*pTop
, 
 370         /* [out] */ long __RPC_FAR 
*pWidth
, 
 371         /* [out] */ long __RPC_FAR 
*pHeight
) = 0; 
 373     virtual /* [id] */ HRESULT STDMETHODCALLTYPE 
GetMinIdealImageSize(  
 374         /* [out] */ long __RPC_FAR 
*pWidth
, 
 375         /* [out] */ long __RPC_FAR 
*pHeight
) = 0; 
 377     virtual /* [id] */ HRESULT STDMETHODCALLTYPE 
GetMaxIdealImageSize(  
 378         /* [out] */ long __RPC_FAR 
*pWidth
, 
 379         /* [out] */ long __RPC_FAR 
*pHeight
) = 0; 
 381     virtual /* [id] */ HRESULT STDMETHODCALLTYPE 
GetRestorePosition(  
 382         /* [out] */ long __RPC_FAR 
*pLeft
, 
 383         /* [out] */ long __RPC_FAR 
*pTop
, 
 384         /* [out] */ long __RPC_FAR 
*pWidth
, 
 385         /* [out] */ long __RPC_FAR 
*pHeight
) = 0; 
 387     virtual /* [id] */ HRESULT STDMETHODCALLTYPE 
HideCursor(  
 388         /* [in] */ long HideCursor
) = 0; 
 390     virtual /* [id] */ HRESULT STDMETHODCALLTYPE 
IsCursorHidden(  
 391         /* [out] */ long __RPC_FAR 
*CursorHidden
) = 0; 
 395 MIDL_INTERFACE("56A868B5-0AD4-11CE-B03A-0020AF0BA770") 
 396 IBasicVideo 
: public IDispatch
 
 399     virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE 
get_AvgTimePerFrame(  
 400         /* [retval][out] */ double __RPC_FAR 
*pAvgTimePerFrame
) = 0; 
 402     virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE 
get_BitRate(  
 403         /* [retval][out] */ long __RPC_FAR 
*pBitRate
) = 0; 
 405     virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE 
get_BitErrorRate(  
 406         /* [retval][out] */ long __RPC_FAR 
*pBitErrorRate
) = 0; 
 408     virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE 
get_VideoWidth(  
 409         /* [retval][out] */ long __RPC_FAR 
*pVideoWidth
) = 0; 
 411     virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE 
get_VideoHeight(  
 412         /* [retval][out] */ long __RPC_FAR 
*pVideoHeight
) = 0; 
 414     virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE 
put_SourceLeft(  
 415         /* [in] */ long pSourceLeft
) = 0; 
 417     virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE 
get_SourceLeft(  
 418         /* [retval][out] */ long __RPC_FAR 
*pSourceLeft
) = 0; 
 420     virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE 
put_SourceWidth(  
 421         /* [in] */ long pSourceWidth
) = 0; 
 423     virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE 
get_SourceWidth(  
 424         /* [retval][out] */ long __RPC_FAR 
*pSourceWidth
) = 0; 
 426     virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE 
put_SourceTop(  
 427         /* [in] */ long pSourceTop
) = 0; 
 429     virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE 
get_SourceTop(  
 430         /* [retval][out] */ long __RPC_FAR 
*pSourceTop
) = 0; 
 432     virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE 
put_SourceHeight(  
 433         /* [in] */ long pSourceHeight
) = 0; 
 435     virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE 
get_SourceHeight(  
 436         /* [retval][out] */ long __RPC_FAR 
*pSourceHeight
) = 0; 
 438     virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE 
put_DestinationLeft(  
 439         /* [in] */ long pDestinationLeft
) = 0; 
 441     virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE 
get_DestinationLeft(  
 442         /* [retval][out] */ long __RPC_FAR 
*pDestinationLeft
) = 0; 
 444     virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE 
put_DestinationWidth(  
 445         /* [in] */ long pDestinationWidth
) = 0; 
 447     virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE 
get_DestinationWidth(  
 448         /* [retval][out] */ long __RPC_FAR 
*pDestinationWidth
) = 0; 
 450     virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE 
put_DestinationTop(  
 451         /* [in] */ long pDestinationTop
) = 0; 
 453     virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE 
get_DestinationTop(  
 454         /* [retval][out] */ long __RPC_FAR 
*pDestinationTop
) = 0; 
 456     virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE 
put_DestinationHeight(  
 457         /* [in] */ long pDestinationHeight
) = 0; 
 459     virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE 
get_DestinationHeight(  
 460         /* [retval][out] */ long __RPC_FAR 
*pDestinationHeight
) = 0; 
 462     virtual /* [id] */ HRESULT STDMETHODCALLTYPE 
SetSourcePosition(  
 463         /* [in] */ long Left
, 
 465         /* [in] */ long Width
, 
 466         /* [in] */ long Height
) = 0; 
 468     virtual /* [id] */ HRESULT STDMETHODCALLTYPE 
GetSourcePosition(  
 469         /* [out] */ long __RPC_FAR 
*pLeft
, 
 470         /* [out] */ long __RPC_FAR 
*pTop
, 
 471         /* [out] */ long __RPC_FAR 
*pWidth
, 
 472         /* [out] */ long __RPC_FAR 
*pHeight
) = 0; 
 474     virtual /* [id] */ HRESULT STDMETHODCALLTYPE 
SetDefaultSourcePosition( void) = 0; 
 476     virtual /* [id] */ HRESULT STDMETHODCALLTYPE 
SetDestinationPosition(  
 477         /* [in] */ long Left
, 
 479         /* [in] */ long Width
, 
 480         /* [in] */ long Height
) = 0; 
 482     virtual /* [id] */ HRESULT STDMETHODCALLTYPE 
GetDestinationPosition(  
 483         /* [out] */ long __RPC_FAR 
*pLeft
, 
 484         /* [out] */ long __RPC_FAR 
*pTop
, 
 485         /* [out] */ long __RPC_FAR 
*pWidth
, 
 486         /* [out] */ long __RPC_FAR 
*pHeight
) = 0; 
 488     virtual /* [id] */ HRESULT STDMETHODCALLTYPE 
SetDefaultDestinationPosition( void) = 0; 
 490     virtual /* [id] */ HRESULT STDMETHODCALLTYPE 
GetVideoSize(  
 491         /* [out] */ long __RPC_FAR 
*pWidth
, 
 492         /* [out] */ long __RPC_FAR 
*pHeight
) = 0; 
 494     virtual /* [id] */ HRESULT STDMETHODCALLTYPE 
GetVideoPaletteEntries(  
 495         /* [in] */ long StartIndex
, 
 496         /* [in] */ long Entries
, 
 497         /* [out] */ long __RPC_FAR 
*pRetrieved
, 
 498         /* [out] */ long __RPC_FAR 
*pPalette
) = 0; 
 500     virtual /* [id] */ HRESULT STDMETHODCALLTYPE 
GetCurrentImage(  
 501         /* [out][in] */ long __RPC_FAR 
*pBufferSize
, 
 502         /* [out] */ long __RPC_FAR 
*pDIBImage
) = 0; 
 504     virtual /* [id] */ HRESULT STDMETHODCALLTYPE 
IsUsingDefaultSource( void) = 0; 
 506     virtual /* [id] */ HRESULT STDMETHODCALLTYPE 
IsUsingDefaultDestination( void) = 0; 
 510 MIDL_INTERFACE("329BB360-F6EA-11D1-9038-00A0C9697298") 
 511 IBasicVideo2 
: public IBasicVideo
 
 514     virtual HRESULT __stdcall 
GetPreferredAspectRatio(  
 515         /* [out] */ long __RPC_FAR 
*plAspectX
, 
 516         /* [out] */ long __RPC_FAR 
*plAspectY
) = 0; 
 520 MIDL_INTERFACE("56A868B8-0AD4-11CE-B03A-0020AF0BA770") 
 521 IDeferredCommand 
: public IUnknown
 
 524     virtual HRESULT __stdcall 
Cancel( void) = 0; 
 526     virtual HRESULT __stdcall 
Confidence(  
 527         /* [out] */ long __RPC_FAR 
*pConfidence
) = 0; 
 529     virtual HRESULT __stdcall 
Postpone(  
 530         /* [in] */ double newtime
) = 0; 
 532     virtual HRESULT __stdcall 
GetHResult(  
 533         /* [out] */ HRESULT __RPC_FAR 
*phrResult
) = 0; 
 537 MIDL_INTERFACE("56A868B7-0AD4-11CE-B03A-0020AF0BA770") 
 538 IQueueCommand 
: public IUnknown
 
 541     virtual HRESULT __stdcall 
InvokeAtStreamTime(  
 542         /* [out] */ IDeferredCommand __RPC_FAR 
*__RPC_FAR 
*pCmd
, 
 543         /* [in] */ double time
, 
 544         /* [in] */ GUID __RPC_FAR 
*iid
, 
 545         /* [in] */ long dispidMethod
, 
 546         /* [in] */ short wFlags
, 
 547         /* [in] */ long cArgs
, 
 548         /* [in] */ VARIANT __RPC_FAR 
*pDispParams
, 
 549         /* [out][in] */ VARIANT __RPC_FAR 
*pvarResult
, 
 550         /* [out] */ short __RPC_FAR 
*puArgErr
) = 0; 
 552     virtual HRESULT __stdcall 
InvokeAtPresentationTime(  
 553         /* [out] */ IDeferredCommand __RPC_FAR 
*__RPC_FAR 
*pCmd
, 
 554         /* [in] */ double time
, 
 555         /* [in] */ GUID __RPC_FAR 
*iid
, 
 556         /* [in] */ long dispidMethod
, 
 557         /* [in] */ short wFlags
, 
 558         /* [in] */ long cArgs
, 
 559         /* [in] */ VARIANT __RPC_FAR 
*pDispParams
, 
 560         /* [out][in] */ VARIANT __RPC_FAR 
*pvarResult
, 
 561         /* [out] */ short __RPC_FAR 
*puArgErr
) = 0; 
 565 MIDL_INTERFACE("56A868BA-0AD4-11CE-B03A-0020AF0BA770") 
 566 IFilterInfo 
: public IDispatch
 
 569     virtual /* [id] */ HRESULT STDMETHODCALLTYPE 
FindPin(  
 570         /* [in] */ BSTR strPinID
, 
 571         /* [out] */ IDispatch __RPC_FAR 
*__RPC_FAR 
*ppUnk
) = 0; 
 573     virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE 
get_Name(  
 574         /* [retval][out] */ BSTR __RPC_FAR 
*strName
) = 0; 
 576     virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE 
get_VendorInfo(  
 577         /* [retval][out] */ BSTR __RPC_FAR 
*strVendorInfo
) = 0; 
 579     virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE 
get_Filter(  
 580         /* [retval][out] */ IUnknown __RPC_FAR 
*__RPC_FAR 
*ppUnk
) = 0; 
 582     virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE 
get_Pins(  
 583         /* [retval][out] */ IDispatch __RPC_FAR 
*__RPC_FAR 
*ppUnk
) = 0; 
 585     virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE 
get_IsFileSource(  
 586         /* [retval][out] */ long __RPC_FAR 
*pbIsSource
) = 0; 
 588     virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE 
get_Filename(  
 589         /* [retval][out] */ BSTR __RPC_FAR 
*pstrFilename
) = 0; 
 591     virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE 
put_Filename(  
 592         /* [in] */ BSTR pstrFilename
) = 0; 
 596 MIDL_INTERFACE("56A868BB-0AD4-11CE-B03A-0020AF0BA770") 
 597 IRegFilterInfo 
: public IDispatch
 
 600     virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE 
get_Name(  
 601         /* [retval][out] */ BSTR __RPC_FAR 
*strName
) = 0; 
 603     virtual /* [id] */ HRESULT STDMETHODCALLTYPE 
Filter(  
 604         /* [out] */ IDispatch __RPC_FAR 
*__RPC_FAR 
*ppUnk
) = 0; 
 608 MIDL_INTERFACE("56A868BC-0AD4-11CE-B03A-0020AF0BA770") 
 609 IMediaTypeInfo 
: public IDispatch
 
 612     virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE 
get_Type(  
 613         /* [retval][out] */ BSTR __RPC_FAR 
*strType
) = 0; 
 615     virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE 
get_Subtype(  
 616         /* [retval][out] */ BSTR __RPC_FAR 
*strType
) = 0; 
 620 MIDL_INTERFACE("56A868BD-0AD4-11CE-B03A-0020AF0BA770") 
 621 IPinInfo 
: public IDispatch
 
 624     virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE 
get_Pin(  
 625         /* [retval][out] */ IUnknown __RPC_FAR 
*__RPC_FAR 
*ppUnk
) = 0; 
 627     virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE 
get_ConnectedTo(  
 628         /* [retval][out] */ IDispatch __RPC_FAR 
*__RPC_FAR 
*ppUnk
) = 0; 
 630     virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE 
get_ConnectionMediaType(  
 631         /* [retval][out] */ IDispatch __RPC_FAR 
*__RPC_FAR 
*ppUnk
) = 0; 
 633     virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE 
get_FilterInfo(  
 634         /* [retval][out] */ IDispatch __RPC_FAR 
*__RPC_FAR 
*ppUnk
) = 0; 
 636     virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE 
get_Name(  
 637         /* [retval][out] */ BSTR __RPC_FAR 
*ppUnk
) = 0; 
 639     virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE 
get_Direction(  
 640         /* [retval][out] */ long __RPC_FAR 
*ppDirection
) = 0; 
 642     virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE 
get_PinID(  
 643         /* [retval][out] */ BSTR __RPC_FAR 
*strPinID
) = 0; 
 645     virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE 
get_MediaTypes(  
 646         /* [retval][out] */ IDispatch __RPC_FAR 
*__RPC_FAR 
*ppUnk
) = 0; 
 648     virtual /* [id] */ HRESULT STDMETHODCALLTYPE 
Connect(  
 649         /* [in] */ IUnknown __RPC_FAR 
*pPin
) = 0; 
 651     virtual /* [id] */ HRESULT STDMETHODCALLTYPE 
ConnectDirect(  
 652         /* [in] */ IUnknown __RPC_FAR 
*pPin
) = 0; 
 654     virtual /* [id] */ HRESULT STDMETHODCALLTYPE 
ConnectWithType(  
 655         /* [in] */ IUnknown __RPC_FAR 
*pPin
, 
 656         /* [in] */ IDispatch __RPC_FAR 
*pMediaType
) = 0; 
 658     virtual /* [id] */ HRESULT STDMETHODCALLTYPE 
Disconnect( void) = 0; 
 660     virtual /* [id] */ HRESULT STDMETHODCALLTYPE 
Render( void) = 0; 
 664 MIDL_INTERFACE("BC9BCF80-DCD2-11D2-ABF6-00A0C905F375") 
 665 IAMStats 
: public IDispatch
 
 668     virtual /* [id] */ HRESULT STDMETHODCALLTYPE 
Reset( void) = 0; 
 670     virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE 
get_Count(  
 671         /* [retval][out] */ long __RPC_FAR 
*plCount
) = 0; 
 673     virtual /* [id] */ HRESULT STDMETHODCALLTYPE 
GetValueByIndex(  
 674         /* [in] */ long lIndex
, 
 675         /* [out] */ BSTR __RPC_FAR 
*szName
, 
 676         /* [out] */ long __RPC_FAR 
*lCount
, 
 677         /* [out] */ double __RPC_FAR 
*dLast
, 
 678         /* [out] */ double __RPC_FAR 
*dAverage
, 
 679         /* [out] */ double __RPC_FAR 
*dStdDev
, 
 680         /* [out] */ double __RPC_FAR 
*dMin
, 
 681         /* [out] */ double __RPC_FAR 
*dMax
) = 0; 
 683     virtual /* [id] */ HRESULT STDMETHODCALLTYPE 
GetValueByName(  
 684         /* [in] */ BSTR szName
, 
 685         /* [out] */ long __RPC_FAR 
*lIndex
, 
 686         /* [out] */ long __RPC_FAR 
*lCount
, 
 687         /* [out] */ double __RPC_FAR 
*dLast
, 
 688         /* [out] */ double __RPC_FAR 
*dAverage
, 
 689         /* [out] */ double __RPC_FAR 
*dStdDev
, 
 690         /* [out] */ double __RPC_FAR 
*dMin
, 
 691         /* [out] */ double __RPC_FAR 
*dMax
) = 0; 
 693     virtual /* [id] */ HRESULT STDMETHODCALLTYPE 
GetIndex(  
 694         /* [in] */ BSTR szName
, 
 695         /* [in] */ long lCreate
, 
 696         /* [out] */ long __RPC_FAR 
*plIndex
) = 0; 
 698     virtual /* [id] */ HRESULT STDMETHODCALLTYPE 
AddValue(  
 699         /* [in] */ long lIndex
, 
 700         /* [in] */ double dValue
) = 0; 
 704 //------------------------------------------------------------------ 
 705 // wxAMMediaBackend (Active Movie) 
 706 //------------------------------------------------------------------ 
 707 class WXDLLIMPEXP_MEDIA wxAMMediaBackend 
: public wxMediaBackend
 
 712     virtual ~wxAMMediaBackend(); 
 714     virtual bool CreateControl(wxControl
* ctrl
, wxWindow
* parent
, 
 719                                      const wxValidator
& validator
, 
 720                                      const wxString
& name
); 
 723     virtual bool Pause(); 
 726     virtual bool Load(const wxString
& fileName
); 
 727     virtual bool Load(const wxURI
& location
); 
 729     virtual wxMediaState 
GetState(); 
 731     virtual bool SetPosition(wxLongLong where
); 
 732     virtual wxLongLong 
GetPosition(); 
 733     virtual wxLongLong 
GetDuration(); 
 735     virtual void Move(int x
, int y
, int w
, int h
); 
 736     wxSize 
GetVideoSize() const; 
 738     virtual double GetPlaybackRate(); 
 739     virtual bool SetPlaybackRate(double); 
 741     virtual double GetVolume(); 
 742     virtual bool SetVolume(double); 
 748     static LRESULT CALLBACK 
NotifyWndProc(HWND hWnd
, UINT nMsg
, 
 749                                           WPARAM wParam
, LPARAM lParam
); 
 751     LRESULT CALLBACK 
OnNotifyWndProc(HWND hWnd
, UINT nMsg
, 
 752                                           WPARAM wParam
, LPARAM lParam
); 
 758     IMediaControl
* m_pMC
; 
 759     IMediaEventEx
* m_pME
; 
 760     IMediaPosition
* m_pMS
; 
 766     DECLARE_DYNAMIC_CLASS(wxAMMediaBackend
); 
 769 #endif //wxUSE_DIRECTSHOW 
 771 //--------------------------------------------------------------------------- 
 775 //--------------------------------------------------------------------------- 
 777 //--------------------------------------------------------------------------- 
 779 //--------------------------------------------------------------------------- 
 780 #include <mmsystem.h> 
 782 class WXDLLIMPEXP_MEDIA wxMCIMediaBackend 
: public wxMediaBackend
 
 787     ~wxMCIMediaBackend(); 
 789     virtual bool CreateControl(wxControl
* ctrl
, wxWindow
* parent
, 
 794                                      const wxValidator
& validator
, 
 795                                      const wxString
& name
); 
 798     virtual bool Pause(); 
 801     virtual bool Load(const wxString
& fileName
); 
 802     virtual bool Load(const wxURI
& location
); 
 804     virtual wxMediaState 
GetState(); 
 806     virtual bool SetPosition(wxLongLong where
); 
 807     virtual wxLongLong 
GetPosition(); 
 808     virtual wxLongLong 
GetDuration(); 
 810     virtual void Move(int x
, int y
, int w
, int h
); 
 811     wxSize 
GetVideoSize() const; 
 813     virtual double GetPlaybackRate(); 
 814     virtual bool SetPlaybackRate(double dRate
); 
 816     virtual double GetVolume(); 
 817     virtual bool SetVolume(double); 
 819     static LRESULT CALLBACK 
NotifyWndProc(HWND hWnd
, UINT nMsg
, 
 820                                              WPARAM wParam
, LPARAM lParam
); 
 822     LRESULT CALLBACK 
OnNotifyWndProc(HWND hWnd
, UINT nMsg
, 
 823                                      WPARAM wParam
, LPARAM lParam
); 
 825     MCIDEVICEID m_hDev
;     //Our MCI Device ID/Handler 
 826     wxControl
* m_ctrl
;      //Parent control 
 827     HWND m_hNotifyWnd
;      //Window to use for MCI events 
 828     bool m_bVideo
;          //Whether or not we have video 
 830     DECLARE_DYNAMIC_CLASS(wxMCIMediaBackend
) 
 833 //--------------------------------------------------------------------------- 
 837 //--------------------------------------------------------------------------- 
 839 //--------------------------------------------------------------------------- 
 840 //  QT Compilation Guard 
 841 //--------------------------------------------------------------------------- 
 844 //--------------------------------------------------------------------------- 
 846 //--------------------------------------------------------------------------- 
 847 //#include <qtml.h>                   //Windoze QT include 
 848 //#include <QuickTimeComponents.h>    //Standard QT stuff 
 849 #include "wx/dynlib.h" 
 851 //--------------------------------------------------------------------------- 
 853 //--------------------------------------------------------------------------- 
 854 typedef struct MovieRecord
* Movie
; 
 855 typedef wxInt16 OSErr
; 
 856 typedef wxInt32 OSStatus
; 
 859 typedef unsigned char                   Str255
[256]; 
 860 #define StringPtr unsigned char* 
 861 #define newMovieActive 1 
 865 #define OSType unsigned long 
 866 #define CGrafPtr struct GrafPort *                       
 867 #define TimeScale long 
 868 #define TimeBase struct TimeBaseRecord *                 
 873     Str255                           name
;  /*Str63 on mac, Str255 on msw */ 
 889     wide                  value
;                      /* units */ 
 890     TimeScale                       scale
;                      /* units per second */ 
 894 //--------------------------------------------------------------------------- 
 896 //--------------------------------------------------------------------------- 
 897 #define wxDL_METHOD_DEFINE( rettype, name, args, shortargs, defret ) \ 
 898     typedef rettype (* name ## Type) args ; \ 
 899     name ## Type pfn_ ## name; \ 
 901     { if (m_ok) return pfn_ ## name shortargs ; return defret; } 
 903 #define wxDL_VOIDMETHOD_DEFINE( name, args, shortargs ) \ 
 904     typedef void (* name ## Type) args ; \ 
 905     name ## Type pfn_ ## name; \ 
 907     { if (m_ok) pfn_ ## name shortargs ; } 
 909 #define wxDL_METHOD_LOAD( lib, name, success ) \ 
 910     pfn_ ## name = (name ## Type) lib.GetSymbol( wxT(#name), &success ); \ 
 911     if (!success) return false; 
 913 //Class that utilizes Robert Roeblings Dynamic Library Macros 
 914 class wxQuickTimeLibrary 
 
 917     ~wxQuickTimeLibrary() 
 924     bool IsOk() const {return m_ok
;} 
 927     wxDynamicLibrary m_dll
; 
 931     wxDL_VOIDMETHOD_DEFINE( StartMovie
, (Movie m
), (m
) ); 
 932     wxDL_VOIDMETHOD_DEFINE( StopMovie
, (Movie m
), (m
) ); 
 933     wxDL_METHOD_DEFINE( bool, IsMovieDone
, (Movie m
), (m
), false); 
 934     wxDL_VOIDMETHOD_DEFINE( GoToBeginningOfMovie
, (Movie m
), (m
) ); 
 935     wxDL_METHOD_DEFINE( OSErr
, GetMoviesError
, (), (), -1); 
 936     wxDL_METHOD_DEFINE( OSErr
, EnterMovies
, (), (), -1); 
 937     wxDL_VOIDMETHOD_DEFINE( ExitMovies
, (), () ); 
 938     wxDL_METHOD_DEFINE( OSErr
, InitializeQTML
, (long flags
), (flags
), -1); 
 939     wxDL_VOIDMETHOD_DEFINE( TerminateQTML
, (), () ); 
 941     wxDL_METHOD_DEFINE( OSErr
, NativePathNameToFSSpec
,  
 942                         (char* inName
, FSSpec
* outFile
, long flags
),  
 943                         (inName
, outFile
, flags
), -1); 
 945     wxDL_METHOD_DEFINE( OSErr
, OpenMovieFile
,  
 946                         (const FSSpec 
* fileSpec
, short * resRefNum
, wxInt8 permission
), 
 947                         (fileSpec
, resRefNum
, permission
), -1 ); 
 949     wxDL_METHOD_DEFINE( OSErr
, CloseMovieFile
, 
 950                         (short resRefNum
), (resRefNum
), -1); 
 952     wxDL_METHOD_DEFINE( OSErr
, NewMovieFromFile
, 
 953                             (Movie 
* theMovie
, short resRefNum
, short *  resId
, 
 954                              StringPtr resName
, short newMovieFlags
, 
 955                              bool * dataRefWasChanged
),  
 956                              (theMovie
, resRefNum
, resId
, resName
, newMovieFlags
, 
 957                               dataRefWasChanged
), -1); 
 959     wxDL_VOIDMETHOD_DEFINE( SetMovieRate
, (Movie m
, Fixed rate
), (m
, rate
) ); 
 960     wxDL_METHOD_DEFINE( Fixed
, GetMovieRate
, (Movie m
), (m
), 0); 
 961     wxDL_VOIDMETHOD_DEFINE( MoviesTask
, (Movie m
, long maxms
), (m
, maxms
) ); 
 962     wxDL_VOIDMETHOD_DEFINE( BlockMove
,  
 963         (const char* p1
, const char* p2
, long s
), (p1
,p2
,s
) ); 
 964     wxDL_METHOD_DEFINE( Handle
, NewHandleClear
, (long s
), (s
), NULL 
); 
 966     wxDL_METHOD_DEFINE( OSErr
, NewMovieFromDataRef
,  
 967                            (Movie 
* m
, short flags
, short * id
, 
 968                             Handle  dataRef
, OSType  dataRefType
), 
 969                             (m
,flags
,id
,dataRef
,dataRefType
), -1 ); 
 971     wxDL_VOIDMETHOD_DEFINE( DisposeHandle
, (Handle h
), (h
) ); 
 972     wxDL_VOIDMETHOD_DEFINE( GetMovieNaturalBoundsRect
, (Movie m
, Rect
* r
), (m
,r
) ); 
 973     wxDL_METHOD_DEFINE( void*, GetMovieIndTrackType
,  
 974                         (Movie m
, long index
, OSType type
, long flags
),  
 975                         (m
,index
,type
,flags
), NULL 
); 
 976     wxDL_VOIDMETHOD_DEFINE( CreatePortAssociation
,  
 977             (void* hWnd
, void* junk
, long morejunk
), (hWnd
, junk
, morejunk
) ); 
 978     wxDL_METHOD_DEFINE(void*, GetNativeWindowPort
, (void* hWnd
), (hWnd
), NULL
); 
 979     wxDL_VOIDMETHOD_DEFINE(SetMovieGWorld
, (Movie m
, CGrafPtr port
, void* whatever
), 
 980                             (m
, port
, whatever
) ); 
 981     wxDL_VOIDMETHOD_DEFINE(DisposeMovie
, (Movie m
), (m
) ); 
 982     wxDL_VOIDMETHOD_DEFINE(SetMovieBox
, (Movie m
, Rect
* r
), (m
,r
)); 
 983     wxDL_VOIDMETHOD_DEFINE(SetMovieTimeScale
, (Movie m
, long s
), (m
,s
)); 
 984     wxDL_METHOD_DEFINE(long, GetMovieDuration
, (Movie m
), (m
), 0); 
 985     wxDL_METHOD_DEFINE(TimeBase
, GetMovieTimeBase
, (Movie m
), (m
), 0); 
 986     wxDL_METHOD_DEFINE(TimeScale
, GetMovieTimeScale
, (Movie m
), (m
), 0); 
 987     wxDL_METHOD_DEFINE(long, GetMovieTime
, (Movie m
, void* cruft
), (m
,cruft
), 0); 
 988     wxDL_VOIDMETHOD_DEFINE(SetMovieTime
, (Movie m
, TimeRecord
* tr
), (m
,tr
) ); 
 989     wxDL_METHOD_DEFINE(short, GetMovieVolume
, (Movie m
), (m
), 0); 
 990     wxDL_VOIDMETHOD_DEFINE(SetMovieVolume
, (Movie m
, short sVolume
), (m
,sVolume
) ); 
 993 bool wxQuickTimeLibrary::Initialize() 
 997     if(!m_dll
.Load(wxT("qtmlClient.dll"))) 
1002     wxDL_METHOD_LOAD( m_dll
, StartMovie
, bOk 
); 
1003     wxDL_METHOD_LOAD( m_dll
, StopMovie
, bOk 
); 
1004     wxDL_METHOD_LOAD( m_dll
, IsMovieDone
, bOk 
); 
1005     wxDL_METHOD_LOAD( m_dll
, GoToBeginningOfMovie
, bOk 
); 
1006     wxDL_METHOD_LOAD( m_dll
, GetMoviesError
, bOk 
); 
1007     wxDL_METHOD_LOAD( m_dll
, EnterMovies
, bOk 
); 
1008     wxDL_METHOD_LOAD( m_dll
, ExitMovies
, bOk 
); 
1009     wxDL_METHOD_LOAD( m_dll
, InitializeQTML
, bOk 
); 
1010     wxDL_METHOD_LOAD( m_dll
, TerminateQTML
, bOk 
); 
1011     wxDL_METHOD_LOAD( m_dll
, NativePathNameToFSSpec
, bOk 
); 
1012     wxDL_METHOD_LOAD( m_dll
, OpenMovieFile
, bOk 
); 
1013     wxDL_METHOD_LOAD( m_dll
, CloseMovieFile
, bOk 
); 
1014     wxDL_METHOD_LOAD( m_dll
, NewMovieFromFile
, bOk 
); 
1015     wxDL_METHOD_LOAD( m_dll
, GetMovieRate
, bOk 
); 
1016     wxDL_METHOD_LOAD( m_dll
, SetMovieRate
, bOk 
); 
1017     wxDL_METHOD_LOAD( m_dll
, MoviesTask
, bOk 
); 
1018     wxDL_METHOD_LOAD( m_dll
, BlockMove
, bOk 
); 
1019     wxDL_METHOD_LOAD( m_dll
, NewHandleClear
, bOk 
); 
1020     wxDL_METHOD_LOAD( m_dll
, NewMovieFromDataRef
, bOk 
); 
1021     wxDL_METHOD_LOAD( m_dll
, DisposeHandle
, bOk 
); 
1022     wxDL_METHOD_LOAD( m_dll
, GetMovieNaturalBoundsRect
, bOk 
); 
1023     wxDL_METHOD_LOAD( m_dll
, GetMovieIndTrackType
, bOk 
); 
1024     wxDL_METHOD_LOAD( m_dll
, CreatePortAssociation
, bOk 
); 
1025     wxDL_METHOD_LOAD( m_dll
, GetNativeWindowPort
, bOk 
); 
1026     wxDL_METHOD_LOAD( m_dll
, SetMovieGWorld
, bOk 
); 
1027     wxDL_METHOD_LOAD( m_dll
, DisposeMovie
, bOk 
); 
1028     wxDL_METHOD_LOAD( m_dll
, SetMovieBox
, bOk 
); 
1029     wxDL_METHOD_LOAD( m_dll
, SetMovieTimeScale
, bOk 
); 
1030     wxDL_METHOD_LOAD( m_dll
, GetMovieDuration
, bOk 
); 
1031     wxDL_METHOD_LOAD( m_dll
, GetMovieTimeBase
, bOk 
); 
1032     wxDL_METHOD_LOAD( m_dll
, GetMovieTimeScale
, bOk 
); 
1033     wxDL_METHOD_LOAD( m_dll
, GetMovieTime
, bOk 
); 
1034     wxDL_METHOD_LOAD( m_dll
, SetMovieTime
, bOk 
); 
1035     wxDL_METHOD_LOAD( m_dll
, GetMovieVolume
, bOk 
); 
1036     wxDL_METHOD_LOAD( m_dll
, SetMovieVolume
, bOk 
); 
1043 class WXDLLIMPEXP_MEDIA wxQTMediaBackend 
: public wxMediaBackend
 
1048     ~wxQTMediaBackend(); 
1050     virtual bool CreateControl(wxControl
* ctrl
, wxWindow
* parent
, 
1055                                      const wxValidator
& validator
, 
1056                                      const wxString
& name
); 
1058     virtual bool Play(); 
1059     virtual bool Pause(); 
1060     virtual bool Stop(); 
1062     virtual bool Load(const wxString
& fileName
); 
1063     virtual bool Load(const wxURI
& location
); 
1065     virtual wxMediaState 
GetState(); 
1067     virtual bool SetPosition(wxLongLong where
); 
1068     virtual wxLongLong 
GetPosition(); 
1069     virtual wxLongLong 
GetDuration(); 
1071     virtual void Move(int x
, int y
, int w
, int h
); 
1072     wxSize 
GetVideoSize() const; 
1074     virtual double GetPlaybackRate(); 
1075     virtual bool SetPlaybackRate(double dRate
); 
1077     virtual double GetVolume(); 
1078     virtual bool SetVolume(double); 
1083     wxSize m_bestSize
;              //Original movie size 
1084     Movie m_movie
;    //QT Movie handle/instance 
1085     wxControl
* m_ctrl
;              //Parent control 
1086     bool m_bVideo
;                  //Whether or not we have video 
1087     class _wxQTTimer
* m_timer
;      //Timer for streaming the movie 
1088     wxQuickTimeLibrary m_lib
; 
1091     DECLARE_DYNAMIC_CLASS(wxQTMediaBackend
); 
1094 //--------------------------------------------------------------------------- 
1095 //  End QT Compilation Guard 
1096 //--------------------------------------------------------------------------- 
1097 #endif //wxUSE_QUICKTIME 
1099 //=========================================================================== 
1101 //=========================================================================== 
1103 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
1107 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
1109 //--------------------------------------------------------------------------- 
1110 // Only use if user wants it - 
1111 //--------------------------------------------------------------------------- 
1112 #if wxUSE_DIRECTSHOW 
1114 IMPLEMENT_DYNAMIC_CLASS(wxAMMediaBackend
, wxMediaBackend
); 
1116 // Numerical value for when the graph reaches the stop position 
1117 #define WM_GRAPHNOTIFY  WM_USER+13 
1119 //--------------------------------------------------------------------------- 
1120 // Usual debugging macros 
1121 //--------------------------------------------------------------------------- 
1123 #define wxAMVERIFY(x) \ 
1125     HRESULT hrdsv = (x); \ 
1126     if ( FAILED(hrdsv) ) \ 
1128         /*TCHAR szError[MAX_ERROR_TEXT_LEN];*/ \ 
1129         /*if( AMGetErrorText(hrdsv, szError, MAX_ERROR_TEXT_LEN) == 0)*/ \ 
1131             /*wxFAIL_MSG( wxString::Format(wxT("DirectShow error \"%s\" ")*/\ 
1132                                          /*wxT("occured at line %i in ")*/ \ 
1133                                          /*wxT("mediactrl.cpp"),*/ \ 
1134                                             /*szError, __LINE__) );*/ \ 
1137             wxFAIL_MSG( wxString::Format(wxT("Unknown error (%i) ") \ 
1139                                          wxT(" line %i in mediactrl.cpp."), \ 
1140                                          (int)hrdsv, __LINE__) ); \ 
1143 #define wxVERIFY(x) wxASSERT((x)) 
1145 #define wxAMVERIFY(x) (x) 
1146 #define wxVERIFY(x) (x) 
1149 //--------------------------------------------------------------------------- 
1150 // Standard macros for ease of use 
1151 //--------------------------------------------------------------------------- 
1152 #define SAFE_RELEASE(x) { if (x) x->Release(); x = NULL; } 
1154 //--------------------------------------------------------------------------- 
1155 // wxAMMediaBackend Constructor 
1157 // Sets m_hNotifyWnd to NULL to signify that we haven't loaded anything yet 
1158 //--------------------------------------------------------------------------- 
1159 wxAMMediaBackend::wxAMMediaBackend() : m_hNotifyWnd(NULL
) 
1163 //--------------------------------------------------------------------------- 
1164 // wxAMMediaBackend Destructor 
1166 // Cleans up everything 
1167 //--------------------------------------------------------------------------- 
1168 wxAMMediaBackend::~wxAMMediaBackend() 
1174 //--------------------------------------------------------------------------- 
1175 // wxAMMediaBackend::CreateControl 
1177 // ActiveMovie does not really have any native control to speak of, 
1178 // so we just create a normal control. 
1180 // We also check to see if ActiveMovie is installed 
1181 //--------------------------------------------------------------------------- 
1182 bool wxAMMediaBackend::CreateControl(wxControl
* ctrl
, wxWindow
* parent
, 
1187                                      const wxValidator
& validator
, 
1188                                      const wxString
& name
) 
1190     //create our filter graph - the beuty of COM is that it loads 
1191     //quartz.dll for us :) 
1192     HRESULT hr 
= CoCreateInstance(CLSID_FilgraphManager
, NULL
, CLSCTX_INPROC_SERVER
, 
1193                       IID_IMediaControl
, (void**)&m_pMC
); 
1195    //directshow not installed? 
1199     //release the filter graph - we don't need it yet 
1205     // By default wxWindow(s) is created with a border - 
1206     // so we need to get rid of those, and create with 
1207     // wxCLIP_CHILDREN, so that if the driver/backend 
1208     // is a child window, it refereshes properly 
1210     if ( !ctrl
->wxControl::Create(parent
, id
, pos
, size
, 
1211                             (style 
& ~wxBORDER_MASK
) | wxBORDER_NONE 
| wxCLIP_CHILDREN
, 
1220 //--------------------------------------------------------------------------- 
1221 // wxAMMediaBackend::Load (file version) 
1223 // Creates an Active Movie filter graph from a file or url 
1224 //--------------------------------------------------------------------------- 
1225 bool wxAMMediaBackend::Load(const wxString
& fileName
) 
1227     //if previously loaded cleanup 
1231     //We already checked for success in CreateControl 
1232     CoCreateInstance(CLSID_FilgraphManager
, NULL
, CLSCTX_INPROC_SERVER
, 
1233                       IID_IMediaControl
, (void**)&m_pMC
); 
1235     //load the graph & render 
1236     if( FAILED(m_pMC
->RenderFile(wxBasicString(fileName
).Get())) ) 
1239     //get the interfaces, all of them 
1240     wxAMVERIFY( m_pMC
->QueryInterface(IID_IMediaEventEx
, (void**)&m_pME
) ); 
1241     wxAMVERIFY( m_pMC
->QueryInterface(IID_IMediaPosition
, (void**)&m_pMS
) ); 
1242     wxAMVERIFY( m_pMC
->QueryInterface(IID_IVideoWindow
, (void**)&m_pVW
) ); 
1243     wxAMVERIFY( m_pMC
->QueryInterface(IID_IBasicAudio
, (void**)&m_pBA
) ); 
1244     wxAMVERIFY( m_pMC
->QueryInterface(IID_IBasicVideo
, (void**)&m_pBV
) ); 
1246     //We could tell if the media has audio or not by 
1250     //pBA->get_Volume(&lVolume) == E_NOTIMPL 
1255     //Obtain the _actual_ size of the movie & remember it 
1260     m_bestSize
.x 
= m_bestSize
.y 
= 0; 
1262     m_bVideo 
= SUCCEEDED( m_pVW
->GetWindowPosition( &nX
, 
1264                                                     (long*)&m_bestSize
.x
, 
1265                                                     (long*)&m_bestSize
.y
) ); 
1268     //If we have video in the media - set it up so that 
1269     //its a child window of the control, its visible, 
1270     //and that the control is the owner of the video window 
1274         wxAMVERIFY( m_pVW
->put_Owner((LONG_PTR
)m_ctrl
->GetHandle()) ); 
1275         wxAMVERIFY( m_pVW
->put_WindowStyle(WS_CHILD 
| WS_CLIPSIBLINGS
) ); 
1276         wxAMVERIFY( m_pVW
->put_Visible(-1) ); //OATRUE == -1 
1280     // Create a hidden window and register to handle 
1281     // directshow events for this graph 
1282     // Note that wxCanvasClassName is already registered 
1283     // and used by all wxWindows and normal wxControls 
1285     m_hNotifyWnd 
= ::CreateWindow
 
1299         wxLogSysError( wxT("Could not create hidden needed for ") 
1300                        wxT("registering for DirectShow events!")  ); 
1306     ::SetWindowLong(m_hNotifyWnd
, GWL_WNDPROC
, 
1307                        (LONG
)wxAMMediaBackend::NotifyWndProc
); 
1309     ::SetWindowLongPtr(m_hNotifyWnd
, GWLP_WNDPROC
, 
1310                        (LONG_PTR
)wxAMMediaBackend::NotifyWndProc
); 
1313     ::SetWindowLong(m_hNotifyWnd
, GWL_USERDATA
, 
1316     wxAMVERIFY( m_pME
->SetNotifyWindow((LONG_PTR
)m_hNotifyWnd
, 
1317                                        WM_GRAPHNOTIFY
, 0) ); 
1320     // Force the parent window of this control to recalculate 
1321     // the size of this if sizers are being used 
1322     // and render the results immediately 
1324     m_ctrl
->InvalidateBestSize(); 
1325     m_ctrl
->GetParent()->Layout(); 
1326     m_ctrl
->GetParent()->Refresh(); 
1327     m_ctrl
->GetParent()->Update(); 
1332 //--------------------------------------------------------------------------- 
1333 // wxAMMediaBackend::Load (URL Version) 
1335 // Loads media from a URL.  Interestingly enough DirectShow 
1336 // appears (?) to escape the URL for us, at least on normal 
1338 //--------------------------------------------------------------------------- 
1339 bool wxAMMediaBackend::Load(const wxURI
& location
) 
1341     return Load(location
.BuildUnescapedURI()); 
1344 //--------------------------------------------------------------------------- 
1345 // wxAMMediaBackend::Play 
1347 // Plays the stream.  If it is non-seekable, it will restart it. 
1348 //--------------------------------------------------------------------------- 
1349 bool wxAMMediaBackend::Play() 
1351     return SUCCEEDED( m_pMC
->Run() ); 
1354 //--------------------------------------------------------------------------- 
1355 // wxAMMediaBackend::Pause 
1357 // Pauses the stream. 
1358 //--------------------------------------------------------------------------- 
1359 bool wxAMMediaBackend::Pause() 
1361     return SUCCEEDED( m_pMC
->Pause() ); 
1364 //--------------------------------------------------------------------------- 
1365 // wxAMMediaBackend::Stop 
1367 // Stops the stream. 
1368 //--------------------------------------------------------------------------- 
1369 bool wxAMMediaBackend::Stop() 
1371     bool bOK 
= SUCCEEDED( m_pMC
->Stop() ); 
1373     //We don't care if it can't get to the beginning in directshow - 
1374     //it could be a non-seeking filter (wince midi) in which case playing 
1375     //starts all over again 
1380 //--------------------------------------------------------------------------- 
1381 // wxAMMediaBackend::SetPosition 
1383 // 1) Translates the current position's time to directshow time, 
1384 //    which is in a scale of 1 second (in a double) 
1385 // 2) Sets the play position of the IMediaSeeking interface - 
1386 //    passing NULL as the stop position means to keep the old 
1388 //--------------------------------------------------------------------------- 
1389 bool wxAMMediaBackend::SetPosition(wxLongLong where
) 
1391     return SUCCEEDED( m_pMS
->put_CurrentPosition( 
1392                         ((LONGLONG
)where
.GetValue()) / 1000 
1397 //--------------------------------------------------------------------------- 
1398 // wxAMMediaBackend::GetPosition 
1400 // 1) Obtains the current play and stop positions from IMediaSeeking 
1401 // 2) Returns the play position translated to our time base 
1402 //--------------------------------------------------------------------------- 
1403 wxLongLong 
wxAMMediaBackend::GetPosition() 
1406     wxAMVERIFY( m_pMS
->get_CurrentPosition(&outCur
) ); 
1408     //h,m,s,milli - outdur is in 1 second (double) 
1409     return (outCur
*1000); 
1412 //--------------------------------------------------------------------------- 
1413 // wxAMMediaBackend::SetVolume 
1415 // Sets the volume through the IBasicAudio interface - 
1416 // value ranges from 0 (MAX volume) to -10000 (minimum volume). 
1417 // -100 per decibel. 
1418 //--------------------------------------------------------------------------- 
1419 bool wxAMMediaBackend::SetVolume(double dVolume
)  
1421     return SUCCEEDED(m_pBA
->put_Volume( (long) ((dVolume
-1.0) * 10000.0) ));  
1424 //--------------------------------------------------------------------------- 
1425 // wxAMMediaBackend::GetVolume 
1427 // Gets the volume through the IBasicAudio interface - 
1428 // value ranges from 0 (MAX volume) to -10000 (minimum volume). 
1429 // -100 per decibel. 
1430 //--------------------------------------------------------------------------- 
1431 double wxAMMediaBackend::GetVolume() 
1434     if ( SUCCEEDED(m_pBA
->get_Volume(&lVolume
)) ) 
1435         return (((double)(lVolume 
+ 10000)) / 10000.0); 
1439 //--------------------------------------------------------------------------- 
1440 // wxAMMediaBackend::GetDuration 
1442 // 1) Obtains the duration of the media from the IMediaSeeking interface 
1443 // 2) Converts that value to our time base, and returns it 
1444 //--------------------------------------------------------------------------- 
1445 wxLongLong 
wxAMMediaBackend::GetDuration() 
1448     wxAMVERIFY( m_pMS
->get_Duration(&outDuration
) ); 
1450     //h,m,s,milli - outdur is in 1 second (double) 
1451     return (outDuration
*1000); 
1454 //--------------------------------------------------------------------------- 
1455 // wxAMMediaBackend::GetState 
1457 // Obtains the state from the IMediaControl interface. 
1458 // Note that it's enumeration values for stopping/playing 
1459 // etc. are the same as ours, so we just do a straight cast. 
1460 // TODO: MS recommends against INFINITE here for 
1461 //       IMediaControl::GetState- do it in stages 
1462 //--------------------------------------------------------------------------- 
1463 wxMediaState 
wxAMMediaBackend::GetState() 
1466     long theState
; //OAFilterState 
1467     hr 
= m_pMC
->GetState(INFINITE
, &theState
); 
1469     wxASSERT( SUCCEEDED(hr
) ); 
1471     //MSW state is the same as ours 
1472     //State_Stopped   = 0, 
1473     //State_Paused    = State_Stopped + 1, 
1474     //State_Running   = State_Paused + 1 
1476     return (wxMediaState
) theState
; 
1479 //--------------------------------------------------------------------------- 
1480 // wxAMMediaBackend::GetPlaybackRate 
1482 // Pretty simple way of obtaining the playback rate from 
1483 // the IMediaSeeking interface 
1484 //--------------------------------------------------------------------------- 
1485 double wxAMMediaBackend::GetPlaybackRate() 
1488     wxAMVERIFY( m_pMS
->get_Rate(&dRate
) ); 
1492 //--------------------------------------------------------------------------- 
1493 // wxAMMediaBackend::SetPlaybackRate 
1495 // Sets the playback rate of the media - DirectShow is pretty good 
1496 // about this, actually 
1497 //--------------------------------------------------------------------------- 
1498 bool wxAMMediaBackend::SetPlaybackRate(double dRate
) 
1500     return SUCCEEDED( m_pMS
->put_Rate(dRate
) ); 
1503 //--------------------------------------------------------------------------- 
1504 // wxAMMediaBackend::NotifyWndProc 
1506 // Here we check to see if DirectShow tells us we've reached the stop 
1507 // position in our stream - if it has, it may not actually stop 
1508 // the stream - which we need to do... 
1509 //--------------------------------------------------------------------------- 
1510 LRESULT CALLBACK 
wxAMMediaBackend::NotifyWndProc(HWND hWnd
, UINT nMsg
, 
1514     wxAMMediaBackend
* backend 
= (wxAMMediaBackend
*) 
1515         ::GetWindowLong(hWnd
, GWL_USERDATA
); 
1517     return backend
->OnNotifyWndProc(hWnd
, nMsg
, wParam
, lParam
); 
1520 LRESULT CALLBACK 
wxAMMediaBackend::OnNotifyWndProc(HWND hWnd
, UINT nMsg
, 
1524     if (nMsg 
== WM_GRAPHNOTIFY
) 
1531         // DirectShow keeps a list of queued events, and we need 
1532         // to go through them one by one, stopping at (Hopefully only one) 
1533         // EC_COMPLETE message 
1535         while(SUCCEEDED(m_pME
->GetEvent(&evCode
, (LONG_PTR 
*) &evParam1
, 
1536                                        (LONG_PTR 
*) &evParam2
, 0) 
1540             // Cleanup memory that GetEvent allocated 
1541             wxAMVERIFY( m_pME
->FreeEventParams(evCode
, evParam1
, evParam2
) ); 
1543             // If this is the end of the clip, notify handler 
1544             if(1 == evCode
) //EC_COMPLETE 
1546                 //send the event to our child 
1547                 wxMediaEvent 
theEvent(wxEVT_MEDIA_STOP
, m_ctrl
->GetId()); 
1548                 m_ctrl
->ProcessEvent(theEvent
); 
1550                 //if the user didn't veto it, stop the stream 
1551                 if (theEvent
.IsAllowed()) 
1553                     //Interestingly enough, DirectShow does not actually stop 
1554                     //the filters - even when it reaches the end! 
1557                     //send the event to our child 
1558                     wxMediaEvent 
theEvent(wxEVT_MEDIA_FINISHED
, 
1560                     m_ctrl
->ProcessEvent(theEvent
); 
1565     return DefWindowProc(hWnd
, nMsg
, wParam
, lParam
); 
1568 //--------------------------------------------------------------------------- 
1569 // wxAMMediaBackend::Cleanup 
1571 // 1) Hide/disowns the video window (MS says bad things will happen if 
1573 // 2) Releases all the directshow interfaces we use 
1574 // TODO: Maybe there's a way to redirect the IMediaControl each time 
1575 //       we load, rather then creating and destroying the interfaces 
1577 //--------------------------------------------------------------------------- 
1578 void wxAMMediaBackend::Cleanup() 
1580     // Hide then disown the window 
1583         m_pVW
->put_Visible(0); //OSFALSE == 0 
1584         m_pVW
->put_Owner(NULL
); 
1587     // Release and zero DirectShow interfaces 
1588     SAFE_RELEASE(m_pME
); 
1589     SAFE_RELEASE(m_pMS
); 
1590     SAFE_RELEASE(m_pBA
); 
1591     SAFE_RELEASE(m_pBV
); 
1592     SAFE_RELEASE(m_pVW
); 
1593     SAFE_RELEASE(m_pMC
); 
1595     // Get rid of our hidden Window 
1596     DestroyWindow(m_hNotifyWnd
); 
1597     m_hNotifyWnd 
= NULL
; 
1601 //--------------------------------------------------------------------------- 
1602 // wxAMMediaBackend::GetVideoSize 
1604 // Obtains the cached original video size 
1605 //--------------------------------------------------------------------------- 
1606 wxSize 
wxAMMediaBackend::GetVideoSize() const 
1611 //--------------------------------------------------------------------------- 
1612 // wxAMMediaBackend::Move 
1614 // Resizes the IVideoWindow to the size of the control window 
1615 //--------------------------------------------------------------------------- 
1616 void wxAMMediaBackend::Move(int WXUNUSED(x
), int WXUNUSED(y
), int w
, int h
) 
1618     if(m_hNotifyWnd 
&& m_bVideo
) 
1620         wxAMVERIFY( m_pVW
->SetWindowPosition(0, 0, w
, h
) ); 
1624 //--------------------------------------------------------------------------- 
1625 // End of wxAMMediaBackend 
1626 //--------------------------------------------------------------------------- 
1627 #endif //wxUSE_DIRECTSHOW 
1629 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
1631 // wxMCIMediaBackend 
1633 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
1636 IMPLEMENT_DYNAMIC_CLASS(wxMCIMediaBackend
, wxMediaBackend
); 
1638 //--------------------------------------------------------------------------- 
1639 // Usual debugging macros for MCI returns 
1640 //--------------------------------------------------------------------------- 
1643 #define wxMCIVERIFY(arg) \ 
1646     if ( (nRet = (arg)) != 0) \ 
1649         mciGetErrorString(nRet, sz, 5000); \ 
1650         wxFAIL_MSG(wxString::Format(_T("MCI Error:%s"), sz)); \ 
1654 #define wxMCIVERIFY(arg) (arg); 
1657 //--------------------------------------------------------------------------- 
1658 // Simulation for <digitalv.h> 
1660 // Mingw and possibly other compilers don't have the digitalv.h header 
1661 // that is needed to have some essential features of mci work with 
1662 // windows - so we provide the declarations for the types we use here 
1663 //--------------------------------------------------------------------------- 
1666     DWORD_PTR   dwCallback
; 
1667 #ifdef MCI_USE_OFFEXT 
1673 } MCI_DGV_RECT_PARMS
; 
1676     DWORD_PTR   dwCallback
; 
1686 } MCI_DGV_WINDOW_PARMS
; 
1689     DWORD_PTR dwCallback
; 
1694 } MCI_DGV_SET_PARMS
; 
1697     DWORD_PTR   dwCallback
; 
1701     wxChar
*   lpstrAlgorithm
; 
1702     wxChar
*   lpstrQuality
; 
1703 } MCI_DGV_SETAUDIO_PARMS
; 
1705 //--------------------------------------------------------------------------- 
1706 // wxMCIMediaBackend Constructor 
1708 // Here we don't need to do much except say we don't have any video :) 
1709 //--------------------------------------------------------------------------- 
1710 wxMCIMediaBackend::wxMCIMediaBackend() : m_hNotifyWnd(NULL
), m_bVideo(false) 
1714 //--------------------------------------------------------------------------- 
1715 // wxMCIMediaBackend Destructor 
1717 // We close the mci device - note that there may not be an mci device here, 
1718 // or it may fail - but we don't really care, since we're destructing 
1719 //--------------------------------------------------------------------------- 
1720 wxMCIMediaBackend::~wxMCIMediaBackend() 
1724         mciSendCommand(m_hDev
, MCI_CLOSE
, 0, 0); 
1725         DestroyWindow(m_hNotifyWnd
); 
1726         m_hNotifyWnd 
= NULL
; 
1730 //--------------------------------------------------------------------------- 
1731 // wxMCIMediaBackend::Create 
1733 // Here we just tell wxMediaCtrl that mci does exist (which it does, on all 
1734 // msw systems, at least in some form dating back to win16 days) 
1735 //--------------------------------------------------------------------------- 
1736 bool wxMCIMediaBackend::CreateControl(wxControl
* ctrl
, wxWindow
* parent
, 
1741                                      const wxValidator
& validator
, 
1742                                      const wxString
& name
) 
1746     // By default wxWindow(s) is created with a border - 
1747     // so we need to get rid of those, and create with 
1748     // wxCLIP_CHILDREN, so that if the driver/backend 
1749     // is a child window, it refereshes properly 
1751     if ( !ctrl
->wxControl::Create(parent
, id
, pos
, size
, 
1752                             (style 
& ~wxBORDER_MASK
) | wxBORDER_NONE 
| wxCLIP_CHILDREN
, 
1760 //--------------------------------------------------------------------------- 
1761 // wxMCIMediaBackend::Load (file version) 
1763 // Here we have MCI load a file and device, set the time format to our 
1764 // default (milliseconds), and set the video (if any) to play in the control 
1765 //--------------------------------------------------------------------------- 
1766 bool wxMCIMediaBackend::Load(const wxString
& fileName
) 
1769     //if the user already called load close the previous MCI device 
1773         mciSendCommand(m_hDev
, MCI_CLOSE
, 0, 0); 
1774         DestroyWindow(m_hNotifyWnd
); 
1775         m_hNotifyWnd 
= NULL
; 
1779     //Opens a file and has MCI select a device.  Normally you'd put 
1780     //MCI_OPEN_TYPE in addition to MCI_OPEN_ELEMENT - however if you 
1781     //omit this it tells MCI to select the device instead.  This is 
1782     //good because we have no reliable way of "enumerating" the devices 
1785     MCI_OPEN_PARMS openParms
; 
1786     openParms
.lpstrElementName 
= (wxChar
*) fileName
.c_str(); 
1788     if ( mciSendCommand(0, MCI_OPEN
, MCI_OPEN_ELEMENT
, 
1789                         (DWORD
)(LPVOID
)&openParms
) != 0) 
1792     m_hDev 
= openParms
.wDeviceID
; 
1795     //Now set the time format for the device to milliseconds 
1797     MCI_SET_PARMS setParms
; 
1798     setParms
.dwCallback 
= 0; 
1799     setParms
.dwTimeFormat 
= MCI_FORMAT_MILLISECONDS
; 
1801     if (mciSendCommand(m_hDev
, MCI_SET
, MCI_SET_TIME_FORMAT
, 
1802                          (DWORD
)(LPVOID
)&setParms
) != 0) 
1806     //Now tell the MCI device to display the video in our wxMediaCtrl 
1808     MCI_DGV_WINDOW_PARMS windowParms
; 
1809     windowParms
.hWnd 
= (HWND
)m_ctrl
->GetHandle(); 
1811     m_bVideo 
= (mciSendCommand(m_hDev
, MCI_WINDOW
, 
1812                                0x00010000L
, //MCI_DGV_WINDOW_HWND 
1813                                (DWORD
)(LPVOID
)&windowParms
) == 0); 
1816     // Create a hidden window and register to handle 
1818     // Note that wxCanvasClassName is already registered 
1819     // and used by all wxWindows and normal wxControls 
1821     m_hNotifyWnd 
= ::CreateWindow
 
1835         wxLogSysError( wxT("Could not create hidden needed for ") 
1836                        wxT("registering for DirectShow events!")  ); 
1842     ::SetWindowLong(m_hNotifyWnd
, GWL_WNDPROC
, 
1843                        (LONG
)wxMCIMediaBackend::NotifyWndProc
); 
1845     ::SetWindowLongPtr(m_hNotifyWnd
, GWLP_WNDPROC
, 
1846                        (LONG_PTR
)wxMCIMediaBackend::NotifyWndProc
); 
1849     ::SetWindowLong(m_hNotifyWnd
, GWL_USERDATA
, 
1853     //Here, if the parent of the control has a sizer - we 
1854     //tell it to recalculate the size of this control since 
1855     //the user opened a seperate media file 
1857     m_ctrl
->InvalidateBestSize(); 
1858     m_ctrl
->GetParent()->Layout(); 
1859     m_ctrl
->GetParent()->Refresh(); 
1860     m_ctrl
->GetParent()->Update(); 
1865 //--------------------------------------------------------------------------- 
1866 // wxMCIMediaBackend::Load (URL version) 
1868 // MCI doesn't support URLs directly (?) 
1870 // TODO:  Use wxURL/wxFileSystem and mmioInstallProc 
1871 //--------------------------------------------------------------------------- 
1872 bool wxMCIMediaBackend::Load(const wxURI
& WXUNUSED(location
)) 
1877 //--------------------------------------------------------------------------- 
1878 // wxMCIMediaBackend::Play 
1880 // Plays/Resumes the MCI device... a couple notes: 
1881 // 1) Certain drivers will crash and burn if we don't pass them an 
1882 //    MCI_PLAY_PARMS, despite the documentation that says otherwise... 
1883 // 2) There is a MCI_RESUME command, but MCI_PLAY does the same thing 
1884 //    and will resume from a stopped state also, so there's no need to 
1885 //    call both, for example 
1886 //--------------------------------------------------------------------------- 
1887 bool wxMCIMediaBackend::Play() 
1889     MCI_PLAY_PARMS playParms
; 
1890     playParms
.dwCallback 
= (DWORD
)m_hNotifyWnd
; 
1892     bool bOK 
= ( mciSendCommand(m_hDev
, MCI_PLAY
, MCI_NOTIFY
, 
1893                             (DWORD
)(LPVOID
)&playParms
) == 0 ); 
1896         m_ctrl
->Show(m_bVideo
); 
1901 //--------------------------------------------------------------------------- 
1902 // wxMCIMediaBackend::Pause 
1904 // Pauses the MCI device - nothing special 
1905 //--------------------------------------------------------------------------- 
1906 bool wxMCIMediaBackend::Pause() 
1908     return (mciSendCommand(m_hDev
, MCI_PAUSE
, MCI_WAIT
, 0) == 0); 
1911 //--------------------------------------------------------------------------- 
1912 // wxMCIMediaBackend::Stop 
1914 // Stops the MCI device & seeks to the beginning as wxMediaCtrl docs outline 
1915 //--------------------------------------------------------------------------- 
1916 bool wxMCIMediaBackend::Stop() 
1918     return (mciSendCommand(m_hDev
, MCI_STOP
, MCI_WAIT
, 0) == 0) && 
1919            (mciSendCommand(m_hDev
, MCI_SEEK
, MCI_SEEK_TO_START
, 0) == 0); 
1922 //--------------------------------------------------------------------------- 
1923 // wxMCIMediaBackend::GetState 
1925 // Here we get the state and convert it to a wxMediaState - 
1926 // since we use direct comparisons with MCI_MODE_PLAY and 
1927 // MCI_MODE_PAUSE, we don't care if the MCI_STATUS call 
1929 //--------------------------------------------------------------------------- 
1930 wxMediaState 
wxMCIMediaBackend::GetState() 
1932     MCI_STATUS_PARMS statusParms
; 
1933     statusParms
.dwItem 
= MCI_STATUS_MODE
; 
1935     mciSendCommand(m_hDev
, MCI_STATUS
, MCI_STATUS_ITEM
, 
1936                          (DWORD
)(LPVOID
)&statusParms
); 
1938     if(statusParms
.dwReturn 
== MCI_MODE_PAUSE
) 
1939         return wxMEDIASTATE_PAUSED
; 
1940     else if(statusParms
.dwReturn 
== MCI_MODE_PLAY
) 
1941         return wxMEDIASTATE_PLAYING
; 
1943         return wxMEDIASTATE_STOPPED
; 
1946 //--------------------------------------------------------------------------- 
1947 // wxMCIMediaBackend::SetPosition 
1949 // Here we set the position of the device in the stream. 
1950 // Note that MCI actually stops the device after you seek it if the 
1951 // device is playing/paused, so we need to play the file after 
1952 // MCI seeks like normal APIs would 
1953 //--------------------------------------------------------------------------- 
1954 bool wxMCIMediaBackend::SetPosition(wxLongLong where
) 
1956     MCI_SEEK_PARMS seekParms
; 
1957     seekParms
.dwCallback 
= 0; 
1958 #if wxUSE_LONGLONG_NATIVE && !wxUSE_LONGLONG_WX 
1959     seekParms
.dwTo 
= (DWORD
)where
.GetValue(); 
1960 #else /* wxUSE_LONGLONG_WX */ 
1961     /* no way to return it in one piece */ 
1962     wxASSERT( where
.GetHi()==0 ); 
1963     seekParms
.dwTo 
= (DWORD
)where
.GetLo(); 
1964 #endif /* wxUSE_LONGLONG_* */ 
1966     //device was playing? 
1967     bool bReplay 
= GetState() == wxMEDIASTATE_PLAYING
; 
1969     if( mciSendCommand(m_hDev
, MCI_SEEK
, MCI_TO
, 
1970                        (DWORD
)(LPVOID
)&seekParms
) != 0) 
1973     //If the device was playing, resume it 
1980 //--------------------------------------------------------------------------- 
1981 // wxMCIMediaBackend::GetPosition 
1983 // Gets the position of the device in the stream using the current 
1984 // time format... nothing special here... 
1985 //--------------------------------------------------------------------------- 
1986 wxLongLong 
wxMCIMediaBackend::GetPosition() 
1988     MCI_STATUS_PARMS statusParms
; 
1989     statusParms
.dwItem 
= MCI_STATUS_POSITION
; 
1991     if (mciSendCommand(m_hDev
, MCI_STATUS
, MCI_STATUS_ITEM
, 
1992                        (DWORD
)(LPSTR
)&statusParms
) != 0) 
1995     return statusParms
.dwReturn
; 
1998 //--------------------------------------------------------------------------- 
1999 // wxMCIMediaBackend::GetVolume 
2001 // Gets the volume of the current media via the MCI_DGV_STATUS_VOLUME 
2002 // message.  Value ranges from 0 (minimum) to 1000 (maximum volume). 
2003 //--------------------------------------------------------------------------- 
2004 double wxMCIMediaBackend::GetVolume() 
2006     MCI_STATUS_PARMS statusParms
; 
2007     statusParms
.dwCallback 
= NULL
; 
2008     statusParms
.dwItem 
= 0x4019; //MCI_DGV_STATUS_VOLUME 
2010     if (mciSendCommand(m_hDev
, MCI_STATUS
, MCI_STATUS_ITEM
, 
2011                        (DWORD
)(LPSTR
)&statusParms
) != 0) 
2014     return ((double)statusParms
.dwReturn
) / 1000.0; 
2017 //--------------------------------------------------------------------------- 
2018 // wxMCIMediaBackend::SetVolume 
2020 // Sets the volume of the current media via the MCI_DGV_SETAUDIO_VOLUME 
2021 // message.  Value ranges from 0 (minimum) to 1000 (maximum volume). 
2022 //--------------------------------------------------------------------------- 
2023 bool wxMCIMediaBackend::SetVolume(double dVolume
) 
2025     MCI_DGV_SETAUDIO_PARMS audioParms
; 
2026     audioParms
.dwCallback 
= NULL
; 
2027     audioParms
.dwItem 
= 0x4002; //MCI_DGV_SETAUDIO_VOLUME 
2028     audioParms
.dwValue 
= (DWORD
) (dVolume 
* 1000.0); 
2029     audioParms
.dwOver 
= 0; 
2030     audioParms
.lpstrAlgorithm 
= NULL
; 
2031     audioParms
.lpstrQuality 
= NULL
; 
2033     if (mciSendCommand(m_hDev
, 0x0873, //MCI_SETAUDIO  
2034                         0x00800000L 
| 0x01000000L
, //MCI_DGV_SETAUDIO+(_ITEM | _VALUE) 
2035                        (DWORD
)(LPSTR
)&audioParms
) != 0) 
2040 //--------------------------------------------------------------------------- 
2041 // wxMCIMediaBackend::GetDuration 
2043 // Gets the duration of the stream... nothing special 
2044 //--------------------------------------------------------------------------- 
2045 wxLongLong 
wxMCIMediaBackend::GetDuration() 
2047     MCI_STATUS_PARMS statusParms
; 
2048     statusParms
.dwItem 
= MCI_STATUS_LENGTH
; 
2050     if (mciSendCommand(m_hDev
, MCI_STATUS
, MCI_STATUS_ITEM
, 
2051                         (DWORD
)(LPSTR
)&statusParms
) != 0) 
2054     return statusParms
.dwReturn
; 
2057 //--------------------------------------------------------------------------- 
2058 // wxMCIMediaBackend::Move 
2060 // Moves the window to a location 
2061 //--------------------------------------------------------------------------- 
2062 void wxMCIMediaBackend::Move(int WXUNUSED(x
), int WXUNUSED(y
), 
2065     if (m_hNotifyWnd 
&& m_bVideo
) 
2067         MCI_DGV_RECT_PARMS putParms
; //ifdefed MCI_DGV_PUT_PARMS 
2068         putParms
.rc
.top 
= 0; 
2069         putParms
.rc
.bottom 
= 0; 
2070         putParms
.rc
.right 
= w
; 
2071         putParms
.rc
.bottom 
= h
; 
2073         wxMCIVERIFY( mciSendCommand(m_hDev
, MCI_PUT
, 
2074                                    0x00040000L
, //MCI_DGV_PUT_DESTINATION 
2075                                    (DWORD
)(LPSTR
)&putParms
) ); 
2079 //--------------------------------------------------------------------------- 
2080 // wxMCIMediaBackend::GetVideoSize 
2082 // Gets the original size of the movie for sizers 
2083 //--------------------------------------------------------------------------- 
2084 wxSize 
wxMCIMediaBackend::GetVideoSize() const 
2088         MCI_DGV_RECT_PARMS whereParms
; //ifdefed MCI_DGV_WHERE_PARMS 
2090         wxMCIVERIFY( mciSendCommand(m_hDev
, MCI_WHERE
, 
2091                        0x00020000L
, //MCI_DGV_WHERE_SOURCE 
2092                        (DWORD
)(LPSTR
)&whereParms
) ); 
2094         return wxSize(whereParms
.rc
.right
, whereParms
.rc
.bottom
); 
2099 //--------------------------------------------------------------------------- 
2100 // wxMCIMediaBackend::GetPlaybackRate 
2103 //--------------------------------------------------------------------------- 
2104 double wxMCIMediaBackend::GetPlaybackRate() 
2109 //--------------------------------------------------------------------------- 
2110 // wxMCIMediaBackend::SetPlaybackRate 
2113 //--------------------------------------------------------------------------- 
2114 bool wxMCIMediaBackend::SetPlaybackRate(double WXUNUSED(dRate
)) 
2117     MCI_WAVE_SET_SAMPLESPERSEC 
2118     MCI_DGV_SET_PARMS setParms; 
2119     setParms.dwSpeed = (DWORD) (dRate * 1000.0); 
2121     return (mciSendCommand(m_hDev, MCI_SET, 
2122                        0x00020000L, //MCI_DGV_SET_SPEED 
2123                        (DWORD)(LPSTR)&setParms) == 0); 
2128 //--------------------------------------------------------------------------- 
2129 // [static] wxMCIMediaBackend::MSWWindowProc 
2131 // Here we process a message when MCI reaches the stopping point 
2133 //--------------------------------------------------------------------------- 
2134 LRESULT CALLBACK 
wxMCIMediaBackend::NotifyWndProc(HWND hWnd
, UINT nMsg
, 
2138     wxMCIMediaBackend
* backend 
= (wxMCIMediaBackend
*) 
2139         ::GetWindowLong(hWnd
, GWL_USERDATA
); 
2142     return backend
->OnNotifyWndProc(hWnd
, nMsg
, wParam
, lParam
); 
2145 LRESULT CALLBACK 
wxMCIMediaBackend::OnNotifyWndProc(HWND hWnd
, UINT nMsg
, 
2149     if(nMsg 
== MM_MCINOTIFY
) 
2151         wxASSERT(lParam 
== (LPARAM
) m_hDev
); 
2152         if(wParam 
== MCI_NOTIFY_SUCCESSFUL 
&& lParam 
== (LPARAM
)m_hDev
) 
2154             wxMediaEvent 
theEvent(wxEVT_MEDIA_STOP
, m_ctrl
->GetId()); 
2155             m_ctrl
->ProcessEvent(theEvent
); 
2157             if(theEvent
.IsAllowed()) 
2159                 wxMCIVERIFY( mciSendCommand(m_hDev
, MCI_SEEK
, 
2160                                             MCI_SEEK_TO_START
, 0) ); 
2162                 //send the event to our child 
2163                 wxMediaEvent 
theEvent(wxEVT_MEDIA_FINISHED
, 
2165                 m_ctrl
->ProcessEvent(theEvent
); 
2169     return DefWindowProc(hWnd
, nMsg
, wParam
, lParam
); 
2171 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
2175 // TODO: Use a less cludgy way to pause/get state/set state 
2176 // TODO: Dynamically load from qtml.dll 
2177 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
2181 IMPLEMENT_DYNAMIC_CLASS(wxQTMediaBackend
, wxMediaBackend
); 
2183 //Time between timer calls 
2184 #define MOVIE_DELAY 100 
2186 #include "wx/timer.h" 
2188 // -------------------------------------------------------------------------- 
2189 //          wxQTTimer - Handle Asyncronous Playing 
2190 // -------------------------------------------------------------------------- 
2191 class _wxQTTimer 
: public wxTimer
 
2194     _wxQTTimer(Movie movie
, wxQTMediaBackend
* parent
, wxQuickTimeLibrary
* pLib
) : 
2195         m_movie(movie
), m_bPaused(false), m_parent(parent
), m_pLib(pLib
) 
2203     bool GetPaused() {return m_bPaused
;} 
2204     void SetPaused(bool bPaused
) {m_bPaused 
= bPaused
;} 
2206     //----------------------------------------------------------------------- 
2207     // _wxQTTimer::Notify 
2209     // 1) Checks to see if the movie is done, and if not continues 
2210     //    streaming the movie 
2211     // 2) Sends the wxEVT_MEDIA_STOP event if we have reached the end of 
2213     //----------------------------------------------------------------------- 
2218             if(!m_pLib
->IsMovieDone(m_movie
)) 
2219                 m_pLib
->MoviesTask(m_movie
, MOVIE_DELAY
); 
2222                 wxMediaEvent 
theEvent(wxEVT_MEDIA_STOP
, 
2223                                       m_parent
->m_ctrl
->GetId()); 
2224                 m_parent
->m_ctrl
->ProcessEvent(theEvent
); 
2226                 if(theEvent
.IsAllowed()) 
2230                     wxASSERT(m_pLib
->GetMoviesError() == noErr
); 
2232                     //send the event to our child 
2233                     wxMediaEvent 
theEvent(wxEVT_MEDIA_FINISHED
, 
2234                                           m_parent
->m_ctrl
->GetId()); 
2235                     m_parent
->m_ctrl
->ProcessEvent(theEvent
); 
2242     Movie m_movie
;                  //Our movie instance 
2243     bool m_bPaused
;                 //Whether we are paused or not 
2244     wxQTMediaBackend
* m_parent
;     //Backend pointer 
2245     wxQuickTimeLibrary
* m_pLib
;         //Interfaces 
2248 //--------------------------------------------------------------------------- 
2249 // wxQTMediaBackend Destructor 
2251 // Sets m_timer to NULL signifying we havn't loaded anything yet 
2252 //--------------------------------------------------------------------------- 
2253 wxQTMediaBackend::wxQTMediaBackend() : m_timer(NULL
) 
2257 //--------------------------------------------------------------------------- 
2258 // wxQTMediaBackend Destructor 
2260 // 1) Cleans up the QuickTime movie instance 
2261 // 2) Decrements the QuickTime reference counter - if this reaches 
2262 //    0, QuickTime shuts down 
2263 // 3) Decrements the QuickTime Windows Media Layer reference counter - 
2264 //    if this reaches 0, QuickTime shuts down the Windows Media Layer 
2265 //--------------------------------------------------------------------------- 
2266 wxQTMediaBackend::~wxQTMediaBackend() 
2273         //Note that ExitMovies() is not neccessary, but 
2274         //the docs are fuzzy on whether or not TerminateQTML is 
2276         m_lib
.TerminateQTML(); 
2280 //--------------------------------------------------------------------------- 
2281 // wxQTMediaBackend::CreateControl 
2283 // 1) Intializes QuickTime 
2284 // 2) Creates the control window 
2285 //--------------------------------------------------------------------------- 
2286 bool wxQTMediaBackend::CreateControl(wxControl
* ctrl
, wxWindow
* parent
, 
2291                                      const wxValidator
& validator
, 
2292                                      const wxString
& name
) 
2294     if(!m_lib
.Initialize()) 
2298     if ((nError 
= m_lib
.InitializeQTML(0)) != noErr
)    //-2093 no dll 
2300         wxFAIL_MSG(wxString::Format(wxT("Couldn't Initialize Quicktime-%i"), nError
)); 
2303     m_lib
.EnterMovies(); 
2307     // By default wxWindow(s) is created with a border - 
2308     // so we need to get rid of those 
2310     // Since we don't have a child window like most other 
2311     // backends, we don't need wxCLIP_CHILDREN 
2313     if ( !ctrl
->wxControl::Create(parent
, id
, pos
, size
, 
2314                             (style 
& ~wxBORDER_MASK
) | wxBORDER_NONE
, 
2322 //--------------------------------------------------------------------------- 
2323 // wxQTMediaBackend::Load (file version) 
2325 // 1) Get an FSSpec from the Windows path name 
2326 // 2) Open the movie 
2327 // 3) Obtain the movie instance from the movie resource 
2329 //--------------------------------------------------------------------------- 
2330 bool wxQTMediaBackend::Load(const wxString
& fileName
) 
2339     if (m_lib
.NativePathNameToFSSpec ((char*) (const char*) fileName
.mb_str(), 
2340                                 &sfFile
, 0) != noErr
) 
2343     if (m_lib
.OpenMovieFile (&sfFile
, &movieResFile
, fsRdPerm
) != noErr
) 
2346     short movieResID 
= 0; 
2349     err 
= m_lib
.NewMovieFromFile ( 
2357     m_lib
.CloseMovieFile (movieResFile
); 
2364     return m_lib
.GetMoviesError() == noErr
; 
2367 //--------------------------------------------------------------------------- 
2368 // wxQTMediaBackend::Move 
2371 //--------------------------------------------------------------------------- 
2372 bool wxQTMediaBackend::Load(const wxURI
& location
) 
2377     wxString theURI 
= location
.BuildURI(); 
2381     Handle theHandle 
= m_lib
.NewHandleClear(theURI
.length() + 1); 
2382     wxASSERT(theHandle
); 
2384     m_lib
.BlockMove(theURI
.mb_str(), *theHandle
, theURI
.length() + 1); 
2386     //create the movie from the handle that refers to the URI 
2387     err 
= m_lib
.NewMovieFromDataRef(&m_movie
, newMovieActive
, 
2389                                 'url'); //URLDataHandlerSubType 
2391     m_lib
.DisposeHandle(theHandle
); 
2396     //preroll movie for streaming 
2401     timeNow = GetMovieTime(m_movie, NULL); 
2402     playRate = GetMoviePreferredRate(m_movie); 
2403     PrePrerollMovie(m_movie, timeNow, playRate, NULL, NULL); 
2404     PrerollMovie(m_movie, timeNow, playRate);     
2405     m_lib.SetMovieRate(m_movie, playRate); 
2410     return m_lib
.GetMoviesError() == noErr
; 
2413 //--------------------------------------------------------------------------- 
2414 // wxQTMediaBackend::Move 
2417 //--------------------------------------------------------------------------- 
2418 void wxQTMediaBackend::FinishLoad() 
2420     m_timer 
= new _wxQTTimer(m_movie
, (wxQTMediaBackend
*) this, &m_lib
); 
2423     //get the real size of the movie 
2425     m_lib
.GetMovieNaturalBoundsRect (m_movie
, &outRect
); 
2426     wxASSERT(m_lib
.GetMoviesError() == noErr
); 
2428     m_bestSize
.x 
= outRect
.right 
- outRect
.left
; 
2429     m_bestSize
.y 
= outRect
.bottom 
- outRect
.top
; 
2431     //reparent movie/*AudioMediaCharacteristic*/ 
2432     if(m_lib
.GetMovieIndTrackType(m_movie
, 1, 
2433                             'eyes', //VisualMediaCharacteristic, 
2434                             (1 << 1) //movieTrackCharacteristic  
2435                             | (1 << 2) //movieTrackEnabledOnly 
2438         m_lib
.CreatePortAssociation(m_ctrl
->GetHWND(), NULL
, 0L); 
2440         m_lib
.SetMovieGWorld(m_movie
, 
2441                        (CGrafPtr
) m_lib
.GetNativeWindowPort(m_ctrl
->GetHWND()), 
2445     //we want millisecond precision 
2446     m_lib
.SetMovieTimeScale(m_movie
, 1000); 
2447     wxASSERT(m_lib
.GetMoviesError() == noErr
); 
2450     //Here, if the parent of the control has a sizer - we 
2451     //tell it to recalculate the size of this control since 
2452     //the user opened a seperate media file 
2454     m_ctrl
->InvalidateBestSize(); 
2455     m_ctrl
->GetParent()->Layout(); 
2456     m_ctrl
->GetParent()->Refresh(); 
2457     m_ctrl
->GetParent()->Update(); 
2460 //--------------------------------------------------------------------------- 
2461 // wxQTMediaBackend::Move 
2464 //--------------------------------------------------------------------------- 
2465 bool wxQTMediaBackend::Play() 
2467     m_lib
.StartMovie(m_movie
); 
2468     m_timer
->SetPaused(false); 
2469     m_timer
->Start(MOVIE_DELAY
, wxTIMER_CONTINUOUS
); 
2470     return m_lib
.GetMoviesError() == noErr
; 
2473 //--------------------------------------------------------------------------- 
2474 // wxQTMediaBackend::Move 
2477 //--------------------------------------------------------------------------- 
2478 bool wxQTMediaBackend::Pause() 
2480     m_lib
.StopMovie(m_movie
); 
2481     m_timer
->SetPaused(true); 
2483     return m_lib
.GetMoviesError() == noErr
; 
2486 //--------------------------------------------------------------------------- 
2487 // wxQTMediaBackend::Move 
2490 //--------------------------------------------------------------------------- 
2491 bool wxQTMediaBackend::Stop() 
2493     m_timer
->SetPaused(false); 
2496     m_lib
.StopMovie(m_movie
); 
2497     if(m_lib
.GetMoviesError() != noErr
) 
2500     m_lib
.GoToBeginningOfMovie(m_movie
); 
2501     return m_lib
.GetMoviesError() == noErr
; 
2504 //--------------------------------------------------------------------------- 
2505 // wxQTMediaBackend::Move 
2508 //--------------------------------------------------------------------------- 
2509 double wxQTMediaBackend::GetPlaybackRate() 
2511     return ( ((double)m_lib
.GetMovieRate(m_movie
)) / 0x10000); 
2514 //--------------------------------------------------------------------------- 
2515 // wxQTMediaBackend::Move 
2518 //--------------------------------------------------------------------------- 
2519 bool wxQTMediaBackend::SetPlaybackRate(double dRate
) 
2521     m_lib
.SetMovieRate(m_movie
, (Fixed
) (dRate 
* 0x10000)); 
2522     return m_lib
.GetMoviesError() == noErr
; 
2525 //--------------------------------------------------------------------------- 
2526 // wxQTMediaBackend::Move 
2529 //--------------------------------------------------------------------------- 
2530 bool wxQTMediaBackend::SetPosition(wxLongLong where
) 
2532     TimeRecord theTimeRecord
; 
2533     memset(&theTimeRecord
, 0, sizeof(TimeRecord
)); 
2534     theTimeRecord
.value
.lo 
= where
.GetValue(); 
2535     theTimeRecord
.scale 
= m_lib
.GetMovieTimeScale(m_movie
); 
2536     theTimeRecord
.base 
= m_lib
.GetMovieTimeBase(m_movie
); 
2537     m_lib
.SetMovieTime(m_movie
, &theTimeRecord
); 
2539     if (m_lib
.GetMoviesError() != noErr
) 
2545 //--------------------------------------------------------------------------- 
2546 // wxQTMediaBackend::GetPosition 
2548 // 1) Calls GetMovieTime to get the position we are in in the movie 
2549 // in milliseconds (we called 
2550 //--------------------------------------------------------------------------- 
2551 wxLongLong 
wxQTMediaBackend::GetPosition() 
2553     return m_lib
.GetMovieTime(m_movie
, NULL
); 
2556 //--------------------------------------------------------------------------- 
2557 // wxQTMediaBackend::GetVolume 
2559 // Gets the volume through GetMovieVolume - which returns a 16 bit short - 
2561 // +--------+--------+ 
2563 // +--------+--------+ 
2565 // (1) first 8 bits are value before decimal 
2566 // (2) second 8 bits are value after decimal 
2568 // Volume ranges from -1.0 (gain but no sound), 0 (no sound and no gain) to 
2569 // 1 (full gain and sound) 
2570 //--------------------------------------------------------------------------- 
2571 double wxQTMediaBackend::GetVolume() 
2573     short sVolume 
= m_lib
.GetMovieVolume(m_movie
); 
2575     if(sVolume 
& (128 << 8)) //negative - no sound 
2578     return (sVolume 
& (127 << 8)) ? 1.0 : ((double)(sVolume 
& 255)) / 255.0; 
2581 //--------------------------------------------------------------------------- 
2582 // wxQTMediaBackend::SetVolume 
2584 // Sets the volume through SetMovieVolume - which takes a 16 bit short - 
2586 // +--------+--------+ 
2588 // +--------+--------+ 
2590 // (1) first 8 bits are value before decimal 
2591 // (2) second 8 bits are value after decimal 
2593 // Volume ranges from -1.0 (gain but no sound), 0 (no sound and no gain) to 
2594 // 1 (full gain and sound) 
2595 //--------------------------------------------------------------------------- 
2596 bool wxQTMediaBackend::SetVolume(double dVolume
) 
2598     short sVolume 
= (dVolume 
>= .9999 ? 1 << 8 :  
2599                                        (short) (dVolume 
* 255)); 
2600     m_lib
.SetMovieVolume(m_movie
, sVolume
); 
2604 //--------------------------------------------------------------------------- 
2605 // wxQTMediaBackend::Move 
2608 //--------------------------------------------------------------------------- 
2609 wxLongLong 
wxQTMediaBackend::GetDuration() 
2611     return m_lib
.GetMovieDuration(m_movie
); 
2614 //--------------------------------------------------------------------------- 
2615 // wxQTMediaBackend::Move 
2618 //--------------------------------------------------------------------------- 
2619 wxMediaState 
wxQTMediaBackend::GetState() 
2621     if ( !m_timer 
|| (m_timer
->IsRunning() == false && 
2622                       m_timer
->GetPaused() == false) ) 
2623         return wxMEDIASTATE_STOPPED
; 
2625     if( m_timer
->IsRunning() == true ) 
2626         return wxMEDIASTATE_PLAYING
; 
2628         return wxMEDIASTATE_PAUSED
; 
2631 //--------------------------------------------------------------------------- 
2632 // wxQTMediaBackend::Move 
2635 //--------------------------------------------------------------------------- 
2636 void wxQTMediaBackend::Cleanup() 
2641     m_lib
.StopMovie(m_movie
); 
2642     m_lib
.DisposeMovie(m_movie
); 
2645 //--------------------------------------------------------------------------- 
2646 // wxQTMediaBackend::Move 
2649 //--------------------------------------------------------------------------- 
2650 wxSize 
wxQTMediaBackend::GetVideoSize() const 
2655 //--------------------------------------------------------------------------- 
2656 // wxQTMediaBackend::Move 
2659 //--------------------------------------------------------------------------- 
2660 void wxQTMediaBackend::Move(int WXUNUSED(x
), int WXUNUSED(y
), int w
, int h
) 
2664         Rect theRect 
= {0, 0, h
, w
}; 
2666         m_lib
.SetMovieBox(m_movie
, &theRect
); 
2667         wxASSERT(m_lib
.GetMoviesError() == noErr
); 
2671 //--------------------------------------------------------------------------- 
2672 //  End QT Compilation Guard 
2673 //--------------------------------------------------------------------------- 
2674 #endif //wxUSE_QUICKTIME 
2676 //in source file that contains stuff you don't directly use 
2677 #include <wx/html/forcelnk.h> 
2678 FORCE_LINK_ME(basewxmediabackends
); 
2680 //--------------------------------------------------------------------------- 
2681 //  End wxMediaCtrl Compilation Guard and this file 
2682 //--------------------------------------------------------------------------- 
2683 #endif //wxUSE_MEDIACTRL