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 //---------------------------------------------------------------------------
63 //---------------------------------------------------------------------------
64 #include "wx/msw/ole/oleutils.h" //wxBasicString, IID etc.
65 #include "wx/msw/ole/uuid.h" //IID etc..
67 //---------------------------------------------------------------------------
68 // IIDS - used by CoCreateInstance and IUnknown::QueryInterface
69 //---------------------------------------------------------------------------
70 const IID LIBID_QuartzTypeLib
= {0x56A868B0,0x0AD4,0x11CE,{0xB0,0x3A,0x00,0x20,0xAF,0x0B,0xA7,0x70}};
71 const IID IID_IAMCollection
= {0x56A868B9,0x0AD4,0x11CE,{0xB0,0x3A,0x00,0x20,0xAF,0x0B,0xA7,0x70}};
72 const IID IID_IMediaControl
= {0x56A868B1,0x0AD4,0x11CE,{0xB0,0x3A,0x00,0x20,0xAF,0x0B,0xA7,0x70}};
73 const IID IID_IMediaEvent
= {0x56A868B6,0x0AD4,0x11CE,{0xB0,0x3A,0x00,0x20,0xAF,0x0B,0xA7,0x70}};
74 const IID IID_IMediaEventEx
= {0x56A868C0,0x0AD4,0x11CE,{0xB0,0x3A,0x00,0x20,0xAF,0x0B,0xA7,0x70}};
75 const IID IID_IMediaPosition
= {0x56A868B2,0x0AD4,0x11CE,{0xB0,0x3A,0x00,0x20,0xAF,0x0B,0xA7,0x70}};
76 const IID IID_IBasicAudio
= {0x56A868B3,0x0AD4,0x11CE,{0xB0,0x3A,0x00,0x20,0xAF,0x0B,0xA7,0x70}};
77 const IID IID_IVideoWindow
= {0x56A868B4,0x0AD4,0x11CE,{0xB0,0x3A,0x00,0x20,0xAF,0x0B,0xA7,0x70}};
78 const IID IID_IBasicVideo
= {0x56A868B5,0x0AD4,0x11CE,{0xB0,0x3A,0x00,0x20,0xAF,0x0B,0xA7,0x70}};
79 const IID IID_IBasicVideo2
= {0x329BB360,0xF6EA,0x11D1,{0x90,0x38,0x00,0xA0,0xC9,0x69,0x72,0x98}};
80 const IID IID_IDeferredCommand
= {0x56A868B8,0x0AD4,0x11CE,{0xB0,0x3A,0x00,0x20,0xAF,0x0B,0xA7,0x70}};
81 const IID IID_IQueueCommand
= {0x56A868B7,0x0AD4,0x11CE,{0xB0,0x3A,0x00,0x20,0xAF,0x0B,0xA7,0x70}};
82 const IID IID_IFilterInfo
= {0x56A868BA,0x0AD4,0x11CE,{0xB0,0x3A,0x00,0x20,0xAF,0x0B,0xA7,0x70}};
83 const IID IID_IRegFilterInfo
= {0x56A868BB,0x0AD4,0x11CE,{0xB0,0x3A,0x00,0x20,0xAF,0x0B,0xA7,0x70}};
84 const IID IID_IMediaTypeInfo
= {0x56A868BC,0x0AD4,0x11CE,{0xB0,0x3A,0x00,0x20,0xAF,0x0B,0xA7,0x70}};
85 const IID IID_IPinInfo
= {0x56A868BD,0x0AD4,0x11CE,{0xB0,0x3A,0x00,0x20,0xAF,0x0B,0xA7,0x70}};
86 const IID IID_IAMStats
= {0xBC9BCF80,0xDCD2,0x11D2,{0xAB,0xF6,0x00,0xA0,0xC9,0x05,0xF3,0x75}};
88 //TODO: These 4 lines needed?
92 #endif // CLSID_DEFINED
95 const CLSID CLSID_FilgraphManager
= {0xE436EBB3,0x524F,0x11CE,{0x9F,0x53,0x00,0x20,0xAF,0x0B,0xA7,0x70}};
97 //---------------------------------------------------------------------------
98 // COM INTERFACES (dumped from midl from quartz.idl from MSVC COM Browser)
99 //---------------------------------------------------------------------------
100 MIDL_INTERFACE("56A868B9-0AD4-11CE-B03A-0020AF0BA770")
101 IAMCollection
: public IDispatch
104 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_Count(
105 /* [retval][out] */ long __RPC_FAR
*plCount
) = 0;
107 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
Item(
108 /* [in] */ long lItem
,
109 /* [out] */ IUnknown __RPC_FAR
*__RPC_FAR
*ppUnk
) = 0;
111 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get__NewEnum(
112 /* [retval][out] */ IUnknown __RPC_FAR
*__RPC_FAR
*ppUnk
) = 0;
116 MIDL_INTERFACE("56A868B1-0AD4-11CE-B03A-0020AF0BA770")
117 IMediaControl
: public IDispatch
120 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
Run( void) = 0;
122 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
Pause( void) = 0;
124 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
Stop( void) = 0;
126 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
GetState(
127 /* [in] */ long msTimeout
,
128 /* [out] */ long __RPC_FAR
*pfs
) = 0;
130 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
RenderFile(
131 /* [in] */ BSTR strFilename
) = 0;
133 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
AddSourceFilter(
134 /* [in] */ BSTR strFilename
,
135 /* [out] */ IDispatch __RPC_FAR
*__RPC_FAR
*ppUnk
) = 0;
137 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_FilterCollection(
138 /* [retval][out] */ IDispatch __RPC_FAR
*__RPC_FAR
*ppUnk
) = 0;
140 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_RegFilterCollection(
141 /* [retval][out] */ IDispatch __RPC_FAR
*__RPC_FAR
*ppUnk
) = 0;
143 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
StopWhenReady( void) = 0;
147 MIDL_INTERFACE("56A868B6-0AD4-11CE-B03A-0020AF0BA770")
148 IMediaEvent
: public IDispatch
151 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
GetEventHandle(
152 /* [out] */ LONG_PTR __RPC_FAR
*hEvent
) = 0;
154 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
GetEvent(
155 /* [out] */ long __RPC_FAR
*lEventCode
,
156 /* [out] */ LONG_PTR __RPC_FAR
*lParam1
,
157 /* [out] */ LONG_PTR __RPC_FAR
*lParam2
,
158 /* [in] */ long msTimeout
) = 0;
160 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
WaitForCompletion(
161 /* [in] */ long msTimeout
,
162 /* [out] */ long __RPC_FAR
*pEvCode
) = 0;
164 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
CancelDefaultHandling(
165 /* [in] */ long lEvCode
) = 0;
167 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
RestoreDefaultHandling(
168 /* [in] */ long lEvCode
) = 0;
170 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
FreeEventParams(
171 /* [in] */ long lEvCode
,
172 /* [in] */ LONG_PTR lParam1
,
173 /* [in] */ LONG_PTR lParam2
) = 0;
177 MIDL_INTERFACE("56A868C0-0AD4-11CE-B03A-0020AF0BA770")
178 IMediaEventEx
: public IMediaEvent
181 virtual HRESULT __stdcall
SetNotifyWindow(
182 /* [in] */ LONG_PTR hwnd
,
183 /* [in] */ long lMsg
,
184 /* [in] */ LONG_PTR lInstanceData
) = 0;
186 virtual HRESULT __stdcall
SetNotifyFlags(
187 /* [in] */ long lNoNotifyFlags
) = 0;
189 virtual HRESULT __stdcall
GetNotifyFlags(
190 /* [out] */ long __RPC_FAR
*lplNoNotifyFlags
) = 0;
194 MIDL_INTERFACE("56A868B2-0AD4-11CE-B03A-0020AF0BA770")
195 IMediaPosition
: public IDispatch
198 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_Duration(
199 /* [retval][out] */ double __RPC_FAR
*plength
) = 0;
201 virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE
put_CurrentPosition(
202 /* [in] */ double pllTime
) = 0;
204 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_CurrentPosition(
205 /* [retval][out] */ double __RPC_FAR
*pllTime
) = 0;
207 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_StopTime(
208 /* [retval][out] */ double __RPC_FAR
*pllTime
) = 0;
210 virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE
put_StopTime(
211 /* [in] */ double pllTime
) = 0;
213 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_PrerollTime(
214 /* [retval][out] */ double __RPC_FAR
*pllTime
) = 0;
216 virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE
put_PrerollTime(
217 /* [in] */ double pllTime
) = 0;
219 virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE
put_Rate(
220 /* [in] */ double pdRate
) = 0;
222 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_Rate(
223 /* [retval][out] */ double __RPC_FAR
*pdRate
) = 0;
225 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
CanSeekForward(
226 /* [retval][out] */ long __RPC_FAR
*pCanSeekForward
) = 0;
228 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
CanSeekBackward(
229 /* [retval][out] */ long __RPC_FAR
*pCanSeekBackward
) = 0;
233 MIDL_INTERFACE("56A868B3-0AD4-11CE-B03A-0020AF0BA770")
234 IBasicAudio
: public IDispatch
237 virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE
put_Volume(
238 /* [in] */ long plVolume
) = 0;
240 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_Volume(
241 /* [retval][out] */ long __RPC_FAR
*plVolume
) = 0;
243 virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE
put_Balance(
244 /* [in] */ long plBalance
) = 0;
246 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_Balance(
247 /* [retval][out] */ long __RPC_FAR
*plBalance
) = 0;
251 MIDL_INTERFACE("56A868B4-0AD4-11CE-B03A-0020AF0BA770")
252 IVideoWindow
: public IDispatch
255 virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE
put_Caption(
256 /* [in] */ BSTR strCaption
) = 0;
258 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_Caption(
259 /* [retval][out] */ BSTR __RPC_FAR
*strCaption
) = 0;
261 virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE
put_WindowStyle(
262 /* [in] */ long WindowStyle
) = 0;
264 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_WindowStyle(
265 /* [retval][out] */ long __RPC_FAR
*WindowStyle
) = 0;
267 virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE
put_WindowStyleEx(
268 /* [in] */ long WindowStyleEx
) = 0;
270 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_WindowStyleEx(
271 /* [retval][out] */ long __RPC_FAR
*WindowStyleEx
) = 0;
273 virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE
put_AutoShow(
274 /* [in] */ long AutoShow
) = 0;
276 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_AutoShow(
277 /* [retval][out] */ long __RPC_FAR
*AutoShow
) = 0;
279 virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE
put_WindowState(
280 /* [in] */ long WindowState
) = 0;
282 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_WindowState(
283 /* [retval][out] */ long __RPC_FAR
*WindowState
) = 0;
285 virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE
put_BackgroundPalette(
286 /* [in] */ long pBackgroundPalette
) = 0;
288 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_BackgroundPalette(
289 /* [retval][out] */ long __RPC_FAR
*pBackgroundPalette
) = 0;
291 virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE
put_Visible(
292 /* [in] */ long pVisible
) = 0;
294 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_Visible(
295 /* [retval][out] */ long __RPC_FAR
*pVisible
) = 0;
297 virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE
put_Left(
298 /* [in] */ long pLeft
) = 0;
300 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_Left(
301 /* [retval][out] */ long __RPC_FAR
*pLeft
) = 0;
303 virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE
put_Width(
304 /* [in] */ long pWidth
) = 0;
306 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_Width(
307 /* [retval][out] */ long __RPC_FAR
*pWidth
) = 0;
309 virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE
put_Top(
310 /* [in] */ long pTop
) = 0;
312 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_Top(
313 /* [retval][out] */ long __RPC_FAR
*pTop
) = 0;
315 virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE
put_Height(
316 /* [in] */ long pHeight
) = 0;
318 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_Height(
319 /* [retval][out] */ long __RPC_FAR
*pHeight
) = 0;
321 virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE
put_Owner(
322 /* [in] */ LONG_PTR Owner
) = 0;
324 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_Owner(
325 /* [retval][out] */ LONG_PTR __RPC_FAR
*Owner
) = 0;
327 virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE
put_MessageDrain(
328 /* [in] */ LONG_PTR Drain
) = 0;
330 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_MessageDrain(
331 /* [retval][out] */ LONG_PTR __RPC_FAR
*Drain
) = 0;
333 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_BorderColor(
334 /* [retval][out] */ long __RPC_FAR
*Color
) = 0;
336 virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE
put_BorderColor(
337 /* [in] */ long Color
) = 0;
339 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_FullScreenMode(
340 /* [retval][out] */ long __RPC_FAR
*FullScreenMode
) = 0;
342 virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE
put_FullScreenMode(
343 /* [in] */ long FullScreenMode
) = 0;
345 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
SetWindowForeground(
346 /* [in] */ long Focus
) = 0;
348 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
NotifyOwnerMessage(
349 /* [in] */ LONG_PTR hwnd
,
350 /* [in] */ long uMsg
,
351 /* [in] */ LONG_PTR wParam
,
352 /* [in] */ LONG_PTR lParam
) = 0;
354 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
SetWindowPosition(
355 /* [in] */ long Left
,
357 /* [in] */ long Width
,
358 /* [in] */ long Height
) = 0;
360 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
GetWindowPosition(
361 /* [out] */ long __RPC_FAR
*pLeft
,
362 /* [out] */ long __RPC_FAR
*pTop
,
363 /* [out] */ long __RPC_FAR
*pWidth
,
364 /* [out] */ long __RPC_FAR
*pHeight
) = 0;
366 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
GetMinIdealImageSize(
367 /* [out] */ long __RPC_FAR
*pWidth
,
368 /* [out] */ long __RPC_FAR
*pHeight
) = 0;
370 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
GetMaxIdealImageSize(
371 /* [out] */ long __RPC_FAR
*pWidth
,
372 /* [out] */ long __RPC_FAR
*pHeight
) = 0;
374 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
GetRestorePosition(
375 /* [out] */ long __RPC_FAR
*pLeft
,
376 /* [out] */ long __RPC_FAR
*pTop
,
377 /* [out] */ long __RPC_FAR
*pWidth
,
378 /* [out] */ long __RPC_FAR
*pHeight
) = 0;
380 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
HideCursor(
381 /* [in] */ long HideCursor
) = 0;
383 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
IsCursorHidden(
384 /* [out] */ long __RPC_FAR
*CursorHidden
) = 0;
388 MIDL_INTERFACE("56A868B5-0AD4-11CE-B03A-0020AF0BA770")
389 IBasicVideo
: public IDispatch
392 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_AvgTimePerFrame(
393 /* [retval][out] */ double __RPC_FAR
*pAvgTimePerFrame
) = 0;
395 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_BitRate(
396 /* [retval][out] */ long __RPC_FAR
*pBitRate
) = 0;
398 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_BitErrorRate(
399 /* [retval][out] */ long __RPC_FAR
*pBitErrorRate
) = 0;
401 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_VideoWidth(
402 /* [retval][out] */ long __RPC_FAR
*pVideoWidth
) = 0;
404 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_VideoHeight(
405 /* [retval][out] */ long __RPC_FAR
*pVideoHeight
) = 0;
407 virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE
put_SourceLeft(
408 /* [in] */ long pSourceLeft
) = 0;
410 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_SourceLeft(
411 /* [retval][out] */ long __RPC_FAR
*pSourceLeft
) = 0;
413 virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE
put_SourceWidth(
414 /* [in] */ long pSourceWidth
) = 0;
416 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_SourceWidth(
417 /* [retval][out] */ long __RPC_FAR
*pSourceWidth
) = 0;
419 virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE
put_SourceTop(
420 /* [in] */ long pSourceTop
) = 0;
422 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_SourceTop(
423 /* [retval][out] */ long __RPC_FAR
*pSourceTop
) = 0;
425 virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE
put_SourceHeight(
426 /* [in] */ long pSourceHeight
) = 0;
428 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_SourceHeight(
429 /* [retval][out] */ long __RPC_FAR
*pSourceHeight
) = 0;
431 virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE
put_DestinationLeft(
432 /* [in] */ long pDestinationLeft
) = 0;
434 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_DestinationLeft(
435 /* [retval][out] */ long __RPC_FAR
*pDestinationLeft
) = 0;
437 virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE
put_DestinationWidth(
438 /* [in] */ long pDestinationWidth
) = 0;
440 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_DestinationWidth(
441 /* [retval][out] */ long __RPC_FAR
*pDestinationWidth
) = 0;
443 virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE
put_DestinationTop(
444 /* [in] */ long pDestinationTop
) = 0;
446 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_DestinationTop(
447 /* [retval][out] */ long __RPC_FAR
*pDestinationTop
) = 0;
449 virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE
put_DestinationHeight(
450 /* [in] */ long pDestinationHeight
) = 0;
452 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_DestinationHeight(
453 /* [retval][out] */ long __RPC_FAR
*pDestinationHeight
) = 0;
455 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
SetSourcePosition(
456 /* [in] */ long Left
,
458 /* [in] */ long Width
,
459 /* [in] */ long Height
) = 0;
461 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
GetSourcePosition(
462 /* [out] */ long __RPC_FAR
*pLeft
,
463 /* [out] */ long __RPC_FAR
*pTop
,
464 /* [out] */ long __RPC_FAR
*pWidth
,
465 /* [out] */ long __RPC_FAR
*pHeight
) = 0;
467 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
SetDefaultSourcePosition( void) = 0;
469 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
SetDestinationPosition(
470 /* [in] */ long Left
,
472 /* [in] */ long Width
,
473 /* [in] */ long Height
) = 0;
475 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
GetDestinationPosition(
476 /* [out] */ long __RPC_FAR
*pLeft
,
477 /* [out] */ long __RPC_FAR
*pTop
,
478 /* [out] */ long __RPC_FAR
*pWidth
,
479 /* [out] */ long __RPC_FAR
*pHeight
) = 0;
481 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
SetDefaultDestinationPosition( void) = 0;
483 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
GetVideoSize(
484 /* [out] */ long __RPC_FAR
*pWidth
,
485 /* [out] */ long __RPC_FAR
*pHeight
) = 0;
487 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
GetVideoPaletteEntries(
488 /* [in] */ long StartIndex
,
489 /* [in] */ long Entries
,
490 /* [out] */ long __RPC_FAR
*pRetrieved
,
491 /* [out] */ long __RPC_FAR
*pPalette
) = 0;
493 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
GetCurrentImage(
494 /* [out][in] */ long __RPC_FAR
*pBufferSize
,
495 /* [out] */ long __RPC_FAR
*pDIBImage
) = 0;
497 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
IsUsingDefaultSource( void) = 0;
499 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
IsUsingDefaultDestination( void) = 0;
503 MIDL_INTERFACE("329BB360-F6EA-11D1-9038-00A0C9697298")
504 IBasicVideo2
: public IBasicVideo
507 virtual HRESULT __stdcall
GetPreferredAspectRatio(
508 /* [out] */ long __RPC_FAR
*plAspectX
,
509 /* [out] */ long __RPC_FAR
*plAspectY
) = 0;
513 MIDL_INTERFACE("56A868B8-0AD4-11CE-B03A-0020AF0BA770")
514 IDeferredCommand
: public IUnknown
517 virtual HRESULT __stdcall
Cancel( void) = 0;
519 virtual HRESULT __stdcall
Confidence(
520 /* [out] */ long __RPC_FAR
*pConfidence
) = 0;
522 virtual HRESULT __stdcall
Postpone(
523 /* [in] */ double newtime
) = 0;
525 virtual HRESULT __stdcall
GetHResult(
526 /* [out] */ HRESULT __RPC_FAR
*phrResult
) = 0;
530 MIDL_INTERFACE("56A868B7-0AD4-11CE-B03A-0020AF0BA770")
531 IQueueCommand
: public IUnknown
534 virtual HRESULT __stdcall
InvokeAtStreamTime(
535 /* [out] */ IDeferredCommand __RPC_FAR
*__RPC_FAR
*pCmd
,
536 /* [in] */ double time
,
537 /* [in] */ GUID __RPC_FAR
*iid
,
538 /* [in] */ long dispidMethod
,
539 /* [in] */ short wFlags
,
540 /* [in] */ long cArgs
,
541 /* [in] */ VARIANT __RPC_FAR
*pDispParams
,
542 /* [out][in] */ VARIANT __RPC_FAR
*pvarResult
,
543 /* [out] */ short __RPC_FAR
*puArgErr
) = 0;
545 virtual HRESULT __stdcall
InvokeAtPresentationTime(
546 /* [out] */ IDeferredCommand __RPC_FAR
*__RPC_FAR
*pCmd
,
547 /* [in] */ double time
,
548 /* [in] */ GUID __RPC_FAR
*iid
,
549 /* [in] */ long dispidMethod
,
550 /* [in] */ short wFlags
,
551 /* [in] */ long cArgs
,
552 /* [in] */ VARIANT __RPC_FAR
*pDispParams
,
553 /* [out][in] */ VARIANT __RPC_FAR
*pvarResult
,
554 /* [out] */ short __RPC_FAR
*puArgErr
) = 0;
558 MIDL_INTERFACE("56A868BA-0AD4-11CE-B03A-0020AF0BA770")
559 IFilterInfo
: public IDispatch
562 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
FindPin(
563 /* [in] */ BSTR strPinID
,
564 /* [out] */ IDispatch __RPC_FAR
*__RPC_FAR
*ppUnk
) = 0;
566 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_Name(
567 /* [retval][out] */ BSTR __RPC_FAR
*strName
) = 0;
569 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_VendorInfo(
570 /* [retval][out] */ BSTR __RPC_FAR
*strVendorInfo
) = 0;
572 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_Filter(
573 /* [retval][out] */ IUnknown __RPC_FAR
*__RPC_FAR
*ppUnk
) = 0;
575 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_Pins(
576 /* [retval][out] */ IDispatch __RPC_FAR
*__RPC_FAR
*ppUnk
) = 0;
578 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_IsFileSource(
579 /* [retval][out] */ long __RPC_FAR
*pbIsSource
) = 0;
581 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_Filename(
582 /* [retval][out] */ BSTR __RPC_FAR
*pstrFilename
) = 0;
584 virtual /* [propput][id] */ HRESULT STDMETHODCALLTYPE
put_Filename(
585 /* [in] */ BSTR pstrFilename
) = 0;
589 MIDL_INTERFACE("56A868BB-0AD4-11CE-B03A-0020AF0BA770")
590 IRegFilterInfo
: public IDispatch
593 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_Name(
594 /* [retval][out] */ BSTR __RPC_FAR
*strName
) = 0;
596 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
Filter(
597 /* [out] */ IDispatch __RPC_FAR
*__RPC_FAR
*ppUnk
) = 0;
601 MIDL_INTERFACE("56A868BC-0AD4-11CE-B03A-0020AF0BA770")
602 IMediaTypeInfo
: public IDispatch
605 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_Type(
606 /* [retval][out] */ BSTR __RPC_FAR
*strType
) = 0;
608 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_Subtype(
609 /* [retval][out] */ BSTR __RPC_FAR
*strType
) = 0;
613 MIDL_INTERFACE("56A868BD-0AD4-11CE-B03A-0020AF0BA770")
614 IPinInfo
: public IDispatch
617 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_Pin(
618 /* [retval][out] */ IUnknown __RPC_FAR
*__RPC_FAR
*ppUnk
) = 0;
620 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_ConnectedTo(
621 /* [retval][out] */ IDispatch __RPC_FAR
*__RPC_FAR
*ppUnk
) = 0;
623 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_ConnectionMediaType(
624 /* [retval][out] */ IDispatch __RPC_FAR
*__RPC_FAR
*ppUnk
) = 0;
626 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_FilterInfo(
627 /* [retval][out] */ IDispatch __RPC_FAR
*__RPC_FAR
*ppUnk
) = 0;
629 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_Name(
630 /* [retval][out] */ BSTR __RPC_FAR
*ppUnk
) = 0;
632 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_Direction(
633 /* [retval][out] */ long __RPC_FAR
*ppDirection
) = 0;
635 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_PinID(
636 /* [retval][out] */ BSTR __RPC_FAR
*strPinID
) = 0;
638 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_MediaTypes(
639 /* [retval][out] */ IDispatch __RPC_FAR
*__RPC_FAR
*ppUnk
) = 0;
641 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
Connect(
642 /* [in] */ IUnknown __RPC_FAR
*pPin
) = 0;
644 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
ConnectDirect(
645 /* [in] */ IUnknown __RPC_FAR
*pPin
) = 0;
647 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
ConnectWithType(
648 /* [in] */ IUnknown __RPC_FAR
*pPin
,
649 /* [in] */ IDispatch __RPC_FAR
*pMediaType
) = 0;
651 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
Disconnect( void) = 0;
653 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
Render( void) = 0;
657 MIDL_INTERFACE("BC9BCF80-DCD2-11D2-ABF6-00A0C905F375")
658 IAMStats
: public IDispatch
661 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
Reset( void) = 0;
663 virtual /* [propget][id] */ HRESULT STDMETHODCALLTYPE
get_Count(
664 /* [retval][out] */ long __RPC_FAR
*plCount
) = 0;
666 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
GetValueByIndex(
667 /* [in] */ long lIndex
,
668 /* [out] */ BSTR __RPC_FAR
*szName
,
669 /* [out] */ long __RPC_FAR
*lCount
,
670 /* [out] */ double __RPC_FAR
*dLast
,
671 /* [out] */ double __RPC_FAR
*dAverage
,
672 /* [out] */ double __RPC_FAR
*dStdDev
,
673 /* [out] */ double __RPC_FAR
*dMin
,
674 /* [out] */ double __RPC_FAR
*dMax
) = 0;
676 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
GetValueByName(
677 /* [in] */ BSTR szName
,
678 /* [out] */ long __RPC_FAR
*lIndex
,
679 /* [out] */ long __RPC_FAR
*lCount
,
680 /* [out] */ double __RPC_FAR
*dLast
,
681 /* [out] */ double __RPC_FAR
*dAverage
,
682 /* [out] */ double __RPC_FAR
*dStdDev
,
683 /* [out] */ double __RPC_FAR
*dMin
,
684 /* [out] */ double __RPC_FAR
*dMax
) = 0;
686 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
GetIndex(
687 /* [in] */ BSTR szName
,
688 /* [in] */ long lCreate
,
689 /* [out] */ long __RPC_FAR
*plIndex
) = 0;
691 virtual /* [id] */ HRESULT STDMETHODCALLTYPE
AddValue(
692 /* [in] */ long lIndex
,
693 /* [in] */ double dValue
) = 0;
697 //------------------------------------------------------------------
698 // wxAMMediaBackend (Active Movie)
699 //------------------------------------------------------------------
700 class WXDLLIMPEXP_MEDIA wxAMMediaBackend
: public wxMediaBackend
705 virtual ~wxAMMediaBackend();
707 virtual bool CreateControl(wxControl
* ctrl
, wxWindow
* parent
,
712 const wxValidator
& validator
,
713 const wxString
& name
);
716 virtual bool Pause();
719 virtual bool Load(const wxString
& fileName
);
720 virtual bool Load(const wxURI
& location
);
722 virtual wxMediaState
GetState();
724 virtual bool SetPosition(wxLongLong where
);
725 virtual wxLongLong
GetPosition();
726 virtual wxLongLong
GetDuration();
728 virtual void Move(int x
, int y
, int w
, int h
);
729 wxSize
GetVideoSize() const;
731 virtual double GetPlaybackRate();
732 virtual bool SetPlaybackRate(double);
734 virtual double GetVolume();
735 virtual bool SetVolume(double);
741 static LRESULT CALLBACK
NotifyWndProc(HWND hWnd
, UINT nMsg
,
742 WPARAM wParam
, LPARAM lParam
);
744 LRESULT CALLBACK
OnNotifyWndProc(HWND hWnd
, UINT nMsg
,
745 WPARAM wParam
, LPARAM lParam
);
751 IMediaControl
* m_pMC
;
752 IMediaEventEx
* m_pME
;
753 IMediaPosition
* m_pMS
;
759 DECLARE_DYNAMIC_CLASS(wxAMMediaBackend
);
762 //---------------------------------------------------------------------------
766 //---------------------------------------------------------------------------
768 //---------------------------------------------------------------------------
770 //---------------------------------------------------------------------------
771 #include <mmsystem.h>
773 class WXDLLIMPEXP_MEDIA wxMCIMediaBackend
: public wxMediaBackend
778 ~wxMCIMediaBackend();
780 virtual bool CreateControl(wxControl
* ctrl
, wxWindow
* parent
,
785 const wxValidator
& validator
,
786 const wxString
& name
);
789 virtual bool Pause();
792 virtual bool Load(const wxString
& fileName
);
793 virtual bool Load(const wxURI
& location
);
795 virtual wxMediaState
GetState();
797 virtual bool SetPosition(wxLongLong where
);
798 virtual wxLongLong
GetPosition();
799 virtual wxLongLong
GetDuration();
801 virtual void Move(int x
, int y
, int w
, int h
);
802 wxSize
GetVideoSize() const;
804 virtual double GetPlaybackRate();
805 virtual bool SetPlaybackRate(double dRate
);
807 virtual double GetVolume();
808 virtual bool SetVolume(double);
810 static LRESULT CALLBACK
NotifyWndProc(HWND hWnd
, UINT nMsg
,
811 WPARAM wParam
, LPARAM lParam
);
813 LRESULT CALLBACK
OnNotifyWndProc(HWND hWnd
, UINT nMsg
,
814 WPARAM wParam
, LPARAM lParam
);
816 MCIDEVICEID m_hDev
; //Our MCI Device ID/Handler
817 wxControl
* m_ctrl
; //Parent control
818 HWND m_hNotifyWnd
; //Window to use for MCI events
819 bool m_bVideo
; //Whether or not we have video
821 DECLARE_DYNAMIC_CLASS(wxMCIMediaBackend
)
824 //---------------------------------------------------------------------------
828 //---------------------------------------------------------------------------
830 //---------------------------------------------------------------------------
832 //---------------------------------------------------------------------------
833 //#include <qtml.h> //Windoze QT include
834 //#include <QuickTimeComponents.h> //Standard QT stuff
835 #include "wx/dynlib.h"
837 //---------------------------------------------------------------------------
839 //---------------------------------------------------------------------------
840 typedef struct MovieRecord
* Movie
;
841 typedef wxInt16 OSErr
;
842 typedef wxInt32 OSStatus
;
845 typedef unsigned char Str255
[256];
846 #define StringPtr unsigned char*
847 #define newMovieActive 1
851 #define OSType unsigned long
852 #define CGrafPtr struct GrafPort *
853 #define TimeScale long
854 #define TimeBase struct TimeBaseRecord *
859 Str255 name
; /*Str63 on mac, Str255 on msw */
875 wide value
; /* units */
876 TimeScale scale
; /* units per second */
880 //---------------------------------------------------------------------------
882 //---------------------------------------------------------------------------
883 #define wxDL_METHOD_DEFINE( rettype, name, args, shortargs, defret ) \
884 typedef rettype (* name ## Type) args ; \
885 name ## Type pfn_ ## name; \
887 { if (m_ok) return pfn_ ## name shortargs ; return defret; }
889 #define wxDL_VOIDMETHOD_DEFINE( name, args, shortargs ) \
890 typedef void (* name ## Type) args ; \
891 name ## Type pfn_ ## name; \
893 { if (m_ok) pfn_ ## name shortargs ; }
895 #define wxDL_METHOD_LOAD( lib, name, success ) \
896 pfn_ ## name = (name ## Type) lib.GetSymbol( wxT(#name), &success ); \
897 if (!success) return false;
899 //Class that utilizes Robert Roeblings Dynamic Library Macros
900 class WXDLLIMPEXP_MEDIA wxQuickTimeLibrary
903 ~wxQuickTimeLibrary()
910 bool IsOk() const {return m_ok
;}
913 wxDynamicLibrary m_dll
;
917 wxDL_VOIDMETHOD_DEFINE( StartMovie
, (Movie m
), (m
) );
918 wxDL_VOIDMETHOD_DEFINE( StopMovie
, (Movie m
), (m
) );
919 wxDL_METHOD_DEFINE( bool, IsMovieDone
, (Movie m
), (m
), false);
920 wxDL_VOIDMETHOD_DEFINE( GoToBeginningOfMovie
, (Movie m
), (m
) );
921 wxDL_METHOD_DEFINE( OSErr
, GetMoviesError
, (), (), -1);
922 wxDL_METHOD_DEFINE( OSErr
, EnterMovies
, (), (), -1);
923 wxDL_VOIDMETHOD_DEFINE( ExitMovies
, (), () );
924 wxDL_METHOD_DEFINE( OSErr
, InitializeQTML
, (long flags
), (flags
), -1);
925 wxDL_VOIDMETHOD_DEFINE( TerminateQTML
, (), () );
927 wxDL_METHOD_DEFINE( OSErr
, NativePathNameToFSSpec
,
928 (char* inName
, FSSpec
* outFile
, long flags
),
929 (inName
, outFile
, flags
), -1);
931 wxDL_METHOD_DEFINE( OSErr
, OpenMovieFile
,
932 (const FSSpec
* fileSpec
, short * resRefNum
, wxInt8 permission
),
933 (fileSpec
, resRefNum
, permission
), -1 );
935 wxDL_METHOD_DEFINE( OSErr
, CloseMovieFile
,
936 (short resRefNum
), (resRefNum
), -1);
938 wxDL_METHOD_DEFINE( OSErr
, NewMovieFromFile
,
939 (Movie
* theMovie
, short resRefNum
, short * resId
,
940 StringPtr resName
, short newMovieFlags
,
941 bool * dataRefWasChanged
),
942 (theMovie
, resRefNum
, resId
, resName
, newMovieFlags
,
943 dataRefWasChanged
), -1);
945 wxDL_VOIDMETHOD_DEFINE( SetMovieRate
, (Movie m
, Fixed rate
), (m
, rate
) );
946 wxDL_METHOD_DEFINE( Fixed
, GetMovieRate
, (Movie m
), (m
), 0);
947 wxDL_VOIDMETHOD_DEFINE( MoviesTask
, (Movie m
, long maxms
), (m
, maxms
) );
948 wxDL_VOIDMETHOD_DEFINE( BlockMove
,
949 (const char* p1
, const char* p2
, long s
), (p1
,p2
,s
) );
950 wxDL_METHOD_DEFINE( Handle
, NewHandleClear
, (long s
), (s
), NULL
);
952 wxDL_METHOD_DEFINE( OSErr
, NewMovieFromDataRef
,
953 (Movie
* m
, short flags
, short * id
,
954 Handle dataRef
, OSType dataRefType
),
955 (m
,flags
,id
,dataRef
,dataRefType
), -1 );
957 wxDL_VOIDMETHOD_DEFINE( DisposeHandle
, (Handle h
), (h
) );
958 wxDL_VOIDMETHOD_DEFINE( GetMovieNaturalBoundsRect
, (Movie m
, Rect
* r
), (m
,r
) );
959 wxDL_METHOD_DEFINE( void*, GetMovieIndTrackType
,
960 (Movie m
, long index
, OSType type
, long flags
),
961 (m
,index
,type
,flags
), NULL
);
962 wxDL_VOIDMETHOD_DEFINE( CreatePortAssociation
,
963 (void* hWnd
, void* junk
, long morejunk
), (hWnd
, junk
, morejunk
) );
964 wxDL_METHOD_DEFINE(void*, GetNativeWindowPort
, (void* hWnd
), (hWnd
), NULL
);
965 wxDL_VOIDMETHOD_DEFINE(SetMovieGWorld
, (Movie m
, CGrafPtr port
, void* whatever
),
966 (m
, port
, whatever
) );
967 wxDL_VOIDMETHOD_DEFINE(DisposeMovie
, (Movie m
), (m
) );
968 wxDL_VOIDMETHOD_DEFINE(SetMovieBox
, (Movie m
, Rect
* r
), (m
,r
));
969 wxDL_VOIDMETHOD_DEFINE(SetMovieTimeScale
, (Movie m
, long s
), (m
,s
));
970 wxDL_METHOD_DEFINE(long, GetMovieDuration
, (Movie m
), (m
), 0);
971 wxDL_METHOD_DEFINE(TimeBase
, GetMovieTimeBase
, (Movie m
), (m
), 0);
972 wxDL_METHOD_DEFINE(TimeScale
, GetMovieTimeScale
, (Movie m
), (m
), 0);
973 wxDL_METHOD_DEFINE(long, GetMovieTime
, (Movie m
, void* cruft
), (m
,cruft
), 0);
974 wxDL_VOIDMETHOD_DEFINE(SetMovieTime
, (Movie m
, TimeRecord
* tr
), (m
,tr
) );
975 wxDL_METHOD_DEFINE(short, GetMovieVolume
, (Movie m
), (m
), 0);
976 wxDL_VOIDMETHOD_DEFINE(SetMovieVolume
, (Movie m
, short sVolume
), (m
,sVolume
) );
979 bool wxQuickTimeLibrary::Initialize()
983 if(!m_dll
.Load(wxT("qtmlClient.dll")))
988 wxDL_METHOD_LOAD( m_dll
, StartMovie
, bOk
);
989 wxDL_METHOD_LOAD( m_dll
, StopMovie
, bOk
);
990 wxDL_METHOD_LOAD( m_dll
, IsMovieDone
, bOk
);
991 wxDL_METHOD_LOAD( m_dll
, GoToBeginningOfMovie
, bOk
);
992 wxDL_METHOD_LOAD( m_dll
, GetMoviesError
, bOk
);
993 wxDL_METHOD_LOAD( m_dll
, EnterMovies
, bOk
);
994 wxDL_METHOD_LOAD( m_dll
, ExitMovies
, bOk
);
995 wxDL_METHOD_LOAD( m_dll
, InitializeQTML
, bOk
);
996 wxDL_METHOD_LOAD( m_dll
, TerminateQTML
, bOk
);
997 wxDL_METHOD_LOAD( m_dll
, NativePathNameToFSSpec
, bOk
);
998 wxDL_METHOD_LOAD( m_dll
, OpenMovieFile
, bOk
);
999 wxDL_METHOD_LOAD( m_dll
, CloseMovieFile
, bOk
);
1000 wxDL_METHOD_LOAD( m_dll
, NewMovieFromFile
, bOk
);
1001 wxDL_METHOD_LOAD( m_dll
, GetMovieRate
, bOk
);
1002 wxDL_METHOD_LOAD( m_dll
, SetMovieRate
, bOk
);
1003 wxDL_METHOD_LOAD( m_dll
, MoviesTask
, bOk
);
1004 wxDL_METHOD_LOAD( m_dll
, BlockMove
, bOk
);
1005 wxDL_METHOD_LOAD( m_dll
, NewHandleClear
, bOk
);
1006 wxDL_METHOD_LOAD( m_dll
, NewMovieFromDataRef
, bOk
);
1007 wxDL_METHOD_LOAD( m_dll
, DisposeHandle
, bOk
);
1008 wxDL_METHOD_LOAD( m_dll
, GetMovieNaturalBoundsRect
, bOk
);
1009 wxDL_METHOD_LOAD( m_dll
, GetMovieIndTrackType
, bOk
);
1010 wxDL_METHOD_LOAD( m_dll
, CreatePortAssociation
, bOk
);
1011 wxDL_METHOD_LOAD( m_dll
, GetNativeWindowPort
, bOk
);
1012 wxDL_METHOD_LOAD( m_dll
, SetMovieGWorld
, bOk
);
1013 wxDL_METHOD_LOAD( m_dll
, DisposeMovie
, bOk
);
1014 wxDL_METHOD_LOAD( m_dll
, SetMovieBox
, bOk
);
1015 wxDL_METHOD_LOAD( m_dll
, SetMovieTimeScale
, bOk
);
1016 wxDL_METHOD_LOAD( m_dll
, GetMovieDuration
, bOk
);
1017 wxDL_METHOD_LOAD( m_dll
, GetMovieTimeBase
, bOk
);
1018 wxDL_METHOD_LOAD( m_dll
, GetMovieTimeScale
, bOk
);
1019 wxDL_METHOD_LOAD( m_dll
, GetMovieTime
, bOk
);
1020 wxDL_METHOD_LOAD( m_dll
, SetMovieTime
, bOk
);
1021 wxDL_METHOD_LOAD( m_dll
, GetMovieVolume
, bOk
);
1022 wxDL_METHOD_LOAD( m_dll
, SetMovieVolume
, bOk
);
1029 class WXDLLIMPEXP_MEDIA wxQTMediaBackend
: public wxMediaBackend
1034 ~wxQTMediaBackend();
1036 virtual bool CreateControl(wxControl
* ctrl
, wxWindow
* parent
,
1041 const wxValidator
& validator
,
1042 const wxString
& name
);
1044 virtual bool Play();
1045 virtual bool Pause();
1046 virtual bool Stop();
1048 virtual bool Load(const wxString
& fileName
);
1049 virtual bool Load(const wxURI
& location
);
1051 virtual wxMediaState
GetState();
1053 virtual bool SetPosition(wxLongLong where
);
1054 virtual wxLongLong
GetPosition();
1055 virtual wxLongLong
GetDuration();
1057 virtual void Move(int x
, int y
, int w
, int h
);
1058 wxSize
GetVideoSize() const;
1060 virtual double GetPlaybackRate();
1061 virtual bool SetPlaybackRate(double dRate
);
1063 virtual double GetVolume();
1064 virtual bool SetVolume(double);
1069 wxSize m_bestSize
; //Original movie size
1070 Movie m_movie
; //QT Movie handle/instance
1071 wxControl
* m_ctrl
; //Parent control
1072 bool m_bVideo
; //Whether or not we have video
1073 class _wxQTTimer
* m_timer
; //Timer for streaming the movie
1074 wxQuickTimeLibrary m_lib
;
1077 DECLARE_DYNAMIC_CLASS(wxQTMediaBackend
);
1081 //===========================================================================
1083 //===========================================================================
1085 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1089 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1091 IMPLEMENT_DYNAMIC_CLASS(wxAMMediaBackend
, wxMediaBackend
);
1093 // Numerical value for when the graph reaches the stop position
1094 #define WM_GRAPHNOTIFY WM_USER+13
1096 //---------------------------------------------------------------------------
1097 // Usual debugging macros
1098 //---------------------------------------------------------------------------
1100 #define wxAMVERIFY(x) \
1102 HRESULT hrdsv = (x); \
1103 if ( FAILED(hrdsv) ) \
1105 /*TCHAR szError[MAX_ERROR_TEXT_LEN];*/ \
1106 /*if( AMGetErrorText(hrdsv, szError, MAX_ERROR_TEXT_LEN) == 0)*/ \
1108 /*wxFAIL_MSG( wxString::Format(wxT("DirectShow error \"%s\" ")*/\
1109 /*wxT("occured at line %i in ")*/ \
1110 /*wxT("mediactrl.cpp"),*/ \
1111 /*szError, __LINE__) );*/ \
1114 wxFAIL_MSG( wxString::Format(wxT("Unknown error (%i) ") \
1116 wxT(" line %i in mediactrl.cpp."), \
1117 (int)hrdsv, __LINE__) ); \
1120 #define wxVERIFY(x) wxASSERT((x))
1122 #define wxAMVERIFY(x) (x)
1123 #define wxVERIFY(x) (x)
1126 //---------------------------------------------------------------------------
1127 // Standard macros for ease of use
1128 //---------------------------------------------------------------------------
1129 #define SAFE_RELEASE(x) { if (x) x->Release(); x = NULL; }
1131 //---------------------------------------------------------------------------
1132 // wxAMMediaBackend Constructor
1134 // Sets m_hNotifyWnd to NULL to signify that we haven't loaded anything yet
1135 //---------------------------------------------------------------------------
1136 wxAMMediaBackend::wxAMMediaBackend() : m_hNotifyWnd(NULL
)
1140 //---------------------------------------------------------------------------
1141 // wxAMMediaBackend Destructor
1143 // Cleans up everything
1144 //---------------------------------------------------------------------------
1145 wxAMMediaBackend::~wxAMMediaBackend()
1151 //---------------------------------------------------------------------------
1152 // wxAMMediaBackend::CreateControl
1154 // ActiveMovie does not really have any native control to speak of,
1155 // so we just create a normal control.
1157 // We also check to see if ActiveMovie is installed
1158 //---------------------------------------------------------------------------
1159 bool wxAMMediaBackend::CreateControl(wxControl
* ctrl
, wxWindow
* parent
,
1164 const wxValidator
& validator
,
1165 const wxString
& name
)
1167 //create our filter graph - the beuty of COM is that it loads
1168 //quartz.dll for us :)
1169 HRESULT hr
= CoCreateInstance(CLSID_FilgraphManager
, NULL
, CLSCTX_INPROC_SERVER
,
1170 IID_IMediaControl
, (void**)&m_pMC
);
1172 //directshow not installed?
1176 //release the filter graph - we don't need it yet
1182 // By default wxWindow(s) is created with a border -
1183 // so we need to get rid of those, and create with
1184 // wxCLIP_CHILDREN, so that if the driver/backend
1185 // is a child window, it refereshes properly
1187 if ( !ctrl
->wxControl::Create(parent
, id
, pos
, size
,
1188 (style
& ~wxBORDER_MASK
) | wxBORDER_NONE
| wxCLIP_CHILDREN
,
1197 //---------------------------------------------------------------------------
1198 // wxAMMediaBackend::Load (file version)
1200 // Creates an Active Movie filter graph from a file or url
1201 //---------------------------------------------------------------------------
1202 bool wxAMMediaBackend::Load(const wxString
& fileName
)
1204 //if previously loaded cleanup
1208 //We already checked for success in CreateControl
1209 CoCreateInstance(CLSID_FilgraphManager
, NULL
, CLSCTX_INPROC_SERVER
,
1210 IID_IMediaControl
, (void**)&m_pMC
);
1212 //load the graph & render
1213 if( FAILED(m_pMC
->RenderFile(wxBasicString(fileName
).Get())) )
1216 //get the interfaces, all of them
1217 wxAMVERIFY( m_pMC
->QueryInterface(IID_IMediaEventEx
, (void**)&m_pME
) );
1218 wxAMVERIFY( m_pMC
->QueryInterface(IID_IMediaPosition
, (void**)&m_pMS
) );
1219 wxAMVERIFY( m_pMC
->QueryInterface(IID_IVideoWindow
, (void**)&m_pVW
) );
1220 wxAMVERIFY( m_pMC
->QueryInterface(IID_IBasicAudio
, (void**)&m_pBA
) );
1221 wxAMVERIFY( m_pMC
->QueryInterface(IID_IBasicVideo
, (void**)&m_pBV
) );
1223 //We could tell if the media has audio or not by
1227 //pBA->get_Volume(&lVolume) == E_NOTIMPL
1232 //Obtain the _actual_ size of the movie & remember it
1237 m_bestSize
.x
= m_bestSize
.y
= 0;
1239 m_bVideo
= SUCCEEDED( m_pVW
->GetWindowPosition( &nX
,
1241 (long*)&m_bestSize
.x
,
1242 (long*)&m_bestSize
.y
) );
1245 //If we have video in the media - set it up so that
1246 //its a child window of the control, its visible,
1247 //and that the control is the owner of the video window
1251 wxAMVERIFY( m_pVW
->put_Owner((LONG_PTR
)m_ctrl
->GetHandle()) );
1252 wxAMVERIFY( m_pVW
->put_WindowStyle(WS_CHILD
| WS_CLIPSIBLINGS
) );
1253 wxAMVERIFY( m_pVW
->put_Visible(-1) ); //OATRUE == -1
1257 // Create a hidden window and register to handle
1258 // directshow events for this graph
1259 // Note that wxCanvasClassName is already registered
1260 // and used by all wxWindows and normal wxControls
1262 m_hNotifyWnd
= ::CreateWindow
1276 wxLogSysError( wxT("Could not create hidden needed for ")
1277 wxT("registering for DirectShow events!") );
1282 wxSetWindowProc(m_hNotifyWnd
, wxAMMediaBackend::NotifyWndProc
);
1283 wxSetWindowUserData(m_hNotifyWnd
, (void*)this);
1286 wxAMVERIFY( m_pME
->SetNotifyWindow((LONG_PTR
)m_hNotifyWnd
,
1287 WM_GRAPHNOTIFY
, 0) );
1290 // Force the parent window of this control to recalculate
1291 // the size of this if sizers are being used
1292 // and render the results immediately
1294 m_ctrl
->InvalidateBestSize();
1295 m_ctrl
->GetParent()->Layout();
1296 m_ctrl
->GetParent()->Refresh();
1297 m_ctrl
->GetParent()->Update();
1298 m_ctrl
->SetSize(m_ctrl
->GetSize());
1303 //---------------------------------------------------------------------------
1304 // wxAMMediaBackend::Load (URL Version)
1306 // Loads media from a URL. Interestingly enough DirectShow
1307 // appears (?) to escape the URL for us, at least on normal
1309 //---------------------------------------------------------------------------
1310 bool wxAMMediaBackend::Load(const wxURI
& location
)
1312 return Load(location
.BuildUnescapedURI());
1315 //---------------------------------------------------------------------------
1316 // wxAMMediaBackend::Play
1318 // Plays the stream. If it is non-seekable, it will restart it.
1319 //---------------------------------------------------------------------------
1320 bool wxAMMediaBackend::Play()
1322 return SUCCEEDED( m_pMC
->Run() );
1325 //---------------------------------------------------------------------------
1326 // wxAMMediaBackend::Pause
1328 // Pauses the stream.
1329 //---------------------------------------------------------------------------
1330 bool wxAMMediaBackend::Pause()
1332 return SUCCEEDED( m_pMC
->Pause() );
1335 //---------------------------------------------------------------------------
1336 // wxAMMediaBackend::Stop
1338 // Stops the stream.
1339 //---------------------------------------------------------------------------
1340 bool wxAMMediaBackend::Stop()
1342 bool bOK
= SUCCEEDED( m_pMC
->Stop() );
1344 //We don't care if it can't get to the beginning in directshow -
1345 //it could be a non-seeking filter (wince midi) in which case playing
1346 //starts all over again
1351 //---------------------------------------------------------------------------
1352 // wxAMMediaBackend::SetPosition
1354 // 1) Translates the current position's time to directshow time,
1355 // which is in a scale of 1 second (in a double)
1356 // 2) Sets the play position of the IMediaSeeking interface -
1357 // passing NULL as the stop position means to keep the old
1359 //---------------------------------------------------------------------------
1360 bool wxAMMediaBackend::SetPosition(wxLongLong where
)
1362 return SUCCEEDED( m_pMS
->put_CurrentPosition(
1363 ((LONGLONG
)where
.GetValue()) / 1000
1368 //---------------------------------------------------------------------------
1369 // wxAMMediaBackend::GetPosition
1371 // 1) Obtains the current play and stop positions from IMediaSeeking
1372 // 2) Returns the play position translated to our time base
1373 //---------------------------------------------------------------------------
1374 wxLongLong
wxAMMediaBackend::GetPosition()
1377 wxAMVERIFY( m_pMS
->get_CurrentPosition(&outCur
) );
1379 //h,m,s,milli - outdur is in 1 second (double)
1387 //---------------------------------------------------------------------------
1388 // wxAMMediaBackend::SetVolume
1390 // Sets the volume through the IBasicAudio interface -
1391 // value ranges from 0 (MAX volume) to -10000 (minimum volume).
1392 // -100 per decibel.
1393 //---------------------------------------------------------------------------
1394 bool wxAMMediaBackend::SetVolume(double dVolume
)
1396 return SUCCEEDED(m_pBA
->put_Volume( (long) ((dVolume
-1.0) * 10000.0) ));
1399 //---------------------------------------------------------------------------
1400 // wxAMMediaBackend::GetVolume
1402 // Gets the volume through the IBasicAudio interface -
1403 // value ranges from 0 (MAX volume) to -10000 (minimum volume).
1404 // -100 per decibel.
1405 //---------------------------------------------------------------------------
1406 double wxAMMediaBackend::GetVolume()
1409 if ( SUCCEEDED(m_pBA
->get_Volume(&lVolume
)) )
1410 return (((double)(lVolume
+ 10000)) / 10000.0);
1414 //---------------------------------------------------------------------------
1415 // wxAMMediaBackend::GetDuration
1417 // 1) Obtains the duration of the media from the IMediaSeeking interface
1418 // 2) Converts that value to our time base, and returns it
1419 //---------------------------------------------------------------------------
1420 wxLongLong
wxAMMediaBackend::GetDuration()
1423 wxAMVERIFY( m_pMS
->get_Duration(&outDuration
) );
1425 //h,m,s,milli - outdur is in 1 second (double)
1426 outDuration
*= 1000;
1428 ll
.Assign(outDuration
);
1433 //---------------------------------------------------------------------------
1434 // wxAMMediaBackend::GetState
1436 // Obtains the state from the IMediaControl interface.
1437 // Note that it's enumeration values for stopping/playing
1438 // etc. are the same as ours, so we just do a straight cast.
1439 // TODO: MS recommends against INFINITE here for
1440 // IMediaControl::GetState- do it in stages
1441 //---------------------------------------------------------------------------
1442 wxMediaState
wxAMMediaBackend::GetState()
1444 long theState
; //OAFilterState
1445 HRESULT hr
= m_pMC
->GetState(INFINITE
, &theState
);
1447 wxASSERT( SUCCEEDED(hr
) );
1453 //MSW state is the same as ours
1454 //State_Stopped = 0,
1455 //State_Paused = State_Stopped + 1,
1456 //State_Running = State_Paused + 1
1458 return (wxMediaState
) theState
;
1461 //---------------------------------------------------------------------------
1462 // wxAMMediaBackend::GetPlaybackRate
1464 // Pretty simple way of obtaining the playback rate from
1465 // the IMediaSeeking interface
1466 //---------------------------------------------------------------------------
1467 double wxAMMediaBackend::GetPlaybackRate()
1470 wxAMVERIFY( m_pMS
->get_Rate(&dRate
) );
1474 //---------------------------------------------------------------------------
1475 // wxAMMediaBackend::SetPlaybackRate
1477 // Sets the playback rate of the media - DirectShow is pretty good
1478 // about this, actually
1479 //---------------------------------------------------------------------------
1480 bool wxAMMediaBackend::SetPlaybackRate(double dRate
)
1482 return SUCCEEDED( m_pMS
->put_Rate(dRate
) );
1485 //---------------------------------------------------------------------------
1486 // wxAMMediaBackend::NotifyWndProc
1488 // Here we check to see if DirectShow tells us we've reached the stop
1489 // position in our stream - if it has, it may not actually stop
1490 // the stream - which we need to do...
1491 //---------------------------------------------------------------------------
1492 LRESULT CALLBACK
wxAMMediaBackend::NotifyWndProc(HWND hWnd
, UINT nMsg
,
1496 wxAMMediaBackend
* backend
= (wxAMMediaBackend
*)
1497 ::GetWindowLong(hWnd
, GWL_USERDATA
);
1499 return backend
->OnNotifyWndProc(hWnd
, nMsg
, wParam
, lParam
);
1502 LRESULT CALLBACK
wxAMMediaBackend::OnNotifyWndProc(HWND hWnd
, UINT nMsg
,
1506 if (nMsg
== WM_GRAPHNOTIFY
)
1513 // DirectShow keeps a list of queued events, and we need
1514 // to go through them one by one, stopping at (Hopefully only one)
1515 // EC_COMPLETE message
1517 while(SUCCEEDED(m_pME
->GetEvent(&evCode
, (LONG_PTR
*) &evParam1
,
1518 (LONG_PTR
*) &evParam2
, 0)
1522 // Cleanup memory that GetEvent allocated
1523 wxAMVERIFY( m_pME
->FreeEventParams(evCode
, evParam1
, evParam2
) );
1525 // If this is the end of the clip, notify handler
1526 if(1 == evCode
) //EC_COMPLETE
1528 //send the event to our child
1529 wxMediaEvent
theEvent(wxEVT_MEDIA_STOP
, m_ctrl
->GetId());
1530 m_ctrl
->ProcessEvent(theEvent
);
1532 //if the user didn't veto it, stop the stream
1533 if (theEvent
.IsAllowed())
1535 //Interestingly enough, DirectShow does not actually stop
1536 //the filters - even when it reaches the end!
1539 //send the event to our child
1540 wxMediaEvent
theEvent(wxEVT_MEDIA_FINISHED
,
1542 m_ctrl
->ProcessEvent(theEvent
);
1547 return DefWindowProc(hWnd
, nMsg
, wParam
, lParam
);
1550 //---------------------------------------------------------------------------
1551 // wxAMMediaBackend::Cleanup
1553 // 1) Hide/disowns the video window (MS says bad things will happen if
1555 // 2) Releases all the directshow interfaces we use
1556 // TODO: Maybe there's a way to redirect the IMediaControl each time
1557 // we load, rather then creating and destroying the interfaces
1559 //---------------------------------------------------------------------------
1560 void wxAMMediaBackend::Cleanup()
1562 // Hide then disown the window
1565 m_pVW
->put_Visible(0); //OSFALSE == 0
1566 m_pVW
->put_Owner(0);
1569 // Release and zero DirectShow interfaces
1570 SAFE_RELEASE(m_pME
);
1571 SAFE_RELEASE(m_pMS
);
1572 SAFE_RELEASE(m_pBA
);
1573 SAFE_RELEASE(m_pBV
);
1574 SAFE_RELEASE(m_pVW
);
1575 SAFE_RELEASE(m_pMC
);
1577 // Get rid of our hidden Window
1578 DestroyWindow(m_hNotifyWnd
);
1579 m_hNotifyWnd
= NULL
;
1583 //---------------------------------------------------------------------------
1584 // wxAMMediaBackend::GetVideoSize
1586 // Obtains the cached original video size
1587 //---------------------------------------------------------------------------
1588 wxSize
wxAMMediaBackend::GetVideoSize() const
1593 //---------------------------------------------------------------------------
1594 // wxAMMediaBackend::Move
1596 // Resizes the IVideoWindow to the size of the control window
1597 //---------------------------------------------------------------------------
1598 void wxAMMediaBackend::Move(int WXUNUSED(x
), int WXUNUSED(y
), int w
, int h
)
1600 if(m_hNotifyWnd
&& m_bVideo
)
1602 wxAMVERIFY( m_pVW
->SetWindowPosition(0, 0, w
, h
) );
1606 //---------------------------------------------------------------------------
1607 // End of wxAMMediaBackend
1608 //---------------------------------------------------------------------------
1610 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1612 // wxMCIMediaBackend
1614 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1617 IMPLEMENT_DYNAMIC_CLASS(wxMCIMediaBackend
, wxMediaBackend
);
1619 //---------------------------------------------------------------------------
1620 // Usual debugging macros for MCI returns
1621 //---------------------------------------------------------------------------
1624 #define wxMCIVERIFY(arg) \
1627 if ( (nRet = (arg)) != 0) \
1630 mciGetErrorString(nRet, sz, 5000); \
1631 wxFAIL_MSG(wxString::Format(_T("MCI Error:%s"), sz)); \
1635 #define wxMCIVERIFY(arg) (arg);
1638 //---------------------------------------------------------------------------
1639 // Simulation for <digitalv.h>
1641 // Mingw and possibly other compilers don't have the digitalv.h header
1642 // that is needed to have some essential features of mci work with
1643 // windows - so we provide the declarations for the types we use here
1644 //---------------------------------------------------------------------------
1647 DWORD_PTR dwCallback
;
1648 #ifdef MCI_USE_OFFEXT
1654 } MCI_DGV_RECT_PARMS
;
1657 DWORD_PTR dwCallback
;
1667 } MCI_DGV_WINDOW_PARMS
;
1670 DWORD_PTR dwCallback
;
1675 } MCI_DGV_SET_PARMS
;
1678 DWORD_PTR dwCallback
;
1682 wxChar
* lpstrAlgorithm
;
1683 wxChar
* lpstrQuality
;
1684 } MCI_DGV_SETAUDIO_PARMS
;
1686 //---------------------------------------------------------------------------
1687 // wxMCIMediaBackend Constructor
1689 // Here we don't need to do much except say we don't have any video :)
1690 //---------------------------------------------------------------------------
1691 wxMCIMediaBackend::wxMCIMediaBackend() : m_hNotifyWnd(NULL
), m_bVideo(false)
1695 //---------------------------------------------------------------------------
1696 // wxMCIMediaBackend Destructor
1698 // We close the mci device - note that there may not be an mci device here,
1699 // or it may fail - but we don't really care, since we're destructing
1700 //---------------------------------------------------------------------------
1701 wxMCIMediaBackend::~wxMCIMediaBackend()
1705 mciSendCommand(m_hDev
, MCI_CLOSE
, 0, 0);
1706 DestroyWindow(m_hNotifyWnd
);
1707 m_hNotifyWnd
= NULL
;
1711 //---------------------------------------------------------------------------
1712 // wxMCIMediaBackend::Create
1714 // Here we just tell wxMediaCtrl that mci does exist (which it does, on all
1715 // msw systems, at least in some form dating back to win16 days)
1716 //---------------------------------------------------------------------------
1717 bool wxMCIMediaBackend::CreateControl(wxControl
* ctrl
, wxWindow
* parent
,
1722 const wxValidator
& validator
,
1723 const wxString
& name
)
1727 // By default wxWindow(s) is created with a border -
1728 // so we need to get rid of those, and create with
1729 // wxCLIP_CHILDREN, so that if the driver/backend
1730 // is a child window, it refereshes properly
1732 if ( !ctrl
->wxControl::Create(parent
, id
, pos
, size
,
1733 (style
& ~wxBORDER_MASK
) | wxBORDER_NONE
| wxCLIP_CHILDREN
,
1741 //---------------------------------------------------------------------------
1742 // wxMCIMediaBackend::Load (file version)
1744 // Here we have MCI load a file and device, set the time format to our
1745 // default (milliseconds), and set the video (if any) to play in the control
1746 //---------------------------------------------------------------------------
1747 bool wxMCIMediaBackend::Load(const wxString
& fileName
)
1750 //if the user already called load close the previous MCI device
1754 mciSendCommand(m_hDev
, MCI_CLOSE
, 0, 0);
1755 DestroyWindow(m_hNotifyWnd
);
1756 m_hNotifyWnd
= NULL
;
1760 //Opens a file and has MCI select a device. Normally you'd put
1761 //MCI_OPEN_TYPE in addition to MCI_OPEN_ELEMENT - however if you
1762 //omit this it tells MCI to select the device instead. This is
1763 //good because we have no reliable way of "enumerating" the devices
1766 MCI_OPEN_PARMS openParms
;
1767 openParms
.lpstrElementName
= (wxChar
*) fileName
.c_str();
1769 if ( mciSendCommand(0, MCI_OPEN
, MCI_OPEN_ELEMENT
,
1770 (DWORD
)(LPVOID
)&openParms
) != 0)
1773 m_hDev
= openParms
.wDeviceID
;
1776 //Now set the time format for the device to milliseconds
1778 MCI_SET_PARMS setParms
;
1779 setParms
.dwCallback
= 0;
1780 setParms
.dwTimeFormat
= MCI_FORMAT_MILLISECONDS
;
1782 if (mciSendCommand(m_hDev
, MCI_SET
, MCI_SET_TIME_FORMAT
,
1783 (DWORD
)(LPVOID
)&setParms
) != 0)
1787 //Now tell the MCI device to display the video in our wxMediaCtrl
1789 MCI_DGV_WINDOW_PARMS windowParms
;
1790 windowParms
.hWnd
= (HWND
)m_ctrl
->GetHandle();
1792 m_bVideo
= (mciSendCommand(m_hDev
, MCI_WINDOW
,
1793 0x00010000L
, //MCI_DGV_WINDOW_HWND
1794 (DWORD
)(LPVOID
)&windowParms
) == 0);
1797 // Create a hidden window and register to handle
1799 // Note that wxCanvasClassName is already registered
1800 // and used by all wxWindows and normal wxControls
1802 m_hNotifyWnd
= ::CreateWindow
1816 wxLogSysError( wxT("Could not create hidden needed for ")
1817 wxT("registering for DirectShow events!") );
1822 wxSetWindowProc(m_hNotifyWnd
, wxMCIMediaBackend::NotifyWndProc
);
1824 ::SetWindowLong(m_hNotifyWnd
, GWL_USERDATA
,
1828 //Here, if the parent of the control has a sizer - we
1829 //tell it to recalculate the size of this control since
1830 //the user opened a seperate media file
1832 m_ctrl
->InvalidateBestSize();
1833 m_ctrl
->GetParent()->Layout();
1834 m_ctrl
->GetParent()->Refresh();
1835 m_ctrl
->GetParent()->Update();
1836 m_ctrl
->SetSize(m_ctrl
->GetSize());
1841 //---------------------------------------------------------------------------
1842 // wxMCIMediaBackend::Load (URL version)
1844 // MCI doesn't support URLs directly (?)
1846 // TODO: Use wxURL/wxFileSystem and mmioInstallProc
1847 //---------------------------------------------------------------------------
1848 bool wxMCIMediaBackend::Load(const wxURI
& WXUNUSED(location
))
1853 //---------------------------------------------------------------------------
1854 // wxMCIMediaBackend::Play
1856 // Plays/Resumes the MCI device... a couple notes:
1857 // 1) Certain drivers will crash and burn if we don't pass them an
1858 // MCI_PLAY_PARMS, despite the documentation that says otherwise...
1859 // 2) There is a MCI_RESUME command, but MCI_PLAY does the same thing
1860 // and will resume from a stopped state also, so there's no need to
1861 // call both, for example
1862 //---------------------------------------------------------------------------
1863 bool wxMCIMediaBackend::Play()
1865 MCI_PLAY_PARMS playParms
;
1866 playParms
.dwCallback
= (DWORD
)m_hNotifyWnd
;
1868 bool bOK
= ( mciSendCommand(m_hDev
, MCI_PLAY
, MCI_NOTIFY
,
1869 (DWORD
)(LPVOID
)&playParms
) == 0 );
1872 m_ctrl
->Show(m_bVideo
);
1877 //---------------------------------------------------------------------------
1878 // wxMCIMediaBackend::Pause
1880 // Pauses the MCI device - nothing special
1881 //---------------------------------------------------------------------------
1882 bool wxMCIMediaBackend::Pause()
1884 return (mciSendCommand(m_hDev
, MCI_PAUSE
, MCI_WAIT
, 0) == 0);
1887 //---------------------------------------------------------------------------
1888 // wxMCIMediaBackend::Stop
1890 // Stops the MCI device & seeks to the beginning as wxMediaCtrl docs outline
1891 //---------------------------------------------------------------------------
1892 bool wxMCIMediaBackend::Stop()
1894 return (mciSendCommand(m_hDev
, MCI_STOP
, MCI_WAIT
, 0) == 0) &&
1895 (mciSendCommand(m_hDev
, MCI_SEEK
, MCI_SEEK_TO_START
, 0) == 0);
1898 //---------------------------------------------------------------------------
1899 // wxMCIMediaBackend::GetState
1901 // Here we get the state and convert it to a wxMediaState -
1902 // since we use direct comparisons with MCI_MODE_PLAY and
1903 // MCI_MODE_PAUSE, we don't care if the MCI_STATUS call
1905 //---------------------------------------------------------------------------
1906 wxMediaState
wxMCIMediaBackend::GetState()
1908 MCI_STATUS_PARMS statusParms
;
1909 statusParms
.dwItem
= MCI_STATUS_MODE
;
1911 mciSendCommand(m_hDev
, MCI_STATUS
, MCI_STATUS_ITEM
,
1912 (DWORD
)(LPVOID
)&statusParms
);
1914 if(statusParms
.dwReturn
== MCI_MODE_PAUSE
)
1915 return wxMEDIASTATE_PAUSED
;
1916 else if(statusParms
.dwReturn
== MCI_MODE_PLAY
)
1917 return wxMEDIASTATE_PLAYING
;
1919 return wxMEDIASTATE_STOPPED
;
1922 //---------------------------------------------------------------------------
1923 // wxMCIMediaBackend::SetPosition
1925 // Here we set the position of the device in the stream.
1926 // Note that MCI actually stops the device after you seek it if the
1927 // device is playing/paused, so we need to play the file after
1928 // MCI seeks like normal APIs would
1929 //---------------------------------------------------------------------------
1930 bool wxMCIMediaBackend::SetPosition(wxLongLong where
)
1932 MCI_SEEK_PARMS seekParms
;
1933 seekParms
.dwCallback
= 0;
1934 #if wxUSE_LONGLONG_NATIVE && !wxUSE_LONGLONG_WX
1935 seekParms
.dwTo
= (DWORD
)where
.GetValue();
1936 #else /* wxUSE_LONGLONG_WX */
1937 /* no way to return it in one piece */
1938 wxASSERT( where
.GetHi()==0 );
1939 seekParms
.dwTo
= (DWORD
)where
.GetLo();
1940 #endif /* wxUSE_LONGLONG_* */
1942 //device was playing?
1943 bool bReplay
= GetState() == wxMEDIASTATE_PLAYING
;
1945 if( mciSendCommand(m_hDev
, MCI_SEEK
, MCI_TO
,
1946 (DWORD
)(LPVOID
)&seekParms
) != 0)
1949 //If the device was playing, resume it
1956 //---------------------------------------------------------------------------
1957 // wxMCIMediaBackend::GetPosition
1959 // Gets the position of the device in the stream using the current
1960 // time format... nothing special here...
1961 //---------------------------------------------------------------------------
1962 wxLongLong
wxMCIMediaBackend::GetPosition()
1964 MCI_STATUS_PARMS statusParms
;
1965 statusParms
.dwItem
= MCI_STATUS_POSITION
;
1967 if (mciSendCommand(m_hDev
, MCI_STATUS
, MCI_STATUS_ITEM
,
1968 (DWORD
)(LPSTR
)&statusParms
) != 0)
1971 return statusParms
.dwReturn
;
1974 //---------------------------------------------------------------------------
1975 // wxMCIMediaBackend::GetVolume
1977 // Gets the volume of the current media via the MCI_DGV_STATUS_VOLUME
1978 // message. Value ranges from 0 (minimum) to 1000 (maximum volume).
1979 //---------------------------------------------------------------------------
1980 double wxMCIMediaBackend::GetVolume()
1982 MCI_STATUS_PARMS statusParms
;
1983 statusParms
.dwCallback
= 0;
1984 statusParms
.dwItem
= 0x4019; //MCI_DGV_STATUS_VOLUME
1986 if (mciSendCommand(m_hDev
, MCI_STATUS
, MCI_STATUS_ITEM
,
1987 (DWORD
)(LPSTR
)&statusParms
) != 0)
1990 return ((double)statusParms
.dwReturn
) / 1000.0;
1993 //---------------------------------------------------------------------------
1994 // wxMCIMediaBackend::SetVolume
1996 // Sets the volume of the current media via the MCI_DGV_SETAUDIO_VOLUME
1997 // message. Value ranges from 0 (minimum) to 1000 (maximum volume).
1998 //---------------------------------------------------------------------------
1999 bool wxMCIMediaBackend::SetVolume(double dVolume
)
2001 MCI_DGV_SETAUDIO_PARMS audioParms
;
2002 audioParms
.dwCallback
= 0;
2003 audioParms
.dwItem
= 0x4002; //MCI_DGV_SETAUDIO_VOLUME
2004 audioParms
.dwValue
= (DWORD
) (dVolume
* 1000.0);
2005 audioParms
.dwOver
= 0;
2006 audioParms
.lpstrAlgorithm
= NULL
;
2007 audioParms
.lpstrQuality
= NULL
;
2009 if (mciSendCommand(m_hDev
, 0x0873, //MCI_SETAUDIO
2010 0x00800000L
| 0x01000000L
, //MCI_DGV_SETAUDIO+(_ITEM | _VALUE)
2011 (DWORD
)(LPSTR
)&audioParms
) != 0)
2016 //---------------------------------------------------------------------------
2017 // wxMCIMediaBackend::GetDuration
2019 // Gets the duration of the stream... nothing special
2020 //---------------------------------------------------------------------------
2021 wxLongLong
wxMCIMediaBackend::GetDuration()
2023 MCI_STATUS_PARMS statusParms
;
2024 statusParms
.dwItem
= MCI_STATUS_LENGTH
;
2026 if (mciSendCommand(m_hDev
, MCI_STATUS
, MCI_STATUS_ITEM
,
2027 (DWORD
)(LPSTR
)&statusParms
) != 0)
2030 return statusParms
.dwReturn
;
2033 //---------------------------------------------------------------------------
2034 // wxMCIMediaBackend::Move
2036 // Moves the window to a location
2037 //---------------------------------------------------------------------------
2038 void wxMCIMediaBackend::Move(int WXUNUSED(x
), int WXUNUSED(y
),
2041 if (m_hNotifyWnd
&& m_bVideo
)
2043 MCI_DGV_RECT_PARMS putParms
; //ifdefed MCI_DGV_PUT_PARMS
2044 memset(&putParms
, 0, sizeof(MCI_DGV_RECT_PARMS
));
2045 putParms
.rc
.bottom
= h
;
2046 putParms
.rc
.right
= w
;
2048 //wxStackWalker will crash and burn here on assert
2049 //and mci doesn't like 0 and 0 for some reason (out of range )
2050 //so just don't it in that case
2053 wxMCIVERIFY( mciSendCommand(m_hDev
, MCI_PUT
,
2054 0x00040000L
, //MCI_DGV_PUT_DESTINATION
2055 (DWORD
)(LPSTR
)&putParms
) );
2060 //---------------------------------------------------------------------------
2061 // wxMCIMediaBackend::GetVideoSize
2063 // Gets the original size of the movie for sizers
2064 //---------------------------------------------------------------------------
2065 wxSize
wxMCIMediaBackend::GetVideoSize() const
2069 MCI_DGV_RECT_PARMS whereParms
; //ifdefed MCI_DGV_WHERE_PARMS
2071 wxMCIVERIFY( mciSendCommand(m_hDev
, MCI_WHERE
,
2072 0x00020000L
, //MCI_DGV_WHERE_SOURCE
2073 (DWORD
)(LPSTR
)&whereParms
) );
2075 return wxSize(whereParms
.rc
.right
, whereParms
.rc
.bottom
);
2080 //---------------------------------------------------------------------------
2081 // wxMCIMediaBackend::GetPlaybackRate
2084 //---------------------------------------------------------------------------
2085 double wxMCIMediaBackend::GetPlaybackRate()
2090 //---------------------------------------------------------------------------
2091 // wxMCIMediaBackend::SetPlaybackRate
2094 //---------------------------------------------------------------------------
2095 bool wxMCIMediaBackend::SetPlaybackRate(double WXUNUSED(dRate
))
2098 MCI_WAVE_SET_SAMPLESPERSEC
2099 MCI_DGV_SET_PARMS setParms;
2100 setParms.dwSpeed = (DWORD) (dRate * 1000.0);
2102 return (mciSendCommand(m_hDev, MCI_SET,
2103 0x00020000L, //MCI_DGV_SET_SPEED
2104 (DWORD)(LPSTR)&setParms) == 0);
2109 //---------------------------------------------------------------------------
2110 // [static] wxMCIMediaBackend::MSWWindowProc
2112 // Here we process a message when MCI reaches the stopping point
2114 //---------------------------------------------------------------------------
2115 LRESULT CALLBACK
wxMCIMediaBackend::NotifyWndProc(HWND hWnd
, UINT nMsg
,
2119 wxMCIMediaBackend
* backend
= (wxMCIMediaBackend
*)
2121 ::GetWindowLong(hWnd
, GWL_USERDATA
);
2123 ::GetWindowLongPtr(hWnd
, GWLP_USERDATA
);
2127 return backend
->OnNotifyWndProc(hWnd
, nMsg
, wParam
, lParam
);
2130 LRESULT CALLBACK
wxMCIMediaBackend::OnNotifyWndProc(HWND hWnd
, UINT nMsg
,
2134 if(nMsg
== MM_MCINOTIFY
)
2136 wxASSERT(lParam
== (LPARAM
) m_hDev
);
2137 if(wParam
== MCI_NOTIFY_SUCCESSFUL
&& lParam
== (LPARAM
)m_hDev
)
2139 wxMediaEvent
theEvent(wxEVT_MEDIA_STOP
, m_ctrl
->GetId());
2140 m_ctrl
->ProcessEvent(theEvent
);
2142 if(theEvent
.IsAllowed())
2144 wxMCIVERIFY( mciSendCommand(m_hDev
, MCI_SEEK
,
2145 MCI_SEEK_TO_START
, 0) );
2147 //send the event to our child
2148 wxMediaEvent
theEvent(wxEVT_MEDIA_FINISHED
,
2150 m_ctrl
->ProcessEvent(theEvent
);
2154 return DefWindowProc(hWnd
, nMsg
, wParam
, lParam
);
2156 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2160 // TODO: Use a less cludgy way to pause/get state/set state
2161 // TODO: Dynamically load from qtml.dll
2162 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2164 IMPLEMENT_DYNAMIC_CLASS(wxQTMediaBackend
, wxMediaBackend
);
2166 //Time between timer calls
2167 #define MOVIE_DELAY 100
2169 #include "wx/timer.h"
2171 // --------------------------------------------------------------------------
2172 // wxQTTimer - Handle Asyncronous Playing
2173 // --------------------------------------------------------------------------
2174 class _wxQTTimer
: public wxTimer
2177 _wxQTTimer(Movie movie
, wxQTMediaBackend
* parent
, wxQuickTimeLibrary
* pLib
) :
2178 m_movie(movie
), m_bPaused(false), m_parent(parent
), m_pLib(pLib
)
2186 bool GetPaused() {return m_bPaused
;}
2187 void SetPaused(bool bPaused
) {m_bPaused
= bPaused
;}
2189 //-----------------------------------------------------------------------
2190 // _wxQTTimer::Notify
2192 // 1) Checks to see if the movie is done, and if not continues
2193 // streaming the movie
2194 // 2) Sends the wxEVT_MEDIA_STOP event if we have reached the end of
2196 //-----------------------------------------------------------------------
2201 if(!m_pLib
->IsMovieDone(m_movie
))
2202 m_pLib
->MoviesTask(m_movie
, MOVIE_DELAY
);
2205 wxMediaEvent
theEvent(wxEVT_MEDIA_STOP
,
2206 m_parent
->m_ctrl
->GetId());
2207 m_parent
->m_ctrl
->ProcessEvent(theEvent
);
2209 if(theEvent
.IsAllowed())
2213 wxASSERT(m_pLib
->GetMoviesError() == noErr
);
2215 //send the event to our child
2216 wxMediaEvent
theEvent(wxEVT_MEDIA_FINISHED
,
2217 m_parent
->m_ctrl
->GetId());
2218 m_parent
->m_ctrl
->ProcessEvent(theEvent
);
2225 Movie m_movie
; //Our movie instance
2226 bool m_bPaused
; //Whether we are paused or not
2227 wxQTMediaBackend
* m_parent
; //Backend pointer
2228 wxQuickTimeLibrary
* m_pLib
; //Interfaces
2231 //---------------------------------------------------------------------------
2232 // wxQTMediaBackend Destructor
2234 // Sets m_timer to NULL signifying we havn't loaded anything yet
2235 //---------------------------------------------------------------------------
2236 wxQTMediaBackend::wxQTMediaBackend() : m_timer(NULL
)
2240 //---------------------------------------------------------------------------
2241 // wxQTMediaBackend Destructor
2243 // 1) Cleans up the QuickTime movie instance
2244 // 2) Decrements the QuickTime reference counter - if this reaches
2245 // 0, QuickTime shuts down
2246 // 3) Decrements the QuickTime Windows Media Layer reference counter -
2247 // if this reaches 0, QuickTime shuts down the Windows Media Layer
2248 //---------------------------------------------------------------------------
2249 wxQTMediaBackend::~wxQTMediaBackend()
2256 //Note that ExitMovies() is not neccessary, but
2257 //the docs are fuzzy on whether or not TerminateQTML is
2259 m_lib
.TerminateQTML();
2263 //---------------------------------------------------------------------------
2264 // wxQTMediaBackend::CreateControl
2266 // 1) Intializes QuickTime
2267 // 2) Creates the control window
2268 //---------------------------------------------------------------------------
2269 bool wxQTMediaBackend::CreateControl(wxControl
* ctrl
, wxWindow
* parent
,
2274 const wxValidator
& validator
,
2275 const wxString
& name
)
2277 if(!m_lib
.Initialize())
2280 int nError
= m_lib
.InitializeQTML(0);
2281 if (nError
!= noErr
) //-2093 no dll
2283 wxFAIL_MSG(wxString::Format(wxT("Couldn't Initialize Quicktime-%i"), nError
));
2286 m_lib
.EnterMovies();
2290 // By default wxWindow(s) is created with a border -
2291 // so we need to get rid of those
2293 // Since we don't have a child window like most other
2294 // backends, we don't need wxCLIP_CHILDREN
2296 if ( !ctrl
->wxControl::Create(parent
, id
, pos
, size
,
2297 (style
& ~wxBORDER_MASK
) | wxBORDER_NONE
,
2305 //---------------------------------------------------------------------------
2306 // wxQTMediaBackend::Load (file version)
2308 // 1) Get an FSSpec from the Windows path name
2309 // 2) Open the movie
2310 // 3) Obtain the movie instance from the movie resource
2312 //---------------------------------------------------------------------------
2313 bool wxQTMediaBackend::Load(const wxString
& fileName
)
2321 if (m_lib
.NativePathNameToFSSpec ((char*) (const char*) fileName
.mb_str(),
2322 &sfFile
, 0) != noErr
)
2325 if (m_lib
.OpenMovieFile (&sfFile
, &movieResFile
, fsRdPerm
) != noErr
)
2328 short movieResID
= 0;
2331 OSErr err
= m_lib
.NewMovieFromFile (
2340 m_lib
.CloseMovieFile (movieResFile
);
2347 return m_lib
.GetMoviesError() == noErr
;
2350 //---------------------------------------------------------------------------
2351 // wxQTMediaBackend::Move
2354 //---------------------------------------------------------------------------
2355 bool wxQTMediaBackend::Load(const wxURI
& location
)
2360 wxString theURI
= location
.BuildURI();
2362 Handle theHandle
= m_lib
.NewHandleClear(theURI
.length() + 1);
2363 wxASSERT(theHandle
);
2365 m_lib
.BlockMove(theURI
.mb_str(), *theHandle
, theURI
.length() + 1);
2367 //create the movie from the handle that refers to the URI
2368 OSErr err
= m_lib
.NewMovieFromDataRef(&m_movie
, newMovieActive
,
2370 'url'); //URLDataHandlerSubType
2372 m_lib
.DisposeHandle(theHandle
);
2377 //preroll movie for streaming
2382 timeNow = GetMovieTime(m_movie, NULL);
2383 playRate = GetMoviePreferredRate(m_movie);
2384 PrePrerollMovie(m_movie, timeNow, playRate, NULL, NULL);
2385 PrerollMovie(m_movie, timeNow, playRate);
2386 m_lib.SetMovieRate(m_movie, playRate);
2391 return m_lib
.GetMoviesError() == noErr
;
2394 //---------------------------------------------------------------------------
2395 // wxQTMediaBackend::Move
2398 //---------------------------------------------------------------------------
2399 void wxQTMediaBackend::FinishLoad()
2401 m_timer
= new _wxQTTimer(m_movie
, (wxQTMediaBackend
*) this, &m_lib
);
2404 //get the real size of the movie
2406 m_lib
.GetMovieNaturalBoundsRect (m_movie
, &outRect
);
2407 wxASSERT(m_lib
.GetMoviesError() == noErr
);
2409 m_bestSize
.x
= outRect
.right
- outRect
.left
;
2410 m_bestSize
.y
= outRect
.bottom
- outRect
.top
;
2412 //reparent movie/*AudioMediaCharacteristic*/
2413 if(m_lib
.GetMovieIndTrackType(m_movie
, 1,
2414 'eyes', //VisualMediaCharacteristic,
2415 (1 << 1) //movieTrackCharacteristic
2416 | (1 << 2) //movieTrackEnabledOnly
2419 m_lib
.CreatePortAssociation(m_ctrl
->GetHWND(), NULL
, 0L);
2421 m_lib
.SetMovieGWorld(m_movie
,
2422 (CGrafPtr
) m_lib
.GetNativeWindowPort(m_ctrl
->GetHWND()),
2426 //we want millisecond precision
2427 m_lib
.SetMovieTimeScale(m_movie
, 1000);
2428 wxASSERT(m_lib
.GetMoviesError() == noErr
);
2431 //Here, if the parent of the control has a sizer - we
2432 //tell it to recalculate the size of this control since
2433 //the user opened a seperate media file
2435 m_ctrl
->InvalidateBestSize();
2436 m_ctrl
->GetParent()->Layout();
2437 m_ctrl
->GetParent()->Refresh();
2438 m_ctrl
->GetParent()->Update();
2441 //---------------------------------------------------------------------------
2442 // wxQTMediaBackend::Move
2445 //---------------------------------------------------------------------------
2446 bool wxQTMediaBackend::Play()
2448 m_lib
.StartMovie(m_movie
);
2449 m_timer
->SetPaused(false);
2450 m_timer
->Start(MOVIE_DELAY
, wxTIMER_CONTINUOUS
);
2451 return m_lib
.GetMoviesError() == noErr
;
2454 //---------------------------------------------------------------------------
2455 // wxQTMediaBackend::Move
2458 //---------------------------------------------------------------------------
2459 bool wxQTMediaBackend::Pause()
2461 m_lib
.StopMovie(m_movie
);
2462 m_timer
->SetPaused(true);
2464 return m_lib
.GetMoviesError() == noErr
;
2467 //---------------------------------------------------------------------------
2468 // wxQTMediaBackend::Move
2471 //---------------------------------------------------------------------------
2472 bool wxQTMediaBackend::Stop()
2474 m_timer
->SetPaused(false);
2477 m_lib
.StopMovie(m_movie
);
2478 if(m_lib
.GetMoviesError() != noErr
)
2481 m_lib
.GoToBeginningOfMovie(m_movie
);
2482 return m_lib
.GetMoviesError() == noErr
;
2485 //---------------------------------------------------------------------------
2486 // wxQTMediaBackend::Move
2489 //---------------------------------------------------------------------------
2490 double wxQTMediaBackend::GetPlaybackRate()
2492 return ( ((double)m_lib
.GetMovieRate(m_movie
)) / 0x10000);
2495 //---------------------------------------------------------------------------
2496 // wxQTMediaBackend::Move
2499 //---------------------------------------------------------------------------
2500 bool wxQTMediaBackend::SetPlaybackRate(double dRate
)
2502 m_lib
.SetMovieRate(m_movie
, (Fixed
) (dRate
* 0x10000));
2503 return m_lib
.GetMoviesError() == noErr
;
2506 //---------------------------------------------------------------------------
2507 // wxQTMediaBackend::Move
2510 //---------------------------------------------------------------------------
2511 bool wxQTMediaBackend::SetPosition(wxLongLong where
)
2513 TimeRecord theTimeRecord
;
2514 memset(&theTimeRecord
, 0, sizeof(TimeRecord
));
2515 theTimeRecord
.value
.lo
= where
.GetLo();
2516 theTimeRecord
.scale
= m_lib
.GetMovieTimeScale(m_movie
);
2517 theTimeRecord
.base
= m_lib
.GetMovieTimeBase(m_movie
);
2518 m_lib
.SetMovieTime(m_movie
, &theTimeRecord
);
2520 if (m_lib
.GetMoviesError() != noErr
)
2526 //---------------------------------------------------------------------------
2527 // wxQTMediaBackend::GetPosition
2529 // 1) Calls GetMovieTime to get the position we are in in the movie
2530 // in milliseconds (we called
2531 //---------------------------------------------------------------------------
2532 wxLongLong
wxQTMediaBackend::GetPosition()
2534 return m_lib
.GetMovieTime(m_movie
, NULL
);
2537 //---------------------------------------------------------------------------
2538 // wxQTMediaBackend::GetVolume
2540 // Gets the volume through GetMovieVolume - which returns a 16 bit short -
2542 // +--------+--------+
2544 // +--------+--------+
2546 // (1) first 8 bits are value before decimal
2547 // (2) second 8 bits are value after decimal
2549 // Volume ranges from -1.0 (gain but no sound), 0 (no sound and no gain) to
2550 // 1 (full gain and sound)
2551 //---------------------------------------------------------------------------
2552 double wxQTMediaBackend::GetVolume()
2554 short sVolume
= m_lib
.GetMovieVolume(m_movie
);
2556 if(sVolume
& (128 << 8)) //negative - no sound
2559 return (sVolume
& (127 << 8)) ? 1.0 : ((double)(sVolume
& 255)) / 255.0;
2562 //---------------------------------------------------------------------------
2563 // wxQTMediaBackend::SetVolume
2565 // Sets the volume through SetMovieVolume - which takes a 16 bit short -
2567 // +--------+--------+
2569 // +--------+--------+
2571 // (1) first 8 bits are value before decimal
2572 // (2) second 8 bits are value after decimal
2574 // Volume ranges from -1.0 (gain but no sound), 0 (no sound and no gain) to
2575 // 1 (full gain and sound)
2576 //---------------------------------------------------------------------------
2577 bool wxQTMediaBackend::SetVolume(double dVolume
)
2579 short sVolume
= (short) (dVolume
>= .9999 ? 1 << 8 : (dVolume
* 255) );
2580 m_lib
.SetMovieVolume(m_movie
, sVolume
);
2584 //---------------------------------------------------------------------------
2585 // wxQTMediaBackend::Move
2588 //---------------------------------------------------------------------------
2589 wxLongLong
wxQTMediaBackend::GetDuration()
2591 return m_lib
.GetMovieDuration(m_movie
);
2594 //---------------------------------------------------------------------------
2595 // wxQTMediaBackend::Move
2598 //---------------------------------------------------------------------------
2599 wxMediaState
wxQTMediaBackend::GetState()
2601 if ( !m_timer
|| (m_timer
->IsRunning() == false &&
2602 m_timer
->GetPaused() == false) )
2603 return wxMEDIASTATE_STOPPED
;
2605 if( m_timer
->IsRunning() == true )
2606 return wxMEDIASTATE_PLAYING
;
2608 return wxMEDIASTATE_PAUSED
;
2611 //---------------------------------------------------------------------------
2612 // wxQTMediaBackend::Move
2615 //---------------------------------------------------------------------------
2616 void wxQTMediaBackend::Cleanup()
2621 m_lib
.StopMovie(m_movie
);
2622 m_lib
.DisposeMovie(m_movie
);
2625 //---------------------------------------------------------------------------
2626 // wxQTMediaBackend::Move
2629 //---------------------------------------------------------------------------
2630 wxSize
wxQTMediaBackend::GetVideoSize() const
2635 //---------------------------------------------------------------------------
2636 // wxQTMediaBackend::Move
2639 //---------------------------------------------------------------------------
2640 void wxQTMediaBackend::Move(int WXUNUSED(x
), int WXUNUSED(y
), int w
, int h
)
2644 Rect theRect
= {0, 0, (short)h
, (short)w
};
2646 m_lib
.SetMovieBox(m_movie
, &theRect
);
2647 wxASSERT(m_lib
.GetMoviesError() == noErr
);
2651 //---------------------------------------------------------------------------
2653 //---------------------------------------------------------------------------
2655 //in source file that contains stuff you don't directly use
2656 #include <wx/html/forcelnk.h>
2657 FORCE_LINK_ME(basewxmediabackends
);
2659 //---------------------------------------------------------------------------
2660 // End wxMediaCtrl Compilation Guard and this file
2661 //---------------------------------------------------------------------------
2662 #endif //wxUSE_MEDIACTRL