37 files changed, 1102 insertions, 1270 deletions
diff --git a/core/multimedia/opieplayer/Makefile.in b/core/multimedia/opieplayer/Makefile.in index 8d33fb4..1d2ff5e 100644 --- a/core/multimedia/opieplayer/Makefile.in +++ b/core/multimedia/opieplayer/Makefile.in | |||
@@ -107,187 +107,167 @@ clean: | |||
107 | -rm -f $(OBJECTS) $(OBJMOC) $(SRCMOC) $(UICIMPLS) $(UICDECLS) | 107 | -rm -f $(OBJECTS) $(OBJMOC) $(SRCMOC) $(UICIMPLS) $(UICDECLS) |
108 | -rm -f *~ core | 108 | -rm -f *~ core |
109 | -rm -f allmoc.cpp | 109 | -rm -f allmoc.cpp |
110 | 110 | ||
111 | ####### Extension Modules | 111 | ####### Extension Modules |
112 | 112 | ||
113 | listpromodules: | 113 | listpromodules: |
114 | @echo | 114 | @echo |
115 | 115 | ||
116 | listallmodules: | 116 | listallmodules: |
117 | @echo | 117 | @echo |
118 | 118 | ||
119 | listaddonpromodules: | 119 | listaddonpromodules: |
120 | @echo | 120 | @echo |
121 | 121 | ||
122 | listaddonentmodules: | 122 | listaddonentmodules: |
123 | @echo | 123 | @echo |
124 | 124 | ||
125 | 125 | ||
126 | REQUIRES= | 126 | REQUIRES= |
127 | 127 | ||
128 | ####### Sub-libraries | 128 | ####### Sub-libraries |
129 | 129 | ||
130 | 130 | ||
131 | ###### Combined headers | 131 | ###### Combined headers |
132 | 132 | ||
133 | 133 | ||
134 | 134 | ||
135 | ####### Compile | 135 | ####### Compile |
136 | 136 | ||
137 | main.o: main.cpp \ | 137 | main.o: main.cpp \ |
138 | $(OPIEDIR)/include/qpe/qpeapplication.h \ | 138 | $(OPIEDIR)/include/qpe/qpeapplication.h \ |
139 | $(OPIEDIR)/include/qpedecoration_qws.h \ | ||
140 | $(OPIEDIR)/include/timestring.h \ | ||
141 | mediaplayerstate.h \ | 139 | mediaplayerstate.h \ |
142 | playlistwidget.h \ | 140 | playlistwidget.h \ |
143 | $(OPIEDIR)/include/qpe/applnk.h \ | 141 | $(OPIEDIR)/include/qpe/applnk.h \ |
144 | audiowidget.h \ | 142 | audiowidget.h \ |
145 | videowidget.h \ | 143 | videowidget.h \ |
146 | loopcontrol.h \ | 144 | loopcontrol.h \ |
147 | mediaplayer.h \ | 145 | mediaplayer.h \ |
148 | $(OPIEDIR)/include/qpe/qlibrary.h \ | 146 | $(OPIEDIR)/include/qpe/qlibrary.h \ |
149 | $(OPIEDIR)/include/qpe/qcom.h \ | 147 | $(OPIEDIR)/include/qpe/qcom.h \ |
150 | $(OPIEDIR)/include/qpe/quuid.h \ | 148 | $(OPIEDIR)/include/qpe/quuid.h |
151 | mediaplayerplugininterface.h | ||
152 | 149 | ||
153 | loopcontrol.o: loopcontrol.cpp \ | 150 | loopcontrol.o: loopcontrol.cpp \ |
154 | $(OPIEDIR)/include/qpe/qpeapplication.h \ | 151 | $(OPIEDIR)/include/qpe/qpeapplication.h \ |
155 | $(OPIEDIR)/include/qpedecoration_qws.h \ | 152 | $(OPIEDIR)/include/qpe/qcopenvelope_qws.h \ |
156 | $(OPIEDIR)/include/timestring.h \ | ||
157 | loopcontrol.h \ | 153 | loopcontrol.h \ |
158 | videowidget.h \ | 154 | videowidget.h \ |
159 | audiodevice.h \ | 155 | audiodevice.h \ |
160 | mediaplayerplugininterface.h \ | 156 | mediaplayerplugininterface.h \ |
161 | $(OPIEDIR)/include/qpe/qcom.h \ | 157 | $(OPIEDIR)/include/qpe/qcom.h \ |
162 | $(OPIEDIR)/include/qpe/quuid.h \ | 158 | $(OPIEDIR)/include/qpe/quuid.h \ |
163 | mediaplayerstate.h | 159 | mediaplayerstate.h |
164 | 160 | ||
165 | playlistselection.o: playlistselection.cpp \ | 161 | playlistselection.o: playlistselection.cpp \ |
166 | $(OPIEDIR)/include/qpe/applnk.h \ | 162 | $(OPIEDIR)/include/qpe/applnk.h \ |
167 | $(OPIEDIR)/include/qpe/resource.h \ | 163 | $(OPIEDIR)/include/qpe/resource.h \ |
168 | playlistselection.h | 164 | playlistselection.h |
169 | 165 | ||
170 | mediaplayerstate.o: mediaplayerstate.cpp \ | 166 | mediaplayerstate.o: mediaplayerstate.cpp \ |
171 | $(OPIEDIR)/include/qpe/qpeapplication.h \ | 167 | $(OPIEDIR)/include/qpe/qpeapplication.h \ |
172 | $(OPIEDIR)/include/qpedecoration_qws.h \ | ||
173 | $(OPIEDIR)/include/timestring.h \ | ||
174 | $(OPIEDIR)/include/qpe/qlibrary.h \ | 168 | $(OPIEDIR)/include/qpe/qlibrary.h \ |
175 | $(OPIEDIR)/include/qpe/qcom.h \ | 169 | $(OPIEDIR)/include/qpe/qcom.h \ |
176 | $(OPIEDIR)/include/qpe/quuid.h \ | 170 | $(OPIEDIR)/include/qpe/quuid.h \ |
177 | $(OPIEDIR)/include/qpe/config.h \ | 171 | $(OPIEDIR)/include/qpe/config.h \ |
178 | mediaplayerplugininterface.h \ | ||
179 | mediaplayerstate.h \ | 172 | mediaplayerstate.h \ |
180 | libmad/libmadpluginimpl.h \ | 173 | libmad/libmadpluginimpl.h \ |
181 | libmpeg3/libmpeg3pluginimpl.h \ | 174 | libmpeg3/libmpeg3pluginimpl.h \ |
182 | wavplugin/wavpluginimpl.h | 175 | wavplugin/wavpluginimpl.h |
183 | 176 | ||
184 | videowidget.o: videowidget.cpp \ | 177 | videowidget.o: videowidget.cpp \ |
185 | $(OPIEDIR)/include/qpe/resource.h \ | 178 | $(OPIEDIR)/include/qpe/resource.h \ |
186 | mediaplayerplugininterface.h \ | ||
187 | $(OPIEDIR)/include/qpe/qcom.h \ | ||
188 | $(OPIEDIR)/include/qpe/quuid.h \ | ||
189 | videowidget.h \ | 179 | videowidget.h \ |
190 | mediaplayerstate.h | 180 | mediaplayerstate.h |
191 | 181 | ||
192 | audiowidget.o: audiowidget.cpp \ | 182 | audiowidget.o: audiowidget.cpp \ |
193 | $(OPIEDIR)/include/qpe/resource.h \ | 183 | $(OPIEDIR)/include/qpe/resource.h \ |
194 | audiowidget.h \ | 184 | audiowidget.h \ |
195 | mediaplayerstate.h | 185 | mediaplayerstate.h |
196 | 186 | ||
197 | playlistwidget.o: playlistwidget.cpp \ | 187 | playlistwidget.o: playlistwidget.cpp \ |
198 | $(OPIEDIR)/include/qpe/qpemenubar.h \ | 188 | $(OPIEDIR)/include/qpe/qpemenubar.h \ |
199 | $(OPIEDIR)/include/qpe/qpetoolbar.h \ | 189 | $(OPIEDIR)/include/qpe/qpetoolbar.h \ |
200 | $(OPIEDIR)/include/qpe/fileselector.h \ | 190 | $(OPIEDIR)/include/qpe/fileselector.h \ |
201 | $(OPIEDIR)/include/filemanager.h \ | ||
202 | $(OPIEDIR)/include/applnk.h \ | ||
203 | $(OPIEDIR)/include/qpe/qpeapplication.h \ | ||
204 | $(OPIEDIR)/include/qpedecoration_qws.h \ | ||
205 | $(OPIEDIR)/include/timestring.h \ | ||
206 | $(OPIEDIR)/include/qpe/applnk.h \ | 191 | $(OPIEDIR)/include/qpe/applnk.h \ |
207 | $(OPIEDIR)/include/qpe/config.h \ | 192 | $(OPIEDIR)/include/qpe/config.h \ |
208 | $(OPIEDIR)/include/qpe/global.h \ | 193 | $(OPIEDIR)/include/qpe/global.h \ |
209 | $(OPIEDIR)/include/qpe/resource.h \ | 194 | $(OPIEDIR)/include/qpe/resource.h \ |
210 | playlistselection.h \ | 195 | playlistselection.h \ |
211 | playlistwidget.h \ | 196 | playlistwidget.h \ |
212 | mediaplayerstate.h | 197 | mediaplayerstate.h |
213 | 198 | ||
214 | mediaplayer.o: mediaplayer.cpp \ | 199 | mediaplayer.o: mediaplayer.cpp \ |
215 | $(OPIEDIR)/include/qpe/qpeapplication.h \ | 200 | $(OPIEDIR)/include/qpe/qpeapplication.h \ |
216 | $(OPIEDIR)/include/qpedecoration_qws.h \ | ||
217 | $(OPIEDIR)/include/timestring.h \ | ||
218 | $(OPIEDIR)/include/qpe/qlibrary.h \ | 201 | $(OPIEDIR)/include/qpe/qlibrary.h \ |
219 | $(OPIEDIR)/include/qpe/qcom.h \ | 202 | $(OPIEDIR)/include/qpe/qcom.h \ |
220 | $(OPIEDIR)/include/qpe/quuid.h \ | 203 | $(OPIEDIR)/include/qpe/quuid.h \ |
221 | $(OPIEDIR)/include/qpe/resource.h \ | 204 | $(OPIEDIR)/include/qpe/resource.h \ |
222 | $(OPIEDIR)/include/qpe/config.h \ | 205 | $(OPIEDIR)/include/qpe/config.h \ |
223 | mediaplayer.h \ | 206 | mediaplayer.h \ |
224 | mediaplayerplugininterface.h \ | ||
225 | playlistwidget.h \ | 207 | playlistwidget.h \ |
226 | $(OPIEDIR)/include/qpe/applnk.h \ | 208 | $(OPIEDIR)/include/qpe/applnk.h \ |
227 | audiowidget.h \ | 209 | audiowidget.h \ |
228 | loopcontrol.h \ | 210 | loopcontrol.h \ |
229 | audiodevice.h \ | 211 | audiodevice.h \ |
230 | mediaplayerstate.h | 212 | mediaplayerstate.h |
231 | 213 | ||
232 | audiodevice.o: audiodevice.cpp \ | 214 | audiodevice.o: audiodevice.cpp \ |
233 | $(OPIEDIR)/include/qpe/qpeapplication.h \ | 215 | $(OPIEDIR)/include/qpe/qpeapplication.h \ |
234 | $(OPIEDIR)/include/qpedecoration_qws.h \ | ||
235 | $(OPIEDIR)/include/timestring.h \ | ||
236 | $(OPIEDIR)/include/qpe/config.h \ | 216 | $(OPIEDIR)/include/qpe/config.h \ |
237 | audiodevice.h | 217 | audiodevice.h \ |
218 | $(OPIEDIR)/include/qpe/qcopenvelope_qws.h | ||
238 | 219 | ||
239 | moc_loopcontrol.o: moc_loopcontrol.cpp \ | 220 | moc_loopcontrol.o: moc_loopcontrol.cpp \ |
240 | loopcontrol.h | 221 | loopcontrol.h |
241 | 222 | ||
242 | moc_playlistselection.o: moc_playlistselection.cpp \ | 223 | moc_playlistselection.o: moc_playlistselection.cpp \ |
243 | playlistselection.h \ | 224 | playlistselection.h \ |
244 | $(OPIEDIR)/include/qpe/applnk.h | 225 | $(OPIEDIR)/include/qpe/applnk.h |
245 | 226 | ||
246 | moc_mediaplayerstate.o: moc_mediaplayerstate.cpp \ | 227 | moc_mediaplayerstate.o: moc_mediaplayerstate.cpp \ |
247 | mediaplayerstate.h | 228 | mediaplayerstate.h |
248 | 229 | ||
249 | moc_videowidget.o: moc_videowidget.cpp \ | 230 | moc_videowidget.o: moc_videowidget.cpp \ |
250 | videowidget.h | 231 | videowidget.h |
251 | 232 | ||
252 | moc_audiowidget.o: moc_audiowidget.cpp \ | 233 | moc_audiowidget.o: moc_audiowidget.cpp \ |
253 | audiowidget.h | 234 | audiowidget.h |
254 | 235 | ||
255 | moc_playlistwidget.o: moc_playlistwidget.cpp \ | 236 | moc_playlistwidget.o: moc_playlistwidget.cpp \ |
256 | playlistwidget.h \ | 237 | playlistwidget.h \ |
257 | $(OPIEDIR)/include/qpe/applnk.h | 238 | $(OPIEDIR)/include/qpe/applnk.h |
258 | 239 | ||
259 | moc_mediaplayer.o: moc_mediaplayer.cpp \ | 240 | moc_mediaplayer.o: moc_mediaplayer.cpp \ |
260 | mediaplayer.h \ | 241 | mediaplayer.h \ |
261 | $(OPIEDIR)/include/qpe/qlibrary.h \ | 242 | $(OPIEDIR)/include/qpe/qlibrary.h \ |
262 | $(OPIEDIR)/include/qpe/qcom.h \ | 243 | $(OPIEDIR)/include/qpe/qcom.h \ |
263 | $(OPIEDIR)/include/qpe/quuid.h \ | 244 | $(OPIEDIR)/include/qpe/quuid.h |
264 | mediaplayerplugininterface.h | ||
265 | 245 | ||
266 | moc_audiodevice.o: moc_audiodevice.cpp \ | 246 | moc_audiodevice.o: moc_audiodevice.cpp \ |
267 | audiodevice.h | 247 | audiodevice.h |
268 | 248 | ||
269 | moc_loopcontrol.cpp: loopcontrol.h | 249 | moc_loopcontrol.cpp: loopcontrol.h |
270 | $(MOC) loopcontrol.h -o moc_loopcontrol.cpp | 250 | $(MOC) loopcontrol.h -o moc_loopcontrol.cpp |
271 | 251 | ||
272 | moc_playlistselection.cpp: playlistselection.h | 252 | moc_playlistselection.cpp: playlistselection.h |
273 | $(MOC) playlistselection.h -o moc_playlistselection.cpp | 253 | $(MOC) playlistselection.h -o moc_playlistselection.cpp |
274 | 254 | ||
275 | moc_mediaplayerstate.cpp: mediaplayerstate.h | 255 | moc_mediaplayerstate.cpp: mediaplayerstate.h |
276 | $(MOC) mediaplayerstate.h -o moc_mediaplayerstate.cpp | 256 | $(MOC) mediaplayerstate.h -o moc_mediaplayerstate.cpp |
277 | 257 | ||
278 | moc_videowidget.cpp: videowidget.h | 258 | moc_videowidget.cpp: videowidget.h |
279 | $(MOC) videowidget.h -o moc_videowidget.cpp | 259 | $(MOC) videowidget.h -o moc_videowidget.cpp |
280 | 260 | ||
281 | moc_audiowidget.cpp: audiowidget.h | 261 | moc_audiowidget.cpp: audiowidget.h |
282 | $(MOC) audiowidget.h -o moc_audiowidget.cpp | 262 | $(MOC) audiowidget.h -o moc_audiowidget.cpp |
283 | 263 | ||
284 | moc_playlistwidget.cpp: playlistwidget.h | 264 | moc_playlistwidget.cpp: playlistwidget.h |
285 | $(MOC) playlistwidget.h -o moc_playlistwidget.cpp | 265 | $(MOC) playlistwidget.h -o moc_playlistwidget.cpp |
286 | 266 | ||
287 | moc_mediaplayer.cpp: mediaplayer.h | 267 | moc_mediaplayer.cpp: mediaplayer.h |
288 | $(MOC) mediaplayer.h -o moc_mediaplayer.cpp | 268 | $(MOC) mediaplayer.h -o moc_mediaplayer.cpp |
289 | 269 | ||
290 | moc_audiodevice.cpp: audiodevice.h | 270 | moc_audiodevice.cpp: audiodevice.h |
291 | $(MOC) audiodevice.h -o moc_audiodevice.cpp | 271 | $(MOC) audiodevice.h -o moc_audiodevice.cpp |
292 | 272 | ||
293 | 273 | ||
diff --git a/core/multimedia/opieplayer/audiodevice.cpp b/core/multimedia/opieplayer/audiodevice.cpp index 11fd9e8..7b3700a 100644 --- a/core/multimedia/opieplayer/audiodevice.cpp +++ b/core/multimedia/opieplayer/audiodevice.cpp | |||
@@ -1,56 +1,53 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | // L.J.Potter added better error code Fri 02-15-2002 14:37:47 | ||
21 | |||
22 | 20 | ||
23 | #include <stdlib.h> | 21 | #include <stdlib.h> |
24 | #include <stdio.h> | ||
25 | #include <qpe/qpeapplication.h> | 22 | #include <qpe/qpeapplication.h> |
26 | #include <qpe/config.h> | 23 | #include <qpe/config.h> |
27 | #include "audiodevice.h" | 24 | #include "audiodevice.h" |
28 | 25 | ||
29 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) | 26 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) |
30 | #include "qpe/qcopenvelope_qws.h" | 27 | #include "qpe/qcopenvelope_qws.h" |
31 | #endif | 28 | #endif |
32 | 29 | ||
33 | #ifdef Q_WS_WIN | 30 | #ifdef Q_WS_WIN |
34 | #include <windows.h> | 31 | #include <windows.h> |
35 | #include <mmsystem.h> | 32 | #include <mmsystem.h> |
36 | #include <mmreg.h> | 33 | #include <mmreg.h> |
37 | #endif | 34 | #endif |
38 | 35 | ||
39 | #if defined(Q_WS_X11) || defined(Q_WS_QWS) | 36 | #if defined(Q_WS_X11) || defined(Q_WS_QWS) |
40 | #include <fcntl.h> | 37 | #include <fcntl.h> |
41 | #include <sys/ioctl.h> | 38 | #include <sys/ioctl.h> |
42 | #include <sys/soundcard.h> | 39 | #include <sys/soundcard.h> |
43 | #include <sys/stat.h> | 40 | #include <sys/stat.h> |
44 | #include <sys/time.h> | 41 | #include <sys/time.h> |
45 | #include <sys/types.h> | 42 | #include <sys/types.h> |
46 | #include <unistd.h> | 43 | #include <unistd.h> |
47 | #endif | 44 | #endif |
48 | 45 | ||
49 | #if defined(Q_OS_WIN32) | 46 | #if defined(Q_OS_WIN32) |
50 | static const int expectedBytesPerMilliSecond = 2 * 2 * 44000 / 1000; | 47 | static const int expectedBytesPerMilliSecond = 2 * 2 * 44000 / 1000; |
51 | static const int timerResolutionMilliSeconds = 30; | 48 | static const int timerResolutionMilliSeconds = 30; |
52 | static const int sound_fragment_bytes = timerResolutionMilliSeconds * expectedBytesPerMilliSecond; | 49 | static const int sound_fragment_bytes = timerResolutionMilliSeconds * expectedBytesPerMilliSecond; |
53 | #else | 50 | #else |
54 | # if defined(QT_QWS_IPAQ) | 51 | # if defined(QT_QWS_IPAQ) |
55 | static const int sound_fragment_shift = 14; | 52 | static const int sound_fragment_shift = 14; |
56 | # else | 53 | # else |
@@ -80,292 +77,311 @@ public: | |||
80 | }; | 77 | }; |
81 | 78 | ||
82 | 79 | ||
83 | #ifdef Q_WS_QWS | 80 | #ifdef Q_WS_QWS |
84 | // This is for keeping the device open in-between playing files when | 81 | // This is for keeping the device open in-between playing files when |
85 | // the device makes clicks and it starts to drive you insane! :) | 82 | // the device makes clicks and it starts to drive you insane! :) |
86 | // Best to have the device not open when not using it though | 83 | // Best to have the device not open when not using it though |
87 | //#define KEEP_DEVICE_OPEN | 84 | //#define KEEP_DEVICE_OPEN |
88 | #endif | 85 | #endif |
89 | 86 | ||
90 | 87 | ||
91 | int AudioDevicePrivate::dspFd = 0; | 88 | int AudioDevicePrivate::dspFd = 0; |
92 | bool AudioDevicePrivate::muted = FALSE; | 89 | bool AudioDevicePrivate::muted = FALSE; |
93 | unsigned int AudioDevicePrivate::leftVolume = 0; | 90 | unsigned int AudioDevicePrivate::leftVolume = 0; |
94 | unsigned int AudioDevicePrivate::rightVolume = 0; | 91 | unsigned int AudioDevicePrivate::rightVolume = 0; |
95 | 92 | ||
96 | 93 | ||
97 | void AudioDevice::getVolume( unsigned int& leftVolume, unsigned int& rightVolume, bool &muted ) { | 94 | void AudioDevice::getVolume( unsigned int& leftVolume, unsigned int& rightVolume, bool &muted ) { |
98 | muted = AudioDevicePrivate::muted; | 95 | muted = AudioDevicePrivate::muted; |
99 | unsigned int volume; | 96 | unsigned int volume; |
100 | #ifdef Q_OS_WIN32 | 97 | #ifdef Q_OS_WIN32 |
101 | HWAVEOUT handle; | 98 | HWAVEOUT handle; |
102 | WAVEFORMATEX formatData; | 99 | WAVEFORMATEX formatData; |
103 | formatData.cbSize = sizeof(WAVEFORMATEX); | 100 | formatData.cbSize = sizeof(WAVEFORMATEX); |
104 | formatData.wFormatTag = WAVE_FORMAT_PCM; | 101 | formatData.wFormatTag = WAVE_FORMAT_PCM; |
105 | formatData.nAvgBytesPerSec = 4 * 44000; | 102 | formatData.nAvgBytesPerSec = 4 * 44000; |
106 | formatData.nBlockAlign = 4; | 103 | formatData.nBlockAlign = 4; |
107 | formatData.nChannels = 2; | 104 | formatData.nChannels = 2; |
108 | formatData.nSamplesPerSec = 44000; | 105 | formatData.nSamplesPerSec = 44000; |
109 | formatData.wBitsPerSample = 16; | 106 | formatData.wBitsPerSample = 16; |
110 | waveOutOpen(&handle, WAVE_MAPPER, &formatData, 0L, 0L, CALLBACK_NULL); | 107 | waveOutOpen(&handle, WAVE_MAPPER, &formatData, 0L, 0L, CALLBACK_NULL); |
111 | if ( waveOutGetVolume( handle, (LPDWORD)&volume ) ) | 108 | if ( waveOutGetVolume( handle, (LPDWORD)&volume ) ) |
112 | // qDebug( "get volume of audio device failed" ); | 109 | qDebug( "get volume of audio device failed" ); |
113 | waveOutClose( handle ); | 110 | waveOutClose( handle ); |
114 | leftVolume = volume & 0xFFFF; | 111 | leftVolume = volume & 0xFFFF; |
115 | rightVolume = volume >> 16; | 112 | rightVolume = volume >> 16; |
116 | #else | 113 | #else |
117 | int mixerHandle = open( "/dev/mixer", O_RDWR ); | 114 | int mixerHandle = open( "/dev/mixer", O_RDWR ); |
118 | if ( mixerHandle >= 0 ) { | 115 | if ( mixerHandle >= 0 ) { |
119 | if(ioctl( mixerHandle, MIXER_READ(0), &volume )==-1) | 116 | ioctl( mixerHandle, MIXER_READ(0), &volume ); |
120 | perror("ioctl(\"MIXER_READ\")"); | ||
121 | close( mixerHandle ); | 117 | close( mixerHandle ); |
122 | } else | 118 | } else |
123 | perror("open(\"/dev/mixer\")"); | 119 | qDebug( "get volume of audio device failed" ); |
124 | leftVolume = ((volume & 0x00FF) << 16) / 101; | 120 | leftVolume = ((volume & 0x00FF) << 16) / 101; |
125 | rightVolume = ((volume & 0xFF00) << 8) / 101; | 121 | rightVolume = ((volume & 0xFF00) << 8) / 101; |
126 | #endif | 122 | #endif |
127 | } | 123 | } |
128 | 124 | ||
129 | 125 | ||
130 | void AudioDevice::setVolume( unsigned int leftVolume, unsigned int rightVolume, bool muted ) { | 126 | void AudioDevice::setVolume( unsigned int leftVolume, unsigned int rightVolume, bool muted ) { |
131 | AudioDevicePrivate::muted = muted; | 127 | AudioDevicePrivate::muted = muted; |
132 | if ( muted ) { | 128 | if ( muted ) { |
133 | AudioDevicePrivate::leftVolume = leftVolume; | 129 | AudioDevicePrivate::leftVolume = leftVolume; |
134 | AudioDevicePrivate::rightVolume = rightVolume; | 130 | AudioDevicePrivate::rightVolume = rightVolume; |
135 | leftVolume = 0; | 131 | leftVolume = 0; |
136 | rightVolume = 0; | 132 | rightVolume = 0; |
137 | } else { | 133 | } else { |
138 | leftVolume = ( (int) leftVolume < 0 ) ? 0 : (( leftVolume > 0xFFFF ) ? 0xFFFF : leftVolume ); | 134 | leftVolume = ( (int) leftVolume < 0 ) ? 0 : (( leftVolume > 0xFFFF ) ? 0xFFFF : leftVolume ); |
139 | rightVolume = ( (int)rightVolume < 0 ) ? 0 : (( rightVolume > 0xFFFF ) ? 0xFFFF : rightVolume ); | 135 | rightVolume = ( (int)rightVolume < 0 ) ? 0 : (( rightVolume > 0xFFFF ) ? 0xFFFF : rightVolume ); |
140 | } | 136 | } |
141 | #ifdef Q_OS_WIN32 | 137 | #ifdef Q_OS_WIN32 |
142 | HWAVEOUT handle; | 138 | HWAVEOUT handle; |
143 | WAVEFORMATEX formatData; | 139 | WAVEFORMATEX formatData; |
144 | formatData.cbSize = sizeof(WAVEFORMATEX); | 140 | formatData.cbSize = sizeof(WAVEFORMATEX); |
145 | formatData.wFormatTag = WAVE_FORMAT_PCM; | 141 | formatData.wFormatTag = WAVE_FORMAT_PCM; |
146 | formatData.nAvgBytesPerSec = 4 * 44000; | 142 | formatData.nAvgBytesPerSec = 4 * 44000; |
147 | formatData.nBlockAlign = 4; | 143 | formatData.nBlockAlign = 4; |
148 | formatData.nChannels = 2; | 144 | formatData.nChannels = 2; |
149 | formatData.nSamplesPerSec = 44000; | 145 | formatData.nSamplesPerSec = 44000; |
150 | formatData.wBitsPerSample = 16; | 146 | formatData.wBitsPerSample = 16; |
151 | waveOutOpen(&handle, WAVE_MAPPER, &formatData, 0L, 0L, CALLBACK_NULL); | 147 | waveOutOpen(&handle, WAVE_MAPPER, &formatData, 0L, 0L, CALLBACK_NULL); |
152 | unsigned int volume = (rightVolume << 16) | leftVolume; | 148 | unsigned int volume = (rightVolume << 16) | leftVolume; |
153 | if ( waveOutSetVolume( handle, volume ) ) | 149 | if ( waveOutSetVolume( handle, volume ) ) |
154 | // qDebug( "set volume of audio device failed" ); | 150 | qDebug( "set volume of audio device failed" ); |
155 | waveOutClose( handle ); | 151 | waveOutClose( handle ); |
156 | #else | 152 | #else |
157 | // Volume can be from 0 to 100 which is 101 distinct values | 153 | // Volume can be from 0 to 100 which is 101 distinct values |
158 | unsigned int rV = (rightVolume * 101) >> 16; | 154 | unsigned int rV = (rightVolume * 101) >> 16; |
159 | 155 | ||
160 | # if 0 | 156 | # if 0 |
161 | unsigned int lV = (leftVolume * 101) >> 16; | 157 | unsigned int lV = (leftVolume * 101) >> 16; |
162 | unsigned int volume = ((rV << 8) & 0xFF00) | (lV & 0x00FF); | 158 | unsigned int volume = ((rV << 8) & 0xFF00) | (lV & 0x00FF); |
163 | int mixerHandle = 0; | 159 | int mixerHandle = 0; |
164 | if ( ( mixerHandle = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 160 | if ( ( mixerHandle = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
165 | if(ioctl( mixerHandle, MIXER_WRITE(0), &volume ) ==-1) | 161 | ioctl( mixerHandle, MIXER_WRITE(0), &volume ); |
166 | perror("ioctl(\"MIXER_WRITE\")"); | ||
167 | close( mixerHandle ); | 162 | close( mixerHandle ); |
168 | } else | 163 | } else |
169 | perror("open(\"/dev/mixer\")"); | 164 | qDebug( "set volume of audio device failed" ); |
170 | |||
171 | # else | 165 | # else |
172 | // This is the way this has to be done now I guess, doesn't allow for | 166 | // This is the way this has to be done now I guess, doesn't allow for |
173 | // independant right and left channel setting, or setting for different outputs | 167 | // independant right and left channel setting, or setting for different outputs |
174 | Config cfg("Sound"); | 168 | Config cfg("Sound"); |
175 | cfg.setGroup("System"); | 169 | cfg.setGroup("System"); |
176 | cfg.writeEntry("Volume",(int)rV); | 170 | cfg.writeEntry("Volume",(int)rV); |
177 | # endif | 171 | # endif |
178 | 172 | ||
179 | #endif | 173 | #endif |
180 | // qDebug( "setting volume to: 0x%x", volume ); | 174 | // qDebug( "setting volume to: 0x%x", volume ); |
181 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) | 175 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) |
182 | // Send notification that the volume has changed | 176 | // Send notification that the volume has changed |
183 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << muted; | 177 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << muted; |
184 | #endif | 178 | #endif |
185 | } | 179 | } |
186 | 180 | ||
187 | 181 | ||
188 | 182 | ||
189 | 183 | ||
190 | AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) { | 184 | AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) { |
191 | d = new AudioDevicePrivate; | 185 | d = new AudioDevicePrivate; |
192 | d->frequency = f; | 186 | d->frequency = f; |
193 | d->channels = chs; | 187 | d->channels = chs; |
194 | d->bytesPerSample = bps; | 188 | d->bytesPerSample = bps; |
195 | // qDebug("%d",bps); | ||
196 | int format=0; | ||
197 | if( bps == 8) format = AFMT_U8; | ||
198 | else if( bps <= 0) format = AFMT_S16_LE; | ||
199 | else format = AFMT_S16_LE; | ||
200 | 189 | ||
201 | // qDebug("AD- freq %d, channels %d, b/sample %d, bitrate %d",f,chs,bps,format); | ||
202 | connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( volumeChanged(bool) ) ); | 190 | connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( volumeChanged(bool) ) ); |
203 | 191 | ||
192 | #ifdef Q_OS_WIN32 | ||
193 | UINT result; | ||
194 | WAVEFORMATEX formatData; | ||
195 | formatData.cbSize = sizeof(WAVEFORMATEX); | ||
196 | /* | ||
197 | // Other possible formats windows supports | ||
198 | formatData.wFormatTag = WAVE_FORMAT_MPEG; | ||
199 | formatData.wFormatTag = WAVE_FORMAT_MPEGLAYER3; | ||
200 | formatData.wFormatTag = WAVE_FORMAT_ADPCM; | ||
201 | */ | ||
202 | formatData.wFormatTag = WAVE_FORMAT_PCM; | ||
203 | formatData.nAvgBytesPerSec = bps * chs * f; | ||
204 | formatData.nBlockAlign = bps * chs; | ||
205 | formatData.nChannels = chs; | ||
206 | formatData.nSamplesPerSec = f; | ||
207 | formatData.wBitsPerSample = bps * 8; | ||
208 | // Open a waveform device for output | ||
209 | if (result = waveOutOpen((LPHWAVEOUT)&d->handle, WAVE_MAPPER, &formatData, 0L, 0L, CALLBACK_NULL)) { | ||
210 | QString errorMsg = "error opening audio device.\nReason: %i - "; | ||
211 | switch (result) { | ||
212 | case MMSYSERR_ALLOCATED:errorMsg += "Specified resource is already allocated."; break; | ||
213 | case MMSYSERR_BADDEVICEID:errorMsg += "Specified device identifier is out of range."; break; | ||
214 | case MMSYSERR_NODRIVER:errorMsg += "No device driver is present."; break; | ||
215 | case MMSYSERR_NOMEM:errorMsg += "Unable to allocate or lock memory."; break; | ||
216 | case WAVERR_BADFORMAT:errorMsg += "Attempted to open with an unsupported waveform-audio format."; break; | ||
217 | case WAVERR_SYNC: errorMsg += "The device is synchronous but waveOutOpen was called without using the WAVE_ALLOWSYNC flag."; break; | ||
218 | default: errorMsg += "Undefined error"; break; | ||
219 | } | ||
220 | qDebug( errorMsg, result ); | ||
221 | } | ||
222 | |||
223 | d->bufferSize = sound_fragment_bytes; | ||
224 | #else | ||
204 | 225 | ||
205 | int fragments = 0x10000 * 8 + sound_fragment_shift; | 226 | int fragments = 0x10000 * 8 + sound_fragment_shift; |
227 | int format = AFMT_S16_LE; | ||
206 | int capabilities = 0; | 228 | int capabilities = 0; |
207 | 229 | ||
208 | #ifdef KEEP_DEVICE_OPEN | 230 | #ifdef KEEP_DEVICE_OPEN |
209 | if ( AudioDevicePrivate::dspFd == 0 ) { | 231 | if ( AudioDevicePrivate::dspFd == 0 ) { |
210 | #endif | 232 | #endif |
211 | if ( ( d->handle = ::open( "/dev/dsp", O_WRONLY ) ) < 0 ) { | 233 | if ( ( d->handle = ::open( "/dev/dsp", O_WRONLY ) ) < 0 ) { |
212 | perror("open(\"/dev/dsp\") sending to /dev/null instead"); | 234 | qDebug( "error opening audio device /dev/dsp, sending data to /dev/null instead" ); |
213 | d->handle = ::open( "/dev/null", O_WRONLY ); | 235 | d->handle = ::open( "/dev/null", O_WRONLY ); |
214 | } | 236 | } |
215 | #ifdef KEEP_DEVICE_OPEN | 237 | #ifdef KEEP_DEVICE_OPEN |
216 | AudioDevicePrivate::dspFd = d->handle; | 238 | AudioDevicePrivate::dspFd = d->handle; |
217 | } else { | 239 | } else { |
218 | d->handle = AudioDevicePrivate::dspFd; | 240 | d->handle = AudioDevicePrivate::dspFd; |
219 | } | 241 | } |
220 | #endif | 242 | #endif |
221 | 243 | ||
222 | if(ioctl( d->handle, SNDCTL_DSP_GETCAPS, &capabilities )==-1) | 244 | ioctl( d->handle, SNDCTL_DSP_GETCAPS, &capabilities ); |
223 | perror("ioctl(\"SNDCTL_DSP_GETCAPS\")"); | 245 | ioctl( d->handle, SNDCTL_DSP_SETFRAGMENT, &fragments ); |
224 | if(ioctl( d->handle, SNDCTL_DSP_SETFRAGMENT, &fragments )==-1) | 246 | ioctl( d->handle, SNDCTL_DSP_SETFMT, &format ); |
225 | perror("ioctl(\"SNDCTL_DSP_SETFRAGMENT\")"); | 247 | ioctl( d->handle, SNDCTL_DSP_SPEED, &d->frequency ); |
226 | if(ioctl( d->handle, SNDCTL_DSP_SETFMT, & format )==-1) | ||
227 | perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); | ||
228 | qDebug("freq %d", d->frequency); | ||
229 | if(ioctl( d->handle, SNDCTL_DSP_SPEED, &d->frequency )==-1) | ||
230 | perror("ioctl(\"SNDCTL_DSP_SPEED\")"); | ||
231 | qDebug("channels %d",d->channels); | ||
232 | if ( ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels ) == -1 ) { | 248 | if ( ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels ) == -1 ) { |
233 | d->channels = ( d->channels == 1 ) ? 2 : d->channels; | 249 | d->channels = ( d->channels == 1 ) ? 2 : d->channels; |
234 | if(ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels )==-1) | 250 | ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels ); |
235 | perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); | ||
236 | } | 251 | } |
237 | 252 | ||
238 | d->bufferSize = sound_fragment_bytes; | 253 | d->bufferSize = sound_fragment_bytes; |
239 | d->unwrittenBuffer = new char[d->bufferSize]; | 254 | d->unwrittenBuffer = new char[d->bufferSize]; |
240 | d->unwritten = 0; | 255 | d->unwritten = 0; |
241 | d->can_GETOSPACE = TRUE; // until we find otherwise | 256 | d->can_GETOSPACE = TRUE; // until we find otherwise |
242 | 257 | ||
243 | //if ( chs != d->channels ) qDebug( "Wanted %d, got %d channels", chs, d->channels ); | 258 | //if ( chs != d->channels ) qDebug( "Wanted %d, got %d channels", chs, d->channels ); |
244 | //if ( f != d->frequency ) qDebug( "wanted %dHz, got %dHz", f, d->frequency ); | 259 | //if ( f != d->frequency ) qDebug( "wanted %dHz, got %dHz", f, d->frequency ); |
245 | //if ( capabilities & DSP_CAP_BATCH ) qDebug( "Sound card has local buffer" ); | 260 | //if ( capabilities & DSP_CAP_BATCH ) qDebug( "Sound card has local buffer" ); |
246 | //if ( capabilities & DSP_CAP_REALTIME )qDebug( "Sound card has realtime sync" ); | 261 | //if ( capabilities & DSP_CAP_REALTIME )qDebug( "Sound card has realtime sync" ); |
247 | //if ( capabilities & DSP_CAP_TRIGGER ) qDebug( "Sound card has precise trigger" ); | 262 | //if ( capabilities & DSP_CAP_TRIGGER ) qDebug( "Sound card has precise trigger" ); |
248 | //if ( capabilities & DSP_CAP_MMAP ) qDebug( "Sound card can mmap" ); | 263 | //if ( capabilities & DSP_CAP_MMAP ) qDebug( "Sound card can mmap" ); |
264 | #endif | ||
249 | } | 265 | } |
250 | 266 | ||
251 | 267 | ||
252 | AudioDevice::~AudioDevice() { | 268 | AudioDevice::~AudioDevice() { |
253 | #ifdef Q_OS_WIN32 | 269 | #ifdef Q_OS_WIN32 |
254 | waveOutClose( (HWAVEOUT)d->handle ); | 270 | waveOutClose( (HWAVEOUT)d->handle ); |
255 | #else | 271 | #else |
256 | # ifndef KEEP_DEVICE_OPEN | 272 | # ifndef KEEP_DEVICE_OPEN |
257 | close( d->handle ); // Now it should be safe to shut the handle | 273 | close( d->handle ); // Now it should be safe to shut the handle |
258 | # endif | 274 | # endif |
259 | delete d->unwrittenBuffer; | 275 | delete d->unwrittenBuffer; |
260 | delete d; | 276 | delete d; |
261 | #endif | 277 | #endif |
262 | } | 278 | } |
263 | 279 | ||
264 | 280 | ||
265 | void AudioDevice::volumeChanged( bool muted ) | 281 | void AudioDevice::volumeChanged( bool muted ) |
266 | { | 282 | { |
267 | AudioDevicePrivate::muted = muted; | 283 | AudioDevicePrivate::muted = muted; |
268 | } | 284 | } |
269 | 285 | ||
270 | 286 | ||
271 | void AudioDevice::write( char *buffer, unsigned int length ) | 287 | void AudioDevice::write( char *buffer, unsigned int length ) |
272 | { | 288 | { |
273 | #ifdef Q_OS_WIN32 | 289 | #ifdef Q_OS_WIN32 |
274 | // returns immediately and (to be implemented) emits completedIO() when finished writing | 290 | // returns immediately and (to be implemented) emits completedIO() when finished writing |
275 | WAVEHDR *lpWaveHdr = (WAVEHDR *)malloc( sizeof(WAVEHDR) ); | 291 | WAVEHDR *lpWaveHdr = (WAVEHDR *)malloc( sizeof(WAVEHDR) ); |
276 | // maybe the buffer should be copied so that this fool proof, but its a performance hit | 292 | // maybe the buffer should be copied so that this fool proof, but its a performance hit |
277 | lpWaveHdr->lpData = buffer; | 293 | lpWaveHdr->lpData = buffer; |
278 | lpWaveHdr->dwBufferLength = length; | 294 | lpWaveHdr->dwBufferLength = length; |
279 | lpWaveHdr->dwFlags = 0L; | 295 | lpWaveHdr->dwFlags = 0L; |
280 | lpWaveHdr->dwLoops = 0L; | 296 | lpWaveHdr->dwLoops = 0L; |
281 | waveOutPrepareHeader( (HWAVEOUT)d->handle, lpWaveHdr, sizeof(WAVEHDR) ); | 297 | waveOutPrepareHeader( (HWAVEOUT)d->handle, lpWaveHdr, sizeof(WAVEHDR) ); |
282 | // waveOutWrite returns immediately. the data is sent in the background. | 298 | // waveOutWrite returns immediately. the data is sent in the background. |
283 | if ( waveOutWrite( (HWAVEOUT)d->handle, lpWaveHdr, sizeof(WAVEHDR) ) ) | 299 | if ( waveOutWrite( (HWAVEOUT)d->handle, lpWaveHdr, sizeof(WAVEHDR) ) ) |
284 | qDebug( "failed to write block to audio device" ); | 300 | qDebug( "failed to write block to audio device" ); |
285 | // emit completedIO(); | 301 | // emit completedIO(); |
286 | #else | 302 | #else |
287 | int t = ::write( d->handle, buffer, length ); | 303 | int t = ::write( d->handle, buffer, length ); |
288 | if ( t<0 ) t = 0; | 304 | if ( t<0 ) t = 0; |
289 | if ( t != (int)length) { | 305 | if ( t != (int)length) { |
290 | qDebug("Ahhh!! memcpys 1"); | 306 | qDebug("Ahhh!! memcpys 1"); |
291 | memcpy(d->unwrittenBuffer,buffer+t,length-t); | 307 | memcpy(d->unwrittenBuffer,buffer+t,length-t); |
292 | d->unwritten = length-t; | 308 | d->unwritten = length-t; |
293 | } | 309 | } |
294 | #endif | 310 | #endif |
295 | } | 311 | } |
296 | 312 | ||
297 | 313 | ||
298 | unsigned int AudioDevice::channels() const | 314 | unsigned int AudioDevice::channels() const |
299 | { | 315 | { |
300 | return d->channels; | 316 | return d->channels; |
301 | } | 317 | } |
302 | 318 | ||
303 | 319 | ||
304 | unsigned int AudioDevice::frequency() const | 320 | unsigned int AudioDevice::frequency() const |
305 | { | 321 | { |
306 | return d->frequency; | 322 | return d->frequency; |
307 | } | 323 | } |
308 | 324 | ||
309 | 325 | ||
310 | unsigned int AudioDevice::bytesPerSample() const | 326 | unsigned int AudioDevice::bytesPerSample() const |
311 | { | 327 | { |
312 | return d->bytesPerSample; | 328 | return d->bytesPerSample; |
313 | } | 329 | } |
314 | 330 | ||
315 | 331 | ||
316 | unsigned int AudioDevice::bufferSize() const | 332 | unsigned int AudioDevice::bufferSize() const |
317 | { | 333 | { |
318 | return d->bufferSize; | 334 | return d->bufferSize; |
319 | } | 335 | } |
320 | 336 | ||
321 | unsigned int AudioDevice::canWrite() const | 337 | unsigned int AudioDevice::canWrite() const |
322 | { | 338 | { |
323 | #ifdef Q_OS_WIN32 | 339 | #ifdef Q_OS_WIN32 |
324 | return bufferSize(); // Any better? | 340 | return bufferSize(); // Any better? |
325 | #else | 341 | #else |
326 | audio_buf_info info; | 342 | audio_buf_info info; |
327 | if ( d->can_GETOSPACE && ioctl(d->handle,SNDCTL_DSP_GETOSPACE,&info) ) { | 343 | if ( d->can_GETOSPACE && ioctl(d->handle,SNDCTL_DSP_GETOSPACE,&info) ) { |
328 | d->can_GETOSPACE = FALSE; | 344 | d->can_GETOSPACE = FALSE; |
329 | fcntl( d->handle, F_SETFL, O_NONBLOCK ); | 345 | fcntl( d->handle, F_SETFL, O_NONBLOCK ); |
330 | } | 346 | } |
331 | if ( d->can_GETOSPACE ) { | 347 | if ( d->can_GETOSPACE ) { |
332 | int t = info.fragments * sound_fragment_bytes; | 348 | int t = info.fragments * sound_fragment_bytes; |
333 | return QMIN(t,(int)bufferSize()); | 349 | return QMIN(t,(int)bufferSize()); |
334 | } else { | 350 | } else { |
335 | if ( d->unwritten ) { | 351 | if ( d->unwritten ) { |
336 | int t = ::write( d->handle, d->unwrittenBuffer, d->unwritten ); | 352 | int t = ::write( d->handle, d->unwrittenBuffer, d->unwritten ); |
337 | if ( t<0 ) t = 0; | 353 | if ( t<0 ) t = 0; |
338 | if ( (unsigned)t!=d->unwritten ) { | 354 | if ( (unsigned)t!=d->unwritten ) { |
339 | memcpy(d->unwrittenBuffer,d->unwrittenBuffer+t,d->unwritten-t); | 355 | memcpy(d->unwrittenBuffer,d->unwrittenBuffer+t,d->unwritten-t); |
340 | d->unwritten -= t; | 356 | d->unwritten -= t; |
341 | } else { | 357 | } else { |
342 | d->unwritten = 0; | 358 | d->unwritten = 0; |
343 | } | 359 | } |
344 | } | 360 | } |
345 | if ( d->unwritten ) | 361 | if ( d->unwritten ) |
346 | return 0; | 362 | return 0; |
347 | else | 363 | else |
348 | return d->bufferSize; | 364 | return d->bufferSize; |
349 | } | 365 | } |
350 | #endif | 366 | #endif |
351 | } | 367 | } |
352 | 368 | ||
353 | 369 | ||
354 | int AudioDevice::bytesWritten() { | 370 | int AudioDevice::bytesWritten() { |
355 | #ifdef Q_OS_WIN32 | 371 | #ifdef Q_OS_WIN32 |
356 | MMTIME pmmt = { TIME_BYTES, 0 }; | 372 | MMTIME pmmt = { TIME_BYTES, 0 }; |
357 | if ( ( waveOutGetPosition( (HWAVEOUT)d->handle, &pmmt, sizeof(MMTIME) ) != MMSYSERR_NOERROR ) || ( pmmt.wType != TIME_BYTES ) ) { | 373 | if ( ( waveOutGetPosition( (HWAVEOUT)d->handle, &pmmt, sizeof(MMTIME) ) != MMSYSERR_NOERROR ) || ( pmmt.wType != TIME_BYTES ) ) { |
358 | qDebug( "failed to get audio device position" ); | 374 | qDebug( "failed to get audio device position" ); |
359 | return -1; | 375 | return -1; |
360 | } | 376 | } |
361 | return pmmt.u.cb; | 377 | return pmmt.u.cb; |
362 | #else | 378 | #else |
363 | int buffered = 0; | 379 | int buffered = 0; |
364 | if ( ioctl( d->handle, SNDCTL_DSP_GETODELAY, &buffered ) ) { | 380 | if ( ioctl( d->handle, SNDCTL_DSP_GETODELAY, &buffered ) ) { |
365 | qDebug( "failed to get audio device position" ); | 381 | qDebug( "failed to get audio device position" ); |
366 | return -1; | 382 | return -1; |
367 | } | 383 | } |
368 | return buffered; | 384 | return buffered; |
369 | #endif | 385 | #endif |
370 | } | 386 | } |
371 | 387 | ||
diff --git a/core/multimedia/opieplayer/audiodevice.h b/core/multimedia/opieplayer/audiodevice.h index dcd79fe..ec70788 100644 --- a/core/multimedia/opieplayer/audiodevice.h +++ b/core/multimedia/opieplayer/audiodevice.h | |||
@@ -1,69 +1,64 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | // L.J.Potter added changes Fri 02-15-2002 | ||
21 | |||
22 | |||
23 | #ifndef AUDIODEVICE_H | 20 | #ifndef AUDIODEVICE_H |
24 | #define AUDIODEVICE_H | 21 | #define AUDIODEVICE_H |
25 | 22 | ||
26 | |||
27 | #include <qobject.h> | 23 | #include <qobject.h> |
28 | #include <sys/soundcard.h> | ||
29 | 24 | ||
30 | 25 | ||
31 | class AudioDevicePrivate; | 26 | class AudioDevicePrivate; |
32 | 27 | ||
33 | 28 | ||
34 | class AudioDevice : public QObject { | 29 | class AudioDevice : public QObject { |
35 | Q_OBJECT | 30 | Q_OBJECT |
36 | public: | 31 | public: |
37 | AudioDevice( unsigned int freq = 44000, unsigned int channels = 2, unsigned int bytesPerSample = AFMT_S16_LE ); | 32 | AudioDevice( unsigned int freq = 44000, unsigned int channels = 2, unsigned int bytesPerSample = 2 ); |
38 | ~AudioDevice(); | 33 | ~AudioDevice(); |
39 | 34 | ||
40 | unsigned int canWrite() const; | 35 | unsigned int canWrite() const; |
41 | void write( char *buffer, unsigned int length ); | 36 | void write( char *buffer, unsigned int length ); |
42 | int bytesWritten(); | 37 | int bytesWritten(); |
43 | 38 | ||
44 | unsigned int channels() const; | 39 | unsigned int channels() const; |
45 | unsigned int frequency() const; | 40 | unsigned int frequency() const; |
46 | unsigned int bytesPerSample() const; | 41 | unsigned int bytesPerSample() const; |
47 | unsigned int bufferSize() const; | 42 | unsigned int bufferSize() const; |
48 | 43 | ||
49 | // Each volume level is from 0 to 0xFFFF | 44 | // Each volume level is from 0 to 0xFFFF |
50 | static void getVolume( unsigned int& left, unsigned int& right, bool& muted ); | 45 | static void getVolume( unsigned int& left, unsigned int& right, bool& muted ); |
51 | static void setVolume( unsigned int left, unsigned int right, bool muted ); | 46 | static void setVolume( unsigned int left, unsigned int right, bool muted ); |
52 | 47 | ||
53 | static unsigned int leftVolume() { bool muted; unsigned int l, r; getVolume( l, r, muted ); return l; } | 48 | static unsigned int leftVolume() { bool muted; unsigned int l, r; getVolume( l, r, muted ); return l; } |
54 | static unsigned int rightVolume() { bool muted; unsigned int l, r; getVolume( l, r, muted ); return r; } | 49 | static unsigned int rightVolume() { bool muted; unsigned int l, r; getVolume( l, r, muted ); return r; } |
55 | static bool isMuted() { bool muted; unsigned int l, r; getVolume( l, r, muted ); return muted; } | 50 | static bool isMuted() { bool muted; unsigned int l, r; getVolume( l, r, muted ); return muted; } |
56 | 51 | ||
57 | static void increaseVolume() { setVolume( leftVolume() + 1968, rightVolume() + 1968, isMuted() ); } | 52 | static void increaseVolume() { setVolume( leftVolume() + 1968, rightVolume() + 1968, isMuted() ); } |
58 | static void decreaseVolume() { setVolume( leftVolume() - 1966, rightVolume() - 1966, isMuted() ); } | 53 | static void decreaseVolume() { setVolume( leftVolume() - 1966, rightVolume() - 1966, isMuted() ); } |
59 | 54 | ||
60 | public slots: | 55 | public slots: |
61 | // Convinence functions derived from above functions | 56 | // Convinence functions derived from above functions |
62 | void setVolume( unsigned int level ) { setVolume( level, level, isMuted() ); } | 57 | void setVolume( unsigned int level ) { setVolume( level, level, isMuted() ); } |
63 | void mute() { setVolume( leftVolume(), rightVolume(), TRUE ); } | 58 | void mute() { setVolume( leftVolume(), rightVolume(), TRUE ); } |
64 | void volumeChanged( bool muted ); | 59 | void volumeChanged( bool muted ); |
65 | 60 | ||
66 | signals: | 61 | signals: |
67 | void completedIO(); | 62 | void completedIO(); |
68 | 63 | ||
69 | private: | 64 | private: |
diff --git a/core/multimedia/opieplayer/audiowidget.cpp b/core/multimedia/opieplayer/audiowidget.cpp index 0d88591..1e0757f 100644 --- a/core/multimedia/opieplayer/audiowidget.cpp +++ b/core/multimedia/opieplayer/audiowidget.cpp | |||
@@ -1,277 +1,276 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include <qwidget.h> | 20 | #include <qwidget.h> |
21 | #include <qpixmap.h> | 21 | #include <qpixmap.h> |
22 | #include <qbutton.h> | 22 | #include <qbutton.h> |
23 | #include <qpainter.h> | 23 | #include <qpainter.h> |
24 | #include <qframe.h> | 24 | #include <qframe.h> |
25 | #include <qpe/resource.h> | 25 | #include <qpe/resource.h> |
26 | #include "audiowidget.h" | 26 | #include "audiowidget.h" |
27 | #include "mediaplayerstate.h" | 27 | #include "mediaplayerstate.h" |
28 | 28 | ||
29 | |||
30 | extern MediaPlayerState *mediaPlayerState; | 29 | extern MediaPlayerState *mediaPlayerState; |
31 | 30 | ||
32 | 31 | ||
33 | static const int xo = -2; // movable x offset | 32 | static const int xo = -2; // movable x offset |
34 | static const int yo = 22; // movable y offset | 33 | static const int yo = 22; // movable y offset |
35 | 34 | ||
36 | 35 | ||
37 | struct MediaButton { | 36 | struct MediaButton { |
38 | int xPos, yPos; | 37 | int xPos, yPos; |
39 | int color; | 38 | int color; |
40 | bool isToggle, isBig, isHeld, isDown; | 39 | bool isToggle, isBig, isHeld, isDown; |
41 | }; | 40 | }; |
42 | 41 | ||
43 | 42 | ||
44 | // Layout information for the audioButtons (and if it is a toggle button or not) | 43 | // Layout information for the audioButtons (and if it is a toggle button or not) |
45 | MediaButton audioButtons[] = { | 44 | MediaButton audioButtons[] = { |
46 | { 3*30-15+xo, 3*30-13+yo, 0, TRUE, TRUE, FALSE, FALSE }, // play | 45 | { 3*30-15+xo, 3*30-13+yo, 0, TRUE, TRUE, FALSE, FALSE }, // play |
47 | { 1*30+xo, 5*30+yo, 2, FALSE, FALSE, FALSE, FALSE }, // stop | 46 | { 1*30+xo, 5*30+yo, 2, FALSE, FALSE, FALSE, FALSE }, // stop |
48 | { 5*30+xo, 5*30+yo, 2, TRUE, FALSE, FALSE, FALSE }, // pause | 47 | { 5*30+xo, 5*30+yo, 2, TRUE, FALSE, FALSE, FALSE }, // pause |
49 | { 6*30-5+xo, 3*30+yo, 1, FALSE, FALSE, FALSE, FALSE }, // next | 48 | { 6*30-5+xo, 3*30+yo, 1, FALSE, FALSE, FALSE, FALSE }, // next |
50 | { 0*30+5+xo, 3*30+yo, 1, FALSE, FALSE, FALSE, FALSE }, // previous | 49 | { 0*30+5+xo, 3*30+yo, 1, FALSE, FALSE, FALSE, FALSE }, // previous |
51 | { 3*30+xo, 0*30+5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume up | 50 | { 3*30+xo, 0*30+5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume up |
52 | { 3*30+xo, 6*30-5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume down | 51 | { 3*30+xo, 6*30-5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume down |
53 | { 5*30+xo, 1*30+yo, 0, TRUE, FALSE, FALSE, FALSE }, // repeat/loop | 52 | { 5*30+xo, 1*30+yo, 0, TRUE, FALSE, FALSE, FALSE }, // repeat/loop |
54 | { 1*30+xo, 1*30+yo, 0, FALSE, FALSE, FALSE, FALSE } // playlist | 53 | { 1*30+xo, 1*30+yo, 0, FALSE, FALSE, FALSE, FALSE } // playlist |
55 | }; | 54 | }; |
56 | 55 | ||
57 | 56 | ||
58 | static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); | 57 | static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); |
59 | 58 | ||
60 | 59 | ||
61 | AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : | 60 | AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : |
62 | QWidget( parent, name, f ) | 61 | QWidget( parent, name, f ) |
63 | { | 62 | { |
64 | setCaption( tr("OpiePlayer") ); | 63 | setCaption( tr("MediaPlayer") ); |
65 | setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/metalFinish" ) ); | 64 | setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/metalFinish" ) ); |
66 | pixmaps[0] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaButtonsAll" ) ); | 65 | pixmaps[0] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaButtonsAll" ) ); |
67 | pixmaps[1] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaButtonsBig" ) ); | 66 | pixmaps[1] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaButtonsBig" ) ); |
68 | pixmaps[2] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaControls" ) ); | 67 | pixmaps[2] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaControls" ) ); |
69 | pixmaps[3] = new QPixmap( Resource::loadPixmap( "mpegplayer/animatedButton" ) ); | 68 | pixmaps[3] = new QPixmap( Resource::loadPixmap( "mpegplayer/animatedButton" ) ); |
70 | 69 | ||
71 | songInfo = new Ticker( this ); | 70 | songInfo = new Ticker( this ); |
72 | songInfo->setFocusPolicy( QWidget::NoFocus ); | 71 | songInfo->setFocusPolicy( QWidget::NoFocus ); |
73 | songInfo->setGeometry( QRect( 7, 3, 220, 20 ) ); | 72 | songInfo->setGeometry( QRect( 7, 3, 220, 20 ) ); |
74 | 73 | ||
75 | slider = new QSlider( Qt::Horizontal, this ); | 74 | slider = new QSlider( Qt::Horizontal, this ); |
76 | slider->setFixedWidth( 220 ); | 75 | slider->setFixedWidth( 220 ); |
77 | slider->setFixedHeight( 20 ); | 76 | slider->setFixedHeight( 20 ); |
78 | slider->setMinValue( 0 ); | 77 | slider->setMinValue( 0 ); |
79 | slider->setMaxValue( 1 ); | 78 | slider->setMaxValue( 1 ); |
80 | slider->setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/metalFinish" ) ); | 79 | slider->setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/metalFinish" ) ); |
81 | slider->setFocusPolicy( QWidget::NoFocus ); | 80 | slider->setFocusPolicy( QWidget::NoFocus ); |
82 | slider->setGeometry( QRect( 7, 262, 220, 20 ) ); | 81 | slider->setGeometry( QRect( 7, 262, 220, 20 ) ); |
83 | 82 | ||
84 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 83 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
85 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 84 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
86 | 85 | ||
87 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); | 86 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); |
88 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 87 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
89 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 88 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
90 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); | 89 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); |
91 | connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); | 90 | connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); |
92 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); | 91 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); |
93 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); | 92 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); |
94 | 93 | ||
95 | // Intialise state | 94 | // Intialise state |
96 | setLength( mediaPlayerState->length() ); | 95 | setLength( mediaPlayerState->length() ); |
97 | setPosition( mediaPlayerState->position() ); | 96 | setPosition( mediaPlayerState->position() ); |
98 | setLooping( mediaPlayerState->fullscreen() ); | 97 | setLooping( mediaPlayerState->fullscreen() ); |
99 | setPaused( mediaPlayerState->paused() ); | 98 | setPaused( mediaPlayerState->paused() ); |
100 | setPlaying( mediaPlayerState->playing() ); | 99 | setPlaying( mediaPlayerState->playing() ); |
101 | 100 | ||
102 | } | 101 | } |
103 | 102 | ||
104 | 103 | ||
105 | AudioWidget::~AudioWidget() { | 104 | AudioWidget::~AudioWidget() { |
106 | for ( int i = 0; i < 4; i++ ) | 105 | for ( int i = 0; i < 4; i++ ) |
107 | delete pixmaps[i]; | 106 | delete pixmaps[i]; |
108 | } | 107 | } |
109 | 108 | ||
110 | 109 | ||
111 | static bool audioSliderBeingMoved = FALSE; | 110 | static bool audioSliderBeingMoved = FALSE; |
112 | 111 | ||
113 | 112 | ||
114 | void AudioWidget::sliderPressed() { | 113 | void AudioWidget::sliderPressed() { |
115 | audioSliderBeingMoved = TRUE; | 114 | audioSliderBeingMoved = TRUE; |
116 | } | 115 | } |
117 | 116 | ||
118 | 117 | ||
119 | void AudioWidget::sliderReleased() { | 118 | void AudioWidget::sliderReleased() { |
120 | audioSliderBeingMoved = FALSE; | 119 | audioSliderBeingMoved = FALSE; |
121 | if ( slider->width() == 0 ) | 120 | if ( slider->width() == 0 ) |
122 | return; | 121 | return; |
123 | long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); | 122 | long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); |
124 | mediaPlayerState->setPosition( val ); | 123 | mediaPlayerState->setPosition( val ); |
125 | } | 124 | } |
126 | 125 | ||
127 | 126 | ||
128 | void AudioWidget::setPosition( long i ) { | 127 | void AudioWidget::setPosition( long i ) { |
129 | updateSlider( i, mediaPlayerState->length() ); | 128 | updateSlider( i, mediaPlayerState->length() ); |
130 | } | 129 | } |
131 | 130 | ||
132 | 131 | ||
133 | void AudioWidget::setLength( long max ) { | 132 | void AudioWidget::setLength( long max ) { |
134 | updateSlider( mediaPlayerState->position(), max ); | 133 | updateSlider( mediaPlayerState->position(), max ); |
135 | } | 134 | } |
136 | 135 | ||
137 | 136 | ||
138 | void AudioWidget::setView( char view ) { | 137 | void AudioWidget::setView( char view ) { |
139 | if ( view == 'a' ) { | 138 | if ( view == 'a' ) { |
140 | startTimer( 150 ); | 139 | startTimer( 150 ); |
141 | showMaximized(); | 140 | showMaximized(); |
142 | } else { | 141 | } else { |
143 | killTimers(); | 142 | killTimers(); |
144 | hide(); | 143 | hide(); |
145 | } | 144 | } |
146 | } | 145 | } |
147 | 146 | ||
148 | 147 | ||
149 | void AudioWidget::updateSlider( long i, long max ) { | 148 | void AudioWidget::updateSlider( long i, long max ) { |
150 | if ( max == 0 ) | 149 | if ( max == 0 ) |
151 | return; | 150 | return; |
152 | // Will flicker too much if we don't do this | 151 | // Will flicker too much if we don't do this |
153 | // Scale to something reasonable | 152 | // Scale to something reasonable |
154 | int width = slider->width(); | 153 | int width = slider->width(); |
155 | int val = int((double)i * width / max); | 154 | int val = int((double)i * width / max); |
156 | if ( !audioSliderBeingMoved ) { | 155 | if ( !audioSliderBeingMoved ) { |
157 | if ( slider->value() != val ) | 156 | if ( slider->value() != val ) |
158 | slider->setValue( val ); | 157 | slider->setValue( val ); |
159 | if ( slider->maxValue() != width ) | 158 | if ( slider->maxValue() != width ) |
160 | slider->setMaxValue( width ); | 159 | slider->setMaxValue( width ); |
161 | } | 160 | } |
162 | } | 161 | } |
163 | 162 | ||
164 | 163 | ||
165 | void AudioWidget::setToggleButton( int i, bool down ) { | 164 | void AudioWidget::setToggleButton( int i, bool down ) { |
166 | if ( down != audioButtons[i].isDown ) | 165 | if ( down != audioButtons[i].isDown ) |
167 | toggleButton( i ); | 166 | toggleButton( i ); |
168 | } | 167 | } |
169 | 168 | ||
170 | 169 | ||
171 | void AudioWidget::toggleButton( int i ) { | 170 | void AudioWidget::toggleButton( int i ) { |
172 | audioButtons[i].isDown = !audioButtons[i].isDown; | 171 | audioButtons[i].isDown = !audioButtons[i].isDown; |
173 | QPainter p(this); | 172 | QPainter p(this); |
174 | paintButton ( &p, i ); | 173 | paintButton ( &p, i ); |
175 | } | 174 | } |
176 | 175 | ||
177 | 176 | ||
178 | void AudioWidget::paintButton( QPainter *p, int i ) { | 177 | void AudioWidget::paintButton( QPainter *p, int i ) { |
179 | int x = audioButtons[i].xPos; | 178 | int x = audioButtons[i].xPos; |
180 | int y = audioButtons[i].yPos; | 179 | int y = audioButtons[i].yPos; |
181 | int offset = 22 + 14 * audioButtons[i].isBig + audioButtons[i].isDown; | 180 | int offset = 22 + 14 * audioButtons[i].isBig + audioButtons[i].isDown; |
182 | int buttonSize = 64 + audioButtons[i].isBig * (90 - 64); | 181 | int buttonSize = 64 + audioButtons[i].isBig * (90 - 64); |
183 | p->drawPixmap( x, y, *pixmaps[audioButtons[i].isBig], buttonSize * (audioButtons[i].isDown + 2 * audioButtons[i].color), 0, buttonSize, buttonSize ); | 182 | p->drawPixmap( x, y, *pixmaps[audioButtons[i].isBig], buttonSize * (audioButtons[i].isDown + 2 * audioButtons[i].color), 0, buttonSize, buttonSize ); |
184 | p->drawPixmap( x + offset, y + offset, *pixmaps[2], 18 * i, 0, 18, 18 ); | 183 | p->drawPixmap( x + offset, y + offset, *pixmaps[2], 18 * i, 0, 18, 18 ); |
185 | } | 184 | } |
186 | 185 | ||
187 | 186 | ||
188 | void AudioWidget::timerEvent( QTimerEvent * ) { | 187 | void AudioWidget::timerEvent( QTimerEvent * ) { |
189 | static int frame = 0; | 188 | static int frame = 0; |
190 | if ( !mediaPlayerState->paused() && audioButtons[ AudioPlay ].isDown ) { | 189 | if ( !mediaPlayerState->paused() && audioButtons[ AudioPlay ].isDown ) { |
191 | frame = frame >= 7 ? 0 : frame + 1; | 190 | frame = frame >= 7 ? 0 : frame + 1; |
192 | int x = audioButtons[AudioPlay].xPos; | 191 | int x = audioButtons[AudioPlay].xPos; |
193 | int y = audioButtons[AudioPlay].yPos; | 192 | int y = audioButtons[AudioPlay].yPos; |
194 | QPainter p( this ); | 193 | QPainter p( this ); |
195 | // Optimize to only draw the little bit of the changing images which is different | 194 | // Optimize to only draw the little bit of the changing images which is different |
196 | p.drawPixmap( x + 14, y + 8, *pixmaps[3], 32 * frame, 0, 32, 32 ); | 195 | p.drawPixmap( x + 14, y + 8, *pixmaps[3], 32 * frame, 0, 32, 32 ); |
197 | p.drawPixmap( x + 37, y + 37, *pixmaps[2], 18 * AudioPlay, 0, 6, 3 ); | 196 | p.drawPixmap( x + 37, y + 37, *pixmaps[2], 18 * AudioPlay, 0, 6, 3 ); |
198 | } | 197 | } |
199 | } | 198 | } |
200 | 199 | ||
201 | 200 | ||
202 | void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { | 201 | void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { |
203 | for ( int i = 0; i < numButtons; i++ ) { | 202 | for ( int i = 0; i < numButtons; i++ ) { |
204 | int size = audioButtons[i].isBig; | 203 | int size = audioButtons[i].isBig; |
205 | int x = audioButtons[i].xPos; | 204 | int x = audioButtons[i].xPos; |
206 | int y = audioButtons[i].yPos; | 205 | int y = audioButtons[i].yPos; |
207 | if ( event->state() == QMouseEvent::LeftButton ) { | 206 | if ( event->state() == QMouseEvent::LeftButton ) { |
208 | // The test to see if the mouse click is inside the circular button or not | 207 | // The test to see if the mouse click is inside the circular button or not |
209 | // (compared with the radius squared to avoid a square-root of our distance) | 208 | // (compared with the radius squared to avoid a square-root of our distance) |
210 | int radius = 32 + 13 * size; | 209 | int radius = 32 + 13 * size; |
211 | QPoint center = QPoint( x + radius, y + radius ); | 210 | QPoint center = QPoint( x + radius, y + radius ); |
212 | QPoint dXY = center - event->pos(); | 211 | QPoint dXY = center - event->pos(); |
213 | int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y(); | 212 | int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y(); |
214 | bool isOnButton = dist <= (radius * radius); | 213 | bool isOnButton = dist <= (radius * radius); |
215 | // QRect r( x, y, 64 + 22*size, 64 + 22*size ); | 214 | // QRect r( x, y, 64 + 22*size, 64 + 22*size ); |
216 | // bool isOnButton = r.contains( event->pos() ); // Rectangular Button code | 215 | // bool isOnButton = r.contains( event->pos() ); // Rectangular Button code |
217 | if ( isOnButton && !audioButtons[i].isHeld ) { | 216 | if ( isOnButton && !audioButtons[i].isHeld ) { |
218 | audioButtons[i].isHeld = TRUE; | 217 | audioButtons[i].isHeld = TRUE; |
219 | toggleButton(i); | 218 | toggleButton(i); |
220 | switch (i) { | 219 | switch (i) { |
221 | case AudioVolumeUp: emit moreClicked(); return; | 220 | case AudioVolumeUp: emit moreClicked(); return; |
222 | case AudioVolumeDown: emit lessClicked(); return; | 221 | case AudioVolumeDown: emit lessClicked(); return; |
223 | } | 222 | } |
224 | } else if ( !isOnButton && audioButtons[i].isHeld ) { | 223 | } else if ( !isOnButton && audioButtons[i].isHeld ) { |
225 | audioButtons[i].isHeld = FALSE; | 224 | audioButtons[i].isHeld = FALSE; |
226 | toggleButton(i); | 225 | toggleButton(i); |
227 | } | 226 | } |
228 | } else { | 227 | } else { |
229 | if ( audioButtons[i].isHeld ) { | 228 | if ( audioButtons[i].isHeld ) { |
230 | audioButtons[i].isHeld = FALSE; | 229 | audioButtons[i].isHeld = FALSE; |
231 | if ( !audioButtons[i].isToggle ) | 230 | if ( !audioButtons[i].isToggle ) |
232 | setToggleButton( i, FALSE ); | 231 | setToggleButton( i, FALSE ); |
233 | switch (i) { | 232 | switch (i) { |
234 | case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return; | 233 | case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return; |
235 | case AudioStop: mediaPlayerState->setPlaying(FALSE); return; | 234 | case AudioStop: mediaPlayerState->setPlaying(FALSE); return; |
236 | case AudioPause: mediaPlayerState->setPaused(audioButtons[i].isDown); return; | 235 | case AudioPause: mediaPlayerState->setPaused(audioButtons[i].isDown); return; |
237 | case AudioNext: mediaPlayerState->setNext(); return; | 236 | case AudioNext: mediaPlayerState->setNext(); return; |
238 | case AudioPrevious: mediaPlayerState->setPrev(); return; | 237 | case AudioPrevious: mediaPlayerState->setPrev(); return; |
239 | case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return; | 238 | case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return; |
240 | case AudioVolumeUp: emit moreReleased(); return; | 239 | case AudioVolumeUp: emit moreReleased(); return; |
241 | case AudioVolumeDown: emit lessReleased(); return; | 240 | case AudioVolumeDown: emit lessReleased(); return; |
242 | case AudioPlayList: mediaPlayerState->setList(); return; | 241 | case AudioPlayList: mediaPlayerState->setList(); return; |
243 | } | 242 | } |
244 | } | 243 | } |
245 | } | 244 | } |
246 | } | 245 | } |
247 | } | 246 | } |
248 | 247 | ||
249 | 248 | ||
250 | void AudioWidget::mousePressEvent( QMouseEvent *event ) { | 249 | void AudioWidget::mousePressEvent( QMouseEvent *event ) { |
251 | mouseMoveEvent( event ); | 250 | mouseMoveEvent( event ); |
252 | } | 251 | } |
253 | 252 | ||
254 | 253 | ||
255 | void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { | 254 | void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { |
256 | mouseMoveEvent( event ); | 255 | mouseMoveEvent( event ); |
257 | } | 256 | } |
258 | 257 | ||
259 | 258 | ||
260 | void AudioWidget::showEvent( QShowEvent* ) { | 259 | void AudioWidget::showEvent( QShowEvent* ) { |
261 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); | 260 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); |
262 | mouseMoveEvent( &event ); | 261 | mouseMoveEvent( &event ); |
263 | } | 262 | } |
264 | 263 | ||
265 | 264 | ||
266 | void AudioWidget::closeEvent( QCloseEvent* ) { | 265 | void AudioWidget::closeEvent( QCloseEvent* ) { |
267 | mediaPlayerState->setList(); | 266 | mediaPlayerState->setList(); |
268 | } | 267 | } |
269 | 268 | ||
270 | 269 | ||
271 | void AudioWidget::paintEvent( QPaintEvent * ) { | 270 | void AudioWidget::paintEvent( QPaintEvent * ) { |
272 | QPainter p( this ); | 271 | QPainter p( this ); |
273 | for ( int i = 0; i < numButtons; i++ ) | 272 | for ( int i = 0; i < numButtons; i++ ) |
274 | paintButton( &p, i ); | 273 | paintButton( &p, i ); |
275 | } | 274 | } |
276 | 275 | ||
277 | 276 | ||
diff --git a/core/multimedia/opieplayer/audiowidget.h b/core/multimedia/opieplayer/audiowidget.h index 4b82a91..95f5322 100644 --- a/core/multimedia/opieplayer/audiowidget.h +++ b/core/multimedia/opieplayer/audiowidget.h | |||
@@ -1,55 +1,54 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef AUDIO_WIDGET_H | 20 | #ifndef AUDIO_WIDGET_H |
21 | #define AUDIO_WIDGET_H | 21 | #define AUDIO_WIDGET_H |
22 | 22 | ||
23 | |||
24 | #include <qwidget.h> | 23 | #include <qwidget.h> |
25 | #include <qpainter.h> | 24 | #include <qpainter.h> |
26 | #include <qdrawutil.h> | 25 | #include <qdrawutil.h> |
27 | #include <qpixmap.h> | 26 | #include <qpixmap.h> |
28 | #include <qstring.h> | 27 | #include <qstring.h> |
29 | #include <qslider.h> | 28 | #include <qslider.h> |
30 | #include <qframe.h> | 29 | #include <qframe.h> |
31 | 30 | ||
32 | 31 | ||
33 | class QPixmap; | 32 | class QPixmap; |
34 | 33 | ||
35 | 34 | ||
36 | enum AudioButtons { | 35 | enum AudioButtons { |
37 | AudioPlay, | 36 | AudioPlay, |
38 | AudioStop, | 37 | AudioStop, |
39 | AudioPause, | 38 | AudioPause, |
40 | AudioNext, | 39 | AudioNext, |
41 | AudioPrevious, | 40 | AudioPrevious, |
42 | AudioVolumeUp, | 41 | AudioVolumeUp, |
43 | AudioVolumeDown, | 42 | AudioVolumeDown, |
44 | AudioLoop, | 43 | AudioLoop, |
45 | AudioPlayList | 44 | AudioPlayList |
46 | }; | 45 | }; |
47 | 46 | ||
48 | 47 | ||
49 | #define USE_DBLBUF | 48 | #define USE_DBLBUF |
50 | 49 | ||
51 | 50 | ||
52 | class Ticker : public QFrame { | 51 | class Ticker : public QFrame { |
53 | Q_OBJECT | 52 | Q_OBJECT |
54 | public: | 53 | public: |
55 | Ticker( QWidget* parent=0 ) : QFrame( parent ) { | 54 | Ticker( QWidget* parent=0 ) : QFrame( parent ) { |
diff --git a/core/multimedia/opieplayer/libflash/libflashplugin.h b/core/multimedia/opieplayer/libflash/libflashplugin.h index a2f1c42..48b512f 100644 --- a/core/multimedia/opieplayer/libflash/libflashplugin.h +++ b/core/multimedia/opieplayer/libflash/libflashplugin.h | |||
@@ -1,84 +1,82 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef LIBFLASH_PLUGIN_H | 20 | #ifndef LIBFLASH_PLUGIN_H |
21 | #define LIBFLASH_PLUGIN_H | 21 | #define LIBFLASH_PLUGIN_H |
22 | 22 | ||
23 | 23 | ||
24 | #include <qstring.h> | 24 | #include <qstring.h> |
25 | #include <qapplication.h> | 25 | #include <qapplication.h> |
26 | #include "flash.h" | 26 | #include "flash.h" |
27 | //#include <qpe/mediaplayerplugininterface.h> | 27 | #include <qpe/mediaplayerplugininterface.h> |
28 | #include "../mediaplayerplugininterface.h" | ||
29 | 28 | ||
30 | 29 | ||
31 | class LibFlashPlugin : public MediaPlayerDecoder { | 30 | class LibFlashPlugin : public MediaPlayerDecoder { |
32 | 31 | ||
33 | public: | 32 | public: |
34 | LibFlashPlugin(); | 33 | LibFlashPlugin(); |
35 | ~LibFlashPlugin() { close(); } | 34 | ~LibFlashPlugin() { close(); } |
36 | 35 | ||
37 | const char *pluginName() { return "LibFlashPlugin: " PLUGIN_NAME " " FLASH_VERSION_STRING; } | 36 | const char *pluginName() { return "LibFlashPlugin: " PLUGIN_NAME " " FLASH_VERSION_STRING; } |
38 | const char *pluginComment() { return "This is the libflash library: " PLUGIN_NAME " " FLASH_VERSION_STRING; } | 37 | const char *pluginComment() { return "This is the libflash library: " PLUGIN_NAME " " FLASH_VERSION_STRING; } |
39 | double pluginVersion() { return 1.0; } | 38 | double pluginVersion() { return 1.0; } |
40 | 39 | ||
41 | bool isFileSupported( const QString& fileName ) { return fileName.right(4) == ".swf"; } | 40 | bool isFileSupported( const QString& fileName ) { return fileName.right(4) == ".swf"; } |
42 | bool open( const QString& fileName ); | 41 | bool open( const QString& fileName ); |
43 | bool close() { FlashClose( file ); file = NULL; return TRUE; } | 42 | bool close() { FlashClose( file ); file = NULL; return TRUE; } |
44 | bool isOpen() { return file != NULL; } | 43 | bool isOpen() { return file != NULL; } |
45 | const QString &fileInfo() { return strInfo = qApp->translate( "MediaPlayer", "No Information Available", "media plugin text" ); } | 44 | const QString &fileInfo() { return strInfo = qApp->translate( "MediaPlayer", "No Information Available", "media plugin text" ); } |
46 | 45 | ||
47 | // If decoder doesn't support audio then return 0 here | 46 | // If decoder doesn't support audio then return 0 here |
48 | int audioStreams() { return 1; } | 47 | int audioStreams() { return 1; } |
49 | int audioChannels( int /*stream*/ ) { return 2; } | 48 | int audioChannels( int /*stream*/ ) { return 2; } |
50 | int audioFrequency( int /*stream*/ ) { return 44100; } | 49 | int audioFrequency( int /*stream*/ ) { return 44100; } |
51 | int audioSamples( int /*stream*/ ) { return 1000000; } | 50 | int audioSamples( int /*stream*/ ) { return 1000000; } |
52 | int audioBitsPerSample(int) { return 0;} | ||
53 | bool audioSetSample( long sample, int stream ); | 51 | bool audioSetSample( long sample, int stream ); |
54 | long audioGetSample( int stream ); | 52 | long audioGetSample( int stream ); |
55 | //bool audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream ); | 53 | //bool audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream ); |
56 | //bool audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream ); | 54 | //bool audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream ); |
57 | bool audioReadSamples( short *output, int channels, long samples, long& samplesRead, int stream ); | 55 | bool audioReadSamples( short *output, int channels, long samples, long& samplesRead, int stream ); |
58 | //bool audioReadSamples( short *output, int channel, long samples, int stream ); | 56 | //bool audioReadSamples( short *output, int channel, long samples, int stream ); |
59 | //bool audioReReadSamples( short *output, int channel, long samples, int stream ); | 57 | //bool audioReReadSamples( short *output, int channel, long samples, int stream ); |
60 | 58 | ||
61 | // If decoder doesn't support video then return 0 here | 59 | // If decoder doesn't support video then return 0 here |
62 | int videoStreams(); | 60 | int videoStreams(); |
63 | int videoWidth( int stream ); | 61 | int videoWidth( int stream ); |
64 | int videoHeight( int stream ); | 62 | int videoHeight( int stream ); |
65 | double videoFrameRate( int stream ); | 63 | double videoFrameRate( int stream ); |
66 | int videoFrames( int stream ); | 64 | int videoFrames( int stream ); |
67 | bool videoSetFrame( long frame, int stream ); | 65 | bool videoSetFrame( long frame, int stream ); |
68 | long videoGetFrame( int stream ); | 66 | long videoGetFrame( int stream ); |
69 | bool videoReadFrame( unsigned char **output_rows, int in_x, int in_y, int in_w, int in_h, ColorFormat color_model, int stream ); | 67 | bool videoReadFrame( unsigned char **output_rows, int in_x, int in_y, int in_w, int in_h, ColorFormat color_model, int stream ); |
70 | bool videoReadScaledFrame( unsigned char **output_rows, int in_x, int in_y, int in_w, int in_h, int out_w, int out_h, ColorFormat color_model, int stream ); | 68 | bool videoReadScaledFrame( unsigned char **output_rows, int in_x, int in_y, int in_w, int in_h, int out_w, int out_h, ColorFormat color_model, int stream ); |
71 | bool videoReadYUVFrame( char *y_output, char *u_output, char *v_output, int in_x, int in_y, int in_w, int in_h, int stream ); | 69 | bool videoReadYUVFrame( char *y_output, char *u_output, char *v_output, int in_x, int in_y, int in_w, int in_h, int stream ); |
72 | 70 | ||
73 | // Profiling | 71 | // Profiling |
74 | double getTime(); | 72 | double getTime(); |
75 | 73 | ||
76 | // Ignore if these aren't supported | 74 | // Ignore if these aren't supported |
77 | bool setSMP( int cpus ); | 75 | bool setSMP( int cpus ); |
78 | bool setMMX( bool useMMX ); | 76 | bool setMMX( bool useMMX ); |
79 | 77 | ||
80 | // Capabilities | 78 | // Capabilities |
81 | bool supportsAudio() { return TRUE; } | 79 | bool supportsAudio() { return TRUE; } |
82 | bool supportsVideo() { return TRUE; } | 80 | bool supportsVideo() { return TRUE; } |
83 | bool supportsYUV() { return TRUE; } | 81 | bool supportsYUV() { return TRUE; } |
84 | bool supportsMMX() { return TRUE; } | 82 | bool supportsMMX() { return TRUE; } |
diff --git a/core/multimedia/opieplayer/libflash/libflashpluginimpl.h b/core/multimedia/opieplayer/libflash/libflashpluginimpl.h index cb8d959..33d8ad2 100644 --- a/core/multimedia/opieplayer/libflash/libflashpluginimpl.h +++ b/core/multimedia/opieplayer/libflash/libflashpluginimpl.h | |||
@@ -1,54 +1,53 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef LIBFLASH_PLUGIN_IMPL_H | 20 | #ifndef LIBFLASH_PLUGIN_IMPL_H |
21 | #define LIBFLASH_PLUGIN_IMPL_H | 21 | #define LIBFLASH_PLUGIN_IMPL_H |
22 | 22 | ||
23 | 23 | ||
24 | //#include <qpe/mediaplayerplugininterface.h> | 24 | #include <qpe/mediaplayerplugininterface.h> |
25 | #include "../mediaplayerplugininterface.h" | ||
26 | 25 | ||
27 | 26 | ||
28 | class LibFlashPlugin; | 27 | class LibFlashPlugin; |
29 | 28 | ||
30 | 29 | ||
31 | class LibFlashPluginImpl : public MediaPlayerPluginInterface | 30 | class LibFlashPluginImpl : public MediaPlayerPluginInterface |
32 | { | 31 | { |
33 | public: | 32 | public: |
34 | LibFlashPluginImpl(); | 33 | LibFlashPluginImpl(); |
35 | virtual ~LibFlashPluginImpl(); | 34 | virtual ~LibFlashPluginImpl(); |
36 | 35 | ||
37 | #ifndef QT_NO_COMPONENT | 36 | #ifndef QT_NO_COMPONENT |
38 | 37 | ||
39 | QRESULT queryInterface( const QUuid&, QUnknownInterface** ); | 38 | QRESULT queryInterface( const QUuid&, QUnknownInterface** ); |
40 | Q_REFCOUNT | 39 | Q_REFCOUNT |
41 | 40 | ||
42 | #endif | 41 | #endif |
43 | 42 | ||
44 | virtual MediaPlayerDecoder *decoder(); | 43 | virtual MediaPlayerDecoder *decoder(); |
45 | virtual MediaPlayerEncoder *encoder(); | 44 | virtual MediaPlayerEncoder *encoder(); |
46 | 45 | ||
47 | private: | 46 | private: |
48 | LibFlashPlugin *libflashplugin; | 47 | LibFlashPlugin *libflashplugin; |
49 | ulong ref; | 48 | ulong ref; |
50 | }; | 49 | }; |
51 | 50 | ||
52 | 51 | ||
53 | #endif | 52 | #endif |
54 | 53 | ||
diff --git a/core/multimedia/opieplayer/libflash/swf.h b/core/multimedia/opieplayer/libflash/swf.h index 48986cc..5f5e4f7 100644 --- a/core/multimedia/opieplayer/libflash/swf.h +++ b/core/multimedia/opieplayer/libflash/swf.h | |||
@@ -179,51 +179,51 @@ enum | |||
179 | stagDefineButton2 = 34,// A button V2 includes color transform, alpha and multiple actions | 179 | stagDefineButton2 = 34,// A button V2 includes color transform, alpha and multiple actions |
180 | stagDefineBitsJPEG3 = 35,// A JPEG bitmap with alpha info. | 180 | stagDefineBitsJPEG3 = 35,// A JPEG bitmap with alpha info. |
181 | stagDefineBitsLossless2 = 36,// A lossless bitmap with alpha info. | 181 | stagDefineBitsLossless2 = 36,// A lossless bitmap with alpha info. |
182 | stagDefineSprite = 39,// Define a sequence of tags that describe the behavior of a sprite. | 182 | stagDefineSprite = 39,// Define a sequence of tags that describe the behavior of a sprite. |
183 | stagNameCharacter = 40,// Name a character definition, character id and a string, (used for buttons, bitmaps, sprites and sounds). | 183 | stagNameCharacter = 40,// Name a character definition, character id and a string, (used for buttons, bitmaps, sprites and sounds). |
184 | stagFrameLabel = 43,// A string label for the current frame. | 184 | stagFrameLabel = 43,// A string label for the current frame. |
185 | stagSoundStreamHead2 = 45,// For lossless streaming sound, should not have needed this... | 185 | stagSoundStreamHead2 = 45,// For lossless streaming sound, should not have needed this... |
186 | stagDefineMorphShape = 46,// A morph shape definition | 186 | stagDefineMorphShape = 46,// A morph shape definition |
187 | stagDefineFont2 = 48, | 187 | stagDefineFont2 = 48, |
188 | 188 | ||
189 | notEnoughData = 0xffff,// Special code | 189 | notEnoughData = 0xffff,// Special code |
190 | }; | 190 | }; |
191 | 191 | ||
192 | #ifndef false | 192 | #ifndef false |
193 | #define false 0 | 193 | #define false 0 |
194 | #endif | 194 | #endif |
195 | #ifndef true | 195 | #ifndef true |
196 | #define true 1 | 196 | #define true 1 |
197 | #endif | 197 | #endif |
198 | 198 | ||
199 | extern int shape_size,shape_nb,shaperecord_size,shaperecord_nb,style_size,style_nb; | 199 | extern int shape_size,shape_nb,shaperecord_size,shaperecord_nb,style_size,style_nb; |
200 | 200 | ||
201 | typedef void (*ScanLineFunc)(void *id, long y, long start, long end); | 201 | typedef void (*ScanLineFunc)(void *id, long y, long start, long end); |
202 | 202 | ||
203 | class Bitmap; | 203 | class Bitmap; |
204 | struct FlashMovie; | 204 | struct FlashMovie; |
205 | 205 | ||
206 | extern "C" { | 206 | extern "C" { |
207 | #include "jpeglib.h" | 207 | #include "jpeglib.h" |
208 | }; | 208 | }; |
209 | extern "C" { | 209 | extern "C" { |
210 | //#include "zlib.h" | 210 | //#include "zlib.h" |
211 | #include "/opt/qt-2.3.2-embedded/src/3rdparty/zlib/zlib.h" | 211 | #include "../src/3rdparty/zlib/zlib.h" |
212 | }; | 212 | }; |
213 | 213 | ||
214 | #include "graphic.h" | 214 | #include "graphic.h" |
215 | #include "character.h" | 215 | #include "character.h" |
216 | #include "bitmap.h" | 216 | #include "bitmap.h" |
217 | #include "shape.h" | 217 | #include "shape.h" |
218 | #include "displaylist.h" | 218 | #include "displaylist.h" |
219 | #include "sound.h" | 219 | #include "sound.h" |
220 | #include "button.h" | 220 | #include "button.h" |
221 | #include "font.h" | 221 | #include "font.h" |
222 | #include "text.h" | 222 | #include "text.h" |
223 | #include "adpcm.h" | 223 | #include "adpcm.h" |
224 | #include "program.h" | 224 | #include "program.h" |
225 | #include "sprite.h" | 225 | #include "sprite.h" |
226 | #include "script.h" | 226 | #include "script.h" |
227 | #include "movie.h" | 227 | #include "movie.h" |
228 | 228 | ||
229 | #endif /* _SWF_H_ */ | 229 | #endif /* _SWF_H_ */ |
diff --git a/core/multimedia/opieplayer/libmad/Makefile.in b/core/multimedia/opieplayer/libmad/Makefile.in index 552043c..e9f74e7 100644 --- a/core/multimedia/opieplayer/libmad/Makefile.in +++ b/core/multimedia/opieplayer/libmad/Makefile.in | |||
@@ -185,41 +185,39 @@ decoder.o: decoder.c \ | |||
185 | synth.h \ | 185 | synth.h \ |
186 | decoder.h | 186 | decoder.h |
187 | 187 | ||
188 | layer12.o: layer12.c \ | 188 | layer12.o: layer12.c \ |
189 | libmad_global.h \ | 189 | libmad_global.h \ |
190 | fixed.h \ | 190 | fixed.h \ |
191 | bit.h \ | 191 | bit.h \ |
192 | stream.h \ | 192 | stream.h \ |
193 | frame.h \ | 193 | frame.h \ |
194 | timer.h \ | 194 | timer.h \ |
195 | layer12.h \ | 195 | layer12.h \ |
196 | sf_table.dat \ | 196 | sf_table.dat \ |
197 | qc_table.dat | 197 | qc_table.dat |
198 | 198 | ||
199 | layer3.o: layer3.c \ | 199 | layer3.o: layer3.c \ |
200 | libmad_global.h \ | 200 | libmad_global.h \ |
201 | fixed.h \ | 201 | fixed.h \ |
202 | bit.h \ | 202 | bit.h \ |
203 | stream.h \ | 203 | stream.h \ |
204 | frame.h \ | 204 | frame.h \ |
205 | timer.h \ | 205 | timer.h \ |
206 | huffman.h \ | 206 | huffman.h \ |
207 | layer3.h \ | 207 | layer3.h \ |
208 | rq_table.dat \ | 208 | rq_table.dat \ |
209 | imdct_s.dat | 209 | imdct_s.dat |
210 | 210 | ||
211 | huffman.o: huffman.c \ | 211 | huffman.o: huffman.c \ |
212 | libmad_global.h \ | 212 | libmad_global.h \ |
213 | huffman.h | 213 | huffman.h |
214 | 214 | ||
215 | libmadplugin.o: libmadplugin.cpp \ | 215 | libmadplugin.o: libmadplugin.cpp \ |
216 | libmadplugin.h \ | 216 | libmadplugin.h \ |
217 | ../mediaplayerplugininterface.h \ | ||
218 | mad.h | 217 | mad.h |
219 | 218 | ||
220 | libmadpluginimpl.o: libmadpluginimpl.cpp \ | 219 | libmadpluginimpl.o: libmadpluginimpl.cpp \ |
221 | libmadplugin.h \ | 220 | libmadplugin.h \ |
222 | ../mediaplayerplugininterface.h \ | ||
223 | libmadpluginimpl.h | 221 | libmadpluginimpl.h |
224 | 222 | ||
225 | 223 | ||
diff --git a/core/multimedia/opieplayer/libmad/libmad.pro b/core/multimedia/opieplayer/libmad/libmad.pro index b54ca6b..6c40a15 100644 --- a/core/multimedia/opieplayer/libmad/libmad.pro +++ b/core/multimedia/opieplayer/libmad/libmad.pro | |||
@@ -1,14 +1,12 @@ | |||
1 | TEMPLATE = lib | 1 | TEMPLATE= lib |
2 | CONFIG += qt warn_on release | 2 | CONFIG += qt warn_on release |
3 | HEADERS = libmad_version.h fixed.h bit.h timer.h stream.h frame.h synth.h decoder.h \ | 3 | HEADERS = libmad_version.h fixed.h bit.h timer.h stream.h frame.h synth.h decoder.h \ |
4 | layer12.h layer3.h huffman.h libmad_global.h mad.h libmadplugin.h libmadpluginimpl.h | 4 | layer12.h layer3.h huffman.h libmad_global.h mad.h libmadplugin.h libmadpluginimpl.h |
5 | SOURCES = version.c fixed.c bit.c timer.c stream.c frame.c synth.c decoder.c \ | 5 | SOURCES = version.c fixed.c bit.c timer.c stream.c frame.c synth.c decoder.c \ |
6 | layer12.c layer3.c huffman.c libmadplugin.cpp libmadpluginimpl.cpp | 6 | layer12.c layer3.c huffman.c libmadplugin.cpp libmadpluginimpl.cpp |
7 | TARGET = madplugin | 7 | TARGET = madplugin |
8 | DESTDIR = ../../plugins/codecs | 8 | DESTDIR = ../../plugins/codecs |
9 | INCLUDEPATH += $(OPIEDIR)/include .. | 9 | INCLUDEPATH += $(OPIEDIR)/include .. |
10 | DEPENDPATH += ../$(OPIEDIR)/include .. | 10 | DEPENDPATH += ../$(OPIEDIR)/include .. |
11 | TMAKE_CFLAGS += -DFPM_64BIT | ||
12 | TMAKE_CXXFLAGS += -DFPM_64BIT | ||
13 | LIBS += -lqpe -lm | 11 | LIBS += -lqpe -lm |
14 | VERSION = 1.0.0 | 12 | VERSION = 1.0.0 |
diff --git a/core/multimedia/opieplayer/libmad/libmadplugin.h b/core/multimedia/opieplayer/libmad/libmadplugin.h index ff84c27..d85e0d4 100644 --- a/core/multimedia/opieplayer/libmad/libmadplugin.h +++ b/core/multimedia/opieplayer/libmad/libmadplugin.h | |||
@@ -1,89 +1,86 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef LIBMAD_PLUGIN_H | 20 | #ifndef LIBMAD_PLUGIN_H |
21 | #define LIBMAD_PLUGIN_H | 21 | #define LIBMAD_PLUGIN_H |
22 | 22 | ||
23 | |||
24 | #include <qstring.h> | 23 | #include <qstring.h> |
25 | //#include <qpe/mediaplayerplugininterface.h> | 24 | #include <qpe/mediaplayerplugininterface.h> |
26 | #include "../mediaplayerplugininterface.h" | ||
27 | 25 | ||
28 | 26 | ||
29 | // #define OLD_MEDIAPLAYER_API | 27 | // #define OLD_MEDIAPLAYER_API |
30 | 28 | ||
31 | 29 | ||
32 | class LibMadPluginData; | 30 | class LibMadPluginData; |
33 | 31 | ||
34 | 32 | ||
35 | class LibMadPlugin : public MediaPlayerDecoder { | 33 | class LibMadPlugin : public MediaPlayerDecoder { |
36 | 34 | ||
37 | public: | 35 | public: |
38 | LibMadPlugin(); | 36 | LibMadPlugin(); |
39 | ~LibMadPlugin(); | 37 | ~LibMadPlugin(); |
40 | 38 | ||
41 | const char *pluginName() { return "LibMadPlugin"; } | 39 | const char *pluginName() { return "LibMadPlugin"; } |
42 | const char *pluginComment() { return "This is the libmad library that has been wrapped as a plugin"; } | 40 | const char *pluginComment() { return "This is the libmad library that has been wrapped as a plugin"; } |
43 | double pluginVersion() { return 1.0; } | 41 | double pluginVersion() { return 1.0; } |
44 | 42 | ||
45 | bool isFileSupported( const QString& ); | 43 | bool isFileSupported( const QString& ); |
46 | bool open( const QString& ); | 44 | bool open( const QString& ); |
47 | bool close(); | 45 | bool close(); |
48 | bool isOpen(); | 46 | bool isOpen(); |
49 | const QString &fileInfo() { return info; } | 47 | const QString &fileInfo() { return info; } |
50 | 48 | ||
51 | // If decoder doesn't support audio then return 0 here | 49 | // If decoder doesn't support audio then return 0 here |
52 | int audioStreams(); | 50 | int audioStreams(); |
53 | int audioChannels( int stream ); | 51 | int audioChannels( int stream ); |
54 | int audioFrequency( int stream ); | 52 | int audioFrequency( int stream ); |
55 | int audioSamples( int stream ); | 53 | int audioSamples( int stream ); |
56 | bool audioSetSample( long sample, int stream ); | 54 | bool audioSetSample( long sample, int stream ); |
57 | int audioBitsPerSample(int) {return 0;} | ||
58 | long audioGetSample( int stream ); | 55 | long audioGetSample( int stream ); |
59 | #ifdef OLD_MEDIAPLAYER_API | 56 | #ifdef OLD_MEDIAPLAYER_API |
60 | bool audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream ); | 57 | bool audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream ); |
61 | bool audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream ); | 58 | bool audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream ); |
62 | bool audioReadSamples( short *output, int channel, long samples, int stream ); | 59 | bool audioReadSamples( short *output, int channel, long samples, int stream ); |
63 | bool audioReReadSamples( short *output, int channel, long samples, int stream ); | 60 | bool audioReReadSamples( short *output, int channel, long samples, int stream ); |
64 | #else | 61 | #else |
65 | bool audioReadSamples( short *output, int channels, long samples, long& samplesRead, int stream ); | 62 | bool audioReadSamples( short *output, int channels, long samples, long& samplesRead, int stream ); |
66 | #endif | 63 | #endif |
67 | 64 | ||
68 | 65 | ||
69 | bool read(); | 66 | bool read(); |
70 | bool decode( short *output, long samples, long& samplesRead ); | 67 | bool decode( short *output, long samples, long& samplesRead ); |
71 | void printID3Tags(); | 68 | void printID3Tags(); |
72 | 69 | ||
73 | 70 | ||
74 | // If decoder doesn't support video then return 0 here | 71 | // If decoder doesn't support video then return 0 here |
75 | int videoStreams() { return 0; } | 72 | int videoStreams() { return 0; } |
76 | int videoWidth( int ) { return 0; } | 73 | int videoWidth( int ) { return 0; } |
77 | int videoHeight( int ) { return 0; } | 74 | int videoHeight( int ) { return 0; } |
78 | double videoFrameRate( int ) { return 0.0; } | 75 | double videoFrameRate( int ) { return 0.0; } |
79 | int videoFrames( int ) { return 0; } | 76 | int videoFrames( int ) { return 0; } |
80 | bool videoSetFrame( long, int ) { return FALSE; } | 77 | bool videoSetFrame( long, int ) { return FALSE; } |
81 | long videoGetFrame( int ) { return 0; } | 78 | long videoGetFrame( int ) { return 0; } |
82 | bool videoReadFrame( unsigned char **, int, int, int, int, ColorFormat, int ) { return FALSE; } | 79 | bool videoReadFrame( unsigned char **, int, int, int, int, ColorFormat, int ) { return FALSE; } |
83 | bool videoReadScaledFrame( unsigned char **, int, int, int, int, int, int, ColorFormat, int ) { return FALSE; } | 80 | bool videoReadScaledFrame( unsigned char **, int, int, int, int, int, int, ColorFormat, int ) { return FALSE; } |
84 | bool videoReadYUVFrame( char *, char *, char *, int, int, int, int, int ) { return FALSE; } | 81 | bool videoReadYUVFrame( char *, char *, char *, int, int, int, int, int ) { return FALSE; } |
85 | 82 | ||
86 | // Profiling | 83 | // Profiling |
87 | double getTime(); | 84 | double getTime(); |
88 | 85 | ||
89 | // Ignore if these aren't supported | 86 | // Ignore if these aren't supported |
diff --git a/core/multimedia/opieplayer/libmad/libmadpluginimpl.h b/core/multimedia/opieplayer/libmad/libmadpluginimpl.h index 8ad4956..2c5ed3b 100644 --- a/core/multimedia/opieplayer/libmad/libmadpluginimpl.h +++ b/core/multimedia/opieplayer/libmad/libmadpluginimpl.h | |||
@@ -1,53 +1,52 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef LIBMAD_PLUGIN_IMPL_H | 20 | #ifndef LIBMAD_PLUGIN_IMPL_H |
21 | #define LIBMAD_PLUGIN_IMPL_H | 21 | #define LIBMAD_PLUGIN_IMPL_H |
22 | 22 | ||
23 | 23 | #include <qpe/mediaplayerplugininterface.h> | |
24 | //#include <qpe/mediaplayerplugininterface.h> | ||
25 | #include "../mediaplayerplugininterface.h" | ||
26 | 24 | ||
27 | 25 | ||
28 | class LibMadPlugin; | 26 | class LibMadPlugin; |
29 | 27 | ||
30 | 28 | ||
31 | class LibMadPluginImpl : public MediaPlayerPluginInterface | 29 | class LibMadPluginImpl : public MediaPlayerPluginInterface |
32 | { | 30 | { |
33 | public: | 31 | public: |
34 | LibMadPluginImpl(); | 32 | LibMadPluginImpl(); |
35 | virtual ~LibMadPluginImpl(); | 33 | virtual ~LibMadPluginImpl(); |
36 | 34 | ||
37 | #ifndef QT_NO_COMPONENT | 35 | #ifndef QT_NO_COMPONENT |
38 | 36 | ||
39 | QRESULT queryInterface( const QUuid&, QUnknownInterface** ); | 37 | QRESULT queryInterface( const QUuid&, QUnknownInterface** ); |
40 | Q_REFCOUNT | 38 | Q_REFCOUNT |
41 | 39 | ||
42 | #endif | 40 | #endif |
43 | 41 | ||
44 | virtual MediaPlayerDecoder *decoder(); | 42 | virtual MediaPlayerDecoder *decoder(); |
45 | virtual MediaPlayerEncoder *encoder(); | 43 | virtual MediaPlayerEncoder *encoder(); |
44 | |||
46 | private: | 45 | private: |
47 | LibMadPlugin *libmadplugin; | 46 | LibMadPlugin *libmadplugin; |
48 | ulong ref; | 47 | ulong ref; |
49 | }; | 48 | }; |
50 | 49 | ||
51 | 50 | ||
52 | #endif | 51 | #endif |
53 | 52 | ||
diff --git a/core/multimedia/opieplayer/libmad/version.c b/core/multimedia/opieplayer/libmad/version.c index 1baba26..413d54b 100644 --- a/core/multimedia/opieplayer/libmad/version.c +++ b/core/multimedia/opieplayer/libmad/version.c | |||
@@ -59,33 +59,33 @@ char const mad_build[] = | |||
59 | # endif | 59 | # endif |
60 | # if defined(ASO_ZEROCHECK) | 60 | # if defined(ASO_ZEROCHECK) |
61 | "ASO_ZEROCHECK " | 61 | "ASO_ZEROCHECK " |
62 | # endif | 62 | # endif |
63 | 63 | ||
64 | # if defined(OPT_SPEED) | 64 | # if defined(OPT_SPEED) |
65 | "OPT_SPEED " | 65 | "OPT_SPEED " |
66 | # elif defined(OPT_ACCURACY) | 66 | # elif defined(OPT_ACCURACY) |
67 | "OPT_ACCURACY " | 67 | "OPT_ACCURACY " |
68 | # endif | 68 | # endif |
69 | 69 | ||
70 | # if defined(OPT_SSO) | 70 | # if defined(OPT_SSO) |
71 | "OPT_SSO " | 71 | "OPT_SSO " |
72 | # endif | 72 | # endif |
73 | 73 | ||
74 | # if defined(OPT_DCTO) /* never defined here */ | 74 | # if defined(OPT_DCTO) /* never defined here */ |
75 | "OPT_DCTO " | 75 | "OPT_DCTO " |
76 | # endif | 76 | # endif |
77 | 77 | ||
78 | # if defined(OPT_STRICT) | 78 | # if defined(OPT_STRICT) |
79 | "OPT_STRICT " | 79 | "OPT_STRICT " |
80 | # endif | 80 | # endif |
81 | 81 | ||
82 | # if defined(EXPERIMENTAL) | 82 | # if defined(EXPERIMENTAL) |
83 | "EXPERIMENTAL " | 83 | "EXPERIMENTAL " |
84 | # endif | 84 | # endif |
85 | 85 | ||
86 | # if defined(DEBUG) | 86 | # if defined(DEBUG) |
87 | "DEBUG " | 87 | "DEBUG " |
88 | # elif defined(NDEBUG) | 88 | # elif defined(NDEBUG) |
89 | "NDEBUG " | 89 | "NDEBUG " |
90 | # endif | 90 | # endif |
91 | ; \ No newline at end of file | 91 | ; |
diff --git a/core/multimedia/opieplayer/libmpeg3/Makefile.in b/core/multimedia/opieplayer/libmpeg3/Makefile.in index d255e4f..154f85d 100644 --- a/core/multimedia/opieplayer/libmpeg3/Makefile.in +++ b/core/multimedia/opieplayer/libmpeg3/Makefile.in | |||
@@ -147,82 +147,80 @@ listallmodules: | |||
147 | 147 | ||
148 | listaddonpromodules: | 148 | listaddonpromodules: |
149 | @echo | 149 | @echo |
150 | 150 | ||
151 | listaddonentmodules: | 151 | listaddonentmodules: |
152 | @echo | 152 | @echo |
153 | 153 | ||
154 | 154 | ||
155 | REQUIRES= | 155 | REQUIRES= |
156 | 156 | ||
157 | ####### Sub-libraries | 157 | ####### Sub-libraries |
158 | 158 | ||
159 | 159 | ||
160 | ###### Combined headers | 160 | ###### Combined headers |
161 | 161 | ||
162 | 162 | ||
163 | 163 | ||
164 | ####### Compile | 164 | ####### Compile |
165 | 165 | ||
166 | libmpeg3plugin.o: libmpeg3plugin.cpp \ | 166 | libmpeg3plugin.o: libmpeg3plugin.cpp \ |
167 | libmpeg3plugin.h \ | 167 | libmpeg3plugin.h \ |
168 | libmpeg3.h \ | 168 | libmpeg3.h \ |
169 | mpeg3private.h \ | 169 | mpeg3private.h \ |
170 | mpeg3atrack.h \ | 170 | mpeg3atrack.h \ |
171 | mpeg3demux.h \ | 171 | mpeg3demux.h \ |
172 | mpeg3title.h \ | 172 | mpeg3title.h \ |
173 | mpeg3io.h \ | 173 | mpeg3io.h \ |
174 | mpeg3css.h \ | 174 | mpeg3css.h \ |
175 | mpeg3private.inc \ | 175 | mpeg3private.inc \ |
176 | audio/mpeg3audio.h \ | 176 | audio/mpeg3audio.h \ |
177 | mpeg3vtrack.h \ | 177 | mpeg3vtrack.h \ |
178 | video/mpeg3video.h \ | 178 | video/mpeg3video.h \ |
179 | mpeg3protos.h \ | 179 | mpeg3protos.h |
180 | ../mediaplayerplugininterface.h | ||
181 | 180 | ||
182 | libmpeg3pluginimpl.o: libmpeg3pluginimpl.cpp \ | 181 | libmpeg3pluginimpl.o: libmpeg3pluginimpl.cpp \ |
183 | libmpeg3plugin.h \ | 182 | libmpeg3plugin.h \ |
184 | libmpeg3.h \ | 183 | libmpeg3.h \ |
185 | mpeg3private.h \ | 184 | mpeg3private.h \ |
186 | mpeg3atrack.h \ | 185 | mpeg3atrack.h \ |
187 | mpeg3demux.h \ | 186 | mpeg3demux.h \ |
188 | mpeg3title.h \ | 187 | mpeg3title.h \ |
189 | mpeg3io.h \ | 188 | mpeg3io.h \ |
190 | mpeg3css.h \ | 189 | mpeg3css.h \ |
191 | mpeg3private.inc \ | 190 | mpeg3private.inc \ |
192 | audio/mpeg3audio.h \ | 191 | audio/mpeg3audio.h \ |
193 | mpeg3vtrack.h \ | 192 | mpeg3vtrack.h \ |
194 | video/mpeg3video.h \ | 193 | video/mpeg3video.h \ |
195 | mpeg3protos.h \ | 194 | mpeg3protos.h \ |
196 | ../mediaplayerplugininterface.h \ | ||
197 | libmpeg3pluginimpl.h | 195 | libmpeg3pluginimpl.h |
198 | 196 | ||
199 | bitstream.o: bitstream.c \ | 197 | bitstream.o: bitstream.c \ |
200 | mpeg3private.h \ | 198 | mpeg3private.h \ |
201 | mpeg3atrack.h \ | 199 | mpeg3atrack.h \ |
202 | mpeg3demux.h \ | 200 | mpeg3demux.h \ |
203 | mpeg3title.h \ | 201 | mpeg3title.h \ |
204 | mpeg3io.h \ | 202 | mpeg3io.h \ |
205 | mpeg3css.h \ | 203 | mpeg3css.h \ |
206 | mpeg3private.inc \ | 204 | mpeg3private.inc \ |
207 | audio/mpeg3audio.h \ | 205 | audio/mpeg3audio.h \ |
208 | mpeg3vtrack.h \ | 206 | mpeg3vtrack.h \ |
209 | video/mpeg3video.h \ | 207 | video/mpeg3video.h \ |
210 | mpeg3protos.h | 208 | mpeg3protos.h |
211 | 209 | ||
212 | libmpeg3.o: libmpeg3.c \ | 210 | libmpeg3.o: libmpeg3.c \ |
213 | libmpeg3.h \ | 211 | libmpeg3.h \ |
214 | mpeg3private.h \ | 212 | mpeg3private.h \ |
215 | mpeg3atrack.h \ | 213 | mpeg3atrack.h \ |
216 | mpeg3demux.h \ | 214 | mpeg3demux.h \ |
217 | mpeg3title.h \ | 215 | mpeg3title.h \ |
218 | mpeg3io.h \ | 216 | mpeg3io.h \ |
219 | mpeg3css.h \ | 217 | mpeg3css.h \ |
220 | mpeg3private.inc \ | 218 | mpeg3private.inc \ |
221 | audio/mpeg3audio.h \ | 219 | audio/mpeg3audio.h \ |
222 | mpeg3vtrack.h \ | 220 | mpeg3vtrack.h \ |
223 | video/mpeg3video.h \ | 221 | video/mpeg3video.h \ |
224 | mpeg3protos.h | 222 | mpeg3protos.h |
225 | 223 | ||
226 | mpeg3atrack.o: mpeg3atrack.c \ | 224 | mpeg3atrack.o: mpeg3atrack.c \ |
227 | libmpeg3.h \ | 225 | libmpeg3.h \ |
228 | mpeg3private.h \ | 226 | mpeg3private.h \ |
@@ -387,65 +385,65 @@ audio/header.o: audio/header.c \ | |||
387 | mpeg3io.h \ | 385 | mpeg3io.h \ |
388 | mpeg3css.h \ | 386 | mpeg3css.h \ |
389 | mpeg3private.inc \ | 387 | mpeg3private.inc \ |
390 | audio/tables.h \ | 388 | audio/tables.h \ |
391 | audio/../libmpeg3.h \ | 389 | audio/../libmpeg3.h \ |
392 | mpeg3private.h \ | 390 | mpeg3private.h \ |
393 | mpeg3atrack.h \ | 391 | mpeg3atrack.h \ |
394 | audio/mpeg3audio.h \ | 392 | audio/mpeg3audio.h \ |
395 | mpeg3vtrack.h \ | 393 | mpeg3vtrack.h \ |
396 | video/mpeg3video.h \ | 394 | video/mpeg3video.h \ |
397 | audio/../mpeg3protos.h | 395 | audio/../mpeg3protos.h |
398 | 396 | ||
399 | audio/layer2.o: audio/layer2.c \ | 397 | audio/layer2.o: audio/layer2.c \ |
400 | audio/mpeg3audio.h \ | 398 | audio/mpeg3audio.h \ |
401 | audio/ac3.h \ | 399 | audio/ac3.h \ |
402 | audio/mpeg3real.h \ | 400 | audio/mpeg3real.h \ |
403 | audio/../bitstream.h \ | 401 | audio/../bitstream.h \ |
404 | mpeg3demux.h \ | 402 | mpeg3demux.h \ |
405 | mpeg3title.h \ | 403 | mpeg3title.h \ |
406 | mpeg3io.h \ | 404 | mpeg3io.h \ |
407 | mpeg3css.h \ | 405 | mpeg3css.h \ |
408 | mpeg3private.inc \ | 406 | mpeg3private.inc \ |
409 | audio/../libmpeg3.h \ | 407 | audio/../libmpeg3.h \ |
410 | mpeg3private.h \ | 408 | mpeg3private.h \ |
411 | mpeg3atrack.h \ | 409 | mpeg3atrack.h \ |
412 | audio/mpeg3audio.h \ | 410 | audio/mpeg3audio.h \ |
413 | mpeg3vtrack.h \ | 411 | mpeg3vtrack.h \ |
414 | video/mpeg3video.h \ | 412 | video/mpeg3video.h \ |
415 | audio/../mpeg3protos.h \ | 413 | audio/../mpeg3protos.h \ |
416 | audio/tables.h | 414 | audio/tables.h |
417 | 415 | ||
418 | audio/layer3.o: audio/layer3.c \ | 416 | audio/layer3.o: audio/layer3.c \ |
419 | huffman.h \ | 417 | audio/huffman.h \ |
420 | audio/mpeg3audio.h \ | 418 | audio/mpeg3audio.h \ |
421 | audio/ac3.h \ | 419 | audio/ac3.h \ |
422 | audio/mpeg3real.h \ | 420 | audio/mpeg3real.h \ |
423 | audio/../bitstream.h \ | 421 | audio/../bitstream.h \ |
424 | mpeg3demux.h \ | 422 | mpeg3demux.h \ |
425 | mpeg3title.h \ | 423 | mpeg3title.h \ |
426 | mpeg3io.h \ | 424 | mpeg3io.h \ |
427 | mpeg3css.h \ | 425 | mpeg3css.h \ |
428 | mpeg3private.inc \ | 426 | mpeg3private.inc \ |
429 | audio/../libmpeg3.h \ | 427 | audio/../libmpeg3.h \ |
430 | mpeg3private.h \ | 428 | mpeg3private.h \ |
431 | mpeg3atrack.h \ | 429 | mpeg3atrack.h \ |
432 | audio/mpeg3audio.h \ | 430 | audio/mpeg3audio.h \ |
433 | mpeg3vtrack.h \ | 431 | mpeg3vtrack.h \ |
434 | video/mpeg3video.h \ | 432 | video/mpeg3video.h \ |
435 | audio/../mpeg3protos.h \ | 433 | audio/../mpeg3protos.h \ |
436 | audio/tables.h | 434 | audio/tables.h |
437 | 435 | ||
438 | audio/mantissa.o: audio/mantissa.c \ | 436 | audio/mantissa.o: audio/mantissa.c \ |
439 | audio/mpeg3audio.h \ | 437 | audio/mpeg3audio.h \ |
440 | audio/ac3.h \ | 438 | audio/ac3.h \ |
441 | audio/mpeg3real.h \ | 439 | audio/mpeg3real.h \ |
442 | audio/../bitstream.h \ | 440 | audio/../bitstream.h \ |
443 | mpeg3demux.h \ | 441 | mpeg3demux.h \ |
444 | mpeg3title.h \ | 442 | mpeg3title.h \ |
445 | mpeg3io.h \ | 443 | mpeg3io.h \ |
446 | mpeg3css.h \ | 444 | mpeg3css.h \ |
447 | mpeg3private.inc \ | 445 | mpeg3private.inc \ |
448 | audio/../libmpeg3.h \ | 446 | audio/../libmpeg3.h \ |
449 | mpeg3private.h \ | 447 | mpeg3private.h \ |
450 | mpeg3atrack.h \ | 448 | mpeg3atrack.h \ |
451 | audio/mpeg3audio.h \ | 449 | audio/mpeg3audio.h \ |
diff --git a/core/multimedia/opieplayer/libmpeg3/libmpeg3plugin.h b/core/multimedia/opieplayer/libmpeg3/libmpeg3plugin.h index 54f259b..e0eb930 100644 --- a/core/multimedia/opieplayer/libmpeg3/libmpeg3plugin.h +++ b/core/multimedia/opieplayer/libmpeg3/libmpeg3plugin.h | |||
@@ -1,87 +1,84 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef LIBMPEG3_PLUGIN_H | 20 | #ifndef LIBMPEG3_PLUGIN_H |
21 | #define LIBMPEG3_PLUGIN_H | 21 | #define LIBMPEG3_PLUGIN_H |
22 | 22 | ||
23 | |||
24 | #include <qstring.h> | 23 | #include <qstring.h> |
25 | #include <qapplication.h> | 24 | #include <qapplication.h> |
26 | #include "libmpeg3.h" | 25 | #include "libmpeg3.h" |
27 | #include "mpeg3protos.h" | 26 | #include "mpeg3protos.h" |
28 | //#include <qpe/mediaplayerplugininterface.h> | 27 | #include <qpe/mediaplayerplugininterface.h> |
29 | #include "../mediaplayerplugininterface.h" | ||
30 | 28 | ||
31 | 29 | ||
32 | // #define OLD_MEDIAPLAYER_API | 30 | // #define OLD_MEDIAPLAYER_API |
33 | 31 | ||
34 | 32 | ||
35 | class LibMpeg3Plugin : public MediaPlayerDecoder { | 33 | class LibMpeg3Plugin : public MediaPlayerDecoder { |
36 | 34 | ||
37 | public: | 35 | public: |
38 | LibMpeg3Plugin() { file = NULL; } | 36 | LibMpeg3Plugin() { file = NULL; } |
39 | ~LibMpeg3Plugin() { close(); } | 37 | ~LibMpeg3Plugin() { close(); } |
40 | 38 | ||
41 | const char *pluginName() { return "LibMpeg3Plugin"; } | 39 | const char *pluginName() { return "LibMpeg3Plugin"; } |
42 | const char *pluginComment() { return "This is the libmpeg3 library writen by ... which has been modified by trolltech to use fixed point maths"; } | 40 | const char *pluginComment() { return "This is the libmpeg3 library writen by ... which has been modified by trolltech to use fixed point maths"; } |
43 | double pluginVersion() { return 1.0; } | 41 | double pluginVersion() { return 1.0; } |
44 | 42 | ||
45 | bool isFileSupported( const QString& fileName ) { return mpeg3_check_sig( (char *)fileName.latin1() ) == 1; } | 43 | bool isFileSupported( const QString& fileName ) { return mpeg3_check_sig( (char *)fileName.latin1() ) == 1; } |
46 | bool open( const QString& fileName ) { file = mpeg3_open( (char *)fileName.latin1() ); return file != NULL; } | 44 | bool open( const QString& fileName ) { file = mpeg3_open( (char *)fileName.latin1() ); return file != NULL; } |
47 | bool close() { if ( file ) { int r = mpeg3_close( file ); file = NULL; return r == 1; } return FALSE; } | 45 | bool close() { if ( file ) { int r = mpeg3_close( file ); file = NULL; return r == 1; } return FALSE; } |
48 | bool isOpen() { return file != NULL; } | 46 | bool isOpen() { return file != NULL; } |
49 | const QString &fileInfo() { return strInfo = ""; } | 47 | const QString &fileInfo() { return strInfo = ""; } |
50 | 48 | ||
51 | // If decoder doesn't support audio then return 0 here | 49 | // If decoder doesn't support audio then return 0 here |
52 | int audioStreams() { return file ? mpeg3_total_astreams( file ) : 0; } | 50 | int audioStreams() { return file ? mpeg3_total_astreams( file ) : 0; } |
53 | int audioChannels( int stream ) { return file ? mpeg3_audio_channels( file, stream ) : 0; } | 51 | int audioChannels( int stream ) { return file ? mpeg3_audio_channels( file, stream ) : 0; } |
54 | int audioFrequency( int stream ) { return file ? mpeg3_sample_rate( file, stream ) : 0; } | 52 | int audioFrequency( int stream ) { return file ? mpeg3_sample_rate( file, stream ) : 0; } |
55 | int audioBitsPerSample(int) { return 0;} | ||
56 | int audioSamples( int stream ) { return file ? mpeg3_audio_samples( file, stream ) : 0; } | 53 | int audioSamples( int stream ) { return file ? mpeg3_audio_samples( file, stream ) : 0; } |
57 | bool audioSetSample( long sample, int stream ) { return file ? mpeg3_set_sample( file, sample, stream) == 1 : FALSE; } | 54 | bool audioSetSample( long sample, int stream ) { return file ? mpeg3_set_sample( file, sample, stream) == 1 : FALSE; } |
58 | long audioGetSample( int stream ) { return file ? mpeg3_get_sample( file, stream ) : 0; } | 55 | long audioGetSample( int stream ) { return file ? mpeg3_get_sample( file, stream ) : 0; } |
59 | #ifdef OLD_MEDIAPLAYER_API | 56 | #ifdef OLD_MEDIAPLAYER_API |
60 | bool audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream ); | 57 | bool audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream ); |
61 | bool audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream ); | 58 | bool audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream ); |
62 | bool audioReadSamples( short *output, int channel, long samples, int stream ); | 59 | bool audioReadSamples( short *output, int channel, long samples, int stream ); |
63 | bool audioReReadSamples( short *output, int channel, long samples, int stream ); | 60 | bool audioReReadSamples( short *output, int channel, long samples, int stream ); |
64 | #else | 61 | #else |
65 | bool audioReadSamples( short *output, int channels, long samples, long& samplesRead, int stream ); | 62 | bool audioReadSamples( short *output, int channels, long samples, long& samplesRead, int stream ); |
66 | #endif | 63 | #endif |
67 | 64 | ||
68 | // If decoder doesn't support video then return 0 here | 65 | // If decoder doesn't support video then return 0 here |
69 | int videoStreams() { return file ? mpeg3_total_vstreams( file ) : 0; } | 66 | int videoStreams() { return file ? mpeg3_total_vstreams( file ) : 0; } |
70 | int videoWidth( int stream ) { return file ? mpeg3_video_width( file, stream ) : 0; } | 67 | int videoWidth( int stream ) { return file ? mpeg3_video_width( file, stream ) : 0; } |
71 | int videoHeight( int stream ) { return file ? mpeg3_video_height( file, stream ) : 0; } | 68 | int videoHeight( int stream ) { return file ? mpeg3_video_height( file, stream ) : 0; } |
72 | double videoFrameRate( int stream ) { return file ? mpeg3_frame_rate( file, stream ) : 0.0; } | 69 | double videoFrameRate( int stream ) { return file ? mpeg3_frame_rate( file, stream ) : 0.0; } |
73 | int videoFrames( int stream ) | 70 | int videoFrames( int stream ) |
74 | { return file ? mpeg3_video_frames( file, stream ) : 0; } | 71 | { return file ? mpeg3_video_frames( file, stream ) : 0; } |
75 | /* | 72 | /* |
76 | { | 73 | { |
77 | if ( file ) { | 74 | if ( file ) { |
78 | int frames = mpeg3_video_frames( file, stream ); | 75 | int frames = mpeg3_video_frames( file, stream ); |
79 | if ( frames == 1 ) { | 76 | if ( frames == 1 ) { |
80 | int res = mpeg3_seek_percentage( file, 0.99 ); | 77 | int res = mpeg3_seek_percentage( file, 0.99 ); |
81 | printf("res: %i\n", res ); | 78 | printf("res: %i\n", res ); |
82 | mpeg3video_seek( file->vtrack[stream]->video ); | 79 | mpeg3video_seek( file->vtrack[stream]->video ); |
83 | frames = mpeg3_get_frame( file, stream ); | 80 | frames = mpeg3_get_frame( file, stream ); |
84 | mpeg3_seek_percentage( file, 0.0 ); | 81 | mpeg3_seek_percentage( file, 0.0 ); |
85 | } | 82 | } |
86 | return frames; | 83 | return frames; |
87 | } | 84 | } |
diff --git a/core/multimedia/opieplayer/libmpeg3/libmpeg3pluginimpl.h b/core/multimedia/opieplayer/libmpeg3/libmpeg3pluginimpl.h index 89abf97..e9926f4 100644 --- a/core/multimedia/opieplayer/libmpeg3/libmpeg3pluginimpl.h +++ b/core/multimedia/opieplayer/libmpeg3/libmpeg3pluginimpl.h | |||
@@ -1,54 +1,52 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef LIBMPEG3_PLUGIN_IMPL_H | 20 | #ifndef LIBMPEG3_PLUGIN_IMPL_H |
21 | #define LIBMPEG3_PLUGIN_IMPL_H | 21 | #define LIBMPEG3_PLUGIN_IMPL_H |
22 | 22 | ||
23 | 23 | #include <qpe/mediaplayerplugininterface.h> | |
24 | //#include <qpe/mediaplayerplugininterface.h> | ||
25 | #include "../mediaplayerplugininterface.h" | ||
26 | 24 | ||
27 | 25 | ||
28 | class LibMpeg3Plugin; | 26 | class LibMpeg3Plugin; |
29 | 27 | ||
30 | 28 | ||
31 | class LibMpeg3PluginImpl : public MediaPlayerPluginInterface | 29 | class LibMpeg3PluginImpl : public MediaPlayerPluginInterface |
32 | { | 30 | { |
33 | public: | 31 | public: |
34 | LibMpeg3PluginImpl(); | 32 | LibMpeg3PluginImpl(); |
35 | virtual ~LibMpeg3PluginImpl(); | 33 | virtual ~LibMpeg3PluginImpl(); |
36 | 34 | ||
37 | #ifndef QT_NO_COMPONENT | 35 | #ifndef QT_NO_COMPONENT |
38 | 36 | ||
39 | QRESULT queryInterface( const QUuid&, QUnknownInterface** ); | 37 | QRESULT queryInterface( const QUuid&, QUnknownInterface** ); |
40 | Q_REFCOUNT | 38 | Q_REFCOUNT |
41 | 39 | ||
42 | #endif | 40 | #endif |
43 | 41 | ||
44 | virtual MediaPlayerDecoder *decoder(); | 42 | virtual MediaPlayerDecoder *decoder(); |
45 | virtual MediaPlayerEncoder *encoder(); | 43 | virtual MediaPlayerEncoder *encoder(); |
46 | 44 | ||
47 | private: | 45 | private: |
48 | LibMpeg3Plugin *libmpeg3plugin; | 46 | LibMpeg3Plugin *libmpeg3plugin; |
49 | ulong ref; | 47 | ulong ref; |
50 | }; | 48 | }; |
51 | 49 | ||
52 | 50 | ||
53 | #endif | 51 | #endif |
54 | 52 | ||
diff --git a/core/multimedia/opieplayer/loopcontrol.cpp b/core/multimedia/opieplayer/loopcontrol.cpp index 1ae0059..dd466ed 100644 --- a/core/multimedia/opieplayer/loopcontrol.cpp +++ b/core/multimedia/opieplayer/loopcontrol.cpp | |||
@@ -1,468 +1,470 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | // L.J.Potter added changes Fri 02-15-2002 | ||
21 | |||
22 | #include <qpe/qpeapplication.h> | 20 | #include <qpe/qpeapplication.h> |
23 | |||
24 | #ifdef Q_WS_QWS | 21 | #ifdef Q_WS_QWS |
22 | |||
25 | #include <qpe/qcopenvelope_qws.h> | 23 | #include <qpe/qcopenvelope_qws.h> |
26 | #endif | 24 | #endif |
25 | #include <qpe/mediaplayerplugininterface.h> | ||
27 | #include <stdio.h> | 26 | #include <stdio.h> |
28 | #include <stdlib.h> | 27 | #include <stdlib.h> |
29 | #include <string.h> | 28 | #include <string.h> |
30 | #include <pthread.h> | 29 | #include <pthread.h> |
31 | #include <errno.h> | 30 | #include <errno.h> |
32 | #include <unistd.h> | 31 | #include <unistd.h> |
33 | #include "loopcontrol.h" | 32 | #include "loopcontrol.h" |
34 | #include "videowidget.h" | 33 | #include "videowidget.h" |
35 | #include "audiodevice.h" | 34 | #include "audiodevice.h" |
36 | #include "mediaplayerplugininterface.h" | ||
37 | #include "mediaplayerstate.h" | 35 | #include "mediaplayerstate.h" |
38 | 36 | ||
39 | 37 | ||
40 | extern VideoWidget *videoUI; // now only needed to tell it to play a frame | 38 | extern VideoWidget *videoUI; // now only needed to tell it to play a frame |
41 | extern MediaPlayerState *mediaPlayerState; | 39 | extern MediaPlayerState *mediaPlayerState; |
42 | 40 | ||
43 | 41 | ||
44 | //#define DecodeLoopDebug(x) qDebug x | 42 | //#define DecodeLoopDebug(x) qDebug x |
45 | #define DecodeLoopDebug(x) | 43 | #define DecodeLoopDebug(x) |
46 | 44 | ||
47 | 45 | ||
48 | static char *audioBuffer = NULL; | 46 | static char *audioBuffer = NULL; |
49 | static AudioDevice *audioDevice = NULL; | 47 | static AudioDevice *audioDevice = NULL; |
50 | static bool disabledSuspendScreenSaver = FALSE; | 48 | static bool disabledSuspendScreenSaver = FALSE; |
51 | static bool previousSuspendMode = FALSE; | 49 | static bool previousSuspendMode = FALSE; |
52 | 50 | ||
53 | 51 | ||
54 | pthread_t audio_tid; | 52 | pthread_taudio_tid; |
55 | pthread_attr_t audio_attr; | 53 | pthread_attr_t audio_attr; |
56 | bool threadOkToGo = FALSE; | 54 | bool threadOkToGo = FALSE; |
57 | 55 | ||
58 | 56 | ||
59 | class Mutex { | 57 | class Mutex { |
60 | public: | 58 | public: |
61 | Mutex() { | 59 | Mutex() { |
62 | pthread_mutexattr_t attr; | 60 | pthread_mutexattr_t attr; |
63 | pthread_mutexattr_init( &attr ); | 61 | pthread_mutexattr_init( &attr ); |
64 | pthread_mutex_init( &mutex, &attr ); | 62 | pthread_mutex_init( &mutex, &attr ); |
65 | pthread_mutexattr_destroy( &attr ); | 63 | pthread_mutexattr_destroy( &attr ); |
66 | } | 64 | } |
67 | 65 | ||
68 | ~Mutex() { | 66 | ~Mutex() { |
69 | pthread_mutex_destroy( &mutex ); | 67 | pthread_mutex_destroy( &mutex ); |
70 | } | 68 | } |
71 | 69 | ||
72 | void lock() { | 70 | void lock() { |
73 | pthread_mutex_lock( &mutex ); | 71 | pthread_mutex_lock( &mutex ); |
74 | } | 72 | } |
75 | 73 | ||
76 | void unlock() { | 74 | void unlock() { |
77 | pthread_mutex_unlock( &mutex ); | 75 | pthread_mutex_unlock( &mutex ); |
78 | } | 76 | } |
79 | private: | 77 | private: |
80 | pthread_mutex_t mutex; | 78 | pthread_mutex_t mutex; |
81 | }; | 79 | }; |
82 | 80 | ||
83 | 81 | ||
84 | void *startAudioThread( void *ptr ) { | 82 | void *startAudioThread( void *ptr ) { |
85 | LoopControl *mpegView = (LoopControl *)ptr; | 83 | LoopControl *mpegView = (LoopControl *)ptr; |
86 | while ( TRUE ) { | 84 | while ( TRUE ) { |
87 | if ( threadOkToGo && mpegView->moreAudio ) | 85 | if ( threadOkToGo && mpegView->moreAudio ) |
88 | mpegView->startAudio(); | 86 | mpegView->startAudio(); |
89 | else | 87 | else |
90 | usleep( 10000 ); // Semi-buzy-wait till we are playing again | 88 | usleep( 10000 ); // Semi-buzy-wait till we are playing again |
91 | } | 89 | } |
92 | return 0; | 90 | return 0; |
93 | } | 91 | } |
94 | 92 | ||
95 | 93 | ||
96 | Mutex *audioMutex; | 94 | Mutex *audioMutex; |
97 | 95 | ||
98 | 96 | ||
99 | LoopControl::LoopControl( QObject *parent, const char *name ) | 97 | LoopControl::LoopControl( QObject *parent, const char *name ) |
100 | : QObject( parent, name ) { | 98 | : QObject( parent, name ) { |
101 | isMuted = FALSE; | 99 | isMuted = FALSE; |
102 | connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( setMute(bool) ) ); | 100 | connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( setMute(bool) ) ); |
103 | 101 | ||
104 | audioMutex = new Mutex; | 102 | audioMutex = new Mutex; |
105 | 103 | ||
106 | pthread_attr_init(&audio_attr); | 104 | pthread_attr_init(&audio_attr); |
107 | #define USE_REALTIME_AUDIO_THREAD | 105 | |
108 | #ifdef USE_REALTIME_AUDIO_THREAD | 106 | if ( getuid() == 0 ) { |
109 | // Attempt to set it to real-time round robin | 107 | printf("true, guid = %i\n", getuid()); |
110 | if ( pthread_attr_setschedpolicy( &audio_attr, SCHED_RR ) == 0 ) { | 108 | |
111 | sched_param params; | 109 | // Attempt to set it to real-time round robin |
112 | params.sched_priority = 50; | 110 | if ( pthread_attr_setschedpolicy( &audio_attr, SCHED_RR ) == 0 ) { |
113 | pthread_attr_setschedparam(&audio_attr,¶ms); | 111 | sched_param params; |
114 | } else { | 112 | params.sched_priority = 50; |
115 | qDebug( "Error setting up a realtime thread, reverting to using a normal thread." ); | 113 | pthread_attr_setschedparam(&audio_attr,¶ms); |
116 | pthread_attr_destroy(&audio_attr); | 114 | } else { |
117 | pthread_attr_init(&audio_attr); | 115 | qDebug( "Error setting up a realtime thread, reverting to using a normal thread." ); |
116 | pthread_attr_destroy(&audio_attr); | ||
117 | pthread_attr_init(&audio_attr); | ||
118 | } | ||
118 | } | 119 | } |
119 | #endif | 120 | // printf("false, guid = %i\n", getuid()); |
121 | usleep( 100 ); | ||
122 | |||
120 | pthread_create(&audio_tid, &audio_attr, (void * (*)(void *))startAudioThread, this); | 123 | pthread_create(&audio_tid, &audio_attr, (void * (*)(void *))startAudioThread, this); |
121 | } | 124 | } |
122 | 125 | ||
123 | 126 | ||
124 | LoopControl::~LoopControl() { | 127 | LoopControl::~LoopControl() { |
125 | stop(); | 128 | stop(); |
126 | } | 129 | } |
127 | 130 | ||
128 | 131 | ||
129 | static long prev_frame = 0; | 132 | static long prev_frame = 0; |
130 | static int currentSample = 0; | 133 | static int currentSample = 0; |
131 | 134 | ||
132 | 135 | ||
133 | void LoopControl::timerEvent( QTimerEvent *te ) { | 136 | void LoopControl::timerEvent( QTimerEvent *te ) { |
134 | 137 | ||
135 | if ( te->timerId() == videoId ) | 138 | if ( te->timerId() == videoId ) |
136 | startVideo(); | 139 | startVideo(); |
137 | 140 | ||
138 | if ( te->timerId() == sliderId ) { | 141 | if ( te->timerId() == sliderId ) { |
139 | if ( hasAudioChannel && !hasVideoChannel && moreAudio ) { | 142 | if ( hasAudioChannel && !hasVideoChannel && moreAudio ) { |
140 | mediaPlayerState->updatePosition( audioSampleCounter ); | 143 | mediaPlayerState->updatePosition( audioSampleCounter ); |
141 | } else if ( hasVideoChannel && moreVideo ) { | 144 | } else if ( hasVideoChannel && moreVideo ) { |
142 | mediaPlayerState->updatePosition( current_frame ); | 145 | mediaPlayerState->updatePosition( current_frame ); |
143 | } | 146 | } |
144 | } | 147 | } |
145 | 148 | ||
146 | if ( !moreVideo && !moreAudio ) { | 149 | if ( !moreVideo && !moreAudio ) { |
147 | mediaPlayerState->setPlaying( FALSE ); | 150 | mediaPlayerState->setPlaying( FALSE ); |
148 | mediaPlayerState->setNext(); | 151 | mediaPlayerState->setNext(); |
149 | } | 152 | } |
150 | } | 153 | } |
151 | 154 | ||
152 | 155 | ||
153 | void LoopControl::setPosition( long pos ) { | 156 | void LoopControl::setPosition( long pos ) { |
154 | audioMutex->lock(); | 157 | audioMutex->lock(); |
155 | 158 | ||
156 | if ( hasVideoChannel && hasAudioChannel ) { | 159 | if ( hasVideoChannel && hasAudioChannel ) { |
157 | playtime.restart(); | 160 | playtime.restart(); |
158 | playtime = playtime.addMSecs( long((double)-pos * 1000.0 / framerate) ); | 161 | playtime = playtime.addMSecs( long((double)-pos * 1000.0 / framerate) ); |
159 | current_frame = pos + 1; | 162 | current_frame = pos + 1; |
160 | mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); | 163 | mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); |
161 | prev_frame = current_frame - 1; | 164 | prev_frame = current_frame - 1; |
162 | currentSample = (int)( (double)current_frame * freq / framerate ); | 165 | currentSample = (int)( (double)current_frame * freq / framerate ); |
163 | mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream ); | 166 | mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream ); |
164 | audioSampleCounter = currentSample - 1; | 167 | audioSampleCounter = currentSample - 1; |
165 | } else if ( hasVideoChannel ) { | 168 | } else if ( hasVideoChannel ) { |
166 | playtime.restart(); | 169 | playtime.restart(); |
167 | playtime = playtime.addMSecs( long((double)-pos * 1000.0 / framerate) ); | 170 | playtime = playtime.addMSecs( long((double)-pos * 1000.0 / framerate) ); |
168 | current_frame = pos + 1; | 171 | current_frame = pos + 1; |
169 | mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); | 172 | mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); |
170 | prev_frame = current_frame - 1; | 173 | prev_frame = current_frame - 1; |
171 | } else if ( hasAudioChannel ) { | 174 | } else if ( hasAudioChannel ) { |
172 | playtime.restart(); | 175 | playtime.restart(); |
173 | playtime = playtime.addMSecs( long((double)-pos * 1000.0 / freq) ); | 176 | playtime = playtime.addMSecs( long((double)-pos * 1000.0 / freq) ); |
174 | currentSample = pos + 1; | 177 | currentSample = pos + 1; |
175 | mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream ); | 178 | mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream ); |
176 | audioSampleCounter = currentSample - 1; | 179 | audioSampleCounter = currentSample - 1; |
177 | } | 180 | } |
178 | 181 | ||
179 | audioMutex->unlock(); | 182 | audioMutex->unlock(); |
180 | } | 183 | } |
181 | 184 | ||
182 | 185 | ||
183 | void LoopControl::startVideo() { | 186 | void LoopControl::startVideo() { |
184 | 187 | ||
185 | if ( moreVideo ) { | 188 | if ( moreVideo ) { |
186 | 189 | ||
187 | if ( mediaPlayerState->curDecoder() ) { | 190 | if ( mediaPlayerState->curDecoder() ) { |
188 | 191 | ||
189 | if ( hasAudioChannel && !isMuted ) { | 192 | if ( hasAudioChannel && !isMuted ) { |
190 | 193 | ||
191 | current_frame = long( playtime.elapsed() * framerate / 1000 ); | 194 | current_frame = long( playtime.elapsed() * framerate / 1000 ); |
192 | 195 | ||
193 | if ( prev_frame != -1 && current_frame <= prev_frame ) | 196 | if ( prev_frame != -1 && current_frame <= prev_frame ) |
194 | return; | 197 | return; |
195 | 198 | ||
196 | } else { | 199 | } else { |
197 | // Don't skip | 200 | // Don't skip |
198 | current_frame++; | 201 | current_frame++; |
199 | } | 202 | } |
200 | 203 | ||
201 | if ( prev_frame == -1 || current_frame > prev_frame ) { | 204 | if ( prev_frame == -1 || current_frame > prev_frame ) { |
202 | if ( current_frame > prev_frame + 1 ) { | 205 | if ( current_frame > prev_frame + 1 ) { |
203 | mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); | 206 | mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); |
204 | } | 207 | } |
205 | moreVideo = videoUI->playVideo(); | 208 | moreVideo = videoUI->playVideo(); |
206 | prev_frame = current_frame; | 209 | prev_frame = current_frame; |
207 | } | 210 | } |
208 | 211 | ||
209 | } else { | 212 | } else { |
210 | 213 | ||
211 | moreVideo = FALSE; | 214 | moreVideo = FALSE; |
212 | killTimer( videoId ); | 215 | killTimer( videoId ); |
213 | 216 | ||
214 | } | 217 | } |
215 | 218 | ||
216 | } | 219 | } |
217 | } | 220 | } |
218 | 221 | ||
219 | 222 | ||
220 | void LoopControl::startAudio() { | 223 | void LoopControl::startAudio() { |
221 | 224 | ||
222 | audioMutex->lock(); | 225 | audioMutex->lock(); |
223 | 226 | ||
224 | if ( moreAudio ) { | 227 | if ( moreAudio ) { |
225 | 228 | ||
226 | if ( !isMuted && mediaPlayerState->curDecoder() ) { | 229 | if ( !isMuted && mediaPlayerState->curDecoder() ) { |
227 | 230 | ||
228 | currentSample = audioSampleCounter + 1; | 231 | currentSample = audioSampleCounter + 1; |
229 | 232 | ||
230 | if ( currentSample != audioSampleCounter + 1 ) | 233 | if ( currentSample != audioSampleCounter + 1 ) |
231 | qDebug("out of sync with decoder %i %i", currentSample, audioSampleCounter); | 234 | qDebug("out of sync with decoder %i %i", currentSample, audioSampleCounter); |
232 | 235 | ||
233 | long samplesRead = 0; | 236 | long samplesRead = 0; |
234 | bool readOk=mediaPlayerState->curDecoder()->audioReadSamples( (short*)audioBuffer, channels, 1024, samplesRead, stream ); | 237 | mediaPlayerState->curDecoder()->audioReadSamples( (short*)audioBuffer, channels, 1024, samplesRead, stream ); |
235 | long sampleWeShouldBeAt = long( playtime.elapsed() ) * freq / 1000; | 238 | long sampleWeShouldBeAt = long( playtime.elapsed() ) * freq / 1000; |
236 | long sampleWaitTime = currentSample - sampleWeShouldBeAt; | 239 | long sampleWaitTime = currentSample - sampleWeShouldBeAt; |
237 | 240 | ||
238 | if ( ( sampleWaitTime > 2000 ) && ( sampleWaitTime < 20000 ) ) { | 241 | if ( ( sampleWaitTime > 2000 ) && ( sampleWaitTime < 20000 ) ) { |
239 | usleep( (long)((double)sampleWaitTime * 1000000.0 / freq) ); | 242 | usleep( (long)((double)sampleWaitTime * 1000000.0 / freq) ); |
240 | } | 243 | } else if ( sampleWaitTime <= -5000 ) { |
241 | else if ( sampleWaitTime <= -5000 ) { | 244 | qDebug("need to catch up by: %li (%i,%li)", -sampleWaitTime, currentSample, sampleWeShouldBeAt ); |
242 | qDebug("need to catch up by: %li (%i,%li)", -sampleWaitTime, currentSample, sampleWeShouldBeAt ); | 245 | //mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream ); |
243 | //mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream ); | 246 | currentSample = sampleWeShouldBeAt; |
244 | currentSample = sampleWeShouldBeAt; | 247 | } |
245 | } | ||
246 | 248 | ||
247 | audioDevice->write( audioBuffer, samplesRead * 2 * channels ); | 249 | audioDevice->write( audioBuffer, samplesRead * 2 * channels ); |
248 | audioSampleCounter = currentSample + samplesRead - 1; | 250 | audioSampleCounter = currentSample + samplesRead - 1; |
249 | 251 | ||
250 | moreAudio = readOk && (audioSampleCounter <= total_audio_samples); | 252 | moreAudio = audioSampleCounter <= total_audio_samples; |
251 | 253 | ||
252 | } else { | 254 | } else { |
253 | 255 | ||
254 | moreAudio = FALSE; | 256 | moreAudio = FALSE; |
255 | 257 | ||
256 | } | 258 | } |
257 | 259 | ||
258 | } | 260 | } |
259 | 261 | ||
260 | audioMutex->unlock(); | 262 | audioMutex->unlock(); |
261 | } | 263 | } |
262 | 264 | ||
263 | 265 | ||
264 | void LoopControl::killTimers() { | 266 | void LoopControl::killTimers() { |
265 | 267 | ||
266 | audioMutex->lock(); | 268 | audioMutex->lock(); |
267 | 269 | ||
268 | if ( hasVideoChannel ) | 270 | if ( hasVideoChannel ) |
269 | killTimer( videoId ); | 271 | killTimer( videoId ); |
270 | killTimer( sliderId ); | 272 | killTimer( sliderId ); |
271 | threadOkToGo = FALSE; | 273 | threadOkToGo = FALSE; |
272 | 274 | ||
273 | audioMutex->unlock(); | 275 | audioMutex->unlock(); |
274 | } | 276 | } |
275 | 277 | ||
276 | 278 | ||
277 | void LoopControl::startTimers() { | 279 | void LoopControl::startTimers() { |
278 | 280 | ||
279 | audioMutex->lock(); | 281 | audioMutex->lock(); |
280 | 282 | ||
281 | moreVideo = FALSE; | 283 | moreVideo = FALSE; |
282 | moreAudio = FALSE; | 284 | moreAudio = FALSE; |
283 | 285 | ||
284 | if ( hasVideoChannel ) { | 286 | if ( hasVideoChannel ) { |
285 | moreVideo = TRUE; | 287 | moreVideo = TRUE; |
286 | int mSecsBetweenFrames = (int)(100 / framerate); // 10% of the real value | 288 | int mSecsBetweenFrames = (int)(100 / framerate); // 10% of the real value |
287 | videoId = startTimer( mSecsBetweenFrames ); | 289 | videoId = startTimer( mSecsBetweenFrames ); |
288 | } | 290 | } |
289 | 291 | ||
290 | if ( hasAudioChannel ) { | 292 | if ( hasAudioChannel ) { |
291 | moreAudio = TRUE; | 293 | moreAudio = TRUE; |
292 | threadOkToGo = TRUE; | 294 | threadOkToGo = TRUE; |
293 | } | 295 | } |
294 | 296 | ||
295 | sliderId = startTimer( 300 ); // update slider every 1/3 second | 297 | sliderId = startTimer( 300 ); // update slider every 1/3 second |
296 | 298 | ||
297 | audioMutex->unlock(); | 299 | audioMutex->unlock(); |
298 | } | 300 | } |
299 | 301 | ||
300 | 302 | ||
301 | void LoopControl::setPaused( bool pause ) { | 303 | void LoopControl::setPaused( bool pause ) { |
302 | 304 | ||
303 | if ( !mediaPlayerState->curDecoder() || !mediaPlayerState->curDecoder()->isOpen() ) | 305 | if ( !mediaPlayerState->curDecoder() || !mediaPlayerState->curDecoder()->isOpen() ) |
304 | return; | 306 | return; |
305 | 307 | ||
306 | if ( pause ) { | 308 | if ( pause ) { |
307 | killTimers(); | 309 | killTimers(); |
308 | } else { | 310 | } else { |
309 | // Force an update of the position | 311 | // Force an update of the position |
310 | mediaPlayerState->setPosition( mediaPlayerState->position() + 1 ); | 312 | mediaPlayerState->setPosition( mediaPlayerState->position() + 1 ); |
311 | mediaPlayerState->setPosition( mediaPlayerState->position() - 1 ); | 313 | mediaPlayerState->setPosition( mediaPlayerState->position() - 1 ); |
312 | // Just like we never stopped | 314 | // Just like we never stopped |
313 | startTimers(); | 315 | startTimers(); |
314 | } | 316 | } |
315 | } | 317 | } |
316 | 318 | ||
317 | 319 | ||
318 | void LoopControl::stop( bool willPlayAgainShortly ) { | 320 | void LoopControl::stop( bool willPlayAgainShortly ) { |
319 | 321 | ||
320 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 322 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
321 | if ( !willPlayAgainShortly && disabledSuspendScreenSaver ) { | 323 | if ( !willPlayAgainShortly && disabledSuspendScreenSaver ) { |
322 | disabledSuspendScreenSaver = FALSE; | 324 | disabledSuspendScreenSaver = FALSE; |
323 | // Re-enable the suspend mode | 325 | // Re-enable the suspend mode |
324 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 326 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
325 | } | 327 | } |
326 | #endif | 328 | #endif |
327 | 329 | ||
328 | if ( mediaPlayerState->curDecoder() && mediaPlayerState->curDecoder()->isOpen() ) { | 330 | if ( mediaPlayerState->curDecoder() && mediaPlayerState->curDecoder()->isOpen() ) { |
329 | 331 | ||
330 | killTimers(); | 332 | killTimers(); |
331 | 333 | ||
332 | audioMutex->lock(); | 334 | audioMutex->lock(); |
333 | 335 | ||
334 | mediaPlayerState->curDecoder()->close(); | 336 | mediaPlayerState->curDecoder()->close(); |
335 | 337 | ||
336 | if ( audioDevice ) { | 338 | if ( audioDevice ) { |
337 | delete audioDevice; | 339 | delete audioDevice; |
338 | delete audioBuffer; | 340 | delete audioBuffer; |
339 | audioDevice = 0; | 341 | audioDevice = 0; |
340 | audioBuffer = 0; | 342 | audioBuffer = 0; |
341 | } | 343 | } |
342 | 344 | ||
343 | audioMutex->unlock(); | 345 | audioMutex->unlock(); |
344 | 346 | ||
345 | } | 347 | } |
346 | } | 348 | } |
347 | 349 | ||
348 | 350 | ||
349 | bool LoopControl::init( const QString& filename ) { | 351 | bool LoopControl::init( const QString& filename ) { |
350 | stop(); | 352 | stop(); |
351 | 353 | ||
352 | audioMutex->lock(); | 354 | audioMutex->lock(); |
353 | 355 | ||
354 | fileName = filename; | 356 | fileName = filename; |
355 | stream = 0; // only play stream 0 for now | 357 | stream = 0; // only play stream 0 for now |
356 | current_frame = total_video_frames = total_audio_samples = 0; | 358 | current_frame = total_video_frames = total_audio_samples = 0; |
357 | 359 | ||
358 | qDebug( "Using the %s decoder", mediaPlayerState->curDecoder()->pluginName() ); | 360 | qDebug( "Using the %s decoder", mediaPlayerState->curDecoder()->pluginName() ); |
359 | 361 | ||
360 | // ### Hack to use libmpeg3plugin to get the number of audio samples if we are using the libmad plugin | 362 | // ### Hack to use libmpeg3plugin to get the number of audio samples if we are using the libmad plugin |
361 | if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibMadPlugin") ) { | 363 | if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibMadPlugin") ) { |
362 | if ( mediaPlayerState->libMpeg3Decoder() && mediaPlayerState->libMpeg3Decoder()->open( filename ) ) { | 364 | if ( mediaPlayerState->libMpeg3Decoder() && mediaPlayerState->libMpeg3Decoder()->open( filename ) ) { |
363 | total_audio_samples = mediaPlayerState->libMpeg3Decoder()->audioSamples( 0 ); | 365 | total_audio_samples = mediaPlayerState->libMpeg3Decoder()->audioSamples( 0 ); |
364 | mediaPlayerState->libMpeg3Decoder()->close(); | 366 | mediaPlayerState->libMpeg3Decoder()->close(); |
365 | } | 367 | } |
366 | } | 368 | } |
367 | 369 | ||
368 | if ( !mediaPlayerState->curDecoder()|| !mediaPlayerState->curDecoder()->open( filename ) ) { | 370 | if ( !mediaPlayerState->curDecoder()|| !mediaPlayerState->curDecoder()->open( filename ) ) { |
369 | audioMutex->unlock(); | 371 | audioMutex->unlock(); |
370 | return FALSE; | 372 | return FALSE; |
371 | } | 373 | } |
372 | 374 | ||
373 | hasAudioChannel = mediaPlayerState->curDecoder()->audioStreams() > 0; | 375 | hasAudioChannel = mediaPlayerState->curDecoder()->audioStreams() > 0; |
374 | hasVideoChannel = mediaPlayerState->curDecoder()->videoStreams() > 0; | 376 | hasVideoChannel = mediaPlayerState->curDecoder()->videoStreams() > 0; |
375 | 377 | ||
376 | if ( hasAudioChannel ) { | 378 | if ( hasAudioChannel ) { |
377 | int astream = 0; | 379 | int astream = 0; |
378 | 380 | ||
379 | channels = mediaPlayerState->curDecoder()->audioChannels( astream ); | 381 | channels = mediaPlayerState->curDecoder()->audioChannels( astream ); |
380 | qDebug( "LC- channels = %d", channels ); | 382 | DecodeLoopDebug(( "channels = %d\n", channels )); |
381 | 383 | ||
382 | if ( !total_audio_samples ) | 384 | if ( !total_audio_samples ) |
383 | total_audio_samples = mediaPlayerState->curDecoder()->audioSamples( astream ); | 385 | total_audio_samples = mediaPlayerState->curDecoder()->audioSamples( astream ); |
384 | 386 | ||
385 | // total_audio_samples += 1000; | 387 | total_audio_samples += 1000; |
386 | 388 | ||
387 | mediaPlayerState->setLength( total_audio_samples ); | 389 | mediaPlayerState->setLength( total_audio_samples ); |
388 | 390 | ||
389 | freq = mediaPlayerState->curDecoder()->audioFrequency( astream ); | 391 | freq = mediaPlayerState->curDecoder()->audioFrequency( astream ); |
390 | qDebug( "LC- frequency = %d", freq ); | 392 | DecodeLoopDebug(( "frequency = %d\n", freq )); |
391 | 393 | ||
392 | audioSampleCounter = 0; | 394 | audioSampleCounter = 0; |
393 | 395 | ||
394 | int bits_per_sample = mediaPlayerState->curDecoder()->audioBitsPerSample( astream); | 396 | static const int bytes_per_sample = 2; //16 bit |
395 | 397 | ||
396 | audioDevice = new AudioDevice( freq, channels, bits_per_sample); | 398 | audioDevice = new AudioDevice( freq, channels, bytes_per_sample ); |
397 | audioBuffer = new char[ audioDevice->bufferSize() ]; | 399 | audioBuffer = new char[ audioDevice->bufferSize() ]; |
398 | channels = audioDevice->channels(); | 400 | channels = audioDevice->channels(); |
399 | 401 | ||
400 | //### must check which frequency is actually used. | 402 | //### must check which frequency is actually used. |
401 | static const int size = 1; | 403 | static const int size = 1; |
402 | short int buf[size]; | 404 | short int buf[size]; |
403 | long samplesRead = 0; | 405 | long samplesRead = 0; |
404 | mediaPlayerState->curDecoder()->audioReadSamples( buf, channels, size, samplesRead, stream ); | 406 | mediaPlayerState->curDecoder()->audioReadSamples( buf, channels, size, samplesRead, stream ); |
405 | } | 407 | } |
406 | 408 | ||
407 | if ( hasVideoChannel ) { | 409 | if ( hasVideoChannel ) { |
408 | total_video_frames = mediaPlayerState->curDecoder()->videoFrames( stream ); | 410 | total_video_frames = mediaPlayerState->curDecoder()->videoFrames( stream ); |
409 | 411 | ||
410 | mediaPlayerState->setLength( total_video_frames ); | 412 | mediaPlayerState->setLength( total_video_frames ); |
411 | 413 | ||
412 | framerate = mediaPlayerState->curDecoder()->videoFrameRate( stream ); | 414 | framerate = mediaPlayerState->curDecoder()->videoFrameRate( stream ); |
413 | DecodeLoopDebug(( "Frame rate %g total %ld", framerate, total_video_frames )); | 415 | DecodeLoopDebug(( "Frame rate %g total %ld", framerate, total_video_frames )); |
414 | 416 | ||
415 | if ( framerate <= 1.0 ) { | 417 | if ( framerate <= 1.0 ) { |
416 | DecodeLoopDebug(( "Crazy frame rate, resetting to sensible" )); | 418 | DecodeLoopDebug(( "Crazy frame rate, resetting to sensible" )); |
417 | framerate = 25; | 419 | framerate = 25; |
418 | } | 420 | } |
419 | 421 | ||
420 | if ( total_video_frames == 1 ) { | 422 | if ( total_video_frames == 1 ) { |
421 | DecodeLoopDebug(( "Cannot seek to frame" )); | 423 | DecodeLoopDebug(( "Cannot seek to frame" )); |
422 | } | 424 | } |
423 | 425 | ||
424 | } | 426 | } |
425 | 427 | ||
426 | current_frame = 0; | 428 | current_frame = 0; |
427 | prev_frame = -1; | 429 | prev_frame = -1; |
428 | 430 | ||
429 | connect( mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( setPosition( long ) ) ); | 431 | connect( mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( setPosition( long ) ) ); |
430 | connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( setPaused( bool ) ) ); | 432 | connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( setPaused( bool ) ) ); |
431 | 433 | ||
432 | audioMutex->unlock(); | 434 | audioMutex->unlock(); |
433 | 435 | ||
434 | return TRUE; | 436 | return TRUE; |
435 | } | 437 | } |
436 | 438 | ||
437 | 439 | ||
438 | void LoopControl::play() { | 440 | void LoopControl::play() { |
439 | 441 | ||
440 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 442 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
441 | if ( !disabledSuspendScreenSaver || previousSuspendMode != hasVideoChannel ) { | 443 | if ( !disabledSuspendScreenSaver || previousSuspendMode != hasVideoChannel ) { |
442 | disabledSuspendScreenSaver = TRUE; | 444 | disabledSuspendScreenSaver = TRUE; |
443 | previousSuspendMode = hasVideoChannel; | 445 | previousSuspendMode = hasVideoChannel; |
444 | // Stop the screen from blanking and power saving state | 446 | // Stop the screen from blanking and power saving state |
445 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) | 447 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) |
446 | << ( hasVideoChannel ? QPEApplication::Disable : QPEApplication::DisableSuspend ); | 448 | << ( hasVideoChannel ? QPEApplication::Disable : QPEApplication::DisableSuspend ); |
447 | } | 449 | } |
448 | #endif | 450 | #endif |
449 | 451 | ||
450 | playtime.start(); | 452 | playtime.start(); |
451 | startTimers(); | 453 | startTimers(); |
452 | } | 454 | } |
453 | 455 | ||
454 | 456 | ||
455 | void LoopControl::setMute( bool on ) { | 457 | void LoopControl::setMute( bool on ) { |
456 | if ( on != isMuted ) { | 458 | if ( on != isMuted ) { |
457 | isMuted = on; | 459 | isMuted = on; |
458 | if ( !on ) { | 460 | if ( !on ) { |
459 | // Force an update of the position | 461 | // Force an update of the position |
460 | mediaPlayerState->setPosition( mediaPlayerState->position() + 1 ); | 462 | mediaPlayerState->setPosition( mediaPlayerState->position() + 1 ); |
461 | mediaPlayerState->setPosition( mediaPlayerState->position() - 1 ); | 463 | mediaPlayerState->setPosition( mediaPlayerState->position() - 1 ); |
462 | // Resume playing audio | 464 | // Resume playing audio |
463 | moreAudio = TRUE; | 465 | moreAudio = TRUE; |
464 | } | 466 | } |
465 | } | 467 | } |
466 | } | 468 | } |
467 | 469 | ||
468 | 470 | ||
diff --git a/core/multimedia/opieplayer/loopcontrol.h b/core/multimedia/opieplayer/loopcontrol.h index fc7d316..3191259 100644 --- a/core/multimedia/opieplayer/loopcontrol.h +++ b/core/multimedia/opieplayer/loopcontrol.h | |||
@@ -1,57 +1,54 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | // L.J.Potter added changes Fri 02-15-2002 | ||
21 | |||
22 | #ifndef MPEGVIEW_H | 20 | #ifndef MPEGVIEW_H |
23 | #define MPEGVIEW_H | 21 | #define MPEGVIEW_H |
24 | 22 | ||
25 | |||
26 | #include <qwidget.h> | 23 | #include <qwidget.h> |
27 | #include <qdatetime.h> | 24 | #include <qdatetime.h> |
28 | 25 | ||
29 | 26 | ||
30 | class LoopControl : public QObject { | 27 | class LoopControl : public QObject { |
31 | Q_OBJECT | 28 | Q_OBJECT |
32 | public: | 29 | public: |
33 | LoopControl( QObject *parent, const char *name ); | 30 | LoopControl( QObject *parent, const char *name ); |
34 | ~LoopControl(); | 31 | ~LoopControl(); |
35 | 32 | ||
36 | bool init( const QString& filename ); | 33 | bool init( const QString& filename ); |
37 | 34 | ||
38 | bool hasVideo() const { return hasVideoChannel; } | 35 | bool hasVideo() const { return hasVideoChannel; } |
39 | bool hasAudio() const { return hasAudioChannel; } | 36 | bool hasAudio() const { return hasAudioChannel; } |
40 | 37 | ||
41 | long totalPlaytime() { return (long)(hasVideoChannel ? total_video_frames / framerate : total_audio_samples / freq); } | 38 | long totalPlaytime() { return (long)(hasVideoChannel ? total_video_frames / framerate : total_audio_samples / freq); } |
42 | 39 | ||
43 | // These are public to run them from global functions needed to start threads | 40 | // These are public to run them from global functions needed to start threads |
44 | // Otherwise they would be private | 41 | // Otherwise they would be private |
45 | void startAudio(); | 42 | void startAudio(); |
46 | void startVideo(); | 43 | void startVideo(); |
47 | bool moreAudio; | 44 | bool moreAudio; |
48 | bool moreVideo; | 45 | bool moreVideo; |
49 | public slots: | 46 | public slots: |
50 | void play(); | 47 | void play(); |
51 | void stop( bool willPlayAgainShortly = FALSE ); | 48 | void stop( bool willPlayAgainShortly = FALSE ); |
52 | 49 | ||
53 | void setMute( bool ); | 50 | void setMute( bool ); |
54 | void setPaused( bool ); | 51 | void setPaused( bool ); |
55 | void setPosition( long ); | 52 | void setPosition( long ); |
56 | 53 | ||
57 | signals: | 54 | signals: |
diff --git a/core/multimedia/opieplayer/loopcontrol_threaded.cpp b/core/multimedia/opieplayer/loopcontrol_threaded.cpp index 2e49bb7..eb89b85 100644 --- a/core/multimedia/opieplayer/loopcontrol_threaded.cpp +++ b/core/multimedia/opieplayer/loopcontrol_threaded.cpp | |||
@@ -1,61 +1,62 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #define _REENTRANT | 21 | #define _REENTRANT |
22 | 22 | ||
23 | |||
23 | #include <qpe/qpeapplication.h> | 24 | #include <qpe/qpeapplication.h> |
24 | #include <qimage.h> | 25 | #include <qimage.h> |
25 | #include <qpainter.h> | 26 | #include <qpainter.h> |
26 | #ifdef Q_WS_QWS | 27 | #ifdef Q_WS_QWS |
27 | #include <qpe/qcopenvelope_qws.h> | 28 | #include <qpe/qcopenvelope_qws.h> |
28 | #endif | 29 | #endif |
29 | #include "mediaplayerplugininterface.h" | 30 | #include <qpe/mediaplayerplugininterface.h> |
30 | #include <stdio.h> | 31 | #include <stdio.h> |
31 | #include <stdlib.h> | 32 | #include <stdlib.h> |
32 | #include <string.h> | 33 | #include <string.h> |
33 | #include <time.h> | 34 | #include <time.h> |
34 | #include <unistd.h> | 35 | #include <unistd.h> |
35 | #include <pthread.h> | 36 | #include <pthread.h> |
36 | #include "loopcontrol.h" | 37 | #include "loopcontrol.h" |
37 | #include "audiodevice.h" | 38 | #include "audiodevice.h" |
38 | #include "videowidget.h" | 39 | #include "videowidget.h" |
39 | #include "audiowidget.h" | 40 | #include "audiowidget.h" |
40 | #include "mediaplayerstate.h" | 41 | #include "mediaplayerstate.h" |
41 | 42 | ||
42 | 43 | ||
43 | #if defined(QT_QWS_CUSTOM) || defined(QT_QWS_IPAQ) | 44 | #if defined(QT_QWS_CUSTOM) || defined(QT_QWS_IPAQ) |
44 | #define USE_REALTIME_AUDIO_THREAD | 45 | #define USE_REALTIME_AUDIO_THREAD |
45 | #endif | 46 | #endif |
46 | 47 | ||
47 | 48 | ||
48 | extern VideoWidget *videoUI; // now only needed to tell it to play a frame | 49 | extern VideoWidget *videoUI; // now only needed to tell it to play a frame |
49 | extern MediaPlayerState *mediaPlayerState; | 50 | extern MediaPlayerState *mediaPlayerState; |
50 | 51 | ||
51 | 52 | ||
52 | #define DecodeLoopDebug(x) qDebug x | 53 | #define DecodeLoopDebug(x) qDebug x |
53 | //#define DecodeLoopDebug(x) | 54 | //#define DecodeLoopDebug(x) |
54 | 55 | ||
55 | 56 | ||
56 | static char *audioBuffer = NULL; | 57 | static char *audioBuffer = NULL; |
57 | static AudioDevice *audioDevice = NULL; | 58 | static AudioDevice *audioDevice = NULL; |
58 | static bool disabledSuspendScreenSaver = FALSE; | 59 | static bool disabledSuspendScreenSaver = FALSE; |
59 | 60 | ||
60 | 61 | ||
61 | pthread_tvideo_tid; | 62 | pthread_tvideo_tid; |
diff --git a/core/multimedia/opieplayer/loopcontrol_threaded.h b/core/multimedia/opieplayer/loopcontrol_threaded.h index 9a009d1..ced6ac8 100644 --- a/core/multimedia/opieplayer/loopcontrol_threaded.h +++ b/core/multimedia/opieplayer/loopcontrol_threaded.h | |||
@@ -1,55 +1,56 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef MPEGVIEW_H | 20 | #ifndef MPEGVIEW_H |
21 | #define MPEGVIEW_H | 21 | #define MPEGVIEW_H |
22 | 22 | ||
23 | 23 | ||
24 | |||
24 | #include <qwidget.h> | 25 | #include <qwidget.h> |
25 | #include <qdatetime.h> | 26 | #include <qdatetime.h> |
26 | 27 | ||
27 | 28 | ||
28 | class LoopControl : public QObject { | 29 | class LoopControl : public QObject { |
29 | Q_OBJECT | 30 | Q_OBJECT |
30 | public: | 31 | public: |
31 | LoopControl( QObject *parent, const char *name ); | 32 | LoopControl( QObject *parent, const char *name ); |
32 | ~LoopControl(); | 33 | ~LoopControl(); |
33 | 34 | ||
34 | bool init( const QString& filename ); | 35 | bool init( const QString& filename ); |
35 | 36 | ||
36 | bool hasVideo() const { return hasVideoChannel; } | 37 | bool hasVideo() const { return hasVideoChannel; } |
37 | bool hasAudio() const { return hasAudioChannel; } | 38 | bool hasAudio() const { return hasAudioChannel; } |
38 | 39 | ||
39 | long totalPlaytime() { return (long)(hasVideoChannel ? total_video_frames / framerate : total_audio_samples / freq); } | 40 | long totalPlaytime() { return (long)(hasVideoChannel ? total_video_frames / framerate : total_audio_samples / freq); } |
40 | 41 | ||
41 | // These are public to run them from global functions needed to start threads | 42 | // These are public to run them from global functions needed to start threads |
42 | // Otherwise they would be private | 43 | // Otherwise they would be private |
43 | void startAudio(); | 44 | void startAudio(); |
44 | void startVideo(); | 45 | void startVideo(); |
45 | public slots: | 46 | public slots: |
46 | void play(); | 47 | void play(); |
47 | void stop( bool willPlayAgainShortly = FALSE ); | 48 | void stop( bool willPlayAgainShortly = FALSE ); |
48 | 49 | ||
49 | void setMute( bool ); | 50 | void setMute( bool ); |
50 | void setPaused( bool ); | 51 | void setPaused( bool ); |
51 | void setPosition( long ); | 52 | void setPosition( long ); |
52 | 53 | ||
53 | signals: | 54 | signals: |
54 | void positionChanged( long, long ); | 55 | void positionChanged( long, long ); |
55 | void playFinished(); | 56 | void playFinished(); |
diff --git a/core/multimedia/opieplayer/main.cpp b/core/multimedia/opieplayer/main.cpp index 9f7ef73..720a1ca 100644 --- a/core/multimedia/opieplayer/main.cpp +++ b/core/multimedia/opieplayer/main.cpp | |||
@@ -1,57 +1,56 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include <qpe/qpeapplication.h> | 20 | #include <qpe/qpeapplication.h> |
21 | #include "mediaplayerstate.h" | 21 | #include "mediaplayerstate.h" |
22 | #include "playlistwidget.h" | 22 | #include "playlistwidget.h" |
23 | #include "audiowidget.h" | 23 | #include "audiowidget.h" |
24 | #include "videowidget.h" | 24 | #include "videowidget.h" |
25 | #include "loopcontrol.h" | 25 | #include "loopcontrol.h" |
26 | #include "mediaplayer.h" | 26 | #include "mediaplayer.h" |
27 | 27 | ||
28 | |||
29 | MediaPlayerState *mediaPlayerState; | 28 | MediaPlayerState *mediaPlayerState; |
30 | PlayListWidget *playList; | 29 | PlayListWidget *playList; |
31 | AudioWidget *audioUI; | 30 | AudioWidget *audioUI; |
32 | VideoWidget *videoUI; | 31 | VideoWidget *videoUI; |
33 | LoopControl *loopControl; | 32 | LoopControl *loopControl; |
34 | 33 | ||
35 | 34 | ||
36 | int main(int argc, char **argv) { | 35 | int main(int argc, char **argv) { |
37 | QPEApplication a(argc,argv); | 36 | QPEApplication a(argc,argv); |
38 | 37 | ||
39 | MediaPlayerState st( 0, "mediaPlayerState" ); | 38 | MediaPlayerState st( 0, "mediaPlayerState" ); |
40 | mediaPlayerState = &st; | 39 | mediaPlayerState = &st; |
41 | PlayListWidget pl( 0, "playList" ); | 40 | PlayListWidget pl( 0, "playList" ); |
42 | playList = &pl; | 41 | playList = &pl; |
43 | AudioWidget aw( 0, "audioUI" ); | 42 | AudioWidget aw( 0, "audioUI" ); |
44 | audioUI = &aw; | 43 | audioUI = &aw; |
45 | VideoWidget vw( 0, "videoUI" ); | 44 | VideoWidget vw( 0, "videoUI" ); |
46 | videoUI = &vw; | 45 | videoUI = &vw; |
47 | LoopControl lc( 0, "loopControl" ); | 46 | LoopControl lc( 0, "loopControl" ); |
48 | loopControl = &lc; | 47 | loopControl = &lc; |
49 | MediaPlayer mp( 0, "mediaPlayer" ); | 48 | MediaPlayer mp( 0, "mediaPlayer" ); |
50 | 49 | ||
51 | pl.setCaption( MediaPlayer::tr("Opie Player") ); | 50 | pl.setCaption( MediaPlayer::tr("Media Player") ); |
52 | a.showMainDocumentWidget(&pl); | 51 | a.showMainDocumentWidget(&pl); |
53 | 52 | ||
54 | return a.exec(); | 53 | return a.exec(); |
55 | } | 54 | } |
56 | 55 | ||
57 | 56 | ||
diff --git a/core/multimedia/opieplayer/mediaplayer.cpp b/core/multimedia/opieplayer/mediaplayer.cpp index 3d8f76c..ce42c2c 100644 --- a/core/multimedia/opieplayer/mediaplayer.cpp +++ b/core/multimedia/opieplayer/mediaplayer.cpp | |||
@@ -1,51 +1,52 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | |||
20 | #include <qpe/qpeapplication.h> | 21 | #include <qpe/qpeapplication.h> |
21 | #include <qpe/qlibrary.h> | 22 | #include <qpe/qlibrary.h> |
22 | #include <qpe/resource.h> | 23 | #include <qpe/resource.h> |
23 | #include <qpe/config.h> | 24 | #include <qpe/config.h> |
24 | 25 | ||
25 | #include <qmainwindow.h> | 26 | #include <qmainwindow.h> |
26 | #include <qmessagebox.h> | 27 | #include <qmessagebox.h> |
27 | #include <qwidgetstack.h> | 28 | #include <qwidgetstack.h> |
28 | #include <qfile.h> | 29 | #include <qfile.h> |
29 | 30 | ||
30 | #include "mediaplayer.h" | 31 | #include "mediaplayer.h" |
31 | #include "playlistwidget.h" | 32 | #include "playlistwidget.h" |
32 | #include "audiowidget.h" | 33 | #include "audiowidget.h" |
33 | #include "loopcontrol.h" | 34 | #include "loopcontrol.h" |
34 | #include "audiodevice.h" | 35 | #include "audiodevice.h" |
35 | 36 | ||
36 | #include "mediaplayerstate.h" | 37 | #include "mediaplayerstate.h" |
37 | 38 | ||
38 | 39 | ||
39 | extern AudioWidget *audioUI; | 40 | extern AudioWidget *audioUI; |
40 | extern PlayListWidget *playList; | 41 | extern PlayListWidget *playList; |
41 | extern LoopControl *loopControl; | 42 | extern LoopControl *loopControl; |
42 | extern MediaPlayerState *mediaPlayerState; | 43 | extern MediaPlayerState *mediaPlayerState; |
43 | 44 | ||
44 | 45 | ||
45 | MediaPlayer::MediaPlayer( QObject *parent, const char *name ) | 46 | MediaPlayer::MediaPlayer( QObject *parent, const char *name ) |
46 | : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) { | 47 | : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) { |
47 | 48 | ||
48 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); | 49 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); |
49 | connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); | 50 | connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); |
50 | connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); | 51 | connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); |
51 | connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); | 52 | connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); |
diff --git a/core/multimedia/opieplayer/mediaplayer.h b/core/multimedia/opieplayer/mediaplayer.h index 379d95c..73f8124 100644 --- a/core/multimedia/opieplayer/mediaplayer.h +++ b/core/multimedia/opieplayer/mediaplayer.h | |||
@@ -1,59 +1,58 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef MEDIA_PLAYER_H | 20 | #ifndef MEDIA_PLAYER_H |
21 | #define MEDIA_PLAYER_H | 21 | #define MEDIA_PLAYER_H |
22 | 22 | ||
23 | |||
24 | #include <qmainwindow.h> | 23 | #include <qmainwindow.h> |
25 | #include <qframe.h> | 24 | #include <qframe.h> |
26 | #include <qpe/qlibrary.h> | 25 | #include <qpe/qlibrary.h> |
27 | #include "mediaplayerplugininterface.h" | 26 | #include <qpe/mediaplayerplugininterface.h> |
28 | 27 | ||
29 | 28 | ||
30 | class DocLnk; | 29 | class DocLnk; |
31 | 30 | ||
32 | 31 | ||
33 | class MediaPlayer : public QObject { | 32 | class MediaPlayer : public QObject { |
34 | Q_OBJECT | 33 | Q_OBJECT |
35 | public: | 34 | public: |
36 | MediaPlayer( QObject *parent, const char *name ); | 35 | MediaPlayer( QObject *parent, const char *name ); |
37 | ~MediaPlayer(); | 36 | ~MediaPlayer(); |
38 | 37 | ||
39 | private slots: | 38 | private slots: |
40 | void setPlaying( bool ); | 39 | void setPlaying( bool ); |
41 | void pauseCheck( bool ); | 40 | void pauseCheck( bool ); |
42 | void play(); | 41 | void play(); |
43 | void next(); | 42 | void next(); |
44 | void prev(); | 43 | void prev(); |
45 | void startIncreasingVolume(); | 44 | void startIncreasingVolume(); |
46 | void startDecreasingVolume(); | 45 | void startDecreasingVolume(); |
47 | void stopChangingVolume(); | 46 | void stopChangingVolume(); |
48 | 47 | ||
49 | protected: | 48 | protected: |
50 | void timerEvent( QTimerEvent *e ); | 49 | void timerEvent( QTimerEvent *e ); |
51 | 50 | ||
52 | private: | 51 | private: |
53 | int volumeDirection; | 52 | int volumeDirection; |
54 | const DocLnk*currentFile; | 53 | const DocLnk*currentFile; |
55 | }; | 54 | }; |
56 | 55 | ||
57 | 56 | ||
58 | #endif // MEDIA_PLAYER_H | 57 | #endif // MEDIA_PLAYER_H |
59 | 58 | ||
diff --git a/core/multimedia/opieplayer/mediaplayerplugininterface.h b/core/multimedia/opieplayer/mediaplayerplugininterface.h index 339b2e4..aeeffde 100644 --- a/core/multimedia/opieplayer/mediaplayerplugininterface.h +++ b/core/multimedia/opieplayer/mediaplayerplugininterface.h | |||
@@ -1,111 +1,114 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef MEDIA_PLAYER_PLUGIN_INTERFACE_H | 20 | #ifndef MEDIA_PLAYER_PLUGIN_INTERFACE_H |
21 | #define MEDIA_PLAYER_PLUGIN_INTERFACE_H | 21 | #define MEDIA_PLAYER_PLUGIN_INTERFACE_H |
22 | 22 | ||
23 | |||
23 | #include <qpe/qcom.h> | 24 | #include <qpe/qcom.h> |
24 | 25 | ||
25 | #ifndef QT_NO_COMPONENT | 26 | #ifndef QT_NO_COMPONENT |
26 | // {c0093632-b44c-4cf7-a279-d82fe8a8890c} | 27 | // {c0093632-b44c-4cf7-a279-d82fe8a8890c} |
27 | # ifndef IID_MediaPlayerPlugin | 28 | # ifndef IID_MediaPlayerPlugin |
28 | # define IID_MediaPlayerPlugin QUuid( 0xc0093632, 0xb44c, 0x4cf7, 0xa2, 0x79, 0xd8, 0x2f, 0xe8, 0xa8, 0x89, 0x0c ) | 29 | # define IID_MediaPlayerPlugin QUuid( 0xc0093632, 0xb44c, 0x4cf7, 0xa2, 0x79, 0xd8, 0x2f, 0xe8, 0xa8, 0x89, 0x0c ) |
29 | # endif | 30 | # endif |
30 | #endif | 31 | #endif |
31 | 32 | ||
32 | 33 | ||
33 | enum ColorFormat { | 34 | enum ColorFormat { |
34 | RGB565, | 35 | RGB565, |
35 | BGR565, | 36 | BGR565, |
36 | RGBA8888, | 37 | RGBA8888, |
37 | BGRA8888 | 38 | BGRA8888 |
38 | }; | 39 | }; |
39 | 40 | ||
40 | 41 | ||
41 | class MediaPlayerDecoder { | 42 | class MediaPlayerDecoder { |
42 | 43 | ||
43 | public: | 44 | public: |
44 | virtual ~MediaPlayerDecoder() { }; | 45 | virtual ~MediaPlayerDecoder() { }; |
45 | 46 | ||
46 | // About Plugin | 47 | // About Plugin |
47 | virtual const char *pluginName() = 0; | 48 | virtual const char *pluginName() = 0; |
48 | virtual const char *pluginComment() = 0; | 49 | virtual const char *pluginComment() = 0; |
49 | virtual double pluginVersion() = 0; | 50 | virtual double pluginVersion() = 0; |
50 | 51 | ||
51 | virtual bool isFileSupported( const QString& file ) = 0; | 52 | virtual bool isFileSupported( const QString& file ) = 0; |
52 | virtual bool open( const QString& file ) = 0; | 53 | virtual bool open( const QString& file ) = 0; |
53 | virtual bool close() = 0; | 54 | virtual bool close() = 0; |
54 | virtual bool isOpen() = 0; | 55 | virtual bool isOpen() = 0; |
55 | virtual const QString &fileInfo() = 0; | 56 | virtual const QString &fileInfo() = 0; |
56 | 57 | ||
57 | // If decoder doesn't support audio then return 0 here | 58 | // If decoder doesn't support audio then return 0 here |
58 | virtual int audioStreams() = 0; | 59 | virtual int audioStreams() = 0; |
59 | virtual int audioChannels( int stream ) = 0; | 60 | virtual int audioChannels( int stream ) = 0; |
60 | virtual int audioFrequency( int stream ) = 0; | 61 | virtual int audioFrequency( int stream ) = 0; |
61 | virtual int audioSamples( int stream ) = 0; | 62 | virtual int audioSamples( int stream ) = 0; |
62 | virtual bool audioSetSample( long sample, int stream ) = 0; | 63 | virtual bool audioSetSample( long sample, int stream ) = 0; |
63 | virtual long audioGetSample( int stream ) = 0; | 64 | virtual long audioGetSample( int stream ) = 0; |
65 | // virtual bool audioReadMonoSamples( short *samples, long samples, long& samplesRead, int stream ) = 0; | ||
66 | // virtual bool audioReadStereoSamples( short *samples, long samples, long& samplesRead, int stream ) = 0; | ||
64 | virtual bool audioReadSamples( short *samples, int channels, long samples, long& samplesRead, int stream ) = 0; | 67 | virtual bool audioReadSamples( short *samples, int channels, long samples, long& samplesRead, int stream ) = 0; |
68 | // Libmpeg3 functions, perhaps good for reading an audio file with 5 channels or something! | ||
69 | // virtual bool audioReadSamples( short *samples, int channel, long samples, int stream ) = 0; | ||
70 | // virtual bool audioReReadSamples( short *samples, int channel, long samples, int stream ) = 0; | ||
65 | 71 | ||
66 | // If decoder doesn't support video then return 0 here | 72 | // If decoder doesn't support video then return 0 here |
67 | virtual int videoStreams() = 0; | 73 | virtual int videoStreams() = 0; |
68 | virtual int videoWidth( int stream ) = 0; | 74 | virtual int videoWidth( int stream ) = 0; |
69 | virtual int videoHeight( int stream ) = 0; | 75 | virtual int videoHeight( int stream ) = 0; |
70 | virtual double videoFrameRate( int stream ) = 0; // frames per second (this may change to frames/1000secs) | 76 | virtual double videoFrameRate( int stream ) = 0; // frames per second (this may change to frames/1000secs) |
71 | virtual int videoFrames( int stream ) = 0; | 77 | virtual int videoFrames( int stream ) = 0; |
72 | virtual bool videoSetFrame( long sample, int stream ) = 0; | 78 | virtual bool videoSetFrame( long sample, int stream ) = 0; |
73 | virtual long videoGetFrame( int stream ) = 0; | 79 | virtual long videoGetFrame( int stream ) = 0; |
74 | virtual bool videoReadFrame( unsigned char **output_rows, int in_x, int in_y, int in_w, int in_h, ColorFormat color_model, int stream ) = 0; | 80 | virtual bool videoReadFrame( unsigned char **output_rows, int in_x, int in_y, int in_w, int in_h, ColorFormat color_model, int stream ) = 0; |
75 | virtual bool videoReadScaledFrame( unsigned char **output_rows, int in_x, int in_y, int in_w, int in_h, int out_w, int out_h, ColorFormat color_model, int stream ) = 0; | 81 | virtual bool videoReadScaledFrame( unsigned char **output_rows, int in_x, int in_y, int in_w, int in_h, int out_w, int out_h, ColorFormat color_model, int stream ) = 0; |
76 | virtual bool videoReadYUVFrame( char *y_output, char *u_output, char *v_output, int in_x, int in_y, int in_w, int in_h, int stream ) = 0; | 82 | virtual bool videoReadYUVFrame( char *y_output, char *u_output, char *v_output, int in_x, int in_y, int in_w, int in_h, int stream ) = 0; |
77 | 83 | ||
78 | // Profiling | 84 | // Profiling |
79 | virtual double getTime() = 0; | 85 | virtual double getTime() = 0; |
80 | 86 | ||
81 | // Ignore if these aren't supported | 87 | // Ignore if these aren't supported |
82 | virtual bool setSMP( int cpus ) = 0; | 88 | virtual bool setSMP( int cpus ) = 0; |
83 | virtual bool setMMX( bool useMMX ) = 0; | 89 | virtual bool setMMX( bool useMMX ) = 0; |
84 | 90 | ||
85 | // Capabilities | 91 | // Capabilities |
86 | virtual bool supportsAudio() = 0; | 92 | virtual bool supportsAudio() = 0; |
87 | virtual bool supportsVideo() = 0; | 93 | virtual bool supportsVideo() = 0; |
88 | virtual bool supportsYUV() = 0; | 94 | virtual bool supportsYUV() = 0; |
89 | virtual bool supportsMMX() = 0; | 95 | virtual bool supportsMMX() = 0; |
90 | virtual bool supportsSMP() = 0; | 96 | virtual bool supportsSMP() = 0; |
91 | virtual bool supportsStereo() = 0; | 97 | virtual bool supportsStereo() = 0; |
92 | virtual bool supportsScaling() = 0; | 98 | virtual bool supportsScaling() = 0; |
93 | 99 | ||
94 | // File Properies | ||
95 | virtual long getPlayTime() { return -1; } | ||
96 | virtual int audioBitsPerSample( int stream ) = 0; | ||
97 | }; | 100 | }; |
98 | 101 | ||
99 | 102 | ||
100 | class MediaPlayerEncoder; | 103 | class MediaPlayerEncoder; |
101 | 104 | ||
102 | 105 | ||
103 | struct MediaPlayerPluginInterface : public QUnknownInterface | 106 | struct MediaPlayerPluginInterface : public QUnknownInterface |
104 | { | 107 | { |
105 | virtual MediaPlayerDecoder *decoder() = 0; | 108 | virtual MediaPlayerDecoder *decoder() = 0; |
106 | virtual MediaPlayerEncoder *encoder() = 0; | 109 | virtual MediaPlayerEncoder *encoder() = 0; |
107 | }; | 110 | }; |
108 | 111 | ||
109 | 112 | ||
110 | #endif | 113 | #endif |
111 | 114 | ||
diff --git a/core/multimedia/opieplayer/mediaplayerstate.cpp b/core/multimedia/opieplayer/mediaplayerstate.cpp index 2a6bca3..7e82166 100644 --- a/core/multimedia/opieplayer/mediaplayerstate.cpp +++ b/core/multimedia/opieplayer/mediaplayerstate.cpp | |||
@@ -1,191 +1,185 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include <qpe/qpeapplication.h> | 20 | #include <qpe/qpeapplication.h> |
21 | #include <qpe/qlibrary.h> | 21 | #include <qpe/qlibrary.h> |
22 | #include <qpe/mediaplayerplugininterface.h> | ||
22 | #include <qpe/config.h> | 23 | #include <qpe/config.h> |
23 | #include <qvaluelist.h> | 24 | #include <qvaluelist.h> |
24 | #include <qobject.h> | 25 | #include <qobject.h> |
25 | #include <qdir.h> | 26 | #include <qdir.h> |
26 | #include "mediaplayerplugininterface.h" | ||
27 | #include "mediaplayerstate.h" | 27 | #include "mediaplayerstate.h" |
28 | 28 | ||
29 | |||
30 | |||
31 | #ifdef QT_NO_COMPONENT | 29 | #ifdef QT_NO_COMPONENT |
32 | // Plugins which are compiled in when no plugin architecture available | 30 | // Plugins which are compiled in when no plugin architecture available |
33 | #include "libmad/libmadpluginimpl.h" | 31 | #include "libmad/libmadpluginimpl.h" |
34 | #include "libmpeg3/libmpeg3pluginimpl.h" | 32 | #include "libmpeg3/libmpeg3pluginimpl.h" |
35 | #include "wavplugin/wavpluginimpl.h" | 33 | #include "wavplugin/wavpluginimpl.h" |
36 | #endif | 34 | #endif |
37 | 35 | ||
38 | 36 | ||
39 | //#define MediaPlayerDebug(x) qDebug x | 37 | #define MediaPlayerDebug(x)qDebug x |
40 | #define MediaPlayerDebug(x) | 38 | //#define MediaPlayerDebug(x) |
41 | 39 | ||
42 | 40 | ||
43 | MediaPlayerState::MediaPlayerState( QObject *parent, const char *name ) | 41 | MediaPlayerState::MediaPlayerState( QObject *parent, const char *name ) |
44 | : QObject( parent, name ), decoder( NULL ), libmpeg3decoder( NULL ) { | 42 | : QObject( parent, name ), decoder( NULL ), libmpeg3decoder( NULL ) { |
45 | Config cfg( "MediaPlayer" ); | 43 | Config cfg( "MediaPlayer" ); |
46 | readConfig( cfg ); | 44 | readConfig( cfg ); |
47 | loadPlugins(); | 45 | loadPlugins(); |
48 | } | 46 | } |
49 | 47 | ||
50 | 48 | ||
51 | MediaPlayerState::~MediaPlayerState() { | 49 | MediaPlayerState::~MediaPlayerState() { |
52 | Config cfg( "MediaPlayer" ); | 50 | Config cfg( "MediaPlayer" ); |
53 | writeConfig( cfg ); | 51 | writeConfig( cfg ); |
54 | } | 52 | } |
55 | 53 | ||
56 | 54 | ||
57 | void MediaPlayerState::readConfig( Config& cfg ) { | 55 | void MediaPlayerState::readConfig( Config& cfg ) { |
58 | cfg.setGroup("Options"); | 56 | cfg.setGroup("Options"); |
59 | isFullscreen = cfg.readBoolEntry( "FullScreen" ); | 57 | isFullscreen = cfg.readBoolEntry( "FullScreen" ); |
60 | isScaled = cfg.readBoolEntry( "Scaling" ); | 58 | isScaled = cfg.readBoolEntry( "Scaling" ); |
61 | isLooping = cfg.readBoolEntry( "Looping" ); | 59 | isLooping = cfg.readBoolEntry( "Looping" ); |
62 | isShuffled = cfg.readBoolEntry( "Shuffle" ); | 60 | isShuffled = cfg.readBoolEntry( "Shuffle" ); |
63 | usePlaylist = cfg.readBoolEntry( "UsePlayList" ); | 61 | usePlaylist = cfg.readBoolEntry( "UsePlayList" ); |
64 | isPlaying = FALSE; | 62 | isPlaying = FALSE; |
65 | isPaused = FALSE; | 63 | isPaused = FALSE; |
66 | curPosition = 0; | 64 | curPosition = 0; |
67 | curLength = 0; | 65 | curLength = 0; |
68 | curView = 'l'; | 66 | curView = 'l'; |
69 | } | 67 | } |
70 | 68 | ||
71 | 69 | ||
72 | void MediaPlayerState::writeConfig( Config& cfg ) const { | 70 | void MediaPlayerState::writeConfig( Config& cfg ) const { |
73 | cfg.setGroup("Options"); | 71 | cfg.setGroup("Options"); |
74 | cfg.writeEntry("FullScreen", isFullscreen ); | 72 | cfg.writeEntry("FullScreen", isFullscreen ); |
75 | cfg.writeEntry("Scaling", isScaled ); | 73 | cfg.writeEntry("Scaling", isScaled ); |
76 | cfg.writeEntry("Looping", isLooping ); | 74 | cfg.writeEntry("Looping", isLooping ); |
77 | cfg.writeEntry("Shuffle", isShuffled ); | 75 | cfg.writeEntry("Shuffle", isShuffled ); |
78 | cfg.writeEntry("UsePlayList", usePlaylist ); | 76 | cfg.writeEntry("UsePlayList", usePlaylist ); |
79 | } | 77 | } |
80 | 78 | ||
81 | 79 | ||
82 | struct MediaPlayerPlugin { | 80 | struct MediaPlayerPlugin { |
83 | #ifndef QT_NO_COMPONENT | 81 | #ifndef QT_NO_COMPONENT |
84 | QLibrary *library; | 82 | QLibrary *library; |
85 | #endif | 83 | #endif |
86 | MediaPlayerPluginInterface *iface; | 84 | MediaPlayerPluginInterface *iface; |
87 | MediaPlayerDecoder *decoder; | 85 | MediaPlayerDecoder *decoder; |
88 | MediaPlayerEncoder *encoder; | 86 | MediaPlayerEncoder *encoder; |
89 | }; | 87 | }; |
90 | 88 | ||
91 | 89 | ||
92 | static QValueList<MediaPlayerPlugin> pluginList; | 90 | static QValueList<MediaPlayerPlugin> pluginList; |
93 | 91 | ||
94 | 92 | ||
95 | // Find the first decoder which supports this type of file | 93 | // Find the first decoder which supports this type of file |
96 | MediaPlayerDecoder *MediaPlayerState::newDecoder( const QString& file ) { | 94 | MediaPlayerDecoder *MediaPlayerState::newDecoder( const QString& file ) { |
97 | MediaPlayerDecoder *tmpDecoder = NULL; | 95 | MediaPlayerDecoder *tmpDecoder = NULL; |
98 | QValueList<MediaPlayerPlugin>::Iterator it; | 96 | QValueList<MediaPlayerPlugin>::Iterator it; |
99 | for ( it = pluginList.begin(); it != pluginList.end(); ++it ) { | 97 | for ( it = pluginList.begin(); it != pluginList.end(); ++it ) { |
100 | if ( (*it).decoder->isFileSupported( file ) ) { | 98 | if ( (*it).decoder->isFileSupported( file ) ) { |
101 | tmpDecoder = (*it).decoder; | 99 | tmpDecoder = (*it).decoder; |
102 | break; | 100 | break; |
103 | } | 101 | } |
104 | } | 102 | } |
105 | return decoder = tmpDecoder; | 103 | return decoder = tmpDecoder; |
106 | } | 104 | } |
107 | 105 | ||
108 | 106 | ||
109 | MediaPlayerDecoder *MediaPlayerState::curDecoder() { | 107 | MediaPlayerDecoder *MediaPlayerState::curDecoder() { |
110 | return decoder; | 108 | return decoder; |
111 | } | 109 | } |
112 | 110 | ||
113 | 111 | ||
114 | // ### hack to get true sample count | 112 | // ### hack to get true sample count |
115 | MediaPlayerDecoder *MediaPlayerState::libMpeg3Decoder() { | 113 | MediaPlayerDecoder *MediaPlayerState::libMpeg3Decoder() { |
116 | return libmpeg3decoder; | 114 | return libmpeg3decoder; |
117 | } | 115 | } |
118 | 116 | ||
119 | // ### hack to get true sample count | ||
120 | // MediaPlayerDecoder *MediaPlayerState::libWavDecoder() { | ||
121 | // return libwavdecoder; | ||
122 | // } | ||
123 | 117 | ||
124 | void MediaPlayerState::loadPlugins() { | 118 | void MediaPlayerState::loadPlugins() { |
125 | 119 | ||
126 | #ifndef QT_NO_COMPONENT | 120 | #ifndef QT_NO_COMPONENT |
127 | QValueList<MediaPlayerPlugin>::Iterator mit; | 121 | QValueList<MediaPlayerPlugin>::Iterator mit; |
128 | for ( mit = pluginList.begin(); mit != pluginList.end(); ++mit ) { | 122 | for ( mit = pluginList.begin(); mit != pluginList.end(); ++mit ) { |
129 | (*mit).iface->release(); | 123 | (*mit).iface->release(); |
130 | (*mit).library->unload(); | 124 | (*mit).library->unload(); |
131 | delete (*mit).library; | 125 | delete (*mit).library; |
132 | } | 126 | } |
133 | pluginList.clear(); | 127 | pluginList.clear(); |
134 | 128 | ||
135 | QString path = QPEApplication::qpeDir() + "/plugins/codecs"; | 129 | QString path = QPEApplication::qpeDir() + "/plugins/codecs"; |
136 | QDir dir( path, "lib*.so" ); | 130 | QDir dir( path, "lib*.so" ); |
137 | QStringList list = dir.entryList(); | 131 | QStringList list = dir.entryList(); |
138 | QStringList::Iterator it; | 132 | QStringList::Iterator it; |
139 | for ( it = list.begin(); it != list.end(); ++it ) { | 133 | for ( it = list.begin(); it != list.end(); ++it ) { |
140 | MediaPlayerPluginInterface *iface = 0; | 134 | MediaPlayerPluginInterface *iface = 0; |
141 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 135 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
142 | 136 | ||
143 | MediaPlayerDebug(( "querying: %s", QString( path + "/" + *it ).latin1() )); | 137 | MediaPlayerDebug(( "querying: %s", QString( path + "/" + *it ).latin1() )); |
144 | 138 | ||
145 | if ( lib->queryInterface( IID_MediaPlayerPlugin, (QUnknownInterface**)&iface ) == QS_OK ) { | 139 | if ( lib->queryInterface( IID_MediaPlayerPlugin, (QUnknownInterface**)&iface ) == QS_OK ) { |
146 | 140 | ||
147 | MediaPlayerDebug(( "loading: %s", QString( path + "/" + *it ).latin1() )); | 141 | MediaPlayerDebug(( "loading: %s", QString( path + "/" + *it ).latin1() )); |
148 | 142 | ||
149 | MediaPlayerPlugin plugin; | 143 | MediaPlayerPlugin plugin; |
150 | plugin.library = lib; | 144 | plugin.library = lib; |
151 | plugin.iface = iface; | 145 | plugin.iface = iface; |
152 | plugin.decoder = plugin.iface->decoder(); | 146 | plugin.decoder = plugin.iface->decoder(); |
153 | plugin.encoder = plugin.iface->encoder(); | 147 | plugin.encoder = plugin.iface->encoder(); |
154 | pluginList.append( plugin ); | 148 | pluginList.append( plugin ); |
155 | 149 | ||
156 | // ### hack to get true sample count | 150 | // ### hack to get true sample count |
157 | if ( plugin.decoder->pluginName() == QString("LibMpeg3Plugin") ) | 151 | if ( plugin.decoder->pluginName() == QString("LibMpeg3Plugin") ) |
158 | libmpeg3decoder = plugin.decoder; | 152 | libmpeg3decoder = plugin.decoder; |
159 | 153 | ||
160 | } else { | 154 | } else { |
161 | delete lib; | 155 | delete lib; |
162 | } | 156 | } |
163 | } | 157 | } |
164 | #else | 158 | #else |
165 | pluginList.clear(); | 159 | pluginList.clear(); |
166 | 160 | ||
167 | MediaPlayerPlugin plugin0; | 161 | MediaPlayerPlugin plugin0; |
168 | plugin0.iface = new LibMpeg3PluginImpl; | 162 | plugin0.iface = new LibMpeg3PluginImpl; |
169 | plugin0.decoder = plugin0.iface->decoder(); | 163 | plugin0.decoder = plugin0.iface->decoder(); |
170 | plugin0.encoder = plugin0.iface->encoder(); | 164 | plugin0.encoder = plugin0.iface->encoder(); |
171 | pluginList.append( plugin0 ); | 165 | pluginList.append( plugin0 ); |
172 | 166 | ||
173 | MediaPlayerPlugin plugin1; | 167 | MediaPlayerPlugin plugin1; |
174 | plugin1.iface = new LibMadPluginImpl; | 168 | plugin1.iface = new LibMadPluginImpl; |
175 | plugin1.decoder = plugin1.iface->decoder(); | 169 | plugin1.decoder = plugin1.iface->decoder(); |
176 | plugin1.encoder = plugin1.iface->encoder(); | 170 | plugin1.encoder = plugin1.iface->encoder(); |
177 | pluginList.append( plugin1 ); | 171 | pluginList.append( plugin1 ); |
178 | 172 | ||
179 | MediaPlayerPlugin plugin2; | 173 | MediaPlayerPlugin plugin2; |
180 | plugin2.iface = new WavPluginImpl; | 174 | plugin2.iface = new WavPluginImpl; |
181 | plugin2.decoder = plugin2.iface->decoder(); | 175 | plugin2.decoder = plugin2.iface->decoder(); |
182 | plugin2.encoder = plugin2.iface->encoder(); | 176 | plugin2.encoder = plugin2.iface->encoder(); |
183 | pluginList.append( plugin2 ); | 177 | pluginList.append( plugin2 ); |
184 | #endif | 178 | #endif |
185 | 179 | ||
186 | if ( pluginList.count() ) | 180 | if ( pluginList.count() ) |
187 | MediaPlayerDebug(( "%i decoders found", pluginList.count() )); | 181 | MediaPlayerDebug(( "%i decoders found", pluginList.count() )); |
188 | else | 182 | else |
189 | MediaPlayerDebug(( "No decoders found" )); | 183 | MediaPlayerDebug(( "No decoders found" )); |
190 | } | 184 | } |
191 | 185 | ||
diff --git a/core/multimedia/opieplayer/mediaplayerstate.h b/core/multimedia/opieplayer/mediaplayerstate.h index 1a23742..e82c263 100644 --- a/core/multimedia/opieplayer/mediaplayerstate.h +++ b/core/multimedia/opieplayer/mediaplayerstate.h | |||
@@ -1,118 +1,116 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef MEDIA_PLAYER_STATE_H | 20 | #ifndef MEDIA_PLAYER_STATE_H |
21 | #define MEDIA_PLAYER_STATE_H | 21 | #define MEDIA_PLAYER_STATE_H |
22 | 22 | ||
23 | |||
24 | #include <qobject.h> | 23 | #include <qobject.h> |
25 | 24 | ||
26 | 25 | ||
27 | class MediaPlayerDecoder; | 26 | class MediaPlayerDecoder; |
28 | class Config; | 27 | class Config; |
29 | 28 | ||
30 | 29 | ||
31 | class MediaPlayerState : public QObject { | 30 | class MediaPlayerState : public QObject { |
32 | Q_OBJECT | 31 | Q_OBJECT |
33 | public: | 32 | public: |
34 | MediaPlayerState( QObject *parent, const char *name ); | 33 | MediaPlayerState( QObject *parent, const char *name ); |
35 | ~MediaPlayerState(); | 34 | ~MediaPlayerState(); |
36 | 35 | ||
37 | bool fullscreen() { return isFullscreen; } | 36 | bool fullscreen() { return isFullscreen; } |
38 | bool scaled() { return isScaled; } | 37 | bool scaled() { return isScaled; } |
39 | bool looping() { return isLooping; } | 38 | bool looping() { return isLooping; } |
40 | bool shuffled() { return isShuffled; } | 39 | bool shuffled() { return isShuffled; } |
41 | bool playlist() { return usePlaylist; } | 40 | bool playlist() { return usePlaylist; } |
42 | bool paused() { return isPaused; } | 41 | bool paused() { return isPaused; } |
43 | bool playing() { return isPlaying; } | 42 | bool playing() { return isPlaying; } |
44 | long position() { return curPosition; } | 43 | long position() { return curPosition; } |
45 | long length() { return curLength; } | 44 | long length() { return curLength; } |
46 | char view() { return curView; } | 45 | char view() { return curView; } |
47 | 46 | ||
48 | MediaPlayerDecoder *newDecoder( const QString& file ); | 47 | MediaPlayerDecoder *newDecoder( const QString& file ); |
49 | MediaPlayerDecoder *curDecoder(); | 48 | MediaPlayerDecoder *curDecoder(); |
50 | MediaPlayerDecoder *libMpeg3Decoder(); // ### Yucky hack needed to use libmpeg3plugin to get the | 49 | MediaPlayerDecoder *libMpeg3Decoder(); // ### Yucky hack needed to use libmpeg3plugin to get the |
51 | // number of audio samples if we are using the libmad plugin | 50 | // number of audio samples if we are using the libmad plugin |
52 | public slots: | 51 | public slots: |
53 | void setFullscreen( bool b ) { if ( isFullscreen == b ) return; isFullscreen = b; emit fullscreenToggled(b); } | 52 | void setFullscreen( bool b ) { if ( isFullscreen == b ) return; isFullscreen = b; emit fullscreenToggled(b); } |
54 | void setScaled( bool b ) { if ( isScaled == b ) return; isScaled = b; emit scaledToggled(b); } | 53 | void setScaled( bool b ) { if ( isScaled == b ) return; isScaled = b; emit scaledToggled(b); } |
55 | void setLooping( bool b ) { if ( isLooping == b ) return; isLooping = b; emit loopingToggled(b); } | 54 | void setLooping( bool b ) { if ( isLooping == b ) return; isLooping = b; emit loopingToggled(b); } |
56 | void setShuffled( bool b ) { if ( isShuffled == b ) return; isShuffled = b; emit shuffledToggled(b); } | 55 | void setShuffled( bool b ) { if ( isShuffled == b ) return; isShuffled = b; emit shuffledToggled(b); } |
57 | void setPlaylist( bool b ) { if ( usePlaylist == b ) return; usePlaylist = b; emit playlistToggled(b); } | 56 | void setPlaylist( bool b ) { if ( usePlaylist == b ) return; usePlaylist = b; emit playlistToggled(b); } |
58 | void setPaused( bool b ) { if ( isPaused == b ) return; isPaused = b; emit pausedToggled(b); } | 57 | void setPaused( bool b ) { if ( isPaused == b ) return; isPaused = b; emit pausedToggled(b); } |
59 | void setPlaying( bool b ) { if ( isPlaying == b ) return; isPlaying = b; emit playingToggled(b); } | 58 | void setPlaying( bool b ) { if ( isPlaying == b ) return; isPlaying = b; emit playingToggled(b); } |
60 | void setPosition( long p ) { if ( curPosition == p ) return; curPosition = p; emit positionChanged(p); } | 59 | void setPosition( long p ) { if ( curPosition == p ) return; curPosition = p; emit positionChanged(p); } |
61 | void updatePosition( long p ){ if ( curPosition == p ) return; curPosition = p; emit positionUpdated(p); } | 60 | void updatePosition( long p ){ if ( curPosition == p ) return; curPosition = p; emit positionUpdated(p); } |
62 | void setLength( long l ) { if ( curLength == l ) return; curLength = l; emit lengthChanged(l); } | 61 | void setLength( long l ) { if ( curLength == l ) return; curLength = l; emit lengthChanged(l); } |
63 | void setView( char v ) { if ( curView == v ) return; curView = v; emit viewChanged(v); } | 62 | void setView( char v ) { if ( curView == v ) return; curView = v; emit viewChanged(v); } |
64 | 63 | ||
65 | void setPrev() { emit prev(); } | 64 | void setPrev() { emit prev(); } |
66 | void setNext() { emit next(); } | 65 | void setNext() { emit next(); } |
67 | void setList() { setPlaying( FALSE ); setView('l'); } | 66 | void setList() { setPlaying( FALSE ); setView('l'); } |
68 | void setVideo() { setView('v'); } | 67 | void setVideo() { setView('v'); } |
69 | void setAudio() { setView('a'); } | 68 | void setAudio() { setView('a'); } |
70 | 69 | ||
71 | void toggleFullscreen() { setFullscreen( !isFullscreen ); } | 70 | void toggleFullscreen() { setFullscreen( !isFullscreen ); } |
72 | void toggleScaled() { setScaled( !isScaled); } | 71 | void toggleScaled() { setScaled( !isScaled); } |
73 | void toggleLooping() { setLooping( !isLooping); } | 72 | void toggleLooping() { setLooping( !isLooping); } |
74 | void toggleShuffled() { setShuffled( !isShuffled); } | 73 | void toggleShuffled() { setShuffled( !isShuffled); } |
75 | void togglePlaylist() { setPlaylist( !usePlaylist); } | 74 | void togglePlaylist() { setPlaylist( !usePlaylist); } |
76 | void togglePaused() { setPaused( !isPaused); } | 75 | void togglePaused() { setPaused( !isPaused); } |
77 | void togglePlaying() { setPlaying( !isPlaying); } | 76 | void togglePlaying() { setPlaying( !isPlaying); } |
78 | 77 | ||
79 | signals: | 78 | signals: |
80 | void fullscreenToggled( bool ); | 79 | void fullscreenToggled( bool ); |
81 | void scaledToggled( bool ); | 80 | void scaledToggled( bool ); |
82 | void loopingToggled( bool ); | 81 | void loopingToggled( bool ); |
83 | void shuffledToggled( bool ); | 82 | void shuffledToggled( bool ); |
84 | void playlistToggled( bool ); | 83 | void playlistToggled( bool ); |
85 | void pausedToggled( bool ); | 84 | void pausedToggled( bool ); |
86 | void playingToggled( bool ); | 85 | void playingToggled( bool ); |
87 | void positionChanged( long ); // When the slider is moved | 86 | void positionChanged( long ); // When the slider is moved |
88 | void positionUpdated( long ); // When the media file progresses | 87 | void positionUpdated( long ); // When the media file progresses |
89 | void lengthChanged( long ); | 88 | void lengthChanged( long ); |
90 | void viewChanged( char ); | 89 | void viewChanged( char ); |
91 | 90 | ||
92 | void prev(); | 91 | void prev(); |
93 | void next(); | 92 | void next(); |
94 | 93 | ||
95 | private: | 94 | private: |
96 | bool isFullscreen; | 95 | bool isFullscreen; |
97 | bool isScaled; | 96 | bool isScaled; |
98 | bool isLooping; | 97 | bool isLooping; |
99 | bool isShuffled; | 98 | bool isShuffled; |
100 | bool usePlaylist; | 99 | bool usePlaylist; |
101 | bool isPaused; | 100 | bool isPaused; |
102 | bool isPlaying; | 101 | bool isPlaying; |
103 | long curPosition; | 102 | long curPosition; |
104 | long curLength; | 103 | long curLength; |
105 | char curView; | 104 | char curView; |
106 | 105 | ||
107 | MediaPlayerDecoder *decoder; | 106 | MediaPlayerDecoder *decoder; |
108 | MediaPlayerDecoder *libmpeg3decoder; | 107 | MediaPlayerDecoder *libmpeg3decoder; |
109 | // MediaPlayerDecoder *libwavdecoder; | ||
110 | 108 | ||
111 | void loadPlugins(); | 109 | void loadPlugins(); |
112 | void readConfig( Config& cfg ); | 110 | void readConfig( Config& cfg ); |
113 | void writeConfig( Config& cfg ) const; | 111 | void writeConfig( Config& cfg ) const; |
114 | }; | 112 | }; |
115 | 113 | ||
116 | 114 | ||
117 | #endif // MEDIA_PLAYER_STATE_H | 115 | #endif // MEDIA_PLAYER_STATE_H |
118 | 116 | ||
diff --git a/core/multimedia/opieplayer/playlistselection.cpp b/core/multimedia/opieplayer/playlistselection.cpp index f17ab6f..a82b594 100644 --- a/core/multimedia/opieplayer/playlistselection.cpp +++ b/core/multimedia/opieplayer/playlistselection.cpp | |||
@@ -1,179 +1,178 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include <qpe/applnk.h> | 20 | #include <qpe/applnk.h> |
21 | #include <qpe/resource.h> | 21 | #include <qpe/resource.h> |
22 | #include <qpainter.h> | 22 | #include <qpainter.h> |
23 | #include <qimage.h> | 23 | #include <qimage.h> |
24 | #include <qheader.h> | 24 | #include <qheader.h> |
25 | #include <qlistview.h> | 25 | #include <qlistview.h> |
26 | #include <qlist.h> | 26 | #include <qlist.h> |
27 | #include <qpixmap.h> | 27 | #include <qpixmap.h> |
28 | 28 | ||
29 | #include "playlistselection.h" | 29 | #include "playlistselection.h" |
30 | 30 | ||
31 | #include <stdlib.h> | 31 | #include <stdlib.h> |
32 | 32 | ||
33 | |||
34 | class PlayListSelectionItem : public QListViewItem { | 33 | class PlayListSelectionItem : public QListViewItem { |
35 | public: | 34 | public: |
36 | PlayListSelectionItem( QListView *parent, const DocLnk *f ) : QListViewItem( parent ), fl( f ) { | 35 | PlayListSelectionItem( QListView *parent, const DocLnk *f ) : QListViewItem( parent ), fl( f ) { |
37 | setText( 0, f->name() ); | 36 | setText( 0, f->name() ); |
38 | setPixmap( 0, f->pixmap() ); | 37 | setPixmap( 0, f->pixmap() ); |
39 | } | 38 | } |
40 | 39 | ||
41 | ~PlayListSelectionItem() { | 40 | ~PlayListSelectionItem() { |
42 | }; | 41 | }; |
43 | 42 | ||
44 | const DocLnk *file() const { return fl; } | 43 | const DocLnk *file() const { return fl; } |
45 | 44 | ||
46 | private: | 45 | private: |
47 | const DocLnk *fl; | 46 | const DocLnk *fl; |
48 | }; | 47 | }; |
49 | 48 | ||
50 | 49 | ||
51 | PlayListSelection::PlayListSelection( QWidget *parent, const char *name ) | 50 | PlayListSelection::PlayListSelection( QWidget *parent, const char *name ) |
52 | : QListView( parent, name ) | 51 | : QListView( parent, name ) |
53 | { | 52 | { |
54 | #ifdef USE_PLAYLIST_BACKGROUND | 53 | #ifdef USE_PLAYLIST_BACKGROUND |
55 | setStaticBackground( TRUE ); | 54 | setStaticBackground( TRUE ); |
56 | setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/background" ) ); | 55 | setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/background" ) ); |
57 | #endif | 56 | #endif |
58 | setAllColumnsShowFocus( TRUE ); | 57 | setAllColumnsShowFocus( TRUE ); |
59 | addColumn( tr( "Playlist Selection" ) ); | 58 | addColumn( tr( "Playlist Selection" ) ); |
60 | header()->hide(); | 59 | header()->hide(); |
61 | setSorting( -1, FALSE ); | 60 | setSorting( -1, FALSE ); |
62 | } | 61 | } |
63 | 62 | ||
64 | 63 | ||
65 | PlayListSelection::~PlayListSelection() { | 64 | PlayListSelection::~PlayListSelection() { |
66 | } | 65 | } |
67 | 66 | ||
68 | 67 | ||
69 | #ifdef USE_PLAYLIST_BACKGROUND | 68 | #ifdef USE_PLAYLIST_BACKGROUND |
70 | void PlayListSelection::drawBackground( QPainter *p, const QRect &r ) { | 69 | void PlayListSelection::drawBackground( QPainter *p, const QRect &r ) { |
71 | p->fillRect( r, QBrush( white ) ); | 70 | p->fillRect( r, QBrush( white ) ); |
72 | QImage logo = Resource::loadImage( "mpegplayer/background" ); | 71 | QImage logo = Resource::loadImage( "mpegplayer/background" ); |
73 | if ( !logo.isNull() ) | 72 | if ( !logo.isNull() ) |
74 | p->drawImage( (width() - logo.width()) / 2, (height() - logo.height()) / 2, logo ); | 73 | p->drawImage( (width() - logo.width()) / 2, (height() - logo.height()) / 2, logo ); |
75 | } | 74 | } |
76 | #endif | 75 | #endif |
77 | 76 | ||
78 | 77 | ||
79 | void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) { | 78 | void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) { |
80 | if ( event->state() == QMouseEvent::LeftButton ) { | 79 | if ( event->state() == QMouseEvent::LeftButton ) { |
81 | QListViewItem *currentItem = selectedItem(); | 80 | QListViewItem *currentItem = selectedItem(); |
82 | QListViewItem *itemUnder = itemAt( QPoint( event->pos().x(), event->pos().y() - contentsY() ) ); | 81 | QListViewItem *itemUnder = itemAt( QPoint( event->pos().x(), event->pos().y() - contentsY() ) ); |
83 | if ( currentItem && currentItem->itemAbove() == itemUnder ) | 82 | if ( currentItem && currentItem->itemAbove() == itemUnder ) |
84 | moveSelectedUp(); | 83 | moveSelectedUp(); |
85 | else if ( currentItem && currentItem->itemBelow() == itemUnder ) | 84 | else if ( currentItem && currentItem->itemBelow() == itemUnder ) |
86 | moveSelectedDown(); | 85 | moveSelectedDown(); |
87 | } | 86 | } |
88 | } | 87 | } |
89 | 88 | ||
90 | 89 | ||
91 | const DocLnk *PlayListSelection::current() { | 90 | const DocLnk *PlayListSelection::current() { |
92 | PlayListSelectionItem *item = (PlayListSelectionItem *)selectedItem(); | 91 | PlayListSelectionItem *item = (PlayListSelectionItem *)selectedItem(); |
93 | if ( item ) | 92 | if ( item ) |
94 | return item->file(); | 93 | return item->file(); |
95 | return NULL; | 94 | return NULL; |
96 | } | 95 | } |
97 | 96 | ||
98 | 97 | ||
99 | void PlayListSelection::addToSelection( const DocLnk &lnk ) { | 98 | void PlayListSelection::addToSelection( const DocLnk &lnk ) { |
100 | PlayListSelectionItem *item = new PlayListSelectionItem( this, new DocLnk( lnk ) ); | 99 | PlayListSelectionItem *item = new PlayListSelectionItem( this, new DocLnk( lnk ) ); |
101 | QListViewItem *current = selectedItem(); | 100 | QListViewItem *current = selectedItem(); |
102 | if ( current ) | 101 | if ( current ) |
103 | item->moveItem( current ); | 102 | item->moveItem( current ); |
104 | setSelected( item, TRUE ); | 103 | setSelected( item, TRUE ); |
105 | ensureItemVisible( selectedItem() ); | 104 | ensureItemVisible( selectedItem() ); |
106 | } | 105 | } |
107 | 106 | ||
108 | 107 | ||
109 | void PlayListSelection::removeSelected() { | 108 | void PlayListSelection::removeSelected() { |
110 | QListViewItem *item = selectedItem(); | 109 | QListViewItem *item = selectedItem(); |
111 | if ( item ) | 110 | if ( item ) |
112 | delete item; | 111 | delete item; |
113 | setSelected( currentItem(), TRUE ); | 112 | setSelected( currentItem(), TRUE ); |
114 | ensureItemVisible( selectedItem() ); | 113 | ensureItemVisible( selectedItem() ); |
115 | } | 114 | } |
116 | 115 | ||
117 | 116 | ||
118 | void PlayListSelection::moveSelectedUp() { | 117 | void PlayListSelection::moveSelectedUp() { |
119 | QListViewItem *item = selectedItem(); | 118 | QListViewItem *item = selectedItem(); |
120 | if ( item && item->itemAbove() ) | 119 | if ( item && item->itemAbove() ) |
121 | item->itemAbove()->moveItem( item ); | 120 | item->itemAbove()->moveItem( item ); |
122 | ensureItemVisible( selectedItem() ); | 121 | ensureItemVisible( selectedItem() ); |
123 | } | 122 | } |
124 | 123 | ||
125 | 124 | ||
126 | void PlayListSelection::moveSelectedDown() { | 125 | void PlayListSelection::moveSelectedDown() { |
127 | QListViewItem *item = selectedItem(); | 126 | QListViewItem *item = selectedItem(); |
128 | if ( item && item->itemBelow() ) | 127 | if ( item && item->itemBelow() ) |
129 | item->moveItem( item->itemBelow() ); | 128 | item->moveItem( item->itemBelow() ); |
130 | ensureItemVisible( selectedItem() ); | 129 | ensureItemVisible( selectedItem() ); |
131 | } | 130 | } |
132 | 131 | ||
133 | 132 | ||
134 | bool PlayListSelection::prev() { | 133 | bool PlayListSelection::prev() { |
135 | QListViewItem *item = selectedItem(); | 134 | QListViewItem *item = selectedItem(); |
136 | if ( item && item->itemAbove() ) | 135 | if ( item && item->itemAbove() ) |
137 | setSelected( item->itemAbove(), TRUE ); | 136 | setSelected( item->itemAbove(), TRUE ); |
138 | else | 137 | else |
139 | return FALSE; | 138 | return FALSE; |
140 | ensureItemVisible( selectedItem() ); | 139 | ensureItemVisible( selectedItem() ); |
141 | return TRUE; | 140 | return TRUE; |
142 | } | 141 | } |
143 | 142 | ||
144 | 143 | ||
145 | bool PlayListSelection::next() { | 144 | bool PlayListSelection::next() { |
146 | QListViewItem *item = selectedItem(); | 145 | QListViewItem *item = selectedItem(); |
147 | if ( item && item->itemBelow() ) | 146 | if ( item && item->itemBelow() ) |
148 | setSelected( item->itemBelow(), TRUE ); | 147 | setSelected( item->itemBelow(), TRUE ); |
149 | else | 148 | else |
150 | return FALSE; | 149 | return FALSE; |
151 | ensureItemVisible( selectedItem() ); | 150 | ensureItemVisible( selectedItem() ); |
152 | return TRUE; | 151 | return TRUE; |
153 | } | 152 | } |
154 | 153 | ||
155 | 154 | ||
156 | bool PlayListSelection::first() { | 155 | bool PlayListSelection::first() { |
157 | QListViewItem *item = firstChild(); | 156 | QListViewItem *item = firstChild(); |
158 | if ( item ) | 157 | if ( item ) |
159 | setSelected( item, TRUE ); | 158 | setSelected( item, TRUE ); |
160 | else | 159 | else |
161 | return FALSE; | 160 | return FALSE; |
162 | ensureItemVisible( selectedItem() ); | 161 | ensureItemVisible( selectedItem() ); |
163 | return TRUE; | 162 | return TRUE; |
164 | } | 163 | } |
165 | 164 | ||
166 | 165 | ||
167 | bool PlayListSelection::last() { | 166 | bool PlayListSelection::last() { |
168 | QListViewItem *prevItem = NULL; | 167 | QListViewItem *prevItem = NULL; |
169 | QListViewItem *item = firstChild(); | 168 | QListViewItem *item = firstChild(); |
170 | while ( ( item = item->nextSibling() ) ) | 169 | while ( ( item = item->nextSibling() ) ) |
171 | prevItem = item; | 170 | prevItem = item; |
172 | if ( prevItem ) | 171 | if ( prevItem ) |
173 | setSelected( prevItem, TRUE ); | 172 | setSelected( prevItem, TRUE ); |
174 | else | 173 | else |
175 | return FALSE; | 174 | return FALSE; |
176 | ensureItemVisible( selectedItem() ); | 175 | ensureItemVisible( selectedItem() ); |
177 | return TRUE; | 176 | return TRUE; |
178 | } | 177 | } |
179 | 178 | ||
diff --git a/core/multimedia/opieplayer/playlistselection.h b/core/multimedia/opieplayer/playlistselection.h index 6ce6bdc..22d3c74 100644 --- a/core/multimedia/opieplayer/playlistselection.h +++ b/core/multimedia/opieplayer/playlistselection.h | |||
@@ -1,55 +1,56 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef PLAY_LIST_SELECTION_H | 20 | #ifndef PLAY_LIST_SELECTION_H |
21 | #define PLAY_LIST_SELECTION_H | 21 | #define PLAY_LIST_SELECTION_H |
22 | 22 | ||
23 | 23 | ||
24 | |||
24 | #include <qlist.h> | 25 | #include <qlist.h> |
25 | #include <qlistview.h> | 26 | #include <qlistview.h> |
26 | #include <qpe/applnk.h> | 27 | #include <qpe/applnk.h> |
27 | 28 | ||
28 | 29 | ||
29 | class PlayListSelection : public QListView { | 30 | class PlayListSelection : public QListView { |
30 | Q_OBJECT | 31 | Q_OBJECT |
31 | public: | 32 | public: |
32 | PlayListSelection( QWidget *parent, const char *name=0 ); | 33 | PlayListSelection( QWidget *parent, const char *name=0 ); |
33 | ~PlayListSelection(); | 34 | ~PlayListSelection(); |
34 | 35 | ||
35 | const DocLnk *current(); // retrieve the current playlist entry (media file link) | 36 | const DocLnk *current(); // retrieve the current playlist entry (media file link) |
36 | 37 | ||
37 | public slots: | 38 | public slots: |
38 | void addToSelection( const DocLnk & ); // Add a media file to the playlist | 39 | void addToSelection( const DocLnk & ); // Add a media file to the playlist |
39 | void removeSelected(); // Remove a media file from the playlist | 40 | void removeSelected(); // Remove a media file from the playlist |
40 | void moveSelectedUp(); // Move the media file up the playlist so it is played earlier | 41 | void moveSelectedUp(); // Move the media file up the playlist so it is played earlier |
41 | void moveSelectedDown(); // Move the media file down the playlist so it is played later | 42 | void moveSelectedDown(); // Move the media file down the playlist so it is played later |
42 | bool prev(); | 43 | bool prev(); |
43 | bool next(); | 44 | bool next(); |
44 | bool first(); | 45 | bool first(); |
45 | bool last(); | 46 | bool last(); |
46 | 47 | ||
47 | protected: | 48 | protected: |
48 | virtual void contentsMouseMoveEvent(QMouseEvent *); | 49 | virtual void contentsMouseMoveEvent(QMouseEvent *); |
49 | #ifdef USE_PLAYLIST_BACKGROUND | 50 | #ifdef USE_PLAYLIST_BACKGROUND |
50 | virtual void drawBackground( QPainter *p, const QRect &r ); | 51 | virtual void drawBackground( QPainter *p, const QRect &r ); |
51 | virtual void paintEmptyArea( QPainter *p, const QRect &r ) { drawBackground( p, r ); }; | 52 | virtual void paintEmptyArea( QPainter *p, const QRect &r ) { drawBackground( p, r ); }; |
52 | #endif | 53 | #endif |
53 | 54 | ||
54 | private: | 55 | private: |
55 | QList<DocLnk> selectedList; | 56 | QList<DocLnk> selectedList; |
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index 269aed8..0423e7a 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp | |||
@@ -1,698 +1,449 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | |||
20 | #include <qpe/qpemenubar.h> | 21 | #include <qpe/qpemenubar.h> |
21 | #include <qpe/qpetoolbar.h> | 22 | #include <qpe/qpetoolbar.h> |
22 | #include <qpe/fileselector.h> | 23 | #include <qpe/fileselector.h> |
23 | #include <qpe/qpeapplication.h> | ||
24 | |||
25 | #include <qpe/applnk.h> | 24 | #include <qpe/applnk.h> |
26 | #include <qpe/config.h> | 25 | #include <qpe/config.h> |
27 | #include <qpe/global.h> | 26 | #include <qpe/global.h> |
28 | #include <qpe/resource.h> | 27 | #include <qpe/resource.h> |
29 | #include <qaction.h> | 28 | #include <qaction.h> |
30 | #include <qimage.h> | 29 | #include <qimage.h> |
31 | #include <qfile.h> | 30 | #include <qfile.h> |
32 | #include <qlayout.h> | 31 | #include <qlayout.h> |
33 | #include <qlabel.h> | 32 | #include <qlabel.h> |
34 | #include <qlist.h> | 33 | #include <qlist.h> |
35 | #include <qlistbox.h> | 34 | #include <qlistbox.h> |
36 | #include <qmainwindow.h> | 35 | #include <qmainwindow.h> |
37 | #include <qmessagebox.h> | 36 | #include <qmessagebox.h> |
38 | #include <qtoolbutton.h> | 37 | #include <qtoolbutton.h> |
39 | #include <qtabwidget.h> | ||
40 | #include <qlistview.h> | ||
41 | #include <qpoint.h> | ||
42 | //#include <qtimer.h> | ||
43 | 38 | ||
44 | #include "playlistselection.h" | 39 | #include "playlistselection.h" |
45 | #include "playlistwidget.h" | 40 | #include "playlistwidget.h" |
46 | #include "mediaplayerstate.h" | 41 | #include "mediaplayerstate.h" |
47 | 42 | ||
48 | #include <stdlib.h> | 43 | #include <stdlib.h> |
49 | 44 | ||
50 | #define BUTTONS_ON_TOOLBAR | ||
51 | #define SIDE_BUTTONS | ||
52 | #define CAN_SAVE_LOAD_PLAYLISTS | ||
53 | 45 | ||
54 | extern MediaPlayerState *mediaPlayerState; | 46 | extern MediaPlayerState *mediaPlayerState; |
55 | 47 | ||
56 | // class myFileSelector { | ||
57 | 48 | ||
58 | // }; | ||
59 | class PlayListWidgetPrivate { | 49 | class PlayListWidgetPrivate { |
60 | public: | 50 | public: |
61 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; | 51 | QToolButton *tbPlay; |
52 | QToolButton *tbFull; | ||
53 | QToolButton *tbLoop; | ||
54 | QToolButton *tbScale; | ||
55 | QToolButton *tbShuffle; | ||
56 | |||
62 | QFrame *playListFrame; | 57 | QFrame *playListFrame; |
63 | FileSelector *files; | 58 | FileSelector *files; |
64 | PlayListSelection *selectedFiles; | 59 | PlayListSelection *selectedFiles; |
65 | bool setDocumentUsed; | 60 | bool setDocumentUsed; |
66 | DocLnk *current; | 61 | DocLnk *current; |
67 | }; | 62 | }; |
68 | 63 | ||
69 | 64 | ||
70 | class ToolButton : public QToolButton { | 65 | class ToolButton : public QToolButton { |
71 | public: | 66 | public: |
72 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) | 67 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) |
73 | : QToolButton( parent, name ) { | 68 | : QToolButton( parent, name ) { |
74 | setTextLabel( name ); | 69 | setTextLabel( name ); |
75 | setPixmap( Resource::loadPixmap( icon ) ); | 70 | setPixmap( Resource::loadPixmap( icon ) ); |
76 | setAutoRaise( TRUE ); | 71 | setAutoRaise( TRUE ); |
77 | setFocusPolicy( QWidget::NoFocus ); | 72 | setFocusPolicy( QWidget::NoFocus ); |
78 | setToggleButton( t ); | 73 | setToggleButton( t ); |
79 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); | 74 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); |
80 | QPEMenuToolFocusManager::manager()->addWidget( this ); | 75 | QPEMenuToolFocusManager::manager()->addWidget( this ); |
81 | } | 76 | } |
82 | }; | 77 | }; |
83 | 78 | ||
84 | 79 | ||
85 | class MenuItem : public QAction { | 80 | class MenuItem : public QAction { |
86 | public: | 81 | public: |
87 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) | 82 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) |
88 | : QAction( text, QString::null, 0, 0 ) { | 83 | : QAction( text, QString::null, 0, 0 ) { |
89 | connect( this, SIGNAL( activated() ), handler, slot ); | 84 | connect( this, SIGNAL( activated() ), handler, slot ); |
90 | addTo( parent ); | 85 | addTo( parent ); |
91 | } | 86 | } |
92 | }; | 87 | }; |
93 | 88 | ||
94 | 89 | ||
95 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | 90 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) |
96 | : QMainWindow( parent, name, fl ) { | 91 | : QMainWindow( parent, name, fl ) { |
97 | 92 | ||
98 | d = new PlayListWidgetPrivate; | 93 | d = new PlayListWidgetPrivate; |
99 | d->setDocumentUsed = FALSE; | 94 | d->setDocumentUsed = FALSE; |
100 | d->current = NULL; | 95 | d->current = NULL; |
101 | // menuTimer = new QTimer( this ,"menu timer"), | ||
102 | // connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); | ||
103 | 96 | ||
104 | setBackgroundMode( PaletteButton ); | 97 | setBackgroundMode( PaletteButton ); |
105 | 98 | ||
106 | setCaption( tr("OpiePlayer") ); | 99 | setCaption( tr("MediaPlayer") ); |
107 | setIcon( Resource::loadPixmap( "MPEGPlayer" ) ); | 100 | setIcon( Resource::loadPixmap( "MPEGPlayer" ) ); |
108 | 101 | ||
109 | setToolBarsMovable( FALSE ); | 102 | setToolBarsMovable( FALSE ); |
110 | 103 | ||
111 | // Create Toolbar | 104 | // Create Toolbar |
112 | QPEToolBar *toolbar = new QPEToolBar( this ); | 105 | QPEToolBar *toolbar = new QPEToolBar( this ); |
113 | toolbar->setHorizontalStretchable( TRUE ); | 106 | toolbar->setHorizontalStretchable( TRUE ); |
114 | 107 | ||
115 | // Create Menubar | 108 | // Create Menubar |
116 | QPEMenuBar *menu = new QPEMenuBar( toolbar ); | 109 | QPEMenuBar *menu = new QPEMenuBar( toolbar ); |
117 | menu->setMargin( 0 ); | 110 | menu->setMargin( 0 ); |
118 | 111 | ||
119 | QPEToolBar *bar = new QPEToolBar( this ); | 112 | QPEToolBar *bar = new QPEToolBar( this ); |
120 | bar->setLabel( tr( "Play Operations" ) ); | 113 | bar->setLabel( tr( "Play Operations" ) ); |
121 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "mpegplayer/add_to_playlist", | 114 | #ifdef BUTTONS_ON_TOOLBAR |
122 | this , SLOT(addSelected()) ); | 115 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "mpegplayer/play", mediaPlayerState, SLOT(setPlaying(bool)), TRUE ); |
123 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "mpegplayer/remove_from_playlist", | 116 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ), "mpegplayer/shuffle", mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); |
124 | this , SLOT(removeSelected()) ); | 117 | #endif |
125 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "mpegplayer/play", | 118 | d->tbLoop = new ToolButton( bar, tr( "Loop" ), "mpegplayer/loop", mediaPlayerState, SLOT(setLooping(bool)), TRUE ); |
126 | mediaPlayerState, SLOT(setPlaying(bool)), TRUE ); | 119 | d->tbFull = new ToolButton( bar, tr( "Fullscreen" ), "fullscreen", mediaPlayerState, SLOT(setFullscreen(bool)), TRUE ); |
127 | 120 | d->tbScale = new ToolButton( bar, tr( "Scale" ), "mpegplayer/scale", mediaPlayerState, SLOT(setScaled(bool)), TRUE ); | |
128 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ), "mpegplayer/shuffle", | ||
129 | mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); | ||
130 | d->tbLoop = new ToolButton( bar, tr( "Loop" ), "mpegplayer/loop", | ||
131 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); | ||
132 | |||
133 | // d->tbFull = new ToolButton( bar, tr( "Fullscreen" ), "fullscreen", mediaPlayerState, SLOT(setFullscreen(bool)), TRUE ); | ||
134 | // d->tbScale = new ToolButton( bar, tr( "Scale" ), "mpegplayer/scale", mediaPlayerState, SLOT(setScaled(bool)), TRUE ); | ||
135 | 121 | ||
136 | QPopupMenu *pmPlayList = new QPopupMenu( this ); | 122 | QPopupMenu *pmPlayList = new QPopupMenu( this ); |
137 | menu->insertItem( tr( "File" ), pmPlayList ); | 123 | menu->insertItem( tr( "PlayList" ), pmPlayList ); |
124 | new MenuItem( pmPlayList, tr( "Toggle PlayList" ), mediaPlayerState, SLOT( togglePlaylist() ) ); | ||
138 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); | 125 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); |
139 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); | 126 | new MenuItem( pmPlayList, tr( "Add all music files" ), this, SLOT( addAllMusicToList() ) ); |
140 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); | 127 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); |
141 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); | 128 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); |
129 | #ifdef CAN_SAVE_LOAD_PLAYLISTS | ||
142 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); | 130 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); |
143 | new MenuItem( pmPlayList, tr( "Load PlayList" ), this, SLOT( loadList() ) ); | 131 | new MenuItem( pmPlayList, tr( "Load PlayList" ), this, SLOT( loadList() ) ); |
144 | 132 | #endif | |
145 | QPopupMenu *pmView = new QPopupMenu( this ); | ||
146 | menu->insertItem( tr( "View" ), pmView ); | ||
147 | |||
148 | fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); | ||
149 | connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); | ||
150 | fullScreenButton->addTo(pmView); | ||
151 | scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("mpegplayer/scale"), QString::null, 0, this, 0); | ||
152 | connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); | ||
153 | scaleButton->addTo(pmView); | ||
154 | 133 | ||
155 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); | 134 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); |
156 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); | ||
157 | // vbox4->setMargin(4); | ||
158 | // libString = new QLabel( tr(" Media Library"), vbox4 ); | ||
159 | // libString->setBackgroundMode( QButton::PaletteButton ); | ||
160 | // libString->setFont( QFont( "Helvetica", 8, QFont::Bold ) ); | ||
161 | |||
162 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); | ||
163 | |||
164 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); | ||
165 | tabWidget->setTabShape(QTabWidget::Triangular); | ||
166 | |||
167 | |||
168 | QWidget *pTab; | ||
169 | pTab = new QWidget( tabWidget, "pTab" ); | ||
170 | playlistView = new QListView( pTab, "Videoview" ); | ||
171 | playlistView->setMinimumSize(236,260); | ||
172 | tabWidget->insertTab( pTab,"Playlist"); | ||
173 | 135 | ||
174 | // Add the playlist area | 136 | // Add the playlist area |
175 | 137 | QVBox *vbox3 = new QVBox( vbox5 ); vbox3->setBackgroundMode( PaletteButton ); | |
176 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); | ||
177 | d->playListFrame = vbox3; | 138 | d->playListFrame = vbox3; |
178 | d->playListFrame ->setMinimumSize(235,260); | 139 | |
140 | QLabel *plString = new QLabel( tr(" PlayList"), vbox3 ); | ||
141 | plString->setBackgroundMode( QButton::PaletteButton ); | ||
142 | plString->setFont( QFont( "Helvetica", 8, QFont::Bold ) ); | ||
179 | 143 | ||
180 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); | 144 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); |
181 | d->selectedFiles = new PlayListSelection( hbox2); | 145 | d->selectedFiles = new PlayListSelection( hbox2 ); |
182 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); | 146 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); |
183 | 147 | ||
184 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch | 148 | #ifndef BUTTONS_ON_TOOLBAR |
185 | new ToolButton( vbox1, tr( "Move Up" ), "mpegplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); | 149 | d->tbPlay = new ToolButton( vbox1, tr( "Play" ), "mpegplayer/play", mediaPlayerState, SLOT(setPlaying(bool)), TRUE ); |
186 | new ToolButton( vbox1, tr( "Remove" ), "mpegplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); | 150 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch |
187 | new ToolButton( vbox1, tr( "Move Down" ), "mpegplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); | 151 | #endif |
188 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch | 152 | new ToolButton( vbox1, tr( "Move Up" ), "mpegplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); |
189 | 153 | new ToolButton( vbox1, tr( "Remove" ), "mpegplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); | |
190 | QWidget *aTab; | 154 | new ToolButton( vbox1, tr( "Move Down" ), "mpegplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); |
191 | aTab = new QWidget( tabWidget, "aTab" ); | 155 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch |
192 | audioView = new QListView( aTab, "Audioview" ); | 156 | #ifndef BUTTONS_ON_TOOLBAR |
193 | audioView->setMinimumSize(233,260); | 157 | d->tbShuffle = new ToolButton( vbox1, tr( "Randomize" ), "mpegplayer/shuffle", mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); |
194 | audioView->addColumn( "Title",150); | 158 | #endif |
195 | audioView->addColumn("Size", 45); | ||
196 | audioView->addColumn("Media",35); | ||
197 | audioView->setColumnAlignment(1, Qt::AlignRight); | ||
198 | audioView->setColumnAlignment(2, Qt::AlignRight); | ||
199 | tabWidget->insertTab(aTab,"Audio"); | ||
200 | // audioView | ||
201 | Global::findDocuments(&files, "audio/*"); | ||
202 | QListIterator<DocLnk> dit( files.children() ); | ||
203 | QString storage; | ||
204 | for ( ; dit.current(); ++dit ) { | ||
205 | QListViewItem * newItem; | ||
206 | if(dit.current()->file().find("/mnt/cf") != -1 ) storage="CF"; | ||
207 | else if(dit.current()->file().find("/mnt/hda") != -1 ) storage="CF"; | ||
208 | else if(dit.current()->file().find("/mnt/card") != -1 ) storage="SD"; | ||
209 | else storage="RAM"; | ||
210 | if ( QFile( dit.current()->file()).exists() ) { | ||
211 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage); | ||
212 | newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/musicfile" )); | ||
213 | } | ||
214 | } | ||
215 | // videowidget | ||
216 | |||
217 | QWidget *vTab; | ||
218 | vTab = new QWidget( tabWidget, "vTab" ); | ||
219 | videoView = new QListView( vTab, "Videoview" ); | ||
220 | videoView->setMinimumSize(233,260); | ||
221 | |||
222 | videoView->addColumn("Title",150); | ||
223 | videoView->addColumn("Size",45); | ||
224 | videoView->addColumn("Media",35); | ||
225 | videoView->setColumnAlignment(1, Qt::AlignRight); | ||
226 | videoView->setColumnAlignment(2, Qt::AlignRight); | ||
227 | |||
228 | tabWidget->insertTab( vTab,"Video"); | ||
229 | |||
230 | Global::findDocuments(&vFiles, "video/*"); | ||
231 | QListIterator<DocLnk> Vdit( vFiles.children() ); | ||
232 | for ( ; Vdit.current(); ++Vdit ) { | ||
233 | if( Vdit.current()->file().find("/mnt/cf") != -1 ) storage="CF"; | ||
234 | else if( Vdit.current()->file().find("/mnt/hda") != -1 ) storage="CF"; | ||
235 | else if( Vdit.current()->file().find("/mnt/card") != -1 ) storage="SD"; | ||
236 | else storage="RAM"; | ||
237 | QListViewItem * newItem; | ||
238 | if ( QFile( Vdit.current()->file()).exists() ) { | ||
239 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage); | ||
240 | newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/videofile" )); | ||
241 | } | ||
242 | } | ||
243 | |||
244 | |||
245 | // d->tbPlay = new ToolButton( vbox1, tr( "Play" ), "mpegplayer/play", mediaPlayerState, SLOT(setPlaying(bool)), TRUE ); | ||
246 | // d->tbShuffle = new ToolButton( vbox1, tr( "Randomize" ), "mpegplayer/shuffle", mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); | ||
247 | 159 | ||
248 | // add the library area | 160 | // add the library area |
161 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); | ||
249 | 162 | ||
250 | // d->files->setBackgroundMode( PaletteButton ); | 163 | QLabel *libString = new QLabel( tr(" Media Library"), vbox4 ); |
251 | // QVBox *vbox7 = new QVBox( hbox6 ); vbox7->setBackgroundMode( PaletteButton ); | 164 | libString->setBackgroundMode( QButton::PaletteButton ); |
252 | 165 | libString->setFont( QFont( "Helvetica", 8, QFont::Bold ) ); | |
253 | // #ifdef SIDE_BUTTONS | ||
254 | // QVBox *stretch3 = new QVBox( vbox1 ); stretch3->setBackgroundMode( PaletteButton ); // add stretch | ||
255 | // #endif | ||
256 | QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); | ||
257 | |||
258 | // connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); | ||
259 | // connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); | ||
260 | 166 | ||
261 | connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 167 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); |
262 | connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 168 | d->files = new FileSelector( "video/*;audio/*", hbox6, "Find Media Files", FALSE, FALSE ); |
169 | d->files->setBackgroundMode( PaletteButton ); | ||
170 | QVBox *vbox7 = new QVBox( hbox6 ); vbox7->setBackgroundMode( PaletteButton ); | ||
263 | 171 | ||
264 | connect( audioView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint&, int ) ), | 172 | #ifdef SIDE_BUTTONS |
265 | this, SLOT( addToSelection( QListViewItem *, const QPoint&, int )) ); | 173 | new ToolButton( vbox7, tr( "Add to Playlist" ), "mpegplayer/add_to_playlist", d->selectedFiles, SLOT(addSelected()) ); |
266 | connect( videoView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint&, int ) ), | 174 | new ToolButton( vbox7, tr( "Remove from Playlist" ), "mpegplayer/remove_from_playlist", d->selectedFiles, SLOT(removeSelected()) ); |
267 | this, SLOT( addToSelection( QListViewItem *, const QPoint&, int )) ); | 175 | QVBox *stretch3 = new QVBox( vbox1 ); stretch3->setBackgroundMode( PaletteButton ); // add stretch |
176 | #endif | ||
268 | 177 | ||
269 | connect( playlistView, SIGNAL( pressed( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); | 178 | connect( d->files, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); |
270 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); | ||
271 | // connect( d->files, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); | ||
272 | // connect( d->files, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); | ||
273 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); | 179 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); |
274 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); | 180 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); |
275 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); | 181 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); |
276 | 182 | connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), d->tbFull, SLOT( setOn( bool ) ) ); | |
277 | // connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), fullScreenButton, SLOT( setOn( bool ) ) ); | 183 | connect( mediaPlayerState, SIGNAL( scaledToggled( bool ) ), d->tbScale, SLOT( setOn( bool ) ) ); |
278 | // connect( mediaPlayerState, SIGNAL( scaledToggled( bool ) ), scaleButton, SLOT( setEnabled( bool ) ) ); | 184 | connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), d->tbScale, SLOT( setEnabled( bool ) ) ); |
279 | // connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), fullScreenButton, SLOT( setEnabled( bool ) ) ); | ||
280 | |||
281 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); | 185 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); |
282 | 186 | ||
283 | setCentralWidget( vbox5 ); | 187 | setCentralWidget( vbox5 ); |
284 | 188 | ||
285 | Config cfg( "MediaPlayer" ); | 189 | Config cfg( "MediaPlayer" ); |
286 | readConfig( cfg ); | 190 | readConfig( cfg ); |
287 | 191 | ||
288 | initializeStates(); | 192 | initializeStates(); |
289 | } | 193 | } |
290 | 194 | ||
291 | 195 | ||
292 | PlayListWidget::~PlayListWidget() { | 196 | PlayListWidget::~PlayListWidget() { |
293 | Config cfg( "MediaPlayer" ); | 197 | Config cfg( "MediaPlayer" ); |
294 | writeConfig( cfg ); | 198 | writeConfig( cfg ); |
295 | 199 | ||
296 | if ( d->current ) | 200 | if ( d->current ) |
297 | delete d->current; | 201 | delete d->current; |
298 | delete d; | 202 | delete d; |
299 | } | 203 | } |
300 | 204 | ||
301 | 205 | ||
302 | void PlayListWidget::initializeStates() { | 206 | void PlayListWidget::initializeStates() { |
303 | |||
304 | d->tbPlay->setOn( mediaPlayerState->playing() ); | 207 | d->tbPlay->setOn( mediaPlayerState->playing() ); |
305 | d->tbLoop->setOn( mediaPlayerState->looping() ); | 208 | d->tbLoop->setOn( mediaPlayerState->looping() ); |
306 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); | 209 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); |
307 | // d->tbFull->setOn( mediaPlayerState->fullscreen() ); | 210 | d->tbFull->setOn( mediaPlayerState->fullscreen() ); |
308 | // d->tbScale->setOn( mediaPlayerState->scaled() ); | 211 | d->tbScale->setOn( mediaPlayerState->scaled() ); |
309 | // d->tbScale->setEnabled( mediaPlayerState->fullscreen() ); | 212 | d->tbScale->setEnabled( mediaPlayerState->fullscreen() ); |
310 | // setPlaylist( mediaPlayerState->playlist() ); | 213 | setPlaylist( mediaPlayerState->playlist() ); |
311 | } | 214 | } |
312 | 215 | ||
313 | 216 | ||
314 | void PlayListWidget::readConfig( Config& cfg ) { | 217 | void PlayListWidget::readConfig( Config& cfg ) { |
315 | cfg.setGroup("PlayList"); | 218 | cfg.setGroup("PlayList"); |
316 | 219 | ||
317 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 220 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
318 | 221 | ||
319 | for ( int i = 0; i < noOfFiles; i++ ) { | 222 | for ( int i = 0; i < noOfFiles; i++ ) { |
320 | QString entryName; | 223 | QString entryName; |
321 | entryName.sprintf( "File%i", i + 1 ); | 224 | entryName.sprintf( "File%i", i + 1 ); |
322 | QString linkFile = cfg.readEntry( entryName ); | 225 | QString linkFile = cfg.readEntry( entryName ); |
323 | DocLnk lnk( linkFile ); | 226 | DocLnk lnk( linkFile ); |
324 | if ( lnk.isValid() ) | 227 | if ( lnk.isValid() ) |
325 | d->selectedFiles->addToSelection( lnk ); | 228 | d->selectedFiles->addToSelection( lnk ); |
326 | 229 | ||
327 | } | 230 | } |
328 | } | 231 | } |
329 | 232 | ||
330 | 233 | ||
331 | void PlayListWidget::writeConfig( Config& cfg ) const { | 234 | void PlayListWidget::writeConfig( Config& cfg ) const { |
332 | cfg.setGroup("PlayList"); | 235 | cfg.setGroup("PlayList"); |
333 | 236 | ||
334 | int noOfFiles = 0; | 237 | int noOfFiles = 0; |
335 | 238 | ||
336 | d->selectedFiles->first(); | 239 | d->selectedFiles->first(); |
337 | do { | 240 | do { |
338 | const DocLnk *lnk = d->selectedFiles->current(); | 241 | const DocLnk *lnk = d->selectedFiles->current(); |
339 | if ( lnk ) { | 242 | if ( lnk ) { |
340 | QString entryName; | 243 | QString entryName; |
341 | entryName.sprintf( "File%i", noOfFiles + 1 ); | 244 | entryName.sprintf( "File%i", noOfFiles + 1 ); |
342 | cfg.writeEntry( entryName, lnk->linkFile() ); | 245 | cfg.writeEntry( entryName, lnk->linkFile() ); |
343 | // if this link does exist, add it so we have the file | 246 | // if this link does exist, add it so we have the file |
344 | // next time... | 247 | // next time... |
345 | if ( !QFile::exists( lnk->linkFile() ) ) { | 248 | if ( !QFile::exists( lnk->linkFile() ) ) { |
346 | // the way writing lnks doesn't really check for out | 249 | // the way writing lnks doesn't really check for out |
347 | // of disk space, but check it anyway. | 250 | // of disk space, but check it anyway. |
348 | if ( !lnk->writeLink() ) { | 251 | if ( !lnk->writeLink() ) { |
349 | QMessageBox::critical( 0, tr("Out of space"), | 252 | QMessageBox::critical( 0, tr("Out of space"), |
350 | tr( "There was a problem saving " | 253 | tr( "There was a problem saving " |
351 | "the playlist.\n" | 254 | "the playlist.\n" |
352 | "Your playlist " | 255 | "Your playlist " |
353 | "may be missing some entries\n" | 256 | "may be missing some entries\n" |
354 | "the next time you start it." ) | 257 | "the next time you start it." ) |
355 | ); | 258 | ); |
356 | } | 259 | } |
357 | } | 260 | } |
358 | noOfFiles++; | 261 | noOfFiles++; |
359 | } | 262 | } |
360 | } while ( d->selectedFiles->next() ); | 263 | } while ( d->selectedFiles->next() ); |
361 | 264 | ||
362 | cfg.writeEntry("NumberOfFiles", noOfFiles ); | 265 | cfg.writeEntry("NumberOfFiles", noOfFiles ); |
363 | } | 266 | } |
364 | 267 | ||
365 | 268 | ||
366 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 269 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
367 | d->setDocumentUsed = FALSE; | 270 | d->setDocumentUsed = FALSE; |
368 | if ( mediaPlayerState->playlist() ) | 271 | if ( mediaPlayerState->playlist() ) |
369 | d->selectedFiles->addToSelection( lnk ); | 272 | d->selectedFiles->addToSelection( lnk ); |
370 | else | 273 | else |
371 | mediaPlayerState->setPlaying( TRUE ); | 274 | mediaPlayerState->setPlaying( TRUE ); |
372 | } | ||
373 | |||
374 | |||
375 | void PlayListWidget::addToSelection( QListViewItem *it ,const QPoint & p, int index) { | ||
376 | qDebug("add"); | ||
377 | // d->selectedFiles->addToSelection( lnk ); | ||
378 | // } | ||
379 | // else | ||
380 | // mediaPlayerState->setPlaying( TRUE ); | ||
381 | // | ||
382 | } | 275 | } |
383 | 276 | ||
384 | 277 | ||
385 | void PlayListWidget::clearList() { | 278 | void PlayListWidget::clearList() { |
386 | while ( first() ) | 279 | while ( first() ) |
387 | d->selectedFiles->removeSelected(); | 280 | d->selectedFiles->removeSelected(); |
388 | } | 281 | } |
389 | 282 | ||
390 | 283 | ||
391 | void PlayListWidget::addAllToList() { | 284 | void PlayListWidget::addAllToList() { |
392 | DocLnkSet files; | 285 | DocLnkSet files; |
393 | Global::findDocuments(&files, "video/*;audio/*"); | 286 | Global::findDocuments(&files, "video/*;audio/*"); |
394 | QListIterator<DocLnk> dit( files.children() ); | 287 | QListIterator<DocLnk> dit( files.children() ); |
395 | for ( ; dit.current(); ++dit ) | 288 | for ( ; dit.current(); ++dit ) |
396 | d->selectedFiles->addToSelection( **dit ); | 289 | d->selectedFiles->addToSelection( **dit ); |
397 | } | 290 | } |
398 | 291 | ||
399 | 292 | ||
400 | void PlayListWidget::addAllMusicToList() { | 293 | void PlayListWidget::addAllMusicToList() { |
401 | DocLnkSet files; | 294 | DocLnkSet files; |
402 | Global::findDocuments(&files, "audio/*"); | 295 | Global::findDocuments(&files, "audio/*"); |
403 | QListIterator<DocLnk> dit( files.children() ); | 296 | QListIterator<DocLnk> dit( files.children() ); |
404 | for ( ; dit.current(); ++dit ) | 297 | for ( ; dit.current(); ++dit ) |
405 | d->selectedFiles->addToSelection( **dit ); | 298 | d->selectedFiles->addToSelection( **dit ); |
406 | } | 299 | } |
407 | 300 | ||
408 | 301 | ||
409 | void PlayListWidget::addAllVideoToList() { | 302 | void PlayListWidget::addAllVideoToList() { |
410 | DocLnkSet files; | 303 | DocLnkSet files; |
411 | Global::findDocuments(&files, "video/*"); | 304 | Global::findDocuments(&files, "video/*"); |
412 | QListIterator<DocLnk> dit( files.children() ); | 305 | QListIterator<DocLnk> dit( files.children() ); |
413 | for ( ; dit.current(); ++dit ) | 306 | for ( ; dit.current(); ++dit ) |
414 | d->selectedFiles->addToSelection( **dit ); | 307 | d->selectedFiles->addToSelection( **dit ); |
415 | } | 308 | } |
416 | 309 | ||
417 | 310 | ||
418 | void PlayListWidget::setDocument(const QString& fileref) { | 311 | void PlayListWidget::setDocument(const QString& fileref) { |
419 | if ( fileref.isNull() ) { | 312 | if ( fileref.isNull() ) { |
420 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); | 313 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); |
421 | return; | 314 | return; |
422 | } | 315 | } |
423 | if ( mediaPlayerState->playlist() ) | 316 | if ( mediaPlayerState->playlist() ) |
424 | addToSelection( DocLnk( fileref ) ); | 317 | addToSelection( DocLnk( fileref ) ); |
425 | else { | 318 | else { |
426 | d->setDocumentUsed = TRUE; | 319 | d->setDocumentUsed = TRUE; |
427 | if ( d->current ) | 320 | if ( d->current ) |
428 | delete d->current; | 321 | delete d->current; |
429 | d->current = new DocLnk( fileref ); | 322 | d->current = new DocLnk( fileref ); |
430 | } | 323 | } |
431 | mediaPlayerState->setPlaying( FALSE ); | 324 | mediaPlayerState->setPlaying( FALSE ); |
432 | mediaPlayerState->setPlaying( TRUE ); | 325 | mediaPlayerState->setPlaying( TRUE ); |
433 | } | 326 | } |
434 | 327 | ||
435 | 328 | ||
436 | void PlayListWidget::setActiveWindow() { | 329 | void PlayListWidget::setActiveWindow() { |
437 | // When we get raised we need to ensure that it switches views | 330 | // When we get raised we need to ensure that it switches views |
438 | char origView = mediaPlayerState->view(); | 331 | char origView = mediaPlayerState->view(); |
439 | mediaPlayerState->setView( 'l' ); // invalidate | 332 | mediaPlayerState->setView( 'l' ); // invalidate |
440 | mediaPlayerState->setView( origView ); // now switch back | 333 | mediaPlayerState->setView( origView ); // now switch back |
441 | } | 334 | } |
442 | 335 | ||
443 | 336 | ||
444 | void PlayListWidget::useSelectedDocument() { | 337 | void PlayListWidget::useSelectedDocument() { |
445 | d->setDocumentUsed = FALSE; | 338 | d->setDocumentUsed = FALSE; |
446 | } | 339 | } |
447 | 340 | ||
448 | 341 | ||
449 | const DocLnk *PlayListWidget::current() { | 342 | const DocLnk *PlayListWidget::current() { |
450 | if ( mediaPlayerState->playlist() ) | 343 | if ( mediaPlayerState->playlist() ) |
451 | return d->selectedFiles->current(); | 344 | return d->selectedFiles->current(); |
452 | else if ( d->setDocumentUsed && d->current ) { | 345 | else if ( d->setDocumentUsed && d->current ) { |
453 | return d->current; | 346 | return d->current; |
454 | } else | 347 | } else |
455 | return d->files->selected(); | 348 | return d->files->selected(); |
456 | } | 349 | } |
457 | 350 | ||
458 | 351 | ||
459 | bool PlayListWidget::prev() { | 352 | bool PlayListWidget::prev() { |
460 | if ( mediaPlayerState->playlist() ) { | 353 | if ( mediaPlayerState->playlist() ) { |
461 | if ( mediaPlayerState->shuffled() ) { | 354 | if ( mediaPlayerState->shuffled() ) { |
462 | const DocLnk *cur = current(); | 355 | const DocLnk *cur = current(); |
463 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 356 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
464 | for ( int i = 0; i < j; i++ ) { | 357 | for ( int i = 0; i < j; i++ ) { |
465 | if ( !d->selectedFiles->next() ) | 358 | if ( !d->selectedFiles->next() ) |
466 | d->selectedFiles->first(); | 359 | d->selectedFiles->first(); |
467 | } | 360 | } |
468 | if ( cur == current() ) | 361 | if ( cur == current() ) |
469 | if ( !d->selectedFiles->next() ) | 362 | if ( !d->selectedFiles->next() ) |
470 | d->selectedFiles->first(); | 363 | d->selectedFiles->first(); |
471 | return TRUE; | 364 | return TRUE; |
472 | } else { | 365 | } else { |
473 | if ( !d->selectedFiles->prev() ) { | 366 | if ( !d->selectedFiles->prev() ) { |
474 | if ( mediaPlayerState->looping() ) { | 367 | if ( mediaPlayerState->looping() ) { |
475 | return d->selectedFiles->last(); | 368 | return d->selectedFiles->last(); |
476 | } else { | 369 | } else { |
477 | return FALSE; | 370 | return FALSE; |
478 | } | 371 | } |
479 | } | 372 | } |
480 | return TRUE; | 373 | return TRUE; |
481 | } | 374 | } |
482 | } else { | 375 | } else { |
483 | return mediaPlayerState->looping(); | 376 | return mediaPlayerState->looping(); |
484 | } | 377 | } |
485 | } | 378 | } |
486 | 379 | ||
487 | 380 | ||
488 | bool PlayListWidget::next() { | 381 | bool PlayListWidget::next() { |
489 | if ( mediaPlayerState->playlist() ) { | 382 | if ( mediaPlayerState->playlist() ) { |
490 | if ( mediaPlayerState->shuffled() ) { | 383 | if ( mediaPlayerState->shuffled() ) { |
491 | return prev(); | 384 | return prev(); |
492 | } else { | 385 | } else { |
493 | if ( !d->selectedFiles->next() ) { | 386 | if ( !d->selectedFiles->next() ) { |
494 | if ( mediaPlayerState->looping() ) { | 387 | if ( mediaPlayerState->looping() ) { |
495 | return d->selectedFiles->first(); | 388 | return d->selectedFiles->first(); |
389 | } else { | ||
390 | return FALSE; | ||
391 | } | ||
392 | } | ||
393 | return TRUE; | ||
394 | } | ||
496 | } else { | 395 | } else { |
497 | return FALSE; | 396 | return mediaPlayerState->looping(); |
498 | } | ||
499 | } | ||
500 | return TRUE; | ||
501 | } | ||
502 | } else { | ||
503 | return mediaPlayerState->looping(); | ||
504 | } | 397 | } |
505 | } | 398 | } |
506 | 399 | ||
507 | 400 | ||
508 | bool PlayListWidget::first() { | 401 | bool PlayListWidget::first() { |
509 | if ( mediaPlayerState->playlist() ) | 402 | if ( mediaPlayerState->playlist() ) |
510 | return d->selectedFiles->first(); | 403 | return d->selectedFiles->first(); |
511 | else | 404 | else |
512 | return mediaPlayerState->looping(); | 405 | return mediaPlayerState->looping(); |
513 | } | 406 | } |
514 | 407 | ||
515 | 408 | ||
516 | bool PlayListWidget::last() { | 409 | bool PlayListWidget::last() { |
517 | if ( mediaPlayerState->playlist() ) | 410 | if ( mediaPlayerState->playlist() ) |
518 | return d->selectedFiles->last(); | 411 | return d->selectedFiles->last(); |
519 | else | 412 | else |
520 | return mediaPlayerState->looping(); | 413 | return mediaPlayerState->looping(); |
521 | } | 414 | } |
522 | 415 | ||
523 | 416 | ||
524 | void PlayListWidget::saveList() { | 417 | void PlayListWidget::saveList() { |
525 | QString filename; | 418 | QString filename; |
526 | // pseudo code | 419 | // pseudo code |
527 | // filename = QLineEdit->getText(); | 420 | // filename = QLineEdit->getText(); |
528 | Config cfg( filename + ".playlist" ); | 421 | Config cfg( filename + ".playlist" ); |
529 | writeConfig( cfg ); | 422 | writeConfig( cfg ); |
530 | } | 423 | } |
531 | 424 | ||
532 | 425 | ||
533 | void PlayListWidget::loadList() { | 426 | void PlayListWidget::loadList() { |
534 | QString filename; | 427 | QString filename; |
535 | // pseudo code | 428 | // pseudo code |
536 | // filename = FileSelector->openFile( "*.playlist" ); | 429 | // filename = FileSelector->openFile( "*.playlist" ); |
537 | Config cfg( filename + ".playlist" ); | 430 | Config cfg( filename + ".playlist" ); |
538 | readConfig( cfg ); | 431 | readConfig( cfg ); |
539 | } | 432 | } |
540 | 433 | ||
541 | 434 | ||
542 | void PlayListWidget::setPlaylist( bool shown ) { | 435 | void PlayListWidget::setPlaylist( bool shown ) { |
543 | if ( shown ) | 436 | if ( shown ) |
544 | d->playListFrame->show(); | 437 | d->playListFrame->show(); |
545 | else | 438 | else |
546 | d->playListFrame->hide(); | 439 | d->playListFrame->hide(); |
547 | } | 440 | } |
548 | 441 | ||
549 | 442 | ||
550 | void PlayListWidget::setView( char view ) { | 443 | void PlayListWidget::setView( char view ) { |
551 | if ( view == 'l' ) | 444 | if ( view == 'l' ) |
552 | showMaximized(); | 445 | showMaximized(); |
553 | else | 446 | else |
554 | hide(); | 447 | hide(); |
555 | } | 448 | } |
556 | 449 | ||
557 | void PlayListWidget::addSelected() { | ||
558 | // QMessageBox::message("Note","Bozo the clown thinks\nthere's something actually here"); | ||
559 | int tabPage=tabWidget->currentPageIndex(); | ||
560 | switch (tabPage) { | ||
561 | case 0: //playlist | ||
562 | break; | ||
563 | case 1: { //audio | ||
564 | addToSelection( audioView->selectedItem() ); | ||
565 | } | ||
566 | break; | ||
567 | case 2: { // video | ||
568 | addToSelection( videoView->selectedItem() ); | ||
569 | } | ||
570 | break; | ||
571 | }; | ||
572 | } | ||
573 | |||
574 | void PlayListWidget::removeSelected() { | ||
575 | d->selectedFiles->removeSelected( ); | ||
576 | } | ||
577 | |||
578 | |||
579 | void PlayListWidget::playIt( QListViewItem *it) { | ||
580 | d->setDocumentUsed = FALSE; | ||
581 | |||
582 | if(it) { | ||
583 | qDebug("playit"); | ||
584 | int tabPage=tabWidget->currentPageIndex(); | ||
585 | switch (tabPage) { | ||
586 | case 1: { | ||
587 | DocLnkSet files; | ||
588 | QListIterator<DocLnk> dit( files.children() ); | ||
589 | for ( ; dit.current(); ++dit ) { | ||
590 | if( dit.current()->name() == it->text(0)) { | ||
591 | setDocument( dit.current()->name()); | ||
592 | } | ||
593 | } | ||
594 | } | ||
595 | break; | ||
596 | case 2: { | ||
597 | DocLnkSet vFiles; | ||
598 | QListIterator<DocLnk> dit( vFiles.children() ); | ||
599 | for ( ; dit.current(); ++dit ) { | ||
600 | qDebug(dit.current()->name()); | ||
601 | if( dit.current()->name() == it->text(0)) { | ||
602 | qDebug(it->text(0)); | ||
603 | setDocument( dit.current()->name()); | ||
604 | } | ||
605 | } | ||
606 | } | ||
607 | break; | ||
608 | }; | ||
609 | } | ||
610 | } | ||
611 | |||
612 | void PlayListWidget::addToSelection( QListViewItem *it) { | ||
613 | d->setDocumentUsed = FALSE; | ||
614 | |||
615 | if(it) { | ||
616 | qDebug("add to selection"); | ||
617 | int tabPage=tabWidget->currentPageIndex(); | ||
618 | switch (tabPage) { | ||
619 | case 1: { | ||
620 | QListIterator<DocLnk> dit( files.children() ); | ||
621 | for ( ; dit.current(); ++dit ) { | ||
622 | if( dit.current()->name() == it->text(0)) { | ||
623 | d->selectedFiles->addToSelection( **dit ); | ||
624 | } | ||
625 | } | ||
626 | } | ||
627 | break; | ||
628 | case 2: { | ||
629 | QListIterator<DocLnk> dit( vFiles.children() ); | ||
630 | for ( ; dit.current(); ++dit ) { | ||
631 | qDebug(dit.current()->name()); | ||
632 | if( dit.current()->name() == it->text(0)) { | ||
633 | d->selectedFiles->addToSelection( **dit ); | ||
634 | } | ||
635 | } | ||
636 | } | ||
637 | break; | ||
638 | case 0: | ||
639 | break; | ||
640 | }; | ||
641 | tabWidget->setCurrentPage(0); | ||
642 | // mediaPlayerState->setPlaying( TRUE ); | ||
643 | } | ||
644 | } | ||
645 | |||
646 | void PlayListWidget::tabChanged(QWidget *widg) { | ||
647 | |||
648 | int tabPage=tabWidget->currentPageIndex(); | ||
649 | switch (tabPage) { | ||
650 | case 0: | ||
651 | { | ||
652 | d->tbRemoveFromList->setEnabled(TRUE); | ||
653 | d->tbAddToList->setEnabled(FALSE); | ||
654 | } | ||
655 | break; | ||
656 | case 1: | ||
657 | { | ||
658 | d->tbRemoveFromList->setEnabled(FALSE); | ||
659 | d->tbAddToList->setEnabled(TRUE); | ||
660 | } | ||
661 | break; | ||
662 | case 2: | ||
663 | { | ||
664 | d->tbRemoveFromList->setEnabled(FALSE); | ||
665 | d->tbAddToList->setEnabled(TRUE); | ||
666 | } | ||
667 | break; | ||
668 | }; | ||
669 | } | ||
670 | |||
671 | // void PlayListWidget::cancelMenuTimer() { | ||
672 | // if( menuTimer->isActive() ) | ||
673 | // menuTimer->stop(); | ||
674 | // } | ||
675 | |||
676 | // void PlayListWidget::showFileMenu() { | ||
677 | |||
678 | // } | ||
679 | |||
680 | // void PlayListWidget::contentsMousePressEvent( QMouseEvent * e ) | ||
681 | // { | ||
682 | // // QListView::contentsMousePressEvent( e ); | ||
683 | // menuTimer->start( 750, TRUE ); | ||
684 | // } | ||
685 | |||
686 | |||
687 | // void PlayListWidget::contentsMouseReleaseEvent( QMouseEvent * e ) | ||
688 | // { | ||
689 | // // QListView::contentsMouseReleaseEvent( e ); | ||
690 | // menuTimer->stop(); | ||
691 | // } | ||
692 | // // void PlayListWidget::setFullScreen() { | ||
693 | // mediaPlayerState->toggleFullscreen( ); | ||
694 | // } | ||
695 | |||
696 | // void PlayListWidget::setScaled() { | ||
697 | // mediaPlayerState->toggleScaled(); | ||
698 | // } | ||
diff --git a/core/multimedia/opieplayer/playlistwidget.h b/core/multimedia/opieplayer/playlistwidget.h index 6fe2211..819adb1 100644 --- a/core/multimedia/opieplayer/playlistwidget.h +++ b/core/multimedia/opieplayer/playlistwidget.h | |||
@@ -1,97 +1,67 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef PLAY_LIST_WIDGET_H | 20 | #ifndef PLAY_LIST_WIDGET_H |
21 | #define PLAY_LIST_WIDGET_H | 21 | #define PLAY_LIST_WIDGET_H |
22 | 22 | ||
23 | |||
24 | #include <qmainwindow.h> | 23 | #include <qmainwindow.h> |
25 | #include <qpe/applnk.h> | 24 | #include <qpe/applnk.h> |
26 | #include <qtabwidget.h> | ||
27 | /* #include <qtimer.h> */ | ||
28 | 25 | ||
29 | 26 | ||
30 | class PlayListWidgetPrivate; | 27 | class PlayListWidgetPrivate; |
31 | class Config; | 28 | class Config; |
32 | class QListViewItem; | 29 | |
33 | class QListView; | ||
34 | class QPoint; | ||
35 | class QAction; | ||
36 | class QLabel; | ||
37 | 30 | ||
38 | class PlayListWidget : public QMainWindow { | 31 | class PlayListWidget : public QMainWindow { |
39 | Q_OBJECT | 32 | Q_OBJECT |
40 | public: | 33 | public: |
41 | PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 ); | 34 | PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 ); |
42 | ~PlayListWidget(); | 35 | ~PlayListWidget(); |
43 | QTabWidget * tabWidget; | 36 | |
44 | QAction *fullScreenButton, *scaleButton; | ||
45 | DocLnkSet files; | ||
46 | DocLnkSet vFiles; | ||
47 | QListView *audioView, *videoView, *playlistView; | ||
48 | QLabel *libString; | ||
49 | // retrieve the current playlist entry (media file link) | 37 | // retrieve the current playlist entry (media file link) |
50 | const DocLnk *current(); | 38 | const DocLnk *current(); |
51 | void useSelectedDocument(); | 39 | void useSelectedDocument(); |
52 | /* QTimer * menuTimer; */ | ||
53 | 40 | ||
54 | public slots: | 41 | public slots: |
55 | void setDocument( const QString& fileref ); | 42 | void setDocument( const QString& fileref ); |
56 | void addToSelection( const DocLnk& ); // Add a media file to the playlist | 43 | void addToSelection( const DocLnk& ); // Add a media file to the playlist |
57 | void addToSelection( QListViewItem* ); // Add a media file to the playlist | ||
58 | void addToSelection( QListViewItem*, const QPoint&,int ); // Add a media file to the playlist | ||
59 | void setActiveWindow(); // need to handle this to show the right view | 44 | void setActiveWindow(); // need to handle this to show the right view |
60 | void setPlaylist( bool ); // Show/Hide the playlist | 45 | void setPlaylist( bool ); // Show/Hide the playlist |
61 | void setView( char ); | 46 | void setView( char ); |
62 | void clearList(); | 47 | void clearList(); |
63 | void addAllToList(); | 48 | void addAllToList(); |
64 | void addAllMusicToList(); | 49 | void addAllMusicToList(); |
65 | void addAllVideoToList(); | 50 | void addAllVideoToList(); |
66 | void saveList(); // Save the playlist | 51 | void saveList(); // Save the playlist |
67 | void loadList(); // Load a playlist | 52 | void loadList(); // Load a playlist |
68 | void playIt( QListViewItem *); | ||
69 | bool first(); | 53 | bool first(); |
70 | bool last(); | 54 | bool last(); |
71 | bool next(); | 55 | bool next(); |
72 | bool prev(); | 56 | bool prev(); |
73 | void addSelected(); | ||
74 | void removeSelected(); | ||
75 | void tabChanged(QWidget*); | ||
76 | /* void setFullScreen(); */ | ||
77 | /* void setScaled(); */ | ||
78 | protected: | ||
79 | /* void contentsMousePressEvent( QMouseEvent * e ); */ | ||
80 | /* void contentsMouseReleaseEvent( QMouseEvent * e ); */ | ||
81 | 57 | ||
82 | private: | 58 | private: |
83 | void initializeStates(); | 59 | void initializeStates(); |
84 | void readConfig( Config& cfg ); | 60 | void readConfig( Config& cfg ); |
85 | void writeConfig( Config& cfg ) const; | 61 | void writeConfig( Config& cfg ) const; |
86 | PlayListWidgetPrivate *d; // Private implementation data | 62 | PlayListWidgetPrivate *d; // Private implementation data |
87 | |||
88 | protected slots: | ||
89 | /* void cancelMenuTimer(); */ | ||
90 | /* void showFileMenu(); */ | ||
91 | |||
92 | |||
93 | }; | 63 | }; |
94 | 64 | ||
95 | 65 | ||
96 | #endif // PLAY_LIST_WIDGET_H | 66 | #endif // PLAY_LIST_WIDGET_H |
97 | 67 | ||
diff --git a/core/multimedia/opieplayer/videowidget.cpp b/core/multimedia/opieplayer/videowidget.cpp index 1f128a4..12ae4fd 100644 --- a/core/multimedia/opieplayer/videowidget.cpp +++ b/core/multimedia/opieplayer/videowidget.cpp | |||
@@ -1,423 +1,424 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | |||
20 | #include <qpe/resource.h> | 21 | #include <qpe/resource.h> |
21 | #include "mediaplayerplugininterface.h" | 22 | #include <qpe/mediaplayerplugininterface.h> |
22 | #include <qwidget.h> | 23 | #include <qwidget.h> |
23 | #include <qpainter.h> | 24 | #include <qpainter.h> |
24 | #include <qpixmap.h> | 25 | #include <qpixmap.h> |
25 | #include <qslider.h> | 26 | #include <qslider.h> |
26 | #include <qdrawutil.h> | 27 | #include <qdrawutil.h> |
27 | #include "videowidget.h" | 28 | #include "videowidget.h" |
28 | #include "mediaplayerstate.h" | 29 | #include "mediaplayerstate.h" |
29 | 30 | ||
30 | 31 | ||
31 | #ifdef Q_WS_QWS | 32 | #ifdef Q_WS_QWS |
32 | # define USE_DIRECT_PAINTER | 33 | # define USE_DIRECT_PAINTER |
33 | # include <qdirectpainter_qws.h> | 34 | # include <qdirectpainter_qws.h> |
34 | # include <qgfxraster_qws.h> | 35 | # include <qgfxraster_qws.h> |
35 | #endif | 36 | #endif |
36 | 37 | ||
37 | 38 | ||
38 | extern MediaPlayerState *mediaPlayerState; | 39 | extern MediaPlayerState *mediaPlayerState; |
39 | 40 | ||
40 | 41 | ||
41 | static const int xo = 2; // movable x offset | 42 | static const int xo = 2; // movable x offset |
42 | static const int yo = 0; // movable y offset | 43 | static const int yo = 0; // movable y offset |
43 | 44 | ||
44 | 45 | ||
45 | struct MediaButton { | 46 | struct MediaButton { |
46 | int xPos, yPos; | 47 | int xPos, yPos; |
47 | bool isToggle, isHeld, isDown; | 48 | bool isToggle, isHeld, isDown; |
48 | int controlType; | 49 | int controlType; |
49 | }; | 50 | }; |
50 | 51 | ||
51 | 52 | ||
52 | // Layout information for the videoButtons (and if it is a toggle button or not) | 53 | // Layout information for the videoButtons (and if it is a toggle button or not) |
53 | MediaButton videoButtons[] = { | 54 | MediaButton videoButtons[] = { |
54 | { 5+0*32+xo, 200+yo, FALSE, FALSE, FALSE, 4 }, // previous | 55 | { 5+0*32+xo, 200+yo, FALSE, FALSE, FALSE, 4 }, // previous |
55 | { 5+1*32+xo, 200+yo, FALSE, FALSE, FALSE, 1 }, // stop | 56 | { 5+1*32+xo, 200+yo, FALSE, FALSE, FALSE, 1 }, // stop |
56 | { 5+2*32+xo, 200+yo, TRUE, FALSE, FALSE, 0 }, // play | 57 | { 5+2*32+xo, 200+yo, TRUE, FALSE, FALSE, 0 }, // play |
57 | { 5+3*32+xo, 200+yo, TRUE, FALSE, FALSE, 2 }, // pause | 58 | { 5+3*32+xo, 200+yo, TRUE, FALSE, FALSE, 2 }, // pause |
58 | { 5+4*32+xo, 200+yo, FALSE, FALSE, FALSE, 3 }, // next | 59 | { 5+4*32+xo, 200+yo, FALSE, FALSE, FALSE, 3 }, // next |
59 | { 5+5*32+xo, 200+yo, FALSE, FALSE, FALSE, 8 }, // playlist | 60 | { 5+5*32+xo, 200+yo, FALSE, FALSE, FALSE, 8 }, // playlist |
60 | { 5+6*32+xo, 200+yo, TRUE, FALSE, FALSE, 9 } // fullscreen | 61 | { 5+6*32+xo, 200+yo, TRUE, FALSE, FALSE, 9 } // fullscreen |
61 | }; | 62 | }; |
62 | 63 | ||
63 | 64 | ||
64 | static const int numButtons = (sizeof(videoButtons)/sizeof(MediaButton)); | 65 | static const int numButtons = (sizeof(videoButtons)/sizeof(MediaButton)); |
65 | 66 | ||
66 | 67 | ||
67 | VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : | 68 | VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : |
68 | QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { | 69 | QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { |
69 | setCaption( tr("OpiePlayer") ); | 70 | setCaption( tr("MediaPlayer") ); |
70 | setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/metalFinish" ) ); | 71 | setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/metalFinish" ) ); |
71 | pixmaps[0] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaButton0a" ) ); | 72 | pixmaps[0] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaButton0a" ) ); |
72 | pixmaps[1] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaButton0b" ) ); | 73 | pixmaps[1] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaButton0b" ) ); |
73 | pixmaps[2] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaControls0" ) ); | 74 | pixmaps[2] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaControls0" ) ); |
74 | currentFrame = new QImage( 220 + 2, 160, (QPixmap::defaultDepth() == 16) ? 16 : 32 ); | 75 | currentFrame = new QImage( 220 + 2, 160, (QPixmap::defaultDepth() == 16) ? 16 : 32 ); |
75 | 76 | ||
76 | slider = new QSlider( Qt::Horizontal, this ); | 77 | slider = new QSlider( Qt::Horizontal, this ); |
77 | slider->setMinValue( 0 ); | 78 | slider->setMinValue( 0 ); |
78 | slider->setMaxValue( 1 ); | 79 | slider->setMaxValue( 1 ); |
79 | slider->setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/metalFinish" ) ); | 80 | slider->setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/metalFinish" ) ); |
80 | slider->setFocusPolicy( QWidget::NoFocus ); | 81 | slider->setFocusPolicy( QWidget::NoFocus ); |
81 | slider->setGeometry( QRect( 7, 250, 220, 20 ) ); | 82 | slider->setGeometry( QRect( 7, 250, 220, 20 ) ); |
82 | 83 | ||
83 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 84 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
84 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 85 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
85 | 86 | ||
86 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); | 87 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); |
87 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 88 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
88 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 89 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
89 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); | 90 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); |
90 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); | 91 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); |
91 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); | 92 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); |
92 | 93 | ||
93 | // Intialise state | 94 | // Intialise state |
94 | setLength( mediaPlayerState->length() ); | 95 | setLength( mediaPlayerState->length() ); |
95 | setPosition( mediaPlayerState->position() ); | 96 | setPosition( mediaPlayerState->position() ); |
96 | setFullscreen( mediaPlayerState->fullscreen() ); | 97 | setFullscreen( mediaPlayerState->fullscreen() ); |
97 | setPaused( mediaPlayerState->paused() ); | 98 | setPaused( mediaPlayerState->paused() ); |
98 | setPlaying( mediaPlayerState->playing() ); | 99 | setPlaying( mediaPlayerState->playing() ); |
99 | } | 100 | } |
100 | 101 | ||
101 | 102 | ||
102 | VideoWidget::~VideoWidget() { | 103 | VideoWidget::~VideoWidget() { |
103 | for ( int i = 0; i < 3; i++ ) | 104 | for ( int i = 0; i < 3; i++ ) |
104 | delete pixmaps[i]; | 105 | delete pixmaps[i]; |
105 | delete currentFrame; | 106 | delete currentFrame; |
106 | } | 107 | } |
107 | 108 | ||
108 | 109 | ||
109 | static bool videoSliderBeingMoved = FALSE; | 110 | static bool videoSliderBeingMoved = FALSE; |
110 | 111 | ||
111 | 112 | ||
112 | void VideoWidget::sliderPressed() { | 113 | void VideoWidget::sliderPressed() { |
113 | videoSliderBeingMoved = TRUE; | 114 | videoSliderBeingMoved = TRUE; |
114 | } | 115 | } |
115 | 116 | ||
116 | 117 | ||
117 | void VideoWidget::sliderReleased() { | 118 | void VideoWidget::sliderReleased() { |
118 | videoSliderBeingMoved = FALSE; | 119 | videoSliderBeingMoved = FALSE; |
119 | if ( slider->width() == 0 ) | 120 | if ( slider->width() == 0 ) |
120 | return; | 121 | return; |
121 | long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); | 122 | long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); |
122 | mediaPlayerState->setPosition( val ); | 123 | mediaPlayerState->setPosition( val ); |
123 | } | 124 | } |
124 | 125 | ||
125 | 126 | ||
126 | void VideoWidget::setPosition( long i ) { | 127 | void VideoWidget::setPosition( long i ) { |
127 | updateSlider( i, mediaPlayerState->length() ); | 128 | updateSlider( i, mediaPlayerState->length() ); |
128 | } | 129 | } |
129 | 130 | ||
130 | 131 | ||
131 | void VideoWidget::setLength( long max ) { | 132 | void VideoWidget::setLength( long max ) { |
132 | updateSlider( mediaPlayerState->position(), max ); | 133 | updateSlider( mediaPlayerState->position(), max ); |
133 | } | 134 | } |
134 | 135 | ||
135 | 136 | ||
136 | void VideoWidget::setView( char view ) { | 137 | void VideoWidget::setView( char view ) { |
137 | if ( view == 'v' ) { | 138 | if ( view == 'v' ) { |
138 | makeVisible(); | 139 | makeVisible(); |
139 | } else { | 140 | } else { |
140 | // Effectively blank the view next time we show it so it looks nicer | 141 | // Effectively blank the view next time we show it so it looks nicer |
141 | scaledWidth = 0; | 142 | scaledWidth = 0; |
142 | scaledHeight = 0; | 143 | scaledHeight = 0; |
143 | hide(); | 144 | hide(); |
144 | } | 145 | } |
145 | } | 146 | } |
146 | 147 | ||
147 | 148 | ||
148 | void VideoWidget::updateSlider( long i, long max ) { | 149 | void VideoWidget::updateSlider( long i, long max ) { |
149 | // Will flicker too much if we don't do this | 150 | // Will flicker too much if we don't do this |
150 | if ( max == 0 ) | 151 | if ( max == 0 ) |
151 | return; | 152 | return; |
152 | int width = slider->width(); | 153 | int width = slider->width(); |
153 | int val = int((double)i * width / max); | 154 | int val = int((double)i * width / max); |
154 | if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) { | 155 | if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) { |
155 | if ( slider->value() != val ) | 156 | if ( slider->value() != val ) |
156 | slider->setValue( val ); | 157 | slider->setValue( val ); |
157 | if ( slider->maxValue() != width ) | 158 | if ( slider->maxValue() != width ) |
158 | slider->setMaxValue( width ); | 159 | slider->setMaxValue( width ); |
159 | } | 160 | } |
160 | } | 161 | } |
161 | 162 | ||
162 | 163 | ||
163 | void VideoWidget::setToggleButton( int i, bool down ) { | 164 | void VideoWidget::setToggleButton( int i, bool down ) { |
164 | if ( down != videoButtons[i].isDown ) | 165 | if ( down != videoButtons[i].isDown ) |
165 | toggleButton( i ); | 166 | toggleButton( i ); |
166 | } | 167 | } |
167 | 168 | ||
168 | 169 | ||
169 | void VideoWidget::toggleButton( int i ) { | 170 | void VideoWidget::toggleButton( int i ) { |
170 | videoButtons[i].isDown = !videoButtons[i].isDown; | 171 | videoButtons[i].isDown = !videoButtons[i].isDown; |
171 | QPainter p(this); | 172 | QPainter p(this); |
172 | paintButton ( &p, i ); | 173 | paintButton ( &p, i ); |
173 | } | 174 | } |
174 | 175 | ||
175 | 176 | ||
176 | void VideoWidget::paintButton( QPainter *p, int i ) { | 177 | void VideoWidget::paintButton( QPainter *p, int i ) { |
177 | int x = videoButtons[i].xPos; | 178 | int x = videoButtons[i].xPos; |
178 | int y = videoButtons[i].yPos; | 179 | int y = videoButtons[i].yPos; |
179 | int offset = 10 + videoButtons[i].isDown; | 180 | int offset = 10 + videoButtons[i].isDown; |
180 | p->drawPixmap( x, y, *pixmaps[videoButtons[i].isDown] ); | 181 | p->drawPixmap( x, y, *pixmaps[videoButtons[i].isDown] ); |
181 | p->drawPixmap( x + 1 + offset, y + offset, *pixmaps[2], 9 * videoButtons[i].controlType, 0, 9, 9 ); | 182 | p->drawPixmap( x + 1 + offset, y + offset, *pixmaps[2], 9 * videoButtons[i].controlType, 0, 9, 9 ); |
182 | } | 183 | } |
183 | 184 | ||
184 | 185 | ||
185 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { | 186 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { |
186 | for ( int i = 0; i < numButtons; i++ ) { | 187 | for ( int i = 0; i < numButtons; i++ ) { |
187 | int x = videoButtons[i].xPos; | 188 | int x = videoButtons[i].xPos; |
188 | int y = videoButtons[i].yPos; | 189 | int y = videoButtons[i].yPos; |
189 | if ( event->state() == QMouseEvent::LeftButton ) { | 190 | if ( event->state() == QMouseEvent::LeftButton ) { |
190 | // The test to see if the mouse click is inside the circular button or not | 191 | // The test to see if the mouse click is inside the circular button or not |
191 | // (compared with the radius squared to avoid a square-root of our distance) | 192 | // (compared with the radius squared to avoid a square-root of our distance) |
192 | int radius = 16; | 193 | int radius = 16; |
193 | QPoint center = QPoint( x + radius, y + radius ); | 194 | QPoint center = QPoint( x + radius, y + radius ); |
194 | QPoint dXY = center - event->pos(); | 195 | QPoint dXY = center - event->pos(); |
195 | int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y(); | 196 | int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y(); |
196 | bool isOnButton = dist <= (radius * radius); | 197 | bool isOnButton = dist <= (radius * radius); |
197 | if ( isOnButton != videoButtons[i].isHeld ) { | 198 | if ( isOnButton != videoButtons[i].isHeld ) { |
198 | videoButtons[i].isHeld = isOnButton; | 199 | videoButtons[i].isHeld = isOnButton; |
199 | toggleButton(i); | 200 | toggleButton(i); |
200 | } | 201 | } |
201 | } else { | 202 | } else { |
202 | if ( videoButtons[i].isHeld ) { | 203 | if ( videoButtons[i].isHeld ) { |
203 | videoButtons[i].isHeld = FALSE; | 204 | videoButtons[i].isHeld = FALSE; |
204 | if ( !videoButtons[i].isToggle ) | 205 | if ( !videoButtons[i].isToggle ) |
205 | setToggleButton( i, FALSE ); | 206 | setToggleButton( i, FALSE ); |
206 | switch (i) { | 207 | switch (i) { |
207 | case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return; | 208 | case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return; |
208 | case VideoStop: mediaPlayerState->setPlaying(FALSE); return; | 209 | case VideoStop: mediaPlayerState->setPlaying(FALSE); return; |
209 | case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return; | 210 | case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return; |
210 | case VideoNext: mediaPlayerState->setNext(); return; | 211 | case VideoNext: mediaPlayerState->setNext(); return; |
211 | case VideoPrevious: mediaPlayerState->setPrev(); return; | 212 | case VideoPrevious: mediaPlayerState->setPrev(); return; |
212 | case VideoPlayList: mediaPlayerState->setList(); return; | 213 | case VideoPlayList: mediaPlayerState->setList(); return; |
213 | case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; | 214 | case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; |
214 | } | 215 | } |
215 | } | 216 | } |
216 | } | 217 | } |
217 | } | 218 | } |
218 | } | 219 | } |
219 | 220 | ||
220 | 221 | ||
221 | void VideoWidget::mousePressEvent( QMouseEvent *event ) { | 222 | void VideoWidget::mousePressEvent( QMouseEvent *event ) { |
222 | mouseMoveEvent( event ); | 223 | mouseMoveEvent( event ); |
223 | } | 224 | } |
224 | 225 | ||
225 | 226 | ||
226 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { | 227 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { |
227 | if ( mediaPlayerState->fullscreen() ) { | 228 | if ( mediaPlayerState->fullscreen() ) { |
228 | mediaPlayerState->setFullscreen( FALSE ); | 229 | mediaPlayerState->setFullscreen( FALSE ); |
229 | makeVisible(); | 230 | makeVisible(); |
230 | } else { | 231 | } else { |
231 | mouseMoveEvent( event ); | 232 | mouseMoveEvent( event ); |
232 | } | 233 | } |
233 | } | 234 | } |
234 | 235 | ||
235 | 236 | ||
236 | void VideoWidget::makeVisible() { | 237 | void VideoWidget::makeVisible() { |
237 | if ( mediaPlayerState->fullscreen() ) { | 238 | if ( mediaPlayerState->fullscreen() ) { |
238 | setBackgroundMode( QWidget::NoBackground ); | 239 | setBackgroundMode( QWidget::NoBackground ); |
239 | showFullScreen(); | 240 | showFullScreen(); |
240 | resize( qApp->desktop()->size() ); | 241 | resize( qApp->desktop()->size() ); |
241 | slider->hide(); | 242 | slider->hide(); |
242 | } else { | 243 | } else { |
243 | setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/metalFinish" ) ); | 244 | setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/metalFinish" ) ); |
244 | showNormal(); | 245 | showNormal(); |
245 | showMaximized(); | 246 | showMaximized(); |
246 | slider->show(); | 247 | slider->show(); |
247 | } | 248 | } |
248 | } | 249 | } |
249 | 250 | ||
250 | 251 | ||
251 | void VideoWidget::paintEvent( QPaintEvent * ) { | 252 | void VideoWidget::paintEvent( QPaintEvent * ) { |
252 | QPainter p( this ); | 253 | QPainter p( this ); |
253 | 254 | ||
254 | if ( mediaPlayerState->fullscreen() ) { | 255 | if ( mediaPlayerState->fullscreen() ) { |
255 | // Clear the background | 256 | // Clear the background |
256 | p.setBrush( QBrush( Qt::black ) ); | 257 | p.setBrush( QBrush( Qt::black ) ); |
257 | p.drawRect( rect() ); | 258 | p.drawRect( rect() ); |
258 | 259 | ||
259 | // Draw the current frame | 260 | // Draw the current frame |
260 | //p.drawImage( ); // If using directpainter we won't have a copy except whats on the screen | 261 | //p.drawImage( ); // If using directpainter we won't have a copy except whats on the screen |
261 | } else { | 262 | } else { |
262 | // draw border | 263 | // draw border |
263 | qDrawShadePanel( &p, 4, 15, 230, 170, colorGroup(), TRUE, 5, NULL ); | 264 | qDrawShadePanel( &p, 4, 15, 230, 170, colorGroup(), TRUE, 5, NULL ); |
264 | 265 | ||
265 | // Clear the movie screen first | 266 | // Clear the movie screen first |
266 | p.setBrush( QBrush( Qt::black ) ); | 267 | p.setBrush( QBrush( Qt::black ) ); |
267 | p.drawRect( 9, 20, 220, 160 ); | 268 | p.drawRect( 9, 20, 220, 160 ); |
268 | 269 | ||
269 | // draw current frame (centrally positioned from scaling to maintain aspect ratio) | 270 | // draw current frame (centrally positioned from scaling to maintain aspect ratio) |
270 | p.drawImage( 9 + (220 - scaledWidth) / 2, 20 + (160 - scaledHeight) / 2, *currentFrame, 0, 0, scaledWidth, scaledHeight ); | 271 | p.drawImage( 9 + (220 - scaledWidth) / 2, 20 + (160 - scaledHeight) / 2, *currentFrame, 0, 0, scaledWidth, scaledHeight ); |
271 | 272 | ||
272 | // draw the buttons | 273 | // draw the buttons |
273 | for ( int i = 0; i < numButtons; i++ ) | 274 | for ( int i = 0; i < numButtons; i++ ) |
274 | paintButton( &p, i ); | 275 | paintButton( &p, i ); |
275 | 276 | ||
276 | // draw the slider | 277 | // draw the slider |
277 | slider->repaint( TRUE ); | 278 | slider->repaint( TRUE ); |
278 | } | 279 | } |
279 | } | 280 | } |
280 | 281 | ||
281 | 282 | ||
282 | void VideoWidget::closeEvent( QCloseEvent* ) { | 283 | void VideoWidget::closeEvent( QCloseEvent* ) { |
283 | mediaPlayerState->setList(); | 284 | mediaPlayerState->setList(); |
284 | } | 285 | } |
285 | 286 | ||
286 | 287 | ||
287 | bool VideoWidget::playVideo() { | 288 | bool VideoWidget::playVideo() { |
288 | bool result = FALSE; | 289 | bool result = FALSE; |
289 | 290 | ||
290 | int stream = 0; | 291 | int stream = 0; |
291 | 292 | ||
292 | int sw = mediaPlayerState->curDecoder()->videoWidth( stream ); | 293 | int sw = mediaPlayerState->curDecoder()->videoWidth( stream ); |
293 | int sh = mediaPlayerState->curDecoder()->videoHeight( stream ); | 294 | int sh = mediaPlayerState->curDecoder()->videoHeight( stream ); |
294 | int dd = QPixmap::defaultDepth(); | 295 | int dd = QPixmap::defaultDepth(); |
295 | int w = height(); | 296 | int w = height(); |
296 | int h = width(); | 297 | int h = width(); |
297 | 298 | ||
298 | ColorFormat format = (dd == 16) ? RGB565 : BGRA8888; | 299 | ColorFormat format = (dd == 16) ? RGB565 : BGRA8888; |
299 | 300 | ||
300 | if ( mediaPlayerState->fullscreen() ) { | 301 | if ( mediaPlayerState->fullscreen() ) { |
301 | #ifdef USE_DIRECT_PAINTER | 302 | #ifdef USE_DIRECT_PAINTER |
302 | QDirectPainter p(this); | 303 | QDirectPainter p(this); |
303 | 304 | ||
304 | if ( ( qt_screen->transformOrientation() == 3 ) && | 305 | if ( ( qt_screen->transformOrientation() == 3 ) && |
305 | ( ( dd == 16 ) || ( dd == 32 ) ) && ( p.numRects() == 1 ) ) { | 306 | ( ( dd == 16 ) || ( dd == 32 ) ) && ( p.numRects() == 1 ) ) { |
306 | 307 | ||
307 | w = 320; | 308 | w = 320; |
308 | h = 240; | 309 | h = 240; |
309 | 310 | ||
310 | if ( mediaPlayerState->scaled() ) { | 311 | if ( mediaPlayerState->scaled() ) { |
311 | // maintain aspect ratio | 312 | // maintain aspect ratio |
312 | if ( w * sh > sw * h ) | 313 | if ( w * sh > sw * h ) |
313 | w = sw * h / sh; | 314 | w = sw * h / sh; |
314 | else | 315 | else |
315 | h = sh * w / sw; | 316 | h = sh * w / sw; |
316 | } else { | 317 | } else { |
317 | w = sw; | 318 | w = sw; |
318 | h = sh; | 319 | h = sh; |
319 | } | 320 | } |
320 | 321 | ||
321 | w--; // we can't allow libmpeg to overwrite. | 322 | w--; // we can't allow libmpeg to overwrite. |
322 | QPoint roff = qt_screen->mapToDevice( p.offset(), QSize( qt_screen->width(), qt_screen->height() ) ); | 323 | QPoint roff = qt_screen->mapToDevice( p.offset(), QSize( qt_screen->width(), qt_screen->height() ) ); |
323 | 324 | ||
324 | int ox = roff.x() - height() + 2 + (height() - w) / 2; | 325 | int ox = roff.x() - height() + 2 + (height() - w) / 2; |
325 | int oy = roff.y() + (width() - h) / 2; | 326 | int oy = roff.y() + (width() - h) / 2; |
326 | int sx = 0, sy = 0; | 327 | int sx = 0, sy = 0; |
327 | 328 | ||
328 | uchar* fp = p.frameBuffer() + p.lineStep() * oy; | 329 | uchar* fp = p.frameBuffer() + p.lineStep() * oy; |
329 | fp += dd * ox / 8; | 330 | fp += dd * ox / 8; |
330 | uchar **jt = new uchar*[h]; | 331 | uchar **jt = new uchar*[h]; |
331 | for ( int i = h; i; i-- ) { | 332 | for ( int i = h; i; i-- ) { |
332 | jt[h - i] = fp; | 333 | jt[h - i] = fp; |
333 | fp += p.lineStep(); | 334 | fp += p.lineStep(); |
334 | } | 335 | } |
335 | 336 | ||
336 | result = mediaPlayerState->curDecoder()->videoReadScaledFrame( jt, sx, sy, sw, sh, w, h, format, 0) == 0; | 337 | result = mediaPlayerState->curDecoder()->videoReadScaledFrame( jt, sx, sy, sw, sh, w, h, format, 0) == 0; |
337 | 338 | ||
338 | delete [] jt; | 339 | delete [] jt; |
339 | } else { | 340 | } else { |
340 | #endif | 341 | #endif |
341 | QPainter p(this); | 342 | QPainter p(this); |
342 | 343 | ||
343 | w = 320; | 344 | w = 320; |
344 | h = 240; | 345 | h = 240; |
345 | 346 | ||
346 | if ( mediaPlayerState->scaled() ) { | 347 | if ( mediaPlayerState->scaled() ) { |
347 | // maintain aspect ratio | 348 | // maintain aspect ratio |
348 | if ( w * sh > sw * h ) | 349 | if ( w * sh > sw * h ) |
349 | w = sw * h / sh; | 350 | w = sw * h / sh; |
350 | else | 351 | else |
351 | h = sh * w / sw; | 352 | h = sh * w / sw; |
352 | } else { | 353 | } else { |
353 | w = sw; | 354 | w = sw; |
354 | h = sh; | 355 | h = sh; |
355 | } | 356 | } |
356 | 357 | ||
357 | int bytes = ( dd == 16 ) ? 2 : 4; | 358 | int bytes = ( dd == 16 ) ? 2 : 4; |
358 | QImage tempFrame( w, h, bytes << 3 ); | 359 | QImage tempFrame( w, h, bytes << 3 ); |
359 | result = mediaPlayerState->curDecoder()->videoReadScaledFrame( tempFrame.jumpTable(), | 360 | result = mediaPlayerState->curDecoder()->videoReadScaledFrame( tempFrame.jumpTable(), |
360 | 0, 0, sw, sh, w, h, format, 0) == 0; | 361 | 0, 0, sw, sh, w, h, format, 0) == 0; |
361 | if ( result && mediaPlayerState->fullscreen() ) { | 362 | if ( result && mediaPlayerState->fullscreen() ) { |
362 | 363 | ||
363 | int rw = h, rh = w; | 364 | int rw = h, rh = w; |
364 | QImage rotatedFrame( rw, rh, bytes << 3 ); | 365 | QImage rotatedFrame( rw, rh, bytes << 3 ); |
365 | 366 | ||
366 | ushort* in = (ushort*)tempFrame.bits(); | 367 | ushort* in = (ushort*)tempFrame.bits(); |
367 | ushort* out = (ushort*)rotatedFrame.bits(); | 368 | ushort* out = (ushort*)rotatedFrame.bits(); |
368 | int spl = rotatedFrame.bytesPerLine() / bytes; | 369 | int spl = rotatedFrame.bytesPerLine() / bytes; |
369 | for (int x=0; x<h; x++) { | 370 | for (int x=0; x<h; x++) { |
370 | if ( bytes == 2 ) { | 371 | if ( bytes == 2 ) { |
371 | ushort* lout = out++ + (w - 1)*spl; | 372 | ushort* lout = out++ + (w - 1)*spl; |
372 | for (int y=0; y<w; y++) { | 373 | for (int y=0; y<w; y++) { |
373 | *lout=*in++; | 374 | *lout=*in++; |
374 | lout-=spl; | 375 | lout-=spl; |
375 | } | 376 | } |
376 | } else { | 377 | } else { |
377 | ulong* lout = ((ulong *)out)++ + (w - 1)*spl; | 378 | ulong* lout = ((ulong *)out)++ + (w - 1)*spl; |
378 | for (int y=0; y<w; y++) { | 379 | for (int y=0; y<w; y++) { |
379 | *lout=*((ulong*)in)++; | 380 | *lout=*((ulong*)in)++; |
380 | lout-=spl; | 381 | lout-=spl; |
381 | } | 382 | } |
382 | } | 383 | } |
383 | } | 384 | } |
384 | 385 | ||
385 | p.drawImage( (240 - rw) / 2, (320 - rh) / 2, rotatedFrame, 0, 0, rw, rh ); | 386 | p.drawImage( (240 - rw) / 2, (320 - rh) / 2, rotatedFrame, 0, 0, rw, rh ); |
386 | } | 387 | } |
387 | #ifdef USE_DIRECT_PAINTER | 388 | #ifdef USE_DIRECT_PAINTER |
388 | } | 389 | } |
389 | #endif | 390 | #endif |
390 | } else { | 391 | } else { |
391 | 392 | ||
392 | w = 220; | 393 | w = 220; |
393 | h = 160; | 394 | h = 160; |
394 | 395 | ||
395 | // maintain aspect ratio | 396 | // maintain aspect ratio |
396 | if ( w * sh > sw * h ) | 397 | if ( w * sh > sw * h ) |
397 | w = sw * h / sh; | 398 | w = sw * h / sh; |
398 | else | 399 | else |
399 | h = sh * w / sw; | 400 | h = sh * w / sw; |
400 | 401 | ||
401 | result = mediaPlayerState->curDecoder()->videoReadScaledFrame( currentFrame->jumpTable(), 0, 0, sw, sh, w, h, format, 0) == 0; | 402 | result = mediaPlayerState->curDecoder()->videoReadScaledFrame( currentFrame->jumpTable(), 0, 0, sw, sh, w, h, format, 0) == 0; |
402 | 403 | ||
403 | QPainter p( this ); | 404 | QPainter p( this ); |
404 | 405 | ||
405 | // Image changed size, therefore need to blank the possibly unpainted regions first | 406 | // Image changed size, therefore need to blank the possibly unpainted regions first |
406 | if ( scaledWidth != w || scaledHeight != h ) { | 407 | if ( scaledWidth != w || scaledHeight != h ) { |
407 | p.setBrush( QBrush( Qt::black ) ); | 408 | p.setBrush( QBrush( Qt::black ) ); |
408 | p.drawRect( 9, 20, 220, 160 ); | 409 | p.drawRect( 9, 20, 220, 160 ); |
409 | } | 410 | } |
410 | 411 | ||
411 | scaledWidth = w; | 412 | scaledWidth = w; |
412 | scaledHeight = h; | 413 | scaledHeight = h; |
413 | 414 | ||
414 | if ( result ) { | 415 | if ( result ) { |
415 | p.drawImage( 9 + (220 - scaledWidth) / 2, 20 + (160 - scaledHeight) / 2, *currentFrame, 0, 0, scaledWidth, scaledHeight ); | 416 | p.drawImage( 9 + (220 - scaledWidth) / 2, 20 + (160 - scaledHeight) / 2, *currentFrame, 0, 0, scaledWidth, scaledHeight ); |
416 | } | 417 | } |
417 | 418 | ||
418 | } | 419 | } |
419 | 420 | ||
420 | return result; | 421 | return result; |
421 | } | 422 | } |
422 | 423 | ||
423 | 424 | ||
diff --git a/core/multimedia/opieplayer/videowidget.h b/core/multimedia/opieplayer/videowidget.h index 8b49091..cf13743 100644 --- a/core/multimedia/opieplayer/videowidget.h +++ b/core/multimedia/opieplayer/videowidget.h | |||
@@ -1,58 +1,57 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef VIDEO_WIDGET_H | 20 | #ifndef VIDEO_WIDGET_H |
21 | #define VIDEO_WIDGET_H | 21 | #define VIDEO_WIDGET_H |
22 | 22 | ||
23 | 23 | ||
24 | #include <qwidget.h> | 24 | #include <qwidget.h> |
25 | 25 | ||
26 | |||
27 | class QPixmap; | 26 | class QPixmap; |
28 | class QSlider; | 27 | class QSlider; |
29 | 28 | ||
30 | 29 | ||
31 | enum VideoButtons { | 30 | enum VideoButtons { |
32 | VideoPrevious, | 31 | VideoPrevious, |
33 | VideoStop, | 32 | VideoStop, |
34 | VideoPlay, | 33 | VideoPlay, |
35 | VideoPause, | 34 | VideoPause, |
36 | VideoNext, | 35 | VideoNext, |
37 | VideoPlayList, | 36 | VideoPlayList, |
38 | VideoFullscreen | 37 | VideoFullscreen |
39 | }; | 38 | }; |
40 | 39 | ||
41 | 40 | ||
42 | class VideoWidget : public QWidget { | 41 | class VideoWidget : public QWidget { |
43 | Q_OBJECT | 42 | Q_OBJECT |
44 | public: | 43 | public: |
45 | VideoWidget( QWidget* parent=0, const char* name=0, WFlags f=0 ); | 44 | VideoWidget( QWidget* parent=0, const char* name=0, WFlags f=0 ); |
46 | ~VideoWidget(); | 45 | ~VideoWidget(); |
47 | 46 | ||
48 | bool playVideo(); | 47 | bool playVideo(); |
49 | 48 | ||
50 | public slots: | 49 | public slots: |
51 | void updateSlider( long, long ); | 50 | void updateSlider( long, long ); |
52 | void sliderPressed( ); | 51 | void sliderPressed( ); |
53 | void sliderReleased( ); | 52 | void sliderReleased( ); |
54 | void setPaused( bool b) { setToggleButton( VideoPause, b ); } | 53 | void setPaused( bool b) { setToggleButton( VideoPause, b ); } |
55 | void setPlaying( bool b) { setToggleButton( VideoPlay, b ); } | 54 | void setPlaying( bool b) { setToggleButton( VideoPlay, b ); } |
56 | void setFullscreen( bool b ) { setToggleButton( VideoFullscreen, b ); } | 55 | void setFullscreen( bool b ) { setToggleButton( VideoFullscreen, b ); } |
57 | void makeVisible(); | 56 | void makeVisible(); |
58 | void setPosition( long ); | 57 | void setPosition( long ); |
diff --git a/core/multimedia/opieplayer/wavplugin/Makefile.in b/core/multimedia/opieplayer/wavplugin/Makefile.in index a46b925..bcbe7f2 100644 --- a/core/multimedia/opieplayer/wavplugin/Makefile.in +++ b/core/multimedia/opieplayer/wavplugin/Makefile.in | |||
@@ -71,41 +71,39 @@ tmake: | |||
71 | clean: | 71 | clean: |
72 | -rm -f $(OBJECTS) $(OBJMOC) $(SRCMOC) $(UICIMPLS) $(UICDECLS) | 72 | -rm -f $(OBJECTS) $(OBJMOC) $(SRCMOC) $(UICIMPLS) $(UICDECLS) |
73 | -rm -f *~ core | 73 | -rm -f *~ core |
74 | -rm -f allmoc.cpp | 74 | -rm -f allmoc.cpp |
75 | 75 | ||
76 | ####### Extension Modules | 76 | ####### Extension Modules |
77 | 77 | ||
78 | listpromodules: | 78 | listpromodules: |
79 | @echo | 79 | @echo |
80 | 80 | ||
81 | listallmodules: | 81 | listallmodules: |
82 | @echo | 82 | @echo |
83 | 83 | ||
84 | listaddonpromodules: | 84 | listaddonpromodules: |
85 | @echo | 85 | @echo |
86 | 86 | ||
87 | listaddonentmodules: | 87 | listaddonentmodules: |
88 | @echo | 88 | @echo |
89 | 89 | ||
90 | 90 | ||
91 | REQUIRES= | 91 | REQUIRES= |
92 | 92 | ||
93 | ####### Sub-libraries | 93 | ####### Sub-libraries |
94 | 94 | ||
95 | 95 | ||
96 | ###### Combined headers | 96 | ###### Combined headers |
97 | 97 | ||
98 | 98 | ||
99 | 99 | ||
100 | ####### Compile | 100 | ####### Compile |
101 | 101 | ||
102 | wavplugin.o: wavplugin.cpp \ | 102 | wavplugin.o: wavplugin.cpp \ |
103 | wavplugin.h \ | 103 | wavplugin.h |
104 | ../mediaplayerplugininterface.h | ||
105 | 104 | ||
106 | wavpluginimpl.o: wavpluginimpl.cpp \ | 105 | wavpluginimpl.o: wavpluginimpl.cpp \ |
107 | wavplugin.h \ | 106 | wavplugin.h \ |
108 | ../mediaplayerplugininterface.h \ | ||
109 | wavpluginimpl.h | 107 | wavpluginimpl.h |
110 | 108 | ||
111 | 109 | ||
diff --git a/core/multimedia/opieplayer/wavplugin/wavplugin.cpp b/core/multimedia/opieplayer/wavplugin/wavplugin.cpp index 7f63b3b..0be667f 100644 --- a/core/multimedia/opieplayer/wavplugin/wavplugin.cpp +++ b/core/multimedia/opieplayer/wavplugin/wavplugin.cpp | |||
@@ -1,341 +1,494 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | // L.J.Potter added changes Fri 02-15-2002 | ||
21 | |||
22 | #include <stdio.h> | 20 | #include <stdio.h> |
23 | #include <stdarg.h> | 21 | #include <stdarg.h> |
24 | #include <stdlib.h> | 22 | #include <stdlib.h> |
25 | #include <errno.h> | 23 | #include <errno.h> |
26 | #include <unistd.h> | 24 | #include <unistd.h> |
27 | #include <qfile.h> | 25 | #include <qfile.h> |
28 | #include "wavplugin.h" | 26 | #include "wavplugin.h" |
29 | 27 | ||
30 | |||
31 | //#define debugMsg(a) qDebug(a) | 28 | //#define debugMsg(a) qDebug(a) |
32 | #define debugMsg(a) | 29 | #define debugMsg(a) |
33 | 30 | ||
34 | 31 | ||
35 | struct RiffChunk { | 32 | struct RiffChunk { |
36 | char id[4]; | 33 | char id[4]; |
37 | Q_UINT32 size; | 34 | Q_UINT32 size; |
38 | char data[4]; | 35 | char data[4]; |
39 | }; | 36 | }; |
40 | 37 | ||
41 | 38 | ||
42 | struct ChunkData { | 39 | struct ChunkData { |
43 | Q_INT16 formatTag; | 40 | Q_INT16 formatTag; |
44 | Q_INT16 channels; | 41 | Q_INT16 channels; |
45 | Q_INT32 samplesPerSec; | 42 | Q_INT32 samplesPerSec; |
46 | Q_INT32 avgBytesPerSec; | 43 | Q_INT32 avgBytesPerSec; |
47 | Q_INT16 blockAlign; | 44 | Q_INT16 blockAlign; |
48 | Q_INT16 wBitsPerSample; | 45 | Q_INT16 wBitsPerSample; |
49 | }; | 46 | }; |
50 | 47 | ||
51 | 48 | ||
52 | const int sound_buffer_size = 512; // 4096; // you got to be kidding right? | 49 | const int sound_buffer_size = 4096; |
53 | 50 | ||
54 | 51 | ||
55 | class WavPluginData { | 52 | class WavPluginData { |
56 | public: | 53 | public: |
57 | QFile *input; | 54 | QFile *input; |
58 | 55 | ||
59 | int wavedata_remaining; | 56 | int wavedata_remaining; |
60 | ChunkData chunkdata; | 57 | ChunkData chunkdata; |
61 | RiffChunk chunk; | 58 | RiffChunk chunk; |
62 | uchar data[sound_buffer_size+32]; // +32 to handle badly aligned input data | 59 | uchar data[sound_buffer_size+32]; // +32 to handle badly aligned input data |
63 | int out,max; | 60 | int out,max; |
64 | int samples_due; | 61 | int samples_due; |
65 | int samples; | 62 | int samples; |
66 | 63 | int freq; | |
64 | int chan; | ||
65 | int sampleRate; | ||
66 | int resolution; | ||
67 | |||
67 | WavPluginData() { | 68 | WavPluginData() { |
68 | max = out = sound_buffer_size; | 69 | max = out = sound_buffer_size; |
69 | wavedata_remaining = 0; | 70 | wavedata_remaining = 0; |
70 | samples_due = 0; | 71 | samples_due = 0; |
71 | samples = -1; | 72 | samples = -1; |
72 | } | 73 | } |
73 | 74 | ||
74 | // expands out samples to the frequency of 44kHz | 75 | // expands out samples to the frequency of 44kHz |
75 | bool add( short *output, long count, long& done, bool stereo ) | 76 | bool add( short *output, long count, long& done, bool stereo ) |
76 | { | 77 | { |
77 | done = 0; | 78 | qDebug("add"); |
78 | qApp->processEvents(); | 79 | done = 0; |
79 | 80 | ||
80 | if ( input == 0 ) { | 81 | if ( input == 0 ) { |
81 | qDebug("no input"); | 82 | qDebug("no input"); |
82 | return FALSE; | ||
83 | } | ||
84 | |||
85 | while ( count ) { | ||
86 | int l,r; | ||
87 | if ( getSample(l, r) == FALSE ) { | ||
88 | qDebug("didn't get sample"); | ||
89 | return FALSE; | 83 | return FALSE; |
90 | } | 84 | } |
91 | samples_due += chunkdata.samplesPerSec; | 85 | |
92 | while ( count && (samples_due > chunkdata.samplesPerSec) ) { | 86 | while ( count ) { |
93 | *output++ = l; | 87 | int l,r; |
94 | if ( stereo ) | 88 | if ( getSample(l, r) == FALSE ) { |
95 | *output++ = r; | 89 | qDebug("didn't get sample"); |
96 | samples_due -= chunkdata.samplesPerSec; | 90 | return FALSE; |
97 | count--; | 91 | } |
98 | done++; | 92 | samples_due += 44100; |
93 | while ( count && (samples_due > chunkdata.samplesPerSec) ) { | ||
94 | *output++ = l; | ||
95 | if ( stereo ) | ||
96 | *output++ = r; | ||
97 | samples_due -= chunkdata.samplesPerSec; | ||
98 | count--; | ||
99 | done++; | ||
100 | } | ||
99 | } | 101 | } |
102 | |||
103 | return TRUE; | ||
100 | } | 104 | } |
101 | return TRUE; | ||
102 | } | ||
103 | 105 | ||
104 | bool initialise() { | 106 | bool initialise() { |
105 | if ( input == 0 ) | 107 | qDebug("initialize"); |
106 | return FALSE; | 108 | if ( input == 0 ) |
109 | return FALSE; | ||
110 | |||
111 | wavedata_remaining = -1; | ||
112 | |||
113 | while ( wavedata_remaining == -1 ) { | ||
114 | // Keep reading chunks... | ||
115 | const int n = sizeof(chunk) - sizeof(chunk.data); | ||
116 | int t = input->readBlock( (char*)&chunk, n ); | ||
117 | if ( t != n ) { | ||
118 | if ( t == -1 ) | ||
119 | return FALSE; | ||
120 | return TRUE; | ||
121 | } | ||
122 | if ( qstrncmp(chunk.id,"data",4) == 0 ) { | ||
123 | samples = wavedata_remaining = chunk.size; | ||
124 | } else if ( qstrncmp(chunk.id,"RIFF",4) == 0 ) { | ||
125 | char d[4]; | ||
126 | if ( input->readBlock(d,4) != 4 ) { | ||
127 | return FALSE; | ||
128 | } | ||
129 | if ( qstrncmp(d,"WAVE",4) != 0 ) { | ||
130 | // skip | ||
131 | if ( chunk.size > 1000000000 || !input->at(input->at()+chunk.size-4) ) { | ||
132 | return FALSE; | ||
133 | } | ||
134 | } | ||
135 | } else if ( qstrncmp(chunk.id,"fmt ",4) == 0 ) { | ||
136 | if ( input->readBlock((char*)&chunkdata,sizeof(chunkdata)) != sizeof(chunkdata) ) { | ||
137 | return FALSE; | ||
138 | } | ||
139 | #define WAVE_FORMAT_PCM 1 | ||
140 | if ( chunkdata.formatTag != WAVE_FORMAT_PCM ) { | ||
141 | qDebug("WAV file: UNSUPPORTED FORMAT %d",chunkdata.formatTag); | ||
142 | return FALSE; | ||
143 | } | ||
144 | } | ||
107 | 145 | ||
108 | wavedata_remaining = -1; | ||
109 | 146 | ||
110 | while ( wavedata_remaining == -1 ) { | 147 | |
111 | // Keep reading chunks... | 148 | |
112 | const int n = sizeof(chunk) - sizeof(chunk.data); | 149 | else { |
113 | int t = input->readBlock( (char*)&chunk, n ); | 150 | // ignored chunk |
114 | if ( t != n ) { | 151 | if ( chunk.size > 1000000000 || !input->at(input->at()+chunk.size) ) { |
115 | if ( t == -1 ) | 152 | return FALSE; |
116 | return FALSE; | 153 | } |
117 | return TRUE; | 154 | } |
118 | } | 155 | } // while |
119 | if ( qstrncmp(chunk.id,"data",4) == 0 ) { | 156 | |
120 | samples = wavedata_remaining = chunk.size; | 157 | return TRUE; |
121 | } else if ( qstrncmp(chunk.id,"RIFF",4) == 0 ) { | ||
122 | char d[4]; | ||
123 | if ( input->readBlock(d,4) != 4 ) { | ||
124 | return FALSE; | ||
125 | } | ||
126 | if ( qstrncmp(d,"WAVE",4) != 0 ) { | ||
127 | // skip | ||
128 | if ( chunk.size > 1000000000 || !input->at(input->at()+chunk.size-4) ) { | ||
129 | return FALSE; | ||
130 | } | ||
131 | } | ||
132 | } else if ( qstrncmp(chunk.id,"fmt ",4) == 0 ) { | ||
133 | if ( input->readBlock((char*)&chunkdata,sizeof(chunkdata)) != sizeof(chunkdata) ) { | ||
134 | return FALSE; | ||
135 | } | ||
136 | #define WAVE_FORMAT_PCM 1 | ||
137 | if ( chunkdata.formatTag != WAVE_FORMAT_PCM ) { | ||
138 | qDebug("WAV file: UNSUPPORTED FORMAT %d",chunkdata.formatTag); | ||
139 | return FALSE; | ||
140 | } | ||
141 | } else { | ||
142 | // ignored chunk | ||
143 | if ( chunk.size > 1000000000 || !input->at(input->at()+chunk.size) ) { | ||
144 | return FALSE; | ||
145 | } | ||
146 | } | ||
147 | } // while | ||
148 | qDebug("bits %d", chunkdata.wBitsPerSample); | ||
149 | return TRUE; | ||
150 | } | 158 | } |
151 | 159 | ||
152 | 160 | ||
153 | // gets a sample from the file | 161 | // gets a sample from the file |
154 | bool getSample(int& l, int& r) | 162 | bool getSample(int& l, int& r) |
155 | { | 163 | { |
156 | l = r = 0; | 164 | l = r = 0; |
157 | 165 | ||
158 | if ( input == 0 ) | 166 | if ( input == 0 ) |
159 | return FALSE; | 167 | return FALSE; |
160 | 168 | ||
161 | if ( (wavedata_remaining < 0) || !max ) | 169 | if ( (wavedata_remaining < 0) || !max ) |
162 | return FALSE; | 170 | return FALSE; |
163 | 171 | ||
164 | if ( out >= max ) { | 172 | if ( out >= max ) { |
165 | max = input->readBlock( (char*)data, (uint)QMIN(sound_buffer_size,wavedata_remaining) ); | 173 | max = input->readBlock( (char*)data, (uint)QMIN(sound_buffer_size,wavedata_remaining) ); |
166 | 174 | ||
167 | wavedata_remaining -= max; | 175 | wavedata_remaining -= max; |
168 | 176 | ||
169 | out = 0; | 177 | out = 0; |
170 | if ( max <= 0 ) { | 178 | if ( max <= 0 ) { |
171 | max = 0; | 179 | max = 0; |
172 | return TRUE; | 180 | return TRUE; |
173 | } | 181 | } |
174 | } | 182 | } |
175 | if ( chunkdata.wBitsPerSample == 8 ) { | 183 | if ( resolution == 8 ) { |
176 | l = (data[out++] - 128) * 128; | 184 | l = (data[out++] - 128) * 128; |
177 | } else { | 185 | } else { |
178 | l = ((short*)data)[out/2]; | 186 | l = ((short*)data)[out/2]; |
179 | out += 2; | 187 | out += 2; |
180 | } | 188 | } |
181 | if ( chunkdata.channels == 1 ) { | 189 | if ( chan == 1 ) { |
182 | r = l; | 190 | r = l; |
183 | } else { | 191 | } else { |
184 | if ( chunkdata.wBitsPerSample == 8 ) { | 192 | if ( resolution == 8 ) { |
185 | r = (data[out++] - 128) * 128; | 193 | r = (data[out++] - 128) * 128; |
186 | } else { | 194 | } else { |
187 | r = ((short*)data)[out/2]; | 195 | r = ((short*)data)[out/2]; |
188 | out += 2; | 196 | out += 2; |
189 | } | 197 | } |
190 | } | 198 | } |
191 | return TRUE; | 199 | return TRUE; |
192 | } // getSample | 200 | } // getSample |
201 | |||
202 | ////////////////////////////////////////////////////// | ||
203 | int getWavSettings(int fd) | ||
204 | { //this came from wmrecord | ||
205 | |||
206 | char t1[4]; | ||
207 | unsigned long l1; | ||
208 | int found; | ||
209 | short fmt; | ||
210 | unsigned short ch, brate; | ||
211 | unsigned long srate; | ||
212 | |||
213 | |||
214 | /* First read in the RIFF identifier. If this is missing then the | ||
215 | * file is not a valid WAVE file. | ||
216 | */ | ||
217 | if (read(fd, t1, 4)<4) { | ||
218 | qDebug(" Could not read from sound file.\n"); | ||
219 | return -1; | ||
220 | } | ||
221 | if (strncmp(t1, "RIFF", 4)) { | ||
222 | qDebug(" not a valid WAV file.\n"); | ||
223 | return -1; | ||
224 | } | ||
225 | /* Advance the file pointer to the next relevant field. */ | ||
226 | lseek(fd, 4, SEEK_CUR); | ||
227 | /* Read in the WAVE identifier. */ | ||
228 | if (read(fd, t1, 4)<4) { | ||
229 | qDebug("Could not read from sound file.\n"); | ||
230 | return -1; | ||
231 | } | ||
232 | if (strncmp(t1, "WAVE", 4)) { | ||
233 | qDebug("not a valid WAV file.\n"); | ||
234 | return -1; | ||
235 | } | ||
193 | 236 | ||
237 | /* Search through the file for the format chunk. If the end of the | ||
238 | * file is reached without finding the chunk, then the file is not a | ||
239 | * valid WAVE file. | ||
240 | */ | ||
241 | found = 0; | ||
242 | while (!found) { | ||
243 | if (read(fd, t1, 4)<4) { | ||
244 | qDebug("Could not read from sound file.\n"); | ||
245 | return -1; | ||
246 | } | ||
247 | if (strncmp(t1, "fmt ", 4)) { | ||
248 | /* Determine the length of the chunk found and skip to the next | ||
249 | * chunk. The chunk length is always stored in the four bytes | ||
250 | * following the chunk id. | ||
251 | */ | ||
252 | if (read(fd, &l1, 4)<4) { | ||
253 | qDebug("Could not read from sound file.\n"); | ||
254 | return -1; | ||
255 | } | ||
256 | lseek(fd, l1, SEEK_CUR); | ||
257 | } | ||
258 | else { | ||
259 | /* This is the format chunk, which stores the playback settings | ||
260 | * for the recording. | ||
261 | */ | ||
262 | /* Skip the length field, since we don't really need it. */ | ||
263 | lseek(fd, 4, SEEK_CUR); | ||
264 | /* Read in the format tag. If it has a value of 1, then there is | ||
265 | * no compression and we can attempt to play the file | ||
266 | * back. Otherwise, return. | ||
267 | */ | ||
268 | if (read(fd, &fmt, 2)<2) { | ||
269 | qDebug("Could not read from format chunk.\n"); | ||
270 | return -1; | ||
271 | } | ||
272 | if (fmt != 1) { | ||
273 | qDebug("Wave file contains compressed data." | ||
274 | " Unable to continue.\n"); | ||
275 | return -1; | ||
276 | } | ||
277 | /* Get the stereo mode. */ | ||
278 | if (read(fd, &ch, 2)<2) { | ||
279 | qDebug("Could not read from format chunk.\n"); | ||
280 | return -1; | ||
281 | } | ||
282 | else { | ||
283 | chan = ch; | ||
284 | qDebug("File has %d channels", chan); | ||
285 | } | ||
286 | /* Get the sample rate. */ | ||
287 | if (read(fd, &srate, 4)<4) { | ||
288 | qDebug("Could not read from format chunk.\n"); | ||
289 | return -1; | ||
290 | } | ||
291 | else { | ||
292 | sampleRate = srate; | ||
293 | qDebug("File has samplerate of %d", sampleRate); | ||
294 | } | ||
295 | /* Get the bit rate. This is at the end of the format chunk. */ | ||
296 | lseek(fd, 6, SEEK_CUR); | ||
297 | if (read(fd, &brate, 2)<2) { | ||
298 | qDebug("Could not read from format chunk.\n"); | ||
299 | return -1; | ||
300 | } | ||
301 | else { | ||
302 | resolution = brate; | ||
303 | qDebug("File has bitrate of %d", resolution); | ||
304 | } | ||
305 | |||
306 | found++; | ||
307 | } | ||
308 | } | ||
309 | |||
310 | /* Search through the file for the data chunk. If the end of the | ||
311 | * file is reached without finding the chunk, then the file is not a | ||
312 | * valid WAVE file. | ||
313 | */ | ||
314 | found = 0; | ||
315 | while (!found) { | ||
316 | if (read(fd, t1, 4)<4) { | ||
317 | qDebug("Could not read from sound file.\n"); | ||
318 | return -1; | ||
319 | } | ||
320 | if (strncmp(t1, "data", 4)) { | ||
321 | /* Determine the length of the chunk found and skip to the next | ||
322 | * chunk. The chunk length is always stored in the four bytes | ||
323 | * following the chunk id. | ||
324 | */ | ||
325 | if (read(fd, &l1, 4)<4) { | ||
326 | qDebug("Could not read from sound file.\n"); | ||
327 | return -1; | ||
328 | } | ||
329 | lseek(fd, l1, SEEK_CUR); | ||
330 | } | ||
331 | else { | ||
332 | /* This is the data chunk, which stores the recording. */ | ||
333 | /* Get the length field. */ | ||
334 | if (read(fd, &l1, 4)<4) { | ||
335 | qDebug("Could not read from sound file.\n"); | ||
336 | return -1; | ||
337 | } | ||
338 | else { | ||
339 | samples =l1; | ||
340 | qDebug("file has length of %d\nlasting %d seconds",l1, (( l1 / sampleRate) / chan) / 2 ); // ???? | ||
341 | return l1; | ||
342 | } | ||
343 | } | ||
344 | } | ||
345 | |||
346 | return 0; | ||
347 | } | ||
348 | |||
349 | ////////////////////////////////////////////////// | ||
194 | }; | 350 | }; |
195 | 351 | ||
196 | 352 | ||
197 | WavPlugin::WavPlugin() { | 353 | WavPlugin::WavPlugin() { |
198 | d = new WavPluginData; | 354 | d = new WavPluginData; |
199 | d->input = 0; | 355 | d->input = 0; |
200 | } | 356 | } |
201 | 357 | ||
202 | 358 | ||
203 | WavPlugin::~WavPlugin() { | 359 | WavPlugin::~WavPlugin() { |
204 | close(); | 360 | close(); |
205 | delete d; | 361 | delete d; |
206 | } | 362 | } |
207 | 363 | ||
208 | 364 | ||
209 | bool WavPlugin::isFileSupported( const QString& path ) { | 365 | bool WavPlugin::isFileSupported( const QString& path ) { |
210 | // qDebug( "WavPlugin::isFileSupported" ); | 366 | debugMsg( "WavPlugin::isFileSupported" ); |
211 | 367 | ||
212 | char *ext = strrchr( path.latin1(), '.' ); | 368 | char *ext = strrchr( path.latin1(), '.' ); |
213 | 369 | ||
214 | // Test file extension | 370 | // Test file extension |
215 | if ( ext ) { | 371 | if ( ext ) { |
216 | if ( strncasecmp(ext, ".raw", 4) == 0 ) | 372 | if ( strncasecmp(ext, ".raw", 4) == 0 ) |
217 | return TRUE; | 373 | return TRUE; |
218 | if ( strncasecmp(ext, ".wav", 4) == 0 ) | 374 | if ( strncasecmp(ext, ".wav", 4) == 0 ) |
219 | return TRUE; | 375 | return TRUE; |
220 | if ( strncasecmp(ext, ".wave", 4) == 0 ) | 376 | if ( strncasecmp(ext, ".wave", 4) == 0 ) |
221 | return TRUE; | 377 | return TRUE; |
222 | } | 378 | } |
223 | 379 | ||
224 | return FALSE; | 380 | return FALSE; |
225 | } | 381 | } |
226 | 382 | ||
227 | 383 | ||
228 | bool WavPlugin::open( const QString& path ) { | 384 | bool WavPlugin::open( const QString& path ) { |
229 | // qDebug( "WavPlugin::open" ); | 385 | qDebug( "WavPlugin::open" ); |
230 | 386 | ||
231 | d->max = d->out = sound_buffer_size; | 387 | d->max = d->out = sound_buffer_size; |
232 | d->wavedata_remaining = 0; | 388 | d->wavedata_remaining = 0; |
233 | d->samples_due = 0; | 389 | d->samples_due = 0; |
234 | 390 | ||
235 | d->input = new QFile( path ); | 391 | d->input = new QFile( path ); |
236 | if ( d->input->open(IO_ReadOnly) == FALSE ) { | 392 | if ( d->input->open(IO_ReadOnly) == FALSE ) { |
237 | qDebug("couldn't open file"); | 393 | qDebug("couldn't open file"); |
238 | delete d->input; | 394 | delete d->input; |
239 | d->input = 0; | 395 | d->input = 0; |
240 | return FALSE; | 396 | return FALSE; |
241 | } | 397 | } |
242 | 398 | ||
399 | // d->getWavSettings( d->input.handle()); | ||
243 | d->initialise(); | 400 | d->initialise(); |
244 | 401 | ||
245 | return TRUE; | 402 | return TRUE; |
246 | } | 403 | } |
247 | 404 | ||
248 | 405 | ||
249 | bool WavPlugin::close() { | 406 | bool WavPlugin::close() { |
250 | // qDebug( "WavPlugin::close" ); | 407 | qDebug( "WavPlugin::close" ); |
251 | 408 | ||
252 | d->input->close(); | 409 | d->input->close(); |
253 | delete d->input; | 410 | delete d->input; |
254 | d->input = 0; | 411 | d->input = 0; |
255 | return TRUE; | 412 | return TRUE; |
256 | } | 413 | } |
257 | 414 | ||
258 | 415 | ||
259 | bool WavPlugin::isOpen() { | 416 | bool WavPlugin::isOpen() { |
260 | // qDebug( "WavPlugin::isOpen" ); | 417 | qDebug( "WavPlugin::isOpen" ); |
261 | return ( d->input != 0 ); | 418 | return ( d->input != 0 ); |
262 | } | 419 | } |
263 | 420 | ||
264 | 421 | ||
265 | int WavPlugin::audioStreams() { | 422 | int WavPlugin::audioStreams() { |
266 | // qDebug( "WavPlugin::audioStreams" ); | 423 | qDebug( "WavPlugin::audioStreams" ); |
267 | return 1; | 424 | return 1; |
268 | } | 425 | } |
269 | 426 | ||
270 | 427 | ||
271 | int WavPlugin::audioChannels( int ) { | 428 | int WavPlugin::audioChannels( int ) { |
272 | // qDebug( "WavPlugin::audioChannels" ); | 429 | debugMsg( "WavPlugin::audioChannels" ); |
273 | return d->chunkdata.channels;// 2; // ### Always scale audio to stereo samples | 430 | return d->chan; |
274 | } | 431 | } |
275 | 432 | ||
276 | 433 | ||
277 | int WavPlugin::audioFrequency( int ) { | 434 | int WavPlugin::audioFrequency( int ) { |
278 | // qDebug( "WavPlugin::audioFrequency %d", d->chunkdata.samplesPerSec ); | 435 | qDebug( "WavPlugin::audioFrequency" ); |
279 | return d->chunkdata.samplesPerSec; //44100; // ### Always scale to frequency of 44100 | 436 | return d->freq; |
280 | } | 437 | } |
281 | 438 | ||
282 | 439 | ||
283 | int WavPlugin::audioSamples( int ) { | 440 | int WavPlugin::audioSamples( int ) { |
284 | // qDebug( "WavPlugin::audioSamples" ); | 441 | qDebug( "WavPlugin::audioSamples" ); |
285 | return d->samples / d->chunkdata.channels/2; // ### Scaled samples will be made stereo, | 442 | return d->samples; |
286 | // Therefore if source is mono we will double the number of samples | 443 | // return d->samples * 2 / d->chunkdata.channels; // ### Scaled samples will be made stereo, |
444 | // // Therefore if source is mono we will double the number of samples | ||
287 | } | 445 | } |
288 | 446 | ||
289 | 447 | ||
290 | bool WavPlugin::audioSetSample( long, int ) { | 448 | bool WavPlugin::audioSetSample( long, int ) { |
291 | // qDebug( "WavPlugin::audioSetSample" ); | 449 | qDebug( "WavPlugin::audioSetSample" ); |
292 | return FALSE; | 450 | return FALSE; |
293 | } | 451 | } |
294 | 452 | ||
295 | 453 | ||
296 | long WavPlugin::audioGetSample( int ) { | 454 | long WavPlugin::audioGetSample( int ) { |
297 | // qDebug( "WavPlugin::audioGetSample" ); | 455 | qDebug( "WavPlugin::audioGetSample" ); |
298 | return 0; | 456 | return 0; |
299 | } | 457 | } |
300 | 458 | ||
301 | /* | 459 | /* |
302 | bool WavPlugin::audioReadSamples( short *, int, long, int ) { | 460 | bool WavPlugin::audioReadSamples( short *, int, long, int ) { |
303 | debugMsg( "WavPlugin::audioReadSamples" ); | 461 | debugMsg( "WavPlugin::audioReadSamples" ); |
304 | return FALSE; | 462 | return FALSE; |
305 | } | 463 | } |
306 | 464 | ||
307 | 465 | ||
308 | bool WavPlugin::audioReReadSamples( short *, int, long, int ) { | 466 | bool WavPlugin::audioReReadSamples( short *, int, long, int ) { |
309 | debugMsg( "WavPlugin::audioReReadSamples" ); | 467 | debugMsg( "WavPlugin::audioReReadSamples" ); |
310 | return FALSE; | 468 | return FALSE; |
311 | } | 469 | } |
312 | 470 | ||
313 | 471 | ||
314 | bool WavPlugin::audioReadMonoSamples( short *output, long samples, long& samplesMade, int ) { | 472 | bool WavPlugin::audioReadMonoSamples( short *output, long samples, long& samplesMade, int ) { |
315 | debugMsg( "WavPlugin::audioReadMonoSamples" ); | 473 | debugMsg( "WavPlugin::audioReadMonoSamples" ); |
316 | return !d->add( output, samples, samplesMade, FALSE ); | 474 | return !d->add( output, samples, samplesMade, FALSE ); |
317 | } | 475 | } |
318 | 476 | ||
319 | 477 | ||
320 | bool WavPlugin::audioReadStereoSamples( short *output, long samples, long& samplesMade, int ) { | 478 | bool WavPlugin::audioReadStereoSamples( short *output, long samples, long& samplesMade, int ) { |
321 | debugMsg( "WavPlugin::audioReadStereoSamples" ); | 479 | debugMsg( "WavPlugin::audioReadStereoSamples" ); |
322 | return !d->add( output, samples, samplesMade, TRUE ); | 480 | return !d->add( output, samples, samplesMade, TRUE ); |
323 | } | 481 | } |
324 | */ | 482 | */ |
325 | 483 | ||
326 | bool WavPlugin::audioReadSamples( short *output, int channels, long samples, long& samplesMade, int ) { | 484 | bool WavPlugin::audioReadSamples( short *output, int channels, long samples, long& samplesMade, int ) { |
327 | // qDebug( "WavPlugin::audioReadSamples" ); | 485 | qDebug( "WavPlugin::audioReadSamples" ); |
328 | return d->add( output, samples, samplesMade, channels != 1 ); | 486 | return d->add( output, samples, samplesMade, channels != 1 ); |
329 | } | 487 | } |
330 | 488 | ||
331 | double WavPlugin::getTime() { | 489 | double WavPlugin::getTime() { |
332 | // qDebug( "WavPlugin::getTime" ); | 490 | qDebug( "WavPlugin::getTime" ); |
333 | return 0.0; | 491 | return 0.0; |
334 | } | 492 | } |
335 | 493 | ||
336 | int WavPlugin::audioBitsPerSample( int ) { | ||
337 | // qDebug( "WavPlugin::audioFormat %d", d->chunkdata.wBitsPerSample ); | ||
338 | return d->chunkdata.wBitsPerSample; // | ||
339 | } | ||
340 | |||
341 | 494 | ||
diff --git a/core/multimedia/opieplayer/wavplugin/wavplugin.h b/core/multimedia/opieplayer/wavplugin/wavplugin.h index 6afd67e..19d1a8e 100644 --- a/core/multimedia/opieplayer/wavplugin/wavplugin.h +++ b/core/multimedia/opieplayer/wavplugin/wavplugin.h | |||
@@ -1,89 +1,85 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | // L.J.Potter added changes Fri 02-15-2002 | ||
21 | |||
22 | #ifndef WAV_PLUGIN_H | 20 | #ifndef WAV_PLUGIN_H |
23 | #define WAV_PLUGIN_H | 21 | #define WAV_PLUGIN_H |
24 | 22 | ||
25 | |||
26 | #include <qstring.h> | 23 | #include <qstring.h> |
27 | #include <qapplication.h> | 24 | #include <qapplication.h> |
28 | #include "../mediaplayerplugininterface.h" | 25 | #include <qpe/mediaplayerplugininterface.h> |
29 | 26 | ||
30 | 27 | ||
31 | // #define OLD_MEDIAPLAYER_API | 28 | // #define OLD_MEDIAPLAYER_API |
32 | 29 | ||
33 | 30 | ||
34 | class WavPluginData; | 31 | class WavPluginData; |
35 | 32 | ||
36 | 33 | ||
37 | class WavPlugin : public MediaPlayerDecoder { | 34 | class WavPlugin : public MediaPlayerDecoder { |
38 | 35 | ||
39 | public: | 36 | public: |
40 | WavPlugin(); | 37 | WavPlugin(); |
41 | ~WavPlugin(); | 38 | ~WavPlugin(); |
42 | 39 | ||
43 | const char *pluginName() { return "WavPlugin"; } | 40 | const char *pluginName() { return "WavPlugin"; } |
44 | const char *pluginComment() { return "This is a simple plugin for playing wav files"; } | 41 | const char *pluginComment() { return "This is a simple plugin for playing wav files"; } |
45 | double pluginVersion() { return 1.0; } | 42 | double pluginVersion() { return 1.0; } |
46 | 43 | ||
47 | bool isFileSupported( const QString& ); | 44 | bool isFileSupported( const QString& ); |
48 | bool open( const QString& ); | 45 | bool open( const QString& ); |
49 | bool close(); | 46 | bool close(); |
50 | bool isOpen(); | 47 | bool isOpen(); |
51 | const QString &fileInfo() { return strInfo = ""; } | 48 | const QString &fileInfo() { return strInfo = ""; } |
52 | 49 | ||
53 | // If decoder doesn't support audio then return 0 here | 50 | // If decoder doesn't support audio then return 0 here |
54 | int audioStreams(); | 51 | int audioStreams(); |
55 | int audioChannels( int stream ); | 52 | int audioChannels( int stream ); |
56 | int audioFrequency( int stream ); | 53 | int audioFrequency( int stream ); |
57 | int audioBitsPerSample( int stream ); | ||
58 | int audioSamples( int stream ); | 54 | int audioSamples( int stream ); |
59 | bool audioSetSample( long sample, int stream ); | 55 | bool audioSetSample( long sample, int stream ); |
60 | long audioGetSample( int stream ); | 56 | long audioGetSample( int stream ); |
61 | #ifdef OLD_MEDIAPLAYER_API | 57 | #ifdef OLD_MEDIAPLAYER_API |
62 | bool audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream ); | 58 | bool audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream ); |
63 | bool audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream ); | 59 | bool audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream ); |
64 | bool audioReadSamples( short *output, int channel, long samples, int stream ); | 60 | bool audioReadSamples( short *output, int channel, long samples, int stream ); |
65 | bool audioReReadSamples( short *output, int channel, long samples, int stream ); | 61 | bool audioReReadSamples( short *output, int channel, long samples, int stream ); |
66 | #else | 62 | #else |
67 | bool audioReadSamples( short *output, int channels, long samples, long& samplesRead, int stream ); | 63 | bool audioReadSamples( short *output, int channels, long samples, long& samplesRead, int stream ); |
68 | #endif | 64 | #endif |
69 | 65 | ||
70 | // If decoder doesn't support video then return 0 here | 66 | // If decoder doesn't support video then return 0 here |
71 | int videoStreams() { return 0; } | 67 | int videoStreams() { return 0; } |
72 | int videoWidth( int ) { return 0; } | 68 | int videoWidth( int ) { return 0; } |
73 | int videoHeight( int ) { return 0; } | 69 | int videoHeight( int ) { return 0; } |
74 | double videoFrameRate( int ) { return 0.0; } | 70 | double videoFrameRate( int ) { return 0.0; } |
75 | int videoFrames( int ) { return 0; } | 71 | int videoFrames( int ) { return 0; } |
76 | bool videoSetFrame( long, int ) { return FALSE; } | 72 | bool videoSetFrame( long, int ) { return FALSE; } |
77 | long videoGetFrame( int ) { return 0; } | 73 | long videoGetFrame( int ) { return 0; } |
78 | bool videoReadFrame( unsigned char **, int, int, int, int, ColorFormat, int ) { return FALSE; } | 74 | bool videoReadFrame( unsigned char **, int, int, int, int, ColorFormat, int ) { return FALSE; } |
79 | bool videoReadScaledFrame( unsigned char **, int, int, int, int, int, int, ColorFormat, int ) { return FALSE; } | 75 | bool videoReadScaledFrame( unsigned char **, int, int, int, int, int, int, ColorFormat, int ) { return FALSE; } |
80 | bool videoReadYUVFrame( char *, char *, char *, int, int, int, int, int ) { return FALSE; } | 76 | bool videoReadYUVFrame( char *, char *, char *, int, int, int, int, int ) { return FALSE; } |
81 | 77 | ||
82 | // Profiling | 78 | // Profiling |
83 | double getTime(); | 79 | double getTime(); |
84 | 80 | ||
85 | // Ignore if these aren't supported | 81 | // Ignore if these aren't supported |
86 | bool setSMP( int ) { return FALSE; } | 82 | bool setSMP( int ) { return FALSE; } |
87 | bool setMMX( bool ) { return FALSE; } | 83 | bool setMMX( bool ) { return FALSE; } |
88 | 84 | ||
89 | // Capabilities | 85 | // Capabilities |
diff --git a/core/multimedia/opieplayer/wavplugin/wavpluginimpl.cpp b/core/multimedia/opieplayer/wavplugin/wavpluginimpl.cpp index 1f7b85b..2923180 100644 --- a/core/multimedia/opieplayer/wavplugin/wavpluginimpl.cpp +++ b/core/multimedia/opieplayer/wavplugin/wavpluginimpl.cpp | |||
@@ -1,55 +1,54 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include "wavplugin.h" | 20 | #include "wavplugin.h" |
21 | #include "wavpluginimpl.h" | 21 | #include "wavpluginimpl.h" |
22 | 22 | ||
23 | |||
24 | WavPluginImpl::WavPluginImpl() | 23 | WavPluginImpl::WavPluginImpl() |
25 | : libmadplugin(0), ref(0) | 24 | : libmadplugin(0), ref(0) |
26 | { | 25 | { |
27 | } | 26 | } |
28 | 27 | ||
29 | 28 | ||
30 | WavPluginImpl::~WavPluginImpl() | 29 | WavPluginImpl::~WavPluginImpl() |
31 | { | 30 | { |
32 | if ( libmadplugin ) | 31 | if ( libmadplugin ) |
33 | delete libmadplugin; | 32 | delete libmadplugin; |
34 | } | 33 | } |
35 | 34 | ||
36 | 35 | ||
37 | MediaPlayerDecoder *WavPluginImpl::decoder() | 36 | MediaPlayerDecoder *WavPluginImpl::decoder() |
38 | { | 37 | { |
39 | if ( !libmadplugin ) | 38 | if ( !libmadplugin ) |
40 | libmadplugin = new WavPlugin; | 39 | libmadplugin = new WavPlugin; |
41 | return libmadplugin; | 40 | return libmadplugin; |
42 | } | 41 | } |
43 | 42 | ||
44 | 43 | ||
45 | MediaPlayerEncoder *WavPluginImpl::encoder() | 44 | MediaPlayerEncoder *WavPluginImpl::encoder() |
46 | { | 45 | { |
47 | return NULL; | 46 | return NULL; |
48 | } | 47 | } |
49 | 48 | ||
50 | 49 | ||
51 | #ifndef QT_NO_COMPONENT | 50 | #ifndef QT_NO_COMPONENT |
52 | 51 | ||
53 | 52 | ||
54 | QRESULT WavPluginImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) | 53 | QRESULT WavPluginImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) |
55 | { | 54 | { |
diff --git a/core/multimedia/opieplayer/wavplugin/wavpluginimpl.h b/core/multimedia/opieplayer/wavplugin/wavpluginimpl.h index ee32f54..71f5f20 100644 --- a/core/multimedia/opieplayer/wavplugin/wavpluginimpl.h +++ b/core/multimedia/opieplayer/wavplugin/wavpluginimpl.h | |||
@@ -1,53 +1,52 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef WAV_PLUGIN_IMPL_H | 20 | #ifndef WAV_PLUGIN_IMPL_H |
21 | #define WAV_PLUGIN_IMPL_H | 21 | #define WAV_PLUGIN_IMPL_H |
22 | 22 | ||
23 | 23 | #include <qpe/mediaplayerplugininterface.h> | |
24 | #include "../mediaplayerplugininterface.h" | ||
25 | 24 | ||
26 | 25 | ||
27 | class WavPlugin; | 26 | class WavPlugin; |
28 | 27 | ||
29 | 28 | ||
30 | class WavPluginImpl : public MediaPlayerPluginInterface | 29 | class WavPluginImpl : public MediaPlayerPluginInterface |
31 | { | 30 | { |
32 | public: | 31 | public: |
33 | WavPluginImpl(); | 32 | WavPluginImpl(); |
34 | virtual ~WavPluginImpl(); | 33 | virtual ~WavPluginImpl(); |
35 | 34 | ||
36 | #ifndef QT_NO_COMPONENT | 35 | #ifndef QT_NO_COMPONENT |
37 | 36 | ||
38 | QRESULT queryInterface( const QUuid&, QUnknownInterface** ); | 37 | QRESULT queryInterface( const QUuid&, QUnknownInterface** ); |
39 | Q_REFCOUNT | 38 | Q_REFCOUNT |
40 | 39 | ||
41 | #endif | 40 | #endif |
42 | 41 | ||
43 | virtual MediaPlayerDecoder *decoder(); | 42 | virtual MediaPlayerDecoder *decoder(); |
44 | virtual MediaPlayerEncoder *encoder(); | 43 | virtual MediaPlayerEncoder *encoder(); |
45 | 44 | ||
46 | private: | 45 | private: |
47 | WavPlugin *libmadplugin; | 46 | WavPlugin *libmadplugin; |
48 | ulong ref; | 47 | ulong ref; |
49 | }; | 48 | }; |
50 | 49 | ||
51 | 50 | ||
52 | #endif | 51 | #endif |
53 | 52 | ||