]> git.saurik.com Git - wxWidgets.git/blob - src/msw/mediactrl.cpp
bfad1da456ae5f0a74560b020b07eec9b0985172
[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 {
1626 wxLogNull noLog;
1627 m_pAX->DissociateHandle();
1628 }
1629
1630 delete m_pAX;
1631 m_pAM->Release();
1632
1633 if (m_pMP)
1634 m_pMP->Release();
1635 }
1636 }
1637
1638 //---------------------------------------------------------------------------
1639 // wxAMMediaBackend::Clear
1640 //
1641 // Free up interfaces and memory allocated by LoadXXX
1642 //---------------------------------------------------------------------------
1643 void wxAMMediaBackend::Clear()
1644 {
1645 if (m_pTimer)
1646 {
1647 delete m_pTimer;
1648 m_pTimer = NULL;
1649 }
1650 }
1651
1652 //---------------------------------------------------------------------------
1653 // wxAMMediaBackend::CreateControl
1654 //---------------------------------------------------------------------------
1655 bool wxAMMediaBackend::CreateControl(wxControl* ctrl, wxWindow* parent,
1656 wxWindowID id,
1657 const wxPoint& pos,
1658 const wxSize& size,
1659 long style,
1660 const wxValidator& validator,
1661 const wxString& name)
1662 {
1663 // First get the AMGetErrorText procedure in debug
1664 // mode for more meaningful messages
1665 #ifdef __WXDEBUG__
1666 if ( m_dllQuartz.Load(_T("quartz.dll"), wxDL_VERBATIM) )
1667 {
1668 m_lpAMGetErrorText = (LPAMGETERRORTEXT)
1669 m_dllQuartz.GetSymbolAorW(wxT("AMGetErrorText"));
1670 }
1671 #endif
1672
1673 // Now determine which (if any) media player interface is
1674 // available - IMediaPlayer or IActiveMovie
1675 if ( ::CoCreateInstance(CLSID_MediaPlayer, NULL,
1676 CLSCTX_INPROC_SERVER,
1677 IID_IMediaPlayer, (void**)&m_pMP) != 0 )
1678 {
1679 if ( ::CoCreateInstance(CLSID_ActiveMovie, NULL,
1680 CLSCTX_INPROC_SERVER,
1681 IID_IActiveMovie, (void**)&m_pAM) != 0 )
1682 return false;
1683 m_pAM->QueryInterface(IID_IMediaPlayer, (void**)&m_pMP);
1684 }
1685 else
1686 {
1687 m_pMP->QueryInterface(IID_IActiveMovie, (void**)&m_pAM);
1688 }
1689
1690 //
1691 // Create window
1692 // By default wxWindow(s) is created with a border -
1693 // so we need to get rid of those
1694 //
1695 // Since we don't have a child window like most other
1696 // backends, we don't need wxCLIP_CHILDREN
1697 //
1698 if ( !ctrl->wxControl::Create(parent, id, pos, size,
1699 (style & ~wxBORDER_MASK) | wxBORDER_NONE,
1700 validator, name) )
1701 return false;
1702
1703 // Now create the ActiveX container along with the media player
1704 // interface and query them
1705 //
1706 m_ctrl = wxStaticCast(ctrl, wxMediaCtrl);
1707 m_pAX = new wxActiveXContainer(ctrl,
1708 m_pMP ? IID_IMediaPlayer : IID_IActiveMovie,
1709 m_pAM);
1710
1711 // Here we set up wx-specific stuff for the default
1712 // settings wxMediaCtrl says it will stay to
1713 //
1714 if (m_pMP)
1715 {
1716 m_pMP->put_DisplaySize(mpFitToSize);
1717
1718 // TODO: Unsure what actual effect this has
1719 m_pMP->put_WindowlessVideo(VARIANT_TRUE);
1720 }
1721 else
1722 m_pAM->put_MovieWindowSize(amvDoubleOriginalSize);
1723
1724 // by default true
1725 m_pAM->put_AutoStart(VARIANT_FALSE);
1726
1727 // by default enabled
1728 wxAMMediaBackend::ShowPlayerControls(wxMEDIACTRLPLAYERCONTROLS_NONE);
1729
1730 // by default with AM only 0.5
1731 wxAMMediaBackend::SetVolume(1.0);
1732
1733 // don't erase the background of our control window
1734 // so that resizing is a bit smoother
1735 m_ctrl->SetBackgroundStyle(wxBG_STYLE_CUSTOM);
1736
1737 // success
1738 return true;
1739 }
1740
1741 //---------------------------------------------------------------------------
1742 // wxAMMediaBackend::Load (file version)
1743 //---------------------------------------------------------------------------
1744 bool wxAMMediaBackend::Load(const wxString& fileName)
1745 {
1746 return DoLoad(fileName);
1747 }
1748
1749 //---------------------------------------------------------------------------
1750 // wxAMMediaBackend::Load (URL Version)
1751 //---------------------------------------------------------------------------
1752 bool wxAMMediaBackend::Load(const wxURI& location)
1753 {
1754 // Turn off loading from a proxy as user
1755 // may have set it previously
1756 INSPlay* pPlay = NULL;
1757 m_pAM->QueryInterface(IID_INSPlay, (void**) &pPlay);
1758 if (pPlay)
1759 {
1760 pPlay->put_UseHTTPProxy(VARIANT_FALSE);
1761 pPlay->Release();
1762 }
1763
1764 return DoLoad(location.BuildURI());
1765 }
1766
1767 //---------------------------------------------------------------------------
1768 // wxAMMediaBackend::Load (URL Version with Proxy)
1769 //---------------------------------------------------------------------------
1770 bool wxAMMediaBackend::Load(const wxURI& location, const wxURI& proxy)
1771 {
1772 // Set the proxy of the NETSHOW interface
1773 INSPlay* pPlay = NULL;
1774 m_pAM->QueryInterface(IID_INSPlay, (void**) &pPlay);
1775
1776 if (pPlay)
1777 {
1778 pPlay->put_UseHTTPProxy(VARIANT_TRUE);
1779 pPlay->put_HTTPProxyHost(wxBasicString(proxy.GetServer()).Get());
1780 pPlay->put_HTTPProxyPort(wxAtoi(proxy.GetPort()));
1781 pPlay->Release();
1782 }
1783
1784 return DoLoad(location.BuildURI());
1785 }
1786
1787 //---------------------------------------------------------------------------
1788 // wxAMMediaBackend::DoLoad
1789 //
1790 // Called by all functions - this actually renders
1791 // the file and sets up the filter graph
1792 //---------------------------------------------------------------------------
1793 bool wxAMMediaBackend::DoLoad(const wxString& location)
1794 {
1795 Clear(); //Clear up previously allocated memory
1796
1797 HRESULT hr;
1798
1799 // Play the movie the normal way through the embedded
1800 // WMP. Supposively Open is better in theory because
1801 // the docs say its async and put_FileName is not -
1802 // but in practice they both seem to be async anyway
1803 if (m_pMP)
1804 hr = m_pMP->Open( wxBasicString(location).Get() );
1805 else
1806 hr = m_pAM->put_FileName( wxBasicString(location).Get() );
1807
1808 if (FAILED(hr))
1809 {
1810 wxAMLOG(hr);
1811 return false;
1812 }
1813
1814 // In AM playing will FAIL if
1815 // the user plays before the media is loaded
1816 m_pTimer = new wxAMLoadTimer(this);
1817 m_pTimer->Start(20);
1818
1819 return true;
1820 }
1821
1822 //---------------------------------------------------------------------------
1823 // wxAMMediaBackend::FinishLoad
1824 //
1825 // Called by our wxAMLoadTimer when the
1826 // embedded WMP tells its the media is ready to play.
1827 //
1828 // Here we get the original size of the video and
1829 // send the loaded event to our watcher :).
1830 //---------------------------------------------------------------------------
1831 void wxAMMediaBackend::FinishLoad()
1832 {
1833 //Get the original video size
1834 m_pAM->get_ImageSourceWidth((long*)&m_bestSize.x);
1835 m_pAM->get_ImageSourceHeight((long*)&m_bestSize.y);
1836
1837 //
1838 //Start the play timer to catch stop events
1839 //Previous load timer cleans up itself
1840 //
1841 m_pTimer = new wxAMPlayTimer(this);
1842
1843 NotifyMovieLoaded();
1844 }
1845
1846 //---------------------------------------------------------------------------
1847 // wxAMMediaBackend::ShowPlayerControls
1848 //---------------------------------------------------------------------------
1849 bool wxAMMediaBackend::ShowPlayerControls(wxMediaCtrlPlayerControls flags)
1850 {
1851 // Note that IMediaPlayer doesn't have a statusbar by
1852 // default but IActiveMovie does - so lets try to keep
1853 // the interface consistant
1854 if (!flags)
1855 {
1856 m_pAM->put_Enabled(VARIANT_FALSE);
1857 m_pAM->put_ShowControls(VARIANT_FALSE);
1858 if (m_pMP)
1859 m_pMP->put_ShowStatusBar(VARIANT_FALSE);
1860 }
1861 else
1862 {
1863 m_pAM->put_Enabled(VARIANT_TRUE);
1864 m_pAM->put_ShowControls(VARIANT_TRUE);
1865
1866 m_pAM->put_ShowPositionControls(
1867 (flags & wxMEDIACTRLPLAYERCONTROLS_STEP) ?
1868 VARIANT_TRUE : VARIANT_FALSE);
1869
1870 if (m_pMP)
1871 {
1872 m_pMP->put_ShowStatusBar(VARIANT_TRUE);
1873 m_pMP->put_ShowAudioControls(
1874 (flags & wxMEDIACTRLPLAYERCONTROLS_VOLUME) ?
1875 VARIANT_TRUE : VARIANT_FALSE);
1876 }
1877 }
1878
1879 return true;
1880 }
1881
1882 //---------------------------------------------------------------------------
1883 // wxAMMediaBackend::Play
1884 //
1885 // Plays the stream. If it is non-seekable, it will restart it (implicit).
1886 //
1887 // Note that we use SUCCEEDED here because run/pause/stop tend to be overly
1888 // picky and return warnings on pretty much every call
1889 //---------------------------------------------------------------------------
1890 bool wxAMMediaBackend::Play()
1891 {
1892 // Actually try to play the movie, even though it may not be loaded yet.
1893 HRESULT hr = m_pAM->Run();
1894 if (SUCCEEDED(hr))
1895 {
1896 m_pTimer->Start(20);
1897 return true;
1898 }
1899
1900 wxAMLOG(hr);
1901
1902 return false;
1903 }
1904
1905 //---------------------------------------------------------------------------
1906 // wxAMMediaBackend::Pause
1907 //
1908 // Pauses the stream.
1909 //---------------------------------------------------------------------------
1910 bool wxAMMediaBackend::Pause()
1911 {
1912 HRESULT hr = m_pAM->Pause();
1913 if (SUCCEEDED(hr))
1914 return true;
1915
1916 wxAMLOG(hr);
1917
1918 return false;
1919 }
1920
1921 //---------------------------------------------------------------------------
1922 // wxAMMediaBackend::Stop
1923 //
1924 // Stops the stream.
1925 //---------------------------------------------------------------------------
1926 bool wxAMMediaBackend::Stop()
1927 {
1928 HRESULT hr = m_pAM->Stop();
1929 if (SUCCEEDED(hr))
1930 {
1931 // Seek to beginning
1932 wxAMMediaBackend::SetPosition(0);
1933
1934 // Stop stop event timer
1935 m_pTimer->Stop();
1936 return true;
1937 }
1938
1939 wxAMLOG(hr);
1940
1941 return false;
1942 }
1943
1944 //---------------------------------------------------------------------------
1945 // wxAMMediaBackend::SetPosition
1946 //
1947 // 1) Translates the current position's time to directshow time,
1948 // which is in a scale of 1 second (in a double)
1949 // 2) Sets the play position of the IMediaSeeking interface -
1950 // passing NULL as the stop position means to keep the old
1951 // stop position
1952 //---------------------------------------------------------------------------
1953 bool wxAMMediaBackend::SetPosition(wxLongLong where)
1954 {
1955 HRESULT hr = m_pAM->put_CurrentPosition(
1956 ((LONGLONG)where.GetValue()) / 1000.0
1957 );
1958 if (FAILED(hr))
1959 {
1960 wxAMLOG(hr);
1961 return false;
1962 }
1963
1964 return true;
1965 }
1966
1967 //---------------------------------------------------------------------------
1968 // wxAMMediaBackend::GetPosition
1969 //
1970 // 1) Obtains the current play and stop positions from IMediaSeeking
1971 // 2) Returns the play position translated to our time base
1972 //---------------------------------------------------------------------------
1973 wxLongLong wxAMMediaBackend::GetPosition()
1974 {
1975 double outCur;
1976 HRESULT hr = m_pAM->get_CurrentPosition(&outCur);
1977 if (FAILED(hr))
1978 {
1979 wxAMLOG(hr);
1980 return 0;
1981 }
1982
1983 // h,m,s,milli - outdur is in 1 second (double)
1984 outCur *= 1000;
1985 wxLongLong ll;
1986 ll.Assign(outCur);
1987
1988 return ll;
1989 }
1990
1991 //---------------------------------------------------------------------------
1992 // wxAMMediaBackend::GetVolume
1993 //
1994 // Gets the volume through the IBasicAudio interface -
1995 // value ranges from 0 (MAX volume) to -10000 (minimum volume).
1996 // -100 per decibel.
1997 //---------------------------------------------------------------------------
1998 double wxAMMediaBackend::GetVolume()
1999 {
2000 long lVolume;
2001 HRESULT hr = m_pAM->get_Volume(&lVolume);
2002 if (FAILED(hr))
2003 {
2004 wxAMLOG(hr);
2005 return 0.0;
2006 }
2007
2008 return pow(10.0, lVolume / 2000.0);
2009 }
2010
2011 //---------------------------------------------------------------------------
2012 // wxAMMediaBackend::SetVolume
2013 //
2014 // Sets the volume through the IBasicAudio interface -
2015 // value ranges from 0 (MAX volume) to -10000 (minimum volume).
2016 // -100 per decibel.
2017 //---------------------------------------------------------------------------
2018 bool wxAMMediaBackend::SetVolume(double dVolume)
2019 {
2020 // pow(10.0, -80.0) to correct 0 == -INF
2021 long lVolume = (long)(2000.0 * log10( pow( 10.0, -80.0) + dVolume ) );
2022 HRESULT hr = m_pAM->put_Volume( lVolume );
2023 if (FAILED(hr))
2024 {
2025 wxAMLOG(hr);
2026 return false;
2027 }
2028
2029 return true;
2030 }
2031
2032 //---------------------------------------------------------------------------
2033 // wxAMMediaBackend::GetDuration
2034 //
2035 // 1) Obtains the duration of the media from IAMMultiMediaStream
2036 // 2) Converts that value to our time base, and returns it
2037 //
2038 // NB: With VBR MP3 files the default DirectShow MP3 render does not
2039 // read the Xing header correctly, resulting in skewed values for duration
2040 // and seeking
2041 //---------------------------------------------------------------------------
2042 wxLongLong wxAMMediaBackend::GetDuration()
2043 {
2044 double outDuration;
2045 HRESULT hr = m_pAM->get_Duration(&outDuration);
2046 if (FAILED(hr))
2047 {
2048 wxAMLOG(hr);
2049 return 0;
2050 }
2051
2052 // h,m,s,milli - outdur is in 1 second (double)
2053 outDuration *= 1000;
2054 wxLongLong ll;
2055 ll.Assign(outDuration);
2056
2057 return ll;
2058 }
2059
2060 //---------------------------------------------------------------------------
2061 // wxAMMediaBackend::GetState
2062 //
2063 // Returns the cached state
2064 //---------------------------------------------------------------------------
2065 wxMediaState wxAMMediaBackend::GetState()
2066 {
2067 StateConstants nState;
2068 HRESULT hr = m_pAM->get_CurrentState(&nState);
2069 if (FAILED(hr))
2070 {
2071 wxAMLOG(hr);
2072 return wxMEDIASTATE_STOPPED;
2073 }
2074
2075 return (wxMediaState)nState;
2076 }
2077
2078 //---------------------------------------------------------------------------
2079 // wxAMMediaBackend::GetPlaybackRate
2080 //
2081 // Pretty simple way of obtaining the playback rate from
2082 // the IMediaSeeking interface
2083 //---------------------------------------------------------------------------
2084 double wxAMMediaBackend::GetPlaybackRate()
2085 {
2086 double dRate;
2087 HRESULT hr = m_pAM->get_Rate(&dRate);
2088 if (FAILED(hr))
2089 {
2090 wxAMLOG(hr);
2091 return 0.0;
2092 }
2093
2094 return dRate;
2095 }
2096
2097 //---------------------------------------------------------------------------
2098 // wxAMMediaBackend::SetPlaybackRate
2099 //
2100 // Sets the playback rate of the media - DirectShow is pretty good
2101 // about this, actually
2102 //---------------------------------------------------------------------------
2103 bool wxAMMediaBackend::SetPlaybackRate(double dRate)
2104 {
2105 HRESULT hr = m_pAM->put_Rate(dRate);
2106 if (FAILED(hr))
2107 {
2108 wxAMLOG(hr);
2109 return false;
2110 }
2111
2112 return true;
2113 }
2114
2115 //---------------------------------------------------------------------------
2116 // wxAMMediaBackend::GetDownloadXXX
2117 //
2118 // Queries for and gets the total size of the file and the current
2119 // progress in downloading that file from the IAMOpenProgress
2120 // interface from the media player interface's filter graph
2121 //---------------------------------------------------------------------------
2122 void wxAMMediaBackend::DoGetDownloadProgress(wxLongLong* pLoadProgress,
2123 wxLongLong* pLoadTotal)
2124 {
2125 LONGLONG loadTotal = 0, loadProgress = 0;
2126 IUnknown* pFG;
2127 IAMOpenProgress* pOP;
2128 HRESULT hr;
2129 hr = m_pAM->get_FilterGraph(&pFG);
2130 if (SUCCEEDED(hr))
2131 {
2132 hr = pFG->QueryInterface(IID_IAMOpenProgress, (void**)&pOP);
2133 if (SUCCEEDED(hr))
2134 {
2135 hr = pOP->QueryProgress(&loadTotal, &loadProgress);
2136 pOP->Release();
2137 }
2138
2139 pFG->Release();
2140 }
2141
2142 if (SUCCEEDED(hr))
2143 {
2144 *pLoadProgress = loadProgress;
2145 *pLoadTotal = loadTotal;
2146 }
2147 else
2148 {
2149 // When not loading from a URL QueryProgress will return
2150 // E_NOINTERFACE or whatever
2151 // wxAMFAIL(hr);
2152 *pLoadProgress = 0;
2153 *pLoadTotal = 0;
2154 }
2155 }
2156
2157 //---------------------------------------------------------------------------
2158 // wxAMMediaBackend::GetVideoSize
2159 //
2160 // Obtains the cached original video size
2161 //---------------------------------------------------------------------------
2162 wxSize wxAMMediaBackend::GetVideoSize() const
2163 {
2164 return m_bestSize;
2165 }
2166
2167 //---------------------------------------------------------------------------
2168 // wxAMMediaBackend::Move
2169 //
2170 // We take care of this in our redrawing
2171 //---------------------------------------------------------------------------
2172 void wxAMMediaBackend::Move(int WXUNUSED(x), int WXUNUSED(y),
2173 int WXUNUSED(w), int WXUNUSED(h))
2174 {
2175 }
2176
2177 //---------------------------------------------------------------------------
2178 // End of wxAMMediaBackend
2179 //---------------------------------------------------------------------------
2180
2181 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2182 //
2183 // wxMCIMediaBackend
2184 //
2185 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2186
2187 #ifndef __WXWINCE__
2188 IMPLEMENT_DYNAMIC_CLASS(wxMCIMediaBackend, wxMediaBackend)
2189
2190 //---------------------------------------------------------------------------
2191 // Usual debugging macros for MCI returns
2192 //---------------------------------------------------------------------------
2193
2194 #ifdef __WXDEBUG__
2195 #define wxMCIVERIFY(arg) \
2196 { \
2197 DWORD nRet; \
2198 if ( (nRet = (arg)) != 0) \
2199 { \
2200 TCHAR sz[5000]; \
2201 mciGetErrorString(nRet, sz, 5000); \
2202 wxFAIL_MSG(wxString::Format(_T("MCI Error:%s"), sz)); \
2203 } \
2204 }
2205 #else
2206 #define wxMCIVERIFY(arg) (arg);
2207 #endif
2208
2209 //---------------------------------------------------------------------------
2210 // Simulation for <digitalv.h>
2211 //
2212 // Mingw and possibly other compilers don't have the digitalv.h header
2213 // that is needed to have some essential features of mci work with
2214 // windows - so we provide the declarations for the types we use here
2215 //---------------------------------------------------------------------------
2216
2217 typedef struct
2218 {
2219 DWORD_PTR dwCallback;
2220 #ifdef MCI_USE_OFFEXT
2221 POINT ptOffset;
2222 POINT ptExtent;
2223 #else
2224 RECT rc;
2225 #endif
2226 }
2227 MCI_DGV_RECT_PARMS;
2228
2229 typedef struct
2230 {
2231 DWORD_PTR dwCallback;
2232 HWND hWnd;
2233 #ifndef _WIN32
2234 WORD wReserved1;
2235 #endif
2236 UINT nCmdShow;
2237 #ifndef _WIN32
2238 WORD wReserved2;
2239 #endif
2240 wxChar* lpstrText;
2241 }
2242 MCI_DGV_WINDOW_PARMS;
2243
2244 typedef struct
2245 {
2246 DWORD_PTR dwCallback;
2247 DWORD dwTimeFormat;
2248 DWORD dwAudio;
2249 DWORD dwFileFormat;
2250 DWORD dwSpeed;
2251 }
2252 MCI_DGV_SET_PARMS;
2253
2254 typedef struct
2255 {
2256 DWORD_PTR dwCallback;
2257 DWORD dwItem;
2258 DWORD dwValue;
2259 DWORD dwOver;
2260 wxChar* lpstrAlgorithm;
2261 wxChar* lpstrQuality;
2262 }
2263 MCI_DGV_SETAUDIO_PARMS;
2264
2265 //---------------------------------------------------------------------------
2266 // wxMCIMediaBackend Constructor
2267 //
2268 // Here we don't need to do much except say we don't have any video :)
2269 //---------------------------------------------------------------------------
2270 wxMCIMediaBackend::wxMCIMediaBackend() : m_hNotifyWnd(NULL), m_bVideo(false)
2271 {
2272 }
2273
2274 //---------------------------------------------------------------------------
2275 // wxMCIMediaBackend Destructor
2276 //
2277 // We close the mci device - note that there may not be an mci device here,
2278 // or it may fail - but we don't really care, since we're destructing
2279 //---------------------------------------------------------------------------
2280 wxMCIMediaBackend::~wxMCIMediaBackend()
2281 {
2282 if (m_hNotifyWnd)
2283 {
2284 mciSendCommand(m_hDev, MCI_CLOSE, 0, 0);
2285 DestroyWindow(m_hNotifyWnd);
2286 m_hNotifyWnd = NULL;
2287 }
2288 }
2289
2290 //---------------------------------------------------------------------------
2291 // wxMCIMediaBackend::Create
2292 //
2293 // Here we just tell wxMediaCtrl that mci does exist (which it does, on all
2294 // msw systems, at least in some form dating back to win16 days)
2295 //---------------------------------------------------------------------------
2296 bool wxMCIMediaBackend::CreateControl(wxControl* ctrl, wxWindow* parent,
2297 wxWindowID id,
2298 const wxPoint& pos,
2299 const wxSize& size,
2300 long style,
2301 const wxValidator& validator,
2302 const wxString& name)
2303 {
2304 // Create window
2305 // By default wxWindow(s) is created with a border -
2306 // so we need to get rid of those, and create with
2307 // wxCLIP_CHILDREN, so that if the driver/backend
2308 // is a child window, it refereshes properly
2309 if ( !ctrl->wxControl::Create(parent, id, pos, size,
2310 (style & ~wxBORDER_MASK) | wxBORDER_NONE | wxCLIP_CHILDREN,
2311 validator, name) )
2312 return false;
2313
2314 m_ctrl = wxStaticCast(ctrl, wxMediaCtrl);
2315
2316 return true;
2317 }
2318
2319 //---------------------------------------------------------------------------
2320 // wxMCIMediaBackend::Load (file version)
2321 //
2322 // Here we have MCI load a file and device, set the time format to our
2323 // default (milliseconds), and set the video (if any) to play in the control
2324 //---------------------------------------------------------------------------
2325 bool wxMCIMediaBackend::Load(const wxString& fileName)
2326 {
2327 // if the user already called load close the previous MCI device
2328 if (m_hNotifyWnd)
2329 {
2330 mciSendCommand(m_hDev, MCI_CLOSE, 0, 0);
2331 DestroyWindow(m_hNotifyWnd);
2332 m_hNotifyWnd = NULL;
2333 }
2334
2335 // Opens a file and has MCI select a device. Normally you'd put
2336 // MCI_OPEN_TYPE in addition to MCI_OPEN_ELEMENT - however if you
2337 // omit this it tells MCI to select the device instead. This is good
2338 // because we have no reliable way of "enumerating" the devices in MCI
2339 MCI_OPEN_PARMS openParms;
2340 openParms.lpstrElementName = (wxChar*) fileName.c_str();
2341
2342 if ( mciSendCommand(0, MCI_OPEN, MCI_OPEN_ELEMENT,
2343 (DWORD)(LPVOID)&openParms) != 0)
2344 return false;
2345
2346 m_hDev = openParms.wDeviceID;
2347
2348 // set the time format for the device to milliseconds
2349 MCI_SET_PARMS setParms;
2350 setParms.dwCallback = 0;
2351 setParms.dwTimeFormat = MCI_FORMAT_MILLISECONDS;
2352
2353 if (mciSendCommand(m_hDev, MCI_SET, MCI_SET_TIME_FORMAT,
2354 (DWORD)(LPVOID)&setParms) != 0)
2355 {
2356 }
2357 return false;
2358
2359 // tell the MCI device to display the video in our wxMediaCtrl
2360 MCI_DGV_WINDOW_PARMS windowParms;
2361 windowParms.hWnd = (HWND)m_ctrl->GetHandle();
2362
2363 m_bVideo = (mciSendCommand(m_hDev, MCI_WINDOW,
2364 0x00010000L, // MCI_DGV_WINDOW_HWND
2365 (DWORD)(LPVOID)&windowParms) == 0);
2366
2367 // Create a hidden window and register to handle MCI events
2368 // Note that wxCanvasClassName is already registered
2369 // and used by all wxWindows and normal wxControls
2370 m_hNotifyWnd = ::CreateWindow(
2371 wxCanvasClassName,
2372 NULL,
2373 0, 0, 0, 0,
2374 0,
2375 (HWND) NULL,
2376 (HMENU)NULL,
2377 wxGetInstance(),
2378 (LPVOID)NULL );
2379
2380 if (!m_hNotifyWnd)
2381 {
2382 wxLogSysError( wxT("Could not create hidden needed for ")
2383 wxT("registering for MCI events!") );
2384
2385 return false;
2386 }
2387
2388 wxSetWindowProc(m_hNotifyWnd, wxMCIMediaBackend::NotifyWndProc);
2389 wxSetWindowUserData(m_hNotifyWnd, this);
2390
2391 NotifyMovieLoaded();
2392
2393 return true;
2394 }
2395
2396 //---------------------------------------------------------------------------
2397 // wxMCIMediaBackend::Load (URL version)
2398 //
2399 // MCI doesn't support URLs directly (?)
2400 //
2401 // TODO: Use wxURL/wxFileSystem and mmioInstallProc
2402 //---------------------------------------------------------------------------
2403 bool wxMCIMediaBackend::Load(const wxURI& WXUNUSED(location))
2404 {
2405 return false;
2406 }
2407
2408 //---------------------------------------------------------------------------
2409 // wxMCIMediaBackend::Play
2410 //
2411 // Plays/Resumes the MCI device... a couple notes:
2412 // 1) Certain drivers will crash and burn if we don't pass them an
2413 // MCI_PLAY_PARMS, despite the documentation that says otherwise...
2414 // 2) There is a MCI_RESUME command, but MCI_PLAY does the same thing
2415 // and will resume from a stopped state also, so there's no need to
2416 // call both, for example
2417 //---------------------------------------------------------------------------
2418 bool wxMCIMediaBackend::Play()
2419 {
2420 MCI_PLAY_PARMS playParms;
2421 playParms.dwCallback = (DWORD)m_hNotifyWnd;
2422
2423 bool bOK = ( mciSendCommand(m_hDev, MCI_PLAY, MCI_NOTIFY,
2424 (DWORD)(LPVOID)&playParms) == 0 );
2425
2426 if (bOK)
2427 m_ctrl->Show(m_bVideo);
2428
2429 return bOK;
2430 }
2431
2432 //---------------------------------------------------------------------------
2433 // wxMCIMediaBackend::Pause
2434 //
2435 // Pauses the MCI device - nothing special
2436 //---------------------------------------------------------------------------
2437 bool wxMCIMediaBackend::Pause()
2438 {
2439 return (mciSendCommand(m_hDev, MCI_PAUSE, MCI_WAIT, 0) == 0);
2440 }
2441
2442 //---------------------------------------------------------------------------
2443 // wxMCIMediaBackend::Stop
2444 //
2445 // Stops the MCI device & seeks to the beginning as wxMediaCtrl docs outline
2446 //---------------------------------------------------------------------------
2447 bool wxMCIMediaBackend::Stop()
2448 {
2449 return (mciSendCommand(m_hDev, MCI_STOP, MCI_WAIT, 0) == 0) &&
2450 (mciSendCommand(m_hDev, MCI_SEEK, MCI_SEEK_TO_START, 0) == 0);
2451 }
2452
2453 //---------------------------------------------------------------------------
2454 // wxMCIMediaBackend::GetState
2455 //
2456 // Here we get the state and convert it to a wxMediaState -
2457 // since we use direct comparisons with MCI_MODE_PLAY and
2458 // MCI_MODE_PAUSE, we don't care if the MCI_STATUS call
2459 // fails or not
2460 //---------------------------------------------------------------------------
2461 wxMediaState wxMCIMediaBackend::GetState()
2462 {
2463 MCI_STATUS_PARMS statusParms;
2464 statusParms.dwItem = MCI_STATUS_MODE;
2465
2466 mciSendCommand(m_hDev, MCI_STATUS, MCI_STATUS_ITEM,
2467 (DWORD)(LPVOID)&statusParms);
2468
2469 if (statusParms.dwReturn == MCI_MODE_PAUSE)
2470 return wxMEDIASTATE_PAUSED;
2471 else if (statusParms.dwReturn == MCI_MODE_PLAY)
2472 return wxMEDIASTATE_PLAYING;
2473 else
2474 return wxMEDIASTATE_STOPPED;
2475 }
2476
2477 //---------------------------------------------------------------------------
2478 // wxMCIMediaBackend::SetPosition
2479 //
2480 // Here we set the position of the device in the stream.
2481 // Note that MCI actually stops the device after you seek it if the
2482 // device is playing/paused, so we need to play the file after
2483 // MCI seeks like normal APIs would
2484 //---------------------------------------------------------------------------
2485 bool wxMCIMediaBackend::SetPosition(wxLongLong where)
2486 {
2487 MCI_SEEK_PARMS seekParms;
2488 seekParms.dwCallback = 0;
2489
2490 #if wxUSE_LONGLONG_NATIVE && !wxUSE_LONGLONG_WX
2491 seekParms.dwTo = (DWORD)where.GetValue();
2492 #else // wxUSE_LONGLONG_WX
2493 // no way to return it in one piece
2494 wxASSERT( where.GetHi() == 0 );
2495 seekParms.dwTo = (DWORD)where.GetLo();
2496 #endif
2497
2498 // device was playing?
2499 bool bReplay = GetState() == wxMEDIASTATE_PLAYING;
2500
2501 if ( mciSendCommand(m_hDev, MCI_SEEK, MCI_TO,
2502 (DWORD)(LPVOID)&seekParms) != 0)
2503 {
2504 return false;
2505 }
2506
2507 // If the device was playing, resume it
2508 if (bReplay)
2509 return Play();
2510 else
2511 return true;
2512 }
2513
2514 //---------------------------------------------------------------------------
2515 // wxMCIMediaBackend::GetPosition
2516 //
2517 // Gets the position of the device in the stream using the current
2518 // time format... nothing special here...
2519 //---------------------------------------------------------------------------
2520 wxLongLong wxMCIMediaBackend::GetPosition()
2521 {
2522 MCI_STATUS_PARMS statusParms;
2523 statusParms.dwItem = MCI_STATUS_POSITION;
2524
2525 if (mciSendCommand(m_hDev, MCI_STATUS, MCI_STATUS_ITEM,
2526 (DWORD)(LPSTR)&statusParms) != 0)
2527 return 0;
2528
2529 return statusParms.dwReturn;
2530 }
2531
2532 //---------------------------------------------------------------------------
2533 // wxMCIMediaBackend::GetVolume
2534 //
2535 // Gets the volume of the current media via the MCI_DGV_STATUS_VOLUME
2536 // message. Value ranges from 0 (minimum) to 1000 (maximum volume).
2537 //---------------------------------------------------------------------------
2538 double wxMCIMediaBackend::GetVolume()
2539 {
2540 MCI_STATUS_PARMS statusParms;
2541 statusParms.dwCallback = 0;
2542 statusParms.dwItem = 0x4019; // MCI_DGV_STATUS_VOLUME
2543
2544 if (mciSendCommand(m_hDev, MCI_STATUS, MCI_STATUS_ITEM,
2545 (DWORD)(LPSTR)&statusParms) != 0)
2546 return 0;
2547
2548 return ((double)statusParms.dwReturn) / 1000.0;
2549 }
2550
2551 //---------------------------------------------------------------------------
2552 // wxMCIMediaBackend::SetVolume
2553 //
2554 // Sets the volume of the current media via the MCI_DGV_SETAUDIO_VOLUME
2555 // message. Value ranges from 0 (minimum) to 1000 (maximum volume).
2556 //---------------------------------------------------------------------------
2557 bool wxMCIMediaBackend::SetVolume(double dVolume)
2558 {
2559 MCI_DGV_SETAUDIO_PARMS audioParms;
2560 audioParms.dwCallback = 0;
2561 audioParms.dwItem = 0x4002; // MCI_DGV_SETAUDIO_VOLUME
2562 audioParms.dwValue = (DWORD) (dVolume * 1000.0);
2563 audioParms.dwOver = 0;
2564 audioParms.lpstrAlgorithm = NULL;
2565 audioParms.lpstrQuality = NULL;
2566
2567 if (mciSendCommand(m_hDev, 0x0873, // MCI_SETAUDIO
2568 // MCI_DGV_SETAUDIO + (_ITEM | _VALUE)
2569 0x00800000L | 0x01000000L,
2570 (DWORD)(LPSTR)&audioParms) != 0)
2571 return false;
2572
2573 return true;
2574 }
2575
2576 //---------------------------------------------------------------------------
2577 // wxMCIMediaBackend::GetDuration
2578 //
2579 // Gets the duration of the stream... nothing special
2580 //---------------------------------------------------------------------------
2581 wxLongLong wxMCIMediaBackend::GetDuration()
2582 {
2583 MCI_STATUS_PARMS statusParms;
2584 statusParms.dwItem = MCI_STATUS_LENGTH;
2585
2586 if (mciSendCommand(m_hDev, MCI_STATUS, MCI_STATUS_ITEM,
2587 (DWORD)(LPSTR)&statusParms) != 0)
2588 return 0;
2589
2590 return statusParms.dwReturn;
2591 }
2592
2593 //---------------------------------------------------------------------------
2594 // wxMCIMediaBackend::Move
2595 //
2596 // Moves the window to a location
2597 //---------------------------------------------------------------------------
2598 void wxMCIMediaBackend::Move(int WXUNUSED(x), int WXUNUSED(y), int w, int h)
2599 {
2600 if (m_hNotifyWnd && m_bVideo)
2601 {
2602 MCI_DGV_RECT_PARMS putParms; // ifdefed MCI_DGV_PUT_PARMS
2603 memset(&putParms, 0, sizeof(MCI_DGV_RECT_PARMS));
2604 putParms.rc.bottom = h;
2605 putParms.rc.right = w;
2606
2607 // wxStackWalker will crash and burn here on assert
2608 // and MCI doesn't like 0 and 0 for some reason (out of range)
2609 // so just don't it in that case
2610 if (w || h)
2611 {
2612 wxMCIVERIFY( mciSendCommand(m_hDev, MCI_PUT,
2613 0x00040000L, // MCI_DGV_PUT_DESTINATION
2614 (DWORD)(LPSTR)&putParms) );
2615 }
2616 }
2617 }
2618
2619 //---------------------------------------------------------------------------
2620 // wxMCIMediaBackend::GetVideoSize
2621 //
2622 // Gets the original size of the movie for sizers
2623 //---------------------------------------------------------------------------
2624 wxSize wxMCIMediaBackend::GetVideoSize() const
2625 {
2626 if (m_bVideo)
2627 {
2628 MCI_DGV_RECT_PARMS whereParms; // ifdefed MCI_DGV_WHERE_PARMS
2629
2630 wxMCIVERIFY( mciSendCommand(m_hDev, MCI_WHERE,
2631 0x00020000L, // MCI_DGV_WHERE_SOURCE
2632 (DWORD)(LPSTR)&whereParms) );
2633
2634 return wxSize(whereParms.rc.right, whereParms.rc.bottom);
2635 }
2636 return wxSize(0, 0);
2637 }
2638
2639 //---------------------------------------------------------------------------
2640 // wxMCIMediaBackend::GetPlaybackRate
2641 //
2642 // TODO
2643 //---------------------------------------------------------------------------
2644 double wxMCIMediaBackend::GetPlaybackRate()
2645 {
2646 return 1.0;
2647 }
2648
2649 //---------------------------------------------------------------------------
2650 // wxMCIMediaBackend::SetPlaybackRate
2651 //
2652 // TODO
2653 //---------------------------------------------------------------------------
2654 bool wxMCIMediaBackend::SetPlaybackRate(double WXUNUSED(dRate))
2655 {
2656 #if 0
2657 MCI_WAVE_SET_SAMPLESPERSEC
2658 MCI_DGV_SET_PARMS setParms;
2659 setParms.dwSpeed = (DWORD) (dRate * 1000.0);
2660
2661 return (mciSendCommand(m_hDev, MCI_SET,
2662 0x00020000L, // MCI_DGV_SET_SPEED
2663 (DWORD)(LPSTR)&setParms) == 0);
2664 #endif
2665
2666 return false;
2667 }
2668
2669 //---------------------------------------------------------------------------
2670 // [static] wxMCIMediaBackend::MSWWindowProc
2671 //
2672 // Here we process a message when MCI reaches the stopping point
2673 // in the stream
2674 //---------------------------------------------------------------------------
2675 LRESULT CALLBACK wxMCIMediaBackend::NotifyWndProc(HWND hWnd, UINT nMsg,
2676 WPARAM wParam,
2677 LPARAM lParam)
2678 {
2679 wxMCIMediaBackend* backend =
2680 (wxMCIMediaBackend*)wxGetWindowUserData(hWnd);
2681
2682 return backend->OnNotifyWndProc(hWnd, nMsg, wParam, lParam);
2683 }
2684
2685 LRESULT CALLBACK wxMCIMediaBackend::OnNotifyWndProc(HWND hWnd, UINT nMsg,
2686 WPARAM wParam,
2687 LPARAM lParam)
2688 {
2689 if (nMsg == MM_MCINOTIFY)
2690 {
2691 wxASSERT(lParam == (LPARAM) m_hDev);
2692 if (wParam == MCI_NOTIFY_SUCCESSFUL && lParam == (LPARAM)m_hDev)
2693 {
2694 if ( SendStopEvent() )
2695 {
2696 wxMCIVERIFY( mciSendCommand(m_hDev, MCI_SEEK, MCI_SEEK_TO_START, 0) );
2697 QueueFinishEvent();
2698 }
2699 }
2700 }
2701 return DefWindowProc(hWnd, nMsg, wParam, lParam);
2702 }
2703 #endif // __WXWINCE__
2704
2705 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2706 //
2707 // wxQTMediaBackend
2708 //
2709 // TODO: Use a less kludgy way to pause/get state/set state
2710 // FIXME: Greg Hazel reports that sometimes files that cannot be played
2711 // with this backend are treated as playable anyway - not verified though.
2712 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2713
2714 IMPLEMENT_DYNAMIC_CLASS(wxQTMediaBackend, wxMediaBackend)
2715
2716 // Time between timer calls - this is the Apple recommendation to the TCL
2717 // team I believe
2718 #define MOVIE_DELAY 20
2719
2720 #include "wx/timer.h"
2721
2722
2723 //---------------------------------------------------------------------------
2724 // wxQTLoadTimer
2725 //
2726 // QT, esp. QT for Windows is very picky about how you go about
2727 // async loading. If you were to go through a Windows message loop
2728 // or a MoviesTask or both and then check the movie load state
2729 // it would still return 1000 (loading)... even (pre)prerolling doesn't
2730 // help. However, making a load timer like this works
2731 //---------------------------------------------------------------------------
2732 class wxQTLoadTimer : public wxTimer
2733 {
2734 public:
2735 wxQTLoadTimer(Movie movie, wxQTMediaBackend* parent, wxQuickTimeLibrary* pLib) :
2736 m_movie(movie), m_parent(parent), m_pLib(pLib) {}
2737
2738 void Notify()
2739 {
2740 m_pLib->MoviesTask(m_movie, 0);
2741 //kMovieLoadStatePlayable
2742 if (m_pLib->GetMovieLoadState(m_movie) >= 10000)
2743 {
2744 m_parent->FinishLoad();
2745 delete this;
2746 }
2747 }
2748
2749 protected:
2750 Movie m_movie; //Our movie instance
2751 wxQTMediaBackend* m_parent; //Backend pointer
2752 wxQuickTimeLibrary* m_pLib; //Interfaces
2753 };
2754
2755
2756 // --------------------------------------------------------------------------
2757 // wxQTPlayTimer - Handle Asyncronous Playing
2758 //
2759 // 1) Checks to see if the movie is done, and if not continues
2760 // streaming the movie
2761 // 2) Sends the wxEVT_MEDIA_STOP event if we have reached the end of
2762 // the movie.
2763 // --------------------------------------------------------------------------
2764 class wxQTPlayTimer : public wxTimer
2765 {
2766 public:
2767 wxQTPlayTimer(Movie movie, wxQTMediaBackend* parent,
2768 wxQuickTimeLibrary* pLib) :
2769 m_movie(movie), m_parent(parent), m_pLib(pLib) {}
2770
2771 void Notify()
2772 {
2773 //
2774 // OK, a little explaining - basically originally
2775 // we only called MoviesTask if the movie was actually
2776 // playing (not paused or stopped)... this was before
2777 // we realized MoviesTask actually handles repainting
2778 // of the current frame - so if you were to resize
2779 // or something it would previously not redraw that
2780 // portion of the movie.
2781 //
2782 // So now we call MoviesTask always so that it repaints
2783 // correctly.
2784 //
2785 m_pLib->MoviesTask(m_movie, 0);
2786
2787 //
2788 // Handle the stop event - if the movie has reached
2789 // the end, notify our handler
2790 //
2791 // m_bPlaying == !(Stopped | Paused)
2792 //
2793 if (m_parent->m_bPlaying)
2794 {
2795 if (m_pLib->IsMovieDone(m_movie))
2796 {
2797 if ( m_parent->SendStopEvent() )
2798 {
2799 m_parent->Stop();
2800 wxASSERT(m_pLib->GetMoviesError() == noErr);
2801
2802 m_parent->QueueFinishEvent();
2803 }
2804 }
2805 }
2806 }
2807
2808 protected:
2809 Movie m_movie; // Our movie instance
2810 wxQTMediaBackend* m_parent; //Backend pointer
2811 wxQuickTimeLibrary* m_pLib; //Interfaces
2812 };
2813
2814
2815 //---------------------------------------------------------------------------
2816 // wxQTMediaBackend::QTWndProc
2817 //
2818 // Forwards events to the Movie Controller so that it can
2819 // redraw itself/process messages etc..
2820 //---------------------------------------------------------------------------
2821 LRESULT CALLBACK wxQTMediaBackend::QTWndProc(HWND hWnd, UINT nMsg,
2822 WPARAM wParam, LPARAM lParam)
2823 {
2824 wxQTMediaBackend* pThis = (wxQTMediaBackend*)wxGetWindowUserData(hWnd);
2825
2826 MSG msg;
2827 msg.hwnd = hWnd;
2828 msg.message = nMsg;
2829 msg.wParam = wParam;
2830 msg.lParam = lParam;
2831 msg.time = 0;
2832 msg.pt.x = 0;
2833 msg.pt.y = 0;
2834 EventRecord theEvent;
2835 pThis->m_lib.NativeEventToMacEvent(&msg, &theEvent);
2836 pThis->m_lib.MCIsPlayerEvent(pThis->m_pMC, &theEvent);
2837
2838 return pThis->m_ctrl->MSWWindowProc(nMsg, wParam, lParam);
2839 }
2840
2841 //---------------------------------------------------------------------------
2842 // wxQTMediaBackend Destructor
2843 //
2844 // Sets m_timer to NULL signifying we havn't loaded anything yet
2845 //---------------------------------------------------------------------------
2846 wxQTMediaBackend::wxQTMediaBackend()
2847 : m_movie(NULL), m_bPlaying(false), m_timer(NULL), m_pMC(NULL)
2848 {
2849 }
2850
2851 //---------------------------------------------------------------------------
2852 // wxQTMediaBackend Destructor
2853 //
2854 // 1) Cleans up the QuickTime movie instance
2855 // 2) Decrements the QuickTime reference counter - if this reaches
2856 // 0, QuickTime shuts down
2857 // 3) Decrements the QuickTime Windows Media Layer reference counter -
2858 // if this reaches 0, QuickTime shuts down the Windows Media Layer
2859 //---------------------------------------------------------------------------
2860 wxQTMediaBackend::~wxQTMediaBackend()
2861 {
2862 if (m_movie)
2863 Cleanup();
2864
2865 if (m_lib.IsOk())
2866 {
2867 if (m_pMC)
2868 {
2869 m_lib.DisposeMovieController(m_pMC);
2870 // m_pMC = NULL;
2871 }
2872
2873 // destroy wxQTMediaEvtHandler we pushed on it
2874 m_ctrl->PopEventHandler(true);
2875
2876 m_lib.DestroyPortAssociation(
2877 (CGrafPtr)m_lib.GetNativeWindowPort(m_ctrl->GetHWND()));
2878
2879 //Note that ExitMovies() is not necessary, but
2880 //the docs are fuzzy on whether or not TerminateQTML is
2881 m_lib.ExitMovies();
2882 m_lib.TerminateQTML();
2883 }
2884 }
2885
2886 //---------------------------------------------------------------------------
2887 // wxQTMediaBackend::CreateControl
2888 //
2889 // 1) Intializes QuickTime
2890 // 2) Creates the control window
2891 //---------------------------------------------------------------------------
2892 bool wxQTMediaBackend::CreateControl(wxControl* ctrl, wxWindow* parent,
2893 wxWindowID id,
2894 const wxPoint& pos,
2895 const wxSize& size,
2896 long style,
2897 const wxValidator& validator,
2898 const wxString& name)
2899 {
2900 if (!m_lib.Initialize())
2901 return false;
2902
2903 int nError = m_lib.InitializeQTML(0);
2904 if (nError != noErr) //-2093 no dll
2905 {
2906 wxFAIL_MSG(wxString::Format(wxT("Couldn't Initialize Quicktime-%i"), nError));
2907 return false;
2908 }
2909
2910 m_lib.EnterMovies();
2911
2912 // Create window
2913 // By default wxWindow(s) is created with a border -
2914 // so we need to get rid of those
2915 //
2916 // Since we don't have a child window like most other
2917 // backends, we don't need wxCLIP_CHILDREN
2918 //
2919 if ( !ctrl->wxControl::Create(parent, id, pos, size,
2920 (style & ~wxBORDER_MASK) | wxBORDER_NONE,
2921 validator, name) )
2922 {
2923 return false;
2924 }
2925
2926 m_ctrl = wxStaticCast(ctrl, wxMediaCtrl);
2927
2928 // Create a port association for our window so we
2929 // can use it as a WindowRef
2930 m_lib.CreatePortAssociation(m_ctrl->GetHWND(), NULL, 0L);
2931
2932 // Part of a suggestion from Greg Hazel
2933 // to repaint movie when idle
2934 m_ctrl->PushEventHandler(new wxQTMediaEvtHandler(this, m_ctrl->GetHWND()));
2935
2936 // done
2937 return true;
2938 }
2939
2940 //---------------------------------------------------------------------------
2941 // wxQTMediaBackend::Load (file version)
2942 //
2943 // 1) Get an FSSpec from the Windows path name
2944 // 2) Open the movie
2945 // 3) Obtain the movie instance from the movie resource
2946 // 4) Close the movie resource
2947 // 5) Finish loading
2948 //---------------------------------------------------------------------------
2949 bool wxQTMediaBackend::Load(const wxString& fileName)
2950 {
2951 if (m_movie)
2952 Cleanup();
2953
2954 short movieResFile = 0; //= 0 because of annoying VC6 warning
2955 FSSpec sfFile;
2956
2957 if (m_lib.NativePathNameToFSSpec(
2958 (char*) (const char*) fileName.mb_str(),
2959 &sfFile, 0) != noErr)
2960 {
2961 return false;
2962 }
2963
2964 if (m_lib.OpenMovieFile (&sfFile, &movieResFile, fsRdPerm) != noErr)
2965 return false;
2966
2967 short movieResID = 0;
2968 Str255 movieName;
2969
2970 OSErr err = m_lib.NewMovieFromFile(
2971 &m_movie,
2972 movieResFile,
2973 &movieResID,
2974 movieName,
2975 newMovieActive,
2976 NULL ); //wasChanged
2977
2978 // m_lib.GetMoviesStickyError() because it may not find the
2979 // proper codec and play black video and other strange effects,
2980 // not to mention mess up the dynamic backend loading scheme
2981 // of wxMediaCtrl - so it just does what the QuickTime player does
2982 if (err == noErr && m_lib.GetMoviesStickyError() == noErr)
2983 {
2984 m_lib.CloseMovieFile (movieResFile);
2985
2986 FinishLoad();
2987 return true;
2988 }
2989 else
2990 return false;
2991 }
2992
2993 //---------------------------------------------------------------------------
2994 // wxQTMediaBackend::PPRMProc (static)
2995 //
2996 // Called when done PrePrerolling the movie.
2997 // Note that in 99% of the cases this does nothing...
2998 // Anyway we set up the loading timer here to tell us when the movie is done
2999 //---------------------------------------------------------------------------
3000 void wxQTMediaBackend::PPRMProc (Movie theMovie,
3001 OSErr WXUNUSED_UNLESS_DEBUG(theErr),
3002 void* theRefCon)
3003 {
3004 wxASSERT( theMovie );
3005 wxASSERT( theRefCon );
3006 wxASSERT( theErr == noErr );
3007
3008 wxQTMediaBackend* pBE = (wxQTMediaBackend*) theRefCon;
3009
3010 long lTime = pBE->m_lib.GetMovieTime(theMovie,NULL);
3011 Fixed rate = pBE->m_lib.GetMoviePreferredRate(theMovie);
3012 pBE->m_lib.PrerollMovie(theMovie,lTime,rate);
3013 pBE->m_timer = new wxQTLoadTimer(pBE->m_movie, pBE, &pBE->m_lib);
3014 pBE->m_timer->Start(MOVIE_DELAY);
3015 }
3016
3017 //---------------------------------------------------------------------------
3018 // wxQTMediaBackend::Load (URL Version)
3019 //
3020 // 1) Build an escaped URI from location
3021 // 2) Create a handle to store the URI string
3022 // 3) Put the URI string inside the handle
3023 // 4) Make a QuickTime URL data ref from the handle with the URI in it
3024 // 5) Clean up the URI string handle
3025 // 6) Do some prerolling
3026 // 7) Finish Loading
3027 //---------------------------------------------------------------------------
3028 bool wxQTMediaBackend::Load(const wxURI& location)
3029 {
3030 if (m_movie)
3031 Cleanup();
3032
3033 wxString theURI = location.BuildURI();
3034
3035 Handle theHandle = m_lib.NewHandleClear(theURI.length() + 1);
3036 wxASSERT(theHandle);
3037
3038 m_lib.BlockMove(theURI.mb_str(), *theHandle, theURI.length() + 1);
3039
3040 // create the movie from the handle that refers to the URI
3041 OSErr err = m_lib.NewMovieFromDataRef(&m_movie, newMovieActive |
3042 newMovieAsyncOK
3043 /*|newMovieIdleImportOK*/,
3044 NULL, theHandle,
3045 URLDataHandlerSubType);
3046
3047 m_lib.DisposeHandle(theHandle);
3048
3049 if (err == noErr)
3050 {
3051 long timeNow;
3052 Fixed playRate;
3053
3054 timeNow = m_lib.GetMovieTime(m_movie, NULL);
3055 wxASSERT(m_lib.GetMoviesError() == noErr);
3056
3057 playRate = m_lib.GetMoviePreferredRate(m_movie);
3058 wxASSERT(m_lib.GetMoviesError() == noErr);
3059
3060 // Note that the callback here is optional,
3061 // but without it PrePrerollMovie can be buggy
3062 // (see Apple ml). Also, some may wonder
3063 // why we need this at all - this is because
3064 // Apple docs say QuickTime streamed movies
3065 // require it if you don't use a Movie Controller,
3066 // which we don't by default.
3067 //
3068 m_lib.PrePrerollMovie(m_movie, timeNow, playRate,
3069 (WXFARPROC)wxQTMediaBackend::PPRMProc,
3070 (void*)this);
3071 return true;
3072 }
3073 else
3074 return false;
3075 }
3076
3077
3078 //---------------------------------------------------------------------------
3079 // wxQTMediaBackend::FinishLoad
3080 //
3081 // 1) Create the movie timer
3082 // 2) Get real size of movie for GetBestSize/sizers
3083 // 3) Set the movie time scale to something usable so that seeking
3084 // etc. will work correctly
3085 // 4) Set our Movie Controller to display the movie if it exists,
3086 // otherwise set the bounds of the Movie
3087 // 5) Refresh parent window
3088 //---------------------------------------------------------------------------
3089 void wxQTMediaBackend::FinishLoad()
3090 {
3091 // Create the playing/streaming timer
3092 m_timer = new wxQTPlayTimer(m_movie, (wxQTMediaBackend*) this, &m_lib);
3093 wxASSERT(m_timer);
3094 m_timer->Start(MOVIE_DELAY, wxTIMER_CONTINUOUS);
3095
3096 // get the real size of the movie
3097 Rect outRect;
3098 memset(&outRect, 0, sizeof(Rect)); // for annoying VC6 warning
3099 m_lib.GetMovieNaturalBoundsRect (m_movie, &outRect);
3100 wxASSERT(m_lib.GetMoviesError() == noErr);
3101
3102 m_bestSize.x = outRect.right - outRect.left;
3103 m_bestSize.y = outRect.bottom - outRect.top;
3104
3105 // Handle the movie GWorld
3106 if (m_pMC)
3107 {
3108 Point thePoint;
3109 thePoint.h = thePoint.v = 0;
3110 m_lib.MCSetMovie(m_pMC, m_movie,
3111 m_lib.GetNativeWindowPort(m_ctrl->GetHandle()),
3112 thePoint);
3113 m_lib.MCSetVisible(m_pMC, true);
3114 m_bestSize.y += 16;
3115 }
3116 else
3117 {
3118 m_lib.SetMovieGWorld(m_movie,
3119 (CGrafPtr) m_lib.GetNativeWindowPort(m_ctrl->GetHWND()),
3120 NULL);
3121 }
3122
3123 // Set the movie to millisecond precision
3124 m_lib.SetMovieTimeScale(m_movie, 1000);
3125 wxASSERT(m_lib.GetMoviesError() == noErr);
3126
3127 NotifyMovieLoaded();
3128 }
3129
3130 //---------------------------------------------------------------------------
3131 // wxQTMediaBackend::Play
3132 //
3133 // 1) Start the QT movie
3134 // 2) Start the movie loading timer
3135 //
3136 // NOTE: This will still return success even when
3137 // the movie is still loading, and as mentioned in wxQTLoadTimer
3138 // I don't know of a way to force this to be sync - so if its
3139 // still loading the function will return true but the movie will
3140 // still be in the stopped state
3141 //---------------------------------------------------------------------------
3142 bool wxQTMediaBackend::Play()
3143 {
3144 m_lib.StartMovie(m_movie);
3145 m_bPlaying = true;
3146
3147 return m_lib.GetMoviesError() == noErr;
3148 }
3149
3150 //---------------------------------------------------------------------------
3151 // wxQTMediaBackend::Pause
3152 //
3153 // 1) Stop the movie
3154 // 2) Stop the movie timer
3155 //---------------------------------------------------------------------------
3156 bool wxQTMediaBackend::Pause()
3157 {
3158 m_bPlaying = false;
3159 m_lib.StopMovie(m_movie);
3160
3161 return m_lib.GetMoviesError() == noErr;
3162 }
3163
3164 //---------------------------------------------------------------------------
3165 // wxQTMediaBackend::Stop
3166 //
3167 // 1) Stop the movie
3168 // 2) Stop the movie timer
3169 // 3) Seek to the beginning of the movie
3170 //---------------------------------------------------------------------------
3171 bool wxQTMediaBackend::Stop()
3172 {
3173 m_bPlaying = false;
3174
3175 m_lib.StopMovie(m_movie);
3176 if (m_lib.GetMoviesError() == noErr)
3177 m_lib.GoToBeginningOfMovie(m_movie);
3178
3179 return m_lib.GetMoviesError() == noErr;
3180 }
3181
3182 //---------------------------------------------------------------------------
3183 // wxQTMediaBackend::GetPlaybackRate
3184 //
3185 // 1) Get the movie playback rate from ::GetMovieRate
3186 //---------------------------------------------------------------------------
3187 double wxQTMediaBackend::GetPlaybackRate()
3188 {
3189 return ( ((double)m_lib.GetMovieRate(m_movie)) / 0x10000);
3190 }
3191
3192 //---------------------------------------------------------------------------
3193 // wxQTMediaBackend::SetPlaybackRate
3194 //
3195 // 1) Convert dRate to Fixed and Set the movie rate through SetMovieRate
3196 //---------------------------------------------------------------------------
3197 bool wxQTMediaBackend::SetPlaybackRate(double dRate)
3198 {
3199 m_lib.SetMovieRate(m_movie, (Fixed) (dRate * 0x10000));
3200
3201 return m_lib.GetMoviesError() == noErr;
3202 }
3203
3204 //---------------------------------------------------------------------------
3205 // wxQTMediaBackend::SetPosition
3206 //
3207 // 1) Create a time record struct (TimeRecord) with appropriate values
3208 // 2) Pass struct to SetMovieTime
3209 //---------------------------------------------------------------------------
3210 bool wxQTMediaBackend::SetPosition(wxLongLong where)
3211 {
3212 //NB: For some reason SetMovieTime does not work
3213 //correctly with the Quicktime Windows SDK (6)
3214 //From Muskelkatermann at the wxForum
3215 //http://www.solidsteel.nl/users/wxwidgets/viewtopic.php?t=2957
3216 //RN - note that I have not verified this but there
3217 //is no harm in calling SetMovieTimeValue instead
3218 #if 0
3219 TimeRecord theTimeRecord;
3220 memset(&theTimeRecord, 0, sizeof(TimeRecord));
3221 theTimeRecord.value.lo = where.GetLo();
3222 theTimeRecord.scale = m_lib.GetMovieTimeScale(m_movie);
3223 theTimeRecord.base = m_lib.GetMovieTimeBase(m_movie);
3224 m_lib.SetMovieTime(m_movie, &theTimeRecord);
3225 #else
3226 m_lib.SetMovieTimeValue(m_movie, where.GetLo());
3227 #endif
3228
3229 return (m_lib.GetMoviesError() == noErr);
3230 }
3231
3232 //---------------------------------------------------------------------------
3233 // wxQTMediaBackend::GetPosition
3234 //
3235 // 1) Calls GetMovieTime to get the position we are in in the movie
3236 // in milliseconds (we called
3237 //---------------------------------------------------------------------------
3238 wxLongLong wxQTMediaBackend::GetPosition()
3239 {
3240 return m_lib.GetMovieTime(m_movie, NULL);
3241 }
3242
3243 //---------------------------------------------------------------------------
3244 // wxQTMediaBackend::GetVolume
3245 //
3246 // Gets the volume through GetMovieVolume - which returns a 16 bit short -
3247 //
3248 // +--------+--------+
3249 // + (1) + (2) +
3250 // +--------+--------+
3251 //
3252 // (1) first 8 bits are value before decimal
3253 // (2) second 8 bits are value after decimal
3254 //
3255 // Volume ranges from -1.0 (gain but no sound), 0 (no sound and no gain) to
3256 // 1 (full gain and sound)
3257 //---------------------------------------------------------------------------
3258 double wxQTMediaBackend::GetVolume()
3259 {
3260 short sVolume = m_lib.GetMovieVolume(m_movie);
3261 wxASSERT(m_lib.GetMoviesError() == noErr);
3262
3263 if (sVolume & (128 << 8)) //negative - no sound
3264 return 0.0;
3265
3266 return sVolume / 256.0;
3267 }
3268
3269 //---------------------------------------------------------------------------
3270 // wxQTMediaBackend::SetVolume
3271 //
3272 // Sets the volume through SetMovieVolume - which takes a 16 bit short -
3273 //
3274 // +--------+--------+
3275 // + (1) + (2) +
3276 // +--------+--------+
3277 //
3278 // (1) first 8 bits are value before decimal
3279 // (2) second 8 bits are value after decimal
3280 //
3281 // Volume ranges from -1.0 (gain but no sound), 0 (no sound and no gain) to
3282 // 1 (full gain and sound)
3283 //---------------------------------------------------------------------------
3284 bool wxQTMediaBackend::SetVolume(double dVolume)
3285 {
3286 m_lib.SetMovieVolume(m_movie, (short) (dVolume * 256));
3287 return m_lib.GetMoviesError() == noErr;
3288 }
3289
3290 //---------------------------------------------------------------------------
3291 // wxQTMediaBackend::GetDuration
3292 //
3293 // Calls GetMovieDuration
3294 //---------------------------------------------------------------------------
3295 wxLongLong wxQTMediaBackend::GetDuration()
3296 {
3297 return m_lib.GetMovieDuration(m_movie);
3298 }
3299
3300 //---------------------------------------------------------------------------
3301 // wxQTMediaBackend::GetState
3302 //
3303 // Determines the current state - if we are at the beginning we
3304 // are stopped
3305 //---------------------------------------------------------------------------
3306 wxMediaState wxQTMediaBackend::GetState()
3307 {
3308 if (m_bPlaying)
3309 return wxMEDIASTATE_PLAYING;
3310 else if ( !m_movie || wxQTMediaBackend::GetPosition() == 0 )
3311 return wxMEDIASTATE_STOPPED;
3312 else
3313 return wxMEDIASTATE_PAUSED;
3314 }
3315
3316 //---------------------------------------------------------------------------
3317 // wxQTMediaBackend::Cleanup
3318 //
3319 // Diposes of the movie timer, Disassociates the Movie Controller with
3320 // movie and hides it if it exists, and stops and disposes
3321 // of the QT movie
3322 //---------------------------------------------------------------------------
3323 void wxQTMediaBackend::Cleanup()
3324 {
3325 m_bPlaying = false;
3326
3327 if (m_timer)
3328 {
3329 delete m_timer;
3330 m_timer = NULL;
3331 }
3332
3333 m_lib.StopMovie(m_movie);
3334
3335 if (m_pMC)
3336 {
3337 Point thePoint;
3338 thePoint.h = thePoint.v = 0;
3339 m_lib.MCSetVisible(m_pMC, false);
3340 m_lib.MCSetMovie(m_pMC, NULL, NULL, thePoint);
3341 }
3342
3343 m_lib.DisposeMovie(m_movie);
3344 m_movie = NULL;
3345 }
3346
3347 //---------------------------------------------------------------------------
3348 // wxQTMediaBackend::ShowPlayerControls
3349 //
3350 // Creates a movie controller for the Movie if the user wants it
3351 //---------------------------------------------------------------------------
3352 bool wxQTMediaBackend::ShowPlayerControls(wxMediaCtrlPlayerControls flags)
3353 {
3354 if (m_pMC)
3355 {
3356 //restore old wndproc
3357 wxSetWindowProc((HWND)m_ctrl->GetHWND(), wxWndProc);
3358 m_lib.DisposeMovieController(m_pMC);
3359 m_pMC = NULL;
3360 m_bestSize.y -= 16; //movie controller height
3361 }
3362
3363 if (flags && m_movie)
3364 {
3365 Rect rect;
3366 wxRect wxrect = m_ctrl->GetClientRect();
3367
3368 //make room for controller
3369 if (wxrect.width < 320)
3370 wxrect.width = 320;
3371
3372 rect.top = (short)wxrect.y;
3373 rect.left = (short)wxrect.x;
3374 rect.right = (short)(rect.left + wxrect.width);
3375 rect.bottom = (short)(rect.top + wxrect.height);
3376
3377 if (!m_pMC)
3378 {
3379 m_pMC = m_lib.NewMovieController(m_movie, &rect, mcTopLeftMovie |
3380 // mcScaleMovieToFit |
3381 // mcWithBadge |
3382 mcWithFrame);
3383 m_lib.MCDoAction(m_pMC, 32, (void*)true); //mcActionSetKeysEnabled
3384 m_lib.MCSetActionFilterWithRefCon(m_pMC,
3385 (WXFARPROC)wxQTMediaBackend::MCFilterProc, (void*)this);
3386 m_bestSize.y += 16; //movie controller height
3387
3388 //
3389 // By default the movie controller uses its own color
3390 // pallette for the movie which can be bad on some files -
3391 // so turn it off. Also turn off its frame/border for
3392 // the movie
3393 //
3394 // Also we take care of a couple of the interface flags here
3395 //
3396 long mcFlags = 0;
3397 m_lib.MCDoAction(m_pMC, 39/*mcActionGetFlags*/, (void*)&mcFlags);
3398 mcFlags |= ( //(1<< 0)/*mcFlagSuppressMovieFrame*/ |
3399 (1<< 3)/*mcFlagsUseWindowPalette*/
3400 | ((flags & wxMEDIACTRLPLAYERCONTROLS_STEP)
3401 ? 0 : (1<< 1) /*mcFlagSuppressStepButtons*/)
3402 | ((flags & wxMEDIACTRLPLAYERCONTROLS_VOLUME)
3403 ? 0 : (1<< 2) /*mcFlagSuppressSpeakerButton*/)
3404 // | (1<< 4) /*mcFlagDontInvalidate*/ //if we take care of repainting ourselves
3405 );
3406 m_lib.MCDoAction(m_pMC, 38/*mcActionSetFlags*/, (void*)mcFlags);
3407
3408 //intercept the wndproc of our control window
3409 wxSetWindowProc((HWND)m_ctrl->GetHWND(),
3410 wxQTMediaBackend::QTWndProc);
3411
3412 //set the user data of our window
3413 wxSetWindowUserData((HWND)m_ctrl->GetHWND(), this);
3414 }
3415 }
3416
3417 NotifyMovieSizeChanged();
3418
3419 return m_lib.GetMoviesError() == noErr;
3420 }
3421
3422 //---------------------------------------------------------------------------
3423 // wxQTMediaBackend::MCFilterProc (static)
3424 //
3425 // Callback for when the movie controller recieves a message
3426 //---------------------------------------------------------------------------
3427 Boolean
3428 wxQTMediaBackend::MCFilterProc(MovieController WXUNUSED(theController),
3429 short action,
3430 void * WXUNUSED(params),
3431 LONG_PTR refCon)
3432 {
3433 if (action != 1) // don't process idle events
3434 {
3435 wxQTMediaBackend* pThis = (wxQTMediaBackend*)refCon;
3436
3437 switch (action)
3438 {
3439 case 8:
3440 // play button triggered - MC will set movie to opposite state
3441 // of current - playing ? paused : playing
3442 pThis->m_bPlaying = !(pThis->m_bPlaying);
3443
3444 // NB: Sometimes it doesn't redraw properly -
3445 // if you click on the button but don't move the mouse
3446 // the button will not change its state until you move
3447 // mcActionDraw and Refresh/Update combo do nothing
3448 // to help this unfortunately
3449 break;
3450
3451 default:
3452 break;
3453 }
3454 }
3455 return 0;
3456 }
3457
3458 //---------------------------------------------------------------------------
3459 // wxQTMediaBackend::GetVideoSize
3460 //
3461 // Returns the actual size of the QT movie
3462 //---------------------------------------------------------------------------
3463 wxSize wxQTMediaBackend::GetVideoSize() const
3464 {
3465 return m_bestSize;
3466 }
3467
3468 //---------------------------------------------------------------------------
3469 // wxQTMediaBackend::Move
3470 //
3471 // Sets the bounds of either the Movie or Movie Controller
3472 //---------------------------------------------------------------------------
3473 void wxQTMediaBackend::Move(int WXUNUSED(x), int WXUNUSED(y), int w, int h)
3474 {
3475 if (m_movie)
3476 {
3477 //make room for controller
3478 if (m_pMC)
3479 {
3480 if (w < 320)
3481 w = 320;
3482
3483 Rect theRect = {0, 0, (short)h, (short)w};
3484 m_lib.MCSetControllerBoundsRect(m_pMC, &theRect);
3485 }
3486 else
3487 {
3488 Rect theRect = {0, 0, (short)h, (short)w};
3489 m_lib.SetMovieBox(m_movie, &theRect);
3490 }
3491
3492 wxASSERT(m_lib.GetMoviesError() == noErr);
3493 }
3494 }
3495
3496 //---------------------------------------------------------------------------
3497 // wxQTMediaBackend::OnEraseBackground
3498 //
3499 // Suggestion from Greg Hazel to repaint the movie when idle
3500 // (on pause also)
3501 //
3502 // TODO: We may be repainting too much here - under what exact circumstances
3503 // do we need this? I think Move also repaints correctly for the Movie
3504 // Controller, so in that instance we don't need this either
3505 //---------------------------------------------------------------------------
3506 void wxQTMediaEvtHandler::OnEraseBackground(wxEraseEvent& evt)
3507 {
3508 wxQuickTimeLibrary& m_pLib = m_qtb->m_lib;
3509
3510 if ( m_qtb->m_pMC )
3511 {
3512 // repaint movie controller
3513 m_pLib.MCDoAction(m_qtb->m_pMC, 2 /*mcActionDraw*/,
3514 m_pLib.GetNativeWindowPort(m_hwnd));
3515 }
3516 else // no movie controller
3517 {
3518 if ( m_qtb->m_movie )
3519 {
3520 CGrafPtr port = (CGrafPtr)m_pLib.GetNativeWindowPort(m_hwnd);
3521
3522 m_pLib.BeginUpdate(port);
3523 m_pLib.UpdateMovie(m_qtb->m_movie);
3524 wxASSERT(m_pLib.GetMoviesError() == noErr);
3525 m_pLib.EndUpdate(port);
3526 }
3527 else // no movie
3528 {
3529 // let the system repaint the window
3530 evt.Skip();
3531 }
3532 }
3533 }
3534
3535 //---------------------------------------------------------------------------
3536 // End QT Backend
3537 //---------------------------------------------------------------------------
3538
3539 //in source file that contains stuff you don't directly use
3540 #include "wx/html/forcelnk.h"
3541 FORCE_LINK_ME(basewxmediabackends)
3542
3543 //---------------------------------------------------------------------------
3544 // End wxMediaCtrl Compilation Guard and this file
3545 //---------------------------------------------------------------------------
3546 #endif //wxUSE_MEDIACTRL