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