+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+// QT Compilation Guard
+//---------------------------------------------------------------------------
+#if wxUSE_QUICKTIME
+
+//---------------------------------------------------------------------------
+// QT Includes
+//---------------------------------------------------------------------------
+//#include <qtml.h> //Windoze QT include
+//#include <QuickTimeComponents.h> //Standard QT stuff
+#include "wx/dynlib.h"
+
+//---------------------------------------------------------------------------
+// QT Types
+//---------------------------------------------------------------------------
+typedef struct MovieRecord* Movie;
+typedef wxInt16 OSErr;
+typedef wxInt32 OSStatus;
+#define noErr 0
+#define fsRdPerm 1
+typedef unsigned char Str255[256];
+#define StringPtr unsigned char*
+#define newMovieActive 1
+#define Ptr char*
+#define Handle Ptr*
+#define Fixed long
+#define OSType unsigned long
+#define CGrafPtr struct GrafPort *
+#define TimeScale long
+#define TimeBase struct TimeBaseRecord *
+
+struct FSSpec {
+ short vRefNum;
+ long parID;
+ Str255 name; /*Str63 on mac, Str255 on msw */
+};
+
+struct Rect {
+ short top;
+ short left;
+ short bottom;
+ short right;
+};
+
+struct wide {
+ wxInt32 hi;
+ wxUint32 lo;
+};
+
+struct TimeRecord {
+ wide value; /* units */
+ TimeScale scale; /* units per second */
+ TimeBase base;
+};
+
+//---------------------------------------------------------------------------
+// QT Library
+//---------------------------------------------------------------------------
+#define wxDL_METHOD_DEFINE( rettype, name, args, shortargs, defret ) \
+ typedef rettype (* name ## Type) args ; \
+ name ## Type pfn_ ## name; \
+ rettype name args \
+ { if (m_ok) return pfn_ ## name shortargs ; return defret; }
+
+#define wxDL_VOIDMETHOD_DEFINE( name, args, shortargs ) \
+ typedef void (* name ## Type) args ; \
+ name ## Type pfn_ ## name; \
+ void name args \
+ { if (m_ok) pfn_ ## name shortargs ; }
+
+#define wxDL_METHOD_LOAD( lib, name, success ) \
+ pfn_ ## name = (name ## Type) lib.GetSymbol( wxT(#name), &success ); \
+ if (!success) return false;
+
+//Class that utilizes Robert Roeblings Dynamic Library Macros
+class wxQuickTimeLibrary
+{
+public:
+ ~wxQuickTimeLibrary()
+ {
+ if(m_dll.IsLoaded())
+ m_dll.Unload();
+ }
+
+ bool Initialize();
+ bool IsOk() const {return m_ok;}
+
+protected:
+ wxDynamicLibrary m_dll;
+ bool m_ok;
+
+public:
+ wxDL_VOIDMETHOD_DEFINE( StartMovie, (Movie m), (m) );
+ wxDL_VOIDMETHOD_DEFINE( StopMovie, (Movie m), (m) );
+ wxDL_METHOD_DEFINE( bool, IsMovieDone, (Movie m), (m), false);
+ wxDL_VOIDMETHOD_DEFINE( GoToBeginningOfMovie, (Movie m), (m) );
+ wxDL_METHOD_DEFINE( OSErr, GetMoviesError, (), (), -1);
+ wxDL_METHOD_DEFINE( OSErr, EnterMovies, (), (), -1);
+ wxDL_VOIDMETHOD_DEFINE( ExitMovies, (), () );
+ wxDL_METHOD_DEFINE( OSErr, InitializeQTML, (long flags), (flags), -1);
+ wxDL_VOIDMETHOD_DEFINE( TerminateQTML, (), () );
+
+ wxDL_METHOD_DEFINE( OSErr, NativePathNameToFSSpec,
+ (char* inName, FSSpec* outFile, long flags),
+ (inName, outFile, flags), -1);
+
+ wxDL_METHOD_DEFINE( OSErr, OpenMovieFile,
+ (const FSSpec * fileSpec, short * resRefNum, wxInt8 permission),
+ (fileSpec, resRefNum, permission), -1 );
+
+ wxDL_METHOD_DEFINE( OSErr, CloseMovieFile,
+ (short resRefNum), (resRefNum), -1);
+
+ wxDL_METHOD_DEFINE( OSErr, NewMovieFromFile,
+ (Movie * theMovie, short resRefNum, short * resId,
+ StringPtr resName, short newMovieFlags,
+ bool * dataRefWasChanged),
+ (theMovie, resRefNum, resId, resName, newMovieFlags,
+ dataRefWasChanged), -1);
+
+ wxDL_VOIDMETHOD_DEFINE( SetMovieRate, (Movie m, Fixed rate), (m, rate) );
+ wxDL_METHOD_DEFINE( Fixed, GetMovieRate, (Movie m), (m), 0);
+ wxDL_VOIDMETHOD_DEFINE( MoviesTask, (Movie m, long maxms), (m, maxms) );
+ wxDL_VOIDMETHOD_DEFINE( BlockMove,
+ (const char* p1, const char* p2, long s), (p1,p2,s) );
+ wxDL_METHOD_DEFINE( Handle, NewHandleClear, (long s), (s), NULL );
+
+ wxDL_METHOD_DEFINE( OSErr, NewMovieFromDataRef,
+ (Movie * m, short flags, short * id,
+ Handle dataRef, OSType dataRefType),
+ (m,flags,id,dataRef,dataRefType), -1 );
+
+ wxDL_VOIDMETHOD_DEFINE( DisposeHandle, (Handle h), (h) );
+ wxDL_VOIDMETHOD_DEFINE( GetMovieNaturalBoundsRect, (Movie m, Rect* r), (m,r) );
+ wxDL_METHOD_DEFINE( void*, GetMovieIndTrackType,
+ (Movie m, long index, OSType type, long flags),
+ (m,index,type,flags), NULL );
+ wxDL_VOIDMETHOD_DEFINE( CreatePortAssociation,
+ (void* hWnd, void* junk, long morejunk), (hWnd, junk, morejunk) );
+ wxDL_METHOD_DEFINE(void*, GetNativeWindowPort, (void* hWnd), (hWnd), NULL);
+ wxDL_VOIDMETHOD_DEFINE(SetMovieGWorld, (Movie m, CGrafPtr port, void* whatever),
+ (m, port, whatever) );
+ wxDL_VOIDMETHOD_DEFINE(DisposeMovie, (Movie m), (m) );
+ wxDL_VOIDMETHOD_DEFINE(SetMovieBox, (Movie m, Rect* r), (m,r));
+ wxDL_VOIDMETHOD_DEFINE(SetMovieTimeScale, (Movie m, long s), (m,s));
+ wxDL_METHOD_DEFINE(long, GetMovieDuration, (Movie m), (m), 0);
+ wxDL_METHOD_DEFINE(TimeBase, GetMovieTimeBase, (Movie m), (m), 0);
+ wxDL_METHOD_DEFINE(TimeScale, GetMovieTimeScale, (Movie m), (m), 0);
+ wxDL_METHOD_DEFINE(long, GetMovieTime, (Movie m, void* cruft), (m,cruft), 0);
+ wxDL_VOIDMETHOD_DEFINE(SetMovieTime, (Movie m, TimeRecord* tr), (m,tr) );
+};
+
+bool wxQuickTimeLibrary::Initialize()
+{
+ m_ok = false;
+
+ if(!m_dll.Load(wxT("qtmlClient.dll")))
+ return false;
+
+ bool bOk;
+
+ wxDL_METHOD_LOAD( m_dll, StartMovie, bOk );
+ wxDL_METHOD_LOAD( m_dll, StopMovie, bOk );
+ wxDL_METHOD_LOAD( m_dll, IsMovieDone, bOk );
+ wxDL_METHOD_LOAD( m_dll, GoToBeginningOfMovie, bOk );
+ wxDL_METHOD_LOAD( m_dll, GetMoviesError, bOk );
+ wxDL_METHOD_LOAD( m_dll, EnterMovies, bOk );
+ wxDL_METHOD_LOAD( m_dll, ExitMovies, bOk );
+ wxDL_METHOD_LOAD( m_dll, InitializeQTML, bOk );
+ wxDL_METHOD_LOAD( m_dll, TerminateQTML, bOk );
+ wxDL_METHOD_LOAD( m_dll, NativePathNameToFSSpec, bOk );
+ wxDL_METHOD_LOAD( m_dll, OpenMovieFile, bOk );
+ wxDL_METHOD_LOAD( m_dll, CloseMovieFile, bOk );
+ wxDL_METHOD_LOAD( m_dll, NewMovieFromFile, bOk );
+ wxDL_METHOD_LOAD( m_dll, GetMovieRate, bOk );
+ wxDL_METHOD_LOAD( m_dll, SetMovieRate, bOk );
+ wxDL_METHOD_LOAD( m_dll, MoviesTask, bOk );
+ wxDL_METHOD_LOAD( m_dll, BlockMove, bOk );
+ wxDL_METHOD_LOAD( m_dll, NewHandleClear, bOk );
+ wxDL_METHOD_LOAD( m_dll, NewMovieFromDataRef, bOk );
+ wxDL_METHOD_LOAD( m_dll, DisposeHandle, bOk );
+ wxDL_METHOD_LOAD( m_dll, GetMovieNaturalBoundsRect, bOk );
+ wxDL_METHOD_LOAD( m_dll, GetMovieIndTrackType, bOk );
+ wxDL_METHOD_LOAD( m_dll, CreatePortAssociation, bOk );
+ wxDL_METHOD_LOAD( m_dll, GetNativeWindowPort, bOk );
+ wxDL_METHOD_LOAD( m_dll, SetMovieGWorld, bOk );
+ wxDL_METHOD_LOAD( m_dll, DisposeMovie, bOk );
+ wxDL_METHOD_LOAD( m_dll, SetMovieBox, bOk );
+ wxDL_METHOD_LOAD( m_dll, SetMovieTimeScale, bOk );
+ wxDL_METHOD_LOAD( m_dll, GetMovieDuration, bOk );
+ wxDL_METHOD_LOAD( m_dll, GetMovieTimeBase, bOk );
+ wxDL_METHOD_LOAD( m_dll, GetMovieTimeScale, bOk );
+ wxDL_METHOD_LOAD( m_dll, GetMovieTime, bOk );
+ wxDL_METHOD_LOAD( m_dll, SetMovieTime, bOk );
+
+ m_ok = true;
+
+ return true;
+}
+
+class WXDLLIMPEXP_MEDIA wxQTMediaBackend : public wxMediaBackend
+{
+public:
+
+ wxQTMediaBackend();
+ ~wxQTMediaBackend();
+
+ virtual bool CreateControl(wxControl* ctrl, wxWindow* parent,
+ wxWindowID id,
+ const wxPoint& pos,
+ const wxSize& size,
+ long style,
+ const wxValidator& validator,
+ const wxString& name);
+
+ virtual bool Play();
+ virtual bool Pause();
+ virtual bool Stop();
+
+ virtual bool Load(const wxString& fileName);
+ virtual bool Load(const wxURI& location);
+
+ virtual wxMediaState GetState();
+
+ virtual bool SetPosition(wxLongLong where);
+ virtual wxLongLong GetPosition();
+ virtual wxLongLong GetDuration();
+
+ virtual void Move(int x, int y, int w, int h);
+ wxSize GetVideoSize() const;
+
+ virtual double GetPlaybackRate();
+ virtual bool SetPlaybackRate(double dRate);
+
+ void Cleanup();
+ void FinishLoad();
+
+ wxSize m_bestSize; //Original movie size
+ Movie m_movie; //QT Movie handle/instance
+ wxControl* m_ctrl; //Parent control
+ bool m_bVideo; //Whether or not we have video
+ class _wxQTTimer* m_timer; //Timer for streaming the movie
+ wxQuickTimeLibrary m_lib;
+
+
+ DECLARE_DYNAMIC_CLASS(wxQTMediaBackend);
+};
+
+//---------------------------------------------------------------------------
+// End QT Compilation Guard
+//---------------------------------------------------------------------------
+#endif //wxUSE_QUICKTIME
+
+//===========================================================================