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"
31 //---------------------------------------------------------------------------
33 //---------------------------------------------------------------------------
34 #include "wx/mediactrl.h"
36 //---------------------------------------------------------------------------
38 //---------------------------------------------------------------------------
41 //---------------------------------------------------------------------------
42 // Externals (somewhere in src/msw/app.cpp)
43 //---------------------------------------------------------------------------
44 extern "C" WXDLLIMPEXP_BASE HINSTANCE
wxGetInstance(void);
46 extern WXDLLIMPEXP_CORE wxChar
*wxCanvasClassName
;
48 extern WXDLLIMPEXP_CORE
const wxChar
*wxCanvasClassName
;
51 //===========================================================================
52 // BACKEND DECLARATIONS
53 //===========================================================================
55 //---------------------------------------------------------------------------
59 //---------------------------------------------------------------------------
61 //---------------------------------------------------------------------------
62 // Compilation guard for DirectShow
63 //---------------------------------------------------------------------------
66 //---------------------------------------------------------------------------
68 //---------------------------------------------------------------------------
69 #include "wx/msw/ole/oleutils.h" //wxBasicString, IID etc.
70 #include "wx/msw/ole/uuid.h" //IID etc..
72 //---------------------------------------------------------------------------
73 // IIDS - used by CoCreateInstance and IUnknown::QueryInterface
74 //---------------------------------------------------------------------------
75 const IID LIBID_QuartzTypeLib
= {0x56A868B0,0x0AD4,0x11CE,{0xB0,0x3A,0x00,0x20,0xAF,0x0B,0xA7,0x70}};
76 const IID IID_IAMCollection
= {0x56A868B9,0x0AD4,0x11CE,{0xB0,0x3A,0x00,0x20,0xAF,0x0B,0xA7,0x70}};
77 const IID IID_IMediaControl
= {0x56A868B1,0x0AD4,0x11CE,{0xB0,0x3A,0x00,0x20,0xAF,0x0B,0xA7,0x70}};
78 const IID IID_IMediaEvent
= {0x56A868B6,0x0AD4,0x11CE,{0xB0,0x3A,0x00,0x20,0xAF,0x0B,0xA7,0x70}};
79 const IID IID_IMediaEventEx
= {0x56A868C0,0x0AD4,0x11CE,{0xB0,0x3A,0x00,0x20,0xAF,0x0B,0xA7,0x70}};
80 const IID IID_IMediaPosition
= {0x56A868B2,0x0AD4,0x11CE,{0xB0,0x3A,0x00,0x20,0xAF,0x0B,0xA7,0x70}};
81 const IID IID_IBasicAudio
= {0x56A868B3,0x0AD4,0x11CE,{0xB0,0x3A,0x00,0x20,0xAF,0x0B,0xA7,0x70}};
82 const IID IID_IVideoWindow
= {0x56A868B4,0x0AD4,0x11CE,{0xB0,0x3A,0x00,0x20,0xAF,0x0B,0xA7,0x70}};
83 const IID IID_IBasicVideo
= {0x56A868B5,0x0AD4,0x11CE,{0xB0,0x3A,0x00,0x20,0xAF,0x0B,0xA7,0x70}};
84 const IID IID_IBasicVideo2
= {0x329BB360,0xF6EA,0x11D1,{0x90,0x38,0x00,0xA0,0xC9,0x69,0x72,0x98}};
85 const IID IID_IDeferredCommand
= {0x56A868B8,0x0AD4,0x11CE,{0xB0,0x3A,0x00,0x20,0xAF,0x0B,0xA7,0x70}};
86 const IID IID_IQueueCommand
= {0x56A868B7,0x0AD4,0x11CE,{0xB0,0x3A,0x00,0x20,0xAF,0x0B,0xA7,0x70}};
87 const IID IID_IFilterInfo
= {0x56A868BA,0x0AD4,0x11CE,{0xB0,0x3A,0x00,0x20,0xAF,0x0B,0xA7,0x70}};
88 const IID IID_IRegFilterInfo
= {0x56A868BB,0x0AD4,0x11CE,{0xB0,0x3A,0x00,0x20,0xAF,0x0B,0xA7,0x70}};
89 const IID IID_IMediaTypeInfo
= {0x56A868BC,0x0AD4,0x11CE,{0xB0,0x3A,0x00,0x20,0xAF,0x0B,0xA7,0x70}};
90 const IID IID_IPinInfo
= {0x56A868BD,0x0AD4,0x11CE,{0xB0,0x3A,0x00,0x20,0xAF,0x0B,0xA7,0x70}};
91 const IID IID_IAMStats
= {0xBC9BCF80,0xDCD2,0x11D2,{0xAB,0xF6,0x00,0xA0,0xC9,0x05,0xF3,0x75}};
93 //TODO: These 4 lines needed?
97 #endif // CLSID_DEFINED
100 const CLSID CLSID_FilgraphManager
= {0xE436EBB3,0x524F,0x11CE,{0x9F,0x53,0x00,0x20,0xAF,0x0B,0xA7,0x70}};
102 //---------------------------------------------------------------------------
103 // COM INTERFACES (dumped from midl from quartz.idl from MSVC COM Browser)
104 //---------------------------------------------------------------------------
105 MIDL_INTERFACE("56A868B9-0AD4-11CE-B03A-0020AF0BA770")
106 IAMCollection
: public IDispatch
109 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_Count(
110 /* [retval][out] */ long __RPC_FAR
*plCount
) = 0;
112 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
Item(
113 /* [in] */ long lItem
,
114 /* [out] */ IUnknown __RPC_FAR
*__RPC_FAR
*ppUnk
) = 0;
116 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get__NewEnum(
117 /* [retval][out] */ IUnknown __RPC_FAR
*__RPC_FAR
*ppUnk
) = 0;
121 MIDL_INTERFACE("56A868B1-0AD4-11CE-B03A-0020AF0BA770")
122 IMediaControl
: public IDispatch
125 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
Run( void) = 0;
127 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
Pause( void) = 0;
129 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
Stop( void) = 0;
131 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
GetState(
132 /* [in] */ long msTimeout
,
133 /* [out] */ long __RPC_FAR
*pfs
) = 0;
135 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
RenderFile(
136 /* [in] */ BSTR strFilename
) = 0;
138 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
AddSourceFilter(
139 /* [in] */ BSTR strFilename
,
140 /* [out] */ IDispatch __RPC_FAR
*__RPC_FAR
*ppUnk
) = 0;
142 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_FilterCollection(
143 /* [retval][out] */ IDispatch __RPC_FAR
*__RPC_FAR
*ppUnk
) = 0;
145 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_RegFilterCollection(
146 /* [retval][out] */ IDispatch __RPC_FAR
*__RPC_FAR
*ppUnk
) = 0;
148 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
StopWhenReady( void) = 0;
152 MIDL_INTERFACE("56A868B6-0AD4-11CE-B03A-0020AF0BA770")
153 IMediaEvent
: public IDispatch
156 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
GetEventHandle(
157 /* [out] */ LONG_PTR __RPC_FAR
*hEvent
) = 0;
159 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
GetEvent(
160 /* [out] */ long __RPC_FAR
*lEventCode
,
161 /* [out] */ LONG_PTR __RPC_FAR
*lParam1
,
162 /* [out] */ LONG_PTR __RPC_FAR
*lParam2
,
163 /* [in] */ long msTimeout
) = 0;
165 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
WaitForCompletion(
166 /* [in] */ long msTimeout
,
167 /* [out] */ long __RPC_FAR
*pEvCode
) = 0;
169 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
CancelDefaultHandling(
170 /* [in] */ long lEvCode
) = 0;
172 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
RestoreDefaultHandling(
173 /* [in] */ long lEvCode
) = 0;
175 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
FreeEventParams(
176 /* [in] */ long lEvCode
,
177 /* [in] */ LONG_PTR lParam1
,
178 /* [in] */ LONG_PTR lParam2
) = 0;
182 MIDL_INTERFACE("56A868C0-0AD4-11CE-B03A-0020AF0BA770")
183 IMediaEventEx
: public IMediaEvent
186 virtual HRESULT __stdcall
SetNotifyWindow(
187 /* [in] */ LONG_PTR hwnd
,
188 /* [in] */ long lMsg
,
189 /* [in] */ LONG_PTR lInstanceData
) = 0;
191 virtual HRESULT __stdcall
SetNotifyFlags(
192 /* [in] */ long lNoNotifyFlags
) = 0;
194 virtual HRESULT __stdcall
GetNotifyFlags(
195 /* [out] */ long __RPC_FAR
*lplNoNotifyFlags
) = 0;
199 MIDL_INTERFACE("56A868B2-0AD4-11CE-B03A-0020AF0BA770")
200 IMediaPosition
: public IDispatch
203 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_Duration(
204 /* [retval][out] */ double __RPC_FAR
*plength
) = 0;
206 virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE
put_CurrentPosition(
207 /* [in] */ double pllTime
) = 0;
209 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_CurrentPosition(
210 /* [retval][out] */ double __RPC_FAR
*pllTime
) = 0;
212 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_StopTime(
213 /* [retval][out] */ double __RPC_FAR
*pllTime
) = 0;
215 virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE
put_StopTime(
216 /* [in] */ double pllTime
) = 0;
218 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_PrerollTime(
219 /* [retval][out] */ double __RPC_FAR
*pllTime
) = 0;
221 virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE
put_PrerollTime(
222 /* [in] */ double pllTime
) = 0;
224 virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE
put_Rate(
225 /* [in] */ double pdRate
) = 0;
227 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_Rate(
228 /* [retval][out] */ double __RPC_FAR
*pdRate
) = 0;
230 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
CanSeekForward(
231 /* [retval][out] */ long __RPC_FAR
*pCanSeekForward
) = 0;
233 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
CanSeekBackward(
234 /* [retval][out] */ long __RPC_FAR
*pCanSeekBackward
) = 0;
238 MIDL_INTERFACE("56A868B3-0AD4-11CE-B03A-0020AF0BA770")
239 IBasicAudio
: public IDispatch
242 virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE
put_Volume(
243 /* [in] */ long plVolume
) = 0;
245 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_Volume(
246 /* [retval][out] */ long __RPC_FAR
*plVolume
) = 0;
248 virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE
put_Balance(
249 /* [in] */ long plBalance
) = 0;
251 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_Balance(
252 /* [retval][out] */ long __RPC_FAR
*plBalance
) = 0;
256 MIDL_INTERFACE("56A868B4-0AD4-11CE-B03A-0020AF0BA770")
257 IVideoWindow
: public IDispatch
260 virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE
put_Caption(
261 /* [in] */ BSTR strCaption
) = 0;
263 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_Caption(
264 /* [retval][out] */ BSTR __RPC_FAR
*strCaption
) = 0;
266 virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE
put_WindowStyle(
267 /* [in] */ long WindowStyle
) = 0;
269 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_WindowStyle(
270 /* [retval][out] */ long __RPC_FAR
*WindowStyle
) = 0;
272 virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE
put_WindowStyleEx(
273 /* [in] */ long WindowStyleEx
) = 0;
275 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_WindowStyleEx(
276 /* [retval][out] */ long __RPC_FAR
*WindowStyleEx
) = 0;
278 virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE
put_AutoShow(
279 /* [in] */ long AutoShow
) = 0;
281 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_AutoShow(
282 /* [retval][out] */ long __RPC_FAR
*AutoShow
) = 0;
284 virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE
put_WindowState(
285 /* [in] */ long WindowState
) = 0;
287 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_WindowState(
288 /* [retval][out] */ long __RPC_FAR
*WindowState
) = 0;
290 virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE
put_BackgroundPalette(
291 /* [in] */ long pBackgroundPalette
) = 0;
293 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_BackgroundPalette(
294 /* [retval][out] */ long __RPC_FAR
*pBackgroundPalette
) = 0;
296 virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE
put_Visible(
297 /* [in] */ long pVisible
) = 0;
299 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_Visible(
300 /* [retval][out] */ long __RPC_FAR
*pVisible
) = 0;
302 virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE
put_Left(
303 /* [in] */ long pLeft
) = 0;
305 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_Left(
306 /* [retval][out] */ long __RPC_FAR
*pLeft
) = 0;
308 virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE
put_Width(
309 /* [in] */ long pWidth
) = 0;
311 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_Width(
312 /* [retval][out] */ long __RPC_FAR
*pWidth
) = 0;
314 virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE
put_Top(
315 /* [in] */ long pTop
) = 0;
317 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_Top(
318 /* [retval][out] */ long __RPC_FAR
*pTop
) = 0;
320 virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE
put_Height(
321 /* [in] */ long pHeight
) = 0;
323 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_Height(
324 /* [retval][out] */ long __RPC_FAR
*pHeight
) = 0;
326 virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE
put_Owner(
327 /* [in] */ LONG_PTR Owner
) = 0;
329 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_Owner(
330 /* [retval][out] */ LONG_PTR __RPC_FAR
*Owner
) = 0;
332 virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE
put_MessageDrain(
333 /* [in] */ LONG_PTR Drain
) = 0;
335 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_MessageDrain(
336 /* [retval][out] */ LONG_PTR __RPC_FAR
*Drain
) = 0;
338 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_BorderColor(
339 /* [retval][out] */ long __RPC_FAR
*Color
) = 0;
341 virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE
put_BorderColor(
342 /* [in] */ long Color
) = 0;
344 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_FullScreenMode(
345 /* [retval][out] */ long __RPC_FAR
*FullScreenMode
) = 0;
347 virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE
put_FullScreenMode(
348 /* [in] */ long FullScreenMode
) = 0;
350 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
SetWindowForeground(
351 /* [in] */ long Focus
) = 0;
353 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
NotifyOwnerMessage(
354 /* [in] */ LONG_PTR hwnd
,
355 /* [in] */ long uMsg
,
356 /* [in] */ LONG_PTR wParam
,
357 /* [in] */ LONG_PTR lParam
) = 0;
359 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
SetWindowPosition(
360 /* [in] */ long Left
,
362 /* [in] */ long Width
,
363 /* [in] */ long Height
) = 0;
365 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
GetWindowPosition(
366 /* [out] */ long __RPC_FAR
*pLeft
,
367 /* [out] */ long __RPC_FAR
*pTop
,
368 /* [out] */ long __RPC_FAR
*pWidth
,
369 /* [out] */ long __RPC_FAR
*pHeight
) = 0;
371 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
GetMinIdealImageSize(
372 /* [out] */ long __RPC_FAR
*pWidth
,
373 /* [out] */ long __RPC_FAR
*pHeight
) = 0;
375 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
GetMaxIdealImageSize(
376 /* [out] */ long __RPC_FAR
*pWidth
,
377 /* [out] */ long __RPC_FAR
*pHeight
) = 0;
379 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
GetRestorePosition(
380 /* [out] */ long __RPC_FAR
*pLeft
,
381 /* [out] */ long __RPC_FAR
*pTop
,
382 /* [out] */ long __RPC_FAR
*pWidth
,
383 /* [out] */ long __RPC_FAR
*pHeight
) = 0;
385 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
HideCursor(
386 /* [in] */ long HideCursor
) = 0;
388 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
IsCursorHidden(
389 /* [out] */ long __RPC_FAR
*CursorHidden
) = 0;
393 MIDL_INTERFACE("56A868B5-0AD4-11CE-B03A-0020AF0BA770")
394 IBasicVideo
: public IDispatch
397 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_AvgTimePerFrame(
398 /* [retval][out] */ double __RPC_FAR
*pAvgTimePerFrame
) = 0;
400 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_BitRate(
401 /* [retval][out] */ long __RPC_FAR
*pBitRate
) = 0;
403 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_BitErrorRate(
404 /* [retval][out] */ long __RPC_FAR
*pBitErrorRate
) = 0;
406 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_VideoWidth(
407 /* [retval][out] */ long __RPC_FAR
*pVideoWidth
) = 0;
409 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_VideoHeight(
410 /* [retval][out] */ long __RPC_FAR
*pVideoHeight
) = 0;
412 virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE
put_SourceLeft(
413 /* [in] */ long pSourceLeft
) = 0;
415 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_SourceLeft(
416 /* [retval][out] */ long __RPC_FAR
*pSourceLeft
) = 0;
418 virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE
put_SourceWidth(
419 /* [in] */ long pSourceWidth
) = 0;
421 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_SourceWidth(
422 /* [retval][out] */ long __RPC_FAR
*pSourceWidth
) = 0;
424 virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE
put_SourceTop(
425 /* [in] */ long pSourceTop
) = 0;
427 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_SourceTop(
428 /* [retval][out] */ long __RPC_FAR
*pSourceTop
) = 0;
430 virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE
put_SourceHeight(
431 /* [in] */ long pSourceHeight
) = 0;
433 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_SourceHeight(
434 /* [retval][out] */ long __RPC_FAR
*pSourceHeight
) = 0;
436 virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE
put_DestinationLeft(
437 /* [in] */ long pDestinationLeft
) = 0;
439 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_DestinationLeft(
440 /* [retval][out] */ long __RPC_FAR
*pDestinationLeft
) = 0;
442 virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE
put_DestinationWidth(
443 /* [in] */ long pDestinationWidth
) = 0;
445 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_DestinationWidth(
446 /* [retval][out] */ long __RPC_FAR
*pDestinationWidth
) = 0;
448 virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE
put_DestinationTop(
449 /* [in] */ long pDestinationTop
) = 0;
451 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_DestinationTop(
452 /* [retval][out] */ long __RPC_FAR
*pDestinationTop
) = 0;
454 virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE
put_DestinationHeight(
455 /* [in] */ long pDestinationHeight
) = 0;
457 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_DestinationHeight(
458 /* [retval][out] */ long __RPC_FAR
*pDestinationHeight
) = 0;
460 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
SetSourcePosition(
461 /* [in] */ long Left
,
463 /* [in] */ long Width
,
464 /* [in] */ long Height
) = 0;
466 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
GetSourcePosition(
467 /* [out] */ long __RPC_FAR
*pLeft
,
468 /* [out] */ long __RPC_FAR
*pTop
,
469 /* [out] */ long __RPC_FAR
*pWidth
,
470 /* [out] */ long __RPC_FAR
*pHeight
) = 0;
472 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
SetDefaultSourcePosition( void) = 0;
474 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
SetDestinationPosition(
475 /* [in] */ long Left
,
477 /* [in] */ long Width
,
478 /* [in] */ long Height
) = 0;
480 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
GetDestinationPosition(
481 /* [out] */ long __RPC_FAR
*pLeft
,
482 /* [out] */ long __RPC_FAR
*pTop
,
483 /* [out] */ long __RPC_FAR
*pWidth
,
484 /* [out] */ long __RPC_FAR
*pHeight
) = 0;
486 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
SetDefaultDestinationPosition( void) = 0;
488 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
GetVideoSize(
489 /* [out] */ long __RPC_FAR
*pWidth
,
490 /* [out] */ long __RPC_FAR
*pHeight
) = 0;
492 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
GetVideoPaletteEntries(
493 /* [in] */ long StartIndex
,
494 /* [in] */ long Entries
,
495 /* [out] */ long __RPC_FAR
*pRetrieved
,
496 /* [out] */ long __RPC_FAR
*pPalette
) = 0;
498 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
GetCurrentImage(
499 /* [out][in] */ long __RPC_FAR
*pBufferSize
,
500 /* [out] */ long __RPC_FAR
*pDIBImage
) = 0;
502 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
IsUsingDefaultSource( void) = 0;
504 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
IsUsingDefaultDestination( void) = 0;
508 MIDL_INTERFACE("329BB360-F6EA-11D1-9038-00A0C9697298")
509 IBasicVideo2
: public IBasicVideo
512 virtual HRESULT __stdcall
GetPreferredAspectRatio(
513 /* [out] */ long __RPC_FAR
*plAspectX
,
514 /* [out] */ long __RPC_FAR
*plAspectY
) = 0;
518 MIDL_INTERFACE("56A868B8-0AD4-11CE-B03A-0020AF0BA770")
519 IDeferredCommand
: public IUnknown
522 virtual HRESULT __stdcall
Cancel( void) = 0;
524 virtual HRESULT __stdcall
Confidence(
525 /* [out] */ long __RPC_FAR
*pConfidence
) = 0;
527 virtual HRESULT __stdcall
Postpone(
528 /* [in] */ double newtime
) = 0;
530 virtual HRESULT __stdcall
GetHResult(
531 /* [out] */ HRESULT __RPC_FAR
*phrResult
) = 0;
535 MIDL_INTERFACE("56A868B7-0AD4-11CE-B03A-0020AF0BA770")
536 IQueueCommand
: public IUnknown
539 virtual HRESULT __stdcall
InvokeAtStreamTime(
540 /* [out] */ IDeferredCommand __RPC_FAR
*__RPC_FAR
*pCmd
,
541 /* [in] */ double time
,
542 /* [in] */ GUID __RPC_FAR
*iid
,
543 /* [in] */ long dispidMethod
,
544 /* [in] */ short wFlags
,
545 /* [in] */ long cArgs
,
546 /* [in] */ VARIANT __RPC_FAR
*pDispParams
,
547 /* [out][in] */ VARIANT __RPC_FAR
*pvarResult
,
548 /* [out] */ short __RPC_FAR
*puArgErr
) = 0;
550 virtual HRESULT __stdcall
InvokeAtPresentationTime(
551 /* [out] */ IDeferredCommand __RPC_FAR
*__RPC_FAR
*pCmd
,
552 /* [in] */ double time
,
553 /* [in] */ GUID __RPC_FAR
*iid
,
554 /* [in] */ long dispidMethod
,
555 /* [in] */ short wFlags
,
556 /* [in] */ long cArgs
,
557 /* [in] */ VARIANT __RPC_FAR
*pDispParams
,
558 /* [out][in] */ VARIANT __RPC_FAR
*pvarResult
,
559 /* [out] */ short __RPC_FAR
*puArgErr
) = 0;
563 MIDL_INTERFACE("56A868BA-0AD4-11CE-B03A-0020AF0BA770")
564 IFilterInfo
: public IDispatch
567 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
FindPin(
568 /* [in] */ BSTR strPinID
,
569 /* [out] */ IDispatch __RPC_FAR
*__RPC_FAR
*ppUnk
) = 0;
571 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_Name(
572 /* [retval][out] */ BSTR __RPC_FAR
*strName
) = 0;
574 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_VendorInfo(
575 /* [retval][out] */ BSTR __RPC_FAR
*strVendorInfo
) = 0;
577 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_Filter(
578 /* [retval][out] */ IUnknown __RPC_FAR
*__RPC_FAR
*ppUnk
) = 0;
580 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_Pins(
581 /* [retval][out] */ IDispatch __RPC_FAR
*__RPC_FAR
*ppUnk
) = 0;
583 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_IsFileSource(
584 /* [retval][out] */ long __RPC_FAR
*pbIsSource
) = 0;
586 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_Filename(
587 /* [retval][out] */ BSTR __RPC_FAR
*pstrFilename
) = 0;
589 virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE
put_Filename(
590 /* [in] */ BSTR pstrFilename
) = 0;
594 MIDL_INTERFACE("56A868BB-0AD4-11CE-B03A-0020AF0BA770")
595 IRegFilterInfo
: public IDispatch
598 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_Name(
599 /* [retval][out] */ BSTR __RPC_FAR
*strName
) = 0;
601 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
Filter(
602 /* [out] */ IDispatch __RPC_FAR
*__RPC_FAR
*ppUnk
) = 0;
606 MIDL_INTERFACE("56A868BC-0AD4-11CE-B03A-0020AF0BA770")
607 IMediaTypeInfo
: public IDispatch
610 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_Type(
611 /* [retval][out] */ BSTR __RPC_FAR
*strType
) = 0;
613 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_Subtype(
614 /* [retval][out] */ BSTR __RPC_FAR
*strType
) = 0;
618 MIDL_INTERFACE("56A868BD-0AD4-11CE-B03A-0020AF0BA770")
619 IPinInfo
: public IDispatch
622 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_Pin(
623 /* [retval][out] */ IUnknown __RPC_FAR
*__RPC_FAR
*ppUnk
) = 0;
625 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_ConnectedTo(
626 /* [retval][out] */ IDispatch __RPC_FAR
*__RPC_FAR
*ppUnk
) = 0;
628 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_ConnectionMediaType(
629 /* [retval][out] */ IDispatch __RPC_FAR
*__RPC_FAR
*ppUnk
) = 0;
631 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_FilterInfo(
632 /* [retval][out] */ IDispatch __RPC_FAR
*__RPC_FAR
*ppUnk
) = 0;
634 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_Name(
635 /* [retval][out] */ BSTR __RPC_FAR
*ppUnk
) = 0;
637 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_Direction(
638 /* [retval][out] */ long __RPC_FAR
*ppDirection
) = 0;
640 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_PinID(
641 /* [retval][out] */ BSTR __RPC_FAR
*strPinID
) = 0;
643 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_MediaTypes(
644 /* [retval][out] */ IDispatch __RPC_FAR
*__RPC_FAR
*ppUnk
) = 0;
646 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
Connect(
647 /* [in] */ IUnknown __RPC_FAR
*pPin
) = 0;
649 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
ConnectDirect(
650 /* [in] */ IUnknown __RPC_FAR
*pPin
) = 0;
652 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
ConnectWithType(
653 /* [in] */ IUnknown __RPC_FAR
*pPin
,
654 /* [in] */ IDispatch __RPC_FAR
*pMediaType
) = 0;
656 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
Disconnect( void) = 0;
658 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
Render( void) = 0;
662 MIDL_INTERFACE("BC9BCF80-DCD2-11D2-ABF6-00A0C905F375")
663 IAMStats
: public IDispatch
666 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
Reset( void) = 0;
668 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_Count(
669 /* [retval][out] */ long __RPC_FAR
*plCount
) = 0;
671 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
GetValueByIndex(
672 /* [in] */ long lIndex
,
673 /* [out] */ BSTR __RPC_FAR
*szName
,
674 /* [out] */ long __RPC_FAR
*lCount
,
675 /* [out] */ double __RPC_FAR
*dLast
,
676 /* [out] */ double __RPC_FAR
*dAverage
,
677 /* [out] */ double __RPC_FAR
*dStdDev
,
678 /* [out] */ double __RPC_FAR
*dMin
,
679 /* [out] */ double __RPC_FAR
*dMax
) = 0;
681 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
GetValueByName(
682 /* [in] */ BSTR szName
,
683 /* [out] */ long __RPC_FAR
*lIndex
,
684 /* [out] */ long __RPC_FAR
*lCount
,
685 /* [out] */ double __RPC_FAR
*dLast
,
686 /* [out] */ double __RPC_FAR
*dAverage
,
687 /* [out] */ double __RPC_FAR
*dStdDev
,
688 /* [out] */ double __RPC_FAR
*dMin
,
689 /* [out] */ double __RPC_FAR
*dMax
) = 0;
691 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
GetIndex(
692 /* [in] */ BSTR szName
,
693 /* [in] */ long lCreate
,
694 /* [out] */ long __RPC_FAR
*plIndex
) = 0;
696 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
AddValue(
697 /* [in] */ long lIndex
,
698 /* [in] */ double dValue
) = 0;
702 //------------------------------------------------------------------
703 // wxAMMediaBackend (Active Movie)
704 //------------------------------------------------------------------
705 class WXDLLIMPEXP_MEDIA wxAMMediaBackend
: public wxMediaBackend
710 virtual ~wxAMMediaBackend();
712 virtual bool CreateControl(wxControl
* ctrl
, wxWindow
* parent
,
717 const wxValidator
& validator
,
718 const wxString
& name
);
721 virtual bool Pause();
724 virtual bool Load(const wxString
& fileName
);
725 virtual bool Load(const wxURI
& location
);
727 virtual wxMediaState
GetState();
729 virtual bool SetPosition(wxLongLong where
);
730 virtual wxLongLong
GetPosition();
731 virtual wxLongLong
GetDuration();
733 virtual void Move(int x
, int y
, int w
, int h
);
734 wxSize
GetVideoSize() const;
736 virtual double GetPlaybackRate();
737 virtual bool SetPlaybackRate(double);
739 virtual double GetVolume();
740 virtual bool SetVolume(double);
746 static LRESULT CALLBACK
NotifyWndProc(HWND hWnd
, UINT nMsg
,
747 WPARAM wParam
, LPARAM lParam
);
749 LRESULT CALLBACK
OnNotifyWndProc(HWND hWnd
, UINT nMsg
,
750 WPARAM wParam
, LPARAM lParam
);
756 IMediaControl
* m_pMC
;
757 IMediaEventEx
* m_pME
;
758 IMediaPosition
* m_pMS
;
764 DECLARE_DYNAMIC_CLASS(wxAMMediaBackend
);
767 #endif //wxUSE_DIRECTSHOW
769 //---------------------------------------------------------------------------
773 //---------------------------------------------------------------------------
775 //---------------------------------------------------------------------------
777 //---------------------------------------------------------------------------
778 #include <mmsystem.h>
780 class WXDLLIMPEXP_MEDIA wxMCIMediaBackend
: public wxMediaBackend
785 ~wxMCIMediaBackend();
787 virtual bool CreateControl(wxControl
* ctrl
, wxWindow
* parent
,
792 const wxValidator
& validator
,
793 const wxString
& name
);
796 virtual bool Pause();
799 virtual bool Load(const wxString
& fileName
);
800 virtual bool Load(const wxURI
& location
);
802 virtual wxMediaState
GetState();
804 virtual bool SetPosition(wxLongLong where
);
805 virtual wxLongLong
GetPosition();
806 virtual wxLongLong
GetDuration();
808 virtual void Move(int x
, int y
, int w
, int h
);
809 wxSize
GetVideoSize() const;
811 virtual double GetPlaybackRate();
812 virtual bool SetPlaybackRate(double dRate
);
814 virtual double GetVolume();
815 virtual bool SetVolume(double);
817 static LRESULT CALLBACK
NotifyWndProc(HWND hWnd
, UINT nMsg
,
818 WPARAM wParam
, LPARAM lParam
);
820 LRESULT CALLBACK
OnNotifyWndProc(HWND hWnd
, UINT nMsg
,
821 WPARAM wParam
, LPARAM lParam
);
823 MCIDEVICEID m_hDev
; //Our MCI Device ID/Handler
824 wxControl
* m_ctrl
; //Parent control
825 HWND m_hNotifyWnd
; //Window to use for MCI events
826 bool m_bVideo
; //Whether or not we have video
828 DECLARE_DYNAMIC_CLASS(wxMCIMediaBackend
)
831 //---------------------------------------------------------------------------
835 //---------------------------------------------------------------------------
837 //---------------------------------------------------------------------------
838 // QT Compilation Guard
839 //---------------------------------------------------------------------------
842 //---------------------------------------------------------------------------
844 //---------------------------------------------------------------------------
845 //#include <qtml.h> //Windoze QT include
846 //#include <QuickTimeComponents.h> //Standard QT stuff
847 #include "wx/dynlib.h"
849 //---------------------------------------------------------------------------
851 //---------------------------------------------------------------------------
852 typedef struct MovieRecord
* Movie
;
853 typedef wxInt16 OSErr
;
854 typedef wxInt32 OSStatus
;
857 typedef unsigned char Str255
[256];
858 #define StringPtr unsigned char*
859 #define newMovieActive 1
863 #define OSType unsigned long
864 #define CGrafPtr struct GrafPort *
865 #define TimeScale long
866 #define TimeBase struct TimeBaseRecord *
871 Str255 name
; /*Str63 on mac, Str255 on msw */
887 wide value
; /* units */
888 TimeScale scale
; /* units per second */
892 //---------------------------------------------------------------------------
894 //---------------------------------------------------------------------------
895 #define wxDL_METHOD_DEFINE( rettype, name, args, shortargs, defret ) \
896 typedef rettype (* name ## Type) args ; \
897 name ## Type pfn_ ## name; \
899 { if (m_ok) return pfn_ ## name shortargs ; return defret; }
901 #define wxDL_VOIDMETHOD_DEFINE( name, args, shortargs ) \
902 typedef void (* name ## Type) args ; \
903 name ## Type pfn_ ## name; \
905 { if (m_ok) pfn_ ## name shortargs ; }
907 #define wxDL_METHOD_LOAD( lib, name, success ) \
908 pfn_ ## name = (name ## Type) lib.GetSymbol( wxT(#name), &success ); \
909 if (!success) return false;
911 //Class that utilizes Robert Roeblings Dynamic Library Macros
912 class wxQuickTimeLibrary
915 ~wxQuickTimeLibrary()
922 bool IsOk() const {return m_ok
;}
925 wxDynamicLibrary m_dll
;
929 wxDL_VOIDMETHOD_DEFINE( StartMovie
, (Movie m
), (m
) );
930 wxDL_VOIDMETHOD_DEFINE( StopMovie
, (Movie m
), (m
) );
931 wxDL_METHOD_DEFINE( bool, IsMovieDone
, (Movie m
), (m
), false);
932 wxDL_VOIDMETHOD_DEFINE( GoToBeginningOfMovie
, (Movie m
), (m
) );
933 wxDL_METHOD_DEFINE( OSErr
, GetMoviesError
, (), (), -1);
934 wxDL_METHOD_DEFINE( OSErr
, EnterMovies
, (), (), -1);
935 wxDL_VOIDMETHOD_DEFINE( ExitMovies
, (), () );
936 wxDL_METHOD_DEFINE( OSErr
, InitializeQTML
, (long flags
), (flags
), -1);
937 wxDL_VOIDMETHOD_DEFINE( TerminateQTML
, (), () );
939 wxDL_METHOD_DEFINE( OSErr
, NativePathNameToFSSpec
,
940 (char* inName
, FSSpec
* outFile
, long flags
),
941 (inName
, outFile
, flags
), -1);
943 wxDL_METHOD_DEFINE( OSErr
, OpenMovieFile
,
944 (const FSSpec
* fileSpec
, short * resRefNum
, wxInt8 permission
),
945 (fileSpec
, resRefNum
, permission
), -1 );
947 wxDL_METHOD_DEFINE( OSErr
, CloseMovieFile
,
948 (short resRefNum
), (resRefNum
), -1);
950 wxDL_METHOD_DEFINE( OSErr
, NewMovieFromFile
,
951 (Movie
* theMovie
, short resRefNum
, short * resId
,
952 StringPtr resName
, short newMovieFlags
,
953 bool * dataRefWasChanged
),
954 (theMovie
, resRefNum
, resId
, resName
, newMovieFlags
,
955 dataRefWasChanged
), -1);
957 wxDL_VOIDMETHOD_DEFINE( SetMovieRate
, (Movie m
, Fixed rate
), (m
, rate
) );
958 wxDL_METHOD_DEFINE( Fixed
, GetMovieRate
, (Movie m
), (m
), 0);
959 wxDL_VOIDMETHOD_DEFINE( MoviesTask
, (Movie m
, long maxms
), (m
, maxms
) );
960 wxDL_VOIDMETHOD_DEFINE( BlockMove
,
961 (const char* p1
, const char* p2
, long s
), (p1
,p2
,s
) );
962 wxDL_METHOD_DEFINE( Handle
, NewHandleClear
, (long s
), (s
), NULL
);
964 wxDL_METHOD_DEFINE( OSErr
, NewMovieFromDataRef
,
965 (Movie
* m
, short flags
, short * id
,
966 Handle dataRef
, OSType dataRefType
),
967 (m
,flags
,id
,dataRef
,dataRefType
), -1 );
969 wxDL_VOIDMETHOD_DEFINE( DisposeHandle
, (Handle h
), (h
) );
970 wxDL_VOIDMETHOD_DEFINE( GetMovieNaturalBoundsRect
, (Movie m
, Rect
* r
), (m
,r
) );
971 wxDL_METHOD_DEFINE( void*, GetMovieIndTrackType
,
972 (Movie m
, long index
, OSType type
, long flags
),
973 (m
,index
,type
,flags
), NULL
);
974 wxDL_VOIDMETHOD_DEFINE( CreatePortAssociation
,
975 (void* hWnd
, void* junk
, long morejunk
), (hWnd
, junk
, morejunk
) );
976 wxDL_METHOD_DEFINE(void*, GetNativeWindowPort
, (void* hWnd
), (hWnd
), NULL
);
977 wxDL_VOIDMETHOD_DEFINE(SetMovieGWorld
, (Movie m
, CGrafPtr port
, void* whatever
),
978 (m
, port
, whatever
) );
979 wxDL_VOIDMETHOD_DEFINE(DisposeMovie
, (Movie m
), (m
) );
980 wxDL_VOIDMETHOD_DEFINE(SetMovieBox
, (Movie m
, Rect
* r
), (m
,r
));
981 wxDL_VOIDMETHOD_DEFINE(SetMovieTimeScale
, (Movie m
, long s
), (m
,s
));
982 wxDL_METHOD_DEFINE(long, GetMovieDuration
, (Movie m
), (m
), 0);
983 wxDL_METHOD_DEFINE(TimeBase
, GetMovieTimeBase
, (Movie m
), (m
), 0);
984 wxDL_METHOD_DEFINE(TimeScale
, GetMovieTimeScale
, (Movie m
), (m
), 0);
985 wxDL_METHOD_DEFINE(long, GetMovieTime
, (Movie m
, void* cruft
), (m
,cruft
), 0);
986 wxDL_VOIDMETHOD_DEFINE(SetMovieTime
, (Movie m
, TimeRecord
* tr
), (m
,tr
) );
987 wxDL_METHOD_DEFINE(short, GetMovieVolume
, (Movie m
), (m
), 0);
988 wxDL_VOIDMETHOD_DEFINE(SetMovieVolume
, (Movie m
, short sVolume
), (m
,sVolume
) );
991 bool wxQuickTimeLibrary::Initialize()
995 if(!m_dll
.Load(wxT("qtmlClient.dll")))
1000 wxDL_METHOD_LOAD( m_dll
, StartMovie
, bOk
);
1001 wxDL_METHOD_LOAD( m_dll
, StopMovie
, bOk
);
1002 wxDL_METHOD_LOAD( m_dll
, IsMovieDone
, bOk
);
1003 wxDL_METHOD_LOAD( m_dll
, GoToBeginningOfMovie
, bOk
);
1004 wxDL_METHOD_LOAD( m_dll
, GetMoviesError
, bOk
);
1005 wxDL_METHOD_LOAD( m_dll
, EnterMovies
, bOk
);
1006 wxDL_METHOD_LOAD( m_dll
, ExitMovies
, bOk
);
1007 wxDL_METHOD_LOAD( m_dll
, InitializeQTML
, bOk
);
1008 wxDL_METHOD_LOAD( m_dll
, TerminateQTML
, bOk
);
1009 wxDL_METHOD_LOAD( m_dll
, NativePathNameToFSSpec
, bOk
);
1010 wxDL_METHOD_LOAD( m_dll
, OpenMovieFile
, bOk
);
1011 wxDL_METHOD_LOAD( m_dll
, CloseMovieFile
, bOk
);
1012 wxDL_METHOD_LOAD( m_dll
, NewMovieFromFile
, bOk
);
1013 wxDL_METHOD_LOAD( m_dll
, GetMovieRate
, bOk
);
1014 wxDL_METHOD_LOAD( m_dll
, SetMovieRate
, bOk
);
1015 wxDL_METHOD_LOAD( m_dll
, MoviesTask
, bOk
);
1016 wxDL_METHOD_LOAD( m_dll
, BlockMove
, bOk
);
1017 wxDL_METHOD_LOAD( m_dll
, NewHandleClear
, bOk
);
1018 wxDL_METHOD_LOAD( m_dll
, NewMovieFromDataRef
, bOk
);
1019 wxDL_METHOD_LOAD( m_dll
, DisposeHandle
, bOk
);
1020 wxDL_METHOD_LOAD( m_dll
, GetMovieNaturalBoundsRect
, bOk
);
1021 wxDL_METHOD_LOAD( m_dll
, GetMovieIndTrackType
, bOk
);
1022 wxDL_METHOD_LOAD( m_dll
, CreatePortAssociation
, bOk
);
1023 wxDL_METHOD_LOAD( m_dll
, GetNativeWindowPort
, bOk
);
1024 wxDL_METHOD_LOAD( m_dll
, SetMovieGWorld
, bOk
);
1025 wxDL_METHOD_LOAD( m_dll
, DisposeMovie
, bOk
);
1026 wxDL_METHOD_LOAD( m_dll
, SetMovieBox
, bOk
);
1027 wxDL_METHOD_LOAD( m_dll
, SetMovieTimeScale
, bOk
);
1028 wxDL_METHOD_LOAD( m_dll
, GetMovieDuration
, bOk
);
1029 wxDL_METHOD_LOAD( m_dll
, GetMovieTimeBase
, bOk
);
1030 wxDL_METHOD_LOAD( m_dll
, GetMovieTimeScale
, bOk
);
1031 wxDL_METHOD_LOAD( m_dll
, GetMovieTime
, bOk
);
1032 wxDL_METHOD_LOAD( m_dll
, SetMovieTime
, bOk
);
1033 wxDL_METHOD_LOAD( m_dll
, GetMovieVolume
, bOk
);
1034 wxDL_METHOD_LOAD( m_dll
, SetMovieVolume
, bOk
);
1041 class WXDLLIMPEXP_MEDIA wxQTMediaBackend
: public wxMediaBackend
1046 ~wxQTMediaBackend();
1048 virtual bool CreateControl(wxControl
* ctrl
, wxWindow
* parent
,
1053 const wxValidator
& validator
,
1054 const wxString
& name
);
1056 virtual bool Play();
1057 virtual bool Pause();
1058 virtual bool Stop();
1060 virtual bool Load(const wxString
& fileName
);
1061 virtual bool Load(const wxURI
& location
);
1063 virtual wxMediaState
GetState();
1065 virtual bool SetPosition(wxLongLong where
);
1066 virtual wxLongLong
GetPosition();
1067 virtual wxLongLong
GetDuration();
1069 virtual void Move(int x
, int y
, int w
, int h
);
1070 wxSize
GetVideoSize() const;
1072 virtual double GetPlaybackRate();
1073 virtual bool SetPlaybackRate(double dRate
);
1075 virtual double GetVolume();
1076 virtual bool SetVolume(double);
1081 wxSize m_bestSize
; //Original movie size
1082 Movie m_movie
; //QT Movie handle/instance
1083 wxControl
* m_ctrl
; //Parent control
1084 bool m_bVideo
; //Whether or not we have video
1085 class _wxQTTimer
* m_timer
; //Timer for streaming the movie
1086 wxQuickTimeLibrary m_lib
;
1089 DECLARE_DYNAMIC_CLASS(wxQTMediaBackend
);
1092 //---------------------------------------------------------------------------
1093 // End QT Compilation Guard
1094 //---------------------------------------------------------------------------
1095 #endif //wxUSE_QUICKTIME
1097 //===========================================================================
1099 //===========================================================================
1101 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1105 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1107 //---------------------------------------------------------------------------
1108 // Only use if user wants it -
1109 //---------------------------------------------------------------------------
1110 #if wxUSE_DIRECTSHOW
1112 IMPLEMENT_DYNAMIC_CLASS(wxAMMediaBackend
, wxMediaBackend
);
1114 // Numerical value for when the graph reaches the stop position
1115 #define WM_GRAPHNOTIFY WM_USER+13
1117 //---------------------------------------------------------------------------
1118 // Usual debugging macros
1119 //---------------------------------------------------------------------------
1121 #define wxAMVERIFY(x) \
1123 HRESULT hrdsv = (x); \
1124 if ( FAILED(hrdsv) ) \
1126 /*TCHAR szError[MAX_ERROR_TEXT_LEN];*/ \
1127 /*if( AMGetErrorText(hrdsv, szError, MAX_ERROR_TEXT_LEN) == 0)*/ \
1129 /*wxFAIL_MSG( wxString::Format(wxT("DirectShow error \"%s\" ")*/\
1130 /*wxT("occured at line %i in ")*/ \
1131 /*wxT("mediactrl.cpp"),*/ \
1132 /*szError, __LINE__) );*/ \
1135 wxFAIL_MSG( wxString::Format(wxT("Unknown error (%i) ") \
1137 wxT(" line %i in mediactrl.cpp."), \
1138 (int)hrdsv, __LINE__) ); \
1141 #define wxVERIFY(x) wxASSERT((x))
1143 #define wxAMVERIFY(x) (x)
1144 #define wxVERIFY(x) (x)
1147 //---------------------------------------------------------------------------
1148 // Standard macros for ease of use
1149 //---------------------------------------------------------------------------
1150 #define SAFE_RELEASE(x) { if (x) x->Release(); x = NULL; }
1152 //---------------------------------------------------------------------------
1153 // wxAMMediaBackend Constructor
1155 // Sets m_hNotifyWnd to NULL to signify that we haven't loaded anything yet
1156 //---------------------------------------------------------------------------
1157 wxAMMediaBackend::wxAMMediaBackend() : m_hNotifyWnd(NULL
)
1161 //---------------------------------------------------------------------------
1162 // wxAMMediaBackend Destructor
1164 // Cleans up everything
1165 //---------------------------------------------------------------------------
1166 wxAMMediaBackend::~wxAMMediaBackend()
1172 //---------------------------------------------------------------------------
1173 // wxAMMediaBackend::CreateControl
1175 // ActiveMovie does not really have any native control to speak of,
1176 // so we just create a normal control.
1178 // We also check to see if ActiveMovie is installed
1179 //---------------------------------------------------------------------------
1180 bool wxAMMediaBackend::CreateControl(wxControl
* ctrl
, wxWindow
* parent
,
1185 const wxValidator
& validator
,
1186 const wxString
& name
)
1188 //create our filter graph - the beuty of COM is that it loads
1189 //quartz.dll for us :)
1190 HRESULT hr
= CoCreateInstance(CLSID_FilgraphManager
, NULL
, CLSCTX_INPROC_SERVER
,
1191 IID_IMediaControl
, (void**)&m_pMC
);
1193 //directshow not installed?
1197 //release the filter graph - we don't need it yet
1203 // By default wxWindow(s) is created with a border -
1204 // so we need to get rid of those, and create with
1205 // wxCLIP_CHILDREN, so that if the driver/backend
1206 // is a child window, it refereshes properly
1208 if ( !ctrl
->wxControl::Create(parent
, id
, pos
, size
,
1209 (style
& ~wxBORDER_MASK
) | wxBORDER_NONE
| wxCLIP_CHILDREN
,
1218 //---------------------------------------------------------------------------
1219 // wxAMMediaBackend::Load (file version)
1221 // Creates an Active Movie filter graph from a file or url
1222 //---------------------------------------------------------------------------
1223 bool wxAMMediaBackend::Load(const wxString
& fileName
)
1225 //if previously loaded cleanup
1229 //We already checked for success in CreateControl
1230 CoCreateInstance(CLSID_FilgraphManager
, NULL
, CLSCTX_INPROC_SERVER
,
1231 IID_IMediaControl
, (void**)&m_pMC
);
1233 //load the graph & render
1234 if( FAILED(m_pMC
->RenderFile(wxBasicString(fileName
).Get())) )
1237 //get the interfaces, all of them
1238 wxAMVERIFY( m_pMC
->QueryInterface(IID_IMediaEventEx
, (void**)&m_pME
) );
1239 wxAMVERIFY( m_pMC
->QueryInterface(IID_IMediaPosition
, (void**)&m_pMS
) );
1240 wxAMVERIFY( m_pMC
->QueryInterface(IID_IVideoWindow
, (void**)&m_pVW
) );
1241 wxAMVERIFY( m_pMC
->QueryInterface(IID_IBasicAudio
, (void**)&m_pBA
) );
1242 wxAMVERIFY( m_pMC
->QueryInterface(IID_IBasicVideo
, (void**)&m_pBV
) );
1244 //We could tell if the media has audio or not by
1248 //pBA->get_Volume(&lVolume) == E_NOTIMPL
1253 //Obtain the _actual_ size of the movie & remember it
1258 m_bestSize
.x
= m_bestSize
.y
= 0;
1260 m_bVideo
= SUCCEEDED( m_pVW
->GetWindowPosition( &nX
,
1262 (long*)&m_bestSize
.x
,
1263 (long*)&m_bestSize
.y
) );
1266 //If we have video in the media - set it up so that
1267 //its a child window of the control, its visible,
1268 //and that the control is the owner of the video window
1272 wxAMVERIFY( m_pVW
->put_Owner((LONG_PTR
)m_ctrl
->GetHandle()) );
1273 wxAMVERIFY( m_pVW
->put_WindowStyle(WS_CHILD
| WS_CLIPSIBLINGS
) );
1274 wxAMVERIFY( m_pVW
->put_Visible(-1) ); //OATRUE == -1
1278 // Create a hidden window and register to handle
1279 // directshow events for this graph
1280 // Note that wxCanvasClassName is already registered
1281 // and used by all wxWindows and normal wxControls
1283 m_hNotifyWnd
= ::CreateWindow
1297 wxLogSysError( wxT("Could not create hidden needed for ")
1298 wxT("registering for DirectShow events!") );
1304 ::SetWindowLong(m_hNotifyWnd
, GWL_WNDPROC
,
1305 (LONG
)wxAMMediaBackend::NotifyWndProc
);
1307 ::SetWindowLongPtr(m_hNotifyWnd
, GWLP_WNDPROC
,
1308 (LONG_PTR
)wxAMMediaBackend::NotifyWndProc
);
1311 ::SetWindowLong(m_hNotifyWnd
, GWL_USERDATA
,
1314 wxAMVERIFY( m_pME
->SetNotifyWindow((LONG_PTR
)m_hNotifyWnd
,
1315 WM_GRAPHNOTIFY
, 0) );
1318 // Force the parent window of this control to recalculate
1319 // the size of this if sizers are being used
1320 // and render the results immediately
1322 m_ctrl
->InvalidateBestSize();
1323 m_ctrl
->GetParent()->Layout();
1324 m_ctrl
->GetParent()->Refresh();
1325 m_ctrl
->GetParent()->Update();
1330 //---------------------------------------------------------------------------
1331 // wxAMMediaBackend::Load (URL Version)
1333 // Loads media from a URL. Interestingly enough DirectShow
1334 // appears (?) to escape the URL for us, at least on normal
1336 //---------------------------------------------------------------------------
1337 bool wxAMMediaBackend::Load(const wxURI
& location
)
1339 return Load(location
.BuildUnescapedURI());
1342 //---------------------------------------------------------------------------
1343 // wxAMMediaBackend::Play
1345 // Plays the stream. If it is non-seekable, it will restart it.
1346 //---------------------------------------------------------------------------
1347 bool wxAMMediaBackend::Play()
1349 return SUCCEEDED( m_pMC
->Run() );
1352 //---------------------------------------------------------------------------
1353 // wxAMMediaBackend::Pause
1355 // Pauses the stream.
1356 //---------------------------------------------------------------------------
1357 bool wxAMMediaBackend::Pause()
1359 return SUCCEEDED( m_pMC
->Pause() );
1362 //---------------------------------------------------------------------------
1363 // wxAMMediaBackend::Stop
1365 // Stops the stream.
1366 //---------------------------------------------------------------------------
1367 bool wxAMMediaBackend::Stop()
1369 bool bOK
= SUCCEEDED( m_pMC
->Stop() );
1371 //We don't care if it can't get to the beginning in directshow -
1372 //it could be a non-seeking filter (wince midi) in which case playing
1373 //starts all over again
1378 //---------------------------------------------------------------------------
1379 // wxAMMediaBackend::SetPosition
1381 // 1) Translates the current position's time to directshow time,
1382 // which is in a scale of 1 second (in a double)
1383 // 2) Sets the play position of the IMediaSeeking interface -
1384 // passing NULL as the stop position means to keep the old
1386 //---------------------------------------------------------------------------
1387 bool wxAMMediaBackend::SetPosition(wxLongLong where
)
1389 return SUCCEEDED( m_pMS
->put_CurrentPosition(
1390 ((LONGLONG
)where
.GetValue()) / 1000
1395 //---------------------------------------------------------------------------
1396 // wxAMMediaBackend::GetPosition
1398 // 1) Obtains the current play and stop positions from IMediaSeeking
1399 // 2) Returns the play position translated to our time base
1400 //---------------------------------------------------------------------------
1401 wxLongLong
wxAMMediaBackend::GetPosition()
1404 wxAMVERIFY( m_pMS
->get_CurrentPosition(&outCur
) );
1406 //h,m,s,milli - outdur is in 1 second (double)
1407 return (outCur
*1000);
1410 //---------------------------------------------------------------------------
1411 // wxAMMediaBackend::SetVolume
1413 // Sets the volume through the IBasicAudio interface -
1414 // value ranges from 0 (MAX volume) to -10000 (minimum volume).
1415 // -100 per decibel.
1416 //---------------------------------------------------------------------------
1417 bool wxAMMediaBackend::SetVolume(double dVolume
)
1419 return SUCCEEDED(m_pBA
->put_Volume( (long) ((dVolume
-1.0) * 10000.0) ));
1422 //---------------------------------------------------------------------------
1423 // wxAMMediaBackend::GetVolume
1425 // Gets the volume through the IBasicAudio interface -
1426 // value ranges from 0 (MAX volume) to -10000 (minimum volume).
1427 // -100 per decibel.
1428 //---------------------------------------------------------------------------
1429 double wxAMMediaBackend::GetVolume()
1432 if ( SUCCEEDED(m_pBA
->get_Volume(&lVolume
)) )
1433 return (((double)(lVolume
+ 10000)) / 10000.0);
1437 //---------------------------------------------------------------------------
1438 // wxAMMediaBackend::GetDuration
1440 // 1) Obtains the duration of the media from the IMediaSeeking interface
1441 // 2) Converts that value to our time base, and returns it
1442 //---------------------------------------------------------------------------
1443 wxLongLong
wxAMMediaBackend::GetDuration()
1446 wxAMVERIFY( m_pMS
->get_Duration(&outDuration
) );
1448 //h,m,s,milli - outdur is in 1 second (double)
1449 return (outDuration
*1000);
1452 //---------------------------------------------------------------------------
1453 // wxAMMediaBackend::GetState
1455 // Obtains the state from the IMediaControl interface.
1456 // Note that it's enumeration values for stopping/playing
1457 // etc. are the same as ours, so we just do a straight cast.
1458 // TODO: MS recommends against INFINITE here for
1459 // IMediaControl::GetState- do it in stages
1460 //---------------------------------------------------------------------------
1461 wxMediaState
wxAMMediaBackend::GetState()
1464 long theState
; //OAFilterState
1465 hr
= m_pMC
->GetState(INFINITE
, &theState
);
1467 wxASSERT( SUCCEEDED(hr
) );
1469 //MSW state is the same as ours
1470 //State_Stopped = 0,
1471 //State_Paused = State_Stopped + 1,
1472 //State_Running = State_Paused + 1
1474 return (wxMediaState
) theState
;
1477 //---------------------------------------------------------------------------
1478 // wxAMMediaBackend::GetPlaybackRate
1480 // Pretty simple way of obtaining the playback rate from
1481 // the IMediaSeeking interface
1482 //---------------------------------------------------------------------------
1483 double wxAMMediaBackend::GetPlaybackRate()
1486 wxAMVERIFY( m_pMS
->get_Rate(&dRate
) );
1490 //---------------------------------------------------------------------------
1491 // wxAMMediaBackend::SetPlaybackRate
1493 // Sets the playback rate of the media - DirectShow is pretty good
1494 // about this, actually
1495 //---------------------------------------------------------------------------
1496 bool wxAMMediaBackend::SetPlaybackRate(double dRate
)
1498 return SUCCEEDED( m_pMS
->put_Rate(dRate
) );
1501 //---------------------------------------------------------------------------
1502 // wxAMMediaBackend::NotifyWndProc
1504 // Here we check to see if DirectShow tells us we've reached the stop
1505 // position in our stream - if it has, it may not actually stop
1506 // the stream - which we need to do...
1507 //---------------------------------------------------------------------------
1508 LRESULT CALLBACK
wxAMMediaBackend::NotifyWndProc(HWND hWnd
, UINT nMsg
,
1512 wxAMMediaBackend
* backend
= (wxAMMediaBackend
*)
1513 ::GetWindowLong(hWnd
, GWL_USERDATA
);
1515 return backend
->OnNotifyWndProc(hWnd
, nMsg
, wParam
, lParam
);
1518 LRESULT CALLBACK
wxAMMediaBackend::OnNotifyWndProc(HWND hWnd
, UINT nMsg
,
1522 if (nMsg
== WM_GRAPHNOTIFY
)
1529 // DirectShow keeps a list of queued events, and we need
1530 // to go through them one by one, stopping at (Hopefully only one)
1531 // EC_COMPLETE message
1533 while(SUCCEEDED(m_pME
->GetEvent(&evCode
, (LONG_PTR
*) &evParam1
,
1534 (LONG_PTR
*) &evParam2
, 0)
1538 // Cleanup memory that GetEvent allocated
1539 wxAMVERIFY( m_pME
->FreeEventParams(evCode
, evParam1
, evParam2
) );
1541 // If this is the end of the clip, notify handler
1542 if(1 == evCode
) //EC_COMPLETE
1544 //send the event to our child
1545 wxMediaEvent
theEvent(wxEVT_MEDIA_STOP
, m_ctrl
->GetId());
1546 m_ctrl
->ProcessEvent(theEvent
);
1548 //if the user didn't veto it, stop the stream
1549 if (theEvent
.IsAllowed())
1551 //Interestingly enough, DirectShow does not actually stop
1552 //the filters - even when it reaches the end!
1555 //send the event to our child
1556 wxMediaEvent
theEvent(wxEVT_MEDIA_FINISHED
,
1558 m_ctrl
->ProcessEvent(theEvent
);
1563 return DefWindowProc(hWnd
, nMsg
, wParam
, lParam
);
1566 //---------------------------------------------------------------------------
1567 // wxAMMediaBackend::Cleanup
1569 // 1) Hide/disowns the video window (MS says bad things will happen if
1571 // 2) Releases all the directshow interfaces we use
1572 // TODO: Maybe there's a way to redirect the IMediaControl each time
1573 // we load, rather then creating and destroying the interfaces
1575 //---------------------------------------------------------------------------
1576 void wxAMMediaBackend::Cleanup()
1578 // Hide then disown the window
1581 m_pVW
->put_Visible(0); //OSFALSE == 0
1582 m_pVW
->put_Owner(NULL
);
1585 // Release and zero DirectShow interfaces
1586 SAFE_RELEASE(m_pME
);
1587 SAFE_RELEASE(m_pMS
);
1588 SAFE_RELEASE(m_pBA
);
1589 SAFE_RELEASE(m_pBV
);
1590 SAFE_RELEASE(m_pVW
);
1591 SAFE_RELEASE(m_pMC
);
1593 // Get rid of our hidden Window
1594 DestroyWindow(m_hNotifyWnd
);
1595 m_hNotifyWnd
= NULL
;
1599 //---------------------------------------------------------------------------
1600 // wxAMMediaBackend::GetVideoSize
1602 // Obtains the cached original video size
1603 //---------------------------------------------------------------------------
1604 wxSize
wxAMMediaBackend::GetVideoSize() const
1609 //---------------------------------------------------------------------------
1610 // wxAMMediaBackend::Move
1612 // Resizes the IVideoWindow to the size of the control window
1613 //---------------------------------------------------------------------------
1614 void wxAMMediaBackend::Move(int WXUNUSED(x
), int WXUNUSED(y
), int w
, int h
)
1616 if(m_hNotifyWnd
&& m_bVideo
)
1618 wxAMVERIFY( m_pVW
->SetWindowPosition(0, 0, w
, h
) );
1622 //---------------------------------------------------------------------------
1623 // End of wxAMMediaBackend
1624 //---------------------------------------------------------------------------
1625 #endif //wxUSE_DIRECTSHOW
1627 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1629 // wxMCIMediaBackend
1631 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1634 IMPLEMENT_DYNAMIC_CLASS(wxMCIMediaBackend
, wxMediaBackend
);
1636 //---------------------------------------------------------------------------
1637 // Usual debugging macros for MCI returns
1638 //---------------------------------------------------------------------------
1641 #define wxMCIVERIFY(arg) \
1644 if ( (nRet = (arg)) != 0) \
1647 mciGetErrorString(nRet, sz, 5000); \
1648 wxFAIL_MSG(wxString::Format(_T("MCI Error:%s"), sz)); \
1652 #define wxMCIVERIFY(arg) (arg);
1655 //---------------------------------------------------------------------------
1656 // Simulation for <digitalv.h>
1658 // Mingw and possibly other compilers don't have the digitalv.h header
1659 // that is needed to have some essential features of mci work with
1660 // windows - so we provide the declarations for the types we use here
1661 //---------------------------------------------------------------------------
1664 DWORD_PTR dwCallback
;
1665 #ifdef MCI_USE_OFFEXT
1671 } MCI_DGV_RECT_PARMS
;
1674 DWORD_PTR dwCallback
;
1684 } MCI_DGV_WINDOW_PARMS
;
1687 DWORD_PTR dwCallback
;
1692 } MCI_DGV_SET_PARMS
;
1695 DWORD_PTR dwCallback
;
1699 wxChar
* lpstrAlgorithm
;
1700 wxChar
* lpstrQuality
;
1701 } MCI_DGV_SETAUDIO_PARMS
;
1703 //---------------------------------------------------------------------------
1704 // wxMCIMediaBackend Constructor
1706 // Here we don't need to do much except say we don't have any video :)
1707 //---------------------------------------------------------------------------
1708 wxMCIMediaBackend::wxMCIMediaBackend() : m_hNotifyWnd(NULL
), m_bVideo(false)
1712 //---------------------------------------------------------------------------
1713 // wxMCIMediaBackend Destructor
1715 // We close the mci device - note that there may not be an mci device here,
1716 // or it may fail - but we don't really care, since we're destructing
1717 //---------------------------------------------------------------------------
1718 wxMCIMediaBackend::~wxMCIMediaBackend()
1722 mciSendCommand(m_hDev
, MCI_CLOSE
, 0, 0);
1723 DestroyWindow(m_hNotifyWnd
);
1724 m_hNotifyWnd
= NULL
;
1728 //---------------------------------------------------------------------------
1729 // wxMCIMediaBackend::Create
1731 // Here we just tell wxMediaCtrl that mci does exist (which it does, on all
1732 // msw systems, at least in some form dating back to win16 days)
1733 //---------------------------------------------------------------------------
1734 bool wxMCIMediaBackend::CreateControl(wxControl
* ctrl
, wxWindow
* parent
,
1739 const wxValidator
& validator
,
1740 const wxString
& name
)
1744 // By default wxWindow(s) is created with a border -
1745 // so we need to get rid of those, and create with
1746 // wxCLIP_CHILDREN, so that if the driver/backend
1747 // is a child window, it refereshes properly
1749 if ( !ctrl
->wxControl::Create(parent
, id
, pos
, size
,
1750 (style
& ~wxBORDER_MASK
) | wxBORDER_NONE
| wxCLIP_CHILDREN
,
1758 //---------------------------------------------------------------------------
1759 // wxMCIMediaBackend::Load (file version)
1761 // Here we have MCI load a file and device, set the time format to our
1762 // default (milliseconds), and set the video (if any) to play in the control
1763 //---------------------------------------------------------------------------
1764 bool wxMCIMediaBackend::Load(const wxString
& fileName
)
1767 //if the user already called load close the previous MCI device
1771 mciSendCommand(m_hDev
, MCI_CLOSE
, 0, 0);
1772 DestroyWindow(m_hNotifyWnd
);
1773 m_hNotifyWnd
= NULL
;
1777 //Opens a file and has MCI select a device. Normally you'd put
1778 //MCI_OPEN_TYPE in addition to MCI_OPEN_ELEMENT - however if you
1779 //omit this it tells MCI to select the device instead. This is
1780 //good because we have no reliable way of "enumerating" the devices
1783 MCI_OPEN_PARMS openParms
;
1784 openParms
.lpstrElementName
= (wxChar
*) fileName
.c_str();
1786 if ( mciSendCommand(0, MCI_OPEN
, MCI_OPEN_ELEMENT
,
1787 (DWORD
)(LPVOID
)&openParms
) != 0)
1790 m_hDev
= openParms
.wDeviceID
;
1793 //Now set the time format for the device to milliseconds
1795 MCI_SET_PARMS setParms
;
1796 setParms
.dwCallback
= 0;
1797 setParms
.dwTimeFormat
= MCI_FORMAT_MILLISECONDS
;
1799 if (mciSendCommand(m_hDev
, MCI_SET
, MCI_SET_TIME_FORMAT
,
1800 (DWORD
)(LPVOID
)&setParms
) != 0)
1804 //Now tell the MCI device to display the video in our wxMediaCtrl
1806 MCI_DGV_WINDOW_PARMS windowParms
;
1807 windowParms
.hWnd
= (HWND
)m_ctrl
->GetHandle();
1809 m_bVideo
= (mciSendCommand(m_hDev
, MCI_WINDOW
,
1810 0x00010000L
, //MCI_DGV_WINDOW_HWND
1811 (DWORD
)(LPVOID
)&windowParms
) == 0);
1814 // Create a hidden window and register to handle
1816 // Note that wxCanvasClassName is already registered
1817 // and used by all wxWindows and normal wxControls
1819 m_hNotifyWnd
= ::CreateWindow
1833 wxLogSysError( wxT("Could not create hidden needed for ")
1834 wxT("registering for DirectShow events!") );
1840 ::SetWindowLong(m_hNotifyWnd
, GWL_WNDPROC
,
1841 (LONG
)wxMCIMediaBackend::NotifyWndProc
);
1843 ::SetWindowLongPtr(m_hNotifyWnd
, GWLP_WNDPROC
,
1844 (LONG_PTR
)wxMCIMediaBackend::NotifyWndProc
);
1847 ::SetWindowLong(m_hNotifyWnd
, GWL_USERDATA
,
1851 //Here, if the parent of the control has a sizer - we
1852 //tell it to recalculate the size of this control since
1853 //the user opened a seperate media file
1855 m_ctrl
->InvalidateBestSize();
1856 m_ctrl
->GetParent()->Layout();
1857 m_ctrl
->GetParent()->Refresh();
1858 m_ctrl
->GetParent()->Update();
1863 //---------------------------------------------------------------------------
1864 // wxMCIMediaBackend::Load (URL version)
1866 // MCI doesn't support URLs directly (?)
1868 // TODO: Use wxURL/wxFileSystem and mmioInstallProc
1869 //---------------------------------------------------------------------------
1870 bool wxMCIMediaBackend::Load(const wxURI
& WXUNUSED(location
))
1875 //---------------------------------------------------------------------------
1876 // wxMCIMediaBackend::Play
1878 // Plays/Resumes the MCI device... a couple notes:
1879 // 1) Certain drivers will crash and burn if we don't pass them an
1880 // MCI_PLAY_PARMS, despite the documentation that says otherwise...
1881 // 2) There is a MCI_RESUME command, but MCI_PLAY does the same thing
1882 // and will resume from a stopped state also, so there's no need to
1883 // call both, for example
1884 //---------------------------------------------------------------------------
1885 bool wxMCIMediaBackend::Play()
1887 MCI_PLAY_PARMS playParms
;
1888 playParms
.dwCallback
= (DWORD
)m_hNotifyWnd
;
1890 bool bOK
= ( mciSendCommand(m_hDev
, MCI_PLAY
, MCI_NOTIFY
,
1891 (DWORD
)(LPVOID
)&playParms
) == 0 );
1894 m_ctrl
->Show(m_bVideo
);
1899 //---------------------------------------------------------------------------
1900 // wxMCIMediaBackend::Pause
1902 // Pauses the MCI device - nothing special
1903 //---------------------------------------------------------------------------
1904 bool wxMCIMediaBackend::Pause()
1906 return (mciSendCommand(m_hDev
, MCI_PAUSE
, MCI_WAIT
, 0) == 0);
1909 //---------------------------------------------------------------------------
1910 // wxMCIMediaBackend::Stop
1912 // Stops the MCI device & seeks to the beginning as wxMediaCtrl docs outline
1913 //---------------------------------------------------------------------------
1914 bool wxMCIMediaBackend::Stop()
1916 return (mciSendCommand(m_hDev
, MCI_STOP
, MCI_WAIT
, 0) == 0) &&
1917 (mciSendCommand(m_hDev
, MCI_SEEK
, MCI_SEEK_TO_START
, 0) == 0);
1920 //---------------------------------------------------------------------------
1921 // wxMCIMediaBackend::GetState
1923 // Here we get the state and convert it to a wxMediaState -
1924 // since we use direct comparisons with MCI_MODE_PLAY and
1925 // MCI_MODE_PAUSE, we don't care if the MCI_STATUS call
1927 //---------------------------------------------------------------------------
1928 wxMediaState
wxMCIMediaBackend::GetState()
1930 MCI_STATUS_PARMS statusParms
;
1931 statusParms
.dwItem
= MCI_STATUS_MODE
;
1933 mciSendCommand(m_hDev
, MCI_STATUS
, MCI_STATUS_ITEM
,
1934 (DWORD
)(LPVOID
)&statusParms
);
1936 if(statusParms
.dwReturn
== MCI_MODE_PAUSE
)
1937 return wxMEDIASTATE_PAUSED
;
1938 else if(statusParms
.dwReturn
== MCI_MODE_PLAY
)
1939 return wxMEDIASTATE_PLAYING
;
1941 return wxMEDIASTATE_STOPPED
;
1944 //---------------------------------------------------------------------------
1945 // wxMCIMediaBackend::SetPosition
1947 // Here we set the position of the device in the stream.
1948 // Note that MCI actually stops the device after you seek it if the
1949 // device is playing/paused, so we need to play the file after
1950 // MCI seeks like normal APIs would
1951 //---------------------------------------------------------------------------
1952 bool wxMCIMediaBackend::SetPosition(wxLongLong where
)
1954 MCI_SEEK_PARMS seekParms
;
1955 seekParms
.dwCallback
= 0;
1956 #if wxUSE_LONGLONG_NATIVE && !wxUSE_LONGLONG_WX
1957 seekParms
.dwTo
= (DWORD
)where
.GetValue();
1958 #else /* wxUSE_LONGLONG_WX */
1959 /* no way to return it in one piece */
1960 wxASSERT( where
.GetHi()==0 );
1961 seekParms
.dwTo
= (DWORD
)where
.GetLo();
1962 #endif /* wxUSE_LONGLONG_* */
1964 //device was playing?
1965 bool bReplay
= GetState() == wxMEDIASTATE_PLAYING
;
1967 if( mciSendCommand(m_hDev
, MCI_SEEK
, MCI_TO
,
1968 (DWORD
)(LPVOID
)&seekParms
) != 0)
1971 //If the device was playing, resume it
1978 //---------------------------------------------------------------------------
1979 // wxMCIMediaBackend::GetPosition
1981 // Gets the position of the device in the stream using the current
1982 // time format... nothing special here...
1983 //---------------------------------------------------------------------------
1984 wxLongLong
wxMCIMediaBackend::GetPosition()
1986 MCI_STATUS_PARMS statusParms
;
1987 statusParms
.dwItem
= MCI_STATUS_POSITION
;
1989 if (mciSendCommand(m_hDev
, MCI_STATUS
, MCI_STATUS_ITEM
,
1990 (DWORD
)(LPSTR
)&statusParms
) != 0)
1993 return statusParms
.dwReturn
;
1996 //---------------------------------------------------------------------------
1997 // wxMCIMediaBackend::GetVolume
1999 // Gets the volume of the current media via the MCI_DGV_STATUS_VOLUME
2000 // message. Value ranges from 0 (minimum) to 1000 (maximum volume).
2001 //---------------------------------------------------------------------------
2002 double wxMCIMediaBackend::GetVolume()
2004 MCI_STATUS_PARMS statusParms
;
2005 statusParms
.dwCallback
= NULL
;
2006 statusParms
.dwItem
= 0x4019; //MCI_DGV_STATUS_VOLUME
2008 if (mciSendCommand(m_hDev
, MCI_STATUS
, MCI_STATUS_ITEM
,
2009 (DWORD
)(LPSTR
)&statusParms
) != 0)
2012 return ((double)statusParms
.dwReturn
) / 1000.0;
2015 //---------------------------------------------------------------------------
2016 // wxMCIMediaBackend::SetVolume
2018 // Sets the volume of the current media via the MCI_DGV_SETAUDIO_VOLUME
2019 // message. Value ranges from 0 (minimum) to 1000 (maximum volume).
2020 //---------------------------------------------------------------------------
2021 bool wxMCIMediaBackend::SetVolume(double dVolume
)
2023 MCI_DGV_SETAUDIO_PARMS audioParms
;
2024 audioParms
.dwCallback
= NULL
;
2025 audioParms
.dwItem
= 0x4002; //MCI_DGV_SETAUDIO_VOLUME
2026 audioParms
.dwValue
= (DWORD
) (dVolume
* 1000.0);
2027 audioParms
.dwOver
= 0;
2028 audioParms
.lpstrAlgorithm
= NULL
;
2029 audioParms
.lpstrQuality
= NULL
;
2031 if (mciSendCommand(m_hDev
, 0x0873, //MCI_SETAUDIO
2032 0x00800000L
| 0x01000000L
, //MCI_DGV_SETAUDIO+(_ITEM | _VALUE)
2033 (DWORD
)(LPSTR
)&audioParms
) != 0)
2038 //---------------------------------------------------------------------------
2039 // wxMCIMediaBackend::GetDuration
2041 // Gets the duration of the stream... nothing special
2042 //---------------------------------------------------------------------------
2043 wxLongLong
wxMCIMediaBackend::GetDuration()
2045 MCI_STATUS_PARMS statusParms
;
2046 statusParms
.dwItem
= MCI_STATUS_LENGTH
;
2048 if (mciSendCommand(m_hDev
, MCI_STATUS
, MCI_STATUS_ITEM
,
2049 (DWORD
)(LPSTR
)&statusParms
) != 0)
2052 return statusParms
.dwReturn
;
2055 //---------------------------------------------------------------------------
2056 // wxMCIMediaBackend::Move
2058 // Moves the window to a location
2059 //---------------------------------------------------------------------------
2060 void wxMCIMediaBackend::Move(int WXUNUSED(x
), int WXUNUSED(y
),
2063 if (m_hNotifyWnd
&& m_bVideo
)
2065 MCI_DGV_RECT_PARMS putParms
; //ifdefed MCI_DGV_PUT_PARMS
2066 putParms
.rc
.top
= 0;
2067 putParms
.rc
.bottom
= 0;
2068 putParms
.rc
.right
= w
;
2069 putParms
.rc
.bottom
= h
;
2071 wxMCIVERIFY( mciSendCommand(m_hDev
, MCI_PUT
,
2072 0x00040000L
, //MCI_DGV_PUT_DESTINATION
2073 (DWORD
)(LPSTR
)&putParms
) );
2077 //---------------------------------------------------------------------------
2078 // wxMCIMediaBackend::GetVideoSize
2080 // Gets the original size of the movie for sizers
2081 //---------------------------------------------------------------------------
2082 wxSize
wxMCIMediaBackend::GetVideoSize() const
2086 MCI_DGV_RECT_PARMS whereParms
; //ifdefed MCI_DGV_WHERE_PARMS
2088 wxMCIVERIFY( mciSendCommand(m_hDev
, MCI_WHERE
,
2089 0x00020000L
, //MCI_DGV_WHERE_SOURCE
2090 (DWORD
)(LPSTR
)&whereParms
) );
2092 return wxSize(whereParms
.rc
.right
, whereParms
.rc
.bottom
);
2097 //---------------------------------------------------------------------------
2098 // wxMCIMediaBackend::GetPlaybackRate
2101 //---------------------------------------------------------------------------
2102 double wxMCIMediaBackend::GetPlaybackRate()
2107 //---------------------------------------------------------------------------
2108 // wxMCIMediaBackend::SetPlaybackRate
2111 //---------------------------------------------------------------------------
2112 bool wxMCIMediaBackend::SetPlaybackRate(double WXUNUSED(dRate
))
2115 MCI_WAVE_SET_SAMPLESPERSEC
2116 MCI_DGV_SET_PARMS setParms;
2117 setParms.dwSpeed = (DWORD) (dRate * 1000.0);
2119 return (mciSendCommand(m_hDev, MCI_SET,
2120 0x00020000L, //MCI_DGV_SET_SPEED
2121 (DWORD)(LPSTR)&setParms) == 0);
2126 //---------------------------------------------------------------------------
2127 // [static] wxMCIMediaBackend::MSWWindowProc
2129 // Here we process a message when MCI reaches the stopping point
2131 //---------------------------------------------------------------------------
2132 LRESULT CALLBACK
wxMCIMediaBackend::NotifyWndProc(HWND hWnd
, UINT nMsg
,
2136 wxMCIMediaBackend
* backend
= (wxMCIMediaBackend
*)
2137 ::GetWindowLong(hWnd
, GWL_USERDATA
);
2140 return backend
->OnNotifyWndProc(hWnd
, nMsg
, wParam
, lParam
);
2143 LRESULT CALLBACK
wxMCIMediaBackend::OnNotifyWndProc(HWND hWnd
, UINT nMsg
,
2147 if(nMsg
== MM_MCINOTIFY
)
2149 wxASSERT(lParam
== (LPARAM
) m_hDev
);
2150 if(wParam
== MCI_NOTIFY_SUCCESSFUL
&& lParam
== (LPARAM
)m_hDev
)
2152 wxMediaEvent
theEvent(wxEVT_MEDIA_STOP
, m_ctrl
->GetId());
2153 m_ctrl
->ProcessEvent(theEvent
);
2155 if(theEvent
.IsAllowed())
2157 wxMCIVERIFY( mciSendCommand(m_hDev
, MCI_SEEK
,
2158 MCI_SEEK_TO_START
, 0) );
2160 //send the event to our child
2161 wxMediaEvent
theEvent(wxEVT_MEDIA_FINISHED
,
2163 m_ctrl
->ProcessEvent(theEvent
);
2167 return DefWindowProc(hWnd
, nMsg
, wParam
, lParam
);
2169 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2173 // TODO: Use a less cludgy way to pause/get state/set state
2174 // TODO: Dynamically load from qtml.dll
2175 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2179 IMPLEMENT_DYNAMIC_CLASS(wxQTMediaBackend
, wxMediaBackend
);
2181 //Time between timer calls
2182 #define MOVIE_DELAY 100
2184 #include "wx/timer.h"
2186 // --------------------------------------------------------------------------
2187 // wxQTTimer - Handle Asyncronous Playing
2188 // --------------------------------------------------------------------------
2189 class _wxQTTimer
: public wxTimer
2192 _wxQTTimer(Movie movie
, wxQTMediaBackend
* parent
, wxQuickTimeLibrary
* pLib
) :
2193 m_movie(movie
), m_bPaused(false), m_parent(parent
), m_pLib(pLib
)
2201 bool GetPaused() {return m_bPaused
;}
2202 void SetPaused(bool bPaused
) {m_bPaused
= bPaused
;}
2204 //-----------------------------------------------------------------------
2205 // _wxQTTimer::Notify
2207 // 1) Checks to see if the movie is done, and if not continues
2208 // streaming the movie
2209 // 2) Sends the wxEVT_MEDIA_STOP event if we have reached the end of
2211 //-----------------------------------------------------------------------
2216 if(!m_pLib
->IsMovieDone(m_movie
))
2217 m_pLib
->MoviesTask(m_movie
, MOVIE_DELAY
);
2220 wxMediaEvent
theEvent(wxEVT_MEDIA_STOP
,
2221 m_parent
->m_ctrl
->GetId());
2222 m_parent
->m_ctrl
->ProcessEvent(theEvent
);
2224 if(theEvent
.IsAllowed())
2228 wxASSERT(m_pLib
->GetMoviesError() == noErr
);
2230 //send the event to our child
2231 wxMediaEvent
theEvent(wxEVT_MEDIA_FINISHED
,
2232 m_parent
->m_ctrl
->GetId());
2233 m_parent
->m_ctrl
->ProcessEvent(theEvent
);
2240 Movie m_movie
; //Our movie instance
2241 bool m_bPaused
; //Whether we are paused or not
2242 wxQTMediaBackend
* m_parent
; //Backend pointer
2243 wxQuickTimeLibrary
* m_pLib
; //Interfaces
2246 //---------------------------------------------------------------------------
2247 // wxQTMediaBackend Destructor
2249 // Sets m_timer to NULL signifying we havn't loaded anything yet
2250 //---------------------------------------------------------------------------
2251 wxQTMediaBackend::wxQTMediaBackend() : m_timer(NULL
)
2255 //---------------------------------------------------------------------------
2256 // wxQTMediaBackend Destructor
2258 // 1) Cleans up the QuickTime movie instance
2259 // 2) Decrements the QuickTime reference counter - if this reaches
2260 // 0, QuickTime shuts down
2261 // 3) Decrements the QuickTime Windows Media Layer reference counter -
2262 // if this reaches 0, QuickTime shuts down the Windows Media Layer
2263 //---------------------------------------------------------------------------
2264 wxQTMediaBackend::~wxQTMediaBackend()
2271 //Note that ExitMovies() is not neccessary, but
2272 //the docs are fuzzy on whether or not TerminateQTML is
2274 m_lib
.TerminateQTML();
2278 //---------------------------------------------------------------------------
2279 // wxQTMediaBackend::CreateControl
2281 // 1) Intializes QuickTime
2282 // 2) Creates the control window
2283 //---------------------------------------------------------------------------
2284 bool wxQTMediaBackend::CreateControl(wxControl
* ctrl
, wxWindow
* parent
,
2289 const wxValidator
& validator
,
2290 const wxString
& name
)
2292 if(!m_lib
.Initialize())
2296 if ((nError
= m_lib
.InitializeQTML(0)) != noErr
) //-2093 no dll
2298 wxFAIL_MSG(wxString::Format(wxT("Couldn't Initialize Quicktime-%i"), nError
));
2301 m_lib
.EnterMovies();
2305 // By default wxWindow(s) is created with a border -
2306 // so we need to get rid of those
2308 // Since we don't have a child window like most other
2309 // backends, we don't need wxCLIP_CHILDREN
2311 if ( !ctrl
->wxControl::Create(parent
, id
, pos
, size
,
2312 (style
& ~wxBORDER_MASK
) | wxBORDER_NONE
,
2320 //---------------------------------------------------------------------------
2321 // wxQTMediaBackend::Load (file version)
2323 // 1) Get an FSSpec from the Windows path name
2324 // 2) Open the movie
2325 // 3) Obtain the movie instance from the movie resource
2327 //---------------------------------------------------------------------------
2328 bool wxQTMediaBackend::Load(const wxString
& fileName
)
2337 if (m_lib
.NativePathNameToFSSpec ((char*) (const char*) fileName
.mb_str(),
2338 &sfFile
, 0) != noErr
)
2341 if (m_lib
.OpenMovieFile (&sfFile
, &movieResFile
, fsRdPerm
) != noErr
)
2344 short movieResID
= 0;
2347 err
= m_lib
.NewMovieFromFile (
2355 m_lib
.CloseMovieFile (movieResFile
);
2362 return m_lib
.GetMoviesError() == noErr
;
2365 //---------------------------------------------------------------------------
2366 // wxQTMediaBackend::Move
2369 //---------------------------------------------------------------------------
2370 bool wxQTMediaBackend::Load(const wxURI
& location
)
2375 wxString theURI
= location
.BuildURI();
2379 Handle theHandle
= m_lib
.NewHandleClear(theURI
.length() + 1);
2380 wxASSERT(theHandle
);
2382 m_lib
.BlockMove(theURI
.mb_str(), *theHandle
, theURI
.length() + 1);
2384 //create the movie from the handle that refers to the URI
2385 err
= m_lib
.NewMovieFromDataRef(&m_movie
, newMovieActive
,
2387 'url'); //URLDataHandlerSubType
2389 m_lib
.DisposeHandle(theHandle
);
2394 //preroll movie for streaming
2399 timeNow = GetMovieTime(m_movie, NULL);
2400 playRate = GetMoviePreferredRate(m_movie);
2401 PrePrerollMovie(m_movie, timeNow, playRate, NULL, NULL);
2402 PrerollMovie(m_movie, timeNow, playRate);
2403 m_lib.SetMovieRate(m_movie, playRate);
2408 return m_lib
.GetMoviesError() == noErr
;
2411 //---------------------------------------------------------------------------
2412 // wxQTMediaBackend::Move
2415 //---------------------------------------------------------------------------
2416 void wxQTMediaBackend::FinishLoad()
2418 m_timer
= new _wxQTTimer(m_movie
, (wxQTMediaBackend
*) this, &m_lib
);
2421 //get the real size of the movie
2423 m_lib
.GetMovieNaturalBoundsRect (m_movie
, &outRect
);
2424 wxASSERT(m_lib
.GetMoviesError() == noErr
);
2426 m_bestSize
.x
= outRect
.right
- outRect
.left
;
2427 m_bestSize
.y
= outRect
.bottom
- outRect
.top
;
2429 //reparent movie/*AudioMediaCharacteristic*/
2430 if(m_lib
.GetMovieIndTrackType(m_movie
, 1,
2431 'eyes', //VisualMediaCharacteristic,
2432 (1 << 1) //movieTrackCharacteristic
2433 | (1 << 2) //movieTrackEnabledOnly
2436 m_lib
.CreatePortAssociation(m_ctrl
->GetHWND(), NULL
, 0L);
2438 m_lib
.SetMovieGWorld(m_movie
,
2439 (CGrafPtr
) m_lib
.GetNativeWindowPort(m_ctrl
->GetHWND()),
2443 //we want millisecond precision
2444 m_lib
.SetMovieTimeScale(m_movie
, 1000);
2445 wxASSERT(m_lib
.GetMoviesError() == noErr
);
2448 //Here, if the parent of the control has a sizer - we
2449 //tell it to recalculate the size of this control since
2450 //the user opened a seperate media file
2452 m_ctrl
->InvalidateBestSize();
2453 m_ctrl
->GetParent()->Layout();
2454 m_ctrl
->GetParent()->Refresh();
2455 m_ctrl
->GetParent()->Update();
2458 //---------------------------------------------------------------------------
2459 // wxQTMediaBackend::Move
2462 //---------------------------------------------------------------------------
2463 bool wxQTMediaBackend::Play()
2465 m_lib
.StartMovie(m_movie
);
2466 m_timer
->SetPaused(false);
2467 m_timer
->Start(MOVIE_DELAY
, wxTIMER_CONTINUOUS
);
2468 return m_lib
.GetMoviesError() == noErr
;
2471 //---------------------------------------------------------------------------
2472 // wxQTMediaBackend::Move
2475 //---------------------------------------------------------------------------
2476 bool wxQTMediaBackend::Pause()
2478 m_lib
.StopMovie(m_movie
);
2479 m_timer
->SetPaused(true);
2481 return m_lib
.GetMoviesError() == noErr
;
2484 //---------------------------------------------------------------------------
2485 // wxQTMediaBackend::Move
2488 //---------------------------------------------------------------------------
2489 bool wxQTMediaBackend::Stop()
2491 m_timer
->SetPaused(false);
2494 m_lib
.StopMovie(m_movie
);
2495 if(m_lib
.GetMoviesError() != noErr
)
2498 m_lib
.GoToBeginningOfMovie(m_movie
);
2499 return m_lib
.GetMoviesError() == noErr
;
2502 //---------------------------------------------------------------------------
2503 // wxQTMediaBackend::Move
2506 //---------------------------------------------------------------------------
2507 double wxQTMediaBackend::GetPlaybackRate()
2509 return ( ((double)m_lib
.GetMovieRate(m_movie
)) / 0x10000);
2512 //---------------------------------------------------------------------------
2513 // wxQTMediaBackend::Move
2516 //---------------------------------------------------------------------------
2517 bool wxQTMediaBackend::SetPlaybackRate(double dRate
)
2519 m_lib
.SetMovieRate(m_movie
, (Fixed
) (dRate
* 0x10000));
2520 return m_lib
.GetMoviesError() == noErr
;
2523 //---------------------------------------------------------------------------
2524 // wxQTMediaBackend::Move
2527 //---------------------------------------------------------------------------
2528 bool wxQTMediaBackend::SetPosition(wxLongLong where
)
2530 TimeRecord theTimeRecord
;
2531 memset(&theTimeRecord
, 0, sizeof(TimeRecord
));
2532 theTimeRecord
.value
.lo
= where
.GetValue();
2533 theTimeRecord
.scale
= m_lib
.GetMovieTimeScale(m_movie
);
2534 theTimeRecord
.base
= m_lib
.GetMovieTimeBase(m_movie
);
2535 m_lib
.SetMovieTime(m_movie
, &theTimeRecord
);
2537 if (m_lib
.GetMoviesError() != noErr
)
2543 //---------------------------------------------------------------------------
2544 // wxQTMediaBackend::GetPosition
2546 // 1) Calls GetMovieTime to get the position we are in in the movie
2547 // in milliseconds (we called
2548 //---------------------------------------------------------------------------
2549 wxLongLong
wxQTMediaBackend::GetPosition()
2551 return m_lib
.GetMovieTime(m_movie
, NULL
);
2554 //---------------------------------------------------------------------------
2555 // wxQTMediaBackend::GetVolume
2557 // Gets the volume through GetMovieVolume - which returns a 16 bit short -
2559 // +--------+--------+
2561 // +--------+--------+
2563 // (1) first 8 bits are value before decimal
2564 // (2) second 8 bits are value after decimal
2566 // Volume ranges from -1.0 (gain but no sound), 0 (no sound and no gain) to
2567 // 1 (full gain and sound)
2568 //---------------------------------------------------------------------------
2569 double wxQTMediaBackend::GetVolume()
2571 short sVolume
= m_lib
.GetMovieVolume(m_movie
);
2573 if(sVolume
& (128 << 8)) //negative - no sound
2576 return (sVolume
& (127 << 8)) ? 1.0 : ((double)(sVolume
& 255)) / 255.0;
2579 //---------------------------------------------------------------------------
2580 // wxQTMediaBackend::SetVolume
2582 // Sets the volume through SetMovieVolume - which takes a 16 bit short -
2584 // +--------+--------+
2586 // +--------+--------+
2588 // (1) first 8 bits are value before decimal
2589 // (2) second 8 bits are value after decimal
2591 // Volume ranges from -1.0 (gain but no sound), 0 (no sound and no gain) to
2592 // 1 (full gain and sound)
2593 //---------------------------------------------------------------------------
2594 bool wxQTMediaBackend::SetVolume(double dVolume
)
2596 short sVolume
= (dVolume
>= .9999 ? 1 << 8 :
2597 (short) (dVolume
* 255));
2598 m_lib
.SetMovieVolume(m_movie
, sVolume
);
2602 //---------------------------------------------------------------------------
2603 // wxQTMediaBackend::Move
2606 //---------------------------------------------------------------------------
2607 wxLongLong
wxQTMediaBackend::GetDuration()
2609 return m_lib
.GetMovieDuration(m_movie
);
2612 //---------------------------------------------------------------------------
2613 // wxQTMediaBackend::Move
2616 //---------------------------------------------------------------------------
2617 wxMediaState
wxQTMediaBackend::GetState()
2619 if ( !m_timer
|| (m_timer
->IsRunning() == false &&
2620 m_timer
->GetPaused() == false) )
2621 return wxMEDIASTATE_STOPPED
;
2623 if( m_timer
->IsRunning() == true )
2624 return wxMEDIASTATE_PLAYING
;
2626 return wxMEDIASTATE_PAUSED
;
2629 //---------------------------------------------------------------------------
2630 // wxQTMediaBackend::Move
2633 //---------------------------------------------------------------------------
2634 void wxQTMediaBackend::Cleanup()
2639 m_lib
.StopMovie(m_movie
);
2640 m_lib
.DisposeMovie(m_movie
);
2643 //---------------------------------------------------------------------------
2644 // wxQTMediaBackend::Move
2647 //---------------------------------------------------------------------------
2648 wxSize
wxQTMediaBackend::GetVideoSize() const
2653 //---------------------------------------------------------------------------
2654 // wxQTMediaBackend::Move
2657 //---------------------------------------------------------------------------
2658 void wxQTMediaBackend::Move(int WXUNUSED(x
), int WXUNUSED(y
), int w
, int h
)
2662 Rect theRect
= {0, 0, h
, w
};
2664 m_lib
.SetMovieBox(m_movie
, &theRect
);
2665 wxASSERT(m_lib
.GetMoviesError() == noErr
);
2669 //---------------------------------------------------------------------------
2670 // End QT Compilation Guard
2671 //---------------------------------------------------------------------------
2672 #endif //wxUSE_QUICKTIME
2674 //in source file that contains stuff you don't directly use
2675 #include <wx/html/forcelnk.h>
2676 FORCE_LINK_ME(basewxmediabackends
);
2678 //---------------------------------------------------------------------------
2679 // End wxMediaCtrl Compilation Guard and this file
2680 //---------------------------------------------------------------------------
2681 #endif //wxUSE_MEDIACTRL