]> git.saurik.com Git - wxWidgets.git/blob - src/msw/mediactrl.cpp
wxDC::Clear() shouldn't do anything in printing DCs (I think)
[wxWidgets.git] / src / msw / mediactrl.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/msw/mediactrl.cpp
3 // Purpose: Built-in Media Backends for Windows
4 // Author: Ryan Norton <wxprojects@comcast.net>
5 // Modified by:
6 // Created: 11/07/04
7 // RCS-ID: $Id$
8 // Copyright: (c) Ryan Norton
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 // FIXME FIXME FIXME:
13 // extract different backends in different files (better yet, make backends
14 // dynamically loadable...), they have nothing to do with each other and this
15 // file is huge and also separate the standard contents from our code itself
16
17
18 //===========================================================================
19 // DECLARATIONS
20 //===========================================================================
21
22 //---------------------------------------------------------------------------
23 // Pre-compiled header stuff
24 //---------------------------------------------------------------------------
25
26 // For compilers that support precompilation, includes "wx.h".
27 #include "wx/wxprec.h"
28
29 #ifdef __BORLANDC__
30 #pragma hdrstop
31 #endif
32
33 #if wxUSE_MEDIACTRL
34
35 #include "wx/mediactrl.h"
36
37 #ifndef WX_PRECOMP
38 #include "wx/log.h"
39 #include "wx/dcclient.h"
40 #include "wx/timer.h"
41 #include "wx/math.h" // log10 & pow
42 #endif
43
44 #include "wx/msw/private.h" // user info and wndproc setting/getting
45 #include "wx/dynlib.h"
46
47 //---------------------------------------------------------------------------
48 // Externals (somewhere in src/msw/app.cpp and src/msw/window.cpp)
49 //---------------------------------------------------------------------------
50 extern "C" WXDLLIMPEXP_BASE HINSTANCE wxGetInstance(void);
51 #ifdef __WXWINCE__
52 extern WXDLLIMPEXP_CORE wxChar *wxCanvasClassName;
53 #else
54 extern WXDLLIMPEXP_CORE const wxChar *wxCanvasClassName;
55 #endif
56
57 LRESULT WXDLLIMPEXP_CORE APIENTRY _EXPORT wxWndProc(HWND hWnd, UINT message,
58 WPARAM wParam, LPARAM lParam);
59
60 //---------------------------------------------------------------------------
61 // Killed MSVC warnings
62 //---------------------------------------------------------------------------
63 //disable "cast truncates constant value" for VARIANT_BOOL values
64 //passed as parameters in VC5 and up
65 #ifdef _MSC_VER
66 #pragma warning (disable:4310)
67 #endif
68
69 //===========================================================================
70 // BACKEND DECLARATIONS
71 //===========================================================================
72
73 //---------------------------------------------------------------------------
74 // wxAMMediaBackend
75 //---------------------------------------------------------------------------
76
77 //---------------------------------------------------------------------------
78 // wxActiveXContainer - includes all the COM-specific stuff we need
79 //---------------------------------------------------------------------------
80 #include "wx/msw/ole/activex.h"
81
82 //---------------------------------------------------------------------------
83 // IIDS - used by CoCreateInstance and IUnknown::QueryInterface
84 //
85 // [idl name] [idl decription]
86 // amcompat.idl Microsoft Active Movie Control (Ver 2.0)
87 // nscompat.idl Microsoft NetShow Player (Ver 1.0)
88 // msdxm.idl Windows Media Player (Ver 1.0)
89 // quartz.idl
90 //
91 // First, when I say I "from XXX.idl", I mean I go into the COM Browser
92 // ($Microsoft Visual Studio$/Common/Tools/OLEVIEW.EXE), open
93 // "type libraries", open a specific type library (for quartz for example its
94 // "ActiveMovie control type library (V1.0)"), save it as an .idl, compile the
95 // idl using the midl compiler that comes with visual studio
96 // ($Microsoft Visual Studio$/VC98/bin/midl.exe on VC6) with the /h argument
97 // to make it generate stubs (a .h & .c file), then clean up the generated
98 // interfaces I want with the STDMETHOD wrappers and then put them into
99 // mediactrl.cpp.
100 //
101 // According to the MSDN docs, IMediaPlayer requires Windows 98 SE
102 // or greater. NetShow is available on Windows 3.1 and I'm guessing
103 // IActiveMovie is too. IMediaPlayer is essentially the Windows Media
104 // Player 6.4 SDK.
105 //
106 // IWMP is from PlayerOCX.idl on PocketPC 2000, which uses CLSID_MediaPlayer
107 // as well as the main windows line.
108 //
109 // Some of these are not used but are kept here for future reference anyway
110 //---------------------------------------------------------------------------
111 const IID IID_IActiveMovie = {0x05589FA2,0xC356,0x11CE,{0xBF,0x01,0x00,0xAA,0x00,0x55,0x59,0x5A}};
112 const IID IID_IActiveMovie2 = {0xB6CD6554,0xE9CB,0x11D0,{0x82,0x1F,0x00,0xA0,0xC9,0x1F,0x9C,0xA0}};
113 const IID IID_IActiveMovie3 = {0x265EC140,0xAE62,0x11D1,{0x85,0x00,0x00,0xA0,0xC9,0x1F,0x9C,0xA0}};
114
115 const IID IID_INSOPlay = {0x2179C5D1,0xEBFF,0x11CF,{0xB6,0xFD,0x00,0xAA,0x00,0xB4,0xE2,0x20}};
116 const IID IID_INSPlay = {0xE7C4BE80,0x7960,0x11D0,{0xB7,0x27,0x00,0xAA,0x00,0xB4,0xE2,0x20}};
117 const IID IID_INSPlay1 = {0x265EC141,0xAE62,0x11D1,{0x85,0x00,0x00,0xA0,0xC9,0x1F,0x9C,0xA0}};
118
119 const IID IID_IMediaPlayer = {0x22D6F311,0xB0F6,0x11D0,{0x94,0xAB,0x00,0x80,0xC7,0x4C,0x7E,0x95}};
120 const IID IID_IMediaPlayer2 = {0x20D4F5E0,0x5475,0x11D2,{0x97,0x74,0x00,0x00,0xF8,0x08,0x55,0xE6}};
121
122 const IID IID_IWMP = {0x136B66EC,0xF30D,0x46A8,{0x88,0xDD,0xF2,0xD0,0x55,0x16,0x3E,0x49}};
123
124 const CLSID CLSID_ActiveMovie = {0x05589FA1,0xC356,0x11CE,{0xBF,0x01,0x00,0xAA,0x00,0x55,0x59,0x5A}};
125 const CLSID CLSID_MediaPlayer = {0x22D6F312,0xB0F6,0x11D0,{0x94,0xAB,0x00,0x80,0xC7,0x4C,0x7E,0x95}};
126 const CLSID CLSID_NSPlay = {0x2179C5D3,0xEBFF,0x11CF,{0xB6,0xFD,0x00,0xAA,0x00,0xB4,0xE2,0x20}};
127
128 const IID IID_IAMOpenProgress = {0x8E1C39A1, 0xDE53, 0x11CF,{0xAA, 0x63, 0x00, 0x80, 0xC7, 0x44, 0x52, 0x8D}};
129
130 // QUARTZ
131 const CLSID CLSID_FilgraphManager = {0xE436EBB3,0x524F,0x11CE,{0x9F,0x53,0x00,0x20,0xAF,0x0B,0xA7,0x70}};
132 const IID IID_IMediaEvent = {0x56A868B6,0x0AD4,0x11CE,{0xB0,0x3A,0x00,0x20,0xAF,0x0B,0xA7,0x70}};
133
134 //?? QUARTZ Also?
135 const CLSID CLSID_VideoMixingRenderer9 ={0x51B4ABF3, 0x748F, 0x4E3B,{0xA2, 0x76, 0xC8, 0x28, 0x33, 0x0E, 0x92, 0x6A}};
136 const IID IID_IVMRWindowlessControl9 = {0x8F537D09, 0xF85E, 0x4414,{0xB2, 0x3B, 0x50, 0x2E, 0x54, 0xC7, 0x99, 0x27}};
137 const IID IID_IFilterGraph = {0x56A8689F, 0x0AD4, 0x11CE,{0xB0, 0x3A, 0x00, 0x20, 0xAF, 0x0B, 0xA7, 0x70}};
138 const IID IID_IGraphBuilder = {0x56A868A9, 0x0AD4, 0x11CE,{0xB0, 0x3A, 0x00, 0x20, 0xAF, 0x0B, 0xA7, 0x70}};
139 const IID IID_IVMRFilterConfig9 = {0x5A804648, 0x4F66, 0x4867,{0x9C, 0x43, 0x4F, 0x5C, 0x82, 0x2C, 0xF1, 0xB8}};
140 const IID IID_IBaseFilter = {0x56A86895, 0x0AD4, 0x11CE,{0xB0, 0x3A, 0x00, 0x20, 0xAF, 0x0B, 0xA7, 0x70}};
141
142 //---------------------------------------------------------------------------
143 // QUARTZ COM INTERFACES (dumped from quartz.idl from MSVC COM Browser)
144 //---------------------------------------------------------------------------
145
146 struct IAMOpenProgress : public IUnknown
147 {
148 STDMETHOD(QueryProgress)(LONGLONG *pllTotal, LONGLONG *pllCurrent) PURE;
149 STDMETHOD(AbortOperation)(void) PURE;
150 };
151
152 struct IMediaEvent : public IDispatch
153 {
154 STDMETHOD(GetEventHandle)(LONG_PTR *) PURE;
155 STDMETHOD(GetEvent)(long *, LONG_PTR *, LONG_PTR *, long) PURE;
156 STDMETHOD(WaitForCompletion)(long, long *) PURE;
157 STDMETHOD(CancelDefaultHandling)(long) PURE;
158 STDMETHOD(RestoreDefaultHandling)(long) PURE;
159 STDMETHOD(FreeEventParams)(long, LONG_PTR, LONG_PTR) PURE;
160 };
161
162 //---------------------------------------------------------------------------
163 // ACTIVEMOVIE COM INTERFACES (dumped from amcompat.idl from MSVC COM Browser)
164 //---------------------------------------------------------------------------
165
166 enum ReadyStateConstants
167 {
168 amvUninitialized = 0,
169 amvLoading = 1,
170 amvInteractive = 3,
171 amvComplete = 4
172 };
173
174 enum StateConstants
175 {
176 amvNotLoaded = -1,
177 amvStopped = 0,
178 amvPaused = 1,
179 amvRunning = 2
180 };
181
182 enum DisplayModeConstants
183 {
184 amvTime = 0,
185 amvFrames = 1
186 };
187
188 enum WindowSizeConstants
189 {
190 amvOriginalSize = 0,
191 amvDoubleOriginalSize = 1,
192 amvOneSixteenthScreen = 2,
193 amvOneFourthScreen = 3,
194 amvOneHalfScreen = 4
195 };
196
197 enum AppearanceConstants
198 {
199 amvFlat = 0,
200 amv3D = 1
201 };
202
203 enum BorderStyleConstants
204 {
205 amvNone = 0,
206 amvFixedSingle = 1
207 };
208
209 struct IActiveMovie : public IDispatch
210 {
211 STDMETHOD(AboutBox)( void) PURE;
212 STDMETHOD(Run)( void) PURE;
213 STDMETHOD(Pause)( void) PURE;
214 STDMETHOD(Stop)( void) PURE;
215 STDMETHOD(get_ImageSourceWidth)(long __RPC_FAR *pWidth) PURE;
216 STDMETHOD(get_ImageSourceHeight)(long __RPC_FAR *pHeight) PURE;
217 STDMETHOD(get_Author)(BSTR __RPC_FAR *pbstrAuthor) PURE;
218 STDMETHOD(get_Title)(BSTR __RPC_FAR *pbstrTitle) PURE;
219 STDMETHOD(get_Copyright)(BSTR __RPC_FAR *pbstrCopyright) PURE;
220 STDMETHOD(get_Description)(BSTR __RPC_FAR *pbstrDescription) PURE;
221 STDMETHOD(get_Rating)(BSTR __RPC_FAR *pbstrRating) PURE;
222 STDMETHOD(get_FileName)(BSTR __RPC_FAR *pbstrFileName) PURE;
223 STDMETHOD(put_FileName)(BSTR pbstrFileName) PURE;
224 STDMETHOD(get_Duration)(double __RPC_FAR *pValue) PURE;
225 STDMETHOD(get_CurrentPosition)(double __RPC_FAR *pValue) PURE;
226 STDMETHOD(put_CurrentPosition)(double pValue) PURE;
227 STDMETHOD(get_PlayCount)(long __RPC_FAR *pPlayCount) PURE;
228 STDMETHOD(put_PlayCount)(long pPlayCount) PURE;
229 STDMETHOD(get_SelectionStart)(double __RPC_FAR *pValue) PURE;
230 STDMETHOD(put_SelectionStart)(double pValue) PURE;
231 STDMETHOD(get_SelectionEnd)(double __RPC_FAR *pValue) PURE;
232 STDMETHOD(put_SelectionEnd)(double pValue) PURE;
233 STDMETHOD(get_CurrentState)(StateConstants __RPC_FAR *pState) PURE;
234 STDMETHOD(get_Rate)(double __RPC_FAR *pValue) PURE;
235 STDMETHOD(put_Rate)(double pValue) PURE;
236 STDMETHOD(get_Volume)(long __RPC_FAR *pValue) PURE;
237 STDMETHOD(put_Volume)(long pValue) PURE;
238 STDMETHOD(get_Balance)(long __RPC_FAR *pValue) PURE;
239 STDMETHOD(put_Balance)(long pValue) PURE;
240 STDMETHOD(get_EnableContextMenu)(VARIANT_BOOL __RPC_FAR *pEnable) PURE;
241 STDMETHOD(put_EnableContextMenu)(VARIANT_BOOL pEnable) PURE;
242 STDMETHOD(get_ShowDisplay)(VARIANT_BOOL __RPC_FAR *Show) PURE;
243 STDMETHOD(put_ShowDisplay)(VARIANT_BOOL Show) PURE;
244 STDMETHOD(get_ShowControls)(VARIANT_BOOL __RPC_FAR *Show) PURE;
245 STDMETHOD(put_ShowControls)(VARIANT_BOOL Show) PURE;
246 STDMETHOD(get_ShowPositionControls)(VARIANT_BOOL __RPC_FAR *Show) PURE;
247 STDMETHOD(put_ShowPositionControls)(VARIANT_BOOL Show) PURE;
248 STDMETHOD(get_ShowSelectionControls)(VARIANT_BOOL __RPC_FAR *Show) PURE;
249 STDMETHOD(put_ShowSelectionControls)(VARIANT_BOOL Show) PURE;
250 STDMETHOD(get_ShowTracker)(VARIANT_BOOL __RPC_FAR *Show) PURE;
251 STDMETHOD(put_ShowTracker)(VARIANT_BOOL Show) PURE;
252 STDMETHOD(get_EnablePositionControls)(VARIANT_BOOL __RPC_FAR *Enable) PURE;
253 STDMETHOD(put_EnablePositionControls)(VARIANT_BOOL Enable) PURE;
254 STDMETHOD(get_EnableSelectionControls)(VARIANT_BOOL __RPC_FAR *Enable) PURE;
255 STDMETHOD(put_EnableSelectionControls)(VARIANT_BOOL Enable) PURE;
256 STDMETHOD(get_EnableTracker)(VARIANT_BOOL __RPC_FAR *Enable) PURE;
257 STDMETHOD(put_EnableTracker)(VARIANT_BOOL Enable) PURE;
258 STDMETHOD(get_AllowHideDisplay)(VARIANT_BOOL __RPC_FAR *Show) PURE;
259 STDMETHOD(put_AllowHideDisplay)(VARIANT_BOOL Show) PURE;
260 STDMETHOD(get_AllowHideControls)(VARIANT_BOOL __RPC_FAR *Show) PURE;
261 STDMETHOD(put_AllowHideControls)(VARIANT_BOOL Show) PURE;
262 STDMETHOD(get_DisplayMode)(DisplayModeConstants __RPC_FAR *pValue) PURE;
263 STDMETHOD(put_DisplayMode)(DisplayModeConstants pValue) PURE;
264 STDMETHOD(get_AllowChangeDisplayMode)(VARIANT_BOOL __RPC_FAR *fAllow) PURE;
265 STDMETHOD(put_AllowChangeDisplayMode)(VARIANT_BOOL fAllow) PURE;
266 STDMETHOD(get_FilterGraph)(IUnknown __RPC_FAR *__RPC_FAR *ppFilterGraph) PURE;
267 STDMETHOD(put_FilterGraph)(IUnknown __RPC_FAR *ppFilterGraph) PURE;
268 STDMETHOD(get_FilterGraphDispatch)(IDispatch __RPC_FAR *__RPC_FAR *pDispatch) PURE;
269 STDMETHOD(get_DisplayForeColor)(unsigned long __RPC_FAR *ForeColor) PURE;
270 STDMETHOD(put_DisplayForeColor)(unsigned long ForeColor) PURE;
271 STDMETHOD(get_DisplayBackColor)(unsigned long __RPC_FAR *BackColor) PURE;
272 STDMETHOD(put_DisplayBackColor)(unsigned long BackColor) PURE;
273 STDMETHOD(get_MovieWindowSize)(WindowSizeConstants __RPC_FAR *WindowSize) PURE;
274 STDMETHOD(put_MovieWindowSize)(WindowSizeConstants WindowSize) PURE;
275 STDMETHOD(get_FullScreenMode)(VARIANT_BOOL __RPC_FAR *pEnable) PURE;
276 STDMETHOD(put_FullScreenMode)(VARIANT_BOOL pEnable) PURE;
277 STDMETHOD(get_AutoStart)(VARIANT_BOOL __RPC_FAR *pEnable) PURE;
278 STDMETHOD(put_AutoStart)(VARIANT_BOOL pEnable) PURE;
279 STDMETHOD(get_AutoRewind)(VARIANT_BOOL __RPC_FAR *pEnable) PURE;
280 STDMETHOD(put_AutoRewind)(VARIANT_BOOL pEnable) PURE;
281 STDMETHOD(get_hWnd)(long __RPC_FAR *hWnd) PURE;
282 STDMETHOD(get_Appearance)(AppearanceConstants __RPC_FAR *pAppearance) PURE;
283 STDMETHOD(put_Appearance)(AppearanceConstants pAppearance) PURE;
284 STDMETHOD(get_BorderStyle)(BorderStyleConstants __RPC_FAR *pBorderStyle) PURE;
285 STDMETHOD(put_BorderStyle)(BorderStyleConstants pBorderStyle) PURE;
286 STDMETHOD(get_Enabled)(VARIANT_BOOL __RPC_FAR *pEnabled) PURE;
287 STDMETHOD(put_Enabled)(VARIANT_BOOL pEnabled) PURE;
288 STDMETHOD(get_Info)(long __RPC_FAR *ppInfo) PURE;
289 };
290
291
292 struct IActiveMovie2 : public IActiveMovie
293 {
294 STDMETHOD(IsSoundCardEnabled)(VARIANT_BOOL __RPC_FAR *pbSoundCard) PURE;
295 STDMETHOD(get_ReadyState)(ReadyStateConstants __RPC_FAR *pValue) PURE;
296 };
297
298 struct IActiveMovie3 : public IActiveMovie2
299 {
300 STDMETHOD(get_MediaPlayer)(IDispatch __RPC_FAR *__RPC_FAR *ppDispatch) PURE;
301 };
302
303
304 //---------------------------------------------------------------------------
305 // MEDIAPLAYER COM INTERFACES (dumped from msdxm.idl from MSVC COM Browser)
306 //---------------------------------------------------------------------------
307
308 enum MPPlayStateConstants
309 {
310 mpStopped = 0,
311 mpPaused = 1,
312 mpPlaying = 2,
313 mpWaiting = 3,
314 mpScanForward = 4,
315 mpScanReverse = 5,
316 mpClosed = 6
317 };
318
319 enum MPDisplaySizeConstants
320 {
321 mpDefaultSize = 0,
322 mpHalfSize = 1,
323 mpDoubleSize = 2,
324 mpFullScreen = 3,
325 mpFitToSize = 4,
326 mpOneSixteenthScreen = 5,
327 mpOneFourthScreen = 6,
328 mpOneHalfScreen = 7
329 };
330
331 enum MPReadyStateConstants
332 {
333 mpReadyStateUninitialized = 0,
334 mpReadyStateLoading = 1,
335 mpReadyStateInteractive = 3,
336 mpReadyStateComplete = 4
337 };
338
339 typedef unsigned long VB_OLE_COLOR;
340
341 enum MPDisplayModeConstants
342 {
343 mpTime = 0,
344 mpFrames = 1
345 };
346
347 enum MPMoreInfoType
348 {
349 mpShowURL = 0,
350 mpClipURL = 1,
351 mpBannerURL = 2
352 };
353
354 enum MPMediaInfoType
355 {
356 mpShowFilename = 0,
357 mpShowTitle = 1,
358 mpShowAuthor = 2,
359 mpShowCopyright = 3,
360 mpShowRating = 4,
361 mpShowDescription = 5,
362 mpShowLogoIcon = 6,
363 mpClipFilename = 7,
364 mpClipTitle = 8,
365 mpClipAuthor = 9,
366 mpClipCopyright = 10,
367 mpClipRating = 11,
368 mpClipDescription = 12,
369 mpClipLogoIcon = 13,
370 mpBannerImage = 14,
371 mpBannerMoreInfo = 15,
372 mpWatermark = 16
373 };
374
375 enum DVDMenuIDConstants
376 {
377 dvdMenu_Title = 2,
378 dvdMenu_Root = 3,
379 dvdMenu_Subpicture = 4,
380 dvdMenu_Audio = 5,
381 dvdMenu_Angle = 6,
382 dvdMenu_Chapter = 7
383 };
384
385 enum MPShowDialogConstants
386 {
387 mpShowDialogHelp = 0,
388 mpShowDialogStatistics = 1,
389 mpShowDialogOptions = 2,
390 mpShowDialogContextMenu = 3
391 };
392
393
394 struct IMediaPlayer : public IDispatch
395 {
396 STDMETHOD(get_CurrentPosition)(double __RPC_FAR *pCurrentPosition) PURE;
397 STDMETHOD(put_CurrentPosition)(double pCurrentPosition) PURE;
398 STDMETHOD(get_Duration)(double __RPC_FAR *pDuration) PURE;
399 STDMETHOD(get_ImageSourceWidth)(long __RPC_FAR *pWidth) PURE;
400 STDMETHOD(get_ImageSourceHeight)(long __RPC_FAR *pHeight) PURE;
401 STDMETHOD(get_MarkerCount)(long __RPC_FAR *pMarkerCount) PURE;
402 STDMETHOD(get_CanScan)(VARIANT_BOOL __RPC_FAR *pCanScan) PURE;
403 STDMETHOD(get_CanSeek)(VARIANT_BOOL __RPC_FAR *pCanSeek) PURE;
404 STDMETHOD(get_CanSeekToMarkers)(VARIANT_BOOL __RPC_FAR *pCanSeekToMarkers) PURE;
405 STDMETHOD(get_CurrentMarker)(long __RPC_FAR *pCurrentMarker) PURE;
406 STDMETHOD(put_CurrentMarker)(long pCurrentMarker) PURE;
407 STDMETHOD(get_FileName)(BSTR __RPC_FAR *pbstrFileName) PURE;
408 STDMETHOD(put_FileName)(BSTR pbstrFileName) PURE;
409 STDMETHOD(get_SourceLink)(BSTR __RPC_FAR *pbstrSourceLink) PURE;
410 STDMETHOD(get_CreationDate)(DATE __RPC_FAR *pCreationDate) PURE;
411 STDMETHOD(get_ErrorCorrection)(BSTR __RPC_FAR *pbstrErrorCorrection) PURE;
412 STDMETHOD(get_Bandwidth)(long __RPC_FAR *pBandwidth) PURE;
413 STDMETHOD(get_SourceProtocol)(long __RPC_FAR *pSourceProtocol) PURE;
414 STDMETHOD(get_ReceivedPackets)(long __RPC_FAR *pReceivedPackets) PURE;
415 STDMETHOD(get_RecoveredPackets)(long __RPC_FAR *pRecoveredPackets) PURE;
416 STDMETHOD(get_LostPackets)(long __RPC_FAR *pLostPackets) PURE;
417 STDMETHOD(get_ReceptionQuality)(long __RPC_FAR *pReceptionQuality) PURE;
418 STDMETHOD(get_BufferingCount)(long __RPC_FAR *pBufferingCount) PURE;
419 STDMETHOD(get_IsBroadcast)(VARIANT_BOOL __RPC_FAR *pIsBroadcast) PURE;
420 STDMETHOD(get_BufferingProgress)(long __RPC_FAR *pBufferingProgress) PURE;
421 STDMETHOD(get_ChannelName)(BSTR __RPC_FAR *pbstrChannelName) PURE;
422 STDMETHOD(get_ChannelDescription)(BSTR __RPC_FAR *pbstrChannelDescription) PURE;
423 STDMETHOD(get_ChannelURL)(BSTR __RPC_FAR *pbstrChannelURL) PURE;
424 STDMETHOD(get_ContactAddress)(BSTR __RPC_FAR *pbstrContactAddress) PURE;
425 STDMETHOD(get_ContactPhone)(BSTR __RPC_FAR *pbstrContactPhone) PURE;
426 STDMETHOD(get_ContactEmail)(BSTR __RPC_FAR *pbstrContactEmail) PURE;
427 STDMETHOD(get_BufferingTime)(double __RPC_FAR *pBufferingTime) PURE;
428 STDMETHOD(put_BufferingTime)(double pBufferingTime) PURE;
429 STDMETHOD(get_AutoStart)(VARIANT_BOOL __RPC_FAR *pAutoStart) PURE;
430 STDMETHOD(put_AutoStart)(VARIANT_BOOL pAutoStart) PURE;
431 STDMETHOD(get_AutoRewind)(VARIANT_BOOL __RPC_FAR *pAutoRewind) PURE;
432 STDMETHOD(put_AutoRewind)(VARIANT_BOOL pAutoRewind) PURE;
433 STDMETHOD(get_Rate)(double __RPC_FAR *pRate) PURE;
434 STDMETHOD(put_Rate)(double pRate) PURE;
435 STDMETHOD(get_SendKeyboardEvents)(VARIANT_BOOL __RPC_FAR *pSendKeyboardEvents) PURE;
436 STDMETHOD(put_SendKeyboardEvents)(VARIANT_BOOL pSendKeyboardEvents) PURE;
437 STDMETHOD(get_SendMouseClickEvents)(VARIANT_BOOL __RPC_FAR *pSendMouseClickEvents) PURE;
438 STDMETHOD(put_SendMouseClickEvents)(VARIANT_BOOL pSendMouseClickEvents) PURE;
439 STDMETHOD(get_SendMouseMoveEvents)(VARIANT_BOOL __RPC_FAR *pSendMouseMoveEvents) PURE;
440 STDMETHOD(put_SendMouseMoveEvents)(VARIANT_BOOL pSendMouseMoveEvents) PURE;
441 STDMETHOD(get_PlayCount)(long __RPC_FAR *pPlayCount) PURE;
442 STDMETHOD(put_PlayCount)(long pPlayCount) PURE;
443 STDMETHOD(get_ClickToPlay)(VARIANT_BOOL __RPC_FAR *pClickToPlay) PURE;
444 STDMETHOD(put_ClickToPlay)(VARIANT_BOOL pClickToPlay) PURE;
445 STDMETHOD(get_AllowScan)(VARIANT_BOOL __RPC_FAR *pAllowScan) PURE;
446 STDMETHOD(put_AllowScan)(VARIANT_BOOL pAllowScan) PURE;
447 STDMETHOD(get_EnableContextMenu)(VARIANT_BOOL __RPC_FAR *pEnableContextMenu) PURE;
448 STDMETHOD(put_EnableContextMenu)(VARIANT_BOOL pEnableContextMenu) PURE;
449 STDMETHOD(get_CursorType)(long __RPC_FAR *pCursorType) PURE;
450 STDMETHOD(put_CursorType)(long pCursorType) PURE;
451 STDMETHOD(get_CodecCount)(long __RPC_FAR *pCodecCount) PURE;
452 STDMETHOD(get_AllowChangeDisplaySize)(VARIANT_BOOL __RPC_FAR *pAllowChangeDisplaySize) PURE;
453 STDMETHOD(put_AllowChangeDisplaySize)( VARIANT_BOOL pAllowChangeDisplaySize) PURE;
454 STDMETHOD(get_IsDurationValid)(VARIANT_BOOL __RPC_FAR *pIsDurationValid) PURE;
455 STDMETHOD(get_OpenState)(long __RPC_FAR *pOpenState) PURE;
456 STDMETHOD(get_SendOpenStateChangeEvents)(VARIANT_BOOL __RPC_FAR *pSendOpenStateChangeEvents) PURE;
457 STDMETHOD(put_SendOpenStateChangeEvents)(VARIANT_BOOL pSendOpenStateChangeEvents) PURE;
458 STDMETHOD(get_SendWarningEvents)( VARIANT_BOOL __RPC_FAR *pSendWarningEvents) PURE;
459 STDMETHOD(put_SendWarningEvents)(VARIANT_BOOL pSendWarningEvents) PURE;
460 STDMETHOD(get_SendErrorEvents)(VARIANT_BOOL __RPC_FAR *pSendErrorEvents) PURE;
461 STDMETHOD(put_SendErrorEvents)(VARIANT_BOOL pSendErrorEvents) PURE;
462 STDMETHOD(get_PlayState)(MPPlayStateConstants __RPC_FAR *pPlayState) PURE;
463 STDMETHOD(get_SendPlayStateChangeEvents)(VARIANT_BOOL __RPC_FAR *pSendPlayStateChangeEvents) PURE;
464 STDMETHOD(put_SendPlayStateChangeEvents)(VARIANT_BOOL pSendPlayStateChangeEvents) PURE;
465 STDMETHOD(get_DisplaySize)(MPDisplaySizeConstants __RPC_FAR *pDisplaySize) PURE;
466 STDMETHOD(put_DisplaySize)(MPDisplaySizeConstants pDisplaySize) PURE;
467 STDMETHOD(get_InvokeURLs)(VARIANT_BOOL __RPC_FAR *pInvokeURLs) PURE;
468 STDMETHOD(put_InvokeURLs)(VARIANT_BOOL pInvokeURLs) PURE;
469 STDMETHOD(get_BaseURL)(BSTR __RPC_FAR *pbstrBaseURL) PURE;
470 STDMETHOD(put_BaseURL)(BSTR pbstrBaseURL) PURE;
471 STDMETHOD(get_DefaultFrame)(BSTR __RPC_FAR *pbstrDefaultFrame) PURE;
472 STDMETHOD(put_DefaultFrame)(BSTR pbstrDefaultFrame) PURE;
473 STDMETHOD(get_HasError)(VARIANT_BOOL __RPC_FAR *pHasError) PURE;
474 STDMETHOD(get_ErrorDescription)(BSTR __RPC_FAR *pbstrErrorDescription) PURE;
475 STDMETHOD(get_ErrorCode)(long __RPC_FAR *pErrorCode) PURE;
476 STDMETHOD(get_AnimationAtStart)(VARIANT_BOOL __RPC_FAR *pAnimationAtStart) PURE;
477 STDMETHOD(put_AnimationAtStart)(VARIANT_BOOL pAnimationAtStart) PURE;
478 STDMETHOD(get_TransparentAtStart)( VARIANT_BOOL __RPC_FAR *pTransparentAtStart) PURE;
479 STDMETHOD(put_TransparentAtStart)(VARIANT_BOOL pTransparentAtStart) PURE;
480 STDMETHOD(get_Volume)(long __RPC_FAR *pVolume) PURE;
481 STDMETHOD(put_Volume)(long pVolume) PURE;
482 STDMETHOD(get_Balance)(long __RPC_FAR *pBalance) PURE;
483 STDMETHOD(put_Balance)(long pBalance) PURE;
484 STDMETHOD(get_ReadyState)(MPReadyStateConstants __RPC_FAR *pValue) PURE;
485 STDMETHOD(get_SelectionStart)(double __RPC_FAR *pValue) PURE;
486 STDMETHOD(put_SelectionStart)(double pValue) PURE;
487 STDMETHOD(get_SelectionEnd)(double __RPC_FAR *pValue) PURE;
488 STDMETHOD(put_SelectionEnd)(double pValue) PURE;
489 STDMETHOD(get_ShowDisplay)(VARIANT_BOOL __RPC_FAR *Show) PURE;
490 STDMETHOD(put_ShowDisplay)(VARIANT_BOOL Show) PURE;
491 STDMETHOD(get_ShowControls)(VARIANT_BOOL __RPC_FAR *Show) PURE;
492 STDMETHOD(put_ShowControls)(VARIANT_BOOL Show) PURE;
493 STDMETHOD(get_ShowPositionControls)(VARIANT_BOOL __RPC_FAR *Show) PURE;
494 STDMETHOD(put_ShowPositionControls)(VARIANT_BOOL Show) PURE;
495 STDMETHOD(get_ShowTracker)(VARIANT_BOOL __RPC_FAR *Show) PURE;
496 STDMETHOD(put_ShowTracker)(VARIANT_BOOL Show) PURE;
497 STDMETHOD(get_EnablePositionControls)(VARIANT_BOOL __RPC_FAR *Enable) PURE;
498 STDMETHOD(put_EnablePositionControls)(VARIANT_BOOL Enable) PURE;
499 STDMETHOD(get_EnableTracker)(VARIANT_BOOL __RPC_FAR *Enable) PURE;
500 STDMETHOD(put_EnableTracker)(VARIANT_BOOL Enable) PURE;
501 STDMETHOD(get_Enabled)(VARIANT_BOOL __RPC_FAR *pEnabled) PURE;
502 STDMETHOD(put_Enabled)(VARIANT_BOOL pEnabled) PURE;
503 STDMETHOD(get_DisplayForeColor)(VB_OLE_COLOR __RPC_FAR *ForeColor) PURE;
504 STDMETHOD(put_DisplayForeColor)(VB_OLE_COLOR ForeColor) PURE;
505 STDMETHOD(get_DisplayBackColor)(VB_OLE_COLOR __RPC_FAR *BackColor) PURE;
506 STDMETHOD(put_DisplayBackColor)(VB_OLE_COLOR BackColor) PURE;
507 STDMETHOD(get_DisplayMode)(MPDisplayModeConstants __RPC_FAR *pValue) PURE;
508 STDMETHOD(put_DisplayMode)(MPDisplayModeConstants pValue) PURE;
509 STDMETHOD(get_VideoBorder3D)(VARIANT_BOOL __RPC_FAR *pVideoBorderWidth) PURE;
510 STDMETHOD(put_VideoBorder3D)(VARIANT_BOOL pVideoBorderWidth) PURE;
511 STDMETHOD(get_VideoBorderWidth)(long __RPC_FAR *pVideoBorderWidth) PURE;
512 STDMETHOD(put_VideoBorderWidth)(long pVideoBorderWidth) PURE;
513 STDMETHOD(get_VideoBorderColor)(VB_OLE_COLOR __RPC_FAR *pVideoBorderWidth) PURE;
514 STDMETHOD(put_VideoBorderColor)(VB_OLE_COLOR pVideoBorderWidth) PURE;
515 STDMETHOD(get_ShowGotoBar)(VARIANT_BOOL __RPC_FAR *pbool) PURE;
516 STDMETHOD(put_ShowGotoBar)(VARIANT_BOOL pbool) PURE;
517 STDMETHOD(get_ShowStatusBar)(VARIANT_BOOL __RPC_FAR *pbool) PURE;
518 STDMETHOD(put_ShowStatusBar)(VARIANT_BOOL pbool) PURE;
519 STDMETHOD(get_ShowCaptioning)(VARIANT_BOOL __RPC_FAR *pbool) PURE;
520 STDMETHOD(put_ShowCaptioning)(VARIANT_BOOL pbool) PURE;
521 STDMETHOD(get_ShowAudioControls)(VARIANT_BOOL __RPC_FAR *pbool) PURE;
522 STDMETHOD(put_ShowAudioControls)(VARIANT_BOOL pbool) PURE;
523 STDMETHOD(get_CaptioningID)( BSTR __RPC_FAR *pstrText) PURE;
524 STDMETHOD(put_CaptioningID)(BSTR pstrText) PURE;
525 STDMETHOD(get_Mute)(VARIANT_BOOL __RPC_FAR *vbool) PURE;
526 STDMETHOD(put_Mute)(VARIANT_BOOL vbool) PURE;
527 STDMETHOD(get_CanPreview)(VARIANT_BOOL __RPC_FAR *pCanPreview) PURE;
528 STDMETHOD(get_PreviewMode)(VARIANT_BOOL __RPC_FAR *pPreviewMode) PURE;
529 STDMETHOD(put_PreviewMode)(VARIANT_BOOL pPreviewMode) PURE;
530 STDMETHOD(get_HasMultipleItems)(VARIANT_BOOL __RPC_FAR *pHasMuliItems) PURE;
531 STDMETHOD(get_Language)(long __RPC_FAR *pLanguage) PURE;
532 STDMETHOD(put_Language)(long pLanguage) PURE;
533 STDMETHOD(get_AudioStream)(long __RPC_FAR *pStream) PURE;
534 STDMETHOD(put_AudioStream)(long pStream) PURE;
535 STDMETHOD(get_SAMIStyle)(BSTR __RPC_FAR *pbstrStyle) PURE;
536 STDMETHOD(put_SAMIStyle)(BSTR pbstrStyle) PURE;
537 STDMETHOD(get_SAMILang)(BSTR __RPC_FAR *pbstrLang) PURE;
538 STDMETHOD(put_SAMILang)(BSTR pbstrLang) PURE;
539 STDMETHOD(get_SAMIFileName)(BSTR __RPC_FAR *pbstrFileName) PURE;
540 STDMETHOD(put_SAMIFileName)(BSTR pbstrFileName) PURE;
541 STDMETHOD(get_StreamCount)( long __RPC_FAR *pStreamCount) PURE;
542 STDMETHOD(get_ClientId)(BSTR __RPC_FAR *pbstrClientId) PURE;
543 STDMETHOD(get_ConnectionSpeed)(long __RPC_FAR *plConnectionSpeed) PURE;
544 STDMETHOD(get_AutoSize)(VARIANT_BOOL __RPC_FAR *pbool) PURE;
545 STDMETHOD(put_AutoSize)(VARIANT_BOOL pbool) PURE;
546 STDMETHOD(get_EnableFullScreenControls)(VARIANT_BOOL __RPC_FAR *pbVal) PURE;
547 STDMETHOD(put_EnableFullScreenControls)(VARIANT_BOOL pbVal) PURE;
548 STDMETHOD(get_ActiveMovie)(IDispatch __RPC_FAR *__RPC_FAR *ppdispatch) PURE;
549 STDMETHOD(get_NSPlay)(IDispatch __RPC_FAR *__RPC_FAR *ppdispatch) PURE;
550 STDMETHOD(get_WindowlessVideo)(VARIANT_BOOL __RPC_FAR *pbool) PURE;
551 STDMETHOD(put_WindowlessVideo)(VARIANT_BOOL pbool) PURE;
552 STDMETHOD(Play)(void) PURE;
553 STDMETHOD(Stop)(void) PURE;
554 STDMETHOD(Pause)(void) PURE;
555 STDMETHOD(GetMarkerTime)(long MarkerNum,
556 double __RPC_FAR *pMarkerTime) PURE;
557 STDMETHOD(GetMarkerName)(long MarkerNum,
558 BSTR __RPC_FAR *pbstrMarkerName) PURE;
559 STDMETHOD(AboutBox)(void) PURE;
560 STDMETHOD(GetCodecInstalled)(long CodecNum,
561 VARIANT_BOOL __RPC_FAR *pCodecInstalled) PURE;
562 STDMETHOD(GetCodecDescription)(long CodecNum,
563 BSTR __RPC_FAR *pbstrCodecDescription) PURE;
564 STDMETHOD(GetCodecURL)(long CodecNum,
565 BSTR __RPC_FAR *pbstrCodecURL) PURE;
566 STDMETHOD(GetMoreInfoURL)(MPMoreInfoType MoreInfoType,
567 BSTR __RPC_FAR *pbstrMoreInfoURL) PURE;
568 STDMETHOD(GetMediaInfoString)(MPMediaInfoType MediaInfoType,
569 BSTR __RPC_FAR *pbstrMediaInfo) PURE;
570 STDMETHOD(Cancel)(void) PURE;
571 STDMETHOD(Open)(BSTR bstrFileName) PURE;
572 STDMETHOD(IsSoundCardEnabled)(VARIANT_BOOL __RPC_FAR *pbSoundCard) PURE;
573 STDMETHOD(Next)(void) PURE;
574 STDMETHOD(Previous)(void) PURE;
575 STDMETHOD(StreamSelect)(long StreamNum) PURE;
576 STDMETHOD(FastForward)(void) PURE;
577 STDMETHOD(FastReverse)(void) PURE;
578 STDMETHOD(GetStreamName)(long StreamNum,
579 BSTR __RPC_FAR *pbstrStreamName) PURE;
580 STDMETHOD(GetStreamGroup)(long StreamNum,
581 long __RPC_FAR *pStreamGroup) PURE;
582 STDMETHOD(GetStreamSelected)(long StreamNum, VARIANT_BOOL __RPC_FAR *pStreamSelected) PURE;
583 };
584
585 struct IMediaPlayer2 : public IMediaPlayer
586 {
587 STDMETHOD(get_DVD)(struct IMediaPlayerDvd __RPC_FAR *__RPC_FAR *ppdispatch) PURE;
588 STDMETHOD(GetMediaParameter)(long EntryNum, BSTR bstrParameterName, BSTR __RPC_FAR *pbstrParameterValue) PURE;
589 STDMETHOD(GetMediaParameterName(long EntryNum, long Index, BSTR __RPC_FAR *pbstrParameterName) PURE;
590 STDMETHOD(get_EntryCount)(long __RPC_FAR *pNumberEntries) PURE;
591 STDMETHOD(GetCurrentEntry)(long __RPC_FAR *pEntryNumber) PURE;
592 STDMETHOD(SetCurrentEntry)(long EntryNumber) PURE;
593 STDMETHOD(ShowDialog)(MPShowDialogConstants mpDialogIndex) PURE;
594 };
595
596 //---------------------------------------------------------------------------
597 // NETSHOW COM INTERFACES (dumped from nscompat.idl from MSVC COM Browser)
598 //---------------------------------------------------------------------------
599
600 struct INSOPlay : public IDispatch
601 {
602 STDMETHOD(get_ImageSourceWidth)(long __RPC_FAR *pWidth) PURE;
603 STDMETHOD(get_ImageSourceHeight)(long __RPC_FAR *pHeight) PURE;
604 STDMETHOD(get_Duration)(double __RPC_FAR *pDuration) PURE;
605 STDMETHOD(get_Author)(BSTR __RPC_FAR *pbstrAuthor) PURE;
606 STDMETHOD(get_Copyright)(BSTR __RPC_FAR *pbstrCopyright) PURE;
607 STDMETHOD(get_Description)(BSTR __RPC_FAR *pbstrDescription) PURE;
608 STDMETHOD(get_Rating)(BSTR __RPC_FAR *pbstrRating) PURE;
609 STDMETHOD(get_Title)(BSTR __RPC_FAR *pbstrTitle) PURE;
610 STDMETHOD(get_SourceLink)(BSTR __RPC_FAR *pbstrSourceLink) PURE;
611 STDMETHOD(get_MarkerCount)(long __RPC_FAR *pMarkerCount) PURE;
612 STDMETHOD(get_CanScan)(VARIANT_BOOL __RPC_FAR *pCanScan) PURE;
613 STDMETHOD(get_CanSeek)(VARIANT_BOOL __RPC_FAR *pCanSeek) PURE;
614 STDMETHOD(get_CanSeekToMarkers)(VARIANT_BOOL __RPC_FAR *pCanSeekToMarkers) PURE;
615 STDMETHOD(get_CreationDate)(DATE __RPC_FAR *pCreationDate) PURE;
616 STDMETHOD(get_Bandwidth)(long __RPC_FAR *pBandwidth) PURE;
617 STDMETHOD(get_ErrorCorrection)(BSTR __RPC_FAR *pbstrErrorCorrection) PURE;
618 STDMETHOD(get_AutoStart)(VARIANT_BOOL __RPC_FAR *pAutoStart) PURE;
619 STDMETHOD(put_AutoStart)(VARIANT_BOOL pAutoStart) PURE;
620 STDMETHOD(get_AutoRewind)(VARIANT_BOOL __RPC_FAR *pAutoRewind) PURE;
621 STDMETHOD(put_AutoRewind)(VARIANT_BOOL pAutoRewind) PURE;
622 STDMETHOD(get_AllowChangeControlType)(VARIANT_BOOL __RPC_FAR *pAllowChangeControlType) PURE;
623 STDMETHOD(put_AllowChangeControlType)(VARIANT_BOOL pAllowChangeControlType) PURE;
624 STDMETHOD(get_InvokeURLs)(VARIANT_BOOL __RPC_FAR *pInvokeURLs) PURE;
625 STDMETHOD(put_InvokeURLs)(VARIANT_BOOL pInvokeURLs) PURE;
626 STDMETHOD(get_EnableContextMenu)(VARIANT_BOOL __RPC_FAR *pEnableContextMenu) PURE;
627 STDMETHOD(put_EnableContextMenu)(VARIANT_BOOL pEnableContextMenu) PURE;
628 STDMETHOD(get_TransparentAtStart)(VARIANT_BOOL __RPC_FAR *pTransparentAtStart) PURE;
629 STDMETHOD(put_TransparentAtStart)(VARIANT_BOOL pTransparentAtStart) PURE;
630 STDMETHOD(get_TransparentOnStop)(VARIANT_BOOL __RPC_FAR *pTransparentOnStop) PURE;
631 STDMETHOD(put_TransparentOnStop)(VARIANT_BOOL pTransparentOnStop) PURE;
632 STDMETHOD(get_ClickToPlay)(VARIANT_BOOL __RPC_FAR *pClickToPlay) PURE;
633 STDMETHOD(put_ClickToPlay)(VARIANT_BOOL pClickToPlay) PURE;
634 STDMETHOD(get_FileName)(BSTR __RPC_FAR *pbstrFileName) PURE;
635 STDMETHOD(put_FileName)(BSTR pbstrFileName) PURE;
636 STDMETHOD(get_CurrentPosition)(double __RPC_FAR *pCurrentPosition) PURE;
637 STDMETHOD(put_CurrentPosition)(double pCurrentPosition) PURE;
638 STDMETHOD(get_Rate)(double __RPC_FAR *pRate) PURE;
639 STDMETHOD(put_Rate)(double pRate) PURE;
640 STDMETHOD(get_CurrentMarker)(long __RPC_FAR *pCurrentMarker) PURE;
641 STDMETHOD(put_CurrentMarker)(long pCurrentMarker) PURE;
642 STDMETHOD(get_PlayCount)(long __RPC_FAR *pPlayCount) PURE;
643 STDMETHOD(put_PlayCount)(long pPlayCount) PURE;
644 STDMETHOD(get_CurrentState)(long __RPC_FAR *pCurrentState) PURE;
645 STDMETHOD(get_DisplaySize)(long __RPC_FAR *pDisplaySize) PURE;
646 STDMETHOD(put_DisplaySize)(long pDisplaySize) PURE;
647 STDMETHOD(get_MainWindow)(long __RPC_FAR *pMainWindow) PURE;
648 STDMETHOD(get_ControlType)(long __RPC_FAR *pControlType) PURE;
649 STDMETHOD(put_ControlType)(long pControlType) PURE;
650 STDMETHOD(get_AllowScan)(VARIANT_BOOL __RPC_FAR *pAllowScan) PURE;
651 STDMETHOD(put_AllowScan)(VARIANT_BOOL pAllowScan) PURE;
652 STDMETHOD(get_SendKeyboardEvents)(VARIANT_BOOL __RPC_FAR *pSendKeyboardEvents) PURE;
653 STDMETHOD(put_SendKeyboardEvents)(VARIANT_BOOL pSendKeyboardEvents) PURE;
654 STDMETHOD(get_SendMouseClickEvents)(VARIANT_BOOL __RPC_FAR *pSendMouseClickEvents) PURE;
655 STDMETHOD(put_SendMouseClickEvents)(VARIANT_BOOL pSendMouseClickEvents) PURE;
656 STDMETHOD(get_SendMouseMoveEvents)(VARIANT_BOOL __RPC_FAR *pSendMouseMoveEvents) PURE;
657 STDMETHOD(put_SendMouseMoveEvents)(VARIANT_BOOL pSendMouseMoveEvents) PURE;
658 STDMETHOD(get_SendStateChangeEvents)(VARIANT_BOOL __RPC_FAR *pSendStateChangeEvents) PURE;
659 STDMETHOD(put_SendStateChangeEvents)(VARIANT_BOOL pSendStateChangeEvents) PURE;
660 STDMETHOD(get_ReceivedPackets)(long __RPC_FAR *pReceivedPackets) PURE;
661 STDMETHOD(get_RecoveredPackets)(long __RPC_FAR *pRecoveredPackets) PURE;
662 STDMETHOD(get_LostPackets)(long __RPC_FAR *pLostPackets) PURE;
663 STDMETHOD(get_ReceptionQuality)(long __RPC_FAR *pReceptionQuality) PURE;
664 STDMETHOD(get_BufferingCount)(long __RPC_FAR *pBufferingCount) PURE;
665 STDMETHOD(get_CursorType)(long __RPC_FAR *pCursorType) PURE;
666 STDMETHOD(put_CursorType)(long pCursorType) PURE;
667 STDMETHOD(get_AnimationAtStart)(VARIANT_BOOL __RPC_FAR *pAnimationAtStart) PURE;
668 STDMETHOD(put_AnimationAtStart)(VARIANT_BOOL pAnimationAtStart) PURE;
669 STDMETHOD(get_AnimationOnStop)(VARIANT_BOOL __RPC_FAR *pAnimationOnStop) PURE;
670 STDMETHOD(put_AnimationOnStop)(VARIANT_BOOL pAnimationOnStop) PURE;
671 STDMETHOD(Play)(void) PURE;
672 STDMETHOD(Pause)(void) PURE;
673 STDMETHOD(Stop)(void) PURE;
674 STDMETHOD(GetMarkerTime)(long MarkerNum, double __RPC_FAR *pMarkerTime) PURE;
675 STDMETHOD(GetMarkerName)(long MarkerNum, BSTR __RPC_FAR *pbstrMarkerName) PURE;
676 };
677
678 struct INSPlay : public INSOPlay
679 {
680 STDMETHOD(get_ChannelName)(BSTR __RPC_FAR *pbstrChannelName) PURE;
681 STDMETHOD(get_ChannelDescription)(BSTR __RPC_FAR *pbstrChannelDescription) PURE;
682 STDMETHOD(get_ChannelURL)(BSTR __RPC_FAR *pbstrChannelURL) PURE;
683 STDMETHOD(get_ContactAddress)(BSTR __RPC_FAR *pbstrContactAddress) PURE;
684 STDMETHOD(get_ContactPhone)(BSTR __RPC_FAR *pbstrContactPhone) PURE;
685 STDMETHOD(get_ContactEmail)(BSTR __RPC_FAR *pbstrContactEmail) PURE;
686 STDMETHOD(get_AllowChangeDisplaySize)(VARIANT_BOOL __RPC_FAR *pAllowChangeDisplaySize) PURE;
687 STDMETHOD(put_AllowChangeDisplaySize)(VARIANT_BOOL pAllowChangeDisplaySize) PURE;
688 STDMETHOD(get_CodecCount)(long __RPC_FAR *pCodecCount) PURE;
689 STDMETHOD(get_IsBroadcast)(VARIANT_BOOL __RPC_FAR *pIsBroadcast) PURE;
690 STDMETHOD(get_IsDurationValid)(VARIANT_BOOL __RPC_FAR *pIsDurationValid) PURE;
691 STDMETHOD(get_SourceProtocol)(long __RPC_FAR *pSourceProtocol) PURE;
692 STDMETHOD(get_OpenState)(long __RPC_FAR *pOpenState) PURE;
693 STDMETHOD(get_SendOpenStateChangeEvents)(VARIANT_BOOL __RPC_FAR *pSendOpenStateChangeEvents) PURE;
694 STDMETHOD(put_SendOpenStateChangeEvents)(VARIANT_BOOL pSendOpenStateChangeEvents) PURE;
695 STDMETHOD(get_SendWarningEvents)(VARIANT_BOOL __RPC_FAR *pSendWarningEvents) PURE;
696 STDMETHOD(put_SendWarningEvents)(VARIANT_BOOL pSendWarningEvents) PURE;
697 STDMETHOD(get_SendErrorEvents)(VARIANT_BOOL __RPC_FAR *pSendErrorEvents) PURE;
698 STDMETHOD(put_SendErrorEvents)(VARIANT_BOOL pSendErrorEvents) PURE;
699 STDMETHOD(get_HasError)(VARIANT_BOOL __RPC_FAR *pHasError) PURE;
700 STDMETHOD(get_ErrorDescription)(BSTR __RPC_FAR *pbstrErrorDescription) PURE;
701 STDMETHOD(get_ErrorCode)(long __RPC_FAR *pErrorCode) PURE;
702 STDMETHOD(get_PlayState)(long __RPC_FAR *pPlayState) PURE;
703 STDMETHOD(get_SendPlayStateChangeEvents)(VARIANT_BOOL __RPC_FAR *pSendPlayStateChangeEvents) PURE;
704 STDMETHOD(put_SendPlayStateChangeEvents)(VARIANT_BOOL pSendPlayStateChangeEvents) PURE;
705 STDMETHOD(get_BufferingTime)(double __RPC_FAR *pBufferingTime) PURE;
706 STDMETHOD(put_BufferingTime)(double pBufferingTime) PURE;
707 STDMETHOD(get_UseFixedUDPPort)(VARIANT_BOOL __RPC_FAR *pUseFixedUDPPort) PURE;
708 STDMETHOD(put_UseFixedUDPPort)(VARIANT_BOOL pUseFixedUDPPort) PURE;
709 STDMETHOD(get_FixedUDPPort)(long __RPC_FAR *pFixedUDPPort) PURE;
710 STDMETHOD(put_FixedUDPPort)(long pFixedUDPPort) PURE;
711 STDMETHOD(get_UseHTTPProxy)(VARIANT_BOOL __RPC_FAR *pUseHTTPProxy) PURE;
712 STDMETHOD(put_UseHTTPProxy)(VARIANT_BOOL pUseHTTPProxy) PURE;
713 STDMETHOD(get_EnableAutoProxy)(VARIANT_BOOL __RPC_FAR *pEnableAutoProxy) PURE;
714 STDMETHOD(put_EnableAutoProxy)(VARIANT_BOOL pEnableAutoProxy) PURE;
715 STDMETHOD(get_HTTPProxyHost)(BSTR __RPC_FAR *pbstrHTTPProxyHost) PURE;
716 STDMETHOD(put_HTTPProxyHost)(BSTR pbstrHTTPProxyHost) PURE;
717 STDMETHOD(get_HTTPProxyPort)(long __RPC_FAR *pHTTPProxyPort) PURE;
718 STDMETHOD(put_HTTPProxyPort)(long pHTTPProxyPort) PURE;
719 STDMETHOD(get_EnableMulticast)(VARIANT_BOOL __RPC_FAR *pEnableMulticast) PURE;
720 STDMETHOD(put_EnableMulticast)(VARIANT_BOOL pEnableMulticast) PURE;
721 STDMETHOD(get_EnableUDP)(VARIANT_BOOL __RPC_FAR *pEnableUDP) PURE;
722 STDMETHOD(put_EnableUDP)(VARIANT_BOOL pEnableUDP) PURE;
723 STDMETHOD(get_EnableTCP)(VARIANT_BOOL __RPC_FAR *pEnableTCP) PURE;
724 STDMETHOD(put_EnableTCP)(VARIANT_BOOL pEnableTCP) PURE;
725 STDMETHOD(get_EnableHTTP)(VARIANT_BOOL __RPC_FAR *pEnableHTTP) PURE;
726 STDMETHOD(put_EnableHTTP)(VARIANT_BOOL pEnableHTTP) PURE;
727 STDMETHOD(get_BufferingProgress)(long __RPC_FAR *pBufferingProgress) PURE;
728 STDMETHOD(get_BaseURL)(BSTR __RPC_FAR *pbstrBaseURL) PURE;
729 STDMETHOD(put_BaseURL)(BSTR pbstrBaseURL) PURE;
730 STDMETHOD(get_DefaultFrame)(BSTR __RPC_FAR *pbstrDefaultFrame) PURE;
731 STDMETHOD(put_DefaultFrame)(BSTR pbstrDefaultFrame) PURE;
732 STDMETHOD(AboutBox))(void) PURE;
733 STDMETHOD(Cancel)(void) PURE;
734 STDMETHOD(GetCodecInstalled)(long CodecNum, VARIANT_BOOL __RPC_FAR *pCodecInstalled) PURE;
735 STDMETHOD(GetCodecDescription)(long CodecNum, BSTR __RPC_FAR *pbstrCodecDescription) PURE;
736 STDMETHOD(GetCodecURL)(long CodecNum, BSTR __RPC_FAR *pbstrCodecURL) PURE;
737 STDMETHOD(Open)(BSTR bstrFileName) PURE;
738 };
739
740
741 struct INSPlay1 : public INSPlay
742 {
743 STDMETHOD(get_MediaPlayer)(IDispatch __RPC_FAR *__RPC_FAR *ppdispatch) PURE;
744 };
745
746 //---------------------------------------------------------------------------
747 // IWMP (PocketPC 2000) COM INTERFACES (dumped from PlayerOCX.idl)
748 //---------------------------------------------------------------------------
749
750 struct IWMP : public IDispatch
751 {
752 public:
753 virtual /* [id][propput] */ HRESULT STDMETHODCALLTYPE put_AutoSize(
754 /* [in] */ VARIANT_BOOL vbool) = 0;
755
756 virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_AutoSize(
757 /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pbool) = 0;
758
759 virtual /* [id][propput] */ HRESULT STDMETHODCALLTYPE put_BorderStyle(
760 /* [in] */ long style) = 0;
761
762 virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_BorderStyle(
763 /* [retval][out] */ long __RPC_FAR *pstyle) = 0;
764
765 virtual /* [id][propput] */ HRESULT STDMETHODCALLTYPE put_Enabled(
766 /* [in] */ VARIANT_BOOL vbool) = 0;
767
768 virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_Enabled(
769 /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pbool) = 0;
770
771 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_FileName(
772 /* [retval][out] */ BSTR __RPC_FAR *pVal) = 0;
773
774 virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_FileName(
775 /* [in] */ BSTR newVal) = 0;
776
777 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_Volume(
778 /* [retval][out] */ long __RPC_FAR *pVal) = 0;
779
780 virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_Volume(
781 /* [in] */ long newVal) = 0;
782
783 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_Mute(
784 /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
785
786 virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_Mute(
787 /* [in] */ VARIANT_BOOL newVal) = 0;
788
789 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_AutoStart(
790 /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
791
792 virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_AutoStart(
793 /* [in] */ VARIANT_BOOL newVal) = 0;
794
795 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_PlayCount(
796 /* [retval][out] */ long __RPC_FAR *pVal) = 0;
797
798 virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_PlayCount(
799 /* [in] */ long newVal) = 0;
800
801 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_ShowStatusBar(
802 /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
803
804 virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_ShowStatusBar(
805 /* [in] */ VARIANT_BOOL newVal) = 0;
806
807 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_ShowAudioControls(
808 /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
809
810 virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_ShowAudioControls(
811 /* [in] */ VARIANT_BOOL newVal) = 0;
812
813 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_ShowCaptioning(
814 /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
815
816 virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_ShowCaptioning(
817 /* [in] */ VARIANT_BOOL newVal) = 0;
818
819 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_ShowControls(
820 /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
821
822 virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_ShowControls(
823 /* [in] */ VARIANT_BOOL newVal) = 0;
824
825 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_ShowDisplay(
826 /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
827
828 virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_ShowDisplay(
829 /* [in] */ VARIANT_BOOL newVal) = 0;
830
831 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_ShowGotoBar(
832 /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
833
834 virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_ShowGotoBar(
835 /* [in] */ VARIANT_BOOL newVal) = 0;
836
837 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_ShowPositionControls(
838 /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
839
840 virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_ShowPositionControls(
841 /* [in] */ VARIANT_BOOL newVal) = 0;
842
843 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_ShowTracker(
844 /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
845
846 virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_ShowTracker(
847 /* [in] */ VARIANT_BOOL newVal) = 0;
848
849 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE Startup( void ) = 0;
850
851 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE Shutdown( void ) = 0;
852
853 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_Bandwidth(
854 /* [retval][out] */ long __RPC_FAR *pVal) = 0;
855
856 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_BaseURL(
857 /* [retval][out] */ BSTR __RPC_FAR *pVal) = 0;
858
859 virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_BaseURL(
860 /* [in] */ BSTR pVal) = 0;
861
862 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_BufferingCount(
863 /* [retval][out] */ long __RPC_FAR *pVal) = 0;
864
865 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_BufferingProgress(
866 /* [retval][out] */ long __RPC_FAR *pVal) = 0;
867
868 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_BufferingTime(
869 /* [retval][out] */ double __RPC_FAR *pVal) = 0;
870
871 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_CanSeek(
872 /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
873
874 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_CanSeekToMarkers(
875 /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
876
877 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_ChannelDescription(
878 /* [retval][out] */ BSTR __RPC_FAR *pVal) = 0;
879
880 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_ChannelName(
881 /* [retval][out] */ BSTR __RPC_FAR *pVal) = 0;
882
883 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_ChannelURL(
884 /* [retval][out] */ BSTR __RPC_FAR *pVal) = 0;
885
886 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_ClientID(
887 /* [retval][out] */ BSTR __RPC_FAR *pVal) = 0;
888
889 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_ConnectionSpeed(
890 /* [retval][out] */ long __RPC_FAR *pVal) = 0;
891
892 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_ContactAddress(
893 /* [retval][out] */ BSTR __RPC_FAR *pVal) = 0;
894
895 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_ContactEmail(
896 /* [retval][out] */ BSTR __RPC_FAR *pVal) = 0;
897
898 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_ContactPhone(
899 /* [retval][out] */ BSTR __RPC_FAR *pVal) = 0;
900
901 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_CurrentMarker(
902 /* [retval][out] */ long __RPC_FAR *pVal) = 0;
903
904 virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_CurrentMarker(
905 /* [in] */ long newVal) = 0;
906
907 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_CurrentPosition(
908 /* [retval][out] */ double __RPC_FAR *pVal) = 0;
909
910 virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_CurrentPosition(
911 /* [in] */ double newVal) = 0;
912
913 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_DefaultFrame(
914 /* [retval][out] */ BSTR __RPC_FAR *pVal) = 0;
915
916 virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_DefaultFrame(
917 /* [in] */ BSTR newVal) = 0;
918
919 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_Duration(
920 /* [retval][out] */ double __RPC_FAR *pVal) = 0;
921
922 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_EntryCount(
923 /* [retval][out] */ long __RPC_FAR *pVal) = 0;
924
925 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_ErrorCode(
926 /* [retval][out] */ long __RPC_FAR *pVal) = 0;
927
928 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_ErrorDescription(
929 /* [retval][out] */ BSTR __RPC_FAR *pVal) = 0;
930
931 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_HasError(
932 /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
933
934 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_HasMultipleItems(
935 /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
936
937 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_ImageSourceHeight(
938 /* [retval][out] */ long __RPC_FAR *pVal) = 0;
939
940 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_ImageSourceWidth(
941 /* [retval][out] */ long __RPC_FAR *pVal) = 0;
942
943 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_InvokeURLs(
944 /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
945
946 virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_InvokeURLs(
947 /* [in] */ VARIANT_BOOL newVal) = 0;
948
949 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_IsBroadcast(
950 /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
951
952 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_IsDurationValid(
953 /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
954
955 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_LostPackets(
956 /* [retval][out] */ long __RPC_FAR *pVal) = 0;
957
958 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_MarkerCount(
959 /* [retval][out] */ long __RPC_FAR *pVal) = 0;
960
961 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_OpenState(
962 /* [retval][out] */ long __RPC_FAR *pVal) = 0;
963
964 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_PlayState(
965 /* [retval][out] */ long __RPC_FAR *pVal) = 0;
966
967 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_PreviewMode(
968 /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
969
970 virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_PreviewMode(
971 /* [in] */ VARIANT_BOOL newVal) = 0;
972
973 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_ReadyState(
974 /* [retval][out] */ long __RPC_FAR *pVal) = 0;
975
976 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_ReceivedPackets(
977 /* [retval][out] */ long __RPC_FAR *pVal) = 0;
978
979 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_ReceptionQuality(
980 /* [retval][out] */ long __RPC_FAR *pVal) = 0;
981
982 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_RecoveredPackets(
983 /* [retval][out] */ long __RPC_FAR *pVal) = 0;
984
985 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_SAMIFileName(
986 /* [retval][out] */ BSTR __RPC_FAR *pVal) = 0;
987
988 virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_SAMIFileName(
989 /* [in] */ BSTR newVal) = 0;
990
991 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_SAMILang(
992 /* [retval][out] */ BSTR __RPC_FAR *pVal) = 0;
993
994 virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_SAMILang(
995 /* [in] */ BSTR newVal) = 0;
996
997 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_SAMIStyle(
998 /* [retval][out] */ BSTR __RPC_FAR *pVal) = 0;
999
1000 virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_SAMIStyle(
1001 /* [in] */ BSTR newVal) = 0;
1002
1003 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_SelectionEnd(
1004 /* [retval][out] */ double __RPC_FAR *pVal) = 0;
1005
1006 virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_SelectionEnd(
1007 /* [in] */ double newVal) = 0;
1008
1009 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_SelectionStart(
1010 /* [retval][out] */ double __RPC_FAR *pVal) = 0;
1011
1012 virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_SelectionStart(
1013 /* [in] */ double newVal) = 0;
1014
1015 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_SendErrorEvents(
1016 /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
1017
1018 virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_SendErrorEvents(
1019 /* [in] */ VARIANT_BOOL newVal) = 0;
1020
1021 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_SendKeyboardEvents(
1022 /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
1023
1024 virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_SendKeyboardEvents(
1025 /* [in] */ VARIANT_BOOL newVal) = 0;
1026
1027 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_SendMouseClickEvents(
1028 /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
1029
1030 virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_SendMouseClickEvents(
1031 /* [in] */ VARIANT_BOOL newVal) = 0;
1032
1033 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_SendMouseMoveEvents(
1034 /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
1035
1036 virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_SendMouseMoveEvents(
1037 /* [in] */ VARIANT_BOOL newVal) = 0;
1038
1039 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_SendOpenStateChangeEvents(
1040 /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
1041
1042 virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_SendOpenStateChangeEvents(
1043 /* [in] */ VARIANT_BOOL newVal) = 0;
1044
1045 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_SendPlayStateChangeEvents(
1046 /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
1047
1048 virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_SendPlayStateChangeEvents(
1049 /* [in] */ VARIANT_BOOL newVal) = 0;
1050
1051 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_SendWarningEvents(
1052 /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
1053
1054 virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_SendWarningEvents(
1055 /* [in] */ VARIANT_BOOL newVal) = 0;
1056
1057 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_SourceLink(
1058 /* [retval][out] */ BSTR __RPC_FAR *pVal) = 0;
1059
1060 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE AboutBox( void) = 0;
1061
1062 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE Cancel( void) = 0;
1063
1064 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE GetCodecDescription(
1065 /* [in] */ long nCodec,
1066 /* [retval][out] */ BSTR __RPC_FAR *pDescription) = 0;
1067
1068 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE GetCodecInstalled(
1069 /* [in] */ BSTR __RPC_FAR *pstrCodec,
1070 /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pIsInstalled) = 0;
1071
1072 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE GetCurrentEntry(
1073 /* [retval][out] */ long __RPC_FAR *pVal) = 0;
1074
1075 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE GetMarkerName(
1076 /* [in] */ long nMarker,
1077 /* [retval][out] */ BSTR __RPC_FAR *pMarkerName) = 0;
1078
1079 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE GetMarkerTime(
1080 /* [in] */ long nMarker,
1081 /* [retval][out] */ double __RPC_FAR *pMarkerTime) = 0;
1082
1083 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE GetMediaInfoString(
1084 /* [in] */ long MPMediaInfoType,
1085 /* [retval][out] */ BSTR __RPC_FAR *pstrMediaInfo) = 0;
1086
1087 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE Next( void) = 0;
1088
1089 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE Open(
1090 BSTR pstrClip) = 0;
1091
1092 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE Pause( void) = 0;
1093
1094 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE Play( void) = 0;
1095
1096 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE Previous( void) = 0;
1097
1098 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE Stop( void) = 0;
1099
1100 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_Rate(
1101 /* [retval][out] */ double __RPC_FAR *pVal) = 0;
1102
1103 virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_Rate(
1104 /* [in] */ double newVal) = 0;
1105
1106 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_DisplaySize(
1107 /* [retval][out] */ long __RPC_FAR *pVal) = 0;
1108
1109 virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_DisplaySize(
1110 /* [in] */ long newVal) = 0;
1111
1112 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_SourceProtocol(
1113 /* [retval][out] */ long __RPC_FAR *pVal) = 0;
1114
1115 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_ErrorCorrection(
1116 /* [retval][out] */ BSTR __RPC_FAR *pVal) = 0;
1117
1118 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE FinalConstruct( void) = 0;
1119
1120 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_AllowChangeDisplaySize(
1121 /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
1122
1123 virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_AllowChangeDisplaySize(
1124 /* [in] */ VARIANT_BOOL newVal) = 0;
1125
1126 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_AllowScan(
1127 /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
1128
1129 virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_AllowScan(
1130 /* [in] */ VARIANT_BOOL newVal) = 0;
1131
1132 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_AnimationAtStart(
1133 /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
1134
1135 virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_AnimationAtStart(
1136 /* [in] */ VARIANT_BOOL newVal) = 0;
1137
1138 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_AudioStream(
1139 /* [retval][out] */ long __RPC_FAR *pVal) = 0;
1140
1141 virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_AudioStream(
1142 /* [in] */ long newVal) = 0;
1143
1144 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_AutoRewind(
1145 /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
1146
1147 virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_AutoRewind(
1148 /* [in] */ VARIANT_BOOL newVal) = 0;
1149
1150 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_Balance(
1151 /* [retval][out] */ long __RPC_FAR *pVal) = 0;
1152
1153 virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_Balance(
1154 /* [in] */ long newVal) = 0;
1155
1156 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_CanPreview(
1157 /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
1158
1159 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_CanScan(
1160 /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
1161
1162 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_CaptioningID(
1163 /* [retval][out] */ BSTR __RPC_FAR *pVal) = 0;
1164
1165 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_ClickToPlay(
1166 /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
1167
1168 virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_ClickToPlay(
1169 /* [in] */ VARIANT_BOOL newVal) = 0;
1170
1171 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_CodecCount(
1172 /* [retval][out] */ long __RPC_FAR *pVal) = 0;
1173
1174 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_CreationDate(
1175 /* [retval][out] */ DATE __RPC_FAR *pVal) = 0;
1176
1177 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_CursorType(
1178 /* [retval][out] */ long __RPC_FAR *pVal) = 0;
1179
1180 virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_CursorType(
1181 /* [in] */ long newVal) = 0;
1182
1183 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_DisplayBackColor(
1184 /* [retval][out] */ VB_OLE_COLOR __RPC_FAR *pVal) = 0;
1185
1186 virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_DisplayBackColor(
1187 /* [in] */ VB_OLE_COLOR newVal) = 0;
1188
1189 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_DisplayForeColor(
1190 /* [retval][out] */ VB_OLE_COLOR __RPC_FAR *pVal) = 0;
1191
1192 virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_DisplayForeColor(
1193 /* [in] */ VB_OLE_COLOR newVal) = 0;
1194
1195 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_DisplayMode(
1196 /* [retval][out] */ long __RPC_FAR *pVal) = 0;
1197
1198 virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_DisplayMode(
1199 /* [in] */ long newVal) = 0;
1200
1201 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_EnableContextMenu(
1202 /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
1203
1204 virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_EnableContextMenu(
1205 /* [in] */ VARIANT_BOOL newVal) = 0;
1206
1207 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_EnableFullScreenControls(
1208 /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
1209
1210 virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_EnableFullScreenControls(
1211 /* [in] */ VARIANT_BOOL newVal) = 0;
1212
1213 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_EnablePositionControls(
1214 /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
1215
1216 virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_EnablePositionControls(
1217 /* [in] */ VARIANT_BOOL newVal) = 0;
1218
1219 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_EnableTracker(
1220 /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
1221
1222 virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_EnableTracker(
1223 /* [in] */ VARIANT_BOOL newVal) = 0;
1224
1225 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_Language(
1226 /* [retval][out] */ long __RPC_FAR *pVal) = 0;
1227
1228 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_StreamCount(
1229 /* [retval][out] */ long __RPC_FAR *pVal) = 0;
1230
1231 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_TransparentAtStart(
1232 /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
1233
1234 virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_TransparentAtStart(
1235 /* [in] */ VARIANT_BOOL newVal) = 0;
1236
1237 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_VideoBorder3D(
1238 /* [retval][out] */ VARIANT_BOOL __RPC_FAR *pVal) = 0;
1239
1240 virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_VideoBorder3D(
1241 /* [in] */ VARIANT_BOOL newVal) = 0;
1242
1243 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_VideoBorderColor(
1244 /* [retval][out] */ long __RPC_FAR *pVal) = 0;
1245
1246 virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_VideoBorderColor(
1247 /* [in] */ long newVal) = 0;
1248
1249 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_VideoBorderWidth(
1250 /* [retval][out] */ long __RPC_FAR *pVal) = 0;
1251
1252 virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_VideoBorderWidth(
1253 /* [in] */ long newVal) = 0;
1254
1255 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE FastForward( void) = 0;
1256
1257 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE FastReverse( void) = 0;
1258
1259 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE GetCodecURL(
1260 /* [retval][out] */ BSTR __RPC_FAR *pstrCodecURL) = 0;
1261
1262 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE GetMediaParameter(
1263 /* [in] */ long nParam,
1264 BSTR szParameterName,
1265 /* [retval][out] */ BSTR __RPC_FAR *pstrParameterValue) = 0;
1266
1267 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE GetMediaParameterName(
1268 /* [in] */ long nParam,
1269 long nIndex,
1270 /* [retval][out] */ BSTR __RPC_FAR *pstrParameterName) = 0;
1271
1272 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE GetMoreInfoURL(
1273 /* [retval][out] */ BSTR __RPC_FAR *pstrMoreInfoURL) = 0;
1274
1275 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE GetStreamGroup(
1276 /* [retval][out] */ BSTR __RPC_FAR *pstrStreamGroup) = 0;
1277
1278 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE GetStreamName(
1279 /* [retval][out] */ BSTR __RPC_FAR *pstrStreamName) = 0;
1280
1281 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE GetStreamSelected(
1282 /* [in] */ long nStream,
1283 /* [retval][out] */ VARIANT_BOOL __RPC_FAR *fIsSelected) = 0;
1284
1285 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE IsSoundCardEnabled(
1286 /* [retval][out] */ VARIANT_BOOL __RPC_FAR *fIsEnabled) = 0;
1287
1288 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE SetCurrentEntry(
1289 long nValue) = 0;
1290
1291 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE ShowDialog(
1292 long nValue) = 0;
1293
1294 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE StreamSelect(
1295 long nSelect) = 0;
1296
1297 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE OnWindowMessage(
1298 UINT msg,
1299 WPARAM wParam,
1300 LPARAM lParam,
1301 LRESULT __RPC_FAR *plResult) = 0;
1302 };
1303
1304 //---------------------------------------------------------------------------
1305 // MISC COM INTERFACES
1306 //---------------------------------------------------------------------------
1307 typedef enum _FilterState
1308 {
1309 State_Stopped,
1310 State_Paused,
1311 State_Running
1312 }
1313 FILTER_STATE;
1314
1315 typedef enum _PinDirection
1316 {
1317 PINDIR_INPUT,
1318 PINDIR_OUTPUT
1319 }
1320 PIN_DIRECTION;
1321
1322 typedef struct _FilterInfo
1323 {
1324 WCHAR achName[128];
1325 struct IFilterGraph *pGraph;
1326 }
1327 FILTER_INFO;
1328
1329 typedef struct _PinInfo
1330 {
1331 struct IBaseFilter *pFilter;
1332 PIN_DIRECTION dir;
1333 WCHAR achName[128];
1334 }
1335 PIN_INFO;
1336
1337 struct IBaseFilter;
1338 struct IPin;
1339 struct IEnumFilters;
1340 typedef struct _MediaType
1341 {
1342 GUID majortype;
1343 GUID subtype;
1344 BOOL bFixedSizeSamples;
1345 BOOL bTemporalCompression;
1346 ULONG lSampleSize;
1347 GUID formattype;
1348 IUnknown *pUnk;
1349 ULONG cbFormat;
1350 BYTE *pbFormat;
1351 }
1352 AM_MEDIA_TYPE;
1353
1354 struct IFilterGraph : public IUnknown
1355 {
1356 STDMETHOD(AddFilter)(IBaseFilter *, LPCWSTR) PURE;
1357 STDMETHOD(RemoveFilter)(IBaseFilter *) PURE;
1358 STDMETHOD(EnumFilters)(IEnumFilters **) PURE;
1359 STDMETHOD(FindFilterByName)(LPCWSTR, IBaseFilter **) PURE;
1360 STDMETHOD(ConnectDirect)(IPin *, IPin *, const AM_MEDIA_TYPE *) PURE;
1361 STDMETHOD(Reconnect)(IPin *) PURE;
1362 STDMETHOD(Disconnect)(IPin *) PURE;
1363 STDMETHOD(SetDefaultSyncSource)() PURE;
1364 };
1365
1366 struct IGraphBuilder : public IFilterGraph
1367 {
1368 STDMETHOD(Connect)(IPin *, IPin *) PURE;
1369 STDMETHOD(Render)(IPin *) PURE;
1370 STDMETHOD(RenderFile)(LPCWSTR, LPCWSTR) PURE;
1371 STDMETHOD(AddSourceFilter)(LPCWSTR, LPCWSTR, IBaseFilter **) PURE;
1372 STDMETHOD(SetLogFile)(DWORD_PTR) PURE;
1373 STDMETHOD(Abort)() PURE;
1374 STDMETHOD(ShouldOperationContinue)() PURE;
1375 };
1376
1377 struct IReferenceClock;
1378 struct IEnumPins;
1379 #define REFERENCE_TIME LONGLONG
1380 struct IMediaFilter : public IPersist
1381 {
1382 STDMETHOD(Stop)( void) PURE;
1383 STDMETHOD(Pause)( void) PURE;
1384 STDMETHOD(Run)(REFERENCE_TIME tStart) PURE;
1385 STDMETHOD(GetState)(DWORD dwMilliSecsTimeout,
1386 FILTER_STATE *State) PURE;
1387 STDMETHOD(SetSyncSource)(IReferenceClock *pClock) PURE;
1388 STDMETHOD(GetSyncSource)(IReferenceClock **pClock) PURE;
1389 };
1390
1391 struct IBaseFilter : public IMediaFilter
1392 {
1393 STDMETHOD(EnumPins)(IEnumPins **ppEnum) PURE;
1394 STDMETHOD(FindPin)(LPCWSTR Id, IPin **ppPin) PURE;
1395 STDMETHOD(QueryFilterInfo)(FILTER_INFO *pInfo) PURE;
1396 STDMETHOD(JoinFilterGraph)(IFilterGraph *pGraph, LPCWSTR pName) PURE;
1397 STDMETHOD(QueryVendorInfo)(LPWSTR *pVendorInfo) PURE;
1398 };
1399
1400
1401 //---------------------------------------------------------------------------
1402 // wxAMMediaBackend
1403 //---------------------------------------------------------------------------
1404
1405 typedef BOOL (WINAPI* LPAMGETERRORTEXT)(HRESULT, wxChar *, DWORD);
1406
1407 class WXDLLIMPEXP_MEDIA wxAMMediaBackend : public wxMediaBackendCommonBase
1408 {
1409 public:
1410 wxAMMediaBackend();
1411 virtual ~wxAMMediaBackend();
1412 void Clear();
1413
1414 virtual bool CreateControl(wxControl* ctrl, wxWindow* parent,
1415 wxWindowID id,
1416 const wxPoint& pos,
1417 const wxSize& size,
1418 long style,
1419 const wxValidator& validator,
1420 const wxString& name);
1421
1422 virtual bool Play();
1423 virtual bool Pause();
1424 virtual bool Stop();
1425
1426 virtual bool Load(const wxString& fileName);
1427 virtual bool Load(const wxURI& location);
1428 virtual bool Load(const wxURI& location, const wxURI& proxy);
1429
1430 bool DoLoad(const wxString& location);
1431 void FinishLoad();
1432
1433 virtual wxMediaState GetState();
1434
1435 virtual bool SetPosition(wxLongLong where);
1436 virtual wxLongLong GetPosition();
1437 virtual wxLongLong GetDuration();
1438
1439 virtual void Move(int x, int y, int w, int h);
1440 wxSize GetVideoSize() const;
1441
1442 virtual double GetPlaybackRate();
1443 virtual bool SetPlaybackRate(double);
1444
1445 virtual double GetVolume();
1446 virtual bool SetVolume(double);
1447
1448 virtual bool ShowPlayerControls(wxMediaCtrlPlayerControls flags);
1449 void Cleanup();
1450
1451 void DoGetDownloadProgress(wxLongLong*, wxLongLong*);
1452
1453 virtual wxLongLong GetDownloadProgress()
1454 {
1455 wxLongLong progress, total;
1456 DoGetDownloadProgress(&progress, &total);
1457 return progress;
1458 }
1459
1460 virtual wxLongLong GetDownloadTotal()
1461 {
1462 wxLongLong progress, total;
1463 DoGetDownloadProgress(&progress, &total);
1464 return total;
1465 }
1466
1467 // WinCE helpers
1468
1469 wxActiveXContainer* m_pAX;
1470
1471 #ifdef __WXWINCE__
1472 IWMP* m_pWMP;
1473
1474 IWMP* GetMP() { return m_pWMP; }
1475 IWMP* GetAM() { return m_pWMP; }
1476 #else
1477 IActiveMovie* m_pAM;
1478 IMediaPlayer* m_pMP;
1479
1480 IMediaPlayer* GetMP() { return m_pMP; }
1481 IActiveMovie* GetAM() { return m_pAM; }
1482 #endif
1483
1484 wxTimer* m_pTimer;
1485 wxSize m_bestSize;
1486
1487 #ifdef __WXDEBUG__
1488 wxDynamicLibrary m_dllQuartz;
1489 LPAMGETERRORTEXT m_lpAMGetErrorText;
1490 wxString GetErrorString(HRESULT hrdsv);
1491 #endif
1492
1493 DECLARE_DYNAMIC_CLASS(wxAMMediaBackend)
1494 };
1495
1496 //---------------------------------------------------------------------------
1497 // wxMCIMediaBackend
1498 //---------------------------------------------------------------------------
1499
1500 //---------------------------------------------------------------------------
1501 // MCI Includes
1502 //---------------------------------------------------------------------------
1503 #ifndef __WXWINCE__
1504 #include <mmsystem.h>
1505
1506 class WXDLLIMPEXP_MEDIA wxMCIMediaBackend : public wxMediaBackendCommonBase
1507 {
1508 public:
1509 wxMCIMediaBackend();
1510 virtual ~wxMCIMediaBackend();
1511
1512 virtual bool CreateControl(wxControl* ctrl, wxWindow* parent,
1513 wxWindowID id,
1514 const wxPoint& pos,
1515 const wxSize& size,
1516 long style,
1517 const wxValidator& validator,
1518 const wxString& name);
1519
1520 virtual bool Play();
1521 virtual bool Pause();
1522 virtual bool Stop();
1523
1524 virtual bool Load(const wxURI& location,
1525 const wxURI& proxy)
1526 { return wxMediaBackend::Load(location, proxy); }
1527
1528 virtual bool Load(const wxString& fileName);
1529 virtual bool Load(const wxURI& location);
1530
1531 virtual wxMediaState GetState();
1532
1533 virtual bool SetPosition(wxLongLong where);
1534 virtual wxLongLong GetPosition();
1535 virtual wxLongLong GetDuration();
1536
1537 virtual void Move(int x, int y, int w, int h);
1538 wxSize GetVideoSize() const;
1539
1540 virtual double GetPlaybackRate();
1541 virtual bool SetPlaybackRate(double dRate);
1542
1543 virtual double GetVolume();
1544 virtual bool SetVolume(double);
1545
1546 static LRESULT CALLBACK NotifyWndProc(HWND hWnd, UINT nMsg,
1547 WPARAM wParam, LPARAM lParam);
1548
1549 LRESULT CALLBACK OnNotifyWndProc(HWND hWnd, UINT nMsg,
1550 WPARAM wParam, LPARAM lParam);
1551
1552 MCIDEVICEID m_hDev; //Our MCI Device ID/Handler
1553 HWND m_hNotifyWnd; //Window to use for MCI events
1554 bool m_bVideo; //Whether or not we have video
1555
1556 DECLARE_DYNAMIC_CLASS(wxMCIMediaBackend)
1557 };
1558 #endif
1559
1560 //---------------------------------------------------------------------------
1561 // wxQTMediaBackend
1562 //
1563 // We don't include Quicktime headers here and define all the types
1564 // ourselves because looking for the quicktime libaries etc. would
1565 // be tricky to do and making this a dependency for the MSVC projects
1566 // would be unrealistic.
1567 //
1568 // Thanks to Robert Roebling for the wxDL macro/library idea
1569 //---------------------------------------------------------------------------
1570
1571 //---------------------------------------------------------------------------
1572 // QT Includes
1573 //---------------------------------------------------------------------------
1574 //#include <qtml.h> // Windoze QT include
1575 //#include <QuickTimeComponents.h> // Standard QT stuff
1576 #include "wx/dynlib.h"
1577
1578 //---------------------------------------------------------------------------
1579 // QT Types
1580 //---------------------------------------------------------------------------
1581 typedef struct MovieRecord* Movie;
1582 typedef wxInt16 OSErr;
1583 typedef wxInt32 OSStatus;
1584 #define noErr 0
1585 #define fsRdPerm 1
1586 typedef unsigned char Str255[256];
1587 #define StringPtr unsigned char*
1588 #define newMovieActive 1
1589 #define newMovieAsyncOK (1 << 8)
1590 #define Ptr char*
1591 #define Handle Ptr*
1592 #define Fixed long
1593 #define OSType unsigned long
1594 #define CGrafPtr struct GrafPort *
1595 #define TimeScale long
1596 #define TimeBase struct TimeBaseRecord *
1597 typedef struct ComponentInstanceRecord * ComponentInstance;
1598 #define kMovieLoadStatePlayable 10000
1599 #define Boolean int
1600 #define MovieController ComponentInstance
1601
1602 #ifndef URLDataHandlerSubType
1603 #if defined(__WATCOMC__) || defined(__MINGW32__)
1604 // use magic numbers for compilers which complain about multicharacter integers
1605 const OSType URLDataHandlerSubType = 1970433056;
1606 const OSType VisualMediaCharacteristic = 1702454643;
1607 #else
1608 const OSType URLDataHandlerSubType = 'url ';
1609 const OSType VisualMediaCharacteristic = 'eyes';
1610 #endif
1611 #endif
1612
1613 struct FSSpec
1614 {
1615 short vRefNum;
1616 long parID;
1617 Str255 name; // Str63 on mac, Str255 on msw
1618 };
1619
1620 struct Rect
1621 {
1622 short top;
1623 short left;
1624 short bottom;
1625 short right;
1626 };
1627
1628 struct wide
1629 {
1630 wxInt32 hi;
1631 wxUint32 lo;
1632 };
1633
1634 struct TimeRecord
1635 {
1636 wide value; // units
1637 TimeScale scale; // units per second
1638 TimeBase base;
1639 };
1640
1641 struct Point
1642 {
1643 short v;
1644 short h;
1645 };
1646
1647 struct EventRecord
1648 {
1649 wxUint16 what;
1650 wxUint32 message;
1651 wxUint32 when;
1652 Point where;
1653 wxUint16 modifiers;
1654 };
1655
1656 enum
1657 {
1658 mcTopLeftMovie = 1,
1659 mcScaleMovieToFit = 2,
1660 mcWithBadge = 4,
1661 mcNotVisible = 8,
1662 mcWithFrame = 16
1663 };
1664
1665 //---------------------------------------------------------------------------
1666 // QT Library
1667 //---------------------------------------------------------------------------
1668
1669 class WXDLLIMPEXP_MEDIA wxQuickTimeLibrary
1670 {
1671 public:
1672 ~wxQuickTimeLibrary()
1673 {
1674 if (m_dll.IsLoaded())
1675 m_dll.Unload();
1676 }
1677
1678 bool Initialize();
1679 bool IsOk() const {return m_ok;}
1680
1681 protected:
1682 wxDynamicLibrary m_dll;
1683 bool m_ok;
1684
1685 public:
1686 wxDL_VOIDMETHOD_DEFINE( StartMovie, (Movie m), (m) );
1687 wxDL_VOIDMETHOD_DEFINE( StopMovie, (Movie m), (m) );
1688 wxDL_METHOD_DEFINE( bool, IsMovieDone, (Movie m), (m), false);
1689 wxDL_VOIDMETHOD_DEFINE( GoToBeginningOfMovie, (Movie m), (m) );
1690 wxDL_METHOD_DEFINE( OSErr, GetMoviesError, (), (), -1);
1691 wxDL_METHOD_DEFINE( OSErr, EnterMovies, (), (), -1);
1692 wxDL_VOIDMETHOD_DEFINE( ExitMovies, (), () );
1693 wxDL_METHOD_DEFINE( OSErr, InitializeQTML, (long flags), (flags), -1);
1694 wxDL_VOIDMETHOD_DEFINE( TerminateQTML, (), () );
1695
1696 wxDL_METHOD_DEFINE( OSErr, NativePathNameToFSSpec,
1697 (char* inName, FSSpec* outFile, long flags),
1698 (inName, outFile, flags), -1);
1699
1700 wxDL_METHOD_DEFINE( OSErr, OpenMovieFile,
1701 (const FSSpec * fileSpec, short * resRefNum, wxInt8 permission),
1702 (fileSpec, resRefNum, permission), -1 );
1703
1704 wxDL_METHOD_DEFINE( OSErr, CloseMovieFile,
1705 (short resRefNum), (resRefNum), -1);
1706
1707 wxDL_METHOD_DEFINE( OSErr, NewMovieFromFile,
1708 (Movie * theMovie, short resRefNum, short * resId,
1709 StringPtr resName, short newMovieFlags,
1710 bool * dataRefWasChanged),
1711 (theMovie, resRefNum, resId, resName, newMovieFlags,
1712 dataRefWasChanged), -1);
1713
1714 wxDL_VOIDMETHOD_DEFINE( SetMovieRate, (Movie m, Fixed rate), (m, rate) );
1715 wxDL_METHOD_DEFINE( Fixed, GetMovieRate, (Movie m), (m), 0);
1716 wxDL_VOIDMETHOD_DEFINE( MoviesTask, (Movie m, long maxms), (m, maxms) );
1717 wxDL_VOIDMETHOD_DEFINE( BlockMove,
1718 (const char* p1, const char* p2, long s), (p1,p2,s) );
1719 wxDL_METHOD_DEFINE( Handle, NewHandleClear, (long s), (s), NULL );
1720
1721 wxDL_METHOD_DEFINE( OSErr, NewMovieFromDataRef,
1722 (Movie * m, short flags, short * id,
1723 Handle dataRef, OSType dataRefType),
1724 (m,flags,id,dataRef,dataRefType), -1 );
1725
1726 wxDL_VOIDMETHOD_DEFINE( DisposeHandle, (Handle h), (h) );
1727 wxDL_VOIDMETHOD_DEFINE( GetMovieNaturalBoundsRect, (Movie m, Rect* r), (m,r) );
1728 wxDL_METHOD_DEFINE( void*, GetMovieIndTrackType,
1729 (Movie m, long index, OSType type, long flags),
1730 (m,index,type,flags), NULL );
1731 wxDL_VOIDMETHOD_DEFINE( CreatePortAssociation,
1732 (void* hWnd, void* junk, long morejunk), (hWnd, junk, morejunk) );
1733 wxDL_METHOD_DEFINE(void*, GetNativeWindowPort, (void* hWnd), (hWnd), NULL);
1734 wxDL_VOIDMETHOD_DEFINE(SetMovieGWorld, (Movie m, CGrafPtr port, void* whatever),
1735 (m, port, whatever) );
1736 wxDL_VOIDMETHOD_DEFINE(DisposeMovie, (Movie m), (m) );
1737 wxDL_VOIDMETHOD_DEFINE(SetMovieBox, (Movie m, Rect* r), (m,r));
1738 wxDL_VOIDMETHOD_DEFINE(SetMovieTimeScale, (Movie m, long s), (m,s));
1739 wxDL_METHOD_DEFINE(long, GetMovieDuration, (Movie m), (m), 0);
1740 wxDL_METHOD_DEFINE(TimeBase, GetMovieTimeBase, (Movie m), (m), 0);
1741 wxDL_METHOD_DEFINE(TimeScale, GetMovieTimeScale, (Movie m), (m), 0);
1742 wxDL_METHOD_DEFINE(long, GetMovieTime, (Movie m, void* cruft), (m,cruft), 0);
1743 wxDL_VOIDMETHOD_DEFINE(SetMovieTime, (Movie m, TimeRecord* tr), (m,tr) );
1744 wxDL_METHOD_DEFINE(short, GetMovieVolume, (Movie m), (m), 0);
1745 wxDL_VOIDMETHOD_DEFINE(SetMovieVolume, (Movie m, short sVolume), (m,sVolume) );
1746 wxDL_VOIDMETHOD_DEFINE(SetMovieTimeValue, (Movie m, long s), (m,s));
1747 wxDL_METHOD_DEFINE(ComponentInstance, NewMovieController, (Movie m, const Rect* mr, long fl), (m,mr,fl), 0);
1748 wxDL_VOIDMETHOD_DEFINE(DisposeMovieController, (ComponentInstance ci), (ci));
1749 wxDL_METHOD_DEFINE(int, MCSetVisible, (ComponentInstance m, int b), (m, b), 0);
1750
1751 wxDL_VOIDMETHOD_DEFINE(PrePrerollMovie, (Movie m, long t, Fixed r, WXFARPROC p1, void* p2), (m,t,r,p1,p2) );
1752 wxDL_VOIDMETHOD_DEFINE(PrerollMovie, (Movie m, long t, Fixed r), (m,t,r) );
1753 wxDL_METHOD_DEFINE(Fixed, GetMoviePreferredRate, (Movie m), (m), 0);
1754 wxDL_METHOD_DEFINE(long, GetMovieLoadState, (Movie m), (m), 0);
1755 wxDL_METHOD_DEFINE(void*, NewRoutineDescriptor, (WXFARPROC f, int l, void* junk), (f, l, junk), 0);
1756 wxDL_VOIDMETHOD_DEFINE(DisposeRoutineDescriptor, (void* f), (f));
1757 wxDL_METHOD_DEFINE(void*, GetCurrentArchitecture, (), (), 0);
1758 wxDL_METHOD_DEFINE(int, MCDoAction, (ComponentInstance ci, long f, void* p), (ci,f,p), 0);
1759 wxDL_VOIDMETHOD_DEFINE(MCSetControllerBoundsRect, (ComponentInstance ci, Rect* r), (ci,r));
1760 wxDL_VOIDMETHOD_DEFINE(DestroyPortAssociation, (CGrafPtr g), (g));
1761 wxDL_VOIDMETHOD_DEFINE(NativeEventToMacEvent, (MSG* p1, EventRecord* p2), (p1,p2));
1762 wxDL_VOIDMETHOD_DEFINE(MCIsPlayerEvent, (ComponentInstance ci, EventRecord* p2), (ci, p2));
1763 wxDL_METHOD_DEFINE(int, MCSetMovie, (ComponentInstance ci, Movie m, void* p1, Point w),
1764 (ci,m,p1,w),0);
1765 wxDL_VOIDMETHOD_DEFINE(MCPositionController,
1766 (ComponentInstance ci, Rect* r, void* junk, void* morejunk), (ci,r,junk,morejunk));
1767 wxDL_VOIDMETHOD_DEFINE(MCSetActionFilterWithRefCon,
1768 (ComponentInstance ci, WXFARPROC cb, void* ref), (ci,cb,ref));
1769 wxDL_VOIDMETHOD_DEFINE(MCGetControllerInfo, (MovieController mc, long* flags), (mc,flags));
1770 wxDL_VOIDMETHOD_DEFINE(BeginUpdate, (CGrafPtr port), (port));
1771 wxDL_VOIDMETHOD_DEFINE(UpdateMovie, (Movie m), (m));
1772 wxDL_VOIDMETHOD_DEFINE(EndUpdate, (CGrafPtr port), (port));
1773 wxDL_METHOD_DEFINE( OSErr, GetMoviesStickyError, (), (), -1);
1774 };
1775
1776 bool wxQuickTimeLibrary::Initialize()
1777 {
1778 m_ok = false;
1779
1780 // Turn off the wxDynamicLibrary logging as we're prepared to handle the
1781 // errors
1782 wxLogNull nolog;
1783
1784 if (!m_dll.Load(wxT("qtmlClient.dll")))
1785 {
1786 return false;
1787 }
1788
1789 wxDL_METHOD_LOAD( m_dll, StartMovie, m_ok );
1790 wxDL_METHOD_LOAD( m_dll, StopMovie, m_ok );
1791 wxDL_METHOD_LOAD( m_dll, IsMovieDone, m_ok );
1792 wxDL_METHOD_LOAD( m_dll, GoToBeginningOfMovie, m_ok );
1793 wxDL_METHOD_LOAD( m_dll, GetMoviesError, m_ok );
1794 wxDL_METHOD_LOAD( m_dll, EnterMovies, m_ok );
1795 wxDL_METHOD_LOAD( m_dll, ExitMovies, m_ok );
1796 wxDL_METHOD_LOAD( m_dll, InitializeQTML, m_ok );
1797 wxDL_METHOD_LOAD( m_dll, TerminateQTML, m_ok );
1798 wxDL_METHOD_LOAD( m_dll, NativePathNameToFSSpec, m_ok );
1799 wxDL_METHOD_LOAD( m_dll, OpenMovieFile, m_ok );
1800 wxDL_METHOD_LOAD( m_dll, CloseMovieFile, m_ok );
1801 wxDL_METHOD_LOAD( m_dll, NewMovieFromFile, m_ok );
1802 wxDL_METHOD_LOAD( m_dll, GetMovieRate, m_ok );
1803 wxDL_METHOD_LOAD( m_dll, SetMovieRate, m_ok );
1804 wxDL_METHOD_LOAD( m_dll, MoviesTask, m_ok );
1805 wxDL_METHOD_LOAD( m_dll, BlockMove, m_ok );
1806 wxDL_METHOD_LOAD( m_dll, NewHandleClear, m_ok );
1807 wxDL_METHOD_LOAD( m_dll, NewMovieFromDataRef, m_ok );
1808 wxDL_METHOD_LOAD( m_dll, DisposeHandle, m_ok );
1809 wxDL_METHOD_LOAD( m_dll, GetMovieNaturalBoundsRect, m_ok );
1810 wxDL_METHOD_LOAD( m_dll, GetMovieIndTrackType, m_ok );
1811 wxDL_METHOD_LOAD( m_dll, CreatePortAssociation, m_ok );
1812 wxDL_METHOD_LOAD( m_dll, DestroyPortAssociation, m_ok );
1813 wxDL_METHOD_LOAD( m_dll, GetNativeWindowPort, m_ok );
1814 wxDL_METHOD_LOAD( m_dll, SetMovieGWorld, m_ok );
1815 wxDL_METHOD_LOAD( m_dll, DisposeMovie, m_ok );
1816 wxDL_METHOD_LOAD( m_dll, SetMovieBox, m_ok );
1817 wxDL_METHOD_LOAD( m_dll, SetMovieTimeScale, m_ok );
1818 wxDL_METHOD_LOAD( m_dll, GetMovieDuration, m_ok );
1819 wxDL_METHOD_LOAD( m_dll, GetMovieTimeBase, m_ok );
1820 wxDL_METHOD_LOAD( m_dll, GetMovieTimeScale, m_ok );
1821 wxDL_METHOD_LOAD( m_dll, GetMovieTime, m_ok );
1822 wxDL_METHOD_LOAD( m_dll, SetMovieTime, m_ok );
1823 wxDL_METHOD_LOAD( m_dll, GetMovieVolume, m_ok );
1824 wxDL_METHOD_LOAD( m_dll, SetMovieVolume, m_ok );
1825 wxDL_METHOD_LOAD( m_dll, SetMovieTimeValue, m_ok );
1826 wxDL_METHOD_LOAD( m_dll, NewMovieController, m_ok );
1827 wxDL_METHOD_LOAD( m_dll, DisposeMovieController, m_ok );
1828 wxDL_METHOD_LOAD( m_dll, MCSetVisible, m_ok );
1829 wxDL_METHOD_LOAD( m_dll, PrePrerollMovie, m_ok );
1830 wxDL_METHOD_LOAD( m_dll, PrerollMovie, m_ok );
1831 wxDL_METHOD_LOAD( m_dll, GetMoviePreferredRate, m_ok );
1832 wxDL_METHOD_LOAD( m_dll, GetMovieLoadState, m_ok );
1833 wxDL_METHOD_LOAD( m_dll, MCDoAction, m_ok );
1834 wxDL_METHOD_LOAD( m_dll, MCSetControllerBoundsRect, m_ok );
1835 wxDL_METHOD_LOAD( m_dll, NativeEventToMacEvent, m_ok );
1836 wxDL_METHOD_LOAD( m_dll, MCIsPlayerEvent, m_ok );
1837 wxDL_METHOD_LOAD( m_dll, MCSetMovie, m_ok );
1838 wxDL_METHOD_LOAD( m_dll, MCSetActionFilterWithRefCon, m_ok );
1839 wxDL_METHOD_LOAD( m_dll, MCGetControllerInfo, m_ok );
1840 wxDL_METHOD_LOAD( m_dll, BeginUpdate, m_ok );
1841 wxDL_METHOD_LOAD( m_dll, UpdateMovie, m_ok );
1842 wxDL_METHOD_LOAD( m_dll, EndUpdate, m_ok );
1843 wxDL_METHOD_LOAD( m_dll, GetMoviesStickyError, m_ok );
1844
1845 m_ok = true;
1846
1847 return true;
1848 }
1849
1850 class WXDLLIMPEXP_MEDIA wxQTMediaBackend : public wxMediaBackendCommonBase
1851 {
1852 public:
1853 wxQTMediaBackend();
1854 virtual ~wxQTMediaBackend();
1855
1856 virtual bool CreateControl(wxControl* ctrl, wxWindow* parent,
1857 wxWindowID id,
1858 const wxPoint& pos,
1859 const wxSize& size,
1860 long style,
1861 const wxValidator& validator,
1862 const wxString& name);
1863
1864 virtual bool Play();
1865 virtual bool Pause();
1866 virtual bool Stop();
1867
1868 virtual bool Load(const wxURI& location,
1869 const wxURI& proxy)
1870 { return wxMediaBackend::Load(location, proxy); }
1871
1872 virtual bool Load(const wxString& fileName);
1873 virtual bool Load(const wxURI& location);
1874
1875 virtual wxMediaState GetState();
1876
1877 virtual bool SetPosition(wxLongLong where);
1878 virtual wxLongLong GetPosition();
1879 virtual wxLongLong GetDuration();
1880
1881 virtual void Move(int x, int y, int w, int h);
1882 wxSize GetVideoSize() const;
1883
1884 virtual double GetPlaybackRate();
1885 virtual bool SetPlaybackRate(double dRate);
1886
1887 virtual double GetVolume();
1888 virtual bool SetVolume(double);
1889
1890 void Cleanup();
1891 void FinishLoad();
1892
1893 static void PPRMProc (Movie theMovie, OSErr theErr, void* theRefCon);
1894
1895 // TODO: Last param actually long - does this work on 64bit machines?
1896 static Boolean MCFilterProc(MovieController theController,
1897 short action, void *params, LONG_PTR refCon);
1898
1899 static LRESULT CALLBACK QTWndProc(HWND, UINT, WPARAM, LPARAM);
1900
1901 virtual bool ShowPlayerControls(wxMediaCtrlPlayerControls flags);
1902
1903 wxSize m_bestSize; // Original movie size
1904 Movie m_movie; // QT Movie handle/instance
1905 bool m_bVideo; // Whether or not we have video
1906 bool m_bPlaying; // Whether or not movie is playing
1907 wxTimer* m_timer; // Load or Play timer
1908 wxQuickTimeLibrary m_lib; // DLL to load functions from
1909 ComponentInstance m_pMC; // Movie Controller
1910
1911 friend class wxQTMediaEvtHandler;
1912
1913 DECLARE_DYNAMIC_CLASS(wxQTMediaBackend)
1914 };
1915
1916 // helper to hijack background erasing for the QT window
1917 class WXDLLIMPEXP_MEDIA wxQTMediaEvtHandler : public wxEvtHandler
1918 {
1919 public:
1920 wxQTMediaEvtHandler(wxQTMediaBackend *qtb, WXHWND hwnd)
1921 {
1922 m_qtb = qtb;
1923 m_hwnd = hwnd;
1924
1925 m_qtb->m_ctrl->Connect(m_qtb->m_ctrl->GetId(),
1926 wxEVT_ERASE_BACKGROUND,
1927 wxEraseEventHandler(wxQTMediaEvtHandler::OnEraseBackground),
1928 NULL, this);
1929 }
1930
1931 void OnEraseBackground(wxEraseEvent& event);
1932
1933 private:
1934 wxQTMediaBackend *m_qtb;
1935 WXHWND m_hwnd;
1936
1937 DECLARE_NO_COPY_CLASS(wxQTMediaEvtHandler)
1938 };
1939
1940
1941 //===========================================================================
1942 // IMPLEMENTATION
1943 //===========================================================================
1944
1945 //---------------------------------------------------------------------------
1946 // wxAMMediaBackend
1947 //---------------------------------------------------------------------------
1948
1949 IMPLEMENT_DYNAMIC_CLASS(wxAMMediaBackend, wxMediaBackend)
1950
1951 //---------------------------------------------------------------------------
1952 // Usual debugging macros
1953 //---------------------------------------------------------------------------
1954 #ifdef __WXDEBUG__
1955 #define MAX_ERROR_TEXT_LEN 160
1956
1957 // Get the error string for Active Movie
1958 wxString wxAMMediaBackend::GetErrorString(HRESULT hrdsv)
1959 {
1960 wxChar szError[MAX_ERROR_TEXT_LEN];
1961 if ( m_lpAMGetErrorText != NULL &&
1962 (*m_lpAMGetErrorText)(hrdsv, szError, MAX_ERROR_TEXT_LEN) == 0)
1963 {
1964 return wxString::Format(wxT("DirectShow error \"%s\" \n")
1965 wxT("(numeric %X)\n")
1966 wxT("occurred"),
1967 szError, (int)hrdsv);
1968 }
1969 else
1970 {
1971 return wxString::Format(wxT("Unknown error \n")
1972 wxT("(numeric %X)\n")
1973 wxT("occurred"),
1974 (int)hrdsv);
1975 }
1976 }
1977
1978 #define wxAMFAIL(x) wxFAIL_MSG(GetErrorString(x));
1979 #define wxVERIFY(x) wxASSERT((x))
1980 #define wxAMLOG(x) wxLogDebug(GetErrorString(x))
1981 #else
1982 #define wxVERIFY(x) (x)
1983 #define wxAMLOG(x)
1984 #define wxAMFAIL(x)
1985 #endif
1986
1987 //---------------------------------------------------------------------------
1988 // Standard macros for ease of use
1989 //---------------------------------------------------------------------------
1990 #define SAFE_RELEASE(x) { if (x) x->Release(); x = NULL; }
1991
1992 //---------------------------------------------------------------------------
1993 // wxAMLoadTimer
1994 //
1995 // Queries the control periodically to see if it has reached the point
1996 // in its loading cycle where we can begin playing the media - if so
1997 // then we finish up some things like getting the original size of the video
1998 // and then sending the loaded event to our handler
1999 //---------------------------------------------------------------------------
2000 class wxAMLoadTimer : public wxTimer
2001 {
2002 public:
2003 wxAMLoadTimer(wxAMMediaBackend* parent) :
2004 m_parent(parent) {}
2005
2006 void Notify()
2007 {
2008 if (m_parent->GetMP())
2009 {
2010 MPReadyStateConstants nState;
2011
2012 #ifdef __WXWINCE__ //Cast to long needed for IWMP (??)
2013 m_parent->GetMP()->get_ReadyState((long*)&nState);
2014 #else
2015 m_parent->GetMP()->get_ReadyState(&nState);
2016 #endif
2017
2018 if (nState != mpReadyStateLoading)
2019 {
2020 Stop();
2021 m_parent->FinishLoad();
2022 delete this;
2023 }
2024 }
2025 else
2026 {
2027 IActiveMovie2* pAM2 = NULL;
2028 ReadyStateConstants nState;
2029 if (m_parent->GetAM()->QueryInterface(IID_IActiveMovie2, (void**)&pAM2) == 0
2030 && pAM2->get_ReadyState(&nState) == 0)
2031 {
2032 pAM2->Release();
2033 if (nState != amvLoading)
2034 {
2035 Stop();
2036 m_parent->FinishLoad();
2037 delete this;
2038 }
2039 }
2040 else
2041 {
2042 if (pAM2)
2043 pAM2->Release();
2044
2045 Stop();
2046 m_parent->FinishLoad();
2047 delete this;
2048 }
2049 }
2050 }
2051
2052 protected:
2053 wxAMMediaBackend* m_parent; // Backend pointer
2054 };
2055
2056 //---------------------------------------------------------------------------
2057 // wxAMPlayTimer
2058 //
2059 // Sets m_hNotifyWnd to NULL to signify that we haven't loaded anything yet
2060 // Queries the control periodically to see if it has stopped -
2061 // if it has it sends the stop event
2062 //---------------------------------------------------------------------------
2063 class wxAMPlayTimer : public wxTimer
2064 {
2065 public:
2066 wxAMPlayTimer(wxAMMediaBackend* parent) :
2067 m_parent(parent) {}
2068
2069 void Notify()
2070 {
2071 // NB: Stop events could get triggered by the interface
2072 // if ShowPlayerControls is enabled, so the "GetPosition == GetDuration"
2073 // hack is needed here to make an attempt at it not getting sent
2074 // - but its far from ideal - they can still get sent in some cases
2075 if (m_parent->GetState() == wxMEDIASTATE_STOPPED &&
2076 m_parent->GetPosition() == m_parent->GetDuration())
2077 {
2078 if ( m_parent->SendStopEvent() )
2079 {
2080 // seek to beginning of movie
2081 m_parent->wxAMMediaBackend::SetPosition(0);
2082 Stop();
2083
2084 // send the event to our child
2085 m_parent->QueueFinishEvent();
2086 }
2087 }
2088 }
2089
2090 protected:
2091 wxAMMediaBackend* m_parent; //Backend pointer
2092 };
2093
2094
2095 #if 0
2096 // The following is an alternative way - but it doesn't seem
2097 // to work with the IActiveMovie control - it probably processes
2098 // its own events
2099 //---------------------------------------------------------------------------
2100 // wxAMPlayTimer
2101 //
2102 // Query the IMediaEvent interface from the embedded WMP's
2103 // filtergraph, then process the events from it - sending
2104 // EC_COMPLETE events as stop events to the media control.
2105 //---------------------------------------------------------------------------
2106 class wxAMPlayTimer : public wxTimer
2107 {
2108 public:
2109 wxAMPlayTimer(wxAMMediaBackend* pBE) : m_pBE(pBE), m_pME(NULL)
2110 {
2111 HRESULT hr;
2112 IUnknown* pGB;
2113 hr = m_pBE->GetAM()->get_FilterGraph(&pGB);
2114 wxASSERT(SUCCEEDED(hr));
2115 hr = pGB->QueryInterface(IID_IMediaEvent, (void**)&m_pME);
2116 wxASSERT(SUCCEEDED(hr));
2117 pGB->Release();
2118 }
2119
2120 virtual ~wxAMPlayTimer()
2121 {
2122 SAFE_RELEASE(m_pME);
2123 }
2124
2125 void Notify()
2126 {
2127 LONG evCode;
2128 LONG_PTR evParam1, evParam2;
2129
2130 // DirectShow keeps a list of queued events, and we need
2131 // to go through them one by one, stopping at (hopefully only one)
2132 // EC_COMPLETE message
2133 while ( m_pME->GetEvent(&evCode, &evParam1, &evParam2, 0) == 0 )
2134 {
2135 // Cleanup memory that GetEvent allocated
2136 HRESULT hr = m_pME->FreeEventParams(evCode, evParam1, evParam2);
2137 if (hr != 0)
2138 {
2139 // Even though this makes a messagebox, this is Windows,
2140 // where we can do GUI stuff in separate threads :)
2141 wxFAIL_MSG(m_pBE->GetErrorString(hr));
2142 }
2143 // If this is the end of the clip, notify handler
2144 else if (1 == evCode) // EC_COMPLETE
2145 {
2146 if ( m_pBE->SendStopEvent() )
2147 {
2148 Stop();
2149 m_pBE->QueueFinishEvent();
2150 }
2151 }
2152 }
2153 }
2154
2155 protected:
2156 wxAMMediaBackend* m_pBE; // Backend pointer
2157 IMediaEvent* m_pME; // To determine when to send stop event
2158 };
2159 #endif
2160
2161 //---------------------------------------------------------------------------
2162 // wxAMMediaBackend Constructor
2163 //---------------------------------------------------------------------------
2164 wxAMMediaBackend::wxAMMediaBackend()
2165 :m_pAX(NULL),
2166 #ifdef __WXWINCE__
2167 m_pWMP(NULL),
2168 #else
2169 m_pAM(NULL),
2170 m_pMP(NULL),
2171 #endif
2172 m_pTimer(NULL)
2173 {
2174 }
2175
2176 //---------------------------------------------------------------------------
2177 // wxAMMediaBackend Destructor
2178 //---------------------------------------------------------------------------
2179 wxAMMediaBackend::~wxAMMediaBackend()
2180 {
2181 // Free memory from Load()
2182 Clear();
2183
2184 if (m_pAX)
2185 {
2186 m_pAX->DissociateHandle();
2187 delete m_pAX;
2188
2189 #ifndef __WXWINCE__
2190 m_pAM->Release();
2191 #endif
2192
2193 if (GetMP())
2194 GetMP()->Release();
2195 }
2196 }
2197
2198 //---------------------------------------------------------------------------
2199 // wxAMMediaBackend::Clear
2200 //
2201 // Free up interfaces and memory allocated by LoadXXX
2202 //---------------------------------------------------------------------------
2203 void wxAMMediaBackend::Clear()
2204 {
2205 if (m_pTimer)
2206 {
2207 delete m_pTimer;
2208 m_pTimer = NULL;
2209 }
2210 }
2211
2212 //---------------------------------------------------------------------------
2213 // wxAMMediaBackend::CreateControl
2214 //---------------------------------------------------------------------------
2215 bool wxAMMediaBackend::CreateControl(wxControl* ctrl, wxWindow* parent,
2216 wxWindowID id,
2217 const wxPoint& pos,
2218 const wxSize& size,
2219 long style,
2220 const wxValidator& validator,
2221 const wxString& name)
2222 {
2223 // First get the AMGetErrorText procedure in
2224 // debug mode for more meaningful messages
2225 #ifdef __WXDEBUG__
2226 if ( m_dllQuartz.Load(_T("quartz.dll"), wxDL_VERBATIM) )
2227 {
2228 m_lpAMGetErrorText = (LPAMGETERRORTEXT)
2229 m_dllQuartz.GetSymbolAorW(wxT("AMGetErrorText"));
2230 }
2231 #endif
2232
2233 #ifdef __WXWINCE__
2234 CLSID clsid;
2235
2236 // Try progids first - *.WMP is PocketPC and Mediaplayer.1 is CE.NET
2237 // later versions support straight creation from CLSID
2238 if (CLSIDFromProgID(L"WPCEOCX.WMP", &clsid) != S_OK &&
2239 CLSIDFromProgID(L"MediaPlayer.MediaPlayer.1", &clsid) != S_OK)
2240 {
2241 clsid = CLSID_MediaPlayer;
2242 }
2243
2244 // While the CLSID is the same as CLSID_MediaPlayer
2245 // CE only supports the IWMP interface
2246 if ( ::CoCreateInstance(clsid, NULL,
2247 CLSCTX_INPROC_SERVER,
2248 IID_IWMP, (void**)&m_pWMP) != 0 )
2249 {
2250 return false;
2251 }
2252
2253 #else
2254 // determine which (if any) media player interface
2255 // is available - IMediaPlayer or IActiveMovie
2256 if ( ::CoCreateInstance(CLSID_MediaPlayer, NULL,
2257 CLSCTX_INPROC_SERVER,
2258 IID_IMediaPlayer, (void**)&m_pMP) != 0 )
2259 {
2260 if ( ::CoCreateInstance(CLSID_ActiveMovie, NULL,
2261 CLSCTX_INPROC_SERVER,
2262 IID_IActiveMovie, (void**)&m_pAM) != 0 )
2263 {
2264 return false;
2265 }
2266
2267 m_pAM->QueryInterface(IID_IMediaPlayer, (void**)&m_pMP);
2268 }
2269 else
2270 {
2271 m_pMP->QueryInterface(IID_IActiveMovie, (void**)&m_pAM);
2272 }
2273 #endif
2274
2275 // Create window
2276 // By default wxWindow(s) is created with a border -
2277 // so we need to get rid of those
2278 //
2279 // Since we don't have a child window like most other
2280 // backends, we don't need wxCLIP_CHILDREN
2281 if ( !ctrl->wxControl::Create(parent, id, pos, size,
2282 (style & ~wxBORDER_MASK) | wxBORDER_NONE,
2283 validator, name) )
2284 {
2285 return false;
2286 }
2287
2288 // Create the ActiveX container along with the media player
2289 // interface and query them
2290 m_ctrl = wxStaticCast(ctrl, wxMediaCtrl);
2291 m_pAX = new wxActiveXContainer(ctrl,
2292 #ifdef __WXWINCE__
2293 IID_IWMP, m_pWMP
2294 #else
2295 m_pMP ? IID_IMediaPlayer : IID_IActiveMovie, m_pAM
2296 #endif
2297 );
2298
2299 // Set up wx-specific stuff for the default
2300 // settings wxMediaCtrl says it will conform to (???)
2301 if (GetMP())
2302 {
2303 GetMP()->put_DisplaySize(mpFitToSize);
2304
2305 #ifndef __WXWINCE__ // Not in CE's IWMP
2306 // TODO: Unsure what actual effect this has
2307 GetMP()->put_WindowlessVideo(VARIANT_TRUE);
2308 #endif
2309 }
2310 #ifndef __WXWINCE__ // Not in CE's IWMP
2311 else
2312 GetAM()->put_MovieWindowSize(amvDoubleOriginalSize);
2313 #endif
2314
2315 // by default true
2316 GetAM()->put_AutoStart(VARIANT_FALSE);
2317
2318 // by default enabled
2319 wxAMMediaBackend::ShowPlayerControls(wxMEDIACTRLPLAYERCONTROLS_NONE);
2320
2321 // by default with AM only 0.5
2322 wxAMMediaBackend::SetVolume(1.0);
2323
2324 // don't erase the background of our control window
2325 // so that resizing is a bit smoother
2326 m_ctrl->SetBackgroundStyle(wxBG_STYLE_CUSTOM);
2327
2328 // success
2329 return true;
2330 }
2331
2332 //---------------------------------------------------------------------------
2333 // wxAMMediaBackend::Load (file version)
2334 //---------------------------------------------------------------------------
2335 bool wxAMMediaBackend::Load(const wxString& fileName)
2336 {
2337 return DoLoad(fileName);
2338 }
2339
2340 //---------------------------------------------------------------------------
2341 // wxAMMediaBackend::Load (URL Version)
2342 //---------------------------------------------------------------------------
2343 bool wxAMMediaBackend::Load(const wxURI& location)
2344 {
2345 // Turn off loading from a proxy, as user may have set it previously
2346 INSPlay* pPlay = NULL;
2347 GetAM()->QueryInterface(IID_INSPlay, (void**) &pPlay);
2348 if (pPlay)
2349 {
2350 pPlay->put_UseHTTPProxy(VARIANT_FALSE);
2351 pPlay->Release();
2352 }
2353
2354 return DoLoad(location.BuildURI());
2355 }
2356
2357 //---------------------------------------------------------------------------
2358 // wxAMMediaBackend::Load (URL Version with Proxy)
2359 //---------------------------------------------------------------------------
2360 bool wxAMMediaBackend::Load(const wxURI& location, const wxURI& proxy)
2361 {
2362 // Set the proxy of the NETSHOW interface
2363 INSPlay* pPlay = NULL;
2364 GetAM()->QueryInterface(IID_INSPlay, (void**) &pPlay);
2365
2366 if (pPlay)
2367 {
2368 pPlay->put_UseHTTPProxy(VARIANT_TRUE);
2369 pPlay->put_HTTPProxyHost(wxBasicString(proxy.GetServer()).Get());
2370 pPlay->put_HTTPProxyPort(wxAtoi(proxy.GetPort()));
2371 pPlay->Release();
2372 }
2373
2374 return DoLoad(location.BuildURI());
2375 }
2376
2377 //---------------------------------------------------------------------------
2378 // wxAMMediaBackend::DoLoad
2379 //
2380 // Called by all functions - this actually renders
2381 // the file and sets up the filter graph
2382 //---------------------------------------------------------------------------
2383 bool wxAMMediaBackend::DoLoad(const wxString& location)
2384 {
2385 //Clear up previously allocated memory
2386 Clear();
2387
2388 HRESULT hr;
2389
2390 // Play the movie the normal way through the embedded WMP.
2391 // Supposedly, Open is better in theory because
2392 // the docs say its async and put_FileName is not -
2393 // but in practice they both appear to be async anyway
2394 if (GetMP())
2395 hr = GetMP()->Open( wxBasicString(location).Get() );
2396 else
2397 hr = GetAM()->put_FileName( wxBasicString(location).Get() );
2398
2399 if (FAILED(hr))
2400 {
2401 wxAMLOG(hr);
2402 return false;
2403 }
2404
2405 // In AM playing will FAIL if
2406 // the user plays before the media is loaded
2407 m_pTimer = new wxAMLoadTimer(this);
2408 m_pTimer->Start(20);
2409
2410 return true;
2411 }
2412
2413 //---------------------------------------------------------------------------
2414 // wxAMMediaBackend::FinishLoad
2415 //
2416 // Called by our wxAMLoadTimer when the
2417 // embedded WMP tells its the media is ready to play.
2418 //
2419 // Here we get the original size of the video and
2420 // send the loaded event to our watcher :).
2421 //---------------------------------------------------------------------------
2422 void wxAMMediaBackend::FinishLoad()
2423 {
2424 // Get the original video size
2425 GetAM()->get_ImageSourceWidth((long*)&m_bestSize.x);
2426 GetAM()->get_ImageSourceHeight((long*)&m_bestSize.y);
2427
2428 // Start the play timer to catch stop events
2429 // Previous load timer cleans up itself
2430 m_pTimer = new wxAMPlayTimer(this);
2431
2432 NotifyMovieLoaded();
2433 }
2434
2435 //---------------------------------------------------------------------------
2436 // wxAMMediaBackend::ShowPlayerControls
2437 //---------------------------------------------------------------------------
2438 bool wxAMMediaBackend::ShowPlayerControls(wxMediaCtrlPlayerControls flags)
2439 {
2440 // Note that IMediaPlayer doesn't have a statusbar by
2441 // default but IActiveMovie does - so lets try to keep
2442 // the interface consistant
2443 if (!flags)
2444 {
2445 GetAM()->put_Enabled(VARIANT_FALSE);
2446 GetAM()->put_ShowControls(VARIANT_FALSE);
2447 if (GetMP())
2448 GetMP()->put_ShowStatusBar(VARIANT_FALSE);
2449 }
2450 else
2451 {
2452 GetAM()->put_Enabled(VARIANT_TRUE);
2453 GetAM()->put_ShowControls(VARIANT_TRUE);
2454
2455 GetAM()->put_ShowPositionControls(
2456 (flags & wxMEDIACTRLPLAYERCONTROLS_STEP) ?
2457 VARIANT_TRUE : VARIANT_FALSE);
2458
2459 if (GetMP())
2460 {
2461 GetMP()->put_ShowStatusBar(VARIANT_TRUE);
2462 GetMP()->put_ShowAudioControls(
2463 (flags & wxMEDIACTRLPLAYERCONTROLS_VOLUME) ?
2464 VARIANT_TRUE : VARIANT_FALSE);
2465 }
2466 }
2467
2468 return true;
2469 }
2470
2471 //---------------------------------------------------------------------------
2472 // wxAMMediaBackend::Play
2473 //
2474 // Plays the stream. If it is non-seekable, it will restart it (implicit).
2475 //
2476 // Note that we use SUCCEEDED here because run/pause/stop tend to be overly
2477 // picky and return warnings on pretty much every call
2478 //---------------------------------------------------------------------------
2479 bool wxAMMediaBackend::Play()
2480 {
2481 // Actually try to play the movie, even though it may not be loaded yet.
2482 #ifdef __WXWINCE__
2483 HRESULT hr = m_pWMP->Play();
2484 #else
2485 HRESULT hr = GetAM()->Run();
2486 #endif
2487 if (SUCCEEDED(hr))
2488 {
2489 m_pTimer->Start(20);
2490 return true;
2491 }
2492
2493 wxAMLOG(hr);
2494
2495 return false;
2496 }
2497
2498 //---------------------------------------------------------------------------
2499 // wxAMMediaBackend::Pause
2500 //
2501 // Pauses the stream.
2502 //---------------------------------------------------------------------------
2503 bool wxAMMediaBackend::Pause()
2504 {
2505 HRESULT hr = GetAM()->Pause();
2506 if (SUCCEEDED(hr))
2507 return true;
2508
2509 wxAMLOG(hr);
2510
2511 return false;
2512 }
2513
2514 //---------------------------------------------------------------------------
2515 // wxAMMediaBackend::Stop
2516 //
2517 // Stops the stream.
2518 //---------------------------------------------------------------------------
2519 bool wxAMMediaBackend::Stop()
2520 {
2521 HRESULT hr = GetAM()->Stop();
2522 if (SUCCEEDED(hr))
2523 {
2524 // Seek to beginning
2525 wxAMMediaBackend::SetPosition(0);
2526
2527 // Stop stop event timer
2528 m_pTimer->Stop();
2529 return true;
2530 }
2531
2532 wxAMLOG(hr);
2533
2534 return false;
2535 }
2536
2537 //---------------------------------------------------------------------------
2538 // wxAMMediaBackend::SetPosition
2539 //
2540 // 1) Translates the current position's time to directshow time,
2541 // which is in a scale of 1 second (in a double)
2542 // 2) Sets the play position of the IMediaSeeking interface -
2543 // passing NULL as the stop position means to keep the old
2544 // stop position
2545 //---------------------------------------------------------------------------
2546 bool wxAMMediaBackend::SetPosition(wxLongLong where)
2547 {
2548 HRESULT hr = GetAM()->put_CurrentPosition(
2549 ((LONGLONG)where.GetValue()) / 1000.0 );
2550 if (FAILED(hr))
2551 {
2552 wxAMLOG(hr);
2553 return false;
2554 }
2555
2556 return true;
2557 }
2558
2559 //---------------------------------------------------------------------------
2560 // wxAMMediaBackend::GetPosition
2561 //
2562 // 1) Obtains the current play and stop positions from IMediaSeeking
2563 // 2) Returns the play position translated to our time base
2564 //---------------------------------------------------------------------------
2565 wxLongLong wxAMMediaBackend::GetPosition()
2566 {
2567 double outCur;
2568 HRESULT hr = GetAM()->get_CurrentPosition(&outCur);
2569 if (FAILED(hr))
2570 {
2571 wxAMLOG(hr);
2572 return 0;
2573 }
2574
2575 // h,m,s,milli - outdur is in 1 second (double)
2576 outCur *= 1000;
2577 wxLongLong ll;
2578 ll.Assign(outCur);
2579
2580 return ll;
2581 }
2582
2583 //---------------------------------------------------------------------------
2584 // wxAMMediaBackend::GetVolume
2585 //
2586 // Gets the volume through the IBasicAudio interface -
2587 // value ranges from 0 (MAX volume) to -10000 (minimum volume).
2588 // -100 per decibel.
2589 //---------------------------------------------------------------------------
2590 double wxAMMediaBackend::GetVolume()
2591 {
2592 long lVolume;
2593 HRESULT hr = GetAM()->get_Volume(&lVolume);
2594 if (FAILED(hr))
2595 {
2596 wxAMLOG(hr);
2597 return 0.0;
2598 }
2599
2600 return pow(10.0, lVolume / 2000.0);
2601 }
2602
2603 //---------------------------------------------------------------------------
2604 // wxAMMediaBackend::SetVolume
2605 //
2606 // Sets the volume through the IBasicAudio interface -
2607 // value ranges from 0 (MAX volume) to -10000 (minimum volume).
2608 // -100 per decibel.
2609 //---------------------------------------------------------------------------
2610 bool wxAMMediaBackend::SetVolume(double dVolume)
2611 {
2612 // pow(10.0, -80.0) to correct 0 == -INF
2613 long lVolume = (long)(2000.0 * log10( pow( 10.0, -80.0) + dVolume ) );
2614 HRESULT hr = GetAM()->put_Volume( lVolume );
2615 if (FAILED(hr))
2616 {
2617 wxAMLOG(hr);
2618 return false;
2619 }
2620
2621 return true;
2622 }
2623
2624 //---------------------------------------------------------------------------
2625 // wxAMMediaBackend::GetDuration
2626 //
2627 // 1) Obtains the duration of the media from IAMMultiMediaStream
2628 // 2) Converts that value to our time base, and returns it
2629 //
2630 // NB: With VBR MP3 files the default DirectShow MP3 render does not
2631 // read the Xing header correctly, resulting in skewed values for duration
2632 // and seeking
2633 //---------------------------------------------------------------------------
2634 wxLongLong wxAMMediaBackend::GetDuration()
2635 {
2636 double outDuration;
2637 HRESULT hr = GetAM()->get_Duration(&outDuration);
2638 if (FAILED(hr))
2639 {
2640 wxAMLOG(hr);
2641 return 0;
2642 }
2643
2644 // h,m,s,milli - outdur is in 1 second (double)
2645 outDuration *= 1000;
2646 wxLongLong ll;
2647 ll.Assign(outDuration);
2648
2649 return ll;
2650 }
2651
2652 //---------------------------------------------------------------------------
2653 // wxAMMediaBackend::GetState
2654 //
2655 // Returns the cached state
2656 //---------------------------------------------------------------------------
2657 wxMediaState wxAMMediaBackend::GetState()
2658 {
2659 StateConstants nState;
2660 #ifdef __WXWINCE__
2661 HRESULT hr = m_pWMP->get_PlayState((long*)&nState);
2662 #else
2663 HRESULT hr = GetAM()->get_CurrentState(&nState);
2664 #endif
2665 if (FAILED(hr))
2666 {
2667 wxAMLOG(hr);
2668 return wxMEDIASTATE_STOPPED;
2669 }
2670
2671 return (wxMediaState)nState;
2672 }
2673
2674 //---------------------------------------------------------------------------
2675 // wxAMMediaBackend::GetPlaybackRate
2676 //
2677 // Pretty simple way of obtaining the playback rate from
2678 // the IMediaSeeking interface
2679 //---------------------------------------------------------------------------
2680 double wxAMMediaBackend::GetPlaybackRate()
2681 {
2682 double dRate;
2683 HRESULT hr = GetAM()->get_Rate(&dRate);
2684 if (FAILED(hr))
2685 {
2686 wxAMLOG(hr);
2687 return 0.0;
2688 }
2689
2690 return dRate;
2691 }
2692
2693 //---------------------------------------------------------------------------
2694 // wxAMMediaBackend::SetPlaybackRate
2695 //
2696 // Sets the playback rate of the media - DirectShow is pretty good
2697 // about this, actually
2698 //---------------------------------------------------------------------------
2699 bool wxAMMediaBackend::SetPlaybackRate(double dRate)
2700 {
2701 HRESULT hr = GetAM()->put_Rate(dRate);
2702 if (FAILED(hr))
2703 {
2704 wxAMLOG(hr);
2705 return false;
2706 }
2707
2708 return true;
2709 }
2710
2711 //---------------------------------------------------------------------------
2712 // wxAMMediaBackend::GetDownloadXXX
2713 //
2714 // Queries for and gets the total size of the file and the current
2715 // progress in downloading that file from the IAMOpenProgress
2716 // interface from the media player interface's filter graph
2717 //---------------------------------------------------------------------------
2718 void wxAMMediaBackend::DoGetDownloadProgress(wxLongLong* pLoadProgress,
2719 wxLongLong* pLoadTotal)
2720 {
2721 #ifndef __WXWINCE__
2722 LONGLONG loadTotal = 0, loadProgress = 0;
2723 IUnknown* pFG;
2724 IAMOpenProgress* pOP;
2725 HRESULT hr;
2726 hr = GetAM()->get_FilterGraph(&pFG);
2727 if (SUCCEEDED(hr))
2728 {
2729 hr = pFG->QueryInterface(IID_IAMOpenProgress, (void**)&pOP);
2730 if (SUCCEEDED(hr))
2731 {
2732 hr = pOP->QueryProgress(&loadTotal, &loadProgress);
2733 pOP->Release();
2734 }
2735
2736 pFG->Release();
2737 }
2738
2739 if (SUCCEEDED(hr))
2740 {
2741 *pLoadProgress = loadProgress;
2742 *pLoadTotal = loadTotal;
2743 }
2744 else
2745 #endif
2746 {
2747 // When not loading from a URL QueryProgress will return
2748 // E_NOINTERFACE or whatever
2749 // wxAMFAIL(hr);
2750 *pLoadProgress = 0;
2751 *pLoadTotal = 0;
2752 }
2753 }
2754
2755 //---------------------------------------------------------------------------
2756 // wxAMMediaBackend::GetVideoSize
2757 //
2758 // Obtains the cached original video size
2759 //---------------------------------------------------------------------------
2760 wxSize wxAMMediaBackend::GetVideoSize() const
2761 {
2762 return m_bestSize;
2763 }
2764
2765 //---------------------------------------------------------------------------
2766 // wxAMMediaBackend::Move
2767 //
2768 // We take care of this in our redrawing
2769 //---------------------------------------------------------------------------
2770 void wxAMMediaBackend::Move(int WXUNUSED(x), int WXUNUSED(y),
2771 int WXUNUSED(w), int WXUNUSED(h))
2772 {
2773 }
2774
2775 //---------------------------------------------------------------------------
2776 // End of wxAMMediaBackend
2777 //---------------------------------------------------------------------------
2778
2779 //---------------------------------------------------------------------------
2780 // wxMCIMediaBackend
2781 //---------------------------------------------------------------------------
2782
2783 #ifndef __WXWINCE__
2784 IMPLEMENT_DYNAMIC_CLASS(wxMCIMediaBackend, wxMediaBackend)
2785
2786 //---------------------------------------------------------------------------
2787 // Usual debugging macros for MCI returns
2788 //---------------------------------------------------------------------------
2789
2790 #ifdef __WXDEBUG__
2791 #define wxMCIVERIFY(arg) \
2792 { \
2793 DWORD nRet; \
2794 if ( (nRet = (arg)) != 0) \
2795 { \
2796 TCHAR sz[5000]; \
2797 mciGetErrorString(nRet, sz, 5000); \
2798 wxFAIL_MSG(wxString::Format(_T("MCI Error:%s"), sz)); \
2799 } \
2800 }
2801 #else
2802 #define wxMCIVERIFY(arg) (arg);
2803 #endif
2804
2805 //---------------------------------------------------------------------------
2806 // Simulation for <digitalv.h>
2807 //
2808 // Mingw and possibly other compilers don't have the digitalv.h header
2809 // that is needed to have some essential features of mci work with
2810 // windows - so we provide the declarations for the types we use here
2811 //---------------------------------------------------------------------------
2812
2813 typedef struct
2814 {
2815 DWORD_PTR dwCallback;
2816 #ifdef MCI_USE_OFFEXT
2817 POINT ptOffset;
2818 POINT ptExtent;
2819 #else
2820 RECT rc;
2821 #endif
2822 }
2823 MCI_DGV_RECT_PARMS;
2824
2825 typedef struct
2826 {
2827 DWORD_PTR dwCallback;
2828 HWND hWnd;
2829 #ifndef _WIN32
2830 WORD wReserved1;
2831 #endif
2832 UINT nCmdShow;
2833 #ifndef _WIN32
2834 WORD wReserved2;
2835 #endif
2836 wxChar* lpstrText;
2837 }
2838 MCI_DGV_WINDOW_PARMS;
2839
2840 typedef struct
2841 {
2842 DWORD_PTR dwCallback;
2843 DWORD dwTimeFormat;
2844 DWORD dwAudio;
2845 DWORD dwFileFormat;
2846 DWORD dwSpeed;
2847 }
2848 MCI_DGV_SET_PARMS;
2849
2850 typedef struct
2851 {
2852 DWORD_PTR dwCallback;
2853 DWORD dwItem;
2854 DWORD dwValue;
2855 DWORD dwOver;
2856 wxChar* lpstrAlgorithm;
2857 wxChar* lpstrQuality;
2858 }
2859 MCI_DGV_SETAUDIO_PARMS;
2860
2861 //---------------------------------------------------------------------------
2862 // wxMCIMediaBackend Constructor
2863 //
2864 // Here we don't need to do much except say we don't have any video :)
2865 //---------------------------------------------------------------------------
2866 wxMCIMediaBackend::wxMCIMediaBackend() : m_hNotifyWnd(NULL), m_bVideo(false)
2867 {
2868 }
2869
2870 //---------------------------------------------------------------------------
2871 // wxMCIMediaBackend Destructor
2872 //
2873 // We close the MCI device - note that there may not be an MCI device here,
2874 // or it may fail - but we don't really care, since we're destructing
2875 //---------------------------------------------------------------------------
2876 wxMCIMediaBackend::~wxMCIMediaBackend()
2877 {
2878 if (m_hNotifyWnd)
2879 {
2880 mciSendCommand(m_hDev, MCI_CLOSE, 0, 0);
2881 DestroyWindow(m_hNotifyWnd);
2882 m_hNotifyWnd = NULL;
2883 }
2884 }
2885
2886 //---------------------------------------------------------------------------
2887 // wxMCIMediaBackend::Create
2888 //
2889 // Here we just tell wxMediaCtrl that MCI does exist (which it does, on all
2890 // msw systems, at least in some form dating back to win16 days)
2891 //---------------------------------------------------------------------------
2892 bool wxMCIMediaBackend::CreateControl(wxControl* ctrl, wxWindow* parent,
2893 wxWindowID id,
2894 const wxPoint& pos,
2895 const wxSize& size,
2896 long style,
2897 const wxValidator& validator,
2898 const wxString& name)
2899 {
2900 // Create window
2901 // By default wxWindow(s) is created with a border -
2902 // so we need to get rid of those, and create with
2903 // wxCLIP_CHILDREN, so that if the driver/backend
2904 // is a child window, it refereshes properly
2905 if ( !ctrl->wxControl::Create(parent, id, pos, size,
2906 (style & ~wxBORDER_MASK) | wxBORDER_NONE | wxCLIP_CHILDREN,
2907 validator, name) )
2908 return false;
2909
2910 m_ctrl = wxStaticCast(ctrl, wxMediaCtrl);
2911
2912 return true;
2913 }
2914
2915 //---------------------------------------------------------------------------
2916 // wxMCIMediaBackend::Load (file version)
2917 //
2918 // Here we have MCI load a file and device, set the time format to our
2919 // default (milliseconds), and set the video (if any) to play in the control
2920 //---------------------------------------------------------------------------
2921 bool wxMCIMediaBackend::Load(const wxString& fileName)
2922 {
2923 // if the user already called load close the previous MCI device
2924 if (m_hNotifyWnd)
2925 {
2926 mciSendCommand(m_hDev, MCI_CLOSE, 0, 0);
2927 DestroyWindow(m_hNotifyWnd);
2928 m_hNotifyWnd = NULL;
2929 }
2930
2931 // Opens a file and has MCI select a device. Normally you'd put
2932 // MCI_OPEN_TYPE in addition to MCI_OPEN_ELEMENT - however if you
2933 // omit this it tells MCI to select the device instead. This is good
2934 // because we have no reliable way of "enumerating" the devices in MCI
2935 MCI_OPEN_PARMS openParms;
2936 openParms.lpstrElementName = (wxChar*) fileName.c_str();
2937
2938 if (mciSendCommand(0, MCI_OPEN, MCI_OPEN_ELEMENT,
2939 (DWORD)(LPVOID)&openParms) != 0)
2940 {
2941 return false;
2942 }
2943
2944 m_hDev = openParms.wDeviceID;
2945
2946 // set the time format for the device to milliseconds
2947 MCI_SET_PARMS setParms;
2948 setParms.dwCallback = 0;
2949 setParms.dwTimeFormat = MCI_FORMAT_MILLISECONDS;
2950
2951 if (mciSendCommand(m_hDev, MCI_SET, MCI_SET_TIME_FORMAT,
2952 (DWORD)(LPVOID)&setParms) != 0)
2953 {
2954 return false;
2955 }
2956
2957 // tell the MCI device to display the video in our wxMediaCtrl
2958 MCI_DGV_WINDOW_PARMS windowParms;
2959 windowParms.hWnd = (HWND)m_ctrl->GetHandle();
2960
2961 m_bVideo = (mciSendCommand(m_hDev, MCI_WINDOW,
2962 0x00010000L, // MCI_DGV_WINDOW_HWND
2963 (DWORD)(LPVOID)&windowParms) == 0);
2964
2965 // Create a hidden window and register to handle MCI events
2966 // Note that wxCanvasClassName is already registered
2967 // and used by all wxWindows and normal wxControls
2968 m_hNotifyWnd = ::CreateWindow(
2969 wxCanvasClassName,
2970 NULL,
2971 0, 0, 0, 0,
2972 0,
2973 (HWND) NULL,
2974 (HMENU)NULL,
2975 wxGetInstance(),
2976 (LPVOID)NULL );
2977
2978 if (!m_hNotifyWnd)
2979 {
2980 wxLogSysError( wxT("Could not create hidden needed for ")
2981 wxT("registering for MCI events!") );
2982
2983 return false;
2984 }
2985
2986 wxSetWindowProc(m_hNotifyWnd, wxMCIMediaBackend::NotifyWndProc);
2987 wxSetWindowUserData(m_hNotifyWnd, this);
2988
2989 NotifyMovieLoaded();
2990
2991 return true;
2992 }
2993
2994 //---------------------------------------------------------------------------
2995 // wxMCIMediaBackend::Load (URL version)
2996 //
2997 // MCI doesn't support URLs directly (?)
2998 //
2999 // TODO: Use wxURL/wxFileSystem and mmioInstallProc
3000 //---------------------------------------------------------------------------
3001 bool wxMCIMediaBackend::Load(const wxURI& WXUNUSED(location))
3002 {
3003 return false;
3004 }
3005
3006 //---------------------------------------------------------------------------
3007 // wxMCIMediaBackend::Play
3008 //
3009 // Plays/Resumes the MCI device... a couple notes:
3010 // 1) Certain drivers will crash and burn if we don't pass them an
3011 // MCI_PLAY_PARMS, despite the documentation that says otherwise...
3012 // 2) There is a MCI_RESUME command, but MCI_PLAY does the same thing
3013 // and will resume from a stopped state also, so there's no need to
3014 // call both, for example
3015 //---------------------------------------------------------------------------
3016 bool wxMCIMediaBackend::Play()
3017 {
3018 MCI_PLAY_PARMS playParms;
3019 playParms.dwCallback = (DWORD)m_hNotifyWnd;
3020
3021 bool bOK = (mciSendCommand(m_hDev, MCI_PLAY, MCI_NOTIFY,
3022 (DWORD)(LPVOID)&playParms) == 0);
3023
3024 if (bOK)
3025 m_ctrl->Show(m_bVideo);
3026
3027 return bOK;
3028 }
3029
3030 //---------------------------------------------------------------------------
3031 // wxMCIMediaBackend::Pause
3032 //
3033 // Pauses the MCI device - nothing special
3034 //---------------------------------------------------------------------------
3035 bool wxMCIMediaBackend::Pause()
3036 {
3037 return (mciSendCommand(m_hDev, MCI_PAUSE, MCI_WAIT, 0) == 0);
3038 }
3039
3040 //---------------------------------------------------------------------------
3041 // wxMCIMediaBackend::Stop
3042 //
3043 // Stops the MCI device & seeks to the beginning as wxMediaCtrl docs outline
3044 //---------------------------------------------------------------------------
3045 bool wxMCIMediaBackend::Stop()
3046 {
3047 return (mciSendCommand(m_hDev, MCI_STOP, MCI_WAIT, 0) == 0) &&
3048 (mciSendCommand(m_hDev, MCI_SEEK, MCI_SEEK_TO_START, 0) == 0);
3049 }
3050
3051 //---------------------------------------------------------------------------
3052 // wxMCIMediaBackend::GetState
3053 //
3054 // Here we get the state and convert it to a wxMediaState -
3055 // since we use direct comparisons with MCI_MODE_PLAY and
3056 // MCI_MODE_PAUSE, we don't care if the MCI_STATUS call
3057 // fails or not
3058 //---------------------------------------------------------------------------
3059 wxMediaState wxMCIMediaBackend::GetState()
3060 {
3061 MCI_STATUS_PARMS statusParms;
3062 statusParms.dwItem = MCI_STATUS_MODE;
3063
3064 mciSendCommand(m_hDev, MCI_STATUS, MCI_STATUS_ITEM,
3065 (DWORD)(LPVOID)&statusParms);
3066
3067 if (statusParms.dwReturn == MCI_MODE_PAUSE)
3068 return wxMEDIASTATE_PAUSED;
3069 else if (statusParms.dwReturn == MCI_MODE_PLAY)
3070 return wxMEDIASTATE_PLAYING;
3071 else
3072 return wxMEDIASTATE_STOPPED;
3073 }
3074
3075 //---------------------------------------------------------------------------
3076 // wxMCIMediaBackend::SetPosition
3077 //
3078 // Here we set the position of the device in the stream.
3079 // Note that MCI actually stops the device after you seek it if the
3080 // device is playing/paused, so we need to play the file after
3081 // MCI seeks like normal APIs would
3082 //---------------------------------------------------------------------------
3083 bool wxMCIMediaBackend::SetPosition(wxLongLong where)
3084 {
3085 MCI_SEEK_PARMS seekParms;
3086 seekParms.dwCallback = 0;
3087
3088 #if wxUSE_LONGLONG_NATIVE && !wxUSE_LONGLONG_WX
3089 seekParms.dwTo = (DWORD)where.GetValue();
3090 #else // wxUSE_LONGLONG_WX
3091 // no way to return it in one piece
3092 wxASSERT( where.GetHi() == 0 );
3093 seekParms.dwTo = (DWORD)where.GetLo();
3094 #endif
3095
3096 // device was playing?
3097 bool bReplay = GetState() == wxMEDIASTATE_PLAYING;
3098
3099 if ( mciSendCommand(m_hDev, MCI_SEEK, MCI_TO,
3100 (DWORD)(LPVOID)&seekParms) != 0)
3101 {
3102 return false;
3103 }
3104
3105 // If the device was playing, resume it
3106 if (bReplay)
3107 return Play();
3108 else
3109 return true;
3110 }
3111
3112 //---------------------------------------------------------------------------
3113 // wxMCIMediaBackend::GetPosition
3114 //
3115 // Gets the position of the device in the stream using the current
3116 // time format... nothing special here...
3117 //---------------------------------------------------------------------------
3118 wxLongLong wxMCIMediaBackend::GetPosition()
3119 {
3120 MCI_STATUS_PARMS statusParms;
3121 statusParms.dwItem = MCI_STATUS_POSITION;
3122
3123 if (mciSendCommand(m_hDev, MCI_STATUS, MCI_STATUS_ITEM,
3124 (DWORD)(LPSTR)&statusParms) != 0)
3125 {
3126 return 0;
3127 }
3128
3129 return statusParms.dwReturn;
3130 }
3131
3132 //---------------------------------------------------------------------------
3133 // wxMCIMediaBackend::GetVolume
3134 //
3135 // Gets the volume of the current media via the MCI_DGV_STATUS_VOLUME
3136 // message. Value ranges from 0 (minimum) to 1000 (maximum volume).
3137 //---------------------------------------------------------------------------
3138 double wxMCIMediaBackend::GetVolume()
3139 {
3140 MCI_STATUS_PARMS statusParms;
3141 statusParms.dwCallback = 0;
3142 statusParms.dwItem = 0x4019; // MCI_DGV_STATUS_VOLUME
3143
3144 if (mciSendCommand(m_hDev, MCI_STATUS, MCI_STATUS_ITEM,
3145 (DWORD)(LPSTR)&statusParms) != 0)
3146 {
3147 return 0;
3148 }
3149
3150 return ((double)statusParms.dwReturn) / 1000.0;
3151 }
3152
3153 //---------------------------------------------------------------------------
3154 // wxMCIMediaBackend::SetVolume
3155 //
3156 // Sets the volume of the current media via the MCI_DGV_SETAUDIO_VOLUME
3157 // message. Value ranges from 0 (minimum) to 1000 (maximum volume).
3158 //---------------------------------------------------------------------------
3159 bool wxMCIMediaBackend::SetVolume(double dVolume)
3160 {
3161 MCI_DGV_SETAUDIO_PARMS audioParms;
3162 audioParms.dwCallback = 0;
3163 audioParms.dwItem = 0x4002; // MCI_DGV_SETAUDIO_VOLUME
3164 audioParms.dwValue = (DWORD) (dVolume * 1000.0);
3165 audioParms.dwOver = 0;
3166 audioParms.lpstrAlgorithm = NULL;
3167 audioParms.lpstrQuality = NULL;
3168
3169 if (mciSendCommand(m_hDev, 0x0873, // MCI_SETAUDIO
3170 // MCI_DGV_SETAUDIO + (_ITEM | _VALUE)
3171 0x00800000L | 0x01000000L,
3172 (DWORD)(LPSTR)&audioParms) != 0)
3173 {
3174 return false;
3175 }
3176
3177 return true;
3178 }
3179
3180 //---------------------------------------------------------------------------
3181 // wxMCIMediaBackend::GetDuration
3182 //
3183 // Gets the duration of the stream... nothing special
3184 //---------------------------------------------------------------------------
3185 wxLongLong wxMCIMediaBackend::GetDuration()
3186 {
3187 MCI_STATUS_PARMS statusParms;
3188 statusParms.dwItem = MCI_STATUS_LENGTH;
3189
3190 if (mciSendCommand(m_hDev, MCI_STATUS, MCI_STATUS_ITEM,
3191 (DWORD)(LPSTR)&statusParms) != 0)
3192 {
3193 return 0;
3194 }
3195
3196 return statusParms.dwReturn;
3197 }
3198
3199 //---------------------------------------------------------------------------
3200 // wxMCIMediaBackend::Move
3201 //
3202 // Moves the window to a location
3203 //---------------------------------------------------------------------------
3204 void wxMCIMediaBackend::Move(int WXUNUSED(x), int WXUNUSED(y), int w, int h)
3205 {
3206 if (m_hNotifyWnd && m_bVideo)
3207 {
3208 MCI_DGV_RECT_PARMS putParms; // ifdefed MCI_DGV_PUT_PARMS
3209 memset(&putParms, 0, sizeof(MCI_DGV_RECT_PARMS));
3210 putParms.rc.bottom = h;
3211 putParms.rc.right = w;
3212
3213 // wxStackWalker will crash and burn here on assert
3214 // and MCI doesn't like 0 and 0 for some reason (out of range)
3215 // so just don't it in that case
3216 if (w || h)
3217 {
3218 wxMCIVERIFY( mciSendCommand(m_hDev, MCI_PUT,
3219 0x00040000L, // MCI_DGV_PUT_DESTINATION
3220 (DWORD)(LPSTR)&putParms) );
3221 }
3222 }
3223 }
3224
3225 //---------------------------------------------------------------------------
3226 // wxMCIMediaBackend::GetVideoSize
3227 //
3228 // Gets the original size of the movie for sizers
3229 //---------------------------------------------------------------------------
3230 wxSize wxMCIMediaBackend::GetVideoSize() const
3231 {
3232 if (m_bVideo)
3233 {
3234 MCI_DGV_RECT_PARMS whereParms; // ifdefed MCI_DGV_WHERE_PARMS
3235
3236 wxMCIVERIFY( mciSendCommand(m_hDev, MCI_WHERE,
3237 0x00020000L, // MCI_DGV_WHERE_SOURCE
3238 (DWORD)(LPSTR)&whereParms) );
3239
3240 return wxSize(whereParms.rc.right, whereParms.rc.bottom);
3241 }
3242
3243 return wxSize(0, 0);
3244 }
3245
3246 //---------------------------------------------------------------------------
3247 // wxMCIMediaBackend::GetPlaybackRate
3248 //
3249 // TODO
3250 //---------------------------------------------------------------------------
3251 double wxMCIMediaBackend::GetPlaybackRate()
3252 {
3253 return 1.0;
3254 }
3255
3256 //---------------------------------------------------------------------------
3257 // wxMCIMediaBackend::SetPlaybackRate
3258 //
3259 // TODO
3260 //---------------------------------------------------------------------------
3261 bool wxMCIMediaBackend::SetPlaybackRate(double WXUNUSED(dRate))
3262 {
3263 #if 0
3264 MCI_WAVE_SET_SAMPLESPERSEC
3265 MCI_DGV_SET_PARMS setParms;
3266 setParms.dwSpeed = (DWORD) (dRate * 1000.0);
3267
3268 return (mciSendCommand(m_hDev, MCI_SET,
3269 0x00020000L, // MCI_DGV_SET_SPEED
3270 (DWORD)(LPSTR)&setParms) == 0);
3271 #endif
3272
3273 return false;
3274 }
3275
3276 //---------------------------------------------------------------------------
3277 // [static] wxMCIMediaBackend::MSWWindowProc
3278 //
3279 // Here we process a message when MCI reaches the stopping point
3280 // in the stream
3281 //---------------------------------------------------------------------------
3282 LRESULT CALLBACK wxMCIMediaBackend::NotifyWndProc(HWND hWnd, UINT nMsg,
3283 WPARAM wParam,
3284 LPARAM lParam)
3285 {
3286 wxMCIMediaBackend* backend =
3287 (wxMCIMediaBackend*)wxGetWindowUserData(hWnd);
3288
3289 return backend->OnNotifyWndProc(hWnd, nMsg, wParam, lParam);
3290 }
3291
3292 LRESULT CALLBACK wxMCIMediaBackend::OnNotifyWndProc(HWND hWnd, UINT nMsg,
3293 WPARAM wParam,
3294 LPARAM lParam)
3295 {
3296 if (nMsg == MM_MCINOTIFY)
3297 {
3298 wxASSERT(lParam == (LPARAM) m_hDev);
3299 if (wParam == MCI_NOTIFY_SUCCESSFUL && lParam == (LPARAM)m_hDev)
3300 {
3301 if ( SendStopEvent() )
3302 {
3303 wxMCIVERIFY( mciSendCommand(m_hDev, MCI_SEEK, MCI_SEEK_TO_START, 0) );
3304 QueueFinishEvent();
3305 }
3306 }
3307 }
3308 return DefWindowProc(hWnd, nMsg, wParam, lParam);
3309 }
3310 #endif // __WXWINCE__
3311
3312 //---------------------------------------------------------------------------
3313 // wxQTMediaBackend
3314 //
3315 // TODO: Use a less kludgy way to pause/get state/set state
3316 // FIXME: Greg Hazel reports that sometimes files that cannot be played
3317 // with this backend are treated as playable anyway - not verified though.
3318 //---------------------------------------------------------------------------
3319
3320 IMPLEMENT_DYNAMIC_CLASS(wxQTMediaBackend, wxMediaBackend)
3321
3322 // Time between timer calls - this is the Apple recommendation to the TCL
3323 // team I believe
3324 #define MOVIE_DELAY 20
3325
3326 //---------------------------------------------------------------------------
3327 // wxQTLoadTimer
3328 //
3329 // QT, esp. QT for Windows is very picky about how you go about
3330 // async loading. If you were to go through a Windows message loop
3331 // or a MoviesTask or both and then check the movie load state
3332 // it would still return 1000 (loading)... even (pre)prerolling doesn't
3333 // help. However, making a load timer like this works
3334 //---------------------------------------------------------------------------
3335 class wxQTLoadTimer : public wxTimer
3336 {
3337 public:
3338 wxQTLoadTimer(Movie movie, wxQTMediaBackend* parent, wxQuickTimeLibrary* pLib) :
3339 m_movie(movie), m_parent(parent), m_pLib(pLib) {}
3340
3341 void Notify()
3342 {
3343 m_pLib->MoviesTask(m_movie, 0);
3344 // kMovieLoadStatePlayable
3345 if (m_pLib->GetMovieLoadState(m_movie) >= 10000)
3346 {
3347 m_parent->FinishLoad();
3348 delete this;
3349 }
3350 }
3351
3352 protected:
3353 Movie m_movie; //Our movie instance
3354 wxQTMediaBackend* m_parent; //Backend pointer
3355 wxQuickTimeLibrary* m_pLib; //Interfaces
3356 };
3357
3358
3359 // --------------------------------------------------------------------------
3360 // wxQTPlayTimer - Handle Asyncronous Playing
3361 //
3362 // 1) Checks to see if the movie is done, and if not continues
3363 // streaming the movie
3364 // 2) Sends the wxEVT_MEDIA_STOP event if we have reached the end of
3365 // the movie.
3366 // --------------------------------------------------------------------------
3367 class wxQTPlayTimer : public wxTimer
3368 {
3369 public:
3370 wxQTPlayTimer(Movie movie, wxQTMediaBackend* parent,
3371 wxQuickTimeLibrary* pLib) :
3372 m_movie(movie), m_parent(parent), m_pLib(pLib) {}
3373
3374 void Notify()
3375 {
3376 //
3377 // OK, a little explaining - basically originally
3378 // we only called MoviesTask if the movie was actually
3379 // playing (not paused or stopped)... this was before
3380 // we realized MoviesTask actually handles repainting
3381 // of the current frame - so if you were to resize
3382 // or something it would previously not redraw that
3383 // portion of the movie.
3384 //
3385 // So now we call MoviesTask always so that it repaints
3386 // correctly.
3387 //
3388 m_pLib->MoviesTask(m_movie, 0);
3389
3390 //
3391 // Handle the stop event - if the movie has reached
3392 // the end, notify our handler
3393 //
3394 // m_bPlaying == !(Stopped | Paused)
3395 //
3396 if (m_parent->m_bPlaying)
3397 {
3398 if (m_pLib->IsMovieDone(m_movie))
3399 {
3400 if ( m_parent->SendStopEvent() )
3401 {
3402 m_parent->Stop();
3403 wxASSERT(m_pLib->GetMoviesError() == noErr);
3404
3405 m_parent->QueueFinishEvent();
3406 }
3407 }
3408 }
3409 }
3410
3411 protected:
3412 Movie m_movie; // Our movie instance
3413 wxQTMediaBackend* m_parent; //Backend pointer
3414 wxQuickTimeLibrary* m_pLib; //Interfaces
3415 };
3416
3417
3418 //---------------------------------------------------------------------------
3419 // wxQTMediaBackend::QTWndProc
3420 //
3421 // Forwards events to the Movie Controller so that it can
3422 // redraw itself/process messages etc..
3423 //---------------------------------------------------------------------------
3424 LRESULT CALLBACK wxQTMediaBackend::QTWndProc(HWND hWnd, UINT nMsg,
3425 WPARAM wParam, LPARAM lParam)
3426 {
3427 wxQTMediaBackend* pThis = (wxQTMediaBackend*)wxGetWindowUserData(hWnd);
3428
3429 MSG msg;
3430 msg.hwnd = hWnd;
3431 msg.message = nMsg;
3432 msg.wParam = wParam;
3433 msg.lParam = lParam;
3434 msg.time = 0;
3435 msg.pt.x = 0;
3436 msg.pt.y = 0;
3437 EventRecord theEvent;
3438 pThis->m_lib.NativeEventToMacEvent(&msg, &theEvent);
3439 pThis->m_lib.MCIsPlayerEvent(pThis->m_pMC, &theEvent);
3440
3441 return pThis->m_ctrl->MSWWindowProc(nMsg, wParam, lParam);
3442 }
3443
3444 //---------------------------------------------------------------------------
3445 // wxQTMediaBackend Destructor
3446 //
3447 // Sets m_timer to NULL signifying we havn't loaded anything yet
3448 //---------------------------------------------------------------------------
3449 wxQTMediaBackend::wxQTMediaBackend()
3450 : m_movie(NULL), m_bPlaying(false), m_timer(NULL), m_pMC(NULL)
3451 {
3452 }
3453
3454 //---------------------------------------------------------------------------
3455 // wxQTMediaBackend Destructor
3456 //
3457 // 1) Cleans up the QuickTime movie instance
3458 // 2) Decrements the QuickTime reference counter - if this reaches
3459 // 0, QuickTime shuts down
3460 // 3) Decrements the QuickTime Windows Media Layer reference counter -
3461 // if this reaches 0, QuickTime shuts down the Windows Media Layer
3462 //---------------------------------------------------------------------------
3463 wxQTMediaBackend::~wxQTMediaBackend()
3464 {
3465 if (m_movie)
3466 Cleanup();
3467
3468 if (m_lib.IsOk())
3469 {
3470 if (m_pMC)
3471 {
3472 m_lib.DisposeMovieController(m_pMC);
3473 // m_pMC = NULL;
3474 }
3475
3476 // destroy wxQTMediaEvtHandler we pushed on it
3477 m_ctrl->PopEventHandler(true);
3478
3479 m_lib.DestroyPortAssociation(
3480 (CGrafPtr)m_lib.GetNativeWindowPort(m_ctrl->GetHWND()));
3481
3482 //Note that ExitMovies() is not necessary, but
3483 //the docs are fuzzy on whether or not TerminateQTML is
3484 m_lib.ExitMovies();
3485 m_lib.TerminateQTML();
3486 }
3487 }
3488
3489 //---------------------------------------------------------------------------
3490 // wxQTMediaBackend::CreateControl
3491 //
3492 // 1) Intializes QuickTime
3493 // 2) Creates the control window
3494 //---------------------------------------------------------------------------
3495 bool wxQTMediaBackend::CreateControl(wxControl* ctrl, wxWindow* parent,
3496 wxWindowID id,
3497 const wxPoint& pos,
3498 const wxSize& size,
3499 long style,
3500 const wxValidator& validator,
3501 const wxString& name)
3502 {
3503 if (!m_lib.Initialize())
3504 return false;
3505
3506 int nError = m_lib.InitializeQTML(0);
3507 if (nError != noErr) //-2093 no dll
3508 {
3509 wxFAIL_MSG(wxString::Format(wxT("Couldn't Initialize Quicktime-%i"), nError));
3510 return false;
3511 }
3512
3513 m_lib.EnterMovies();
3514
3515 // Create window
3516 // By default wxWindow(s) is created with a border -
3517 // so we need to get rid of those
3518 //
3519 // Since we don't have a child window like most other
3520 // backends, we don't need wxCLIP_CHILDREN
3521 if ( !ctrl->wxControl::Create(parent, id, pos, size,
3522 (style & ~wxBORDER_MASK) | wxBORDER_NONE,
3523 validator, name) )
3524 {
3525 return false;
3526 }
3527
3528 m_ctrl = wxStaticCast(ctrl, wxMediaCtrl);
3529
3530 // Create a port association for our window so we
3531 // can use it as a WindowRef
3532 m_lib.CreatePortAssociation(m_ctrl->GetHWND(), NULL, 0L);
3533
3534 // Part of a suggestion from Greg Hazel
3535 // to repaint movie when idle
3536 m_ctrl->PushEventHandler(new wxQTMediaEvtHandler(this, m_ctrl->GetHWND()));
3537
3538 // done
3539 return true;
3540 }
3541
3542 //---------------------------------------------------------------------------
3543 // wxQTMediaBackend::Load (file version)
3544 //
3545 // 1) Get an FSSpec from the Windows path name
3546 // 2) Open the movie
3547 // 3) Obtain the movie instance from the movie resource
3548 // 4) Close the movie resource
3549 // 5) Finish loading
3550 //---------------------------------------------------------------------------
3551 bool wxQTMediaBackend::Load(const wxString& fileName)
3552 {
3553 if (m_movie)
3554 Cleanup();
3555
3556 bool result = true;
3557 OSErr err = noErr;
3558 short movieResFile = 0; //= 0 because of annoying VC6 warning
3559 FSSpec sfFile;
3560
3561 err = m_lib.NativePathNameToFSSpec(
3562 (char*) (const char*) fileName.mb_str(),
3563 &sfFile, 0);
3564 result = (err == noErr);
3565
3566 if (result)
3567 {
3568 err = m_lib.OpenMovieFile(&sfFile, &movieResFile, fsRdPerm);
3569 result = (err == noErr);
3570 }
3571
3572 if (result)
3573 {
3574 short movieResID = 0;
3575 Str255 movieName;
3576
3577 err = m_lib.NewMovieFromFile(
3578 &m_movie,
3579 movieResFile,
3580 &movieResID,
3581 movieName,
3582 newMovieActive,
3583 NULL ); // wasChanged
3584 result = (err == noErr && m_lib.GetMoviesStickyError() == noErr);
3585
3586 // check m_lib.GetMoviesStickyError() because it may not find the
3587 // proper codec and play black video and other strange effects,
3588 // not to mention mess up the dynamic backend loading scheme
3589 // of wxMediaCtrl - so it just does what the QuickTime player does
3590 if (result)
3591 {
3592 m_lib.CloseMovieFile(movieResFile);
3593 FinishLoad();
3594 }
3595 }
3596
3597 return result;
3598 }
3599
3600 //---------------------------------------------------------------------------
3601 // wxQTMediaBackend::PPRMProc (static)
3602 //
3603 // Called when done PrePrerolling the movie.
3604 // Note that in 99% of the cases this does nothing...
3605 // Anyway we set up the loading timer here to tell us when the movie is done
3606 //---------------------------------------------------------------------------
3607 void wxQTMediaBackend::PPRMProc (Movie theMovie,
3608 OSErr WXUNUSED_UNLESS_DEBUG(theErr),
3609 void* theRefCon)
3610 {
3611 wxASSERT( theMovie );
3612 wxASSERT( theRefCon );
3613 wxASSERT( theErr == noErr );
3614
3615 wxQTMediaBackend* pBE = (wxQTMediaBackend*) theRefCon;
3616
3617 long lTime = pBE->m_lib.GetMovieTime(theMovie,NULL);
3618 Fixed rate = pBE->m_lib.GetMoviePreferredRate(theMovie);
3619 pBE->m_lib.PrerollMovie(theMovie, lTime, rate);
3620 pBE->m_timer = new wxQTLoadTimer(pBE->m_movie, pBE, &pBE->m_lib);
3621 pBE->m_timer->Start(MOVIE_DELAY);
3622 }
3623
3624 //---------------------------------------------------------------------------
3625 // wxQTMediaBackend::Load (URL Version)
3626 //
3627 // 1) Build an escaped URI from location
3628 // 2) Create a handle to store the URI string
3629 // 3) Put the URI string inside the handle
3630 // 4) Make a QuickTime URL data ref from the handle with the URI in it
3631 // 5) Clean up the URI string handle
3632 // 6) Do some prerolling
3633 // 7) Finish Loading
3634 //---------------------------------------------------------------------------
3635 bool wxQTMediaBackend::Load(const wxURI& location)
3636 {
3637 if (m_movie)
3638 Cleanup();
3639
3640 wxString theURI = location.BuildURI();
3641
3642 Handle theHandle = m_lib.NewHandleClear(theURI.length() + 1);
3643 wxASSERT(theHandle);
3644
3645 m_lib.BlockMove(theURI.mb_str(), *theHandle, theURI.length() + 1);
3646
3647 // create the movie from the handle that refers to the URI
3648 OSErr err = m_lib.NewMovieFromDataRef(&m_movie, newMovieActive |
3649 newMovieAsyncOK
3650 /* | newMovieIdleImportOK */,
3651 NULL, theHandle,
3652 URLDataHandlerSubType);
3653
3654 m_lib.DisposeHandle(theHandle);
3655
3656 if (err == noErr)
3657 {
3658 long timeNow;
3659 Fixed playRate;
3660
3661 timeNow = m_lib.GetMovieTime(m_movie, NULL);
3662 wxASSERT(m_lib.GetMoviesError() == noErr);
3663
3664 playRate = m_lib.GetMoviePreferredRate(m_movie);
3665 wxASSERT(m_lib.GetMoviesError() == noErr);
3666
3667 // Note that the callback here is optional,
3668 // but without it PrePrerollMovie can be buggy
3669 // (see Apple ml). Also, some may wonder
3670 // why we need this at all - this is because
3671 // Apple docs say QuickTime streamed movies
3672 // require it if you don't use a Movie Controller,
3673 // which we don't by default.
3674 //
3675 m_lib.PrePrerollMovie(m_movie, timeNow, playRate,
3676 (WXFARPROC)wxQTMediaBackend::PPRMProc,
3677 (void*)this);
3678
3679 return true;
3680 }
3681 else
3682 return false;
3683 }
3684
3685 //---------------------------------------------------------------------------
3686 // wxQTMediaBackend::FinishLoad
3687 //
3688 // 1) Create the movie timer
3689 // 2) Get real size of movie for GetBestSize/sizers
3690 // 3) Set the movie time scale to something usable so that seeking
3691 // etc. will work correctly
3692 // 4) Set our Movie Controller to display the movie if it exists,
3693 // otherwise set the bounds of the Movie
3694 // 5) Refresh parent window
3695 //---------------------------------------------------------------------------
3696 void wxQTMediaBackend::FinishLoad()
3697 {
3698 // Create the playing/streaming timer
3699 m_timer = new wxQTPlayTimer(m_movie, (wxQTMediaBackend*) this, &m_lib);
3700 wxASSERT(m_timer);
3701
3702 m_timer->Start(MOVIE_DELAY, wxTIMER_CONTINUOUS);
3703
3704 // get the real size of the movie
3705 Rect outRect;
3706 memset(&outRect, 0, sizeof(Rect)); // suppress annoying VC6 warning
3707 m_lib.GetMovieNaturalBoundsRect (m_movie, &outRect);
3708 wxASSERT(m_lib.GetMoviesError() == noErr);
3709
3710 m_bestSize.x = outRect.right - outRect.left;
3711 m_bestSize.y = outRect.bottom - outRect.top;
3712
3713 // Handle the movie GWorld
3714 if (m_pMC)
3715 {
3716 Point thePoint;
3717 thePoint.h = thePoint.v = 0;
3718 m_lib.MCSetMovie(m_pMC, m_movie,
3719 m_lib.GetNativeWindowPort(m_ctrl->GetHandle()),
3720 thePoint);
3721 m_lib.MCSetVisible(m_pMC, true);
3722 m_bestSize.y += 16;
3723 }
3724 else
3725 {
3726 m_lib.SetMovieGWorld(m_movie,
3727 (CGrafPtr) m_lib.GetNativeWindowPort(m_ctrl->GetHWND()),
3728 NULL);
3729 }
3730
3731 // Set the movie to millisecond precision
3732 m_lib.SetMovieTimeScale(m_movie, 1000);
3733 wxASSERT(m_lib.GetMoviesError() == noErr);
3734
3735 NotifyMovieLoaded();
3736 }
3737
3738 //---------------------------------------------------------------------------
3739 // wxQTMediaBackend::Play
3740 //
3741 // 1) Start the QT movie
3742 // 2) Start the movie loading timer
3743 //
3744 // NOTE: This will still return success even when
3745 // the movie is still loading, and as mentioned in wxQTLoadTimer
3746 // I don't know of a way to force this to be sync - so if its
3747 // still loading the function will return true but the movie will
3748 // still be in the stopped state
3749 //---------------------------------------------------------------------------
3750 bool wxQTMediaBackend::Play()
3751 {
3752 m_lib.StartMovie(m_movie);
3753 m_bPlaying = true;
3754
3755 return m_lib.GetMoviesError() == noErr;
3756 }
3757
3758 //---------------------------------------------------------------------------
3759 // wxQTMediaBackend::Pause
3760 //
3761 // 1) Stop the movie
3762 // 2) Stop the movie timer
3763 //---------------------------------------------------------------------------
3764 bool wxQTMediaBackend::Pause()
3765 {
3766 m_bPlaying = false;
3767 m_lib.StopMovie(m_movie);
3768
3769 return m_lib.GetMoviesError() == noErr;
3770 }
3771
3772 //---------------------------------------------------------------------------
3773 // wxQTMediaBackend::Stop
3774 //
3775 // 1) Stop the movie
3776 // 2) Stop the movie timer
3777 // 3) Seek to the beginning of the movie
3778 //---------------------------------------------------------------------------
3779 bool wxQTMediaBackend::Stop()
3780 {
3781 m_bPlaying = false;
3782
3783 m_lib.StopMovie(m_movie);
3784 if (m_lib.GetMoviesError() == noErr)
3785 m_lib.GoToBeginningOfMovie(m_movie);
3786
3787 return m_lib.GetMoviesError() == noErr;
3788 }
3789
3790 //---------------------------------------------------------------------------
3791 // wxQTMediaBackend::GetPlaybackRate
3792 //
3793 // Get the movie playback rate from ::GetMovieRate
3794 //---------------------------------------------------------------------------
3795 double wxQTMediaBackend::GetPlaybackRate()
3796 {
3797 return ( ((double)m_lib.GetMovieRate(m_movie)) / 0x10000);
3798 }
3799
3800 //---------------------------------------------------------------------------
3801 // wxQTMediaBackend::SetPlaybackRate
3802 //
3803 // Convert dRate to Fixed and Set the movie rate through SetMovieRate
3804 //---------------------------------------------------------------------------
3805 bool wxQTMediaBackend::SetPlaybackRate(double dRate)
3806 {
3807 m_lib.SetMovieRate(m_movie, (Fixed) (dRate * 0x10000));
3808
3809 return m_lib.GetMoviesError() == noErr;
3810 }
3811
3812 //---------------------------------------------------------------------------
3813 // wxQTMediaBackend::SetPosition
3814 //
3815 // 1) Create a time record struct (TimeRecord) with appropriate values
3816 // 2) Pass struct to SetMovieTime
3817 //---------------------------------------------------------------------------
3818 bool wxQTMediaBackend::SetPosition(wxLongLong where)
3819 {
3820 // NB: For some reason SetMovieTime does not work
3821 // correctly with the Quicktime Windows SDK (6)
3822 // From Muskelkatermann at the wxForum
3823 // http://www.solidsteel.nl/users/wxwidgets/viewtopic.php?t=2957
3824 // RN - note that I have not verified this but there
3825 // is no harm in calling SetMovieTimeValue instead
3826 #if 0
3827 TimeRecord theTimeRecord;
3828 memset(&theTimeRecord, 0, sizeof(TimeRecord));
3829 theTimeRecord.value.lo = where.GetLo();
3830 theTimeRecord.scale = m_lib.GetMovieTimeScale(m_movie);
3831 theTimeRecord.base = m_lib.GetMovieTimeBase(m_movie);
3832 m_lib.SetMovieTime(m_movie, &theTimeRecord);
3833 #else
3834 m_lib.SetMovieTimeValue(m_movie, where.GetLo());
3835 #endif
3836
3837 return (m_lib.GetMoviesError() == noErr);
3838 }
3839
3840 //---------------------------------------------------------------------------
3841 // wxQTMediaBackend::GetPosition
3842 //
3843 // 1) Calls GetMovieTime to get the position we are in in the movie
3844 // in milliseconds (we called
3845 //---------------------------------------------------------------------------
3846 wxLongLong wxQTMediaBackend::GetPosition()
3847 {
3848 return m_lib.GetMovieTime(m_movie, NULL);
3849 }
3850
3851 //---------------------------------------------------------------------------
3852 // wxQTMediaBackend::GetVolume
3853 //
3854 // Gets the volume through GetMovieVolume - which returns a 16 bit short -
3855 //
3856 // +--------+--------+
3857 // + (1) + (2) +
3858 // +--------+--------+
3859 //
3860 // (1) first 8 bits are value before decimal
3861 // (2) second 8 bits are value after decimal
3862 //
3863 // Volume ranges from -1.0 (gain but no sound), 0 (no sound and no gain) to
3864 // 1 (full gain and sound)
3865 //---------------------------------------------------------------------------
3866 double wxQTMediaBackend::GetVolume()
3867 {
3868 short sVolume = m_lib.GetMovieVolume(m_movie);
3869 wxASSERT(m_lib.GetMoviesError() == noErr);
3870
3871 if (sVolume & (128 << 8)) //negative - no sound
3872 return 0.0;
3873
3874 return sVolume / 256.0;
3875 }
3876
3877 //---------------------------------------------------------------------------
3878 // wxQTMediaBackend::SetVolume
3879 //
3880 // Sets the volume through SetMovieVolume - which takes a 16 bit short -
3881 //
3882 // +--------+--------+
3883 // + (1) + (2) +
3884 // +--------+--------+
3885 //
3886 // (1) first 8 bits are value before decimal
3887 // (2) second 8 bits are value after decimal
3888 //
3889 // Volume ranges from -1.0 (gain but no sound), 0 (no sound and no gain) to
3890 // 1 (full gain and sound)
3891 //---------------------------------------------------------------------------
3892 bool wxQTMediaBackend::SetVolume(double dVolume)
3893 {
3894 m_lib.SetMovieVolume(m_movie, (short) (dVolume * 256));
3895 return m_lib.GetMoviesError() == noErr;
3896 }
3897
3898 //---------------------------------------------------------------------------
3899 // wxQTMediaBackend::GetDuration
3900 //
3901 // Calls GetMovieDuration
3902 //---------------------------------------------------------------------------
3903 wxLongLong wxQTMediaBackend::GetDuration()
3904 {
3905 return m_lib.GetMovieDuration(m_movie);
3906 }
3907
3908 //---------------------------------------------------------------------------
3909 // wxQTMediaBackend::GetState
3910 //
3911 // Determines the current state:
3912 // if we are at the beginning, then we are stopped
3913 //---------------------------------------------------------------------------
3914 wxMediaState wxQTMediaBackend::GetState()
3915 {
3916 if (m_bPlaying)
3917 return wxMEDIASTATE_PLAYING;
3918 else if ( !m_movie || wxQTMediaBackend::GetPosition() == 0 )
3919 return wxMEDIASTATE_STOPPED;
3920 else
3921 return wxMEDIASTATE_PAUSED;
3922 }
3923
3924 //---------------------------------------------------------------------------
3925 // wxQTMediaBackend::Cleanup
3926 //
3927 // Diposes of the movie timer, Disassociates the Movie Controller with
3928 // movie and hides it if it exists, and stops and disposes
3929 // of the QT movie
3930 //---------------------------------------------------------------------------
3931 void wxQTMediaBackend::Cleanup()
3932 {
3933 m_bPlaying = false;
3934
3935 if (m_timer)
3936 {
3937 delete m_timer;
3938 m_timer = NULL;
3939 }
3940
3941 m_lib.StopMovie(m_movie);
3942
3943 if (m_pMC)
3944 {
3945 Point thePoint;
3946 thePoint.h = thePoint.v = 0;
3947 m_lib.MCSetVisible(m_pMC, false);
3948 m_lib.MCSetMovie(m_pMC, NULL, NULL, thePoint);
3949 }
3950
3951 m_lib.DisposeMovie(m_movie);
3952 m_movie = NULL;
3953 }
3954
3955 //---------------------------------------------------------------------------
3956 // wxQTMediaBackend::ShowPlayerControls
3957 //
3958 // Creates a movie controller for the Movie if the user wants it
3959 //---------------------------------------------------------------------------
3960 bool wxQTMediaBackend::ShowPlayerControls(wxMediaCtrlPlayerControls flags)
3961 {
3962 if (m_pMC)
3963 {
3964 // restore old wndproc
3965 wxSetWindowProc((HWND)m_ctrl->GetHWND(), wxWndProc);
3966 m_lib.DisposeMovieController(m_pMC);
3967 m_pMC = NULL;
3968
3969 // movie controller height
3970 m_bestSize.y -= 16;
3971 }
3972
3973 if (flags && m_movie)
3974 {
3975 Rect rect;
3976 wxRect wxrect = m_ctrl->GetClientRect();
3977
3978 // make room for controller
3979 if (wxrect.width < 320)
3980 wxrect.width = 320;
3981
3982 rect.top = (short)wxrect.y;
3983 rect.left = (short)wxrect.x;
3984 rect.right = (short)(rect.left + wxrect.width);
3985 rect.bottom = (short)(rect.top + wxrect.height);
3986
3987 if (!m_pMC)
3988 {
3989 m_pMC = m_lib.NewMovieController(m_movie, &rect, mcTopLeftMovie |
3990 // mcScaleMovieToFit |
3991 // mcWithBadge |
3992 mcWithFrame);
3993 m_lib.MCDoAction(m_pMC, 32, (void*)true); // mcActionSetKeysEnabled
3994 m_lib.MCSetActionFilterWithRefCon(m_pMC,
3995 (WXFARPROC)wxQTMediaBackend::MCFilterProc, (void*)this);
3996 m_bestSize.y += 16; // movie controller height
3997
3998 // By default the movie controller uses its own colour palette
3999 // for the movie which can be bad on some files, so turn it off.
4000 // Also turn off its frame / border for the movie
4001 // Also take care of a couple of the interface flags here
4002 long mcFlags = 0;
4003 m_lib.MCDoAction(m_pMC, 39/*mcActionGetFlags*/, (void*)&mcFlags);
4004
4005 mcFlags |=
4006 // (1<< 0) /*mcFlagSuppressMovieFrame*/ |
4007 (1<< 3) /*mcFlagsUseWindowPalette*/
4008 | ((flags & wxMEDIACTRLPLAYERCONTROLS_STEP)
4009 ? 0 : (1<< 1) /*mcFlagSuppressStepButtons*/)
4010 | ((flags & wxMEDIACTRLPLAYERCONTROLS_VOLUME)
4011 ? 0 : (1<< 2) /*mcFlagSuppressSpeakerButton*/)
4012 // | (1<< 4) /*mcFlagDontInvalidate*/ // if we take care of repainting ourselves
4013 ;
4014
4015 m_lib.MCDoAction(m_pMC, 38/*mcActionSetFlags*/, (void*)mcFlags);
4016
4017 // intercept the wndproc of our control window
4018 wxSetWindowProc((HWND)m_ctrl->GetHWND(), wxQTMediaBackend::QTWndProc);
4019
4020 // set the user data of our window
4021 wxSetWindowUserData((HWND)m_ctrl->GetHWND(), this);
4022 }
4023 }
4024
4025 NotifyMovieSizeChanged();
4026
4027 return m_lib.GetMoviesError() == noErr;
4028 }
4029
4030 //---------------------------------------------------------------------------
4031 // wxQTMediaBackend::MCFilterProc (static)
4032 //
4033 // Callback for when the movie controller recieves a message
4034 //---------------------------------------------------------------------------
4035 Boolean wxQTMediaBackend::MCFilterProc(MovieController WXUNUSED(theController),
4036 short action,
4037 void * WXUNUSED(params),
4038 LONG_PTR refCon)
4039 {
4040 // NB: potential optimisation
4041 // if (action == 1)
4042 // return 0;
4043
4044 wxQTMediaBackend* pThis = (wxQTMediaBackend*)refCon;
4045
4046 switch (action)
4047 {
4048 case 1:
4049 // don't process idle events
4050 break;
4051
4052 case 8:
4053 // play button triggered - MC will set movie to opposite state
4054 // of current - playing ? paused : playing
4055 if (pThis)
4056 pThis->m_bPlaying = !(pThis->m_bPlaying);
4057
4058 // NB: Sometimes it doesn't redraw properly -
4059 // if you click on the button but don't move the mouse
4060 // the button will not change its state until you move
4061 // mcActionDraw and Refresh/Update combo do nothing
4062 // to help this unfortunately
4063 break;
4064
4065 default:
4066 break;
4067 }
4068
4069 return 0;
4070 }
4071
4072 //---------------------------------------------------------------------------
4073 // wxQTMediaBackend::GetVideoSize
4074 //
4075 // Returns the actual size of the QT movie
4076 //---------------------------------------------------------------------------
4077 wxSize wxQTMediaBackend::GetVideoSize() const
4078 {
4079 return m_bestSize;
4080 }
4081
4082 //---------------------------------------------------------------------------
4083 // wxQTMediaBackend::Move
4084 //
4085 // Sets the bounds of either the Movie or Movie Controller
4086 //---------------------------------------------------------------------------
4087 void wxQTMediaBackend::Move(int WXUNUSED(x), int WXUNUSED(y), int w, int h)
4088 {
4089 if (m_movie)
4090 {
4091 // make room for controller
4092 if (m_pMC)
4093 {
4094 if (w < 320)
4095 w = 320;
4096
4097 Rect theRect = {0, 0, (short)h, (short)w};
4098 m_lib.MCSetControllerBoundsRect(m_pMC, &theRect);
4099 }
4100 else
4101 {
4102 Rect theRect = {0, 0, (short)h, (short)w};
4103 m_lib.SetMovieBox(m_movie, &theRect);
4104 }
4105
4106 wxASSERT(m_lib.GetMoviesError() == noErr);
4107 }
4108 }
4109
4110 //---------------------------------------------------------------------------
4111 // wxQTMediaBackend::OnEraseBackground
4112 //
4113 // Suggestion from Greg Hazel to repaint the movie when idle
4114 // (on pause also)
4115 //
4116 // TODO: We may be repainting too much here - under what exact circumstances
4117 // do we need this? I think Move also repaints correctly for the Movie
4118 // Controller, so in that instance we don't need this either
4119 //---------------------------------------------------------------------------
4120 void wxQTMediaEvtHandler::OnEraseBackground(wxEraseEvent& evt)
4121 {
4122 wxQuickTimeLibrary& m_pLib = m_qtb->m_lib;
4123
4124 if ( m_qtb->m_pMC )
4125 {
4126 // repaint movie controller
4127 m_pLib.MCDoAction(m_qtb->m_pMC, 2 /*mcActionDraw*/,
4128 m_pLib.GetNativeWindowPort(m_hwnd));
4129 }
4130 else if ( m_qtb->m_movie )
4131 {
4132 // no movie controller
4133 CGrafPtr port = (CGrafPtr)m_pLib.GetNativeWindowPort(m_hwnd);
4134
4135 m_pLib.BeginUpdate(port);
4136 m_pLib.UpdateMovie(m_qtb->m_movie);
4137 wxASSERT(m_pLib.GetMoviesError() == noErr);
4138 m_pLib.EndUpdate(port);
4139 }
4140 else
4141 {
4142 // no movie
4143 // let the system repaint the window
4144 evt.Skip();
4145 }
4146 }
4147
4148 //---------------------------------------------------------------------------
4149 // End QT Backend
4150 //---------------------------------------------------------------------------
4151
4152 //in source file that contains stuff you don't directly use
4153 #include "wx/html/forcelnk.h"
4154 FORCE_LINK_ME(basewxmediabackends)
4155
4156 #endif //wxUSE_MEDIACTRL