1 // -----------------------------------------------------------------------------
4 // Author: Guilhem Lavaux
5 // Created: February 1998
7 // Copyright: (C) 1998, 1999, 2000 Guilhem Lavaux
8 // License: wxWindows license
9 // -----------------------------------------------------------------------------
12 #pragma implementation "vidwin.h"
15 #include "wx/wxprec.h"
21 #if defined(__WINDOWS__) && !defined(__MINGW32__) && !defined(__WATCOMC__) && !defined(__CYGWIN__)
22 // versions of Open Watcom and MinGW tested against this source does not
23 // deliver "digitalv.h" required in this feature
29 #include "wx/stream.h"
30 #include "wx/wfstream.h"
32 #define WXMMEDIA_INTERNAL
36 #include "wx/mmedia/vidwin.h"
42 IMPLEMENT_DYNAMIC_CLASS(wxVideoWindows
, wxVideoBaseDriver
)
44 wxVideoWindows::wxVideoWindows()
48 wxVideoWindows::wxVideoWindows(wxInputStream
& str
)
49 : wxVideoBaseDriver(str
)
51 m_internal
= new wxVIDWinternal
;
53 m_filename
= wxGetTempFileName(_T("wxvid"));
58 wxFileOutputStream
temp_file(m_filename
);
64 wxVideoWindows::wxVideoWindows(const wxString
& filename
)
65 : wxVideoBaseDriver(filename
)
67 m_internal
= new wxVIDWinternal
;
68 m_remove_file
= false;
69 m_filename
= filename
;
76 wxVideoWindows::~wxVideoWindows(void)
78 mciSendCommand(m_internal
->m_dev_id
, MCI_CLOSE
, 0, 0);
84 void wxVideoWindows::OpenFile()
86 MCI_DGV_OPEN_PARMS openStruct
;
87 MCI_DGV_SET_PARMS setStruct
;
88 MCI_STATUS_PARMS statusStruct
;
90 openStruct
.lpstrDeviceType
= _T("avivideo");
91 openStruct
.lpstrElementName
= (wxChar
*)m_filename
.c_str();
92 openStruct
.hWndParent
= 0;
94 mciSendCommand(0, MCI_OPEN
,
95 MCI_OPEN_ELEMENT
|MCI_DGV_OPEN_PARENT
|MCI_OPEN_TYPE
|MCI_DGV_OPEN_32BIT
,
96 (DWORD
)(LPVOID
)&openStruct
);
97 m_internal
->m_dev_id
= openStruct
.wDeviceID
;
100 setStruct
.dwCallback
= 0;
101 setStruct
.dwTimeFormat
= MCI_FORMAT_FRAMES
;
103 mciSendCommand(m_internal
->m_dev_id
, MCI_SET
, MCI_SET_TIME_FORMAT
,
104 (DWORD
)(LPVOID
)&setStruct
);
107 statusStruct
.dwCallback
= 0;
108 statusStruct
.dwItem
= MCI_DGV_STATUS_FRAME_RATE
;
109 mciSendCommand(m_internal
->m_dev_id
, MCI_STATUS
,
111 (DWORD
)(LPVOID
)&statusStruct
);
113 m_frameRate
= ((double)statusStruct
.dwReturn
) / 1000;
115 statusStruct
.dwItem
= MCI_DGV_STATUS_BITSPERSAMPLE
;
116 mciSendCommand(m_internal
->m_dev_id
, MCI_STATUS
, MCI_STATUS_ITEM
,
117 (DWORD
)(LPVOID
)&statusStruct
);
118 m_bps
= statusStruct
.dwReturn
;
122 bool wxVideoWindows::Pause()
124 if (m_paused
|| m_stopped
)
127 return (mciSendCommand(m_internal
->m_dev_id
, MCI_PAUSE
, MCI_WAIT
, 0) == 0);
130 bool wxVideoWindows::Resume()
132 if (!m_paused
|| m_stopped
)
135 return (mciSendCommand(m_internal
->m_dev_id
, MCI_RESUME
, 0, 0) == 0);
138 bool wxVideoWindows::IsPaused() const
143 bool wxVideoWindows::IsStopped() const
148 bool wxVideoWindows::GetSize(wxSize
& size
) const
155 bool wxVideoWindows::SetSize(wxSize
WXUNUSED(size
))
160 bool wxVideoWindows::IsCapable(wxVideoType v_type
) const
162 return (v_type
== wxVIDEO_MSAVI
);
165 bool wxVideoWindows::AttachOutput(wxWindow
& output
)
167 MCI_DGV_WINDOW_PARMS win_struct
;
169 if (!wxVideoBaseDriver::AttachOutput(output
))
172 win_struct
.hWnd
= (HWND
)output
.GetHWND();
173 mciSendCommand(m_internal
->m_dev_id
, MCI_WINDOW
,
174 MCI_DGV_WINDOW_HWND
, (DWORD
)(LPVOID
)&win_struct
);
178 void wxVideoWindows::DetachOutput()
180 MCI_DGV_WINDOW_PARMS win_struct
;
182 wxVideoBaseDriver::DetachOutput();
185 mciSendCommand(m_internal
->m_dev_id
, MCI_WINDOW
,
186 MCI_DGV_WINDOW_HWND
, (DWORD
)(LPVOID
)&win_struct
);
189 bool wxVideoWindows::Play()
194 return (mciSendCommand(m_internal
->m_dev_id
, MCI_PLAY
, 0, NULL
) == 0);
197 bool wxVideoWindows::Stop()
199 MCI_SEEK_PARMS seekStruct
;
204 if (::mciSendCommand(m_internal
->m_dev_id
, MCI_STOP
, MCI_WAIT
, NULL
) != 0)
207 seekStruct
.dwCallback
= 0;
209 return (::mciSendCommand(m_internal
->m_dev_id
, MCI_SEEK
, MCI_SEEK_TO_START
|MCI_WAIT
, (DWORD
)(LPVOID
)&seekStruct
) == 0);
213 // I hate windows :-(. The doc says MCI_STATUS should return all info I want but when I call it
214 // it returns to me with an UNSUPPORTED_FUNCTION error. I will have to do all by myself. Grrrr !
216 wxString
wxVideoWindows::GetMovieCodec() const
218 return wxT("No info");
221 wxString
wxVideoWindows::GetAudioCodec() const
223 return wxT("No info");
226 wxUint32
wxVideoWindows::GetSampleRate() const
231 wxUint8
wxVideoWindows::GetChannels() const
236 wxUint8
wxVideoWindows::GetBPS() const
241 double wxVideoWindows::GetFrameRate() const
246 wxUint32
wxVideoWindows::GetNbFrames() const