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__)
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("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
;
89 openStruct
.lpstrDeviceType
= "avivideo";
90 openStruct
.lpstrElementName
= (LPSTR
)(m_filename
.mb_str());
91 openStruct
.hWndParent
= 0;
93 ret
= mciSendCommand(0, MCI_OPEN
,
94 MCI_OPEN_ELEMENT
|MCI_DGV_OPEN_PARENT
|MCI_OPEN_TYPE
|MCI_DGV_OPEN_32BIT
,
95 (DWORD
)(LPVOID
)&openStruct
);
96 m_internal
->m_dev_id
= openStruct
.wDeviceID
;
99 setStruct
.dwCallback
= 0;
100 setStruct
.dwTimeFormat
= MCI_FORMAT_FRAMES
;
102 ret
= mciSendCommand(m_internal
->m_dev_id
, MCI_SET
, MCI_SET_TIME_FORMAT
,
103 (DWORD
)(LPVOID
)&setStruct
);
106 statusStruct
.dwCallback
= 0;
107 statusStruct
.dwItem
= MCI_DGV_STATUS_FRAME_RATE
;
108 ret
= mciSendCommand(m_internal
->m_dev_id
, MCI_STATUS
,
110 (DWORD
)(LPVOID
)&statusStruct
);
112 m_frameRate
= ((double)statusStruct
.dwReturn
) / 1000;
114 statusStruct
.dwItem
= MCI_DGV_STATUS_BITSPERSAMPLE
;
115 ret
= mciSendCommand(m_internal
->m_dev_id
, MCI_STATUS
, MCI_STATUS_ITEM
,
116 (DWORD
)(LPVOID
)&statusStruct
);
117 m_bps
= statusStruct
.dwReturn
;
121 bool wxVideoWindows::Pause()
123 if (m_paused
|| m_stopped
)
126 return (mciSendCommand(m_internal
->m_dev_id
, MCI_PAUSE
, MCI_WAIT
, 0) == 0);
129 bool wxVideoWindows::Resume()
131 if (!m_paused
|| m_stopped
)
134 return (mciSendCommand(m_internal
->m_dev_id
, MCI_RESUME
, 0, 0) == 0);
137 bool wxVideoWindows::IsPaused() const
142 bool wxVideoWindows::IsStopped() const
147 bool wxVideoWindows::GetSize(wxSize
& size
) const
154 bool wxVideoWindows::SetSize(wxSize size
)
159 bool wxVideoWindows::IsCapable(wxVideoType v_type
)
161 return (v_type
== wxVIDEO_MSAVI
);
164 bool wxVideoWindows::AttachOutput(wxWindow
& output
)
166 MCI_DGV_WINDOW_PARMS win_struct
;
168 if (!wxVideoBaseDriver::AttachOutput(output
))
171 win_struct
.hWnd
= (HWND
)output
.GetHWND();
172 mciSendCommand(m_internal
->m_dev_id
, MCI_WINDOW
,
173 MCI_DGV_WINDOW_HWND
, (DWORD
)(LPVOID
)&win_struct
);
177 void wxVideoWindows::DetachOutput()
179 MCI_DGV_WINDOW_PARMS win_struct
;
181 wxVideoBaseDriver::DetachOutput();
184 mciSendCommand(m_internal
->m_dev_id
, MCI_WINDOW
,
185 MCI_DGV_WINDOW_HWND
, (DWORD
)(LPVOID
)&win_struct
);
188 bool wxVideoWindows::Play()
193 return (mciSendCommand(m_internal
->m_dev_id
, MCI_PLAY
, 0, NULL
) == 0);
196 bool wxVideoWindows::Stop()
198 MCI_SEEK_PARMS seekStruct
;
203 if (::mciSendCommand(m_internal
->m_dev_id
, MCI_STOP
, MCI_WAIT
, NULL
) != 0)
206 seekStruct
.dwCallback
= 0;
208 return (::mciSendCommand(m_internal
->m_dev_id
, MCI_SEEK
, MCI_SEEK_TO_START
|MCI_WAIT
, (DWORD
)(LPVOID
)&seekStruct
) == 0);
212 // I hate windows :-(. The doc says MCI_STATUS should return all info I want but when I call it
213 // it returns to me with an UNSUPPORTED_FUNCTION error. I will have to do all by myself. Grrrr !
215 wxString
wxVideoWindows::GetMovieCodec() const
217 return wxT("No info");
220 wxString
wxVideoWindows::GetAudioCodec() const
222 return wxT("No info");
225 wxUint32
wxVideoWindows::GetSampleRate() const
230 wxUint8
wxVideoWindows::GetChannels() const
235 wxUint8
wxVideoWindows::GetBPS() const
240 double wxVideoWindows::GetFrameRate() const
245 wxUint32
wxVideoWindows::GetNbFrames() const