1 // -----------------------------------------------------------------------------
4 // Author: Guilhem Lavaux
5 // Created: February 1998
7 // Copyright: (C) 1998, 1999, 2000 Guilhem Lavaux
8 // License: wxWindows license
9 // -----------------------------------------------------------------------------
11 #include "wx/wxprec.h"
17 #if defined(__WINDOWS__) && !defined(__MINGW32__) && !defined(__WATCOMC__) && !defined(__CYGWIN__)
18 // versions of Open Watcom and MinGW tested against this source does not
19 // deliver "digitalv.h" required in this feature
25 #include "wx/stream.h"
26 #include "wx/wfstream.h"
28 #define WXMMEDIA_INTERNAL
32 #include "wx/mmedia/vidwin.h"
38 IMPLEMENT_DYNAMIC_CLASS(wxVideoWindows
, wxVideoBaseDriver
)
40 wxVideoWindows::wxVideoWindows()
44 wxVideoWindows::wxVideoWindows(wxInputStream
& str
)
45 : wxVideoBaseDriver(str
)
47 m_internal
= new wxVIDWinternal
;
49 m_filename
= wxGetTempFileName(_T("wxvid"));
54 wxFileOutputStream
temp_file(m_filename
);
60 wxVideoWindows::wxVideoWindows(const wxString
& filename
)
61 : wxVideoBaseDriver(filename
)
63 m_internal
= new wxVIDWinternal
;
64 m_remove_file
= false;
65 m_filename
= filename
;
72 wxVideoWindows::~wxVideoWindows(void)
74 mciSendCommand(m_internal
->m_dev_id
, MCI_CLOSE
, 0, 0);
80 void wxVideoWindows::OpenFile()
82 MCI_DGV_OPEN_PARMS openStruct
;
83 MCI_DGV_SET_PARMS setStruct
;
84 MCI_STATUS_PARMS statusStruct
;
86 openStruct
.lpstrDeviceType
= _T("avivideo");
87 openStruct
.lpstrElementName
= (wxChar
*)m_filename
.c_str();
88 openStruct
.hWndParent
= 0;
90 mciSendCommand(0, MCI_OPEN
,
91 MCI_OPEN_ELEMENT
|MCI_DGV_OPEN_PARENT
|MCI_OPEN_TYPE
|MCI_DGV_OPEN_32BIT
,
92 (DWORD
)(LPVOID
)&openStruct
);
93 m_internal
->m_dev_id
= openStruct
.wDeviceID
;
96 setStruct
.dwCallback
= 0;
97 setStruct
.dwTimeFormat
= MCI_FORMAT_FRAMES
;
99 mciSendCommand(m_internal
->m_dev_id
, MCI_SET
, MCI_SET_TIME_FORMAT
,
100 (DWORD
)(LPVOID
)&setStruct
);
103 statusStruct
.dwCallback
= 0;
104 statusStruct
.dwItem
= MCI_DGV_STATUS_FRAME_RATE
;
105 mciSendCommand(m_internal
->m_dev_id
, MCI_STATUS
,
107 (DWORD
)(LPVOID
)&statusStruct
);
109 m_frameRate
= ((double)statusStruct
.dwReturn
) / 1000;
111 statusStruct
.dwItem
= MCI_DGV_STATUS_BITSPERSAMPLE
;
112 mciSendCommand(m_internal
->m_dev_id
, MCI_STATUS
, MCI_STATUS_ITEM
,
113 (DWORD
)(LPVOID
)&statusStruct
);
114 m_bps
= statusStruct
.dwReturn
;
118 bool wxVideoWindows::Pause()
120 if (m_paused
|| m_stopped
)
123 return (mciSendCommand(m_internal
->m_dev_id
, MCI_PAUSE
, MCI_WAIT
, 0) == 0);
126 bool wxVideoWindows::Resume()
128 if (!m_paused
|| m_stopped
)
131 return (mciSendCommand(m_internal
->m_dev_id
, MCI_RESUME
, 0, 0) == 0);
134 bool wxVideoWindows::IsPaused() const
139 bool wxVideoWindows::IsStopped() const
144 bool wxVideoWindows::GetSize(wxSize
& size
) const
151 bool wxVideoWindows::SetSize(wxSize
WXUNUSED(size
))
156 bool wxVideoWindows::IsCapable(wxVideoType v_type
) const
158 return (v_type
== wxVIDEO_MSAVI
);
161 bool wxVideoWindows::AttachOutput(wxWindow
& output
)
163 MCI_DGV_WINDOW_PARMS win_struct
;
165 if (!wxVideoBaseDriver::AttachOutput(output
))
168 win_struct
.hWnd
= (HWND
)output
.GetHWND();
169 mciSendCommand(m_internal
->m_dev_id
, MCI_WINDOW
,
170 MCI_DGV_WINDOW_HWND
, (DWORD
)(LPVOID
)&win_struct
);
174 void wxVideoWindows::DetachOutput()
176 MCI_DGV_WINDOW_PARMS win_struct
;
178 wxVideoBaseDriver::DetachOutput();
181 mciSendCommand(m_internal
->m_dev_id
, MCI_WINDOW
,
182 MCI_DGV_WINDOW_HWND
, (DWORD
)(LPVOID
)&win_struct
);
185 bool wxVideoWindows::Play()
190 return (mciSendCommand(m_internal
->m_dev_id
, MCI_PLAY
, 0, NULL
) == 0);
193 bool wxVideoWindows::Stop()
195 MCI_SEEK_PARMS seekStruct
;
200 if (::mciSendCommand(m_internal
->m_dev_id
, MCI_STOP
, MCI_WAIT
, NULL
) != 0)
203 seekStruct
.dwCallback
= 0;
205 return (::mciSendCommand(m_internal
->m_dev_id
, MCI_SEEK
, MCI_SEEK_TO_START
|MCI_WAIT
, (DWORD
)(LPVOID
)&seekStruct
) == 0);
209 // I hate windows :-(. The doc says MCI_STATUS should return all info I want but when I call it
210 // it returns to me with an UNSUPPORTED_FUNCTION error. I will have to do all by myself. Grrrr !
212 wxString
wxVideoWindows::GetMovieCodec() const
214 return wxT("No info");
217 wxString
wxVideoWindows::GetAudioCodec() const
219 return wxT("No info");
222 wxUint32
wxVideoWindows::GetSampleRate() const
227 wxUint8
wxVideoWindows::GetChannels() const
232 wxUint8
wxVideoWindows::GetBPS() const
237 double wxVideoWindows::GetFrameRate() const
242 wxUint32
wxVideoWindows::GetNbFrames() const