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(__GNUWIN32__) && !defined(__WATCOMC__)
27 #include "wx/stream.h"
28 #include "wx/wfstream.h"
30 #define WXMMEDIA_INTERNAL
34 #include "wx/mmedia/vidwin.h"
40 IMPLEMENT_DYNAMIC_CLASS(wxVideoWindows
, wxVideoBaseDriver
)
42 wxVideoWindows::wxVideoWindows()
46 wxVideoWindows::wxVideoWindows(wxInputStream
& str
)
47 : wxVideoBaseDriver(str
)
49 m_internal
= new wxVIDWinternal
;
51 m_filename
= wxGetTempFileName(_T("wxvid"));
56 wxFileOutputStream
temp_file(m_filename
);
62 wxVideoWindows::wxVideoWindows(const wxString
& filename
)
63 : wxVideoBaseDriver(filename
)
65 m_internal
= new wxVIDWinternal
;
66 m_remove_file
= FALSE
;
67 m_filename
= filename
;
74 wxVideoWindows::~wxVideoWindows(void)
76 mciSendCommand(m_internal
->m_dev_id
, MCI_CLOSE
, 0, 0);
82 void wxVideoWindows::OpenFile()
84 MCI_DGV_OPEN_PARMS openStruct
;
85 MCI_DGV_SET_PARMS setStruct
;
86 MCI_STATUS_PARMS statusStruct
;
88 openStruct
.lpstrDeviceType
= _T("avivideo");
89 openStruct
.lpstrElementName
= (wxChar
*)m_filename
.mb_str().data();
90 openStruct
.hWndParent
= 0;
92 mciSendCommand(0, MCI_OPEN
,
93 MCI_OPEN_ELEMENT
|MCI_DGV_OPEN_PARENT
|MCI_OPEN_TYPE
|MCI_DGV_OPEN_32BIT
,
94 (DWORD
)(LPVOID
)&openStruct
);
95 m_internal
->m_dev_id
= openStruct
.wDeviceID
;
98 setStruct
.dwCallback
= 0;
99 setStruct
.dwTimeFormat
= MCI_FORMAT_FRAMES
;
101 mciSendCommand(m_internal
->m_dev_id
, MCI_SET
, MCI_SET_TIME_FORMAT
,
102 (DWORD
)(LPVOID
)&setStruct
);
105 statusStruct
.dwCallback
= 0;
106 statusStruct
.dwItem
= MCI_DGV_STATUS_FRAME_RATE
;
107 mciSendCommand(m_internal
->m_dev_id
, MCI_STATUS
,
109 (DWORD
)(LPVOID
)&statusStruct
);
111 m_frameRate
= ((double)statusStruct
.dwReturn
) / 1000;
113 statusStruct
.dwItem
= MCI_DGV_STATUS_BITSPERSAMPLE
;
114 mciSendCommand(m_internal
->m_dev_id
, MCI_STATUS
, MCI_STATUS_ITEM
,
115 (DWORD
)(LPVOID
)&statusStruct
);
116 m_bps
= statusStruct
.dwReturn
;
120 bool wxVideoWindows::Pause()
122 if (m_paused
|| m_stopped
)
125 return (mciSendCommand(m_internal
->m_dev_id
, MCI_PAUSE
, MCI_WAIT
, 0) == 0);
128 bool wxVideoWindows::Resume()
130 if (!m_paused
|| m_stopped
)
133 return (mciSendCommand(m_internal
->m_dev_id
, MCI_RESUME
, 0, 0) == 0);
136 bool wxVideoWindows::IsPaused() const
141 bool wxVideoWindows::IsStopped() const
146 bool wxVideoWindows::GetSize(wxSize
& size
) const
153 bool wxVideoWindows::SetSize(wxSize
WXUNUSED(size
))
158 bool wxVideoWindows::IsCapable(wxVideoType v_type
)
160 return (v_type
== wxVIDEO_MSAVI
);
163 bool wxVideoWindows::AttachOutput(wxWindow
& output
)
165 MCI_DGV_WINDOW_PARMS win_struct
;
167 if (!wxVideoBaseDriver::AttachOutput(output
))
170 win_struct
.hWnd
= (HWND
)output
.GetHWND();
171 mciSendCommand(m_internal
->m_dev_id
, MCI_WINDOW
,
172 MCI_DGV_WINDOW_HWND
, (DWORD
)(LPVOID
)&win_struct
);
176 void wxVideoWindows::DetachOutput()
178 MCI_DGV_WINDOW_PARMS win_struct
;
180 wxVideoBaseDriver::DetachOutput();
183 mciSendCommand(m_internal
->m_dev_id
, MCI_WINDOW
,
184 MCI_DGV_WINDOW_HWND
, (DWORD
)(LPVOID
)&win_struct
);
187 bool wxVideoWindows::Play()
192 return (mciSendCommand(m_internal
->m_dev_id
, MCI_PLAY
, 0, NULL
) == 0);
195 bool wxVideoWindows::Stop()
197 MCI_SEEK_PARMS seekStruct
;
202 if (::mciSendCommand(m_internal
->m_dev_id
, MCI_STOP
, MCI_WAIT
, NULL
) != 0)
205 seekStruct
.dwCallback
= 0;
207 return (::mciSendCommand(m_internal
->m_dev_id
, MCI_SEEK
, MCI_SEEK_TO_START
|MCI_WAIT
, (DWORD
)(LPVOID
)&seekStruct
) == 0);
211 // I hate windows :-(. The doc says MCI_STATUS should return all info I want but when I call it
212 // it returns to me with an UNSUPPORTED_FUNCTION error. I will have to do all by myself. Grrrr !
214 wxString
wxVideoWindows::GetMovieCodec() const
216 return wxT("No info");
219 wxString
wxVideoWindows::GetAudioCodec() const
221 return wxT("No info");
224 wxUint32
wxVideoWindows::GetSampleRate() const
229 wxUint8
wxVideoWindows::GetChannels() const
234 wxUint8
wxVideoWindows::GetBPS() const
239 double wxVideoWindows::GetFrameRate() const
244 wxUint32
wxVideoWindows::GetNbFrames() const