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 #include "wx/stream.h"
22 #include "wx/wfstream.h"
24 #define WXMMEDIA_INTERNAL
34 IMPLEMENT_DYNAMIC_CLASS(wxVideoWindows
, wxVideoBaseDriver
)
36 wxVideoWindows::wxVideoWindows()
40 wxVideoWindows::wxVideoWindows(wxInputStream
& str
)
41 : wxVideoBaseDriver(str
)
43 m_internal
= new wxVIDWinternal
;
45 m_filename
= wxGetTempFileName("wxvid");
49 wxFileOutputStream
temp_file(m_filename
);
55 wxVideoWindows::wxVideoWindows(const wxString
& filename
)
56 : wxVideoBaseDriver(filename
)
58 m_internal
= new wxVIDWinternal
;
59 m_remove_file
= FALSE
;
60 m_filename
= filename
;
66 wxVideoWindows::~wxVideoWindows(void)
68 mciSendCommand(m_internal
->m_dev_id
, MCI_CLOSE
, 0, 0);
74 void wxVideoWindows::OpenFile()
76 MCI_DGV_OPEN_PARMS open_struct
;
79 open_struct
.lpstrDeviceType
= "avivideo";
80 open_struct
.lpstrElementName
= (LPSTR
)(m_filename
.mb_str());
81 open_struct
.hWndParent
= 0;
83 ret
= mciSendCommand(0, MCI_OPEN
,
84 MCI_OPEN_ELEMENT
|MCI_DGV_OPEN_PARENT
|MCI_OPEN_TYPE
|MCI_DGV_OPEN_32BIT
,
85 (DWORD
)(LPVOID
)&open_struct
);
86 m_internal
->m_dev_id
= open_struct
.wDeviceID
;
89 bool wxVideoWindows::Pause()
91 if (m_paused
|| m_stopped
)
94 return (mciSendCommand(m_internal
->m_dev_id
, MCI_PAUSE
, 0, 0) == 0);
97 bool wxVideoWindows::Resume()
99 if (!m_paused
|| m_stopped
)
102 return (mciSendCommand(m_internal
->m_dev_id
, MCI_RESUME
, 0, 0) == 0);
105 bool wxVideoWindows::IsPaused() const
110 bool wxVideoWindows::IsStopped() const
115 bool wxVideoWindows::GetSize(wxSize
& size
) const
117 // Two random numbers.
123 bool wxVideoWindows::SetSize(wxSize size
)
128 bool wxVideoWindows::IsCapable(wxVideoType v_type
)
130 return (v_type
== wxVIDEO_MSAVI
);
133 bool wxVideoWindows::AttachOutput(wxWindow
& output
)
135 MCI_DGV_WINDOW_PARMS win_struct
;
137 if (!wxVideoBaseDriver::AttachOutput(output
))
140 win_struct
.hWnd
= (HWND
)output
.GetHWND();
141 mciSendCommand(m_internal
->m_dev_id
, MCI_WINDOW
,
142 MCI_DGV_WINDOW_HWND
, (DWORD
)(LPVOID
)&win_struct
);
146 void wxVideoWindows::DetachOutput()
148 MCI_DGV_WINDOW_PARMS win_struct
;
150 wxVideoBaseDriver::DetachOutput();
153 mciSendCommand(m_internal
->m_dev_id
, MCI_WINDOW
,
154 MCI_DGV_WINDOW_HWND
, (DWORD
)(LPVOID
)&win_struct
);
157 bool wxVideoWindows::Play()
162 return (mciSendCommand(m_internal
->m_dev_id
, MCI_PLAY
, 0, NULL
) == 0);
165 bool wxVideoWindows::Stop()
167 MCI_SEEK_PARMS seekStruct
;
172 if (::mciSendCommand(m_internal
->m_dev_id
, MCI_STOP
, 0, NULL
) != 0)
175 seekStruct
.dwCallback
= 0;
177 return (::mciSendCommand(m_internal
->m_dev_id
, MCI_SEEK
, 0, (DWORD
)(LPVOID
)&seekStruct
) == 0);
183 wxString
wxVideoWindows::GetMovieCodec() const
185 return wxT("No info");
188 wxString
wxVideoWindows::GetAudioCodec() const
190 return wxT("No info");
193 wxUint32
wxVideoWindows::GetSampleRate() const
198 wxUint8
wxVideoWindows::GetChannels() const
203 wxUint8
wxVideoWindows::GetBPS() const
208 double wxVideoWindows::GetFrameRate() const
213 wxUint32
wxVideoWindows::GetNbFrames() const