]> git.saurik.com Git - wxWidgets.git/blame - contrib/src/mmedia/vidwin.cpp
Changes to make commandline compilation with VC6 match the same settings and LIB...
[wxWidgets.git] / contrib / src / mmedia / vidwin.cpp
CommitLineData
e8482f24
GL
1// -----------------------------------------------------------------------------
2// Name: vidwin.h
3// Purpose: wxMMedia
4// Author: Guilhem Lavaux
5// Created: February 1998
6// Updated:
7// Copyright: (C) 1998, 1999, 2000 Guilhem Lavaux
8// License: wxWindows license
9// -----------------------------------------------------------------------------
10
11#ifdef __GNUG__
12#pragma implementation "vidwin.h"
13#endif
14
15#include "wx/wxprec.h"
16
17#ifndef WX_PRECOMP
18#include "wx/wx.h"
19#endif
20
d0af5538 21#if defined(__WINDOWS__) && !defined(__GNUWIN32__)
e8482f24
GL
22
23#ifdef __BORLANDC__
24 #pragma hdrstop
25#endif
26
27#include "wx/stream.h"
28#include "wx/wfstream.h"
29
30#define WXMMEDIA_INTERNAL
31#include <windows.h>
32#include <mmsystem.h>
33#include <digitalv.h>
34#include "wx/mmedia/vidwin.h"
35
36#ifdef __BORLANDC__
37#pragma hdrstop
38#endif
39
40IMPLEMENT_DYNAMIC_CLASS(wxVideoWindows, wxVideoBaseDriver)
41
42wxVideoWindows::wxVideoWindows()
43{
44}
45
46wxVideoWindows::wxVideoWindows(wxInputStream& str)
47 : wxVideoBaseDriver(str)
48{
49 m_internal = new wxVIDWinternal;
50 m_remove_file = TRUE;
51 m_filename = wxGetTempFileName("wxvid");
52 m_paused = FALSE;
53 m_stopped = TRUE;
54 m_frameRate = 1.0;
55
56 wxFileOutputStream temp_file(m_filename);
57 temp_file << str;
58
59 OpenFile();
60}
61
62wxVideoWindows::wxVideoWindows(const wxString& filename)
63 : wxVideoBaseDriver(filename)
64{
65 m_internal = new wxVIDWinternal;
66 m_remove_file = FALSE;
67 m_filename = filename;
68 m_paused = FALSE;
69 m_stopped = TRUE;
70 m_frameRate = 1.0;
71 OpenFile();
72}
73
74wxVideoWindows::~wxVideoWindows(void)
75{
76 mciSendCommand(m_internal->m_dev_id, MCI_CLOSE, 0, 0);
77
78 if (m_internal)
79 delete m_internal;
80}
81
82void wxVideoWindows::OpenFile()
83{
84 MCI_DGV_OPEN_PARMS openStruct;
85 MCI_DGV_SET_PARMS setStruct;
86 MCI_STATUS_PARMS statusStruct;
87 DWORD ret;
88
89 openStruct.lpstrDeviceType = "avivideo";
90 openStruct.lpstrElementName = (LPSTR)(m_filename.mb_str());
91 openStruct.hWndParent = 0;
92
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;
97
98
99 setStruct.dwCallback = 0;
100 setStruct.dwTimeFormat = MCI_FORMAT_FRAMES;
101
102 ret = mciSendCommand(m_internal->m_dev_id, MCI_SET, MCI_SET_TIME_FORMAT,
103 (DWORD)(LPVOID)&setStruct);
104
105
106 statusStruct.dwCallback = 0;
107 statusStruct.dwItem = MCI_DGV_STATUS_FRAME_RATE;
108 ret = mciSendCommand(m_internal->m_dev_id, MCI_STATUS,
109 MCI_STATUS_ITEM,
110 (DWORD)(LPVOID)&statusStruct);
111
112 m_frameRate = ((double)statusStruct.dwReturn) / 1000;
113
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;
118
119}
120
121bool wxVideoWindows::Pause()
122{
123 if (m_paused || m_stopped)
124 return TRUE;
125 m_paused = TRUE;
126 return (mciSendCommand(m_internal->m_dev_id, MCI_PAUSE, MCI_WAIT, 0) == 0);
127}
128
129bool wxVideoWindows::Resume()
130{
131 if (!m_paused || m_stopped)
132 return TRUE;
133 m_paused = FALSE;
134 return (mciSendCommand(m_internal->m_dev_id, MCI_RESUME, 0, 0) == 0);
135}
136
137bool wxVideoWindows::IsPaused() const
138{
139 return m_paused;
140}
141
142bool wxVideoWindows::IsStopped() const
143{
144 return m_stopped;
145}
146
147bool wxVideoWindows::GetSize(wxSize& size) const
148{
149 size.SetWidth(200);
150 size.SetHeight(200);
151 return TRUE;
152}
153
154bool wxVideoWindows::SetSize(wxSize size)
155{
156 return TRUE;
157}
158
159bool wxVideoWindows::IsCapable(wxVideoType v_type)
160{
161 return (v_type == wxVIDEO_MSAVI);
162}
163
164bool wxVideoWindows::AttachOutput(wxWindow& output)
165{
166 MCI_DGV_WINDOW_PARMS win_struct;
167
168 if (!wxVideoBaseDriver::AttachOutput(output))
169 return FALSE;
170
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);
174 return TRUE;
175}
176
177void wxVideoWindows::DetachOutput()
178{
179 MCI_DGV_WINDOW_PARMS win_struct;
180
181 wxVideoBaseDriver::DetachOutput();
182
183 win_struct.hWnd = 0;
184 mciSendCommand(m_internal->m_dev_id, MCI_WINDOW,
185 MCI_DGV_WINDOW_HWND, (DWORD)(LPVOID)&win_struct);
186}
187
188bool wxVideoWindows::Play()
189{
190 if (!m_stopped)
191 return FALSE;
192 m_stopped = FALSE;
193 return (mciSendCommand(m_internal->m_dev_id, MCI_PLAY, 0, NULL) == 0);
194}
195
196bool wxVideoWindows::Stop()
197{
198 MCI_SEEK_PARMS seekStruct;
199
200 if (m_stopped)
201 return FALSE;
202 m_stopped = TRUE;
203 if (::mciSendCommand(m_internal->m_dev_id, MCI_STOP, MCI_WAIT, NULL) != 0)
204 return FALSE;
205
206 seekStruct.dwCallback = 0;
207 seekStruct.dwTo = 0;
208 return (::mciSendCommand(m_internal->m_dev_id, MCI_SEEK, MCI_SEEK_TO_START|MCI_WAIT, (DWORD)(LPVOID)&seekStruct) == 0);
209}
210
211// TODO TODO
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 !
214
215wxString wxVideoWindows::GetMovieCodec() const
216{
217 return wxT("No info");
218}
219
220wxString wxVideoWindows::GetAudioCodec() const
221{
222 return wxT("No info");
223}
224
225wxUint32 wxVideoWindows::GetSampleRate() const
226{
227 return 22500;
228}
229
230wxUint8 wxVideoWindows::GetChannels() const
231{
232 return 1;
233}
234
235wxUint8 wxVideoWindows::GetBPS() const
236{
237 return m_bps;
238}
239
240double wxVideoWindows::GetFrameRate() const
241{
242 return m_frameRate;
243}
244
245wxUint32 wxVideoWindows::GetNbFrames() const
246{
247 return 0;
248}
249
250#endif
251 // __WINDOWS__