summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/Makefile.in29
-rw-r--r--core/multimedia/opieplayer/audiodevice.cpp153
-rw-r--r--core/multimedia/opieplayer/audiodevice.h6
-rw-r--r--core/multimedia/opieplayer/audiowidget.cpp122
-rw-r--r--core/multimedia/opieplayer/libflash/libflashplugin.h4
-rw-r--r--core/multimedia/opieplayer/libflash/libflashpluginimpl.h1
-rw-r--r--core/multimedia/opieplayer/libflash/swf.h2
-rw-r--r--core/multimedia/opieplayer/libmad/Makefile.in2
-rw-r--r--core/multimedia/opieplayer/libmad/libmad.pro20
-rw-r--r--core/multimedia/opieplayer/libmad/libmadplugin.h20
-rw-r--r--core/multimedia/opieplayer/libmad/libmadpluginimpl.h2
-rw-r--r--core/multimedia/opieplayer/libmad/version.c2
-rw-r--r--core/multimedia/opieplayer/libmpeg3/Makefile.in6
-rw-r--r--core/multimedia/opieplayer/libmpeg3/libmpeg3plugin.h22
-rw-r--r--core/multimedia/opieplayer/libmpeg3/libmpeg3pluginimpl.h1
-rw-r--r--core/multimedia/opieplayer/loopcontrol.cpp328
-rw-r--r--core/multimedia/opieplayer/loopcontrol.h2
-rw-r--r--core/multimedia/opieplayer/loopcontrol_threaded.cpp2
-rw-r--r--core/multimedia/opieplayer/main.cpp2
-rw-r--r--core/multimedia/opieplayer/mediaplayerplugininterface.h8
-rw-r--r--core/multimedia/opieplayer/mediaplayerstate.cpp60
-rw-r--r--core/multimedia/opieplayer/mediaplayerstate.h59
-rw-r--r--core/multimedia/opieplayer/playlistselection.cpp36
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp553
-rw-r--r--core/multimedia/opieplayer/playlistwidget.h33
-rw-r--r--core/multimedia/opieplayer/videowidget.cpp358
-rw-r--r--core/multimedia/opieplayer/wavplugin/Makefile.in4
-rw-r--r--core/multimedia/opieplayer/wavplugin/wavplugin.cpp261
-rw-r--r--core/multimedia/opieplayer/wavplugin/wavplugin.h24
29 files changed, 1229 insertions, 893 deletions
diff --git a/core/multimedia/opieplayer/Makefile.in b/core/multimedia/opieplayer/Makefile.in
index 1b0307a..8d33fb4 100644
--- a/core/multimedia/opieplayer/Makefile.in
+++ b/core/multimedia/opieplayer/Makefile.in
@@ -1,280 +1,293 @@
1############################################################################# 1#############################################################################
2 2
3####### Compiler, tools and options 3####### Compiler, tools and options
4 4
5 CXX =$(SYSCONF_CXX) $(QT_CXX_MT) 5 CXX =$(SYSCONF_CXX) $(QT_CXX_MT)
6 CXXFLAGS=$(SYSCONF_CXXFLAGS_QT) $(SYSCONF_CXXFLAGS) 6 CXXFLAGS=$(SYSCONF_CXXFLAGS_QT) $(SYSCONF_CXXFLAGS)
7 CC =$(SYSCONF_CC) $(QT_C_MT) 7 CC =$(SYSCONF_CC) $(QT_C_MT)
8 CFLAGS =$(SYSCONF_CFLAGS) 8 CFLAGS =$(SYSCONF_CFLAGS)
9 INCPATH =-I$(OPIEDIR)/include 9 INCPATH =-I$(OPIEDIR)/include
10 LFLAGS =$(SYSCONF_LFLAGS_QT) $(SYSCONF_RPATH_QT) $(SYSCONF_LFLAGS) $(QT_LFLAGS_MT) 10 LFLAGS =$(SYSCONF_LFLAGS_QT) $(SYSCONF_RPATH_QT) $(SYSCONF_LFLAGS) $(QT_LFLAGS_MT)
11 LIBS =$(SUBLIBS) -lqpe -lpthread $(SYSCONF_LIBS_QT) $(SYSCONF_LIBS) $(SYSCONF_LIBS_QTAPP) 11 LIBS =$(SUBLIBS) -lqpe -lpthread $(SYSCONF_LIBS_QT) $(SYSCONF_LIBS) $(SYSCONF_LIBS_QTAPP)
12 MOC =$(SYSCONF_MOC) 12 MOC =$(SYSCONF_MOC)
13 UIC =$(SYSCONF_UIC) 13 UIC =$(SYSCONF_UIC)
14 14
15####### Target 15####### Target
16 16
17DESTDIR = $(OPIEDIR)/bin/ 17DESTDIR = $(OPIEDIR)/bin/
18VER_MAJ = 1 18VER_MAJ = 1
19VER_MIN = 0 19VER_MIN = 0
20VER_PATCH = 0 20VER_PATCH = 0
21 TARGET= mpegplayer 21 TARGET= mpegplayer
22TARGET1 = lib$(TARGET).so.$(VER_MAJ) 22TARGET1 = lib$(TARGET).so.$(VER_MAJ)
23 23
24####### Files 24####### Files
25 25
26 HEADERS =loopcontrol.h \ 26 HEADERS =loopcontrol.h \
27 mediaplayerplugininterface.h \ 27 mediaplayerplugininterface.h \
28 playlistselection.h \ 28 playlistselection.h \
29 mediaplayerstate.h \ 29 mediaplayerstate.h \
30 videowidget.h \ 30 videowidget.h \
31 audiowidget.h \ 31 audiowidget.h \
32 playlistwidget.h \ 32 playlistwidget.h \
33 mediaplayer.h \ 33 mediaplayer.h \
34 audiodevice.h 34 audiodevice.h
35 SOURCES =main.cpp \ 35 SOURCES =main.cpp \
36 loopcontrol.cpp \ 36 loopcontrol.cpp \
37 playlistselection.cpp \ 37 playlistselection.cpp \
38 mediaplayerstate.cpp \ 38 mediaplayerstate.cpp \
39 videowidget.cpp \ 39 videowidget.cpp \
40 audiowidget.cpp \ 40 audiowidget.cpp \
41 playlistwidget.cpp \ 41 playlistwidget.cpp \
42 mediaplayer.cpp \ 42 mediaplayer.cpp \
43 audiodevice.cpp 43 audiodevice.cpp
44 OBJECTS =main.o \ 44 OBJECTS =main.o \
45 loopcontrol.o \ 45 loopcontrol.o \
46 playlistselection.o \ 46 playlistselection.o \
47 mediaplayerstate.o \ 47 mediaplayerstate.o \
48 videowidget.o \ 48 videowidget.o \
49 audiowidget.o \ 49 audiowidget.o \
50 playlistwidget.o \ 50 playlistwidget.o \
51 mediaplayer.o \ 51 mediaplayer.o \
52 audiodevice.o 52 audiodevice.o
53INTERFACES = 53INTERFACES =
54UICDECLS = 54UICDECLS =
55UICIMPLS = 55UICIMPLS =
56 SRCMOC =moc_loopcontrol.cpp \ 56 SRCMOC =moc_loopcontrol.cpp \
57 moc_playlistselection.cpp \ 57 moc_playlistselection.cpp \
58 moc_mediaplayerstate.cpp \ 58 moc_mediaplayerstate.cpp \
59 moc_videowidget.cpp \ 59 moc_videowidget.cpp \
60 moc_audiowidget.cpp \ 60 moc_audiowidget.cpp \
61 moc_playlistwidget.cpp \ 61 moc_playlistwidget.cpp \
62 moc_mediaplayer.cpp \ 62 moc_mediaplayer.cpp \
63 moc_audiodevice.cpp 63 moc_audiodevice.cpp
64 OBJMOC =moc_loopcontrol.o \ 64 OBJMOC =moc_loopcontrol.o \
65 moc_playlistselection.o \ 65 moc_playlistselection.o \
66 moc_mediaplayerstate.o \ 66 moc_mediaplayerstate.o \
67 moc_videowidget.o \ 67 moc_videowidget.o \
68 moc_audiowidget.o \ 68 moc_audiowidget.o \
69 moc_playlistwidget.o \ 69 moc_playlistwidget.o \
70 moc_mediaplayer.o \ 70 moc_mediaplayer.o \
71 moc_audiodevice.o 71 moc_audiodevice.o
72 72
73 73
74####### Implicit rules 74####### Implicit rules
75 75
76.SUFFIXES: .cpp .cxx .cc .C .c 76.SUFFIXES: .cpp .cxx .cc .C .c
77 77
78.cpp.o: 78.cpp.o:
79 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< 79 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
80 80
81.cxx.o: 81.cxx.o:
82 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< 82 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
83 83
84.cc.o: 84.cc.o:
85 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< 85 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
86 86
87.C.o: 87.C.o:
88 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< 88 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
89 89
90.c.o: 90.c.o:
91 $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $< 91 $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $<
92 92
93####### Build rules 93####### Build rules
94 94
95 95
96all: $(DESTDIR)$(TARGET) 96all: $(DESTDIR)$(TARGET)
97 97
98$(DESTDIR)$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) $(SUBLIBS) 98$(DESTDIR)$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) $(SUBLIBS)
99 $(SYSCONF_LINK) $(LFLAGS) -o $(DESTDIR)$(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS) 99 $(SYSCONF_LINK) $(LFLAGS) -o $(DESTDIR)$(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS)
100 100
101moc: $(SRCMOC) 101moc: $(SRCMOC)
102 102
103tmake: 103tmake:
104 tmake mpegplayer.pro 104 tmake mpegplayer.pro
105 105
106clean: 106clean:
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
113listpromodules: 113listpromodules:
114 @echo 114 @echo
115 115
116listallmodules: 116listallmodules:
117 @echo 117 @echo
118 118
119listaddonpromodules: 119listaddonpromodules:
120 @echo 120 @echo
121 121
122listaddonentmodules: 122listaddonentmodules:
123 @echo 123 @echo
124 124
125 125
126REQUIRES= 126REQUIRES=
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
137main.o: main.cpp \ 137main.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 \
139 mediaplayerstate.h \ 141 mediaplayerstate.h \
140 playlistwidget.h \ 142 playlistwidget.h \
141 $(OPIEDIR)/include/qpe/applnk.h \ 143 $(OPIEDIR)/include/qpe/applnk.h \
142 audiowidget.h \ 144 audiowidget.h \
143 videowidget.h \ 145 videowidget.h \
144 loopcontrol.h \ 146 loopcontrol.h \
145 mediaplayer.h \ 147 mediaplayer.h \
146 $(OPIEDIR)/include/qpe/qlibrary.h \ 148 $(OPIEDIR)/include/qpe/qlibrary.h \
147 $(OPIEDIR)/include/qpe/qcom.h \ 149 $(OPIEDIR)/include/qpe/qcom.h \
148 $(OPIEDIR)/include/qpe/quuid.h \ 150 $(OPIEDIR)/include/qpe/quuid.h \
149 $(OPIEDIR)/include/qpe/mediaplayerplugininterface.h 151 mediaplayerplugininterface.h
150 152
151loopcontrol.o: loopcontrol.cpp \ 153loopcontrol.o: loopcontrol.cpp \
152 $(OPIEDIR)/include/qpe/qpeapplication.h \ 154 $(OPIEDIR)/include/qpe/qpeapplication.h \
153 $(OPIEDIR)/include/qpe/qcopenvelope_qws.h \ 155 $(OPIEDIR)/include/qpedecoration_qws.h \
156 $(OPIEDIR)/include/timestring.h \
154 loopcontrol.h \ 157 loopcontrol.h \
155 videowidget.h \ 158 videowidget.h \
156 audiodevice.h \ 159 audiodevice.h \
157 mediaplayerplugininterface.h \ 160 mediaplayerplugininterface.h \
158 $(OPIEDIR)/include/qpe/qcom.h \ 161 $(OPIEDIR)/include/qpe/qcom.h \
159 $(OPIEDIR)/include/qpe/quuid.h \ 162 $(OPIEDIR)/include/qpe/quuid.h \
160 mediaplayerstate.h 163 mediaplayerstate.h
161 164
162playlistselection.o: playlistselection.cpp \ 165playlistselection.o: playlistselection.cpp \
163 $(OPIEDIR)/include/qpe/applnk.h \ 166 $(OPIEDIR)/include/qpe/applnk.h \
164 $(OPIEDIR)/include/qpe/resource.h \ 167 $(OPIEDIR)/include/qpe/resource.h \
165 playlistselection.h 168 playlistselection.h
166 169
167mediaplayerstate.o: mediaplayerstate.cpp \ 170mediaplayerstate.o: mediaplayerstate.cpp \
168 $(OPIEDIR)/include/qpe/qpeapplication.h \ 171 $(OPIEDIR)/include/qpe/qpeapplication.h \
172 $(OPIEDIR)/include/qpedecoration_qws.h \
173 $(OPIEDIR)/include/timestring.h \
169 $(OPIEDIR)/include/qpe/qlibrary.h \ 174 $(OPIEDIR)/include/qpe/qlibrary.h \
170 $(OPIEDIR)/include/qpe/qcom.h \ 175 $(OPIEDIR)/include/qpe/qcom.h \
171 $(OPIEDIR)/include/qpe/quuid.h \ 176 $(OPIEDIR)/include/qpe/quuid.h \
172 $(OPIEDIR)/include/qpe/mediaplayerplugininterface.h \
173 $(OPIEDIR)/include/qpe/config.h \ 177 $(OPIEDIR)/include/qpe/config.h \
178 mediaplayerplugininterface.h \
174 mediaplayerstate.h \ 179 mediaplayerstate.h \
175 libmad/libmadpluginimpl.h \ 180 libmad/libmadpluginimpl.h \
176 libmpeg3/libmpeg3pluginimpl.h \ 181 libmpeg3/libmpeg3pluginimpl.h \
177 wavplugin/wavpluginimpl.h 182 wavplugin/wavpluginimpl.h
178 183
179videowidget.o: videowidget.cpp \ 184videowidget.o: videowidget.cpp \
180 $(OPIEDIR)/include/qpe/resource.h \ 185 $(OPIEDIR)/include/qpe/resource.h \
181 $(OPIEDIR)/include/qpe/mediaplayerplugininterface.h \ 186 mediaplayerplugininterface.h \
182 $(OPIEDIR)/include/qpe/qcom.h \ 187 $(OPIEDIR)/include/qpe/qcom.h \
183 $(OPIEDIR)/include/qpe/quuid.h \ 188 $(OPIEDIR)/include/qpe/quuid.h \
184 videowidget.h \ 189 videowidget.h \
185 mediaplayerstate.h 190 mediaplayerstate.h
186 191
187audiowidget.o: audiowidget.cpp \ 192audiowidget.o: audiowidget.cpp \
188 $(OPIEDIR)/include/qpe/resource.h \ 193 $(OPIEDIR)/include/qpe/resource.h \
189 audiowidget.h \ 194 audiowidget.h \
190 mediaplayerstate.h 195 mediaplayerstate.h
191 196
192playlistwidget.o: playlistwidget.cpp \ 197playlistwidget.o: playlistwidget.cpp \
193 $(OPIEDIR)/include/qpe/qpemenubar.h \ 198 $(OPIEDIR)/include/qpe/qpemenubar.h \
194 $(OPIEDIR)/include/qpe/qpetoolbar.h \ 199 $(OPIEDIR)/include/qpe/qpetoolbar.h \
195 $(OPIEDIR)/include/qpe/fileselector.h \ 200 $(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 \
196 $(OPIEDIR)/include/qpe/applnk.h \ 206 $(OPIEDIR)/include/qpe/applnk.h \
197 $(OPIEDIR)/include/qpe/config.h \ 207 $(OPIEDIR)/include/qpe/config.h \
198 $(OPIEDIR)/include/qpe/global.h \ 208 $(OPIEDIR)/include/qpe/global.h \
199 $(OPIEDIR)/include/qpe/resource.h \ 209 $(OPIEDIR)/include/qpe/resource.h \
200 playlistselection.h \ 210 playlistselection.h \
201 playlistwidget.h \ 211 playlistwidget.h \
202 mediaplayerstate.h 212 mediaplayerstate.h
203 213
204mediaplayer.o: mediaplayer.cpp \ 214mediaplayer.o: mediaplayer.cpp \
205 $(OPIEDIR)/include/qpe/qpeapplication.h \ 215 $(OPIEDIR)/include/qpe/qpeapplication.h \
216 $(OPIEDIR)/include/qpedecoration_qws.h \
217 $(OPIEDIR)/include/timestring.h \
206 $(OPIEDIR)/include/qpe/qlibrary.h \ 218 $(OPIEDIR)/include/qpe/qlibrary.h \
207 $(OPIEDIR)/include/qpe/qcom.h \ 219 $(OPIEDIR)/include/qpe/qcom.h \
208 $(OPIEDIR)/include/qpe/quuid.h \ 220 $(OPIEDIR)/include/qpe/quuid.h \
209 $(OPIEDIR)/include/qpe/resource.h \ 221 $(OPIEDIR)/include/qpe/resource.h \
210 $(OPIEDIR)/include/qpe/config.h \ 222 $(OPIEDIR)/include/qpe/config.h \
211 mediaplayer.h \ 223 mediaplayer.h \
212 $(OPIEDIR)/include/qpe/mediaplayerplugininterface.h \ 224 mediaplayerplugininterface.h \
213 playlistwidget.h \ 225 playlistwidget.h \
214 $(OPIEDIR)/include/qpe/applnk.h \ 226 $(OPIEDIR)/include/qpe/applnk.h \
215 audiowidget.h \ 227 audiowidget.h \
216 loopcontrol.h \ 228 loopcontrol.h \
217 audiodevice.h \ 229 audiodevice.h \
218 mediaplayerstate.h 230 mediaplayerstate.h
219 231
220audiodevice.o: audiodevice.cpp \ 232audiodevice.o: audiodevice.cpp \
221 $(OPIEDIR)/include/qpe/qpeapplication.h \ 233 $(OPIEDIR)/include/qpe/qpeapplication.h \
234 $(OPIEDIR)/include/qpedecoration_qws.h \
235 $(OPIEDIR)/include/timestring.h \
222 $(OPIEDIR)/include/qpe/config.h \ 236 $(OPIEDIR)/include/qpe/config.h \
223 audiodevice.h \ 237 audiodevice.h
224 $(OPIEDIR)/include/qpe/qcopenvelope_qws.h
225 238
226moc_loopcontrol.o: moc_loopcontrol.cpp \ 239moc_loopcontrol.o: moc_loopcontrol.cpp \
227 loopcontrol.h 240 loopcontrol.h
228 241
229moc_playlistselection.o: moc_playlistselection.cpp \ 242moc_playlistselection.o: moc_playlistselection.cpp \
230 playlistselection.h \ 243 playlistselection.h \
231 $(OPIEDIR)/include/qpe/applnk.h 244 $(OPIEDIR)/include/qpe/applnk.h
232 245
233moc_mediaplayerstate.o: moc_mediaplayerstate.cpp \ 246moc_mediaplayerstate.o: moc_mediaplayerstate.cpp \
234 mediaplayerstate.h 247 mediaplayerstate.h
235 248
236moc_videowidget.o: moc_videowidget.cpp \ 249moc_videowidget.o: moc_videowidget.cpp \
237 videowidget.h 250 videowidget.h
238 251
239moc_audiowidget.o: moc_audiowidget.cpp \ 252moc_audiowidget.o: moc_audiowidget.cpp \
240 audiowidget.h 253 audiowidget.h
241 254
242moc_playlistwidget.o: moc_playlistwidget.cpp \ 255moc_playlistwidget.o: moc_playlistwidget.cpp \
243 playlistwidget.h \ 256 playlistwidget.h \
244 $(OPIEDIR)/include/qpe/applnk.h 257 $(OPIEDIR)/include/qpe/applnk.h
245 258
246moc_mediaplayer.o: moc_mediaplayer.cpp \ 259moc_mediaplayer.o: moc_mediaplayer.cpp \
247 mediaplayer.h \ 260 mediaplayer.h \
248 $(OPIEDIR)/include/qpe/qlibrary.h \ 261 $(OPIEDIR)/include/qpe/qlibrary.h \
249 $(OPIEDIR)/include/qpe/qcom.h \ 262 $(OPIEDIR)/include/qpe/qcom.h \
250 $(OPIEDIR)/include/qpe/quuid.h \ 263 $(OPIEDIR)/include/qpe/quuid.h \
251 $(OPIEDIR)/include/qpe/mediaplayerplugininterface.h 264 mediaplayerplugininterface.h
252 265
253moc_audiodevice.o: moc_audiodevice.cpp \ 266moc_audiodevice.o: moc_audiodevice.cpp \
254 audiodevice.h 267 audiodevice.h
255 268
256moc_loopcontrol.cpp: loopcontrol.h 269moc_loopcontrol.cpp: loopcontrol.h
257 $(MOC) loopcontrol.h -o moc_loopcontrol.cpp 270 $(MOC) loopcontrol.h -o moc_loopcontrol.cpp
258 271
259moc_playlistselection.cpp: playlistselection.h 272moc_playlistselection.cpp: playlistselection.h
260 $(MOC) playlistselection.h -o moc_playlistselection.cpp 273 $(MOC) playlistselection.h -o moc_playlistselection.cpp
261 274
262moc_mediaplayerstate.cpp: mediaplayerstate.h 275moc_mediaplayerstate.cpp: mediaplayerstate.h
263 $(MOC) mediaplayerstate.h -o moc_mediaplayerstate.cpp 276 $(MOC) mediaplayerstate.h -o moc_mediaplayerstate.cpp
264 277
265moc_videowidget.cpp: videowidget.h 278moc_videowidget.cpp: videowidget.h
266 $(MOC) videowidget.h -o moc_videowidget.cpp 279 $(MOC) videowidget.h -o moc_videowidget.cpp
267 280
268moc_audiowidget.cpp: audiowidget.h 281moc_audiowidget.cpp: audiowidget.h
269 $(MOC) audiowidget.h -o moc_audiowidget.cpp 282 $(MOC) audiowidget.h -o moc_audiowidget.cpp
270 283
271moc_playlistwidget.cpp: playlistwidget.h 284moc_playlistwidget.cpp: playlistwidget.h
272 $(MOC) playlistwidget.h -o moc_playlistwidget.cpp 285 $(MOC) playlistwidget.h -o moc_playlistwidget.cpp
273 286
274moc_mediaplayer.cpp: mediaplayer.h 287moc_mediaplayer.cpp: mediaplayer.h
275 $(MOC) mediaplayer.h -o moc_mediaplayer.cpp 288 $(MOC) mediaplayer.h -o moc_mediaplayer.cpp
276 289
277moc_audiodevice.cpp: audiodevice.h 290moc_audiodevice.cpp: audiodevice.h
278 $(MOC) audiodevice.h -o moc_audiodevice.cpp 291 $(MOC) audiodevice.h -o moc_audiodevice.cpp
279 292
280 293
diff --git a/core/multimedia/opieplayer/audiodevice.cpp b/core/multimedia/opieplayer/audiodevice.cpp
index 8861015..59136af 100644
--- a/core/multimedia/opieplayer/audiodevice.cpp
+++ b/core/multimedia/opieplayer/audiodevice.cpp
@@ -1,386 +1,371 @@
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 better error code Fri 02-15-2002 14:37:47
21
22
20#include <stdlib.h> 23#include <stdlib.h>
24#include <stdio.h>
21#include <qpe/qpeapplication.h> 25#include <qpe/qpeapplication.h>
22#include <qpe/config.h> 26#include <qpe/config.h>
23#include "audiodevice.h" 27#include "audiodevice.h"
24 28
25#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) 29#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP)
26#include "qpe/qcopenvelope_qws.h" 30#include "qpe/qcopenvelope_qws.h"
27#endif 31#endif
28 32
29#ifdef Q_WS_WIN 33#ifdef Q_WS_WIN
30#include <windows.h> 34#include <windows.h>
31#include <mmsystem.h> 35#include <mmsystem.h>
32#include <mmreg.h> 36#include <mmreg.h>
33#endif 37#endif
34 38
35#if defined(Q_WS_X11) || defined(Q_WS_QWS) 39#if defined(Q_WS_X11) || defined(Q_WS_QWS)
36#include <fcntl.h> 40#include <fcntl.h>
37#include <sys/ioctl.h> 41#include <sys/ioctl.h>
38#include <sys/soundcard.h> 42#include <sys/soundcard.h>
39#include <sys/stat.h> 43#include <sys/stat.h>
40#include <sys/time.h> 44#include <sys/time.h>
41#include <sys/types.h> 45#include <sys/types.h>
42#include <unistd.h> 46#include <unistd.h>
43#endif 47#endif
44 48
45#if defined(Q_OS_WIN32) 49#if defined(Q_OS_WIN32)
46static const int expectedBytesPerMilliSecond = 2 * 2 * 44000 / 1000; 50static const int expectedBytesPerMilliSecond = 2 * 2 * 44000 / 1000;
47static const int timerResolutionMilliSeconds = 30; 51static const int timerResolutionMilliSeconds = 30;
48static const int sound_fragment_bytes = timerResolutionMilliSeconds * expectedBytesPerMilliSecond; 52static const int sound_fragment_bytes = timerResolutionMilliSeconds * expectedBytesPerMilliSecond;
49#else 53#else
50# if defined(QT_QWS_IPAQ) 54# if defined(QT_QWS_IPAQ)
51static const int sound_fragment_shift = 14; 55static const int sound_fragment_shift = 14;
52# else 56# else
53static const int sound_fragment_shift = 16; 57static const int sound_fragment_shift = 16;
54# endif 58# endif
55static const int sound_fragment_bytes = (1<<sound_fragment_shift); 59static const int sound_fragment_bytes = (1<<sound_fragment_shift);
56#endif 60#endif
57 61
58 62
59class AudioDevicePrivate { 63class AudioDevicePrivate {
60public: 64public:
61 int handle; 65 int handle;
62 unsigned int frequency; 66 unsigned int frequency;
63 unsigned int channels; 67 unsigned int channels;
64 unsigned int bytesPerSample; 68 unsigned int bytesPerSample;
65 unsigned int bufferSize; 69 unsigned int bufferSize;
66#ifndef Q_OS_WIN32 70#ifndef Q_OS_WIN32
67 bool can_GETOSPACE; 71 bool can_GETOSPACE;
68 char* unwrittenBuffer; 72 char* unwrittenBuffer;
69 unsigned int unwritten; 73 unsigned int unwritten;
70#endif 74#endif
71 75
72 static int dspFd; 76 static int dspFd;
73 static bool muted; 77 static bool muted;
74 static unsigned int leftVolume; 78 static unsigned int leftVolume;
75 static unsigned int rightVolume; 79 static unsigned int rightVolume;
76}; 80};
77 81
78 82
79#ifdef Q_WS_QWS 83#ifdef Q_WS_QWS
80// This is for keeping the device open in-between playing files when 84// This is for keeping the device open in-between playing files when
81// the device makes clicks and it starts to drive you insane! :) 85// the device makes clicks and it starts to drive you insane! :)
82// Best to have the device not open when not using it though 86// Best to have the device not open when not using it though
83//#define KEEP_DEVICE_OPEN 87//#define KEEP_DEVICE_OPEN
84#endif 88#endif
85 89
86 90
87int AudioDevicePrivate::dspFd = 0; 91int AudioDevicePrivate::dspFd = 0;
88bool AudioDevicePrivate::muted = FALSE; 92bool AudioDevicePrivate::muted = FALSE;
89unsigned int AudioDevicePrivate::leftVolume = 0; 93unsigned int AudioDevicePrivate::leftVolume = 0;
90unsigned int AudioDevicePrivate::rightVolume = 0; 94unsigned int AudioDevicePrivate::rightVolume = 0;
91 95
92 96
93void AudioDevice::getVolume( unsigned int& leftVolume, unsigned int& rightVolume, bool &muted ) { 97void AudioDevice::getVolume( unsigned int& leftVolume, unsigned int& rightVolume, bool &muted ) {
94 muted = AudioDevicePrivate::muted; 98 muted = AudioDevicePrivate::muted;
95 unsigned int volume; 99 unsigned int volume;
96#ifdef Q_OS_WIN32 100#ifdef Q_OS_WIN32
97 HWAVEOUT handle; 101 HWAVEOUT handle;
98 WAVEFORMATEX formatData; 102 WAVEFORMATEX formatData;
99 formatData.cbSize = sizeof(WAVEFORMATEX); 103 formatData.cbSize = sizeof(WAVEFORMATEX);
100 formatData.wFormatTag = WAVE_FORMAT_PCM; 104 formatData.wFormatTag = WAVE_FORMAT_PCM;
101 formatData.nAvgBytesPerSec = 4 * 44000; 105 formatData.nAvgBytesPerSec = 4 * 44000;
102 formatData.nBlockAlign = 4; 106 formatData.nBlockAlign = 4;
103 formatData.nChannels = 2; 107 formatData.nChannels = 2;
104 formatData.nSamplesPerSec = 44000; 108 formatData.nSamplesPerSec = 44000;
105 formatData.wBitsPerSample = 16; 109 formatData.wBitsPerSample = 16;
106 waveOutOpen(&handle, WAVE_MAPPER, &formatData, 0L, 0L, CALLBACK_NULL); 110 waveOutOpen(&handle, WAVE_MAPPER, &formatData, 0L, 0L, CALLBACK_NULL);
107 if ( waveOutGetVolume( handle, (LPDWORD)&volume ) ) 111 if ( waveOutGetVolume( handle, (LPDWORD)&volume ) )
108 qDebug( "get volume of audio device failed" ); 112 qDebug( "get volume of audio device failed" );
109 waveOutClose( handle ); 113 waveOutClose( handle );
110 leftVolume = volume & 0xFFFF; 114 leftVolume = volume & 0xFFFF;
111 rightVolume = volume >> 16; 115 rightVolume = volume >> 16;
112#else 116#else
113 int mixerHandle = open( "/dev/mixer", O_RDWR ); 117 int mixerHandle = open( "/dev/mixer", O_RDWR );
114 if ( mixerHandle >= 0 ) { 118 if ( mixerHandle >= 0 ) {
115 ioctl( mixerHandle, MIXER_READ(0), &volume ); 119 if(ioctl( mixerHandle, MIXER_READ(0), &volume )==-1)
120 perror("ioctl(\"MIXER_READ\")");
116 close( mixerHandle ); 121 close( mixerHandle );
117 } else 122 } else
118 qDebug( "get volume of audio device failed" ); 123 perror("open(\"/dev/mixer\")");
119 leftVolume = ((volume & 0x00FF) << 16) / 101; 124 leftVolume = ((volume & 0x00FF) << 16) / 101;
120 rightVolume = ((volume & 0xFF00) << 8) / 101; 125 rightVolume = ((volume & 0xFF00) << 8) / 101;
121#endif 126#endif
122} 127}
123 128
124 129
125void AudioDevice::setVolume( unsigned int leftVolume, unsigned int rightVolume, bool muted ) { 130void AudioDevice::setVolume( unsigned int leftVolume, unsigned int rightVolume, bool muted ) {
126 AudioDevicePrivate::muted = muted; 131 AudioDevicePrivate::muted = muted;
127 if ( muted ) { 132 if ( muted ) {
128 AudioDevicePrivate::leftVolume = leftVolume; 133 AudioDevicePrivate::leftVolume = leftVolume;
129 AudioDevicePrivate::rightVolume = rightVolume; 134 AudioDevicePrivate::rightVolume = rightVolume;
130 leftVolume = 0; 135 leftVolume = 0;
131 rightVolume = 0; 136 rightVolume = 0;
132 } else { 137 } else {
133 leftVolume = ( (int) leftVolume < 0 ) ? 0 : (( leftVolume > 0xFFFF ) ? 0xFFFF : leftVolume ); 138 leftVolume = ( (int) leftVolume < 0 ) ? 0 : (( leftVolume > 0xFFFF ) ? 0xFFFF : leftVolume );
134 rightVolume = ( (int)rightVolume < 0 ) ? 0 : (( rightVolume > 0xFFFF ) ? 0xFFFF : rightVolume ); 139 rightVolume = ( (int)rightVolume < 0 ) ? 0 : (( rightVolume > 0xFFFF ) ? 0xFFFF : rightVolume );
135 } 140 }
136#ifdef Q_OS_WIN32 141#ifdef Q_OS_WIN32
137 HWAVEOUT handle; 142 HWAVEOUT handle;
138 WAVEFORMATEX formatData; 143 WAVEFORMATEX formatData;
139 formatData.cbSize = sizeof(WAVEFORMATEX); 144 formatData.cbSize = sizeof(WAVEFORMATEX);
140 formatData.wFormatTag = WAVE_FORMAT_PCM; 145 formatData.wFormatTag = WAVE_FORMAT_PCM;
141 formatData.nAvgBytesPerSec = 4 * 44000; 146 formatData.nAvgBytesPerSec = 4 * 44000;
142 formatData.nBlockAlign = 4; 147 formatData.nBlockAlign = 4;
143 formatData.nChannels = 2; 148 formatData.nChannels = 2;
144 formatData.nSamplesPerSec = 44000; 149 formatData.nSamplesPerSec = 44000;
145 formatData.wBitsPerSample = 16; 150 formatData.wBitsPerSample = 16;
146 waveOutOpen(&handle, WAVE_MAPPER, &formatData, 0L, 0L, CALLBACK_NULL); 151 waveOutOpen(&handle, WAVE_MAPPER, &formatData, 0L, 0L, CALLBACK_NULL);
147 unsigned int volume = (rightVolume << 16) | leftVolume; 152 unsigned int volume = (rightVolume << 16) | leftVolume;
148 if ( waveOutSetVolume( handle, volume ) ) 153 if ( waveOutSetVolume( handle, volume ) )
149 qDebug( "set volume of audio device failed" ); 154 qDebug( "set volume of audio device failed" );
150 waveOutClose( handle ); 155 waveOutClose( handle );
151#else 156#else
152 // Volume can be from 0 to 100 which is 101 distinct values 157 // Volume can be from 0 to 100 which is 101 distinct values
153 unsigned int rV = (rightVolume * 101) >> 16; 158 unsigned int rV = (rightVolume * 101) >> 16;
154 159
155# if 0 160# if 0
156 unsigned int lV = (leftVolume * 101) >> 16; 161 unsigned int lV = (leftVolume * 101) >> 16;
157 unsigned int volume = ((rV << 8) & 0xFF00) | (lV & 0x00FF); 162 unsigned int volume = ((rV << 8) & 0xFF00) | (lV & 0x00FF);
158 int mixerHandle = 0; 163 int mixerHandle = 0;
159 if ( ( mixerHandle = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 164 if ( ( mixerHandle = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
160 ioctl( mixerHandle, MIXER_WRITE(0), &volume ); 165 if(ioctl( mixerHandle, MIXER_WRITE(0), &volume ) ==-1)
166 perror("ioctl(\"MIXER_WRITE\")");
161 close( mixerHandle ); 167 close( mixerHandle );
162 } else 168 } else
163 qDebug( "set volume of audio device failed" ); 169 perror("open(\"/dev/mixer\")");
170
164# else 171# else
165 // This is the way this has to be done now I guess, doesn't allow for 172 // This is the way this has to be done now I guess, doesn't allow for
166 // independant right and left channel setting, or setting for different outputs 173 // independant right and left channel setting, or setting for different outputs
167 Config cfg("Sound"); 174 Config cfg("Sound");
168 cfg.setGroup("System"); 175 cfg.setGroup("System");
169 cfg.writeEntry("Volume",(int)rV); 176 cfg.writeEntry("Volume",(int)rV);
170# endif 177# endif
171 178
172#endif 179#endif
173// qDebug( "setting volume to: 0x%x", volume ); 180// qDebug( "setting volume to: 0x%x", volume );
174#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) 181#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP)
175 // Send notification that the volume has changed 182 // Send notification that the volume has changed
176 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << muted; 183 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << muted;
177#endif 184#endif
178} 185}
179 186
180 187
181 188
182 189
183AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) { 190AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) {
184 d = new AudioDevicePrivate; 191 d = new AudioDevicePrivate;
185 d->frequency = f; 192 d->frequency = f;
186 d->channels = chs; 193 d->channels = chs;
187 d->bytesPerSample = bps; 194 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;
188 200
201 qDebug("AD- freq %d, channels %d, b/sample %d, bitrate %d",f,chs,bps,format);
189 connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( volumeChanged(bool) ) ); 202 connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( volumeChanged(bool) ) );
190 203
191#ifdef Q_OS_WIN32
192 UINT result;
193 WAVEFORMATEX formatData;
194 formatData.cbSize = sizeof(WAVEFORMATEX);
195/*
196 // Other possible formats windows supports
197 formatData.wFormatTag = WAVE_FORMAT_MPEG;
198 formatData.wFormatTag = WAVE_FORMAT_MPEGLAYER3;
199 formatData.wFormatTag = WAVE_FORMAT_ADPCM;
200*/
201 formatData.wFormatTag = WAVE_FORMAT_PCM;
202 formatData.nAvgBytesPerSec = bps * chs * f;
203 formatData.nBlockAlign = bps * chs;
204 formatData.nChannels = chs;
205 formatData.nSamplesPerSec = f;
206 formatData.wBitsPerSample = bps * 8;
207 // Open a waveform device for output
208 if (result = waveOutOpen((LPHWAVEOUT)&d->handle, WAVE_MAPPER, &formatData, 0L, 0L, CALLBACK_NULL)) {
209 QString errorMsg = "error opening audio device.\nReason: %i - ";
210 switch (result) {
211 case MMSYSERR_ALLOCATED:errorMsg += "Specified resource is already allocated."; break;
212 case MMSYSERR_BADDEVICEID:errorMsg += "Specified device identifier is out of range."; break;
213 case MMSYSERR_NODRIVER:errorMsg += "No device driver is present."; break;
214 case MMSYSERR_NOMEM:errorMsg += "Unable to allocate or lock memory."; break;
215 case WAVERR_BADFORMAT:errorMsg += "Attempted to open with an unsupported waveform-audio format."; break;
216 case WAVERR_SYNC: errorMsg += "The device is synchronous but waveOutOpen was called without using the WAVE_ALLOWSYNC flag."; break;
217 default: errorMsg += "Undefined error"; break;
218 }
219 qDebug( errorMsg, result );
220 }
221
222 d->bufferSize = sound_fragment_bytes;
223#else
224 204
225 int fragments = 0x10000 * 8 + sound_fragment_shift; 205 int fragments = 0x10000 * 8 + sound_fragment_shift;
226 int format = AFMT_S16_LE;
227 int capabilities = 0; 206 int capabilities = 0;
228 207
229#ifdef KEEP_DEVICE_OPEN 208#ifdef KEEP_DEVICE_OPEN
230 if ( AudioDevicePrivate::dspFd == 0 ) { 209 if ( AudioDevicePrivate::dspFd == 0 ) {
231#endif 210#endif
232 if ( ( d->handle = ::open( "/dev/dsp", O_WRONLY ) ) < 0 ) { 211 if ( ( d->handle = ::open( "/dev/dsp", O_WRONLY ) ) < 0 ) {
233 qDebug( "error opening audio device /dev/dsp, sending data to /dev/null instead" ); 212 perror("open(\"/dev/dsp\") sending to /dev/null instead");
234 d->handle = ::open( "/dev/null", O_WRONLY ); 213 d->handle = ::open( "/dev/null", O_WRONLY );
235 } 214 }
236#ifdef KEEP_DEVICE_OPEN 215#ifdef KEEP_DEVICE_OPEN
237 AudioDevicePrivate::dspFd = d->handle; 216 AudioDevicePrivate::dspFd = d->handle;
238 } else { 217 } else {
239 d->handle = AudioDevicePrivate::dspFd; 218 d->handle = AudioDevicePrivate::dspFd;
240 } 219 }
241#endif 220#endif
242 221
243 ioctl( d->handle, SNDCTL_DSP_GETCAPS, &capabilities ); 222 if(ioctl( d->handle, SNDCTL_DSP_GETCAPS, &capabilities )==-1)
244 ioctl( d->handle, SNDCTL_DSP_SETFRAGMENT, &fragments ); 223 perror("ioctl(\"SNDCTL_DSP_GETCAPS\")");
245 ioctl( d->handle, SNDCTL_DSP_SETFMT, &format ); 224 if(ioctl( d->handle, SNDCTL_DSP_SETFRAGMENT, &fragments )==-1)
246 ioctl( d->handle, SNDCTL_DSP_SPEED, &d->frequency ); 225 perror("ioctl(\"SNDCTL_DSP_SETFRAGMENT\")");
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);
247 if ( ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels ) == -1 ) { 232 if ( ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels ) == -1 ) {
248 d->channels = ( d->channels == 1 ) ? 2 : d->channels; 233 d->channels = ( d->channels == 1 ) ? 2 : d->channels;
249 ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels ); 234 if(ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels )==-1)
235 perror("ioctl(\"SNDCTL_DSP_CHANNELS\")");
250 } 236 }
251 237
252 d->bufferSize = sound_fragment_bytes; 238 d->bufferSize = sound_fragment_bytes;
253 d->unwrittenBuffer = new char[d->bufferSize]; 239 d->unwrittenBuffer = new char[d->bufferSize];
254 d->unwritten = 0; 240 d->unwritten = 0;
255 d->can_GETOSPACE = TRUE; // until we find otherwise 241 d->can_GETOSPACE = TRUE; // until we find otherwise
256 242
257 //if ( chs != d->channels ) qDebug( "Wanted %d, got %d channels", chs, d->channels ); 243 //if ( chs != d->channels ) qDebug( "Wanted %d, got %d channels", chs, d->channels );
258 //if ( f != d->frequency ) qDebug( "wanted %dHz, got %dHz", f, d->frequency ); 244 //if ( f != d->frequency ) qDebug( "wanted %dHz, got %dHz", f, d->frequency );
259 //if ( capabilities & DSP_CAP_BATCH ) qDebug( "Sound card has local buffer" ); 245 //if ( capabilities & DSP_CAP_BATCH ) qDebug( "Sound card has local buffer" );
260 //if ( capabilities & DSP_CAP_REALTIME )qDebug( "Sound card has realtime sync" ); 246 //if ( capabilities & DSP_CAP_REALTIME )qDebug( "Sound card has realtime sync" );
261 //if ( capabilities & DSP_CAP_TRIGGER ) qDebug( "Sound card has precise trigger" ); 247 //if ( capabilities & DSP_CAP_TRIGGER ) qDebug( "Sound card has precise trigger" );
262 //if ( capabilities & DSP_CAP_MMAP ) qDebug( "Sound card can mmap" ); 248 //if ( capabilities & DSP_CAP_MMAP ) qDebug( "Sound card can mmap" );
263#endif
264} 249}
265 250
266 251
267AudioDevice::~AudioDevice() { 252AudioDevice::~AudioDevice() {
268#ifdef Q_OS_WIN32 253#ifdef Q_OS_WIN32
269 waveOutClose( (HWAVEOUT)d->handle ); 254 waveOutClose( (HWAVEOUT)d->handle );
270#else 255#else
271# ifndef KEEP_DEVICE_OPEN 256# ifndef KEEP_DEVICE_OPEN
272 close( d->handle ); // Now it should be safe to shut the handle 257 close( d->handle ); // Now it should be safe to shut the handle
273# endif 258# endif
274 delete d->unwrittenBuffer; 259 delete d->unwrittenBuffer;
275 delete d; 260 delete d;
276#endif 261#endif
277} 262}
278 263
279 264
280void AudioDevice::volumeChanged( bool muted ) 265void AudioDevice::volumeChanged( bool muted )
281{ 266{
282 AudioDevicePrivate::muted = muted; 267 AudioDevicePrivate::muted = muted;
283} 268}
284 269
285 270
286void AudioDevice::write( char *buffer, unsigned int length ) 271void AudioDevice::write( char *buffer, unsigned int length )
287{ 272{
288#ifdef Q_OS_WIN32 273#ifdef Q_OS_WIN32
289 // returns immediately and (to be implemented) emits completedIO() when finished writing 274 // returns immediately and (to be implemented) emits completedIO() when finished writing
290 WAVEHDR *lpWaveHdr = (WAVEHDR *)malloc( sizeof(WAVEHDR) ); 275 WAVEHDR *lpWaveHdr = (WAVEHDR *)malloc( sizeof(WAVEHDR) );
291 // maybe the buffer should be copied so that this fool proof, but its a performance hit 276 // maybe the buffer should be copied so that this fool proof, but its a performance hit
292 lpWaveHdr->lpData = buffer; 277 lpWaveHdr->lpData = buffer;
293 lpWaveHdr->dwBufferLength = length; 278 lpWaveHdr->dwBufferLength = length;
294 lpWaveHdr->dwFlags = 0L; 279 lpWaveHdr->dwFlags = 0L;
295 lpWaveHdr->dwLoops = 0L; 280 lpWaveHdr->dwLoops = 0L;
296 waveOutPrepareHeader( (HWAVEOUT)d->handle, lpWaveHdr, sizeof(WAVEHDR) ); 281 waveOutPrepareHeader( (HWAVEOUT)d->handle, lpWaveHdr, sizeof(WAVEHDR) );
297 // waveOutWrite returns immediately. the data is sent in the background. 282 // waveOutWrite returns immediately. the data is sent in the background.
298 if ( waveOutWrite( (HWAVEOUT)d->handle, lpWaveHdr, sizeof(WAVEHDR) ) ) 283 if ( waveOutWrite( (HWAVEOUT)d->handle, lpWaveHdr, sizeof(WAVEHDR) ) )
299 qDebug( "failed to write block to audio device" ); 284 qDebug( "failed to write block to audio device" );
300 // emit completedIO(); 285 // emit completedIO();
301#else 286#else
302 int t = ::write( d->handle, buffer, length ); 287 int t = ::write( d->handle, buffer, length );
303 if ( t<0 ) t = 0; 288 if ( t<0 ) t = 0;
304 if ( t != (int)length) { 289 if ( t != (int)length) {
305 qDebug("Ahhh!! memcpys 1"); 290 qDebug("Ahhh!! memcpys 1");
306 memcpy(d->unwrittenBuffer,buffer+t,length-t); 291 memcpy(d->unwrittenBuffer,buffer+t,length-t);
307 d->unwritten = length-t; 292 d->unwritten = length-t;
308 } 293 }
309#endif 294#endif
310} 295}
311 296
312 297
313unsigned int AudioDevice::channels() const 298unsigned int AudioDevice::channels() const
314{ 299{
315 return d->channels; 300 return d->channels;
316} 301}
317 302
318 303
319unsigned int AudioDevice::frequency() const 304unsigned int AudioDevice::frequency() const
320{ 305{
321 return d->frequency; 306 return d->frequency;
322} 307}
323 308
324 309
325unsigned int AudioDevice::bytesPerSample() const 310unsigned int AudioDevice::bytesPerSample() const
326{ 311{
327 return d->bytesPerSample; 312 return d->bytesPerSample;
328} 313}
329 314
330 315
331unsigned int AudioDevice::bufferSize() const 316unsigned int AudioDevice::bufferSize() const
332{ 317{
333 return d->bufferSize; 318 return d->bufferSize;
334} 319}
335 320
336unsigned int AudioDevice::canWrite() const 321unsigned int AudioDevice::canWrite() const
337{ 322{
338#ifdef Q_OS_WIN32 323#ifdef Q_OS_WIN32
339 return bufferSize(); // Any better? 324 return bufferSize(); // Any better?
340#else 325#else
341 audio_buf_info info; 326 audio_buf_info info;
342 if ( d->can_GETOSPACE && ioctl(d->handle,SNDCTL_DSP_GETOSPACE,&info) ) { 327 if ( d->can_GETOSPACE && ioctl(d->handle,SNDCTL_DSP_GETOSPACE,&info) ) {
343 d->can_GETOSPACE = FALSE; 328 d->can_GETOSPACE = FALSE;
344 fcntl( d->handle, F_SETFL, O_NONBLOCK ); 329 fcntl( d->handle, F_SETFL, O_NONBLOCK );
345 } 330 }
346 if ( d->can_GETOSPACE ) { 331 if ( d->can_GETOSPACE ) {
347 int t = info.fragments * sound_fragment_bytes; 332 int t = info.fragments * sound_fragment_bytes;
348 return QMIN(t,(int)bufferSize()); 333 return QMIN(t,(int)bufferSize());
349 } else { 334 } else {
350 if ( d->unwritten ) { 335 if ( d->unwritten ) {
351 int t = ::write( d->handle, d->unwrittenBuffer, d->unwritten ); 336 int t = ::write( d->handle, d->unwrittenBuffer, d->unwritten );
352 if ( t<0 ) t = 0; 337 if ( t<0 ) t = 0;
353 if ( (unsigned)t!=d->unwritten ) { 338 if ( (unsigned)t!=d->unwritten ) {
354 memcpy(d->unwrittenBuffer,d->unwrittenBuffer+t,d->unwritten-t); 339 memcpy(d->unwrittenBuffer,d->unwrittenBuffer+t,d->unwritten-t);
355 d->unwritten -= t; 340 d->unwritten -= t;
356 } else { 341 } else {
357 d->unwritten = 0; 342 d->unwritten = 0;
358 } 343 }
359 } 344 }
360 if ( d->unwritten ) 345 if ( d->unwritten )
361 return 0; 346 return 0;
362 else 347 else
363 return d->bufferSize; 348 return d->bufferSize;
364 } 349 }
365#endif 350#endif
366} 351}
367 352
368 353
369int AudioDevice::bytesWritten() { 354int AudioDevice::bytesWritten() {
370#ifdef Q_OS_WIN32 355#ifdef Q_OS_WIN32
371 MMTIME pmmt = { TIME_BYTES, 0 }; 356 MMTIME pmmt = { TIME_BYTES, 0 };
372 if ( ( waveOutGetPosition( (HWAVEOUT)d->handle, &pmmt, sizeof(MMTIME) ) != MMSYSERR_NOERROR ) || ( pmmt.wType != TIME_BYTES ) ) { 357 if ( ( waveOutGetPosition( (HWAVEOUT)d->handle, &pmmt, sizeof(MMTIME) ) != MMSYSERR_NOERROR ) || ( pmmt.wType != TIME_BYTES ) ) {
373 qDebug( "failed to get audio device position" ); 358 qDebug( "failed to get audio device position" );
374 return -1; 359 return -1;
375 } 360 }
376 return pmmt.u.cb; 361 return pmmt.u.cb;
377#else 362#else
378 int buffered = 0; 363 int buffered = 0;
379 if ( ioctl( d->handle, SNDCTL_DSP_GETODELAY, &buffered ) ) { 364 if ( ioctl( d->handle, SNDCTL_DSP_GETODELAY, &buffered ) ) {
380 qDebug( "failed to get audio device position" ); 365 qDebug( "failed to get audio device position" );
381 return -1; 366 return -1;
382 } 367 }
383 return buffered; 368 return buffered;
384#endif 369#endif
385} 370}
386 371
diff --git a/core/multimedia/opieplayer/audiodevice.h b/core/multimedia/opieplayer/audiodevice.h
index 928f134..dcd79fe 100644
--- a/core/multimedia/opieplayer/audiodevice.h
+++ b/core/multimedia/opieplayer/audiodevice.h
@@ -1,71 +1,75 @@
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
20#ifndef AUDIODEVICE_H 23#ifndef AUDIODEVICE_H
21#define AUDIODEVICE_H 24#define AUDIODEVICE_H
22 25
23 26
24#include <qobject.h> 27#include <qobject.h>
28#include <sys/soundcard.h>
25 29
26 30
27class AudioDevicePrivate; 31class AudioDevicePrivate;
28 32
29 33
30class AudioDevice : public QObject { 34class AudioDevice : public QObject {
31 Q_OBJECT 35 Q_OBJECT
32public: 36public:
33 AudioDevice( unsigned int freq = 44000, unsigned int channels = 2, unsigned int bytesPerSample = 2 ); 37 AudioDevice( unsigned int freq = 44000, unsigned int channels = 2, unsigned int bytesPerSample = AFMT_S16_LE );
34 ~AudioDevice(); 38 ~AudioDevice();
35 39
36 unsigned int canWrite() const; 40 unsigned int canWrite() const;
37 void write( char *buffer, unsigned int length ); 41 void write( char *buffer, unsigned int length );
38 int bytesWritten(); 42 int bytesWritten();
39 43
40 unsigned int channels() const; 44 unsigned int channels() const;
41 unsigned int frequency() const; 45 unsigned int frequency() const;
42 unsigned int bytesPerSample() const; 46 unsigned int bytesPerSample() const;
43 unsigned int bufferSize() const; 47 unsigned int bufferSize() const;
44 48
45 // Each volume level is from 0 to 0xFFFF 49 // Each volume level is from 0 to 0xFFFF
46 static void getVolume( unsigned int& left, unsigned int& right, bool& muted ); 50 static void getVolume( unsigned int& left, unsigned int& right, bool& muted );
47 static void setVolume( unsigned int left, unsigned int right, bool muted ); 51 static void setVolume( unsigned int left, unsigned int right, bool muted );
48 52
49 static unsigned int leftVolume() { bool muted; unsigned int l, r; getVolume( l, r, muted ); return l; } 53 static unsigned int leftVolume() { bool muted; unsigned int l, r; getVolume( l, r, muted ); return l; }
50 static unsigned int rightVolume() { bool muted; unsigned int l, r; getVolume( l, r, muted ); return r; } 54 static unsigned int rightVolume() { bool muted; unsigned int l, r; getVolume( l, r, muted ); return r; }
51 static bool isMuted() { bool muted; unsigned int l, r; getVolume( l, r, muted ); return muted; } 55 static bool isMuted() { bool muted; unsigned int l, r; getVolume( l, r, muted ); return muted; }
52 56
53 static void increaseVolume() { setVolume( leftVolume() + 1968, rightVolume() + 1968, isMuted() ); } 57 static void increaseVolume() { setVolume( leftVolume() + 1968, rightVolume() + 1968, isMuted() ); }
54 static void decreaseVolume() { setVolume( leftVolume() - 1966, rightVolume() - 1966, isMuted() ); } 58 static void decreaseVolume() { setVolume( leftVolume() - 1966, rightVolume() - 1966, isMuted() ); }
55 59
56public slots: 60public slots:
57 // Convinence functions derived from above functions 61 // Convinence functions derived from above functions
58 void setVolume( unsigned int level ) { setVolume( level, level, isMuted() ); } 62 void setVolume( unsigned int level ) { setVolume( level, level, isMuted() ); }
59 void mute() { setVolume( leftVolume(), rightVolume(), TRUE ); } 63 void mute() { setVolume( leftVolume(), rightVolume(), TRUE ); }
60 void volumeChanged( bool muted ); 64 void volumeChanged( bool muted );
61 65
62signals: 66signals:
63 void completedIO(); 67 void completedIO();
64 68
65private: 69private:
66 AudioDevicePrivate *d; 70 AudioDevicePrivate *d;
67}; 71};
68 72
69 73
70#endif // AUDIODEVICE_H 74#endif // AUDIODEVICE_H
71 75
diff --git a/core/multimedia/opieplayer/audiowidget.cpp b/core/multimedia/opieplayer/audiowidget.cpp
index 243c58c..0d88591 100644
--- a/core/multimedia/opieplayer/audiowidget.cpp
+++ b/core/multimedia/opieplayer/audiowidget.cpp
@@ -1,277 +1,277 @@
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 <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 29
30extern MediaPlayerState *mediaPlayerState; 30extern MediaPlayerState *mediaPlayerState;
31 31
32 32
33static const int xo = -2; // movable x offset 33static const int xo = -2; // movable x offset
34static const int yo = 22; // movable y offset 34static const int yo = 22; // movable y offset
35 35
36 36
37struct MediaButton { 37struct MediaButton {
38 int xPos, yPos; 38 int xPos, yPos;
39 int color; 39 int color;
40 bool isToggle, isBig, isHeld, isDown; 40 bool isToggle, isBig, isHeld, isDown;
41}; 41};
42 42
43 43
44// Layout information for the audioButtons (and if it is a toggle button or not) 44// Layout information for the audioButtons (and if it is a toggle button or not)
45MediaButton audioButtons[] = { 45MediaButton audioButtons[] = {
46 { 3*30-15+xo, 3*30-13+yo, 0, TRUE, TRUE, FALSE, FALSE }, // play 46 { 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 47 { 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 48 { 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 49 { 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 50 { 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 51 { 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 52 { 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 53 { 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 54 { 1*30+xo, 1*30+yo, 0, FALSE, FALSE, FALSE, FALSE } // playlist
55}; 55};
56 56
57 57
58static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); 58static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton));
59 59
60 60
61AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : 61AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) :
62 QWidget( parent, name, f ) 62 QWidget( parent, name, f )
63{ 63{
64 setCaption( tr("MediaPlayer") ); 64 setCaption( tr("OpiePlayer") );
65 setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/metalFinish" ) ); 65 setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/metalFinish" ) );
66 pixmaps[0] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaButtonsAll" ) ); 66 pixmaps[0] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaButtonsAll" ) );
67 pixmaps[1] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaButtonsBig" ) ); 67 pixmaps[1] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaButtonsBig" ) );
68 pixmaps[2] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaControls" ) ); 68 pixmaps[2] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaControls" ) );
69 pixmaps[3] = new QPixmap( Resource::loadPixmap( "mpegplayer/animatedButton" ) ); 69 pixmaps[3] = new QPixmap( Resource::loadPixmap( "mpegplayer/animatedButton" ) );
70 70
71 songInfo = new Ticker( this ); 71 songInfo = new Ticker( this );
72 songInfo->setFocusPolicy( QWidget::NoFocus ); 72 songInfo->setFocusPolicy( QWidget::NoFocus );
73 songInfo->setGeometry( QRect( 7, 3, 220, 20 ) ); 73 songInfo->setGeometry( QRect( 7, 3, 220, 20 ) );
74 74
75 slider = new QSlider( Qt::Horizontal, this ); 75 slider = new QSlider( Qt::Horizontal, this );
76 slider->setFixedWidth( 220 ); 76 slider->setFixedWidth( 220 );
77 slider->setFixedHeight( 20 ); 77 slider->setFixedHeight( 20 );
78 slider->setMinValue( 0 ); 78 slider->setMinValue( 0 );
79 slider->setMaxValue( 1 ); 79 slider->setMaxValue( 1 );
80 slider->setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/metalFinish" ) ); 80 slider->setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/metalFinish" ) );
81 slider->setFocusPolicy( QWidget::NoFocus ); 81 slider->setFocusPolicy( QWidget::NoFocus );
82 slider->setGeometry( QRect( 7, 262, 220, 20 ) ); 82 slider->setGeometry( QRect( 7, 262, 220, 20 ) );
83 83
84 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 84 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
85 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 85 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
86 86
87 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); 87 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) );
88 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 88 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
89 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 89 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
90 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); 90 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) );
91 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); 91 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) );
92 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); 92 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) );
93 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); 93 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) );
94 94
95 // Intialise state 95 // Intialise state
96 setLength( mediaPlayerState->length() ); 96 setLength( mediaPlayerState->length() );
97 setPosition( mediaPlayerState->position() ); 97 setPosition( mediaPlayerState->position() );
98 setLooping( mediaPlayerState->fullscreen() ); 98 setLooping( mediaPlayerState->fullscreen() );
99 setPaused( mediaPlayerState->paused() ); 99 setPaused( mediaPlayerState->paused() );
100 setPlaying( mediaPlayerState->playing() ); 100 setPlaying( mediaPlayerState->playing() );
101 101
102} 102}
103 103
104 104
105AudioWidget::~AudioWidget() { 105AudioWidget::~AudioWidget() {
106 for ( int i = 0; i < 4; i++ ) 106 for ( int i = 0; i < 4; i++ )
107 delete pixmaps[i]; 107 delete pixmaps[i];
108} 108}
109 109
110 110
111static bool audioSliderBeingMoved = FALSE; 111static bool audioSliderBeingMoved = FALSE;
112 112
113 113
114void AudioWidget::sliderPressed() { 114void AudioWidget::sliderPressed() {
115 audioSliderBeingMoved = TRUE; 115 audioSliderBeingMoved = TRUE;
116} 116}
117 117
118 118
119void AudioWidget::sliderReleased() { 119void AudioWidget::sliderReleased() {
120 audioSliderBeingMoved = FALSE; 120 audioSliderBeingMoved = FALSE;
121 if ( slider->width() == 0 ) 121 if ( slider->width() == 0 )
122 return; 122 return;
123 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); 123 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width());
124 mediaPlayerState->setPosition( val ); 124 mediaPlayerState->setPosition( val );
125} 125}
126 126
127 127
128void AudioWidget::setPosition( long i ) { 128void AudioWidget::setPosition( long i ) {
129 updateSlider( i, mediaPlayerState->length() ); 129 updateSlider( i, mediaPlayerState->length() );
130} 130}
131 131
132 132
133void AudioWidget::setLength( long max ) { 133void AudioWidget::setLength( long max ) {
134 updateSlider( mediaPlayerState->position(), max ); 134 updateSlider( mediaPlayerState->position(), max );
135} 135}
136 136
137 137
138void AudioWidget::setView( char view ) { 138void AudioWidget::setView( char view ) {
139 if ( view == 'a' ) { 139 if ( view == 'a' ) {
140 startTimer( 150 ); 140 startTimer( 150 );
141 showMaximized(); 141 showMaximized();
142 } else { 142 } else {
143 killTimers(); 143 killTimers();
144 hide(); 144 hide();
145 } 145 }
146} 146}
147 147
148 148
149void AudioWidget::updateSlider( long i, long max ) { 149void AudioWidget::updateSlider( long i, long max ) {
150 if ( max == 0 ) 150 if ( max == 0 )
151 return; 151 return;
152 // Will flicker too much if we don't do this 152 // Will flicker too much if we don't do this
153 // Scale to something reasonable 153 // Scale to something reasonable
154 int width = slider->width(); 154 int width = slider->width();
155 int val = int((double)i * width / max); 155 int val = int((double)i * width / max);
156 if ( !audioSliderBeingMoved ) { 156 if ( !audioSliderBeingMoved ) {
157 if ( slider->value() != val ) 157 if ( slider->value() != val )
158 slider->setValue( val ); 158 slider->setValue( val );
159 if ( slider->maxValue() != width ) 159 if ( slider->maxValue() != width )
160 slider->setMaxValue( width ); 160 slider->setMaxValue( width );
161 } 161 }
162} 162}
163 163
164 164
165void AudioWidget::setToggleButton( int i, bool down ) { 165void AudioWidget::setToggleButton( int i, bool down ) {
166 if ( down != audioButtons[i].isDown ) 166 if ( down != audioButtons[i].isDown )
167 toggleButton( i ); 167 toggleButton( i );
168} 168}
169 169
170 170
171void AudioWidget::toggleButton( int i ) { 171void AudioWidget::toggleButton( int i ) {
172 audioButtons[i].isDown = !audioButtons[i].isDown; 172 audioButtons[i].isDown = !audioButtons[i].isDown;
173 QPainter p(this); 173 QPainter p(this);
174 paintButton ( &p, i ); 174 paintButton ( &p, i );
175} 175}
176 176
177 177
178void AudioWidget::paintButton( QPainter *p, int i ) { 178void AudioWidget::paintButton( QPainter *p, int i ) {
179 int x = audioButtons[i].xPos; 179 int x = audioButtons[i].xPos;
180 int y = audioButtons[i].yPos; 180 int y = audioButtons[i].yPos;
181 int offset = 22 + 14 * audioButtons[i].isBig + audioButtons[i].isDown; 181 int offset = 22 + 14 * audioButtons[i].isBig + audioButtons[i].isDown;
182 int buttonSize = 64 + audioButtons[i].isBig * (90 - 64); 182 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 ); 183 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 ); 184 p->drawPixmap( x + offset, y + offset, *pixmaps[2], 18 * i, 0, 18, 18 );
185} 185}
186 186
187 187
188void AudioWidget::timerEvent( QTimerEvent * ) { 188void AudioWidget::timerEvent( QTimerEvent * ) {
189 static int frame = 0; 189 static int frame = 0;
190 if ( !mediaPlayerState->paused() && audioButtons[ AudioPlay ].isDown ) { 190 if ( !mediaPlayerState->paused() && audioButtons[ AudioPlay ].isDown ) {
191 frame = frame >= 7 ? 0 : frame + 1; 191 frame = frame >= 7 ? 0 : frame + 1;
192 int x = audioButtons[AudioPlay].xPos; 192 int x = audioButtons[AudioPlay].xPos;
193 int y = audioButtons[AudioPlay].yPos; 193 int y = audioButtons[AudioPlay].yPos;
194 QPainter p( this ); 194 QPainter p( this );
195 // Optimize to only draw the little bit of the changing images which is different 195 // 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 ); 196 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 ); 197 p.drawPixmap( x + 37, y + 37, *pixmaps[2], 18 * AudioPlay, 0, 6, 3 );
198 } 198 }
199} 199}
200 200
201 201
202void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { 202void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
203 for ( int i = 0; i < numButtons; i++ ) { 203 for ( int i = 0; i < numButtons; i++ ) {
204 int size = audioButtons[i].isBig; 204 int size = audioButtons[i].isBig;
205 int x = audioButtons[i].xPos; 205 int x = audioButtons[i].xPos;
206 int y = audioButtons[i].yPos; 206 int y = audioButtons[i].yPos;
207 if ( event->state() == QMouseEvent::LeftButton ) { 207 if ( event->state() == QMouseEvent::LeftButton ) {
208 // The test to see if the mouse click is inside the circular button or not 208 // 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) 209 // (compared with the radius squared to avoid a square-root of our distance)
210 int radius = 32 + 13 * size; 210 int radius = 32 + 13 * size;
211 QPoint center = QPoint( x + radius, y + radius ); 211 QPoint center = QPoint( x + radius, y + radius );
212 QPoint dXY = center - event->pos(); 212 QPoint dXY = center - event->pos();
213 int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y(); 213 int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y();
214 bool isOnButton = dist <= (radius * radius); 214 bool isOnButton = dist <= (radius * radius);
215 // QRect r( x, y, 64 + 22*size, 64 + 22*size ); 215// QRect r( x, y, 64 + 22*size, 64 + 22*size );
216 // bool isOnButton = r.contains( event->pos() ); // Rectangular Button code 216// bool isOnButton = r.contains( event->pos() ); // Rectangular Button code
217 if ( isOnButton && !audioButtons[i].isHeld ) { 217 if ( isOnButton && !audioButtons[i].isHeld ) {
218 audioButtons[i].isHeld = TRUE; 218 audioButtons[i].isHeld = TRUE;
219 toggleButton(i); 219 toggleButton(i);
220 switch (i) { 220 switch (i) {
221 case AudioVolumeUp: emit moreClicked(); return; 221 case AudioVolumeUp: emit moreClicked(); return;
222 case AudioVolumeDown: emit lessClicked(); return; 222 case AudioVolumeDown: emit lessClicked(); return;
223 } 223 }
224 } else if ( !isOnButton && audioButtons[i].isHeld ) { 224 } else if ( !isOnButton && audioButtons[i].isHeld ) {
225 audioButtons[i].isHeld = FALSE; 225 audioButtons[i].isHeld = FALSE;
226 toggleButton(i); 226 toggleButton(i);
227 } 227 }
228 } else { 228 } else {
229 if ( audioButtons[i].isHeld ) { 229 if ( audioButtons[i].isHeld ) {
230 audioButtons[i].isHeld = FALSE; 230 audioButtons[i].isHeld = FALSE;
231 if ( !audioButtons[i].isToggle ) 231 if ( !audioButtons[i].isToggle )
232 setToggleButton( i, FALSE ); 232 setToggleButton( i, FALSE );
233 switch (i) { 233 switch (i) {
234 case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return; 234 case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return;
235 case AudioStop: mediaPlayerState->setPlaying(FALSE); return; 235 case AudioStop: mediaPlayerState->setPlaying(FALSE); return;
236 case AudioPause: mediaPlayerState->setPaused(audioButtons[i].isDown); return; 236 case AudioPause: mediaPlayerState->setPaused(audioButtons[i].isDown); return;
237 case AudioNext: mediaPlayerState->setNext(); return; 237 case AudioNext: mediaPlayerState->setNext(); return;
238 case AudioPrevious: mediaPlayerState->setPrev(); return; 238 case AudioPrevious: mediaPlayerState->setPrev(); return;
239 case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return; 239 case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return;
240 case AudioVolumeUp: emit moreReleased(); return; 240 case AudioVolumeUp: emit moreReleased(); return;
241 case AudioVolumeDown: emit lessReleased(); return; 241 case AudioVolumeDown: emit lessReleased(); return;
242 case AudioPlayList: mediaPlayerState->setList(); return; 242 case AudioPlayList: mediaPlayerState->setList(); return;
243 } 243 }
244 } 244 }
245 } 245 }
246 } 246 }
247} 247}
248 248
249 249
250void AudioWidget::mousePressEvent( QMouseEvent *event ) { 250void AudioWidget::mousePressEvent( QMouseEvent *event ) {
251 mouseMoveEvent( event ); 251 mouseMoveEvent( event );
252} 252}
253 253
254 254
255void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { 255void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) {
256 mouseMoveEvent( event ); 256 mouseMoveEvent( event );
257} 257}
258 258
259 259
260void AudioWidget::showEvent( QShowEvent* ) { 260void AudioWidget::showEvent( QShowEvent* ) {
261 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); 261 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 );
262 mouseMoveEvent( &event ); 262 mouseMoveEvent( &event );
263} 263}
264 264
265 265
266void AudioWidget::closeEvent( QCloseEvent* ) { 266void AudioWidget::closeEvent( QCloseEvent* ) {
267 mediaPlayerState->setList(); 267 mediaPlayerState->setList();
268} 268}
269 269
270 270
271void AudioWidget::paintEvent( QPaintEvent * ) { 271void AudioWidget::paintEvent( QPaintEvent * ) {
272 QPainter p( this ); 272 QPainter p( this );
273 for ( int i = 0; i < numButtons; i++ ) 273 for ( int i = 0; i < numButtons; i++ )
274 paintButton( &p, i ); 274 paintButton( &p, i );
275} 275}
276 276
277 277
diff --git a/core/multimedia/opieplayer/libflash/libflashplugin.h b/core/multimedia/opieplayer/libflash/libflashplugin.h
index 532bca2..a2f1c42 100644
--- a/core/multimedia/opieplayer/libflash/libflashplugin.h
+++ b/core/multimedia/opieplayer/libflash/libflashplugin.h
@@ -1,96 +1,98 @@
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 "mediaplayerplugininterface.h" 27//#include <qpe/mediaplayerplugininterface.h>
28#include "../mediaplayerplugininterface.h"
28 29
29 30
30class LibFlashPlugin : public MediaPlayerDecoder { 31class LibFlashPlugin : public MediaPlayerDecoder {
31 32
32public: 33public:
33 LibFlashPlugin(); 34 LibFlashPlugin();
34 ~LibFlashPlugin() { close(); } 35 ~LibFlashPlugin() { close(); }
35 36
36 const char *pluginName() { return "LibFlashPlugin: " PLUGIN_NAME " " FLASH_VERSION_STRING; } 37 const char *pluginName() { return "LibFlashPlugin: " PLUGIN_NAME " " FLASH_VERSION_STRING; }
37 const char *pluginComment() { return "This is the libflash library: " PLUGIN_NAME " " FLASH_VERSION_STRING; } 38 const char *pluginComment() { return "This is the libflash library: " PLUGIN_NAME " " FLASH_VERSION_STRING; }
38 double pluginVersion() { return 1.0; } 39 double pluginVersion() { return 1.0; }
39 40
40 bool isFileSupported( const QString& fileName ) { return fileName.right(4) == ".swf"; } 41 bool isFileSupported( const QString& fileName ) { return fileName.right(4) == ".swf"; }
41 bool open( const QString& fileName ); 42 bool open( const QString& fileName );
42 bool close() { FlashClose( file ); file = NULL; return TRUE; } 43 bool close() { FlashClose( file ); file = NULL; return TRUE; }
43 bool isOpen() { return file != NULL; } 44 bool isOpen() { return file != NULL; }
44 const QString &fileInfo() { return strInfo = qApp->translate( "MediaPlayer", "No Information Available", "media plugin text" ); } 45 const QString &fileInfo() { return strInfo = qApp->translate( "MediaPlayer", "No Information Available", "media plugin text" ); }
45 46
46 // If decoder doesn't support audio then return 0 here 47 // If decoder doesn't support audio then return 0 here
47 int audioStreams() { return 1; } 48 int audioStreams() { return 1; }
48 int audioChannels( int /*stream*/ ) { return 2; } 49 int audioChannels( int /*stream*/ ) { return 2; }
49 int audioFrequency( int /*stream*/ ) { return 44100; } 50 int audioFrequency( int /*stream*/ ) { return 44100; }
50 int audioSamples( int /*stream*/ ) { return 1000000; } 51 int audioSamples( int /*stream*/ ) { return 1000000; }
52int audioBitsPerSample(int) { return 0;}
51 bool audioSetSample( long sample, int stream ); 53 bool audioSetSample( long sample, int stream );
52 long audioGetSample( int stream ); 54 long audioGetSample( int stream );
53 //bool audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream ); 55 //bool audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream );
54 //bool audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream ); 56 //bool audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream );
55 bool audioReadSamples( short *output, int channels, long samples, long& samplesRead, int stream ); 57 bool audioReadSamples( short *output, int channels, long samples, long& samplesRead, int stream );
56 //bool audioReadSamples( short *output, int channel, long samples, int stream ); 58 //bool audioReadSamples( short *output, int channel, long samples, int stream );
57 //bool audioReReadSamples( short *output, int channel, long samples, int stream ); 59 //bool audioReReadSamples( short *output, int channel, long samples, int stream );
58 60
59 // If decoder doesn't support video then return 0 here 61 // If decoder doesn't support video then return 0 here
60 int videoStreams(); 62 int videoStreams();
61 int videoWidth( int stream ); 63 int videoWidth( int stream );
62 int videoHeight( int stream ); 64 int videoHeight( int stream );
63 double videoFrameRate( int stream ); 65 double videoFrameRate( int stream );
64 int videoFrames( int stream ); 66 int videoFrames( int stream );
65 bool videoSetFrame( long frame, int stream ); 67 bool videoSetFrame( long frame, int stream );
66 long videoGetFrame( int stream ); 68 long videoGetFrame( 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 ); 69 bool videoReadFrame( unsigned char **output_rows, int in_x, int in_y, int in_w, int in_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 ); 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 );
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 ); 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 );
70 72
71 // Profiling 73 // Profiling
72 double getTime(); 74 double getTime();
73 75
74 // Ignore if these aren't supported 76 // Ignore if these aren't supported
75 bool setSMP( int cpus ); 77 bool setSMP( int cpus );
76 bool setMMX( bool useMMX ); 78 bool setMMX( bool useMMX );
77 79
78 // Capabilities 80 // Capabilities
79 bool supportsAudio() { return TRUE; } 81 bool supportsAudio() { return TRUE; }
80 bool supportsVideo() { return TRUE; } 82 bool supportsVideo() { return TRUE; }
81 bool supportsYUV() { return TRUE; } 83 bool supportsYUV() { return TRUE; }
82 bool supportsMMX() { return TRUE; } 84 bool supportsMMX() { return TRUE; }
83 bool supportsSMP() { return TRUE; } 85 bool supportsSMP() { return TRUE; }
84 bool supportsStereo() { return TRUE; } 86 bool supportsStereo() { return TRUE; }
85 bool supportsScaling() { return TRUE; } 87 bool supportsScaling() { return TRUE; }
86 88
87private: 89private:
88 FlashHandle file; 90 FlashHandle file;
89 FlashDisplay *fd; 91 FlashDisplay *fd;
90 QString strInfo; 92 QString strInfo;
91 93
92}; 94};
93 95
94 96
95#endif 97#endif
96 98
diff --git a/core/multimedia/opieplayer/libflash/libflashpluginimpl.h b/core/multimedia/opieplayer/libflash/libflashpluginimpl.h
index b5cc869..cb8d959 100644
--- a/core/multimedia/opieplayer/libflash/libflashpluginimpl.h
+++ b/core/multimedia/opieplayer/libflash/libflashpluginimpl.h
@@ -1,53 +1,54 @@
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 "../mediaplayerplugininterface.h" 25#include "../mediaplayerplugininterface.h"
25 26
26 27
27class LibFlashPlugin; 28class LibFlashPlugin;
28 29
29 30
30class LibFlashPluginImpl : public MediaPlayerPluginInterface 31class LibFlashPluginImpl : public MediaPlayerPluginInterface
31{ 32{
32public: 33public:
33 LibFlashPluginImpl(); 34 LibFlashPluginImpl();
34 virtual ~LibFlashPluginImpl(); 35 virtual ~LibFlashPluginImpl();
35 36
36#ifndef QT_NO_COMPONENT 37#ifndef QT_NO_COMPONENT
37 38
38 QRESULT queryInterface( const QUuid&, QUnknownInterface** ); 39 QRESULT queryInterface( const QUuid&, QUnknownInterface** );
39 Q_REFCOUNT 40 Q_REFCOUNT
40 41
41#endif 42#endif
42 43
43 virtual MediaPlayerDecoder *decoder(); 44 virtual MediaPlayerDecoder *decoder();
44 virtual MediaPlayerEncoder *encoder(); 45 virtual MediaPlayerEncoder *encoder();
45 46
46private: 47private:
47 LibFlashPlugin *libflashplugin; 48 LibFlashPlugin *libflashplugin;
48 ulong ref; 49 ulong ref;
49}; 50};
50 51
51 52
52#endif 53#endif
53 54
diff --git a/core/multimedia/opieplayer/libflash/swf.h b/core/multimedia/opieplayer/libflash/swf.h
index 5f5e4f7..48986cc 100644
--- a/core/multimedia/opieplayer/libflash/swf.h
+++ b/core/multimedia/opieplayer/libflash/swf.h
@@ -19,211 +19,211 @@ extern int debug;
19// Global Types 19// Global Types
20typedef unsigned long U32, *P_U32, **PP_U32; 20typedef unsigned long U32, *P_U32, **PP_U32;
21typedef signed long S32, *P_S32, **PP_S32; 21typedef signed long S32, *P_S32, **PP_S32;
22typedef unsigned short U16, *P_U16, **PP_U16; 22typedef unsigned short U16, *P_U16, **PP_U16;
23typedef signed short S16, *P_S16, **PP_S16; 23typedef signed short S16, *P_S16, **PP_S16;
24typedef unsigned char U8, *P_U8, **PP_U8; 24typedef unsigned char U8, *P_U8, **PP_U8;
25typedef signed char S8, *P_S8, **PP_S8; 25typedef signed char S8, *P_S8, **PP_S8;
26typedef signed long SFIXED, *P_SFIXED; 26typedef signed long SFIXED, *P_SFIXED;
27typedef signed long SCOORD, *P_SCOORD; 27typedef signed long SCOORD, *P_SCOORD;
28typedef unsigned long BOOL; 28typedef unsigned long BOOL;
29 29
30#define ZOOM(v,f) ((v)/(f)) 30#define ZOOM(v,f) ((v)/(f))
31 31
32#include "matrix.h" 32#include "matrix.h"
33#include "cxform.h" 33#include "cxform.h"
34#include "rect.h" 34#include "rect.h"
35 35
36#include <sys/time.h> 36#include <sys/time.h>
37#define ST struct timeval t1,t2; 37#define ST struct timeval t1,t2;
38#define START gettimeofday(&t1,0) 38#define START gettimeofday(&t1,0)
39#define STOP(msg) gettimeofday(&t2,0); printf("%s Delta = %d ms\n", msg, (t2.tv_sec-t1.tv_sec)*1000+(t2.tv_usec-t1.tv_usec)/1000); fflush(stdout); 39#define STOP(msg) gettimeofday(&t2,0); printf("%s Delta = %d ms\n", msg, (t2.tv_sec-t1.tv_sec)*1000+(t2.tv_usec-t1.tv_usec)/1000); fflush(stdout);
40 40
41// Start Sound Flags 41// Start Sound Flags
42enum { 42enum {
43 soundHasInPoint = 0x01, 43 soundHasInPoint = 0x01,
44 soundHasOutPoint= 0x02, 44 soundHasOutPoint= 0x02,
45 soundHasLoops = 0x04, 45 soundHasLoops = 0x04,
46 soundHasEnvelope= 0x08 46 soundHasEnvelope= 0x08
47 47
48 // the upper 4 bits are reserved for synchronization flags 48 // the upper 4 bits are reserved for synchronization flags
49}; 49};
50 50
51// Flags for Sound Format 51// Flags for Sound Format
52enum SounfFlags { 52enum SounfFlags {
53 soundIsStereo = 0x01, 53 soundIsStereo = 0x01,
54 soundIs16bit = 0x02, 54 soundIs16bit = 0x02,
55 soundIsADPCMCompressed= 0x10 55 soundIsADPCMCompressed= 0x10
56}; 56};
57 57
58// Flags for defining Button States 58// Flags for defining Button States
59enum ButtonState { 59enum ButtonState {
60 stateHitTest = 0x08, 60 stateHitTest = 0x08,
61 stateDown = 0x04, 61 stateDown = 0x04,
62 stateOver = 0x02, 62 stateOver = 0x02,
63 stateUp = 0x01 63 stateUp = 0x01
64}; 64};
65 65
66// Actions 66// Actions
67enum Action { 67enum Action {
68 // Internal actions 68 // Internal actions
69 ActionRefresh = 0x00, 69 ActionRefresh = 0x00,
70 ActionPlaySound = 0x01, 70 ActionPlaySound = 0x01,
71 // Normal actions 71 // Normal actions
72 ActionGotoFrame = 0x81, 72 ActionGotoFrame = 0x81,
73 ActionGetURL = 0x83, 73 ActionGetURL = 0x83,
74 ActionNextFrame = 0x04, 74 ActionNextFrame = 0x04,
75 ActionPrevFrame = 0x05, 75 ActionPrevFrame = 0x05,
76 ActionPlay = 0x06, 76 ActionPlay = 0x06,
77 ActionStop = 0x07, 77 ActionStop = 0x07,
78 ActionToggleQuality= 0x08, 78 ActionToggleQuality= 0x08,
79 ActionStopSounds= 0x09, 79 ActionStopSounds= 0x09,
80 ActionWaitForFrame= 0x8a, 80 ActionWaitForFrame= 0x8a,
81 ActionSetTarget = 0x8b, 81 ActionSetTarget = 0x8b,
82 ActionGoToLabel = 0x8c 82 ActionGoToLabel = 0x8c
83}; 83};
84 84
85class Sound; 85class Sound;
86 86
87struct ActionRecord { 87struct ActionRecord {
88 Action action; 88 Action action;
89 89
90 // GotoFrame & WaitForFrame 90 // GotoFrame & WaitForFrame
91 long frameIndex; 91 long frameIndex;
92 92
93 // GetURL 93 // GetURL
94 char *url; 94 char *url;
95 char *target; 95 char *target;
96 96
97 // GotoLabel 97 // GotoLabel
98 char *frameLabel; 98 char *frameLabel;
99 99
100 // WaitForFrame 100 // WaitForFrame
101 long skipCount; 101 long skipCount;
102 102
103 // Sound 103 // Sound
104 Sound *sound; 104 Sound *sound;
105 105
106 struct ActionRecord*next; 106 struct ActionRecord*next;
107 107
108 ActionRecord() { 108 ActionRecord() {
109 frameLabel = 0; 109 frameLabel = 0;
110 url = 0; 110 url = 0;
111 target = 0; 111 target = 0;
112 sound = 0; 112 sound = 0;
113 }; 113 };
114 114
115 ~ActionRecord() { 115 ~ActionRecord() {
116 if (frameLabel) free(frameLabel); 116 if (frameLabel) free(frameLabel);
117 if (url) free(url); 117 if (url) free(url);
118 if (target) free(target); 118 if (target) free(target);
119 }; 119 };
120}; 120};
121 121
122enum FontFlags { 122enum FontFlags {
123 fontUnicode = 0x20, 123 fontUnicode = 0x20,
124 fontShiftJIS = 0x10, 124 fontShiftJIS = 0x10,
125 fontANSI = 0x08, 125 fontANSI = 0x08,
126 fontItalic = 0x04, 126 fontItalic = 0x04,
127 fontBold = 0x02, 127 fontBold = 0x02,
128 fontWideCodes = 0x01 128 fontWideCodes = 0x01
129}; 129};
130 130
131enum TextFlags { 131enum TextFlags {
132 isTextControl = 0x80, 132 isTextControl = 0x80,
133 133
134 textIsLarge = 0x70, 134 textIsLarge = 0x70,
135 textHasFont = 0x08, 135 textHasFont = 0x08,
136 textHasColor = 0x04, 136 textHasColor = 0x04,
137 textHasYOffset= 0x02, 137 textHasYOffset= 0x02,
138 textHasXOffset= 0x01 138 textHasXOffset= 0x01
139}; 139};
140 140
141#ifndef NULL 141#ifndef NULL
142#define NULL 0 142#define NULL 0
143#endif 143#endif
144 144
145// Tag values that represent actions or data in a Flash script. 145// Tag values that represent actions or data in a Flash script.
146enum 146enum
147{ 147{
148 stagEnd = 0, 148 stagEnd = 0,
149 stagShowFrame = 1, 149 stagShowFrame = 1,
150 stagDefineShape = 2, 150 stagDefineShape = 2,
151 stagFreeCharacter = 3, 151 stagFreeCharacter = 3,
152 stagPlaceObject = 4, 152 stagPlaceObject = 4,
153 stagRemoveObject = 5, 153 stagRemoveObject = 5,
154 stagDefineBits = 6, 154 stagDefineBits = 6,
155 stagDefineButton = 7, 155 stagDefineButton = 7,
156 stagJPEGTables = 8, 156 stagJPEGTables = 8,
157 stagSetBackgroundColor= 9, 157 stagSetBackgroundColor= 9,
158 stagDefineFont = 10, 158 stagDefineFont = 10,
159 stagDefineText = 11, 159 stagDefineText = 11,
160 stagDoAction = 12, 160 stagDoAction = 12,
161 stagDefineFontInfo = 13, 161 stagDefineFontInfo = 13,
162 stagDefineSound = 14,// Event sound tags. 162 stagDefineSound = 14,// Event sound tags.
163 stagStartSound = 15, 163 stagStartSound = 15,
164 stagStopSound = 16, 164 stagStopSound = 16,
165 stagDefineButtonSound= 17, 165 stagDefineButtonSound= 17,
166 stagSoundStreamHead = 18, 166 stagSoundStreamHead = 18,
167 stagSoundStreamBlock= 19, 167 stagSoundStreamBlock= 19,
168 stagDefineBitsLossless = 20,// A bitmap using lossless zlib compression. 168 stagDefineBitsLossless = 20,// A bitmap using lossless zlib compression.
169 stagDefineBitsJPEG2 = 21,// A bitmap using an internal JPEG compression table. 169 stagDefineBitsJPEG2 = 21,// A bitmap using an internal JPEG compression table.
170 stagDefineShape2 = 22, 170 stagDefineShape2 = 22,
171 stagDefineButtonCxform= 23, 171 stagDefineButtonCxform= 23,
172 stagProtect = 24,// This file should not be importable for editing. 172 stagProtect = 24,// This file should not be importable for editing.
173 173
174 // These are the new tags for Flash 3. 174 // These are the new tags for Flash 3.
175 stagPlaceObject2 = 26,// The new style place w/ alpha color transform and name. 175 stagPlaceObject2 = 26,// The new style place w/ alpha color transform and name.
176 stagRemoveObject2 = 28,// A more compact remove object that omits the character tag (just depth). 176 stagRemoveObject2 = 28,// A more compact remove object that omits the character tag (just depth).
177 stagDefineShape3 = 32,// A shape V3 includes alpha values. 177 stagDefineShape3 = 32,// A shape V3 includes alpha values.
178 stagDefineText2 = 33,// A text V2 includes alpha values. 178 stagDefineText2 = 33,// A text V2 includes alpha values.
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
199extern int shape_size,shape_nb,shaperecord_size,shaperecord_nb,style_size,style_nb; 199extern int shape_size,shape_nb,shaperecord_size,shaperecord_nb,style_size,style_nb;
200 200
201typedef void (*ScanLineFunc)(void *id, long y, long start, long end); 201typedef void (*ScanLineFunc)(void *id, long y, long start, long end);
202 202
203class Bitmap; 203class Bitmap;
204struct FlashMovie; 204struct FlashMovie;
205 205
206extern "C" { 206extern "C" {
207#include "jpeglib.h" 207#include "jpeglib.h"
208}; 208};
209extern "C" { 209extern "C" {
210//#include "zlib.h" 210//#include "zlib.h"
211#include "../src/3rdparty/zlib/zlib.h" 211#include "/opt/qt-2.3.2-embedded/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 e9f74e7..552043c 100644
--- a/core/multimedia/opieplayer/libmad/Makefile.in
+++ b/core/multimedia/opieplayer/libmad/Makefile.in
@@ -25,199 +25,201 @@ TARGET1 = lib$(TARGET).so.$(VER_MAJ)
25 25
26 HEADERS =libmad_version.h \ 26 HEADERS =libmad_version.h \
27 fixed.h \ 27 fixed.h \
28 bit.h \ 28 bit.h \
29 timer.h \ 29 timer.h \
30 stream.h \ 30 stream.h \
31 frame.h \ 31 frame.h \
32 synth.h \ 32 synth.h \
33 decoder.h \ 33 decoder.h \
34 layer12.h \ 34 layer12.h \
35 layer3.h \ 35 layer3.h \
36 huffman.h \ 36 huffman.h \
37 libmad_global.h \ 37 libmad_global.h \
38 mad.h \ 38 mad.h \
39 libmadplugin.h \ 39 libmadplugin.h \
40 libmadpluginimpl.h 40 libmadpluginimpl.h
41 SOURCES =version.c \ 41 SOURCES =version.c \
42 fixed.c \ 42 fixed.c \
43 bit.c \ 43 bit.c \
44 timer.c \ 44 timer.c \
45 stream.c \ 45 stream.c \
46 frame.c \ 46 frame.c \
47 synth.c \ 47 synth.c \
48 decoder.c \ 48 decoder.c \
49 layer12.c \ 49 layer12.c \
50 layer3.c \ 50 layer3.c \
51 huffman.c \ 51 huffman.c \
52 libmadplugin.cpp \ 52 libmadplugin.cpp \
53 libmadpluginimpl.cpp 53 libmadpluginimpl.cpp
54 OBJECTS =version.o \ 54 OBJECTS =version.o \
55 fixed.o \ 55 fixed.o \
56 bit.o \ 56 bit.o \
57 timer.o \ 57 timer.o \
58 stream.o \ 58 stream.o \
59 frame.o \ 59 frame.o \
60 synth.o \ 60 synth.o \
61 decoder.o \ 61 decoder.o \
62 layer12.o \ 62 layer12.o \
63 layer3.o \ 63 layer3.o \
64 huffman.o \ 64 huffman.o \
65 libmadplugin.o \ 65 libmadplugin.o \
66 libmadpluginimpl.o 66 libmadpluginimpl.o
67INTERFACES = 67INTERFACES =
68UICDECLS = 68UICDECLS =
69UICIMPLS = 69UICIMPLS =
70 SRCMOC = 70 SRCMOC =
71 OBJMOC = 71 OBJMOC =
72 72
73 73
74####### Implicit rules 74####### Implicit rules
75 75
76.SUFFIXES: .cpp .cxx .cc .C .c 76.SUFFIXES: .cpp .cxx .cc .C .c
77 77
78.cpp.o: 78.cpp.o:
79 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< 79 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
80 80
81.cxx.o: 81.cxx.o:
82 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< 82 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
83 83
84.cc.o: 84.cc.o:
85 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< 85 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
86 86
87.C.o: 87.C.o:
88 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< 88 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
89 89
90.c.o: 90.c.o:
91 $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $< 91 $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $<
92 92
93####### Build rules 93####### Build rules
94 94
95 95
96all: $(DESTDIR)$(SYSCONF_LINK_TARGET) 96all: $(DESTDIR)$(SYSCONF_LINK_TARGET)
97 97
98$(DESTDIR)$(SYSCONF_LINK_TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) $(SUBLIBS) 98$(DESTDIR)$(SYSCONF_LINK_TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) $(SUBLIBS)
99 $(SYSCONF_LINK_LIB) 99 $(SYSCONF_LINK_LIB)
100 100
101moc: $(SRCMOC) 101moc: $(SRCMOC)
102 102
103tmake: 103tmake:
104 tmake libmad.pro 104 tmake libmad.pro
105 105
106clean: 106clean:
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
113listpromodules: 113listpromodules:
114 @echo 114 @echo
115 115
116listallmodules: 116listallmodules:
117 @echo 117 @echo
118 118
119listaddonpromodules: 119listaddonpromodules:
120 @echo 120 @echo
121 121
122listaddonentmodules: 122listaddonentmodules:
123 @echo 123 @echo
124 124
125 125
126REQUIRES= 126REQUIRES=
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
137version.o: version.c \ 137version.o: version.c \
138 libmad_global.h \ 138 libmad_global.h \
139 libmad_version.h 139 libmad_version.h
140 140
141fixed.o: fixed.c \ 141fixed.o: fixed.c \
142 libmad_global.h \ 142 libmad_global.h \
143 fixed.h 143 fixed.h
144 144
145bit.o: bit.c \ 145bit.o: bit.c \
146 libmad_global.h \ 146 libmad_global.h \
147 bit.h 147 bit.h
148 148
149timer.o: timer.c \ 149timer.o: timer.c \
150 libmad_global.h \ 150 libmad_global.h \
151 timer.h 151 timer.h
152 152
153stream.o: stream.c \ 153stream.o: stream.c \
154 libmad_global.h \ 154 libmad_global.h \
155 bit.h \ 155 bit.h \
156 stream.h 156 stream.h
157 157
158frame.o: frame.c \ 158frame.o: frame.c \
159 libmad_global.h \ 159 libmad_global.h \
160 bit.h \ 160 bit.h \
161 stream.h \ 161 stream.h \
162 frame.h \ 162 frame.h \
163 fixed.h \ 163 fixed.h \
164 timer.h \ 164 timer.h \
165 layer12.h \ 165 layer12.h \
166 layer3.h 166 layer3.h
167 167
168synth.o: synth.c \ 168synth.o: synth.c \
169 libmad_global.h \ 169 libmad_global.h \
170 fixed.h \ 170 fixed.h \
171 frame.h \ 171 frame.h \
172 timer.h \ 172 timer.h \
173 stream.h \ 173 stream.h \
174 bit.h \ 174 bit.h \
175 synth.h \ 175 synth.h \
176 D.dat 176 D.dat
177 177
178decoder.o: decoder.c \ 178decoder.o: decoder.c \
179 libmad_global.h \ 179 libmad_global.h \
180 stream.h \ 180 stream.h \
181 bit.h \ 181 bit.h \
182 frame.h \ 182 frame.h \
183 fixed.h \ 183 fixed.h \
184 timer.h \ 184 timer.h \
185 synth.h \ 185 synth.h \
186 decoder.h 186 decoder.h
187 187
188layer12.o: layer12.c \ 188layer12.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
199layer3.o: layer3.c \ 199layer3.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
211huffman.o: huffman.c \ 211huffman.o: huffman.c \
212 libmad_global.h \ 212 libmad_global.h \
213 huffman.h 213 huffman.h
214 214
215libmadplugin.o: libmadplugin.cpp \ 215libmadplugin.o: libmadplugin.cpp \
216 libmadplugin.h \ 216 libmadplugin.h \
217 ../mediaplayerplugininterface.h \
217 mad.h 218 mad.h
218 219
219libmadpluginimpl.o: libmadpluginimpl.cpp \ 220libmadpluginimpl.o: libmadpluginimpl.cpp \
220 libmadplugin.h \ 221 libmadplugin.h \
222 ../mediaplayerplugininterface.h \
221 libmadpluginimpl.h 223 libmadpluginimpl.h
222 224
223 225
diff --git a/core/multimedia/opieplayer/libmad/libmad.pro b/core/multimedia/opieplayer/libmad/libmad.pro
index 6c40a15..b54ca6b 100644
--- a/core/multimedia/opieplayer/libmad/libmad.pro
+++ b/core/multimedia/opieplayer/libmad/libmad.pro
@@ -1,12 +1,14 @@
1 TEMPLATE= lib 1TEMPLATE = lib
2 CONFIG += qt warn_on release 2CONFIG += qt warn_on release
3 HEADERS = libmad_version.h fixed.h bit.h timer.h stream.h frame.h synth.h decoder.h \ 3HEADERS = 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 \ 5SOURCES = 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 7TARGET = madplugin
8 DESTDIR = ../../plugins/codecs 8DESTDIR = ../../plugins/codecs
9INCLUDEPATH += $(OPIEDIR)/include .. 9INCLUDEPATH += $(OPIEDIR)/include ..
10DEPENDPATH += ../$(OPIEDIR)/include .. 10DEPENDPATH += ../$(OPIEDIR)/include ..
11TMAKE_CFLAGS += -DFPM_64BIT
12TMAKE_CXXFLAGS += -DFPM_64BIT
11LIBS += -lqpe -lm 13LIBS += -lqpe -lm
12 VERSION = 1.0.0 14VERSION = 1.0.0
diff --git a/core/multimedia/opieplayer/libmad/libmadplugin.h b/core/multimedia/opieplayer/libmad/libmadplugin.h
index 88647ae..ff84c27 100644
--- a/core/multimedia/opieplayer/libmad/libmadplugin.h
+++ b/core/multimedia/opieplayer/libmad/libmadplugin.h
@@ -1,101 +1,111 @@
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 23
24#include <qstring.h> 24#include <qstring.h>
25#include "mediaplayerplugininterface.h" 25//#include <qpe/mediaplayerplugininterface.h>
26#include "../mediaplayerplugininterface.h"
27
28
29// #define OLD_MEDIAPLAYER_API
26 30
27 31
28class LibMadPluginData; 32class LibMadPluginData;
29 33
30 34
31class LibMadPlugin : public MediaPlayerDecoder { 35class LibMadPlugin : public MediaPlayerDecoder {
32 36
33public: 37public:
34 LibMadPlugin(); 38 LibMadPlugin();
35 ~LibMadPlugin(); 39 ~LibMadPlugin();
36 40
37 const char *pluginName() { return "LibMadPlugin"; } 41 const char *pluginName() { return "LibMadPlugin"; }
38 const char *pluginComment() { return "This is the libmad library that has been wrapped as a plugin"; } 42 const char *pluginComment() { return "This is the libmad library that has been wrapped as a plugin"; }
39 double pluginVersion() { return 1.0; } 43 double pluginVersion() { return 1.0; }
40 44
41 bool isFileSupported( const QString& ); 45 bool isFileSupported( const QString& );
42 bool open( const QString& ); 46 bool open( const QString& );
43 bool close(); 47 bool close();
44 bool isOpen(); 48 bool isOpen();
45 const QString &fileInfo() { return info; } 49 const QString &fileInfo() { return info; }
46 50
47 // If decoder doesn't support audio then return 0 here 51 // If decoder doesn't support audio then return 0 here
48 int audioStreams(); 52 int audioStreams();
49 int audioChannels( int stream ); 53 int audioChannels( int stream );
50 int audioFrequency( int stream ); 54 int audioFrequency( int stream );
51 int audioSamples( int stream ); 55 int audioSamples( int stream );
52 bool audioSetSample( long sample, int stream ); 56 bool audioSetSample( long sample, int stream );
57 int audioBitsPerSample(int) {return 0;}
53 long audioGetSample( int stream ); 58 long audioGetSample( int stream );
54// bool audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream ); 59#ifdef OLD_MEDIAPLAYER_API
55// bool audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream ); 60 bool audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream );
61 bool audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream );
62 bool audioReadSamples( short *output, int channel, long samples, int stream );
63 bool audioReReadSamples( short *output, int channel, long samples, int stream );
64#else
56 bool audioReadSamples( short *output, int channels, long samples, long& samplesRead, int stream ); 65 bool audioReadSamples( short *output, int channels, long samples, long& samplesRead, int stream );
57// bool audioReadSamples( short *output, int channel, long samples, int stream ); 66#endif
58// bool audioReReadSamples( short *output, int channel, long samples, int stream );
59 67
60 68
61 bool read(); 69 bool read();
62 bool decode( short *output, long samples, long& samplesRead ); 70 bool decode( short *output, long samples, long& samplesRead );
63 void printID3Tags(); 71 void printID3Tags();
64 72
65 73
66 // If decoder doesn't support video then return 0 here 74 // If decoder doesn't support video then return 0 here
67 int videoStreams() { return 0; } 75 int videoStreams() { return 0; }
68 int videoWidth( int ) { return 0; } 76 int videoWidth( int ) { return 0; }
69 int videoHeight( int ) { return 0; } 77 int videoHeight( int ) { return 0; }
70 double videoFrameRate( int ) { return 0.0; } 78 double videoFrameRate( int ) { return 0.0; }
71 int videoFrames( int ) { return 0; } 79 int videoFrames( int ) { return 0; }
72 bool videoSetFrame( long, int ) { return FALSE; } 80 bool videoSetFrame( long, int ) { return FALSE; }
73 long videoGetFrame( int ) { return 0; } 81 long videoGetFrame( int ) { return 0; }
74 bool videoReadFrame( unsigned char **, int, int, int, int, ColorFormat, int ) { return FALSE; } 82 bool videoReadFrame( unsigned char **, int, int, int, int, ColorFormat, int ) { return FALSE; }
75 bool videoReadScaledFrame( unsigned char **, int, int, int, int, int, int, ColorFormat, int ) { return FALSE; } 83 bool videoReadScaledFrame( unsigned char **, int, int, int, int, int, int, ColorFormat, int ) { return FALSE; }
76 bool videoReadYUVFrame( char *, char *, char *, int, int, int, int, int ) { return FALSE; } 84 bool videoReadYUVFrame( char *, char *, char *, int, int, int, int, int ) { return FALSE; }
77 85
78 // Profiling 86 // Profiling
79 double getTime(); 87 double getTime();
80 88
81 // Ignore if these aren't supported 89 // Ignore if these aren't supported
82 bool setSMP( int ) { return FALSE; } 90 bool setSMP( int ) { return FALSE; }
83 bool setMMX( bool ) { return FALSE; } 91 bool setMMX( bool ) { return FALSE; }
84 92
85 // Capabilities 93 // Capabilities
86 bool supportsAudio() { return TRUE; } 94 bool supportsAudio() { return TRUE; }
87 bool supportsVideo() { return FALSE; } 95 bool supportsVideo() { return FALSE; }
88 bool supportsYUV() { return FALSE; } 96 bool supportsYUV() { return FALSE; }
89 bool supportsMMX() { return TRUE; } 97 bool supportsMMX() { return TRUE; }
90 bool supportsSMP() { return FALSE; } 98 bool supportsSMP() { return FALSE; }
91 bool supportsStereo() { return TRUE; } 99 bool supportsStereo() { return TRUE; }
92 bool supportsScaling() { return FALSE; } 100 bool supportsScaling() { return FALSE; }
93 101
102 long getPlayTime() { return -1; }
103
94private: 104private:
95 LibMadPluginData *d; 105 LibMadPluginData *d;
96 QString info; 106 QString info;
97 107
98}; 108};
99 109
100 110
101#endif 111#endif
diff --git a/core/multimedia/opieplayer/libmad/libmadpluginimpl.h b/core/multimedia/opieplayer/libmad/libmadpluginimpl.h
index a26b421..8ad4956 100644
--- a/core/multimedia/opieplayer/libmad/libmadpluginimpl.h
+++ b/core/multimedia/opieplayer/libmad/libmadpluginimpl.h
@@ -1,53 +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 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
24//#include <qpe/mediaplayerplugininterface.h>
24#include "../mediaplayerplugininterface.h" 25#include "../mediaplayerplugininterface.h"
25 26
26 27
27class LibMadPlugin; 28class LibMadPlugin;
28 29
29 30
30class LibMadPluginImpl : public MediaPlayerPluginInterface 31class LibMadPluginImpl : public MediaPlayerPluginInterface
31{ 32{
32public: 33public:
33 LibMadPluginImpl(); 34 LibMadPluginImpl();
34 virtual ~LibMadPluginImpl(); 35 virtual ~LibMadPluginImpl();
35 36
36#ifndef QT_NO_COMPONENT 37#ifndef QT_NO_COMPONENT
37 38
38 QRESULT queryInterface( const QUuid&, QUnknownInterface** ); 39 QRESULT queryInterface( const QUuid&, QUnknownInterface** );
39 Q_REFCOUNT 40 Q_REFCOUNT
40 41
41#endif 42#endif
42 43
43 virtual MediaPlayerDecoder *decoder(); 44 virtual MediaPlayerDecoder *decoder();
44 virtual MediaPlayerEncoder *encoder(); 45 virtual MediaPlayerEncoder *encoder();
45
46private: 46private:
47 LibMadPlugin *libmadplugin; 47 LibMadPlugin *libmadplugin;
48 ulong ref; 48 ulong ref;
49}; 49};
50 50
51 51
52#endif 52#endif
53 53
diff --git a/core/multimedia/opieplayer/libmad/version.c b/core/multimedia/opieplayer/libmad/version.c
index 413d54b..1baba26 100644
--- a/core/multimedia/opieplayer/libmad/version.c
+++ b/core/multimedia/opieplayer/libmad/version.c
@@ -1,91 +1,91 @@
1/* 1/*
2 * mad - MPEG audio decoder 2 * mad - MPEG audio decoder
3 * Copyright (C) 2000-2001 Robert Leslie 3 * Copyright (C) 2000-2001 Robert Leslie
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or 7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version. 8 * (at your option) any later version.
9 * 9 *
10 * This program is distributed in the hope that it will be useful, 10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License 15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software 16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 * 18 *
19 * $Id$ 19 * $Id$
20 */ 20 */
21 21
22# ifdef HAVE_CONFIG_H 22# ifdef HAVE_CONFIG_H
23# include "libmad_config.h" 23# include "libmad_config.h"
24# endif 24# endif
25 25
26# include "libmad_global.h" 26# include "libmad_global.h"
27 27
28# include "libmad_version.h" 28# include "libmad_version.h"
29 29
30char const mad_version[] = "MPEG Audio Decoder version " MAD_VERSION; 30char const mad_version[] = "MPEG Audio Decoder version " MAD_VERSION;
31char const mad_copyright[] = "Copyright (C) " MAD_PUBLISHYEAR " " MAD_AUTHOR; 31char const mad_copyright[] = "Copyright (C) " MAD_PUBLISHYEAR " " MAD_AUTHOR;
32char const mad_author[] = MAD_AUTHOR " <" MAD_EMAIL ">"; 32char const mad_author[] = MAD_AUTHOR " <" MAD_EMAIL ">";
33 33
34char const mad_build[] = 34char const mad_build[] =
35# if defined(FPM_64BIT) 35# if defined(FPM_64BIT)
36 "FPM_64BIT " 36 "FPM_64BIT "
37# elif defined(FPM_INTEL) 37# elif defined(FPM_INTEL)
38 "FPM_INTEL " 38 "FPM_INTEL "
39# elif defined(FPM_ARM) 39# elif defined(FPM_ARM)
40 "FPM_ARM " 40 "FPM_ARM "
41# elif defined(FPM_MIPS) 41# elif defined(FPM_MIPS)
42 "FPM_MIPS " 42 "FPM_MIPS "
43# elif defined(FPM_SPARC) 43# elif defined(FPM_SPARC)
44 "FPM_SPARC " 44 "FPM_SPARC "
45# elif defined(FPM_PPC) 45# elif defined(FPM_PPC)
46 "FPM_PPC " 46 "FPM_PPC "
47# elif defined(FPM_DEFAULT) 47# elif defined(FPM_DEFAULT)
48 "FPM_DEFAULT " 48 "FPM_DEFAULT "
49# endif 49# endif
50 50
51# if defined(ASO_IMDCT) 51# if defined(ASO_IMDCT)
52 "ASO_IMDCT " 52 "ASO_IMDCT "
53# endif 53# endif
54# if defined(ASO_INTERLEAVE1) 54# if defined(ASO_INTERLEAVE1)
55 "ASO_INTERLEAVE1 " 55 "ASO_INTERLEAVE1 "
56# endif 56# endif
57# if defined(ASO_INTERLEAVE2) 57# if defined(ASO_INTERLEAVE2)
58 "ASO_INTERLEAVE2 " 58 "ASO_INTERLEAVE2 "
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; 91; \ No newline at end of file
diff --git a/core/multimedia/opieplayer/libmpeg3/Makefile.in b/core/multimedia/opieplayer/libmpeg3/Makefile.in
index 154f85d..d255e4f 100644
--- a/core/multimedia/opieplayer/libmpeg3/Makefile.in
+++ b/core/multimedia/opieplayer/libmpeg3/Makefile.in
@@ -1,609 +1,611 @@
1############################################################################# 1#############################################################################
2 2
3####### Compiler, tools and options 3####### Compiler, tools and options
4 4
5 CXX =$(SYSCONF_CXX) $(QT_CXX_MT) 5 CXX =$(SYSCONF_CXX) $(QT_CXX_MT)
6 CXXFLAGS=$(SYSCONF_CXXFLAGS_QT) $(SYSCONF_CXXFLAGS) $(SYSCONF_CXXFLAGS_LIB) 6 CXXFLAGS=$(SYSCONF_CXXFLAGS_QT) $(SYSCONF_CXXFLAGS) $(SYSCONF_CXXFLAGS_LIB)
7 CC =$(SYSCONF_CC) $(QT_C_MT) 7 CC =$(SYSCONF_CC) $(QT_C_MT)
8 CFLAGS =$(SYSCONF_CFLAGS) $(SYSCONF_CFLAGS_LIB) 8 CFLAGS =$(SYSCONF_CFLAGS) $(SYSCONF_CFLAGS_LIB)
9 INCPATH =-I$(OPIEDIR)/include -I.. 9 INCPATH =-I$(OPIEDIR)/include -I..
10 LFLAGS =$(SYSCONF_LFLAGS_QT) $(SYSCONF_RPATH_QT) $(SYSCONF_LFLAGS) $(QT_LFLAGS_MT) 10 LFLAGS =$(SYSCONF_LFLAGS_QT) $(SYSCONF_RPATH_QT) $(SYSCONF_LFLAGS) $(QT_LFLAGS_MT)
11 LIBS =$(SUBLIBS) -lqpe -lpthread -lm $(SYSCONF_LIBS_QT) $(SYSCONF_LIBS_QTAPP) 11 LIBS =$(SUBLIBS) -lqpe -lpthread -lm $(SYSCONF_LIBS_QT) $(SYSCONF_LIBS_QTAPP)
12 MOC =$(SYSCONF_MOC) 12 MOC =$(SYSCONF_MOC)
13 UIC =$(SYSCONF_UIC) 13 UIC =$(SYSCONF_UIC)
14 14
15####### Target 15####### Target
16 16
17DESTDIR = ../../plugins/codecs/ 17DESTDIR = ../../plugins/codecs/
18VER_MAJ = 1 18VER_MAJ = 1
19VER_MIN = 0 19VER_MIN = 0
20VER_PATCH = 0 20VER_PATCH = 0
21 TARGET= mpeg3plugin 21 TARGET= mpeg3plugin
22TARGET1 = lib$(TARGET).so.$(VER_MAJ) 22TARGET1 = lib$(TARGET).so.$(VER_MAJ)
23 23
24####### Files 24####### Files
25 25
26 HEADERS =libmpeg3plugin.h \ 26 HEADERS =libmpeg3plugin.h \
27 libmpeg3pluginimpl.h 27 libmpeg3pluginimpl.h
28 SOURCES =libmpeg3plugin.cpp \ 28 SOURCES =libmpeg3plugin.cpp \
29 libmpeg3pluginimpl.cpp \ 29 libmpeg3pluginimpl.cpp \
30 bitstream.c \ 30 bitstream.c \
31 libmpeg3.c \ 31 libmpeg3.c \
32 mpeg3atrack.c \ 32 mpeg3atrack.c \
33 mpeg3css.c \ 33 mpeg3css.c \
34 mpeg3demux.c \ 34 mpeg3demux.c \
35 mpeg3io.c \ 35 mpeg3io.c \
36 mpeg3title.c \ 36 mpeg3title.c \
37 mpeg3vtrack.c \ 37 mpeg3vtrack.c \
38 audio/ac3.c \ 38 audio/ac3.c \
39 audio/bit_allocation.c \ 39 audio/bit_allocation.c \
40 audio/dct.c \ 40 audio/dct.c \
41 audio/exponents.c \ 41 audio/exponents.c \
42 audio/header.c \ 42 audio/header.c \
43 audio/layer2.c \ 43 audio/layer2.c \
44 audio/layer3.c \ 44 audio/layer3.c \
45 audio/mantissa.c \ 45 audio/mantissa.c \
46 audio/mpeg3audio.c \ 46 audio/mpeg3audio.c \
47 audio/pcm.c \ 47 audio/pcm.c \
48 audio/synthesizers.c \ 48 audio/synthesizers.c \
49 audio/tables.c \ 49 audio/tables.c \
50 video/getpicture.c \ 50 video/getpicture.c \
51 video/headers.c \ 51 video/headers.c \
52 video/idct.c \ 52 video/idct.c \
53 video/macroblocks.c \ 53 video/macroblocks.c \
54 video/mmxtest.c \ 54 video/mmxtest.c \
55 video/motion.c \ 55 video/motion.c \
56 video/mpeg3video.c \ 56 video/mpeg3video.c \
57 video/output.c \ 57 video/output.c \
58 video/reconstruct.c \ 58 video/reconstruct.c \
59 video/seek.c \ 59 video/seek.c \
60 video/slice.c \ 60 video/slice.c \
61 video/vlc.c 61 video/vlc.c
62 OBJECTS =libmpeg3plugin.o \ 62 OBJECTS =libmpeg3plugin.o \
63 libmpeg3pluginimpl.o \ 63 libmpeg3pluginimpl.o \
64 bitstream.o \ 64 bitstream.o \
65 libmpeg3.o \ 65 libmpeg3.o \
66 mpeg3atrack.o \ 66 mpeg3atrack.o \
67 mpeg3css.o \ 67 mpeg3css.o \
68 mpeg3demux.o \ 68 mpeg3demux.o \
69 mpeg3io.o \ 69 mpeg3io.o \
70 mpeg3title.o \ 70 mpeg3title.o \
71 mpeg3vtrack.o \ 71 mpeg3vtrack.o \
72 audio/ac3.o \ 72 audio/ac3.o \
73 audio/bit_allocation.o \ 73 audio/bit_allocation.o \
74 audio/dct.o \ 74 audio/dct.o \
75 audio/exponents.o \ 75 audio/exponents.o \
76 audio/header.o \ 76 audio/header.o \
77 audio/layer2.o \ 77 audio/layer2.o \
78 audio/layer3.o \ 78 audio/layer3.o \
79 audio/mantissa.o \ 79 audio/mantissa.o \
80 audio/mpeg3audio.o \ 80 audio/mpeg3audio.o \
81 audio/pcm.o \ 81 audio/pcm.o \
82 audio/synthesizers.o \ 82 audio/synthesizers.o \
83 audio/tables.o \ 83 audio/tables.o \
84 video/getpicture.o \ 84 video/getpicture.o \
85 video/headers.o \ 85 video/headers.o \
86 video/idct.o \ 86 video/idct.o \
87 video/macroblocks.o \ 87 video/macroblocks.o \
88 video/mmxtest.o \ 88 video/mmxtest.o \
89 video/motion.o \ 89 video/motion.o \
90 video/mpeg3video.o \ 90 video/mpeg3video.o \
91 video/output.o \ 91 video/output.o \
92 video/reconstruct.o \ 92 video/reconstruct.o \
93 video/seek.o \ 93 video/seek.o \
94 video/slice.o \ 94 video/slice.o \
95 video/vlc.o 95 video/vlc.o
96INTERFACES = 96INTERFACES =
97UICDECLS = 97UICDECLS =
98UICIMPLS = 98UICIMPLS =
99 SRCMOC = 99 SRCMOC =
100 OBJMOC = 100 OBJMOC =
101 101
102 102
103####### Implicit rules 103####### Implicit rules
104 104
105.SUFFIXES: .cpp .cxx .cc .C .c 105.SUFFIXES: .cpp .cxx .cc .C .c
106 106
107.cpp.o: 107.cpp.o:
108 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< 108 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
109 109
110.cxx.o: 110.cxx.o:
111 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< 111 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
112 112
113.cc.o: 113.cc.o:
114 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< 114 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
115 115
116.C.o: 116.C.o:
117 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< 117 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
118 118
119.c.o: 119.c.o:
120 $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $< 120 $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $<
121 121
122####### Build rules 122####### Build rules
123 123
124 124
125all: $(DESTDIR)$(SYSCONF_LINK_TARGET) 125all: $(DESTDIR)$(SYSCONF_LINK_TARGET)
126 126
127$(DESTDIR)$(SYSCONF_LINK_TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) $(SUBLIBS) 127$(DESTDIR)$(SYSCONF_LINK_TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) $(SUBLIBS)
128 $(SYSCONF_LINK_LIB) 128 $(SYSCONF_LINK_LIB)
129 129
130moc: $(SRCMOC) 130moc: $(SRCMOC)
131 131
132tmake: 132tmake:
133 tmake libmpeg3.pro 133 tmake libmpeg3.pro
134 134
135clean: 135clean:
136 -rm -f $(OBJECTS) $(OBJMOC) $(SRCMOC) $(UICIMPLS) $(UICDECLS) 136 -rm -f $(OBJECTS) $(OBJMOC) $(SRCMOC) $(UICIMPLS) $(UICDECLS)
137 -rm -f *~ core 137 -rm -f *~ core
138 -rm -f allmoc.cpp 138 -rm -f allmoc.cpp
139 139
140####### Extension Modules 140####### Extension Modules
141 141
142listpromodules: 142listpromodules:
143 @echo 143 @echo
144 144
145listallmodules: 145listallmodules:
146 @echo 146 @echo
147 147
148listaddonpromodules: 148listaddonpromodules:
149 @echo 149 @echo
150 150
151listaddonentmodules: 151listaddonentmodules:
152 @echo 152 @echo
153 153
154 154
155REQUIRES= 155REQUIRES=
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
166libmpeg3plugin.o: libmpeg3plugin.cpp \ 166libmpeg3plugin.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
180 181
181libmpeg3pluginimpl.o: libmpeg3pluginimpl.cpp \ 182libmpeg3pluginimpl.o: libmpeg3pluginimpl.cpp \
182 libmpeg3plugin.h \ 183 libmpeg3plugin.h \
183 libmpeg3.h \ 184 libmpeg3.h \
184 mpeg3private.h \ 185 mpeg3private.h \
185 mpeg3atrack.h \ 186 mpeg3atrack.h \
186 mpeg3demux.h \ 187 mpeg3demux.h \
187 mpeg3title.h \ 188 mpeg3title.h \
188 mpeg3io.h \ 189 mpeg3io.h \
189 mpeg3css.h \ 190 mpeg3css.h \
190 mpeg3private.inc \ 191 mpeg3private.inc \
191 audio/mpeg3audio.h \ 192 audio/mpeg3audio.h \
192 mpeg3vtrack.h \ 193 mpeg3vtrack.h \
193 video/mpeg3video.h \ 194 video/mpeg3video.h \
194 mpeg3protos.h \ 195 mpeg3protos.h \
196 ../mediaplayerplugininterface.h \
195 libmpeg3pluginimpl.h 197 libmpeg3pluginimpl.h
196 198
197bitstream.o: bitstream.c \ 199bitstream.o: bitstream.c \
198 mpeg3private.h \ 200 mpeg3private.h \
199 mpeg3atrack.h \ 201 mpeg3atrack.h \
200 mpeg3demux.h \ 202 mpeg3demux.h \
201 mpeg3title.h \ 203 mpeg3title.h \
202 mpeg3io.h \ 204 mpeg3io.h \
203 mpeg3css.h \ 205 mpeg3css.h \
204 mpeg3private.inc \ 206 mpeg3private.inc \
205 audio/mpeg3audio.h \ 207 audio/mpeg3audio.h \
206 mpeg3vtrack.h \ 208 mpeg3vtrack.h \
207 video/mpeg3video.h \ 209 video/mpeg3video.h \
208 mpeg3protos.h 210 mpeg3protos.h
209 211
210libmpeg3.o: libmpeg3.c \ 212libmpeg3.o: libmpeg3.c \
211 libmpeg3.h \ 213 libmpeg3.h \
212 mpeg3private.h \ 214 mpeg3private.h \
213 mpeg3atrack.h \ 215 mpeg3atrack.h \
214 mpeg3demux.h \ 216 mpeg3demux.h \
215 mpeg3title.h \ 217 mpeg3title.h \
216 mpeg3io.h \ 218 mpeg3io.h \
217 mpeg3css.h \ 219 mpeg3css.h \
218 mpeg3private.inc \ 220 mpeg3private.inc \
219 audio/mpeg3audio.h \ 221 audio/mpeg3audio.h \
220 mpeg3vtrack.h \ 222 mpeg3vtrack.h \
221 video/mpeg3video.h \ 223 video/mpeg3video.h \
222 mpeg3protos.h 224 mpeg3protos.h
223 225
224mpeg3atrack.o: mpeg3atrack.c \ 226mpeg3atrack.o: mpeg3atrack.c \
225 libmpeg3.h \ 227 libmpeg3.h \
226 mpeg3private.h \ 228 mpeg3private.h \
227 mpeg3atrack.h \ 229 mpeg3atrack.h \
228 mpeg3demux.h \ 230 mpeg3demux.h \
229 mpeg3title.h \ 231 mpeg3title.h \
230 mpeg3io.h \ 232 mpeg3io.h \
231 mpeg3css.h \ 233 mpeg3css.h \
232 mpeg3private.inc \ 234 mpeg3private.inc \
233 audio/mpeg3audio.h \ 235 audio/mpeg3audio.h \
234 mpeg3vtrack.h \ 236 mpeg3vtrack.h \
235 video/mpeg3video.h \ 237 video/mpeg3video.h \
236 mpeg3protos.h 238 mpeg3protos.h
237 239
238mpeg3css.o: mpeg3css.c \ 240mpeg3css.o: mpeg3css.c \
239 mpeg3css.h \ 241 mpeg3css.h \
240 mpeg3private.h \ 242 mpeg3private.h \
241 mpeg3atrack.h \ 243 mpeg3atrack.h \
242 mpeg3demux.h \ 244 mpeg3demux.h \
243 mpeg3title.h \ 245 mpeg3title.h \
244 mpeg3io.h \ 246 mpeg3io.h \
245 mpeg3private.inc \ 247 mpeg3private.inc \
246 audio/mpeg3audio.h \ 248 audio/mpeg3audio.h \
247 mpeg3vtrack.h \ 249 mpeg3vtrack.h \
248 video/mpeg3video.h 250 video/mpeg3video.h
249 251
250mpeg3demux.o: mpeg3demux.c \ 252mpeg3demux.o: mpeg3demux.c \
251 libmpeg3.h \ 253 libmpeg3.h \
252 mpeg3private.h \ 254 mpeg3private.h \
253 mpeg3atrack.h \ 255 mpeg3atrack.h \
254 mpeg3demux.h \ 256 mpeg3demux.h \
255 mpeg3title.h \ 257 mpeg3title.h \
256 mpeg3io.h \ 258 mpeg3io.h \
257 mpeg3css.h \ 259 mpeg3css.h \
258 mpeg3private.inc \ 260 mpeg3private.inc \
259 audio/mpeg3audio.h \ 261 audio/mpeg3audio.h \
260 mpeg3vtrack.h \ 262 mpeg3vtrack.h \
261 video/mpeg3video.h \ 263 video/mpeg3video.h \
262 mpeg3protos.h 264 mpeg3protos.h
263 265
264mpeg3io.o: mpeg3io.c \ 266mpeg3io.o: mpeg3io.c \
265 mpeg3private.h \ 267 mpeg3private.h \
266 mpeg3atrack.h \ 268 mpeg3atrack.h \
267 mpeg3demux.h \ 269 mpeg3demux.h \
268 mpeg3title.h \ 270 mpeg3title.h \
269 mpeg3io.h \ 271 mpeg3io.h \
270 mpeg3css.h \ 272 mpeg3css.h \
271 mpeg3private.inc \ 273 mpeg3private.inc \
272 audio/mpeg3audio.h \ 274 audio/mpeg3audio.h \
273 mpeg3vtrack.h \ 275 mpeg3vtrack.h \
274 video/mpeg3video.h \ 276 video/mpeg3video.h \
275 mpeg3protos.h 277 mpeg3protos.h
276 278
277mpeg3title.o: mpeg3title.c \ 279mpeg3title.o: mpeg3title.c \
278 mpeg3private.h \ 280 mpeg3private.h \
279 mpeg3atrack.h \ 281 mpeg3atrack.h \
280 mpeg3demux.h \ 282 mpeg3demux.h \
281 mpeg3title.h \ 283 mpeg3title.h \
282 mpeg3io.h \ 284 mpeg3io.h \
283 mpeg3css.h \ 285 mpeg3css.h \
284 mpeg3private.inc \ 286 mpeg3private.inc \
285 audio/mpeg3audio.h \ 287 audio/mpeg3audio.h \
286 mpeg3vtrack.h \ 288 mpeg3vtrack.h \
287 video/mpeg3video.h \ 289 video/mpeg3video.h \
288 mpeg3protos.h 290 mpeg3protos.h
289 291
290mpeg3vtrack.o: mpeg3vtrack.c \ 292mpeg3vtrack.o: mpeg3vtrack.c \
291 libmpeg3.h \ 293 libmpeg3.h \
292 mpeg3private.h \ 294 mpeg3private.h \
293 mpeg3atrack.h \ 295 mpeg3atrack.h \
294 mpeg3demux.h \ 296 mpeg3demux.h \
295 mpeg3title.h \ 297 mpeg3title.h \
296 mpeg3io.h \ 298 mpeg3io.h \
297 mpeg3css.h \ 299 mpeg3css.h \
298 mpeg3private.inc \ 300 mpeg3private.inc \
299 audio/mpeg3audio.h \ 301 audio/mpeg3audio.h \
300 mpeg3vtrack.h \ 302 mpeg3vtrack.h \
301 video/mpeg3video.h \ 303 video/mpeg3video.h \
302 mpeg3protos.h 304 mpeg3protos.h
303 305
304audio/ac3.o: audio/ac3.c \ 306audio/ac3.o: audio/ac3.c \
305 audio/mpeg3audio.h \ 307 audio/mpeg3audio.h \
306 audio/ac3.h \ 308 audio/ac3.h \
307 audio/mpeg3real.h \ 309 audio/mpeg3real.h \
308 audio/../bitstream.h \ 310 audio/../bitstream.h \
309 mpeg3demux.h \ 311 mpeg3demux.h \
310 mpeg3title.h \ 312 mpeg3title.h \
311 mpeg3io.h \ 313 mpeg3io.h \
312 mpeg3css.h \ 314 mpeg3css.h \
313 mpeg3private.inc \ 315 mpeg3private.inc \
314 audio/../libmpeg3.h \ 316 audio/../libmpeg3.h \
315 mpeg3private.h \ 317 mpeg3private.h \
316 mpeg3atrack.h \ 318 mpeg3atrack.h \
317 audio/mpeg3audio.h \ 319 audio/mpeg3audio.h \
318 mpeg3vtrack.h \ 320 mpeg3vtrack.h \
319 video/mpeg3video.h \ 321 video/mpeg3video.h \
320 audio/../mpeg3protos.h 322 audio/../mpeg3protos.h
321 323
322audio/bit_allocation.o: audio/bit_allocation.c \ 324audio/bit_allocation.o: audio/bit_allocation.c \
323 audio/mpeg3audio.h \ 325 audio/mpeg3audio.h \
324 audio/ac3.h \ 326 audio/ac3.h \
325 audio/mpeg3real.h \ 327 audio/mpeg3real.h \
326 audio/../bitstream.h \ 328 audio/../bitstream.h \
327 mpeg3demux.h \ 329 mpeg3demux.h \
328 mpeg3title.h \ 330 mpeg3title.h \
329 mpeg3io.h \ 331 mpeg3io.h \
330 mpeg3css.h \ 332 mpeg3css.h \
331 mpeg3private.inc \ 333 mpeg3private.inc \
332 audio/../libmpeg3.h \ 334 audio/../libmpeg3.h \
333 mpeg3private.h \ 335 mpeg3private.h \
334 mpeg3atrack.h \ 336 mpeg3atrack.h \
335 audio/mpeg3audio.h \ 337 audio/mpeg3audio.h \
336 mpeg3vtrack.h \ 338 mpeg3vtrack.h \
337 video/mpeg3video.h \ 339 video/mpeg3video.h \
338 audio/../mpeg3protos.h 340 audio/../mpeg3protos.h
339 341
340audio/dct.o: audio/dct.c \ 342audio/dct.o: audio/dct.c \
341 audio/mpeg3audio.h \ 343 audio/mpeg3audio.h \
342 audio/ac3.h \ 344 audio/ac3.h \
343 audio/mpeg3real.h \ 345 audio/mpeg3real.h \
344 audio/../bitstream.h \ 346 audio/../bitstream.h \
345 mpeg3demux.h \ 347 mpeg3demux.h \
346 mpeg3title.h \ 348 mpeg3title.h \
347 mpeg3io.h \ 349 mpeg3io.h \
348 mpeg3css.h \ 350 mpeg3css.h \
349 mpeg3private.inc \ 351 mpeg3private.inc \
350 audio/../libmpeg3.h \ 352 audio/../libmpeg3.h \
351 mpeg3private.h \ 353 mpeg3private.h \
352 mpeg3atrack.h \ 354 mpeg3atrack.h \
353 audio/mpeg3audio.h \ 355 audio/mpeg3audio.h \
354 mpeg3vtrack.h \ 356 mpeg3vtrack.h \
355 video/mpeg3video.h \ 357 video/mpeg3video.h \
356 audio/../mpeg3protos.h \ 358 audio/../mpeg3protos.h \
357 audio/tables.h \ 359 audio/tables.h \
358 audio/fptables.h 360 audio/fptables.h
359 361
360audio/exponents.o: audio/exponents.c \ 362audio/exponents.o: audio/exponents.c \
361 audio/mpeg3audio.h \ 363 audio/mpeg3audio.h \
362 audio/ac3.h \ 364 audio/ac3.h \
363 audio/mpeg3real.h \ 365 audio/mpeg3real.h \
364 audio/../bitstream.h \ 366 audio/../bitstream.h \
365 mpeg3demux.h \ 367 mpeg3demux.h \
366 mpeg3title.h \ 368 mpeg3title.h \
367 mpeg3io.h \ 369 mpeg3io.h \
368 mpeg3css.h \ 370 mpeg3css.h \
369 mpeg3private.inc \ 371 mpeg3private.inc \
370 audio/../libmpeg3.h \ 372 audio/../libmpeg3.h \
371 mpeg3private.h \ 373 mpeg3private.h \
372 mpeg3atrack.h \ 374 mpeg3atrack.h \
373 audio/mpeg3audio.h \ 375 audio/mpeg3audio.h \
374 mpeg3vtrack.h \ 376 mpeg3vtrack.h \
375 video/mpeg3video.h \ 377 video/mpeg3video.h \
376 audio/../mpeg3protos.h 378 audio/../mpeg3protos.h
377 379
378audio/header.o: audio/header.c \ 380audio/header.o: audio/header.c \
379 audio/mpeg3audio.h \ 381 audio/mpeg3audio.h \
380 audio/ac3.h \ 382 audio/ac3.h \
381 audio/mpeg3real.h \ 383 audio/mpeg3real.h \
382 audio/../bitstream.h \ 384 audio/../bitstream.h \
383 mpeg3demux.h \ 385 mpeg3demux.h \
384 mpeg3title.h \ 386 mpeg3title.h \
385 mpeg3io.h \ 387 mpeg3io.h \
386 mpeg3css.h \ 388 mpeg3css.h \
387 mpeg3private.inc \ 389 mpeg3private.inc \
388 audio/tables.h \ 390 audio/tables.h \
389 audio/../libmpeg3.h \ 391 audio/../libmpeg3.h \
390 mpeg3private.h \ 392 mpeg3private.h \
391 mpeg3atrack.h \ 393 mpeg3atrack.h \
392 audio/mpeg3audio.h \ 394 audio/mpeg3audio.h \
393 mpeg3vtrack.h \ 395 mpeg3vtrack.h \
394 video/mpeg3video.h \ 396 video/mpeg3video.h \
395 audio/../mpeg3protos.h 397 audio/../mpeg3protos.h
396 398
397audio/layer2.o: audio/layer2.c \ 399audio/layer2.o: audio/layer2.c \
398 audio/mpeg3audio.h \ 400 audio/mpeg3audio.h \
399 audio/ac3.h \ 401 audio/ac3.h \
400 audio/mpeg3real.h \ 402 audio/mpeg3real.h \
401 audio/../bitstream.h \ 403 audio/../bitstream.h \
402 mpeg3demux.h \ 404 mpeg3demux.h \
403 mpeg3title.h \ 405 mpeg3title.h \
404 mpeg3io.h \ 406 mpeg3io.h \
405 mpeg3css.h \ 407 mpeg3css.h \
406 mpeg3private.inc \ 408 mpeg3private.inc \
407 audio/../libmpeg3.h \ 409 audio/../libmpeg3.h \
408 mpeg3private.h \ 410 mpeg3private.h \
409 mpeg3atrack.h \ 411 mpeg3atrack.h \
410 audio/mpeg3audio.h \ 412 audio/mpeg3audio.h \
411 mpeg3vtrack.h \ 413 mpeg3vtrack.h \
412 video/mpeg3video.h \ 414 video/mpeg3video.h \
413 audio/../mpeg3protos.h \ 415 audio/../mpeg3protos.h \
414 audio/tables.h 416 audio/tables.h
415 417
416audio/layer3.o: audio/layer3.c \ 418audio/layer3.o: audio/layer3.c \
417 audio/huffman.h \ 419 huffman.h \
418 audio/mpeg3audio.h \ 420 audio/mpeg3audio.h \
419 audio/ac3.h \ 421 audio/ac3.h \
420 audio/mpeg3real.h \ 422 audio/mpeg3real.h \
421 audio/../bitstream.h \ 423 audio/../bitstream.h \
422 mpeg3demux.h \ 424 mpeg3demux.h \
423 mpeg3title.h \ 425 mpeg3title.h \
424 mpeg3io.h \ 426 mpeg3io.h \
425 mpeg3css.h \ 427 mpeg3css.h \
426 mpeg3private.inc \ 428 mpeg3private.inc \
427 audio/../libmpeg3.h \ 429 audio/../libmpeg3.h \
428 mpeg3private.h \ 430 mpeg3private.h \
429 mpeg3atrack.h \ 431 mpeg3atrack.h \
430 audio/mpeg3audio.h \ 432 audio/mpeg3audio.h \
431 mpeg3vtrack.h \ 433 mpeg3vtrack.h \
432 video/mpeg3video.h \ 434 video/mpeg3video.h \
433 audio/../mpeg3protos.h \ 435 audio/../mpeg3protos.h \
434 audio/tables.h 436 audio/tables.h
435 437
436audio/mantissa.o: audio/mantissa.c \ 438audio/mantissa.o: audio/mantissa.c \
437 audio/mpeg3audio.h \ 439 audio/mpeg3audio.h \
438 audio/ac3.h \ 440 audio/ac3.h \
439 audio/mpeg3real.h \ 441 audio/mpeg3real.h \
440 audio/../bitstream.h \ 442 audio/../bitstream.h \
441 mpeg3demux.h \ 443 mpeg3demux.h \
442 mpeg3title.h \ 444 mpeg3title.h \
443 mpeg3io.h \ 445 mpeg3io.h \
444 mpeg3css.h \ 446 mpeg3css.h \
445 mpeg3private.inc \ 447 mpeg3private.inc \
446 audio/../libmpeg3.h \ 448 audio/../libmpeg3.h \
447 mpeg3private.h \ 449 mpeg3private.h \
448 mpeg3atrack.h \ 450 mpeg3atrack.h \
449 audio/mpeg3audio.h \ 451 audio/mpeg3audio.h \
450 mpeg3vtrack.h \ 452 mpeg3vtrack.h \
451 video/mpeg3video.h \ 453 video/mpeg3video.h \
452 audio/../mpeg3protos.h 454 audio/../mpeg3protos.h
453 455
454audio/mpeg3audio.o: audio/mpeg3audio.c \ 456audio/mpeg3audio.o: audio/mpeg3audio.c \
455 audio/../libmpeg3.h \ 457 audio/../libmpeg3.h \
456 mpeg3private.h \ 458 mpeg3private.h \
457 mpeg3atrack.h \ 459 mpeg3atrack.h \
458 mpeg3demux.h \ 460 mpeg3demux.h \
459 mpeg3title.h \ 461 mpeg3title.h \
460 mpeg3io.h \ 462 mpeg3io.h \
461 mpeg3css.h \ 463 mpeg3css.h \
462 mpeg3private.inc \ 464 mpeg3private.inc \
463 audio/mpeg3audio.h \ 465 audio/mpeg3audio.h \
464 audio/ac3.h \ 466 audio/ac3.h \
465 audio/mpeg3real.h \ 467 audio/mpeg3real.h \
466 audio/../bitstream.h \ 468 audio/../bitstream.h \
467 mpeg3vtrack.h \ 469 mpeg3vtrack.h \
468 video/mpeg3video.h \ 470 video/mpeg3video.h \
469 audio/../mpeg3protos.h \ 471 audio/../mpeg3protos.h \
470 audio/mpeg3audio.h \ 472 audio/mpeg3audio.h \
471 audio/tables.h 473 audio/tables.h
472 474
473audio/pcm.o: audio/pcm.c \ 475audio/pcm.o: audio/pcm.c \
474 audio/mpeg3audio.h \ 476 audio/mpeg3audio.h \
475 audio/ac3.h \ 477 audio/ac3.h \
476 audio/mpeg3real.h \ 478 audio/mpeg3real.h \
477 audio/../bitstream.h \ 479 audio/../bitstream.h \
478 mpeg3demux.h \ 480 mpeg3demux.h \
479 mpeg3title.h \ 481 mpeg3title.h \
480 mpeg3io.h \ 482 mpeg3io.h \
481 mpeg3css.h \ 483 mpeg3css.h \
482 mpeg3private.inc \ 484 mpeg3private.inc \
483 audio/../libmpeg3.h \ 485 audio/../libmpeg3.h \
484 mpeg3private.h \ 486 mpeg3private.h \
485 mpeg3atrack.h \ 487 mpeg3atrack.h \
486 audio/mpeg3audio.h \ 488 audio/mpeg3audio.h \
487 mpeg3vtrack.h \ 489 mpeg3vtrack.h \
488 video/mpeg3video.h \ 490 video/mpeg3video.h \
489 audio/../mpeg3protos.h 491 audio/../mpeg3protos.h
490 492
491audio/synthesizers.o: audio/synthesizers.c \ 493audio/synthesizers.o: audio/synthesizers.c \
492 audio/mpeg3audio.h \ 494 audio/mpeg3audio.h \
493 audio/ac3.h \ 495 audio/ac3.h \
494 audio/mpeg3real.h \ 496 audio/mpeg3real.h \
495 audio/../bitstream.h \ 497 audio/../bitstream.h \
496 mpeg3demux.h \ 498 mpeg3demux.h \
497 mpeg3title.h \ 499 mpeg3title.h \
498 mpeg3io.h \ 500 mpeg3io.h \
499 mpeg3css.h \ 501 mpeg3css.h \
500 mpeg3private.inc \ 502 mpeg3private.inc \
501 audio/../libmpeg3.h \ 503 audio/../libmpeg3.h \
502 mpeg3private.h \ 504 mpeg3private.h \
503 mpeg3atrack.h \ 505 mpeg3atrack.h \
504 audio/mpeg3audio.h \ 506 audio/mpeg3audio.h \
505 mpeg3vtrack.h \ 507 mpeg3vtrack.h \
506 video/mpeg3video.h \ 508 video/mpeg3video.h \
507 audio/../mpeg3protos.h \ 509 audio/../mpeg3protos.h \
508 audio/tables.h 510 audio/tables.h
509 511
510audio/tables.o: audio/tables.c \ 512audio/tables.o: audio/tables.c \
511 audio/mpeg3audio.h \ 513 audio/mpeg3audio.h \
512 audio/ac3.h \ 514 audio/ac3.h \
513 audio/mpeg3real.h \ 515 audio/mpeg3real.h \
514 audio/../bitstream.h \ 516 audio/../bitstream.h \
515 mpeg3demux.h \ 517 mpeg3demux.h \
516 mpeg3title.h \ 518 mpeg3title.h \
517 mpeg3io.h \ 519 mpeg3io.h \
518 mpeg3css.h \ 520 mpeg3css.h \
519 mpeg3private.inc \ 521 mpeg3private.inc \
520 audio/../libmpeg3.h \ 522 audio/../libmpeg3.h \
521 mpeg3private.h \ 523 mpeg3private.h \
522 mpeg3atrack.h \ 524 mpeg3atrack.h \
523 audio/mpeg3audio.h \ 525 audio/mpeg3audio.h \
524 mpeg3vtrack.h \ 526 mpeg3vtrack.h \
525 video/mpeg3video.h \ 527 video/mpeg3video.h \
526 audio/../mpeg3protos.h \ 528 audio/../mpeg3protos.h \
527 audio/tables.h \ 529 audio/tables.h \
528 audio/fptables.h 530 audio/fptables.h
529 531
530video/getpicture.o: video/getpicture.c \ 532video/getpicture.o: video/getpicture.c \
531 audio/../libmpeg3.h \ 533 audio/../libmpeg3.h \
532 mpeg3private.h \ 534 mpeg3private.h \
533 mpeg3atrack.h \ 535 mpeg3atrack.h \
534 mpeg3demux.h \ 536 mpeg3demux.h \
535 mpeg3title.h \ 537 mpeg3title.h \
536 mpeg3io.h \ 538 mpeg3io.h \
537 mpeg3css.h \ 539 mpeg3css.h \
538 mpeg3private.inc \ 540 mpeg3private.inc \
539 audio/mpeg3audio.h \ 541 audio/mpeg3audio.h \
540 audio/ac3.h \ 542 audio/ac3.h \
541 audio/mpeg3real.h \ 543 audio/mpeg3real.h \
542 audio/../bitstream.h \ 544 audio/../bitstream.h \
543 mpeg3vtrack.h \ 545 mpeg3vtrack.h \
544 video/mpeg3video.h \ 546 video/mpeg3video.h \
545 video/../mpeg3private.inc \ 547 video/../mpeg3private.inc \
546 video/idct.h \ 548 video/idct.h \
547 video/slice.h \ 549 video/slice.h \
548 video/../timecode.h \ 550 video/../timecode.h \
549 video/../mpeg3protos.h \ 551 video/../mpeg3protos.h \
550 video/mpeg3video.h \ 552 video/mpeg3video.h \
551 video/vlc.h 553 video/vlc.h
552 554
553video/headers.o: video/headers.c \ 555video/headers.o: video/headers.c \
554 video/../mpeg3demux.h \ 556 video/../mpeg3demux.h \
555 mpeg3title.h \ 557 mpeg3title.h \
556 mpeg3io.h \ 558 mpeg3io.h \
557 mpeg3css.h \ 559 mpeg3css.h \
558 mpeg3private.inc \ 560 mpeg3private.inc \
559 audio/../libmpeg3.h \ 561 audio/../libmpeg3.h \
560 mpeg3private.h \ 562 mpeg3private.h \
561 mpeg3atrack.h \ 563 mpeg3atrack.h \
562 mpeg3demux.h \ 564 mpeg3demux.h \
563 audio/mpeg3audio.h \ 565 audio/mpeg3audio.h \
564 audio/ac3.h \ 566 audio/ac3.h \
565 audio/mpeg3real.h \ 567 audio/mpeg3real.h \
566 audio/../bitstream.h \ 568 audio/../bitstream.h \
567 mpeg3vtrack.h \ 569 mpeg3vtrack.h \
568 video/mpeg3video.h \ 570 video/mpeg3video.h \
569 video/../mpeg3private.inc \ 571 video/../mpeg3private.inc \
570 video/idct.h \ 572 video/idct.h \
571 video/slice.h \ 573 video/slice.h \
572 video/../timecode.h \ 574 video/../timecode.h \
573 video/../mpeg3protos.h \ 575 video/../mpeg3protos.h \
574 video/mpeg3video.h 576 video/mpeg3video.h
575 577
576video/idct.o: video/idct.c \ 578video/idct.o: video/idct.c \
577 video/idct.h 579 video/idct.h
578 580
579video/macroblocks.o: video/macroblocks.c \ 581video/macroblocks.o: video/macroblocks.c \
580 audio/../libmpeg3.h \ 582 audio/../libmpeg3.h \
581 mpeg3private.h \ 583 mpeg3private.h \
582 mpeg3atrack.h \ 584 mpeg3atrack.h \
583 mpeg3demux.h \ 585 mpeg3demux.h \
584 mpeg3title.h \ 586 mpeg3title.h \
585 mpeg3io.h \ 587 mpeg3io.h \
586 mpeg3css.h \ 588 mpeg3css.h \
587 mpeg3private.inc \ 589 mpeg3private.inc \
588 audio/mpeg3audio.h \ 590 audio/mpeg3audio.h \
589 audio/ac3.h \ 591 audio/ac3.h \
590 audio/mpeg3real.h \ 592 audio/mpeg3real.h \
591 audio/../bitstream.h \ 593 audio/../bitstream.h \
592 mpeg3vtrack.h \ 594 mpeg3vtrack.h \
593 video/mpeg3video.h \ 595 video/mpeg3video.h \
594 video/../mpeg3private.inc \ 596 video/../mpeg3private.inc \
595 video/idct.h \ 597 video/idct.h \
596 video/slice.h \ 598 video/slice.h \
597 video/../timecode.h \ 599 video/../timecode.h \
598 video/../mpeg3protos.h \ 600 video/../mpeg3protos.h \
599 video/mpeg3video.h \ 601 video/mpeg3video.h \
600 video/vlc.h 602 video/vlc.h
601 603
602video/mmxtest.o: video/mmxtest.c \ 604video/mmxtest.o: video/mmxtest.c \
603 audio/../libmpeg3.h \ 605 audio/../libmpeg3.h \
604 mpeg3private.h \ 606 mpeg3private.h \
605 mpeg3atrack.h \ 607 mpeg3atrack.h \
606 mpeg3demux.h \ 608 mpeg3demux.h \
607 mpeg3title.h \ 609 mpeg3title.h \
608 mpeg3io.h \ 610 mpeg3io.h \
609 mpeg3css.h \ 611 mpeg3css.h \
diff --git a/core/multimedia/opieplayer/libmpeg3/libmpeg3plugin.h b/core/multimedia/opieplayer/libmpeg3/libmpeg3plugin.h
index 0a06264..54f259b 100644
--- a/core/multimedia/opieplayer/libmpeg3/libmpeg3plugin.h
+++ b/core/multimedia/opieplayer/libmpeg3/libmpeg3plugin.h
@@ -1,113 +1,123 @@
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 23
24#include <qstring.h> 24#include <qstring.h>
25#include <qapplication.h> 25#include <qapplication.h>
26#include "libmpeg3.h" 26#include "libmpeg3.h"
27#include "mpeg3protos.h" 27#include "mpeg3protos.h"
28#include "mediaplayerplugininterface.h" 28//#include <qpe/mediaplayerplugininterface.h>
29#include "../mediaplayerplugininterface.h"
30
31
32// #define OLD_MEDIAPLAYER_API
29 33
30 34
31class LibMpeg3Plugin : public MediaPlayerDecoder { 35class LibMpeg3Plugin : public MediaPlayerDecoder {
32 36
33public: 37public:
34 LibMpeg3Plugin() { file = NULL; } 38 LibMpeg3Plugin() { file = NULL; }
35 ~LibMpeg3Plugin() { close(); } 39 ~LibMpeg3Plugin() { close(); }
36 40
37 const char *pluginName() { return "LibMpeg3Plugin"; } 41 const char *pluginName() { return "LibMpeg3Plugin"; }
38 const char *pluginComment() { return "This is the libmpeg3 library writen by ... which has been modified by trolltech to use fixed point maths"; } 42 const char *pluginComment() { return "This is the libmpeg3 library writen by ... which has been modified by trolltech to use fixed point maths"; }
39 double pluginVersion() { return 1.0; } 43 double pluginVersion() { return 1.0; }
40 44
41 bool isFileSupported( const QString& fileName ) { return mpeg3_check_sig( (char *)fileName.latin1() ) == 1; } 45 bool isFileSupported( const QString& fileName ) { return mpeg3_check_sig( (char *)fileName.latin1() ) == 1; }
42 bool open( const QString& fileName ) { file = mpeg3_open( (char *)fileName.latin1() ); return file != NULL; } 46 bool open( const QString& fileName ) { file = mpeg3_open( (char *)fileName.latin1() ); return file != NULL; }
43 bool close() { if ( file ) { int r = mpeg3_close( file ); file = NULL; return r == 1; } return FALSE; } 47 bool close() { if ( file ) { int r = mpeg3_close( file ); file = NULL; return r == 1; } return FALSE; }
44 bool isOpen() { return file != NULL; } 48 bool isOpen() { return file != NULL; }
45 const QString &fileInfo() { return strInfo = QString( "" ); } 49 const QString &fileInfo() { return strInfo = ""; }
46 50
47 // If decoder doesn't support audio then return 0 here 51 // If decoder doesn't support audio then return 0 here
48 int audioStreams() { return file ? mpeg3_total_astreams( file ) : 0; } 52 int audioStreams() { return file ? mpeg3_total_astreams( file ) : 0; }
49 int audioChannels( int stream ) { return file ? mpeg3_audio_channels( file, stream ) : 0; } 53 int audioChannels( int stream ) { return file ? mpeg3_audio_channels( file, stream ) : 0; }
50 int audioFrequency( int stream ) { return file ? mpeg3_sample_rate( file, stream ) : 0; } 54 int audioFrequency( int stream ) { return file ? mpeg3_sample_rate( file, stream ) : 0; }
55 int audioBitsPerSample(int) { return 0;}
51 int audioSamples( int stream ) { return file ? mpeg3_audio_samples( file, stream ) : 0; } 56 int audioSamples( int stream ) { return file ? mpeg3_audio_samples( file, stream ) : 0; }
52 bool audioSetSample( long sample, int stream ) { return file ? mpeg3_set_sample( file, sample, stream) == 1 : FALSE; } 57 bool audioSetSample( long sample, int stream ) { return file ? mpeg3_set_sample( file, sample, stream) == 1 : FALSE; }
53 long audioGetSample( int stream ) { return file ? mpeg3_get_sample( file, stream ) : 0; } 58 long audioGetSample( int stream ) { return file ? mpeg3_get_sample( file, stream ) : 0; }
54// bool audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream ); 59#ifdef OLD_MEDIAPLAYER_API
55// bool audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream ); 60 bool audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream );
61 bool audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream );
62 bool audioReadSamples( short *output, int channel, long samples, int stream );
63 bool audioReReadSamples( short *output, int channel, long samples, int stream );
64#else
56 bool audioReadSamples( short *output, int channels, long samples, long& samplesRead, int stream ); 65 bool audioReadSamples( short *output, int channels, long samples, long& samplesRead, int stream );
57// bool audioReadSamples( short *output, int channel, long samples, int stream ); 66#endif
58// bool audioReReadSamples( short *output, int channel, long samples, int stream );
59 67
60 // If decoder doesn't support video then return 0 here 68 // If decoder doesn't support video then return 0 here
61 int videoStreams() { return file ? mpeg3_total_vstreams( file ) : 0; } 69 int videoStreams() { return file ? mpeg3_total_vstreams( file ) : 0; }
62 int videoWidth( int stream ) { return file ? mpeg3_video_width( file, stream ) : 0; } 70 int videoWidth( int stream ) { return file ? mpeg3_video_width( file, stream ) : 0; }
63 int videoHeight( int stream ) { return file ? mpeg3_video_height( file, stream ) : 0; } 71 int videoHeight( int stream ) { return file ? mpeg3_video_height( file, stream ) : 0; }
64 double videoFrameRate( int stream ) { return file ? mpeg3_frame_rate( file, stream ) : 0.0; } 72 double videoFrameRate( int stream ) { return file ? mpeg3_frame_rate( file, stream ) : 0.0; }
65 int videoFrames( int stream ) 73 int videoFrames( int stream )
66{ return file ? mpeg3_video_frames( file, stream ) : 0; } 74{ return file ? mpeg3_video_frames( file, stream ) : 0; }
67/* 75/*
68{ 76{
69 if ( file ) { 77 if ( file ) {
70 int frames = mpeg3_video_frames( file, stream ); 78 int frames = mpeg3_video_frames( file, stream );
71 if ( frames == 1 ) { 79 if ( frames == 1 ) {
72 int res = mpeg3_seek_percentage( file, 0.99 ); 80 int res = mpeg3_seek_percentage( file, 0.99 );
73 printf("res: %i\n", res ); 81 printf("res: %i\n", res );
74 mpeg3video_seek( file->vtrack[stream]->video ); 82 mpeg3video_seek( file->vtrack[stream]->video );
75 frames = mpeg3_get_frame( file, stream ); 83 frames = mpeg3_get_frame( file, stream );
76 mpeg3_seek_percentage( file, 0.0 ); 84 mpeg3_seek_percentage( file, 0.0 );
77 } 85 }
78 return frames; 86 return frames;
79 } 87 }
80 return 0; 88 return 0;
81} 89}
82*/ 90*/
83 bool videoSetFrame( long frame, int stream ) { return file ? mpeg3_set_frame( file, frame, stream) == 1 : FALSE; } 91 bool videoSetFrame( long frame, int stream ) { return file ? mpeg3_set_frame( file, frame, stream) == 1 : FALSE; }
84 long videoGetFrame( int stream ) { return file ? mpeg3_get_frame( file, stream ) : 0; } 92 long videoGetFrame( int stream ) { return file ? mpeg3_get_frame( file, stream ) : 0; }
85 bool videoReadFrame( unsigned char **output_rows, int in_x, int in_y, int in_w, int in_h, ColorFormat color_model, int stream ); 93 bool videoReadFrame( unsigned char **output_rows, int in_x, int in_y, int in_w, int in_h, ColorFormat color_model, int stream );
86 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 ); 94 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 );
87 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 ); 95 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 );
88 96
89 // Profiling 97 // Profiling
90 double getTime() { return file ? mpeg3_get_time( file ) : 0.0; } 98 double getTime() { return file ? mpeg3_get_time( file ) : 0.0; }
91 99
92 // Ignore if these aren't supported 100 // Ignore if these aren't supported
93 bool setSMP( int cpus ) { return file ? mpeg3_set_cpus( file, cpus ) == 1 : FALSE; } 101 bool setSMP( int cpus ) { return file ? mpeg3_set_cpus( file, cpus ) == 1 : FALSE; }
94 bool setMMX( bool useMMX ) { return file ? mpeg3_set_mmx( file, useMMX ) == 1 : FALSE; } 102 bool setMMX( bool useMMX ) { return file ? mpeg3_set_mmx( file, useMMX ) == 1 : FALSE; }
95 103
96 // Capabilities 104 // Capabilities
97 bool supportsAudio() { return TRUE; } 105 bool supportsAudio() { return TRUE; }
98 bool supportsVideo() { return TRUE; } 106 bool supportsVideo() { return TRUE; }
99 bool supportsYUV() { return TRUE; } 107 bool supportsYUV() { return TRUE; }
100 bool supportsMMX() { return TRUE; } 108 bool supportsMMX() { return TRUE; }
101 bool supportsSMP() { return TRUE; } 109 bool supportsSMP() { return TRUE; }
102 bool supportsStereo() { return TRUE; } 110 bool supportsStereo() { return TRUE; }
103 bool supportsScaling() { return TRUE; } 111 bool supportsScaling() { return TRUE; }
104 112
113 long getPlayTime() { return -1; }
114
105private: 115private:
106 mpeg3_t *file; 116 mpeg3_t *file;
107 QString strInfo; 117 QString strInfo;
108 118
109}; 119};
110 120
111 121
112#endif 122#endif
113 123
diff --git a/core/multimedia/opieplayer/libmpeg3/libmpeg3pluginimpl.h b/core/multimedia/opieplayer/libmpeg3/libmpeg3pluginimpl.h
index 29ec6ba..89abf97 100644
--- a/core/multimedia/opieplayer/libmpeg3/libmpeg3pluginimpl.h
+++ b/core/multimedia/opieplayer/libmpeg3/libmpeg3pluginimpl.h
@@ -1,53 +1,54 @@
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
24//#include <qpe/mediaplayerplugininterface.h>
24#include "../mediaplayerplugininterface.h" 25#include "../mediaplayerplugininterface.h"
25 26
26 27
27class LibMpeg3Plugin; 28class LibMpeg3Plugin;
28 29
29 30
30class LibMpeg3PluginImpl : public MediaPlayerPluginInterface 31class LibMpeg3PluginImpl : public MediaPlayerPluginInterface
31{ 32{
32public: 33public:
33 LibMpeg3PluginImpl(); 34 LibMpeg3PluginImpl();
34 virtual ~LibMpeg3PluginImpl(); 35 virtual ~LibMpeg3PluginImpl();
35 36
36#ifndef QT_NO_COMPONENT 37#ifndef QT_NO_COMPONENT
37 38
38 QRESULT queryInterface( const QUuid&, QUnknownInterface** ); 39 QRESULT queryInterface( const QUuid&, QUnknownInterface** );
39 Q_REFCOUNT 40 Q_REFCOUNT
40 41
41#endif 42#endif
42 43
43 virtual MediaPlayerDecoder *decoder(); 44 virtual MediaPlayerDecoder *decoder();
44 virtual MediaPlayerEncoder *encoder(); 45 virtual MediaPlayerEncoder *encoder();
45 46
46private: 47private:
47 LibMpeg3Plugin *libmpeg3plugin; 48 LibMpeg3Plugin *libmpeg3plugin;
48 ulong ref; 49 ulong ref;
49}; 50};
50 51
51 52
52#endif 53#endif
53 54
diff --git a/core/multimedia/opieplayer/loopcontrol.cpp b/core/multimedia/opieplayer/loopcontrol.cpp
index 6dfd057..859a67a 100644
--- a/core/multimedia/opieplayer/loopcontrol.cpp
+++ b/core/multimedia/opieplayer/loopcontrol.cpp
@@ -1,464 +1,468 @@
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
20#include <qpe/qpeapplication.h> 22#include <qpe/qpeapplication.h>
23
21#ifdef Q_WS_QWS 24#ifdef Q_WS_QWS
22#include <qpe/qcopenvelope_qws.h> 25#include <qpe/qcopenvelope_qws.h>
23#endif 26#endif
24#include <stdio.h> 27#include <stdio.h>
25#include <stdlib.h> 28#include <stdlib.h>
26#include <string.h> 29#include <string.h>
27#include <pthread.h> 30#include <pthread.h>
28#include <errno.h> 31#include <errno.h>
29#include <unistd.h> 32#include <unistd.h>
30#include "loopcontrol.h" 33#include "loopcontrol.h"
31#include "videowidget.h" 34#include "videowidget.h"
32#include "audiodevice.h" 35#include "audiodevice.h"
33#include "mediaplayerplugininterface.h" 36#include "mediaplayerplugininterface.h"
34#include "mediaplayerstate.h" 37#include "mediaplayerstate.h"
35 38
36 39
37extern VideoWidget *videoUI; // now only needed to tell it to play a frame 40extern VideoWidget *videoUI; // now only needed to tell it to play a frame
38extern MediaPlayerState *mediaPlayerState; 41extern MediaPlayerState *mediaPlayerState;
39 42
40 43
41//#define DecodeLoopDebug(x) qDebug x 44//#define DecodeLoopDebug(x) qDebug x
42#define DecodeLoopDebug(x) 45#define DecodeLoopDebug(x)
43 46
44 47
45 static char *audioBuffer = NULL; 48static char *audioBuffer = NULL;
46static AudioDevice *audioDevice = NULL; 49static AudioDevice *audioDevice = NULL;
47 static bool disabledSuspendScreenSaver = FALSE; 50static bool disabledSuspendScreenSaver = FALSE;
48 static bool previousSuspendMode = FALSE; 51static bool previousSuspendMode = FALSE;
49 52
50 53
51 pthread_taudio_tid; 54pthread_t audio_tid;
52pthread_attr_t audio_attr; 55pthread_attr_t audio_attr;
53bool threadOkToGo = FALSE; 56bool threadOkToGo = FALSE;
54 57
55 58
56class Mutex { 59class Mutex {
57public: 60public:
58 Mutex() { 61 Mutex() {
59 pthread_mutexattr_t attr; 62 pthread_mutexattr_t attr;
60 pthread_mutexattr_init( &attr ); 63 pthread_mutexattr_init( &attr );
61 pthread_mutex_init( &mutex, &attr ); 64 pthread_mutex_init( &mutex, &attr );
62 pthread_mutexattr_destroy( &attr ); 65 pthread_mutexattr_destroy( &attr );
63 } 66 }
64 67
65 ~Mutex() { 68 ~Mutex() {
66 pthread_mutex_destroy( &mutex ); 69 pthread_mutex_destroy( &mutex );
67 } 70 }
68 71
69 void lock() { 72 void lock() {
70 pthread_mutex_lock( &mutex ); 73 pthread_mutex_lock( &mutex );
71 } 74 }
72 75
73 void unlock() { 76 void unlock() {
74 pthread_mutex_unlock( &mutex ); 77 pthread_mutex_unlock( &mutex );
75 } 78 }
76private: 79private:
77 pthread_mutex_t mutex; 80 pthread_mutex_t mutex;
78}; 81};
79 82
80 83
81void *startAudioThread( void *ptr ) { 84void *startAudioThread( void *ptr ) {
82 LoopControl *mpegView = (LoopControl *)ptr; 85 LoopControl *mpegView = (LoopControl *)ptr;
83 while ( TRUE ) { 86 while ( TRUE ) {
84 if ( threadOkToGo && mpegView->moreAudio ) 87 if ( threadOkToGo && mpegView->moreAudio )
85 mpegView->startAudio(); 88 mpegView->startAudio();
86 else 89 else
87 usleep( 10000 ); // Semi-buzy-wait till we are playing again 90 usleep( 10000 ); // Semi-buzy-wait till we are playing again
88 } 91 }
89 return 0; 92 return 0;
90} 93}
91 94
92 95
93Mutex *audioMutex; 96Mutex *audioMutex;
94 97
95 98
96LoopControl::LoopControl( QObject *parent, const char *name ) 99LoopControl::LoopControl( QObject *parent, const char *name )
97 : QObject( parent, name ) { 100 : QObject( parent, name ) {
98 isMuted = FALSE; 101 isMuted = FALSE;
99 connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( setMute(bool) ) ); 102 connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( setMute(bool) ) );
100 103
101 audioMutex = new Mutex; 104 audioMutex = new Mutex;
102 105
103 pthread_attr_init(&audio_attr); 106 pthread_attr_init(&audio_attr);
104#define USE_REALTIME_AUDIO_THREAD 107#define USE_REALTIME_AUDIO_THREAD
105#ifdef USE_REALTIME_AUDIO_THREAD 108#ifdef USE_REALTIME_AUDIO_THREAD
106 // Attempt to set it to real-time round robin 109 // Attempt to set it to real-time round robin
107 if ( pthread_attr_setschedpolicy( &audio_attr, SCHED_RR ) == 0 ) { 110 if ( pthread_attr_setschedpolicy( &audio_attr, SCHED_RR ) == 0 ) {
108 sched_param params; 111 sched_param params;
109 params.sched_priority = 50; 112 params.sched_priority = 50;
110 pthread_attr_setschedparam(&audio_attr,&params); 113 pthread_attr_setschedparam(&audio_attr,&params);
111 } else { 114 } else {
112 qDebug( "Error setting up a realtime thread, reverting to using a normal thread." ); 115 qDebug( "Error setting up a realtime thread, reverting to using a normal thread." );
113 pthread_attr_destroy(&audio_attr); 116 pthread_attr_destroy(&audio_attr);
114 pthread_attr_init(&audio_attr); 117 pthread_attr_init(&audio_attr);
115 } 118 }
116#endif 119#endif
117 pthread_create(&audio_tid, &audio_attr, (void * (*)(void *))startAudioThread, this); 120 pthread_create(&audio_tid, &audio_attr, (void * (*)(void *))startAudioThread, this);
118} 121}
119 122
120 123
121LoopControl::~LoopControl() { 124LoopControl::~LoopControl() {
122 stop(); 125 stop();
123} 126}
124 127
125 128
126static long prev_frame = 0; 129static long prev_frame = 0;
127static int currentSample = 0; 130static int currentSample = 0;
128 131
129 132
130void LoopControl::timerEvent( QTimerEvent *te ) { 133void LoopControl::timerEvent( QTimerEvent *te ) {
131 134
132 if ( te->timerId() == videoId ) 135 if ( te->timerId() == videoId )
133 startVideo(); 136 startVideo();
134 137
135 if ( te->timerId() == sliderId ) { 138 if ( te->timerId() == sliderId ) {
136 if ( hasAudioChannel && !hasVideoChannel && moreAudio ) { 139 if ( hasAudioChannel && !hasVideoChannel && moreAudio ) {
137 mediaPlayerState->updatePosition( audioSampleCounter ); 140 mediaPlayerState->updatePosition( audioSampleCounter );
138 } else if ( hasVideoChannel && moreVideo ) { 141 } else if ( hasVideoChannel && moreVideo ) {
139 mediaPlayerState->updatePosition( current_frame ); 142 mediaPlayerState->updatePosition( current_frame );
140 } 143 }
141 } 144 }
142 145
143 if ( !moreVideo && !moreAudio ) { 146 if ( !moreVideo && !moreAudio ) {
144 mediaPlayerState->setPlaying( FALSE ); 147 mediaPlayerState->setPlaying( FALSE );
145 mediaPlayerState->setNext(); 148 mediaPlayerState->setNext();
146 } 149 }
147} 150}
148 151
149 152
150void LoopControl::setPosition( long pos ) { 153void LoopControl::setPosition( long pos ) {
151 audioMutex->lock(); 154 audioMutex->lock();
152 155
153 if ( hasVideoChannel && hasAudioChannel ) { 156 if ( hasVideoChannel && hasAudioChannel ) {
154 playtime.restart(); 157 playtime.restart();
155 playtime = playtime.addMSecs( long((double)-pos * 1000.0 / framerate) ); 158 playtime = playtime.addMSecs( long((double)-pos * 1000.0 / framerate) );
156 current_frame = pos + 1; 159 current_frame = pos + 1;
157 mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); 160 mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream );
158 prev_frame = current_frame - 1; 161 prev_frame = current_frame - 1;
159 currentSample = (int)( (double)current_frame * freq / framerate ); 162 currentSample = (int)( (double)current_frame * freq / framerate );
160 mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream ); 163 mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream );
161 audioSampleCounter = currentSample - 1; 164 audioSampleCounter = currentSample - 1;
162 } else if ( hasVideoChannel ) { 165 } else if ( hasVideoChannel ) {
163 playtime.restart(); 166 playtime.restart();
164 playtime = playtime.addMSecs( long((double)-pos * 1000.0 / framerate) ); 167 playtime = playtime.addMSecs( long((double)-pos * 1000.0 / framerate) );
165 current_frame = pos + 1; 168 current_frame = pos + 1;
166 mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); 169 mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream );
167 prev_frame = current_frame - 1; 170 prev_frame = current_frame - 1;
168 } else if ( hasAudioChannel ) { 171 } else if ( hasAudioChannel ) {
169 playtime.restart(); 172 playtime.restart();
170 playtime = playtime.addMSecs( long((double)-pos * 1000.0 / freq) ); 173 playtime = playtime.addMSecs( long((double)-pos * 1000.0 / freq) );
171 currentSample = pos + 1; 174 currentSample = pos + 1;
172 mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream ); 175 mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream );
173 audioSampleCounter = currentSample - 1; 176 audioSampleCounter = currentSample - 1;
174 } 177 }
175 178
176 audioMutex->unlock(); 179 audioMutex->unlock();
177} 180}
178 181
179 182
180void LoopControl::startVideo() { 183void LoopControl::startVideo() {
181 184
182 if ( moreVideo ) { 185 if ( moreVideo ) {
183 186
184 if ( mediaPlayerState->curDecoder() ) { 187 if ( mediaPlayerState->curDecoder() ) {
185 188
186 if ( hasAudioChannel && !isMuted ) { 189 if ( hasAudioChannel && !isMuted ) {
187 190
188 current_frame = long( playtime.elapsed() * framerate / 1000 ); 191 current_frame = long( playtime.elapsed() * framerate / 1000 );
189 192
190 if ( prev_frame != -1 && current_frame <= prev_frame ) 193 if ( prev_frame != -1 && current_frame <= prev_frame )
191 return; 194 return;
192 195
193 } else { 196 } else {
194 // Don't skip 197 // Don't skip
195 current_frame++; 198 current_frame++;
196 } 199 }
197 200
198 if ( prev_frame == -1 || current_frame > prev_frame ) { 201 if ( prev_frame == -1 || current_frame > prev_frame ) {
199 if ( current_frame > prev_frame + 1 ) { 202 if ( current_frame > prev_frame + 1 ) {
200 mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); 203 mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream );
201 } 204 }
202 moreVideo = videoUI->playVideo(); 205 moreVideo = videoUI->playVideo();
203 prev_frame = current_frame; 206 prev_frame = current_frame;
204 } 207 }
205 208
206 } else { 209 } else {
207 210
208 moreVideo = FALSE; 211 moreVideo = FALSE;
209 killTimer( videoId ); 212 killTimer( videoId );
210 213
211 } 214 }
212 215
213 } 216 }
214} 217}
215 218
216 219
217void LoopControl::startAudio() { 220void LoopControl::startAudio() {
218 221
219 audioMutex->lock(); 222 audioMutex->lock();
220 223
221 if ( moreAudio ) { 224 if ( moreAudio ) {
222 225
223 if ( !isMuted && mediaPlayerState->curDecoder() ) { 226 if ( !isMuted && mediaPlayerState->curDecoder() ) {
224 227
225 currentSample = audioSampleCounter + 1; 228 currentSample = audioSampleCounter + 1;
226 229
227 if ( currentSample != audioSampleCounter + 1 ) 230 if ( currentSample != audioSampleCounter + 1 )
228 qDebug("out of sync with decoder %i %i", currentSample, audioSampleCounter); 231 qDebug("out of sync with decoder %i %i", currentSample, audioSampleCounter);
229 232
230 long samplesRead = 0; 233 long samplesRead = 0;
231 bool readOk=mediaPlayerState->curDecoder()->audioReadSamples( (short*)audioBuffer, channels, 1024, samplesRead, stream ); 234 bool readOk=mediaPlayerState->curDecoder()->audioReadSamples( (short*)audioBuffer, channels, 1024, samplesRead, stream );
232 long sampleWeShouldBeAt = long( playtime.elapsed() ) * freq / 1000; 235 long sampleWeShouldBeAt = long( playtime.elapsed() ) * freq / 1000;
233 long sampleWaitTime = currentSample - sampleWeShouldBeAt; 236 long sampleWaitTime = currentSample - sampleWeShouldBeAt;
234 237
235 if ( ( sampleWaitTime > 2000 ) && ( sampleWaitTime < 20000 ) ) { 238// if ( ( sampleWaitTime > 2000 ) && ( sampleWaitTime < 5000 ) ) {
236 usleep( (long)((double)sampleWaitTime * 1000000.0 / freq) ); 239// usleep( (long)((double)sampleWaitTime * 1000000.0 / freq) );
237 } else if ( sampleWaitTime <= -5000 ) { 240// }
238 qDebug("need to catch up by: %li (%i,%li)", -sampleWaitTime, currentSample, sampleWeShouldBeAt ); 241// else if ( sampleWaitTime <= -5000 ) {
239 //mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream ); 242// qDebug("need to catch up by: %li (%i,%li)", -sampleWaitTime, currentSample, sampleWeShouldBeAt );
240 currentSample = sampleWeShouldBeAt; 243// //mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream );
241 } 244// currentSample = sampleWeShouldBeAt;
245// }
242 246
243 audioDevice->write( audioBuffer, samplesRead * 2 * channels ); 247 audioDevice->write( audioBuffer, samplesRead * 2 * channels );
244 audioSampleCounter = currentSample + samplesRead - 1; 248 audioSampleCounter = currentSample + samplesRead - 1;
245 249
246 moreAudio = readOk && (audioSampleCounter <= total_audio_samples); 250 moreAudio = readOk && (audioSampleCounter <= total_audio_samples);
247 251
248 } else { 252 } else {
249 253
250 moreAudio = FALSE; 254 moreAudio = FALSE;
251 255
252 } 256 }
253 257
254 } 258 }
255 259
256 audioMutex->unlock(); 260 audioMutex->unlock();
257} 261}
258 262
259 263
260void LoopControl::killTimers() { 264void LoopControl::killTimers() {
261 265
262 audioMutex->lock(); 266 audioMutex->lock();
263 267
264 if ( hasVideoChannel ) 268 if ( hasVideoChannel )
265 killTimer( videoId ); 269 killTimer( videoId );
266 killTimer( sliderId ); 270 killTimer( sliderId );
267 threadOkToGo = FALSE; 271 threadOkToGo = FALSE;
268 272
269 audioMutex->unlock(); 273 audioMutex->unlock();
270} 274}
271 275
272 276
273void LoopControl::startTimers() { 277void LoopControl::startTimers() {
274 278
275 audioMutex->lock(); 279 audioMutex->lock();
276 280
277 moreVideo = FALSE; 281 moreVideo = FALSE;
278 moreAudio = FALSE; 282 moreAudio = FALSE;
279 283
280 if ( hasVideoChannel ) { 284 if ( hasVideoChannel ) {
281 moreVideo = TRUE; 285 moreVideo = TRUE;
282 int mSecsBetweenFrames = (int)(100 / framerate); // 10% of the real value 286 int mSecsBetweenFrames = (int)(100 / framerate); // 10% of the real value
283 videoId = startTimer( mSecsBetweenFrames ); 287 videoId = startTimer( mSecsBetweenFrames );
284 } 288 }
285 289
286 if ( hasAudioChannel ) { 290 if ( hasAudioChannel ) {
287 moreAudio = TRUE; 291 moreAudio = TRUE;
288 threadOkToGo = TRUE; 292 threadOkToGo = TRUE;
289 } 293 }
290 294
291 sliderId = startTimer( 300 ); // update slider every 1/3 second 295 sliderId = startTimer( 300 ); // update slider every 1/3 second
292 296
293 audioMutex->unlock(); 297 audioMutex->unlock();
294} 298}
295 299
296 300
297void LoopControl::setPaused( bool pause ) { 301void LoopControl::setPaused( bool pause ) {
298 302
299 if ( !mediaPlayerState->curDecoder() || !mediaPlayerState->curDecoder()->isOpen() ) 303 if ( !mediaPlayerState->curDecoder() || !mediaPlayerState->curDecoder()->isOpen() )
300 return; 304 return;
301 305
302 if ( pause ) { 306 if ( pause ) {
303 killTimers(); 307 killTimers();
304 } else { 308 } else {
305 // Force an update of the position 309 // Force an update of the position
306 mediaPlayerState->setPosition( mediaPlayerState->position() + 1 ); 310 mediaPlayerState->setPosition( mediaPlayerState->position() + 1 );
307 mediaPlayerState->setPosition( mediaPlayerState->position() - 1 ); 311 mediaPlayerState->setPosition( mediaPlayerState->position() - 1 );
308 // Just like we never stopped 312 // Just like we never stopped
309 startTimers(); 313 startTimers();
310 } 314 }
311} 315}
312 316
313 317
314void LoopControl::stop( bool willPlayAgainShortly ) { 318void LoopControl::stop( bool willPlayAgainShortly ) {
315 319
316#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 320#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
317 if ( !willPlayAgainShortly && disabledSuspendScreenSaver ) { 321 if ( !willPlayAgainShortly && disabledSuspendScreenSaver ) {
318 disabledSuspendScreenSaver = FALSE; 322 disabledSuspendScreenSaver = FALSE;
319 // Re-enable the suspend mode 323 // Re-enable the suspend mode
320 QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; 324 QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
321 } 325 }
322#endif 326#endif
323 327
324 if ( mediaPlayerState->curDecoder() && mediaPlayerState->curDecoder()->isOpen() ) { 328 if ( mediaPlayerState->curDecoder() && mediaPlayerState->curDecoder()->isOpen() ) {
325 329
326 killTimers(); 330 killTimers();
327 331
328 audioMutex->lock(); 332 audioMutex->lock();
329 333
330 mediaPlayerState->curDecoder()->close(); 334 mediaPlayerState->curDecoder()->close();
331 335
332 if ( audioDevice ) { 336 if ( audioDevice ) {
333 delete audioDevice; 337 delete audioDevice;
334 delete audioBuffer; 338 delete audioBuffer;
335 audioDevice = 0; 339 audioDevice = 0;
336 audioBuffer = 0; 340 audioBuffer = 0;
337 } 341 }
338 342
339 audioMutex->unlock(); 343 audioMutex->unlock();
340 344
341 } 345 }
342} 346}
343 347
344 348
345bool LoopControl::init( const QString& filename ) { 349bool LoopControl::init( const QString& filename ) {
346 stop(); 350 stop();
347 351
348 audioMutex->lock(); 352 audioMutex->lock();
349 353
350 fileName = filename; 354 fileName = filename;
351 stream = 0; // only play stream 0 for now 355 stream = 0; // only play stream 0 for now
352 current_frame = total_video_frames = total_audio_samples = 0; 356 current_frame = total_video_frames = total_audio_samples = 0;
353 357
354 qDebug( "Using the %s decoder", mediaPlayerState->curDecoder()->pluginName() ); 358 qDebug( "Using the %s decoder", mediaPlayerState->curDecoder()->pluginName() );
355 359
356 // ### Hack to use libmpeg3plugin to get the number of audio samples if we are using the libmad plugin 360 // ### Hack to use libmpeg3plugin to get the number of audio samples if we are using the libmad plugin
357 if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibMadPlugin") ) { 361 if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibMadPlugin") ) {
358 if ( mediaPlayerState->libMpeg3Decoder() && mediaPlayerState->libMpeg3Decoder()->open( filename ) ) { 362 if ( mediaPlayerState->libMpeg3Decoder() && mediaPlayerState->libMpeg3Decoder()->open( filename ) ) {
359 total_audio_samples = mediaPlayerState->libMpeg3Decoder()->audioSamples( 0 ); 363 total_audio_samples = mediaPlayerState->libMpeg3Decoder()->audioSamples( 0 );
360 mediaPlayerState->libMpeg3Decoder()->close(); 364 mediaPlayerState->libMpeg3Decoder()->close();
361 } 365 }
362 } 366 }
363 367
364 if ( !mediaPlayerState->curDecoder()|| !mediaPlayerState->curDecoder()->open( filename ) ) { 368 if ( !mediaPlayerState->curDecoder()|| !mediaPlayerState->curDecoder()->open( filename ) ) {
365 audioMutex->unlock(); 369 audioMutex->unlock();
366 return FALSE; 370 return FALSE;
367 } 371 }
368 372
369 hasAudioChannel = mediaPlayerState->curDecoder()->audioStreams() > 0; 373 hasAudioChannel = mediaPlayerState->curDecoder()->audioStreams() > 0;
370 hasVideoChannel = mediaPlayerState->curDecoder()->videoStreams() > 0; 374 hasVideoChannel = mediaPlayerState->curDecoder()->videoStreams() > 0;
371 375
372 if ( hasAudioChannel ) { 376 if ( hasAudioChannel ) {
373 int astream = 0; 377 int astream = 0;
374 378
375 channels = mediaPlayerState->curDecoder()->audioChannels( astream ); 379 channels = mediaPlayerState->curDecoder()->audioChannels( astream );
376 DecodeLoopDebug(( "channels = %d\n", channels )); 380 qDebug( "LC- channels = %d", channels );
377 381
378 if ( !total_audio_samples ) 382 if ( !total_audio_samples )
379 total_audio_samples = mediaPlayerState->curDecoder()->audioSamples( astream ); 383 total_audio_samples = mediaPlayerState->curDecoder()->audioSamples( astream );
380 384
381 total_audio_samples += 1000; 385// total_audio_samples += 1000;
382 386
383 mediaPlayerState->setLength( total_audio_samples ); 387 mediaPlayerState->setLength( total_audio_samples );
384 388
385 freq = mediaPlayerState->curDecoder()->audioFrequency( astream ); 389 freq = mediaPlayerState->curDecoder()->audioFrequency( astream );
386 DecodeLoopDebug(( "frequency = %d\n", freq )); 390 qDebug( "LC- frequency = %d", freq );
387 391
388 audioSampleCounter = 0; 392 audioSampleCounter = 0;
389 393
390 static const int bytes_per_sample = 2; //16 bit 394 int bits_per_sample = mediaPlayerState->curDecoder()->audioBitsPerSample( astream);
391 395
392 audioDevice = new AudioDevice( freq, channels, bytes_per_sample ); 396 audioDevice = new AudioDevice( freq, channels, bits_per_sample);
393 audioBuffer = new char[ audioDevice->bufferSize() ]; 397 audioBuffer = new char[ audioDevice->bufferSize() ];
394 channels = audioDevice->channels(); 398 channels = audioDevice->channels();
395 399
396 //### must check which frequency is actually used. 400 //### must check which frequency is actually used.
397 static const int size = 1; 401 static const int size = 1;
398 short int buf[size]; 402 short int buf[size];
399 long samplesRead = 0; 403 long samplesRead = 0;
400 mediaPlayerState->curDecoder()->audioReadSamples( buf, channels, size, samplesRead, stream ); 404 mediaPlayerState->curDecoder()->audioReadSamples( buf, channels, size, samplesRead, stream );
401 } 405 }
402 406
403 if ( hasVideoChannel ) { 407 if ( hasVideoChannel ) {
404 total_video_frames = mediaPlayerState->curDecoder()->videoFrames( stream ); 408 total_video_frames = mediaPlayerState->curDecoder()->videoFrames( stream );
405 409
406 mediaPlayerState->setLength( total_video_frames ); 410 mediaPlayerState->setLength( total_video_frames );
407 411
408 framerate = mediaPlayerState->curDecoder()->videoFrameRate( stream ); 412 framerate = mediaPlayerState->curDecoder()->videoFrameRate( stream );
409 DecodeLoopDebug(( "Frame rate %g total %ld", framerate, total_video_frames )); 413 DecodeLoopDebug(( "Frame rate %g total %ld", framerate, total_video_frames ));
410 414
411 if ( framerate <= 1.0 ) { 415 if ( framerate <= 1.0 ) {
412 DecodeLoopDebug(( "Crazy frame rate, resetting to sensible" )); 416 DecodeLoopDebug(( "Crazy frame rate, resetting to sensible" ));
413 framerate = 25; 417 framerate = 25;
414 } 418 }
415 419
416 if ( total_video_frames == 1 ) { 420 if ( total_video_frames == 1 ) {
417 DecodeLoopDebug(( "Cannot seek to frame" )); 421 DecodeLoopDebug(( "Cannot seek to frame" ));
418 } 422 }
419 423
420 } 424 }
421 425
422 current_frame = 0; 426 current_frame = 0;
423 prev_frame = -1; 427 prev_frame = -1;
424 428
425 connect( mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( setPosition( long ) ) ); 429 connect( mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( setPosition( long ) ) );
426 connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( setPaused( bool ) ) ); 430 connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( setPaused( bool ) ) );
427 431
428 audioMutex->unlock(); 432 audioMutex->unlock();
429 433
430 return TRUE; 434 return TRUE;
431} 435}
432 436
433 437
434void LoopControl::play() { 438void LoopControl::play() {
435 439
436#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 440#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
437 if ( !disabledSuspendScreenSaver || previousSuspendMode != hasVideoChannel ) { 441 if ( !disabledSuspendScreenSaver || previousSuspendMode != hasVideoChannel ) {
438 disabledSuspendScreenSaver = TRUE; 442 disabledSuspendScreenSaver = TRUE;
439 previousSuspendMode = hasVideoChannel; 443 previousSuspendMode = hasVideoChannel;
440 // Stop the screen from blanking and power saving state 444 // Stop the screen from blanking and power saving state
441 QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) 445 QCopEnvelope("QPE/System", "setScreenSaverMode(int)" )
442 << ( hasVideoChannel ? QPEApplication::Disable : QPEApplication::DisableSuspend ); 446 << ( hasVideoChannel ? QPEApplication::Disable : QPEApplication::DisableSuspend );
443 } 447 }
444#endif 448#endif
445 449
446 playtime.start(); 450 playtime.start();
447 startTimers(); 451 startTimers();
448} 452}
449 453
450 454
451void LoopControl::setMute( bool on ) { 455void LoopControl::setMute( bool on ) {
452 if ( on != isMuted ) { 456 if ( on != isMuted ) {
453 isMuted = on; 457 isMuted = on;
454 if ( !on ) { 458 if ( !on ) {
455 // Force an update of the position 459 // Force an update of the position
456 mediaPlayerState->setPosition( mediaPlayerState->position() + 1 ); 460 mediaPlayerState->setPosition( mediaPlayerState->position() + 1 );
457 mediaPlayerState->setPosition( mediaPlayerState->position() - 1 ); 461 mediaPlayerState->setPosition( mediaPlayerState->position() - 1 );
458 // Resume playing audio 462 // Resume playing audio
459 moreAudio = TRUE; 463 moreAudio = TRUE;
460 } 464 }
461 } 465 }
462} 466}
463 467
464 468
diff --git a/core/multimedia/opieplayer/loopcontrol.h b/core/multimedia/opieplayer/loopcontrol.h
index 967ee25..fc7d316 100644
--- a/core/multimedia/opieplayer/loopcontrol.h
+++ b/core/multimedia/opieplayer/loopcontrol.h
@@ -1,88 +1,90 @@
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
20#ifndef MPEGVIEW_H 22#ifndef MPEGVIEW_H
21#define MPEGVIEW_H 23#define MPEGVIEW_H
22 24
23 25
24#include <qwidget.h> 26#include <qwidget.h>
25#include <qdatetime.h> 27#include <qdatetime.h>
26 28
27 29
28class LoopControl : public QObject { 30class LoopControl : public QObject {
29 Q_OBJECT 31 Q_OBJECT
30public: 32public:
31 LoopControl( QObject *parent, const char *name ); 33 LoopControl( QObject *parent, const char *name );
32 ~LoopControl(); 34 ~LoopControl();
33 35
34 bool init( const QString& filename ); 36 bool init( const QString& filename );
35 37
36 bool hasVideo() const { return hasVideoChannel; } 38 bool hasVideo() const { return hasVideoChannel; }
37 bool hasAudio() const { return hasAudioChannel; } 39 bool hasAudio() const { return hasAudioChannel; }
38 40
39 long totalPlaytime() { return (long)(hasVideoChannel ? total_video_frames / framerate : total_audio_samples / freq); } 41 long totalPlaytime() { return (long)(hasVideoChannel ? total_video_frames / framerate : total_audio_samples / freq); }
40 42
41 // These are public to run them from global functions needed to start threads 43 // These are public to run them from global functions needed to start threads
42 // Otherwise they would be private 44 // Otherwise they would be private
43 void startAudio(); 45 void startAudio();
44 void startVideo(); 46 void startVideo();
45 bool moreAudio; 47 bool moreAudio;
46 bool moreVideo; 48 bool moreVideo;
47public slots: 49public slots:
48 void play(); 50 void play();
49 void stop( bool willPlayAgainShortly = FALSE ); 51 void stop( bool willPlayAgainShortly = FALSE );
50 52
51 void setMute( bool ); 53 void setMute( bool );
52 void setPaused( bool ); 54 void setPaused( bool );
53 void setPosition( long ); 55 void setPosition( long );
54 56
55signals: 57signals:
56 void positionChanged( long, long ); 58 void positionChanged( long, long );
57 59
58protected: 60protected:
59 void timerEvent(QTimerEvent*); 61 void timerEvent(QTimerEvent*);
60 62
61private: 63private:
62 void startTimers(); 64 void startTimers();
63 void killTimers(); 65 void killTimers();
64 66
65 QTime playtime; 67 QTime playtime;
66 int videoId; 68 int videoId;
67 int sliderId; 69 int sliderId;
68 70
69 int audioSampleCounter; 71 int audioSampleCounter;
70 long current_frame; 72 long current_frame;
71 long total_video_frames; 73 long total_video_frames;
72 long total_audio_samples; 74 long total_audio_samples;
73 75
74 float framerate; 76 float framerate;
75 int freq; 77 int freq;
76 int stream; 78 int stream;
77 int framecount; 79 int framecount;
78 int channels; 80 int channels;
79 81
80 bool hasVideoChannel; 82 bool hasVideoChannel;
81 bool hasAudioChannel; 83 bool hasAudioChannel;
82 bool isMuted; 84 bool isMuted;
83 QString fileName; 85 QString fileName;
84}; 86};
85 87
86 88
87#endif 89#endif
88 90
diff --git a/core/multimedia/opieplayer/loopcontrol_threaded.cpp b/core/multimedia/opieplayer/loopcontrol_threaded.cpp
index 2ec4a48..2e49bb7 100644
--- a/core/multimedia/opieplayer/loopcontrol_threaded.cpp
+++ b/core/multimedia/opieplayer/loopcontrol_threaded.cpp
@@ -1,231 +1,231 @@
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 20
21#define _REENTRANT 21#define _REENTRANT
22 22
23#include <qpe/qpeapplication.h> 23#include <qpe/qpeapplication.h>
24#include <qimage.h> 24#include <qimage.h>
25#include <qpainter.h> 25#include <qpainter.h>
26#ifdef Q_WS_QWS 26#ifdef Q_WS_QWS
27#include <qpe/qcopenvelope_qws.h> 27#include <qpe/qcopenvelope_qws.h>
28#endif 28#endif
29#include "mediaplayerplugininterface.h"
29#include <stdio.h> 30#include <stdio.h>
30#include <stdlib.h> 31#include <stdlib.h>
31#include <string.h> 32#include <string.h>
32#include <time.h> 33#include <time.h>
33#include <unistd.h> 34#include <unistd.h>
34#include <pthread.h> 35#include <pthread.h>
35#include "loopcontrol.h" 36#include "loopcontrol.h"
36#include "audiodevice.h" 37#include "audiodevice.h"
37#include "videowidget.h" 38#include "videowidget.h"
38#include "audiowidget.h" 39#include "audiowidget.h"
39#include "mediaplayerplugininterface.h"
40#include "mediaplayerstate.h" 40#include "mediaplayerstate.h"
41 41
42 42
43#if defined(QT_QWS_CUSTOM) || defined(QT_QWS_IPAQ) 43#if defined(QT_QWS_CUSTOM) || defined(QT_QWS_IPAQ)
44#define USE_REALTIME_AUDIO_THREAD 44#define USE_REALTIME_AUDIO_THREAD
45#endif 45#endif
46 46
47 47
48extern VideoWidget *videoUI; // now only needed to tell it to play a frame 48extern VideoWidget *videoUI; // now only needed to tell it to play a frame
49extern MediaPlayerState *mediaPlayerState; 49extern MediaPlayerState *mediaPlayerState;
50 50
51 51
52#define DecodeLoopDebug(x) qDebug x 52#define DecodeLoopDebug(x) qDebug x
53//#define DecodeLoopDebug(x) 53//#define DecodeLoopDebug(x)
54 54
55 55
56 static char *audioBuffer = NULL; 56 static char *audioBuffer = NULL;
57static AudioDevice *audioDevice = NULL; 57static AudioDevice *audioDevice = NULL;
58 static bool disabledSuspendScreenSaver = FALSE; 58 static bool disabledSuspendScreenSaver = FALSE;
59 59
60 60
61 pthread_tvideo_tid; 61 pthread_tvideo_tid;
62pthread_attr_t video_attr; 62pthread_attr_t video_attr;
63 pthread_taudio_tid; 63 pthread_taudio_tid;
64pthread_attr_t audio_attr; 64pthread_attr_t audio_attr;
65 65
66 66
67bool emitPlayFinished = FALSE; 67bool emitPlayFinished = FALSE;
68bool emitChangePos = FALSE; 68bool emitChangePos = FALSE;
69 69
70 70
71class Mutex { 71class Mutex {
72public: 72public:
73 Mutex() { 73 Mutex() {
74 pthread_mutexattr_t attr; 74 pthread_mutexattr_t attr;
75 pthread_mutexattr_init( &attr ); 75 pthread_mutexattr_init( &attr );
76 pthread_mutex_init( &mutex, &attr ); 76 pthread_mutex_init( &mutex, &attr );
77 pthread_mutexattr_destroy( &attr ); 77 pthread_mutexattr_destroy( &attr );
78 } 78 }
79 79
80 ~Mutex() { 80 ~Mutex() {
81 pthread_mutex_destroy( &mutex ); 81 pthread_mutex_destroy( &mutex );
82 } 82 }
83 83
84 void lock() { 84 void lock() {
85 pthread_mutex_lock( &mutex ); 85 pthread_mutex_lock( &mutex );
86 } 86 }
87 87
88 void unlock() { 88 void unlock() {
89 pthread_mutex_unlock( &mutex ); 89 pthread_mutex_unlock( &mutex );
90 } 90 }
91/* 91/*
92 bool locked() { 92 bool locked() {
93 switch ( pthread_mutex_trylock( &mutex ) ) { 93 switch ( pthread_mutex_trylock( &mutex ) ) {
94 case EBUSY: 94 case EBUSY:
95 return TRUE; 95 return TRUE;
96 case 0: 96 case 0:
97 pthread_mutex_unlock( &mutex ); 97 pthread_mutex_unlock( &mutex );
98 default: 98 default:
99 return FALSE; 99 return FALSE;
100 } 100 }
101 } 101 }
102*/ 102*/
103private: 103private:
104 pthread_mutex_t mutex; 104 pthread_mutex_t mutex;
105}; 105};
106 106
107 107
108class currentFrameObj { 108class currentFrameObj {
109public: 109public:
110 currentFrameObj() : value( 0 ) { } 110 currentFrameObj() : value( 0 ) { }
111 void set( long f ) { 111 void set( long f ) {
112 mutex.lock(); 112 mutex.lock();
113 value = f; 113 value = f;
114 mediaPlayerState->curDecoder()->videoSetFrame( f, 0 ); 114 mediaPlayerState->curDecoder()->videoSetFrame( f, 0 );
115 mutex.unlock(); 115 mutex.unlock();
116 } 116 }
117 long get() { 117 long get() {
118 return value; 118 return value;
119 } 119 }
120private: 120private:
121 long value; 121 long value;
122 Mutex mutex; 122 Mutex mutex;
123}; 123};
124 124
125 125
126Mutex *videoMutex; 126Mutex *videoMutex;
127Mutex *audioMutex; 127Mutex *audioMutex;
128Mutex *globalMutex; 128Mutex *globalMutex;
129 129
130 130
131 clock_tbegin; 131 clock_tbegin;
132 132
133 133
134LoopControl::LoopControl( QObject *parent, const char *name ) 134LoopControl::LoopControl( QObject *parent, const char *name )
135 : QObject( parent, name ) { 135 : QObject( parent, name ) {
136 isMuted = FALSE; 136 isMuted = FALSE;
137 connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( setMute(bool) ) ); 137 connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( setMute(bool) ) );
138 timerid = startTimer( 200 ); 138 timerid = startTimer( 200 );
139 videoMutex = new Mutex; 139 videoMutex = new Mutex;
140 audioMutex = new Mutex; 140 audioMutex = new Mutex;
141 globalMutex = new Mutex; 141 globalMutex = new Mutex;
142 //begin = clock(); 142 //begin = clock();
143} 143}
144 144
145 145
146LoopControl::~LoopControl() { 146LoopControl::~LoopControl() {
147 stop(); 147 stop();
148 killTimer( timerid ); 148 killTimer( timerid );
149} 149}
150 150
151 151
152static bool sendingNewPos = FALSE; 152static bool sendingNewPos = FALSE;
153static long prev_frame = 0; 153static long prev_frame = 0;
154static int currentSample = 0; 154static int currentSample = 0;
155 155
156 156
157void LoopControl::timerEvent( QTimerEvent* ) { 157void LoopControl::timerEvent( QTimerEvent* ) {
158 // We need to emit playFinished from the main thread, not one of the 158 // We need to emit playFinished from the main thread, not one of the
159 // decoding threads else we'll have all kinds of yucky things happen (reentrance). 159 // decoding threads else we'll have all kinds of yucky things happen (reentrance).
160 // playFinished will eventually call stop() which stops these threads. 160 // playFinished will eventually call stop() which stops these threads.
161 if ( emitPlayFinished ) { 161 if ( emitPlayFinished ) {
162 emitPlayFinished = FALSE; 162 emitPlayFinished = FALSE;
163 mediaPlayerState->setPlaying( FALSE ); 163 mediaPlayerState->setPlaying( FALSE );
164 } 164 }
165 165
166 if ( emitChangePos ) { 166 if ( emitChangePos ) {
167 167
168 emitChangePos = FALSE; 168 emitChangePos = FALSE;
169 169
170 if ( hasVideoChannel && hasAudioChannel ) { 170 if ( hasVideoChannel && hasAudioChannel ) {
171 sendingNewPos = TRUE; 171 sendingNewPos = TRUE;
172 mediaPlayerState->setPosition( current_frame ); 172 mediaPlayerState->setPosition( current_frame );
173 } else if ( hasVideoChannel ) { 173 } else if ( hasVideoChannel ) {
174 sendingNewPos = TRUE; 174 sendingNewPos = TRUE;
175 mediaPlayerState->setPosition( current_frame ); 175 mediaPlayerState->setPosition( current_frame );
176 } else if ( hasAudioChannel ) { 176 } else if ( hasAudioChannel ) {
177 sendingNewPos = TRUE; 177 sendingNewPos = TRUE;
178 mediaPlayerState->setPosition( audioSampleCounter ); 178 mediaPlayerState->setPosition( audioSampleCounter );
179 } 179 }
180 180
181 } 181 }
182} 182}
183 183
184 184
185 185
186 186
187void LoopControl::setPosition( long pos ) { 187void LoopControl::setPosition( long pos ) {
188 if ( sendingNewPos ) { 188 if ( sendingNewPos ) {
189 sendingNewPos = FALSE; 189 sendingNewPos = FALSE;
190 return; 190 return;
191 } 191 }
192 192
193 if ( hasVideoChannel && hasAudioChannel ) { 193 if ( hasVideoChannel && hasAudioChannel ) {
194 videoMutex->lock(); 194 videoMutex->lock();
195 audioMutex->lock(); 195 audioMutex->lock();
196qDebug("setting position"); 196qDebug("setting position");
197 playtime.restart(); 197 playtime.restart();
198 playtime = playtime.addMSecs( -pos * 1000 / framerate ); 198 playtime = playtime.addMSecs( -pos * 1000 / framerate );
199 //begin = clock() - (double)pos * CLOCKS_PER_SEC / framerate; 199 //begin = clock() - (double)pos * CLOCKS_PER_SEC / framerate;
200 current_frame = pos + 1; 200 current_frame = pos + 1;
201 mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); 201 mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream );
202 prev_frame = current_frame - 1; 202 prev_frame = current_frame - 1;
203 currentSample = (int)( current_frame * freq / framerate ); 203 currentSample = (int)( current_frame * freq / framerate );
204 mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream ); 204 mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream );
205 audioSampleCounter = currentSample - 1; 205 audioSampleCounter = currentSample - 1;
206 audioMutex->unlock(); 206 audioMutex->unlock();
207 videoMutex->unlock(); 207 videoMutex->unlock();
208 } else if ( hasVideoChannel ) { 208 } else if ( hasVideoChannel ) {
209 videoMutex->lock(); 209 videoMutex->lock();
210 playtime.restart(); 210 playtime.restart();
211 playtime = playtime.addMSecs( -pos * 1000 / framerate ); 211 playtime = playtime.addMSecs( -pos * 1000 / framerate );
212 //begin = clock() - (double)pos * CLOCKS_PER_SEC / framerate; 212 //begin = clock() - (double)pos * CLOCKS_PER_SEC / framerate;
213 current_frame = pos + 1; 213 current_frame = pos + 1;
214 mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); 214 mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream );
215 videoMutex->unlock(); 215 videoMutex->unlock();
216 prev_frame = current_frame - 1; 216 prev_frame = current_frame - 1;
217 } else if ( hasAudioChannel ) { 217 } else if ( hasAudioChannel ) {
218 audioMutex->lock(); 218 audioMutex->lock();
219 playtime.restart(); 219 playtime.restart();
220 playtime = playtime.addMSecs( -pos * 1000 / freq ); 220 playtime = playtime.addMSecs( -pos * 1000 / freq );
221 //begin = clock() - (double)pos * CLOCKS_PER_SEC / freq; 221 //begin = clock() - (double)pos * CLOCKS_PER_SEC / freq;
222 currentSample = pos + 1; // (int)( current_frame * freq / framerate ); 222 currentSample = pos + 1; // (int)( current_frame * freq / framerate );
223 mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream ); 223 mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream );
224 audioSampleCounter = currentSample - 1; 224 audioSampleCounter = currentSample - 1;
225 audioMutex->unlock(); 225 audioMutex->unlock();
226 } 226 }
227} 227}
228 228
229 229
230void *startVideoThread( void *ptr ) { 230void *startVideoThread( void *ptr ) {
231 LoopControl *mpegView = (LoopControl *)ptr; 231 LoopControl *mpegView = (LoopControl *)ptr;
diff --git a/core/multimedia/opieplayer/main.cpp b/core/multimedia/opieplayer/main.cpp
index 5246e40..9f7ef73 100644
--- a/core/multimedia/opieplayer/main.cpp
+++ b/core/multimedia/opieplayer/main.cpp
@@ -1,57 +1,57 @@
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 <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 28
29MediaPlayerState *mediaPlayerState; 29MediaPlayerState *mediaPlayerState;
30PlayListWidget *playList; 30PlayListWidget *playList;
31AudioWidget *audioUI; 31AudioWidget *audioUI;
32VideoWidget *videoUI; 32VideoWidget *videoUI;
33LoopControl *loopControl; 33LoopControl *loopControl;
34 34
35 35
36int main(int argc, char **argv) { 36int main(int argc, char **argv) {
37 QPEApplication a(argc,argv); 37 QPEApplication a(argc,argv);
38 38
39 MediaPlayerState st( 0, "mediaPlayerState" ); 39 MediaPlayerState st( 0, "mediaPlayerState" );
40 mediaPlayerState = &st; 40 mediaPlayerState = &st;
41 PlayListWidget pl( 0, "playList" ); 41 PlayListWidget pl( 0, "playList" );
42 playList = &pl; 42 playList = &pl;
43 AudioWidget aw( 0, "audioUI" ); 43 AudioWidget aw( 0, "audioUI" );
44 audioUI = &aw; 44 audioUI = &aw;
45 VideoWidget vw( 0, "videoUI" ); 45 VideoWidget vw( 0, "videoUI" );
46 videoUI = &vw; 46 videoUI = &vw;
47 LoopControl lc( 0, "loopControl" ); 47 LoopControl lc( 0, "loopControl" );
48 loopControl = &lc; 48 loopControl = &lc;
49 MediaPlayer mp( 0, "mediaPlayer" ); 49 MediaPlayer mp( 0, "mediaPlayer" );
50 50
51 pl.setCaption( MediaPlayer::tr("Media Player") ); 51 pl.setCaption( MediaPlayer::tr("Opie Player") );
52 a.showMainDocumentWidget(&pl); 52 a.showMainDocumentWidget(&pl);
53 53
54 return a.exec(); 54 return a.exec();
55} 55}
56 56
57 57
diff --git a/core/multimedia/opieplayer/mediaplayerplugininterface.h b/core/multimedia/opieplayer/mediaplayerplugininterface.h
index 24d5a80..339b2e4 100644
--- a/core/multimedia/opieplayer/mediaplayerplugininterface.h
+++ b/core/multimedia/opieplayer/mediaplayerplugininterface.h
@@ -1,113 +1,111 @@
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#include <qpe/qcom.h> 23#include <qpe/qcom.h>
24 24
25#ifndef QT_NO_COMPONENT 25#ifndef QT_NO_COMPONENT
26// {c0093632-b44c-4cf7-a279-d82fe8a8890c} 26// {c0093632-b44c-4cf7-a279-d82fe8a8890c}
27# ifndef IID_MediaPlayerPlugin 27# ifndef IID_MediaPlayerPlugin
28# define IID_MediaPlayerPlugin QUuid( 0xc0093632, 0xb44c, 0x4cf7, 0xa2, 0x79, 0xd8, 0x2f, 0xe8, 0xa8, 0x89, 0x0c ) 28# define IID_MediaPlayerPlugin QUuid( 0xc0093632, 0xb44c, 0x4cf7, 0xa2, 0x79, 0xd8, 0x2f, 0xe8, 0xa8, 0x89, 0x0c )
29# endif 29# endif
30#endif 30#endif
31 31
32 32
33enum ColorFormat { 33enum ColorFormat {
34 RGB565, 34 RGB565,
35 BGR565, 35 BGR565,
36 RGBA8888, 36 RGBA8888,
37 BGRA8888 37 BGRA8888
38}; 38};
39 39
40 40
41class MediaPlayerDecoder { 41class MediaPlayerDecoder {
42 42
43public: 43public:
44 virtual ~MediaPlayerDecoder() { }; 44 virtual ~MediaPlayerDecoder() { };
45 45
46 // About Plugin 46 // About Plugin
47 virtual const char *pluginName() = 0; 47 virtual const char *pluginName() = 0;
48 virtual const char *pluginComment() = 0; 48 virtual const char *pluginComment() = 0;
49 virtual double pluginVersion() = 0; 49 virtual double pluginVersion() = 0;
50 50
51 virtual bool isFileSupported( const QString& file ) = 0; 51 virtual bool isFileSupported( const QString& file ) = 0;
52 virtual bool open( const QString& file ) = 0; 52 virtual bool open( const QString& file ) = 0;
53 virtual bool close() = 0; 53 virtual bool close() = 0;
54 virtual bool isOpen() = 0; 54 virtual bool isOpen() = 0;
55 virtual const QString &fileInfo() = 0; 55 virtual const QString &fileInfo() = 0;
56 56
57 // If decoder doesn't support audio then return 0 here 57 // If decoder doesn't support audio then return 0 here
58 virtual int audioStreams() = 0; 58 virtual int audioStreams() = 0;
59 virtual int audioChannels( int stream ) = 0; 59 virtual int audioChannels( int stream ) = 0;
60 virtual int audioFrequency( int stream ) = 0; 60 virtual int audioFrequency( int stream ) = 0;
61 virtual int audioSamples( int stream ) = 0; 61 virtual int audioSamples( int stream ) = 0;
62 virtual bool audioSetSample( long sample, int stream ) = 0; 62 virtual bool audioSetSample( long sample, int stream ) = 0;
63 virtual long audioGetSample( int stream ) = 0; 63 virtual long audioGetSample( int stream ) = 0;
64// virtual bool audioReadMonoSamples( short *samples, long samples, long& samplesRead, int stream ) = 0;
65// virtual bool audioReadStereoSamples( short *samples, long samples, long& samplesRead, int stream ) = 0;
66 virtual bool audioReadSamples( short *samples, int channels, long samples, long& samplesRead, int stream ) = 0; 64 virtual bool audioReadSamples( short *samples, int channels, long samples, long& samplesRead, int stream ) = 0;
67 // Libmpeg3 functions, perhaps good for reading an audio file with 5 channels or something!
68// virtual bool audioReadSamples( short *samples, int channel, long samples, int stream ) = 0;
69// virtual bool audioReReadSamples( short *samples, int channel, long samples, int stream ) = 0;
70 65
71 // If decoder doesn't support video then return 0 here 66 // If decoder doesn't support video then return 0 here
72 virtual int videoStreams() = 0; 67 virtual int videoStreams() = 0;
73 virtual int videoWidth( int stream ) = 0; 68 virtual int videoWidth( int stream ) = 0;
74 virtual int videoHeight( int stream ) = 0; 69 virtual int videoHeight( int stream ) = 0;
75 virtual double videoFrameRate( int stream ) = 0; // frames per second (this may change to frames/1000secs) 70 virtual double videoFrameRate( int stream ) = 0; // frames per second (this may change to frames/1000secs)
76 virtual int videoFrames( int stream ) = 0; 71 virtual int videoFrames( int stream ) = 0;
77 virtual bool videoSetFrame( long sample, int stream ) = 0; 72 virtual bool videoSetFrame( long sample, int stream ) = 0;
78 virtual long videoGetFrame( int stream ) = 0; 73 virtual long videoGetFrame( int stream ) = 0;
79 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; 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 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; 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 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; 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 77
83 // Profiling 78 // Profiling
84 virtual double getTime() = 0; 79 virtual double getTime() = 0;
85 80
86 // Ignore if these aren't supported 81 // Ignore if these aren't supported
87 virtual bool setSMP( int cpus ) = 0; 82 virtual bool setSMP( int cpus ) = 0;
88 virtual bool setMMX( bool useMMX ) = 0; 83 virtual bool setMMX( bool useMMX ) = 0;
89 84
90 // Capabilities 85 // Capabilities
91 virtual bool supportsAudio() = 0; 86 virtual bool supportsAudio() = 0;
92 virtual bool supportsVideo() = 0; 87 virtual bool supportsVideo() = 0;
93 virtual bool supportsYUV() = 0; 88 virtual bool supportsYUV() = 0;
94 virtual bool supportsMMX() = 0; 89 virtual bool supportsMMX() = 0;
95 virtual bool supportsSMP() = 0; 90 virtual bool supportsSMP() = 0;
96 virtual bool supportsStereo() = 0; 91 virtual bool supportsStereo() = 0;
97 virtual bool supportsScaling() = 0; 92 virtual bool supportsScaling() = 0;
98 93
94 // File Properies
95 virtual long getPlayTime() { return -1; }
96 virtual int audioBitsPerSample( int stream ) = 0;
99}; 97};
100 98
101 99
102class MediaPlayerEncoder; 100class MediaPlayerEncoder;
103 101
104 102
105struct MediaPlayerPluginInterface : public QUnknownInterface 103struct MediaPlayerPluginInterface : public QUnknownInterface
106{ 104{
107 virtual MediaPlayerDecoder *decoder() = 0; 105 virtual MediaPlayerDecoder *decoder() = 0;
108 virtual MediaPlayerEncoder *encoder() = 0; 106 virtual MediaPlayerEncoder *encoder() = 0;
109}; 107};
110 108
111 109
112#endif 110#endif
113 111
diff --git a/core/multimedia/opieplayer/mediaplayerstate.cpp b/core/multimedia/opieplayer/mediaplayerstate.cpp
index 9b9d133..2a6bca3 100644
--- a/core/multimedia/opieplayer/mediaplayerstate.cpp
+++ b/core/multimedia/opieplayer/mediaplayerstate.cpp
@@ -1,185 +1,191 @@
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 <qpe/qpeapplication.h> 20#include <qpe/qpeapplication.h>
21#include <qpe/qlibrary.h> 21#include <qpe/qlibrary.h>
22#include <qpe/config.h> 22#include <qpe/config.h>
23#include <qvaluelist.h> 23#include <qvaluelist.h>
24#include <qobject.h> 24#include <qobject.h>
25#include <qdir.h> 25#include <qdir.h>
26#include "mediaplayerplugininterface.h" 26#include "mediaplayerplugininterface.h"
27#include "mediaplayerstate.h" 27#include "mediaplayerstate.h"
28 28
29
30
29#ifdef QT_NO_COMPONENT 31#ifdef QT_NO_COMPONENT
30// Plugins which are compiled in when no plugin architecture available 32// Plugins which are compiled in when no plugin architecture available
31#include "libmad/libmadpluginimpl.h" 33#include "libmad/libmadpluginimpl.h"
32#include "libmpeg3/libmpeg3pluginimpl.h" 34#include "libmpeg3/libmpeg3pluginimpl.h"
33#include "wavplugin/wavpluginimpl.h" 35#include "wavplugin/wavpluginimpl.h"
34#endif 36#endif
35 37
36 38
37 //#define MediaPlayerDebug(x)qDebug x 39//#define MediaPlayerDebug(x) qDebug x
38#define MediaPlayerDebug(x) 40#define MediaPlayerDebug(x)
39 41
40 42
41MediaPlayerState::MediaPlayerState( QObject *parent, const char *name ) 43MediaPlayerState::MediaPlayerState( QObject *parent, const char *name )
42 : QObject( parent, name ), decoder( NULL ), libmpeg3decoder( NULL ) { 44 : QObject( parent, name ), decoder( NULL ), libmpeg3decoder( NULL ) {
43 Config cfg( "MediaPlayer" ); 45 Config cfg( "MediaPlayer" );
44 readConfig( cfg ); 46 readConfig( cfg );
45 loadPlugins(); 47 loadPlugins();
46} 48}
47 49
48 50
49MediaPlayerState::~MediaPlayerState() { 51MediaPlayerState::~MediaPlayerState() {
50 Config cfg( "MediaPlayer" ); 52 Config cfg( "MediaPlayer" );
51 writeConfig( cfg ); 53 writeConfig( cfg );
52} 54}
53 55
54 56
55void MediaPlayerState::readConfig( Config& cfg ) { 57void MediaPlayerState::readConfig( Config& cfg ) {
56 cfg.setGroup("Options"); 58 cfg.setGroup("Options");
57 isFullscreen = cfg.readBoolEntry( "FullScreen" ); 59 isFullscreen = cfg.readBoolEntry( "FullScreen" );
58 isScaled = cfg.readBoolEntry( "Scaling" ); 60 isScaled = cfg.readBoolEntry( "Scaling" );
59 isLooping = cfg.readBoolEntry( "Looping" ); 61 isLooping = cfg.readBoolEntry( "Looping" );
60 isShuffled = cfg.readBoolEntry( "Shuffle" ); 62 isShuffled = cfg.readBoolEntry( "Shuffle" );
61 usePlaylist = cfg.readBoolEntry( "UsePlayList" ); 63 usePlaylist = cfg.readBoolEntry( "UsePlayList" );
62 isPlaying = FALSE; 64 isPlaying = FALSE;
63 isPaused = FALSE; 65 isPaused = FALSE;
64 curPosition = 0; 66 curPosition = 0;
65 curLength = 0; 67 curLength = 0;
66 curView = 'l'; 68 curView = 'l';
67} 69}
68 70
69 71
70void MediaPlayerState::writeConfig( Config& cfg ) const { 72void MediaPlayerState::writeConfig( Config& cfg ) const {
71 cfg.setGroup("Options"); 73 cfg.setGroup("Options");
72 cfg.writeEntry("FullScreen", isFullscreen ); 74 cfg.writeEntry("FullScreen", isFullscreen );
73 cfg.writeEntry("Scaling", isScaled ); 75 cfg.writeEntry("Scaling", isScaled );
74 cfg.writeEntry("Looping", isLooping ); 76 cfg.writeEntry("Looping", isLooping );
75 cfg.writeEntry("Shuffle", isShuffled ); 77 cfg.writeEntry("Shuffle", isShuffled );
76 cfg.writeEntry("UsePlayList", usePlaylist ); 78 cfg.writeEntry("UsePlayList", usePlaylist );
77} 79}
78 80
79 81
80struct MediaPlayerPlugin { 82struct MediaPlayerPlugin {
81#ifndef QT_NO_COMPONENT 83#ifndef QT_NO_COMPONENT
82 QLibrary *library; 84 QLibrary *library;
83#endif 85#endif
84 MediaPlayerPluginInterface *iface; 86 MediaPlayerPluginInterface *iface;
85 MediaPlayerDecoder *decoder; 87 MediaPlayerDecoder *decoder;
86 MediaPlayerEncoder *encoder; 88 MediaPlayerEncoder *encoder;
87}; 89};
88 90
89 91
90static QValueList<MediaPlayerPlugin> pluginList; 92static QValueList<MediaPlayerPlugin> pluginList;
91 93
92 94
93// Find the first decoder which supports this type of file 95// Find the first decoder which supports this type of file
94MediaPlayerDecoder *MediaPlayerState::newDecoder( const QString& file ) { 96MediaPlayerDecoder *MediaPlayerState::newDecoder( const QString& file ) {
95 MediaPlayerDecoder *tmpDecoder = NULL; 97 MediaPlayerDecoder *tmpDecoder = NULL;
96 QValueList<MediaPlayerPlugin>::Iterator it; 98 QValueList<MediaPlayerPlugin>::Iterator it;
97 for ( it = pluginList.begin(); it != pluginList.end(); ++it ) { 99 for ( it = pluginList.begin(); it != pluginList.end(); ++it ) {
98 if ( (*it).decoder->isFileSupported( file ) ) { 100 if ( (*it).decoder->isFileSupported( file ) ) {
99 tmpDecoder = (*it).decoder; 101 tmpDecoder = (*it).decoder;
100 break; 102 break;
101 } 103 }
102 } 104 }
103 return decoder = tmpDecoder; 105 return decoder = tmpDecoder;
104} 106}
105 107
106 108
107MediaPlayerDecoder *MediaPlayerState::curDecoder() { 109MediaPlayerDecoder *MediaPlayerState::curDecoder() {
108 return decoder; 110 return decoder;
109} 111}
110 112
111 113
112// ### hack to get true sample count 114// ### hack to get true sample count
113MediaPlayerDecoder *MediaPlayerState::libMpeg3Decoder() { 115MediaPlayerDecoder *MediaPlayerState::libMpeg3Decoder() {
114 return libmpeg3decoder; 116 return libmpeg3decoder;
115} 117}
116 118
119// ### hack to get true sample count
120// MediaPlayerDecoder *MediaPlayerState::libWavDecoder() {
121// return libwavdecoder;
122// }
117 123
118void MediaPlayerState::loadPlugins() { 124void MediaPlayerState::loadPlugins() {
119 125
120#ifndef QT_NO_COMPONENT 126#ifndef QT_NO_COMPONENT
121 QValueList<MediaPlayerPlugin>::Iterator mit; 127 QValueList<MediaPlayerPlugin>::Iterator mit;
122 for ( mit = pluginList.begin(); mit != pluginList.end(); ++mit ) { 128 for ( mit = pluginList.begin(); mit != pluginList.end(); ++mit ) {
123 (*mit).iface->release(); 129 (*mit).iface->release();
124 (*mit).library->unload(); 130 (*mit).library->unload();
125 delete (*mit).library; 131 delete (*mit).library;
126 } 132 }
127 pluginList.clear(); 133 pluginList.clear();
128 134
129 QString path = QPEApplication::qpeDir() + "/plugins/codecs"; 135 QString path = QPEApplication::qpeDir() + "/plugins/codecs";
130 QDir dir( path, "lib*.so" ); 136 QDir dir( path, "lib*.so" );
131 QStringList list = dir.entryList(); 137 QStringList list = dir.entryList();
132 QStringList::Iterator it; 138 QStringList::Iterator it;
133 for ( it = list.begin(); it != list.end(); ++it ) { 139 for ( it = list.begin(); it != list.end(); ++it ) {
134 MediaPlayerPluginInterface *iface = 0; 140 MediaPlayerPluginInterface *iface = 0;
135 QLibrary *lib = new QLibrary( path + "/" + *it ); 141 QLibrary *lib = new QLibrary( path + "/" + *it );
136 142
137 MediaPlayerDebug(( "querying: %s", QString( path + "/" + *it ).latin1() )); 143 MediaPlayerDebug(( "querying: %s", QString( path + "/" + *it ).latin1() ));
138 144
139 if ( lib->queryInterface( IID_MediaPlayerPlugin, (QUnknownInterface**)&iface ) == QS_OK ) { 145 if ( lib->queryInterface( IID_MediaPlayerPlugin, (QUnknownInterface**)&iface ) == QS_OK ) {
140 146
141 MediaPlayerDebug(( "loading: %s", QString( path + "/" + *it ).latin1() )); 147 MediaPlayerDebug(( "loading: %s", QString( path + "/" + *it ).latin1() ));
142 148
143 MediaPlayerPlugin plugin; 149 MediaPlayerPlugin plugin;
144 plugin.library = lib; 150 plugin.library = lib;
145 plugin.iface = iface; 151 plugin.iface = iface;
146 plugin.decoder = plugin.iface->decoder(); 152 plugin.decoder = plugin.iface->decoder();
147 plugin.encoder = plugin.iface->encoder(); 153 plugin.encoder = plugin.iface->encoder();
148 pluginList.append( plugin ); 154 pluginList.append( plugin );
149 155
150 // ### hack to get true sample count 156 // ### hack to get true sample count
151 if ( plugin.decoder->pluginName() == QString("LibMpeg3Plugin") ) 157 if ( plugin.decoder->pluginName() == QString("LibMpeg3Plugin") )
152 libmpeg3decoder = plugin.decoder; 158 libmpeg3decoder = plugin.decoder;
153 159
154 } else { 160 } else {
155 delete lib; 161 delete lib;
156 } 162 }
157 } 163 }
158#else 164#else
159 pluginList.clear(); 165 pluginList.clear();
160 166
161 MediaPlayerPlugin plugin0; 167 MediaPlayerPlugin plugin0;
162 plugin0.iface = new LibMpeg3PluginImpl; 168 plugin0.iface = new LibMpeg3PluginImpl;
163 plugin0.decoder = plugin0.iface->decoder(); 169 plugin0.decoder = plugin0.iface->decoder();
164 plugin0.encoder = plugin0.iface->encoder(); 170 plugin0.encoder = plugin0.iface->encoder();
165 pluginList.append( plugin0 ); 171 pluginList.append( plugin0 );
166 172
167 MediaPlayerPlugin plugin1; 173 MediaPlayerPlugin plugin1;
168 plugin1.iface = new LibMadPluginImpl; 174 plugin1.iface = new LibMadPluginImpl;
169 plugin1.decoder = plugin1.iface->decoder(); 175 plugin1.decoder = plugin1.iface->decoder();
170 plugin1.encoder = plugin1.iface->encoder(); 176 plugin1.encoder = plugin1.iface->encoder();
171 pluginList.append( plugin1 ); 177 pluginList.append( plugin1 );
172 178
173 MediaPlayerPlugin plugin2; 179 MediaPlayerPlugin plugin2;
174 plugin2.iface = new WavPluginImpl; 180 plugin2.iface = new WavPluginImpl;
175 plugin2.decoder = plugin2.iface->decoder(); 181 plugin2.decoder = plugin2.iface->decoder();
176 plugin2.encoder = plugin2.iface->encoder(); 182 plugin2.encoder = plugin2.iface->encoder();
177 pluginList.append( plugin2 ); 183 pluginList.append( plugin2 );
178#endif 184#endif
179 185
180 if ( pluginList.count() ) 186 if ( pluginList.count() )
181 MediaPlayerDebug(( "%i decoders found", pluginList.count() )); 187 MediaPlayerDebug(( "%i decoders found", pluginList.count() ));
182 else 188 else
183 MediaPlayerDebug(( "No decoders found" )); 189 MediaPlayerDebug(( "No decoders found" ));
184} 190}
185 191
diff --git a/core/multimedia/opieplayer/mediaplayerstate.h b/core/multimedia/opieplayer/mediaplayerstate.h
index 5d95b92..1a23742 100644
--- a/core/multimedia/opieplayer/mediaplayerstate.h
+++ b/core/multimedia/opieplayer/mediaplayerstate.h
@@ -1,117 +1,118 @@
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_STATE_H 20#ifndef MEDIA_PLAYER_STATE_H
21#define MEDIA_PLAYER_STATE_H 21#define MEDIA_PLAYER_STATE_H
22 22
23 23
24#include <qobject.h> 24#include <qobject.h>
25 25
26 26
27class MediaPlayerDecoder; 27class MediaPlayerDecoder;
28class Config; 28class Config;
29 29
30 30
31class MediaPlayerState : public QObject { 31class MediaPlayerState : public QObject {
32Q_OBJECT 32Q_OBJECT
33public: 33public:
34 MediaPlayerState( QObject *parent, const char *name ); 34 MediaPlayerState( QObject *parent, const char *name );
35 ~MediaPlayerState(); 35 ~MediaPlayerState();
36 36
37 bool fullscreen() { return isFullscreen; } 37 bool fullscreen() { return isFullscreen; }
38 bool scaled() { return isScaled; } 38 bool scaled() { return isScaled; }
39 bool looping() { return isLooping; } 39 bool looping() { return isLooping; }
40 bool shuffled() { return isShuffled; } 40 bool shuffled() { return isShuffled; }
41 bool playlist() { return usePlaylist; } 41 bool playlist() { return usePlaylist; }
42 bool paused() { return isPaused; } 42 bool paused() { return isPaused; }
43 bool playing() { return isPlaying; } 43 bool playing() { return isPlaying; }
44 long position() { return curPosition; } 44 long position() { return curPosition; }
45 long length() { return curLength; } 45 long length() { return curLength; }
46 char view() { return curView; } 46 char view() { return curView; }
47 47
48 MediaPlayerDecoder *newDecoder( const QString& file ); 48 MediaPlayerDecoder *newDecoder( const QString& file );
49 MediaPlayerDecoder *curDecoder(); 49 MediaPlayerDecoder *curDecoder();
50 MediaPlayerDecoder *libMpeg3Decoder(); // ### Yucky hack needed to use libmpeg3plugin to get the 50 MediaPlayerDecoder *libMpeg3Decoder(); // ### Yucky hack needed to use libmpeg3plugin to get the
51 // number of audio samples if we are using the libmad plugin 51 // number of audio samples if we are using the libmad plugin
52public slots: 52public slots:
53 void setFullscreen( bool b ) { if ( isFullscreen == b ) return; isFullscreen = b; emit fullscreenToggled(b); } 53 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); } 54 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); } 55 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); } 56 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); } 57 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); } 58 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); } 59 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); } 60 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); } 61 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); } 62 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); } 63 void setView( char v ) { if ( curView == v ) return; curView = v; emit viewChanged(v); }
64 64
65 void setPrev() { emit prev(); } 65 void setPrev() { emit prev(); }
66 void setNext() { emit next(); } 66 void setNext() { emit next(); }
67 void setList() { setPlaying( FALSE ); setView('l'); } 67 void setList() { setPlaying( FALSE ); setView('l'); }
68 void setVideo() { setView('v'); } 68 void setVideo() { setView('v'); }
69 void setAudio() { setView('a'); } 69 void setAudio() { setView('a'); }
70 70
71 void toggleFullscreen() { setFullscreen( !isFullscreen ); } 71 void toggleFullscreen() { setFullscreen( !isFullscreen ); }
72 void toggleScaled() { setScaled( !isScaled); } 72 void toggleScaled() { setScaled( !isScaled); }
73 void toggleLooping() { setLooping( !isLooping); } 73 void toggleLooping() { setLooping( !isLooping); }
74 void toggleShuffled() { setShuffled( !isShuffled); } 74 void toggleShuffled() { setShuffled( !isShuffled); }
75 void togglePlaylist() { setPlaylist( !usePlaylist); } 75 void togglePlaylist() { setPlaylist( !usePlaylist); }
76 void togglePaused() { setPaused( !isPaused); } 76 void togglePaused() { setPaused( !isPaused); }
77 void togglePlaying() { setPlaying( !isPlaying); } 77 void togglePlaying() { setPlaying( !isPlaying); }
78 78
79signals: 79signals:
80 void fullscreenToggled( bool ); 80 void fullscreenToggled( bool );
81 void scaledToggled( bool ); 81 void scaledToggled( bool );
82 void loopingToggled( bool ); 82 void loopingToggled( bool );
83 void shuffledToggled( bool ); 83 void shuffledToggled( bool );
84 void playlistToggled( bool ); 84 void playlistToggled( bool );
85 void pausedToggled( bool ); 85 void pausedToggled( bool );
86 void playingToggled( bool ); 86 void playingToggled( bool );
87 void positionChanged( long ); // When the slider is moved 87 void positionChanged( long ); // When the slider is moved
88 void positionUpdated( long ); // When the media file progresses 88 void positionUpdated( long ); // When the media file progresses
89 void lengthChanged( long ); 89 void lengthChanged( long );
90 void viewChanged( char ); 90 void viewChanged( char );
91 91
92 void prev(); 92 void prev();
93 void next(); 93 void next();
94 94
95private: 95private:
96 bool isFullscreen; 96 bool isFullscreen;
97 bool isScaled; 97 bool isScaled;
98 bool isLooping; 98 bool isLooping;
99 bool isShuffled; 99 bool isShuffled;
100 bool usePlaylist; 100 bool usePlaylist;
101 bool isPaused; 101 bool isPaused;
102 bool isPlaying; 102 bool isPlaying;
103 long curPosition; 103 long curPosition;
104 long curLength; 104 long curLength;
105 char curView; 105 char curView;
106 106
107 MediaPlayerDecoder *decoder; 107 MediaPlayerDecoder *decoder;
108 MediaPlayerDecoder *libmpeg3decoder; 108 MediaPlayerDecoder *libmpeg3decoder;
109// MediaPlayerDecoder *libwavdecoder;
109 110
110 void loadPlugins(); 111 void loadPlugins();
111 void readConfig( Config& cfg ); 112 void readConfig( Config& cfg );
112 void writeConfig( Config& cfg ) const; 113 void writeConfig( Config& cfg ) const;
113}; 114};
114 115
115 116
116#endif // MEDIA_PLAYER_STATE_H 117#endif // MEDIA_PLAYER_STATE_H
117 118
diff --git a/core/multimedia/opieplayer/playlistselection.cpp b/core/multimedia/opieplayer/playlistselection.cpp
index fbfb946..f17ab6f 100644
--- a/core/multimedia/opieplayer/playlistselection.cpp
+++ b/core/multimedia/opieplayer/playlistselection.cpp
@@ -1,179 +1,179 @@
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 <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 33
34class PlayListSelectionItem : public QListViewItem { 34class PlayListSelectionItem : public QListViewItem {
35public: 35public:
36 PlayListSelectionItem( QListView *parent, const DocLnk *f ) : QListViewItem( parent ), fl( f ) { 36 PlayListSelectionItem( QListView *parent, const DocLnk *f ) : QListViewItem( parent ), fl( f ) {
37 setText( 0, f->name() ); 37 setText( 0, f->name() );
38 setPixmap( 0, f->pixmap() ); 38 setPixmap( 0, f->pixmap() );
39 } 39 }
40 40
41 ~PlayListSelectionItem() { 41 ~PlayListSelectionItem() {
42 }; 42 };
43 43
44 const DocLnk *file() const { return fl; } 44 const DocLnk *file() const { return fl; }
45 45
46private: 46private:
47 const DocLnk *fl; 47 const DocLnk *fl;
48}; 48};
49 49
50 50
51PlayListSelection::PlayListSelection( QWidget *parent, const char *name ) 51PlayListSelection::PlayListSelection( QWidget *parent, const char *name )
52 : QListView( parent, name ) 52 : QListView( parent, name )
53{ 53{
54#ifdef USE_PLAYLIST_BACKGROUND 54#ifdef USE_PLAYLIST_BACKGROUND
55 setStaticBackground( TRUE ); 55 setStaticBackground( TRUE );
56 setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/background" ) ); 56 setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/background" ) );
57#endif 57#endif
58 setAllColumnsShowFocus( TRUE ); 58 setAllColumnsShowFocus( TRUE );
59 addColumn( tr( "Playlist Selection" ) ); 59 addColumn( tr( "Playlist Selection" ) );
60 header()->hide(); 60 header()->hide();
61 setSorting( -1, FALSE ); 61 setSorting( -1, FALSE );
62} 62}
63 63
64 64
65PlayListSelection::~PlayListSelection() { 65PlayListSelection::~PlayListSelection() {
66} 66}
67 67
68 68
69#ifdef USE_PLAYLIST_BACKGROUND 69#ifdef USE_PLAYLIST_BACKGROUND
70void PlayListSelection::drawBackground( QPainter *p, const QRect &r ) { 70void PlayListSelection::drawBackground( QPainter *p, const QRect &r ) {
71 p->fillRect( r, QBrush( white ) ); 71 p->fillRect( r, QBrush( white ) );
72 QImage logo = Resource::loadImage( "mpegplayer/background" ); 72 QImage logo = Resource::loadImage( "mpegplayer/background" );
73 if ( !logo.isNull() ) 73 if ( !logo.isNull() )
74 p->drawImage( (width() - logo.width()) / 2, (height() - logo.height()) / 2, logo ); 74 p->drawImage( (width() - logo.width()) / 2, (height() - logo.height()) / 2, logo );
75} 75}
76#endif 76#endif
77 77
78 78
79void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) { 79void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) {
80 if ( event->state() == QMouseEvent::LeftButton ) { 80 if ( event->state() == QMouseEvent::LeftButton ) {
81 QListViewItem *currentItem = selectedItem(); 81 QListViewItem *currentItem = selectedItem();
82 QListViewItem *itemUnder = itemAt( QPoint( event->pos().x(), event->pos().y() - contentsY() ) ); 82 QListViewItem *itemUnder = itemAt( QPoint( event->pos().x(), event->pos().y() - contentsY() ) );
83 if ( currentItem && currentItem->itemAbove() == itemUnder ) 83 if ( currentItem && currentItem->itemAbove() == itemUnder )
84 moveSelectedUp(); 84 moveSelectedUp();
85 else if ( currentItem && currentItem->itemBelow() == itemUnder ) 85 else if ( currentItem && currentItem->itemBelow() == itemUnder )
86 moveSelectedDown(); 86 moveSelectedDown();
87 } 87 }
88} 88}
89 89
90 90
91const DocLnk *PlayListSelection::current() { 91const DocLnk *PlayListSelection::current() {
92 PlayListSelectionItem *item = (PlayListSelectionItem *)selectedItem(); 92 PlayListSelectionItem *item = (PlayListSelectionItem *)selectedItem();
93 if ( item ) 93 if ( item )
94 return item->file(); 94 return item->file();
95 return NULL; 95 return NULL;
96} 96}
97 97
98 98
99void PlayListSelection::addToSelection( const DocLnk &lnk ) { 99void PlayListSelection::addToSelection( const DocLnk &lnk ) {
100 PlayListSelectionItem *item = new PlayListSelectionItem( this, new DocLnk( lnk ) ); 100 PlayListSelectionItem *item = new PlayListSelectionItem( this, new DocLnk( lnk ) );
101 QListViewItem *current = selectedItem(); 101 QListViewItem *current = selectedItem();
102 if ( current ) 102 if ( current )
103 item->moveItem( current ); 103 item->moveItem( current );
104 setSelected( item, TRUE ); 104 setSelected( item, TRUE );
105 ensureItemVisible( selectedItem() ); 105 ensureItemVisible( selectedItem() );
106} 106}
107 107
108 108
109void PlayListSelection::removeSelected() { 109void PlayListSelection::removeSelected() {
110 QListViewItem *item = selectedItem(); 110 QListViewItem *item = selectedItem();
111 if ( item ) 111 if ( item )
112 delete item; 112 delete item;
113 setSelected( currentItem(), TRUE ); 113 setSelected( currentItem(), TRUE );
114 ensureItemVisible( selectedItem() ); 114 ensureItemVisible( selectedItem() );
115} 115}
116 116
117 117
118void PlayListSelection::moveSelectedUp() { 118void PlayListSelection::moveSelectedUp() {
119 QListViewItem *item = selectedItem(); 119 QListViewItem *item = selectedItem();
120 if ( item && item->itemAbove() ) 120 if ( item && item->itemAbove() )
121 item->itemAbove()->moveItem( item ); 121 item->itemAbove()->moveItem( item );
122 ensureItemVisible( selectedItem() ); 122 ensureItemVisible( selectedItem() );
123} 123}
124 124
125 125
126void PlayListSelection::moveSelectedDown() { 126void PlayListSelection::moveSelectedDown() {
127 QListViewItem *item = selectedItem(); 127 QListViewItem *item = selectedItem();
128 if ( item && item->itemBelow() ) 128 if ( item && item->itemBelow() )
129 item->moveItem( item->itemBelow() ); 129 item->moveItem( item->itemBelow() );
130 ensureItemVisible( selectedItem() ); 130 ensureItemVisible( selectedItem() );
131} 131}
132 132
133 133
134bool PlayListSelection::prev() { 134bool PlayListSelection::prev() {
135 QListViewItem *item = selectedItem(); 135 QListViewItem *item = selectedItem();
136 if ( item && item->itemAbove() ) 136 if ( item && item->itemAbove() )
137 setSelected( item->itemAbove(), TRUE ); 137 setSelected( item->itemAbove(), TRUE );
138 else 138 else
139 return FALSE; 139 return FALSE;
140 ensureItemVisible( selectedItem() ); 140 ensureItemVisible( selectedItem() );
141 return TRUE; 141 return TRUE;
142} 142}
143 143
144 144
145bool PlayListSelection::next() { 145bool PlayListSelection::next() {
146 QListViewItem *item = selectedItem(); 146 QListViewItem *item = selectedItem();
147 if ( item && item->itemBelow() ) 147 if ( item && item->itemBelow() )
148 setSelected( item->itemBelow(), TRUE ); 148 setSelected( item->itemBelow(), TRUE );
149 else 149 else
150 return FALSE; 150 return FALSE;
151 ensureItemVisible( selectedItem() ); 151 ensureItemVisible( selectedItem() );
152 return TRUE; 152 return TRUE;
153} 153}
154 154
155 155
156bool PlayListSelection::first() { 156bool PlayListSelection::first() {
157 QListViewItem *item = firstChild(); 157 QListViewItem *item = firstChild();
158 if ( item ) 158 if ( item )
159 setSelected( item, TRUE ); 159 setSelected( item, TRUE );
160 else 160 else
161 return FALSE; 161 return FALSE;
162 ensureItemVisible( selectedItem() ); 162 ensureItemVisible( selectedItem() );
163 return TRUE; 163 return TRUE;
164} 164}
165 165
166 166
167bool PlayListSelection::last() { 167bool PlayListSelection::last() {
168 QListViewItem *prevItem = NULL; 168 QListViewItem *prevItem = NULL;
169 QListViewItem *item = firstChild(); 169 QListViewItem *item = firstChild();
170 while ( ( item = item->nextSibling() ) ) 170 while ( ( item = item->nextSibling() ) )
171 prevItem = item; 171 prevItem = item;
172 if ( prevItem ) 172 if ( prevItem )
173 setSelected( prevItem, TRUE ); 173 setSelected( prevItem, TRUE );
174 else 174 else
175 return FALSE; 175 return FALSE;
176 ensureItemVisible( selectedItem() ); 176 ensureItemVisible( selectedItem() );
177 return TRUE; 177 return TRUE;
178} 178}
179 179
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp
index 969fc4b..4e1543e 100644
--- a/core/multimedia/opieplayer/playlistwidget.cpp
+++ b/core/multimedia/opieplayer/playlistwidget.cpp
@@ -1,448 +1,693 @@
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 <qpe/qpemenubar.h> 20#include <qpe/qpemenubar.h>
21#include <qpe/qpetoolbar.h> 21#include <qpe/qpetoolbar.h>
22#include <qpe/fileselector.h> 22#include <qpe/fileselector.h>
23#include <qpe/qpeapplication.h>
24
23#include <qpe/applnk.h> 25#include <qpe/applnk.h>
24#include <qpe/config.h> 26#include <qpe/config.h>
25#include <qpe/global.h> 27#include <qpe/global.h>
26#include <qpe/resource.h> 28#include <qpe/resource.h>
27#include <qaction.h> 29#include <qaction.h>
28#include <qimage.h> 30#include <qimage.h>
29#include <qfile.h> 31#include <qfile.h>
30#include <qlayout.h> 32#include <qlayout.h>
31#include <qlabel.h> 33#include <qlabel.h>
32#include <qlist.h> 34#include <qlist.h>
33#include <qlistbox.h> 35#include <qlistbox.h>
34#include <qmainwindow.h> 36#include <qmainwindow.h>
35#include <qmessagebox.h> 37#include <qmessagebox.h>
36#include <qtoolbutton.h> 38#include <qtoolbutton.h>
39#include <qtabwidget.h>
40#include <qlistview.h>
41#include <qpoint.h>
42#include <qtimer.h>
37 43
38#include "playlistselection.h" 44#include "playlistselection.h"
39#include "playlistwidget.h" 45#include "playlistwidget.h"
40#include "mediaplayerstate.h" 46#include "mediaplayerstate.h"
41 47
42#include <stdlib.h> 48#include <stdlib.h>
43 49
50#define BUTTONS_ON_TOOLBAR
51#define SIDE_BUTTONS
52#define CAN_SAVE_LOAD_PLAYLISTS
44 53
45extern MediaPlayerState *mediaPlayerState; 54extern MediaPlayerState *mediaPlayerState;
46 55
56// class myFileSelector {
47 57
58// };
48class PlayListWidgetPrivate { 59class PlayListWidgetPrivate {
49public: 60public:
50 QToolButton *tbPlay; 61 QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove;
51 QToolButton *tbFull;
52 QToolButton *tbLoop;
53 QToolButton *tbScale;
54 QToolButton *tbShuffle;
55
56 QFrame *playListFrame; 62 QFrame *playListFrame;
57 FileSelector *files; 63 FileSelector *files;
58 PlayListSelection *selectedFiles; 64 PlayListSelection *selectedFiles;
59 bool setDocumentUsed; 65 bool setDocumentUsed;
60 DocLnk *current; 66 DocLnk *current;
61}; 67};
62 68
63 69
64class ToolButton : public QToolButton { 70class ToolButton : public QToolButton {
65public: 71public:
66 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) 72 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE )
67 : QToolButton( parent, name ) { 73 : QToolButton( parent, name ) {
68 setTextLabel( name ); 74 setTextLabel( name );
69 setPixmap( Resource::loadPixmap( icon ) ); 75 setPixmap( Resource::loadPixmap( icon ) );
70 setAutoRaise( TRUE ); 76 setAutoRaise( TRUE );
71 setFocusPolicy( QWidget::NoFocus ); 77 setFocusPolicy( QWidget::NoFocus );
72 setToggleButton( t ); 78 setToggleButton( t );
73 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); 79 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot );
74 QPEMenuToolFocusManager::manager()->addWidget( this ); 80 QPEMenuToolFocusManager::manager()->addWidget( this );
75 } 81 }
76}; 82};
77 83
78 84
79class MenuItem : public QAction { 85class MenuItem : public QAction {
80public: 86public:
81 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) 87 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot )
82 : QAction( text, QString::null, 0, 0 ) { 88 : QAction( text, QString::null, 0, 0 ) {
83 connect( this, SIGNAL( activated() ), handler, slot ); 89 connect( this, SIGNAL( activated() ), handler, slot );
84 addTo( parent ); 90 addTo( parent );
85 } 91 }
86}; 92};
87 93
88 94
89PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) 95PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
90 : QMainWindow( parent, name, fl ) { 96 : QMainWindow( parent, name, fl ) {
91 97
92 d = new PlayListWidgetPrivate; 98 d = new PlayListWidgetPrivate;
93 d->setDocumentUsed = FALSE; 99 d->setDocumentUsed = FALSE;
94 d->current = NULL; 100 d->current = NULL;
101 menuTimer = new QTimer( this ,"menu timer"),
102 connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) );
95 103
96 setBackgroundMode( PaletteButton ); 104 setBackgroundMode( PaletteButton );
97 105
98 setCaption( tr("MediaPlayer") ); 106 setCaption( tr("OpiePlayer") );
99 setIcon( Resource::loadPixmap( "MPEGPlayer" ) ); 107 setIcon( Resource::loadPixmap( "MPEGPlayer" ) );
100 108
101 setToolBarsMovable( FALSE ); 109 setToolBarsMovable( FALSE );
102 110
103 // Create Toolbar 111 // Create Toolbar
104 QPEToolBar *toolbar = new QPEToolBar( this ); 112 QPEToolBar *toolbar = new QPEToolBar( this );
105 toolbar->setHorizontalStretchable( TRUE ); 113 toolbar->setHorizontalStretchable( TRUE );
106 114
107 // Create Menubar 115 // Create Menubar
108 QPEMenuBar *menu = new QPEMenuBar( toolbar ); 116 QPEMenuBar *menu = new QPEMenuBar( toolbar );
109 menu->setMargin( 0 ); 117 menu->setMargin( 0 );
110 118
111 QPEToolBar *bar = new QPEToolBar( this ); 119 QPEToolBar *bar = new QPEToolBar( this );
112 bar->setLabel( tr( "Play Operations" ) ); 120 bar->setLabel( tr( "Play Operations" ) );
113#ifdef BUTTONS_ON_TOOLBAR 121 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "mpegplayer/add_to_playlist",
114 d->tbPlay = new ToolButton( bar, tr( "Play" ), "mpegplayer/play", mediaPlayerState, SLOT(setPlaying(bool)), TRUE ); 122 this , SLOT(addSelected()) );
115 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ), "mpegplayer/shuffle", mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); 123 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "mpegplayer/remove_from_playlist",
116#endif 124 this , SLOT(removeSelected()) );
117 d->tbLoop = new ToolButton( bar, tr( "Loop" ), "mpegplayer/loop", mediaPlayerState, SLOT(setLooping(bool)), TRUE ); 125 d->tbPlay = new ToolButton( bar, tr( "Play" ), "mpegplayer/play",
118 d->tbFull = new ToolButton( bar, tr( "Fullscreen" ), "fullscreen", mediaPlayerState, SLOT(setFullscreen(bool)), TRUE ); 126 mediaPlayerState, SLOT(setPlaying(bool)), TRUE );
119 d->tbScale = new ToolButton( bar, tr( "Scale" ), "mpegplayer/scale", mediaPlayerState, SLOT(setScaled(bool)), TRUE ); 127
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 );
120 135
121 QPopupMenu *pmPlayList = new QPopupMenu( this ); 136 QPopupMenu *pmPlayList = new QPopupMenu( this );
122 menu->insertItem( tr( "PlayList" ), pmPlayList ); 137 menu->insertItem( tr( "File" ), pmPlayList );
123 new MenuItem( pmPlayList, tr( "Toggle PlayList" ), mediaPlayerState, SLOT( togglePlaylist() ) );
124 new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); 138 new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) );
125 new MenuItem( pmPlayList, tr( "Add all music files" ), this, SLOT( addAllMusicToList() ) ); 139 new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) );
126 new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); 140 new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) );
127 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); 141 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) );
128#ifdef CAN_SAVE_LOAD_PLAYLISTS
129 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); 142 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) );
130 new MenuItem( pmPlayList, tr( "Load PlayList" ), this, SLOT( loadList() ) ); 143 new MenuItem( pmPlayList, tr( "Load PlayList" ), this, SLOT( loadList() ) );
131#endif 144
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);
132 154
133 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); 155 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");
134 173
135 // Add the playlist area 174 // Add the playlist area
136 QVBox *vbox3 = new QVBox( vbox5 ); vbox3->setBackgroundMode( PaletteButton );
137 d->playListFrame = vbox3;
138 175
139 QLabel *plString = new QLabel( tr(" PlayList"), vbox3 ); 176 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton );
140 plString->setBackgroundMode( QButton::PaletteButton ); 177 d->playListFrame = vbox3;
141 plString->setFont( QFont( "Helvetica", 8, QFont::Bold ) ); 178 d->playListFrame ->setMinimumSize(235,260);
142 179
143 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); 180 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton );
144 d->selectedFiles = new PlayListSelection( hbox2 ); 181 d->selectedFiles = new PlayListSelection( hbox2);
145 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); 182 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton );
146 183
147#ifndef BUTTONS_ON_TOOLBAR 184 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch
148 d->tbPlay = new ToolButton( vbox1, tr( "Play" ), "mpegplayer/play", mediaPlayerState, SLOT(setPlaying(bool)), TRUE ); 185 new ToolButton( vbox1, tr( "Move Up" ), "mpegplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) );
149 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch 186 new ToolButton( vbox1, tr( "Remove" ), "mpegplayer/cut", d->selectedFiles, SLOT(removeSelected()) );
150#endif 187 new ToolButton( vbox1, tr( "Move Down" ), "mpegplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) );
151 new ToolButton( vbox1, tr( "Move Up" ), "mpegplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); 188 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch
152 new ToolButton( vbox1, tr( "Remove" ), "mpegplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); 189
153 new ToolButton( vbox1, tr( "Move Down" ), "mpegplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); 190 QWidget *aTab;
154 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch 191 aTab = new QWidget( tabWidget, "aTab" );
155#ifndef BUTTONS_ON_TOOLBAR 192 audioView = new QListView( aTab, "Audioview" );
156 d->tbShuffle = new ToolButton( vbox1, tr( "Randomize" ), "mpegplayer/shuffle", mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); 193 audioView->setMinimumSize(233,260);
157#endif 194 audioView->addColumn( "Title",150);
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/card") != -1 ) storage="SD";
208 else storage="RAM";
209
210 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage);
211 newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/musicfile" ));
212 }
213// videowidget
214
215 QWidget *vTab;
216 vTab = new QWidget( tabWidget, "vTab" );
217 videoView = new QListView( vTab, "Videoview" );
218 videoView->setMinimumSize(233,260);
219
220 videoView->addColumn("Title",150);
221 videoView->addColumn("Size",45);
222 videoView->addColumn("Media",35);
223 videoView->setColumnAlignment(1, Qt::AlignRight);
224 videoView->setColumnAlignment(2, Qt::AlignRight);
225
226 tabWidget->insertTab( vTab,"Video");
227
228 Global::findDocuments(&vFiles, "video/*");
229 QListIterator<DocLnk> Vdit( vFiles.children() );
230 for ( ; Vdit.current(); ++Vdit ) {
231 if( Vdit.current()->file().find("/mnt/cf") != -1 ) storage="CF";
232 else if( Vdit.current()->file().find("/mnt/card") != -1 ) storage="SD";
233 else storage="RAM";
234 QListViewItem * newItem;
235 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage);
236 newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/videofile" ));
237 }
238
239
240// d->tbPlay = new ToolButton( vbox1, tr( "Play" ), "mpegplayer/play", mediaPlayerState, SLOT(setPlaying(bool)), TRUE );
241// d->tbShuffle = new ToolButton( vbox1, tr( "Randomize" ), "mpegplayer/shuffle", mediaPlayerState, SLOT(setShuffled(bool)), TRUE );
158 242
159 // add the library area 243 // add the library area
160 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton );
161 244
162 QLabel *libString = new QLabel( tr(" Media Library"), vbox4 ); 245// d->files->setBackgroundMode( PaletteButton );
163 libString->setBackgroundMode( QButton::PaletteButton ); 246// QVBox *vbox7 = new QVBox( hbox6 ); vbox7->setBackgroundMode( PaletteButton );
164 libString->setFont( QFont( "Helvetica", 8, QFont::Bold ) );
165 247
166 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); 248// #ifdef SIDE_BUTTONS
167 d->files = new FileSelector( "video/*;audio/*", hbox6, "Find Media Files", FALSE, FALSE ); 249// QVBox *stretch3 = new QVBox( vbox1 ); stretch3->setBackgroundMode( PaletteButton ); // add stretch
168 d->files->setBackgroundMode( PaletteButton ); 250// #endif
169 QVBox *vbox7 = new QVBox( hbox6 ); vbox7->setBackgroundMode( PaletteButton ); 251 QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold );
252
253// connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) );
254// connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) );
170 255
171#ifdef SIDE_BUTTONS 256 connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
172 new ToolButton( vbox7, tr( "Add to Playlist" ), "mpegplayer/add_to_playlist", d->selectedFiles, SLOT(addSelected()) ); 257 connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
173 new ToolButton( vbox7, tr( "Remove from Playlist" ), "mpegplayer/remove_from_playlist", d->selectedFiles, SLOT(removeSelected()) );
174 QVBox *stretch3 = new QVBox( vbox1 ); stretch3->setBackgroundMode( PaletteButton ); // add stretch
175#endif
176 258
177 connect( d->files, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); 259 connect( audioView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint&, int ) ),
260 this, SLOT( addToSelection( QListViewItem *, const QPoint&, int )) );
261 connect( videoView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint&, int ) ),
262 this, SLOT( addToSelection( QListViewItem *, const QPoint&, int )) );
263
264 connect( playlistView, SIGNAL( pressed( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) );
265 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*)));
266 // connect( d->files, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) );
267 // connect( d->files, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) );
178 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); 268 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) );
179 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); 269 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) );
180 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); 270 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) );
181 connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), d->tbFull, SLOT( setOn( bool ) ) ); 271
182 connect( mediaPlayerState, SIGNAL( scaledToggled( bool ) ), d->tbScale, SLOT( setOn( bool ) ) ); 272// connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), fullScreenButton, SLOT( setOn( bool ) ) );
183 connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), d->tbScale, SLOT( setEnabled( bool ) ) ); 273// connect( mediaPlayerState, SIGNAL( scaledToggled( bool ) ), scaleButton, SLOT( setEnabled( bool ) ) );
274// connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), fullScreenButton, SLOT( setEnabled( bool ) ) );
275
184 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); 276 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) );
185 277
186 setCentralWidget( vbox5 ); 278 setCentralWidget( vbox5 );
187 279
188 Config cfg( "MediaPlayer" ); 280 Config cfg( "MediaPlayer" );
189 readConfig( cfg ); 281 readConfig( cfg );
190 282
191 initializeStates(); 283 initializeStates();
192} 284}
193 285
194 286
195PlayListWidget::~PlayListWidget() { 287PlayListWidget::~PlayListWidget() {
196 Config cfg( "MediaPlayer" ); 288 Config cfg( "MediaPlayer" );
197 writeConfig( cfg ); 289 writeConfig( cfg );
198 290
199 if ( d->current ) 291 if ( d->current )
200 delete d->current; 292 delete d->current;
201 delete d; 293 delete d;
202} 294}
203 295
204 296
205void PlayListWidget::initializeStates() { 297void PlayListWidget::initializeStates() {
298
206 d->tbPlay->setOn( mediaPlayerState->playing() ); 299 d->tbPlay->setOn( mediaPlayerState->playing() );
207 d->tbLoop->setOn( mediaPlayerState->looping() ); 300 d->tbLoop->setOn( mediaPlayerState->looping() );
208 d->tbShuffle->setOn( mediaPlayerState->shuffled() ); 301 d->tbShuffle->setOn( mediaPlayerState->shuffled() );
209 d->tbFull->setOn( mediaPlayerState->fullscreen() ); 302// d->tbFull->setOn( mediaPlayerState->fullscreen() );
210 d->tbScale->setOn( mediaPlayerState->scaled() ); 303// d->tbScale->setOn( mediaPlayerState->scaled() );
211 d->tbScale->setEnabled( mediaPlayerState->fullscreen() ); 304// d->tbScale->setEnabled( mediaPlayerState->fullscreen() );
212 setPlaylist( mediaPlayerState->playlist() ); 305// setPlaylist( mediaPlayerState->playlist() );
213} 306}
214 307
215 308
216void PlayListWidget::readConfig( Config& cfg ) { 309void PlayListWidget::readConfig( Config& cfg ) {
217 cfg.setGroup("PlayList"); 310 cfg.setGroup("PlayList");
218 311
219 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 312 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
220 313
221 for ( int i = 0; i < noOfFiles; i++ ) { 314 for ( int i = 0; i < noOfFiles; i++ ) {
222 QString entryName; 315 QString entryName;
223 entryName.sprintf( "File%i", i + 1 ); 316 entryName.sprintf( "File%i", i + 1 );
224 QString linkFile = cfg.readEntry( entryName ); 317 QString linkFile = cfg.readEntry( entryName );
225 DocLnk lnk( linkFile ); 318 DocLnk lnk( linkFile );
226 if ( lnk.isValid() ) 319 if ( lnk.isValid() )
227 d->selectedFiles->addToSelection( lnk ); 320 d->selectedFiles->addToSelection( lnk );
228 321
229 } 322 }
230} 323}
231 324
232 325
233void PlayListWidget::writeConfig( Config& cfg ) const { 326void PlayListWidget::writeConfig( Config& cfg ) const {
234 cfg.setGroup("PlayList"); 327 cfg.setGroup("PlayList");
235 328
236 int noOfFiles = 0; 329 int noOfFiles = 0;
237 330
238 d->selectedFiles->first(); 331 d->selectedFiles->first();
239 do { 332 do {
240 const DocLnk *lnk = d->selectedFiles->current(); 333 const DocLnk *lnk = d->selectedFiles->current();
241 if ( lnk ) { 334 if ( lnk ) {
242 QString entryName; 335 QString entryName;
243 entryName.sprintf( "File%i", noOfFiles + 1 ); 336 entryName.sprintf( "File%i", noOfFiles + 1 );
244 cfg.writeEntry( entryName, lnk->linkFile() ); 337 cfg.writeEntry( entryName, lnk->linkFile() );
245 // if this link does exist, add it so we have the file 338 // if this link does exist, add it so we have the file
246 // next time... 339 // next time...
247 if ( !QFile::exists( lnk->linkFile() ) ) { 340 if ( !QFile::exists( lnk->linkFile() ) ) {
248 // the way writing lnks doesn't really check for out 341 // the way writing lnks doesn't really check for out
249 // of disk space, but check it anyway. 342 // of disk space, but check it anyway.
250 if ( !lnk->writeLink() ) { 343 if ( !lnk->writeLink() ) {
251 QMessageBox::critical( 0, tr("Out of space"), 344 QMessageBox::critical( 0, tr("Out of space"),
252 tr( "There was a problem saving " 345 tr( "There was a problem saving "
253 "the playlist.\n" 346 "the playlist.\n"
254 "Your playlist " 347 "Your playlist "
255 "may be missing some entries\n" 348 "may be missing some entries\n"
256 "the next time you start it." ) 349 "the next time you start it." )
257 ); 350 );
258 } 351 }
259 } 352 }
260 noOfFiles++; 353 noOfFiles++;
261 } 354 }
262 } while ( d->selectedFiles->next() ); 355 } while ( d->selectedFiles->next() );
263 356
264 cfg.writeEntry("NumberOfFiles", noOfFiles ); 357 cfg.writeEntry("NumberOfFiles", noOfFiles );
265} 358}
266 359
267 360
268void PlayListWidget::addToSelection( const DocLnk& lnk ) { 361void PlayListWidget::addToSelection( const DocLnk& lnk ) {
269 d->setDocumentUsed = FALSE; 362 d->setDocumentUsed = FALSE;
270 if ( mediaPlayerState->playlist() ) 363 if ( mediaPlayerState->playlist() )
271 d->selectedFiles->addToSelection( lnk ); 364 d->selectedFiles->addToSelection( lnk );
272 else 365 else
273 mediaPlayerState->setPlaying( TRUE ); 366 mediaPlayerState->setPlaying( TRUE );
367}
368
369
370void PlayListWidget::addToSelection( QListViewItem *it ,const QPoint & p, int index) {
371 qDebug("add");
372// d->selectedFiles->addToSelection( lnk );
373 // }
374// else
375// mediaPlayerState->setPlaying( TRUE );
376//
274} 377}
275 378
276 379
277void PlayListWidget::clearList() { 380void PlayListWidget::clearList() {
278 while ( first() ) 381 while ( first() )
279 d->selectedFiles->removeSelected(); 382 d->selectedFiles->removeSelected();
280} 383}
281 384
282 385
283void PlayListWidget::addAllToList() { 386void PlayListWidget::addAllToList() {
284 DocLnkSet files; 387 DocLnkSet files;
285 Global::findDocuments(&files, "video/*;audio/*"); 388 Global::findDocuments(&files, "video/*;audio/*");
286 QListIterator<DocLnk> dit( files.children() ); 389 QListIterator<DocLnk> dit( files.children() );
287 for ( ; dit.current(); ++dit ) 390 for ( ; dit.current(); ++dit )
288 d->selectedFiles->addToSelection( **dit ); 391 d->selectedFiles->addToSelection( **dit );
289} 392}
290 393
291 394
292void PlayListWidget::addAllMusicToList() { 395void PlayListWidget::addAllMusicToList() {
293 DocLnkSet files; 396 DocLnkSet files;
294 Global::findDocuments(&files, "audio/*"); 397 Global::findDocuments(&files, "audio/*");
295 QListIterator<DocLnk> dit( files.children() ); 398 QListIterator<DocLnk> dit( files.children() );
296 for ( ; dit.current(); ++dit ) 399 for ( ; dit.current(); ++dit )
297 d->selectedFiles->addToSelection( **dit ); 400 d->selectedFiles->addToSelection( **dit );
298} 401}
299 402
300 403
301void PlayListWidget::addAllVideoToList() { 404void PlayListWidget::addAllVideoToList() {
302 DocLnkSet files; 405 DocLnkSet files;
303 Global::findDocuments(&files, "video/*"); 406 Global::findDocuments(&files, "video/*");
304 QListIterator<DocLnk> dit( files.children() ); 407 QListIterator<DocLnk> dit( files.children() );
305 for ( ; dit.current(); ++dit ) 408 for ( ; dit.current(); ++dit )
306 d->selectedFiles->addToSelection( **dit ); 409 d->selectedFiles->addToSelection( **dit );
307} 410}
308 411
309 412
310void PlayListWidget::setDocument(const QString& fileref) { 413void PlayListWidget::setDocument(const QString& fileref) {
311 if ( fileref.isNull() ) { 414 if ( fileref.isNull() ) {
312 QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); 415 QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) );
313 return; 416 return;
314 } 417 }
315 if ( mediaPlayerState->playlist() ) 418 if ( mediaPlayerState->playlist() )
316 addToSelection( DocLnk( fileref ) ); 419 addToSelection( DocLnk( fileref ) );
317 else { 420 else {
318 d->setDocumentUsed = TRUE; 421 d->setDocumentUsed = TRUE;
319 if ( d->current ) 422 if ( d->current )
320 delete d->current; 423 delete d->current;
321 d->current = new DocLnk( fileref ); 424 d->current = new DocLnk( fileref );
322 } 425 }
323 mediaPlayerState->setPlaying( FALSE ); 426 mediaPlayerState->setPlaying( FALSE );
324 mediaPlayerState->setPlaying( TRUE ); 427 mediaPlayerState->setPlaying( TRUE );
325} 428}
326 429
327 430
328void PlayListWidget::setActiveWindow() { 431void PlayListWidget::setActiveWindow() {
329 // When we get raised we need to ensure that it switches views 432 // When we get raised we need to ensure that it switches views
330 char origView = mediaPlayerState->view(); 433 char origView = mediaPlayerState->view();
331 mediaPlayerState->setView( 'l' ); // invalidate 434 mediaPlayerState->setView( 'l' ); // invalidate
332 mediaPlayerState->setView( origView ); // now switch back 435 mediaPlayerState->setView( origView ); // now switch back
333} 436}
334 437
335 438
336void PlayListWidget::useSelectedDocument() { 439void PlayListWidget::useSelectedDocument() {
337 d->setDocumentUsed = FALSE; 440 d->setDocumentUsed = FALSE;
338} 441}
339 442
340 443
341const DocLnk *PlayListWidget::current() { 444const DocLnk *PlayListWidget::current() {
342 if ( mediaPlayerState->playlist() ) 445 if ( mediaPlayerState->playlist() )
343 return d->selectedFiles->current(); 446 return d->selectedFiles->current();
344 else if ( d->setDocumentUsed && d->current ) { 447 else if ( d->setDocumentUsed && d->current ) {
345 return d->current; 448 return d->current;
346 } else 449 } else
347 return d->files->selected(); 450 return d->files->selected();
348} 451}
349 452
350 453
351bool PlayListWidget::prev() { 454bool PlayListWidget::prev() {
352 if ( mediaPlayerState->playlist() ) { 455 if ( mediaPlayerState->playlist() ) {
353 if ( mediaPlayerState->shuffled() ) { 456 if ( mediaPlayerState->shuffled() ) {
354 const DocLnk *cur = current(); 457 const DocLnk *cur = current();
355 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); 458 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0));
356 for ( int i = 0; i < j; i++ ) { 459 for ( int i = 0; i < j; i++ ) {
357 if ( !d->selectedFiles->next() ) 460 if ( !d->selectedFiles->next() )
358 d->selectedFiles->first(); 461 d->selectedFiles->first();
359 } 462 }
360 if ( cur == current() ) 463 if ( cur == current() )
361 if ( !d->selectedFiles->next() ) 464 if ( !d->selectedFiles->next() )
362 d->selectedFiles->first(); 465 d->selectedFiles->first();
363 return TRUE; 466 return TRUE;
364 } else { 467 } else {
365 if ( !d->selectedFiles->prev() ) { 468 if ( !d->selectedFiles->prev() ) {
366 if ( mediaPlayerState->looping() ) { 469 if ( mediaPlayerState->looping() ) {
367 return d->selectedFiles->last(); 470 return d->selectedFiles->last();
368 } else { 471 } else {
369 return FALSE; 472 return FALSE;
370 } 473 }
371 } 474 }
372 return TRUE; 475 return TRUE;
373 } 476 }
374 } else { 477 } else {
375 return mediaPlayerState->looping(); 478 return mediaPlayerState->looping();
376 } 479 }
377} 480}
378 481
379 482
380bool PlayListWidget::next() { 483bool PlayListWidget::next() {
381 if ( mediaPlayerState->playlist() ) { 484 if ( mediaPlayerState->playlist() ) {
382 if ( mediaPlayerState->shuffled() ) { 485 if ( mediaPlayerState->shuffled() ) {
383 return prev(); 486 return prev();
384 } else { 487 } else {
385 if ( !d->selectedFiles->next() ) { 488 if ( !d->selectedFiles->next() ) {
386 if ( mediaPlayerState->looping() ) { 489 if ( mediaPlayerState->looping() ) {
387 return d->selectedFiles->first(); 490 return d->selectedFiles->first();
388 } else {
389 return FALSE;
390 }
391 }
392 return TRUE;
393 }
394 } else { 491 } else {
395 return mediaPlayerState->looping(); 492 return FALSE;
493 }
494 }
495 return TRUE;
496 }
497 } else {
498 return mediaPlayerState->looping();
396 } 499 }
397} 500}
398 501
399 502
400bool PlayListWidget::first() { 503bool PlayListWidget::first() {
401 if ( mediaPlayerState->playlist() ) 504 if ( mediaPlayerState->playlist() )
402 return d->selectedFiles->first(); 505 return d->selectedFiles->first();
403 else 506 else
404 return mediaPlayerState->looping(); 507 return mediaPlayerState->looping();
405} 508}
406 509
407 510
408bool PlayListWidget::last() { 511bool PlayListWidget::last() {
409 if ( mediaPlayerState->playlist() ) 512 if ( mediaPlayerState->playlist() )
410 return d->selectedFiles->last(); 513 return d->selectedFiles->last();
411 else 514 else
412 return mediaPlayerState->looping(); 515 return mediaPlayerState->looping();
413} 516}
414 517
415 518
416void PlayListWidget::saveList() { 519void PlayListWidget::saveList() {
417 QString filename; 520 QString filename;
418// pseudo code 521// pseudo code
419// filename = QLineEdit->getText(); 522// filename = QLineEdit->getText();
420 Config cfg( filename + ".playlist" ); 523 Config cfg( filename + ".playlist" );
421 writeConfig( cfg ); 524 writeConfig( cfg );
422} 525}
423 526
424 527
425void PlayListWidget::loadList() { 528void PlayListWidget::loadList() {
426 QString filename; 529 QString filename;
427// pseudo code 530// pseudo code
428// filename = FileSelector->openFile( "*.playlist" ); 531// filename = FileSelector->openFile( "*.playlist" );
429 Config cfg( filename + ".playlist" ); 532 Config cfg( filename + ".playlist" );
430 readConfig( cfg ); 533 readConfig( cfg );
431} 534}
432 535
433 536
434void PlayListWidget::setPlaylist( bool shown ) { 537void PlayListWidget::setPlaylist( bool shown ) {
435 if ( shown ) 538 if ( shown )
436 d->playListFrame->show(); 539 d->playListFrame->show();
437 else 540 else
438 d->playListFrame->hide(); 541 d->playListFrame->hide();
439} 542}
440 543
441 544
442void PlayListWidget::setView( char view ) { 545void PlayListWidget::setView( char view ) {
443 if ( view == 'l' ) 546 if ( view == 'l' )
444 showMaximized(); 547 showMaximized();
445 else 548 else
446 hide(); 549 hide();
550}
551
552void PlayListWidget::addSelected() {
553// QMessageBox::message("Note","Bozo the clown thinks\nthere's something actually here");
554 int tabPage=tabWidget->currentPageIndex();
555 switch (tabPage) {
556 case 0: //playlist
557 break;
558 case 1: { //audio
559 addToSelection( audioView->selectedItem() );
560 }
561 break;
562 case 2: { // video
563 addToSelection( videoView->selectedItem() );
564 }
565 break;
566 };
567}
568
569void PlayListWidget::removeSelected() {
570 d->selectedFiles->removeSelected( );
571}
572
573
574void PlayListWidget::playIt( QListViewItem *it) {
575 d->setDocumentUsed = FALSE;
576
577 if(it) {
578 qDebug("playit");
579 int tabPage=tabWidget->currentPageIndex();
580 switch (tabPage) {
581 case 1: {
582 DocLnkSet files;
583 QListIterator<DocLnk> dit( files.children() );
584 for ( ; dit.current(); ++dit ) {
585 if( dit.current()->name() == it->text(0)) {
586 setDocument( dit.current()->name());
587 }
588 }
589 }
590 break;
591 case 2: {
592 DocLnkSet vFiles;
593 QListIterator<DocLnk> dit( vFiles.children() );
594 for ( ; dit.current(); ++dit ) {
595 qDebug(dit.current()->name());
596 if( dit.current()->name() == it->text(0)) {
597 qDebug(it->text(0));
598 setDocument( dit.current()->name());
599 }
600 }
601 }
602 break;
603 };
604 }
605}
606
607void PlayListWidget::addToSelection( QListViewItem *it) {
608 d->setDocumentUsed = FALSE;
609
610 if(it) {
611 qDebug("add to selection");
612 int tabPage=tabWidget->currentPageIndex();
613 switch (tabPage) {
614 case 1: {
615 QListIterator<DocLnk> dit( files.children() );
616 for ( ; dit.current(); ++dit ) {
617 if( dit.current()->name() == it->text(0)) {
618 d->selectedFiles->addToSelection( **dit );
619 }
620 }
621 }
622 break;
623 case 2: {
624 QListIterator<DocLnk> dit( vFiles.children() );
625 for ( ; dit.current(); ++dit ) {
626 qDebug(dit.current()->name());
627 if( dit.current()->name() == it->text(0)) {
628 d->selectedFiles->addToSelection( **dit );
629 }
630 }
631 }
632 break;
633 case 0:
634 break;
635 };
636 tabWidget->setCurrentPage(0);
637// mediaPlayerState->setPlaying( TRUE );
638 }
639}
640
641void PlayListWidget::tabChanged(QWidget *widg) {
642
643 int tabPage=tabWidget->currentPageIndex();
644 switch (tabPage) {
645 case 0:
646 {
647 d->tbRemoveFromList->setEnabled(TRUE);
648 d->tbAddToList->setEnabled(FALSE);
649 }
650 break;
651 case 1:
652 {
653 d->tbRemoveFromList->setEnabled(FALSE);
654 d->tbAddToList->setEnabled(TRUE);
655 }
656 break;
657 case 2:
658 {
659 d->tbRemoveFromList->setEnabled(FALSE);
660 d->tbAddToList->setEnabled(TRUE);
661 }
662 break;
663 };
664}
665
666void PlayListWidget::cancelMenuTimer() {
667 if( menuTimer->isActive() )
668 menuTimer->stop();
669}
670
671void PlayListWidget::showFileMenu() {
672
673}
674
675void PlayListWidget::contentsMousePressEvent( QMouseEvent * e )
676{
677// QListView::contentsMousePressEvent( e );
678 menuTimer->start( 750, TRUE );
679}
680
681
682void PlayListWidget::contentsMouseReleaseEvent( QMouseEvent * e )
683{
684// QListView::contentsMouseReleaseEvent( e );
685 menuTimer->stop();
447} 686}
687// void PlayListWidget::setFullScreen() {
688// mediaPlayerState->toggleFullscreen( );
689// }
448 690
691// void PlayListWidget::setScaled() {
692// mediaPlayerState->toggleScaled();
693// }
diff --git a/core/multimedia/opieplayer/playlistwidget.h b/core/multimedia/opieplayer/playlistwidget.h
index 6976641..3a52dd5 100644
--- a/core/multimedia/opieplayer/playlistwidget.h
+++ b/core/multimedia/opieplayer/playlistwidget.h
@@ -1,68 +1,97 @@
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 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 23
24#include <qmainwindow.h> 24#include <qmainwindow.h>
25#include <qpe/applnk.h> 25#include <qpe/applnk.h>
26#include <qtabwidget.h>
27#include <qtimer.h>
26 28
27 29
28class PlayListWidgetPrivate; 30class PlayListWidgetPrivate;
29class Config; 31class Config;
30 32class QListViewItem;
33class QListView;
34class QPoint;
35class QAction;
36class QLabel;
31 37
32class PlayListWidget : public QMainWindow { 38class PlayListWidget : public QMainWindow {
33 Q_OBJECT 39 Q_OBJECT
34public: 40public:
35 PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 ); 41 PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 );
36 ~PlayListWidget(); 42 ~PlayListWidget();
37 43 QTabWidget * tabWidget;
44 QAction *fullScreenButton, *scaleButton;
45 DocLnkSet files;
46 DocLnkSet vFiles;
47 QListView *audioView, *videoView, *playlistView;
48 QLabel *libString;
38 // retrieve the current playlist entry (media file link) 49 // retrieve the current playlist entry (media file link)
39 const DocLnk *current(); 50 const DocLnk *current();
40 void useSelectedDocument(); 51 void useSelectedDocument();
52 QTimer * menuTimer;
41 53
42public slots: 54public slots:
43 void setDocument( const QString& fileref ); 55 void setDocument( const QString& fileref );
44 void addToSelection( const DocLnk& ); // Add a media file to the playlist 56 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
45 void setActiveWindow(); // need to handle this to show the right view 59 void setActiveWindow(); // need to handle this to show the right view
46 void setPlaylist( bool ); // Show/Hide the playlist 60 void setPlaylist( bool ); // Show/Hide the playlist
47 void setView( char ); 61 void setView( char );
48 void clearList(); 62 void clearList();
49 void addAllToList(); 63 void addAllToList();
50 void addAllMusicToList(); 64 void addAllMusicToList();
51 void addAllVideoToList(); 65 void addAllVideoToList();
52 void saveList(); // Save the playlist 66 void saveList(); // Save the playlist
53 void loadList(); // Load a playlist 67 void loadList(); // Load a playlist
68 void playIt( QListViewItem *);
54 bool first(); 69 bool first();
55 bool last(); 70 bool last();
56 bool next(); 71 bool next();
57 bool prev(); 72 bool prev();
73 void addSelected();
74 void removeSelected();
75 void tabChanged(QWidget*);
76/* void setFullScreen(); */
77/* void setScaled(); */
78protected:
79 void contentsMousePressEvent( QMouseEvent * e );
80 void contentsMouseReleaseEvent( QMouseEvent * e );
58 81
59private: 82private:
60 void initializeStates(); 83 void initializeStates();
61 void readConfig( Config& cfg ); 84 void readConfig( Config& cfg );
62 void writeConfig( Config& cfg ) const; 85 void writeConfig( Config& cfg ) const;
63 PlayListWidgetPrivate *d; // Private implementation data 86 PlayListWidgetPrivate *d; // Private implementation data
87
88protected slots:
89 void cancelMenuTimer();
90 void showFileMenu();
91
92
64}; 93};
65 94
66 95
67#endif // PLAY_LIST_WIDGET_H 96#endif // PLAY_LIST_WIDGET_H
68 97
diff --git a/core/multimedia/opieplayer/videowidget.cpp b/core/multimedia/opieplayer/videowidget.cpp
index f3974a0..1f128a4 100644
--- a/core/multimedia/opieplayer/videowidget.cpp
+++ b/core/multimedia/opieplayer/videowidget.cpp
@@ -1,423 +1,423 @@
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 <qpe/resource.h> 20#include <qpe/resource.h>
21#include "mediaplayerplugininterface.h"
21#include <qwidget.h> 22#include <qwidget.h>
22#include <qpainter.h> 23#include <qpainter.h>
23#include <qpixmap.h> 24#include <qpixmap.h>
24#include <qslider.h> 25#include <qslider.h>
25#include <qdrawutil.h> 26#include <qdrawutil.h>
26#include "videowidget.h" 27#include "videowidget.h"
27#include "mediaplayerplugininterface.h"
28#include "mediaplayerstate.h" 28#include "mediaplayerstate.h"
29 29
30 30
31#ifdef Q_WS_QWS 31#ifdef Q_WS_QWS
32# define USE_DIRECT_PAINTER 32# define USE_DIRECT_PAINTER
33# include <qdirectpainter_qws.h> 33# include <qdirectpainter_qws.h>
34# include <qgfxraster_qws.h> 34# include <qgfxraster_qws.h>
35#endif 35#endif
36 36
37 37
38extern MediaPlayerState *mediaPlayerState; 38extern MediaPlayerState *mediaPlayerState;
39 39
40 40
41static const int xo = 2; // movable x offset 41static const int xo = 2; // movable x offset
42static const int yo = 0; // movable y offset 42static const int yo = 0; // movable y offset
43 43
44 44
45struct MediaButton { 45struct MediaButton {
46 int xPos, yPos; 46 int xPos, yPos;
47 bool isToggle, isHeld, isDown; 47 bool isToggle, isHeld, isDown;
48 int controlType; 48 int controlType;
49}; 49};
50 50
51 51
52// Layout information for the videoButtons (and if it is a toggle button or not) 52// Layout information for the videoButtons (and if it is a toggle button or not)
53MediaButton videoButtons[] = { 53MediaButton videoButtons[] = {
54 { 5+0*32+xo, 200+yo, FALSE, FALSE, FALSE, 4 }, // previous 54 { 5+0*32+xo, 200+yo, FALSE, FALSE, FALSE, 4 }, // previous
55 { 5+1*32+xo, 200+yo, FALSE, FALSE, FALSE, 1 }, // stop 55 { 5+1*32+xo, 200+yo, FALSE, FALSE, FALSE, 1 }, // stop
56 { 5+2*32+xo, 200+yo, TRUE, FALSE, FALSE, 0 }, // play 56 { 5+2*32+xo, 200+yo, TRUE, FALSE, FALSE, 0 }, // play
57 { 5+3*32+xo, 200+yo, TRUE, FALSE, FALSE, 2 }, // pause 57 { 5+3*32+xo, 200+yo, TRUE, FALSE, FALSE, 2 }, // pause
58 { 5+4*32+xo, 200+yo, FALSE, FALSE, FALSE, 3 }, // next 58 { 5+4*32+xo, 200+yo, FALSE, FALSE, FALSE, 3 }, // next
59 { 5+5*32+xo, 200+yo, FALSE, FALSE, FALSE, 8 }, // playlist 59 { 5+5*32+xo, 200+yo, FALSE, FALSE, FALSE, 8 }, // playlist
60 { 5+6*32+xo, 200+yo, TRUE, FALSE, FALSE, 9 } // fullscreen 60 { 5+6*32+xo, 200+yo, TRUE, FALSE, FALSE, 9 } // fullscreen
61}; 61};
62 62
63 63
64static const int numButtons = (sizeof(videoButtons)/sizeof(MediaButton)); 64static const int numButtons = (sizeof(videoButtons)/sizeof(MediaButton));
65 65
66 66
67VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : 67VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) :
68 QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { 68 QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) {
69 setCaption( tr("MediaPlayer") ); 69 setCaption( tr("OpiePlayer") );
70 setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/metalFinish" ) ); 70 setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/metalFinish" ) );
71 pixmaps[0] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaButton0a" ) ); 71 pixmaps[0] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaButton0a" ) );
72 pixmaps[1] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaButton0b" ) ); 72 pixmaps[1] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaButton0b" ) );
73 pixmaps[2] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaControls0" ) ); 73 pixmaps[2] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaControls0" ) );
74 currentFrame = new QImage( 220 + 2, 160, (QPixmap::defaultDepth() == 16) ? 16 : 32 ); 74 currentFrame = new QImage( 220 + 2, 160, (QPixmap::defaultDepth() == 16) ? 16 : 32 );
75 75
76 slider = new QSlider( Qt::Horizontal, this ); 76 slider = new QSlider( Qt::Horizontal, this );
77 slider->setMinValue( 0 ); 77 slider->setMinValue( 0 );
78 slider->setMaxValue( 1 ); 78 slider->setMaxValue( 1 );
79 slider->setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/metalFinish" ) ); 79 slider->setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/metalFinish" ) );
80 slider->setFocusPolicy( QWidget::NoFocus ); 80 slider->setFocusPolicy( QWidget::NoFocus );
81 slider->setGeometry( QRect( 7, 250, 220, 20 ) ); 81 slider->setGeometry( QRect( 7, 250, 220, 20 ) );
82 82
83 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 83 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
84 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 84 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
85 85
86 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); 86 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) );
87 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 87 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
88 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 88 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
89 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); 89 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) );
90 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); 90 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) );
91 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); 91 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) );
92 92
93 // Intialise state 93 // Intialise state
94 setLength( mediaPlayerState->length() ); 94 setLength( mediaPlayerState->length() );
95 setPosition( mediaPlayerState->position() ); 95 setPosition( mediaPlayerState->position() );
96 setFullscreen( mediaPlayerState->fullscreen() ); 96 setFullscreen( mediaPlayerState->fullscreen() );
97 setPaused( mediaPlayerState->paused() ); 97 setPaused( mediaPlayerState->paused() );
98 setPlaying( mediaPlayerState->playing() ); 98 setPlaying( mediaPlayerState->playing() );
99} 99}
100 100
101 101
102VideoWidget::~VideoWidget() { 102VideoWidget::~VideoWidget() {
103 for ( int i = 0; i < 3; i++ ) 103 for ( int i = 0; i < 3; i++ )
104 delete pixmaps[i]; 104 delete pixmaps[i];
105 delete currentFrame; 105 delete currentFrame;
106} 106}
107 107
108 108
109static bool videoSliderBeingMoved = FALSE; 109static bool videoSliderBeingMoved = FALSE;
110 110
111 111
112void VideoWidget::sliderPressed() { 112void VideoWidget::sliderPressed() {
113 videoSliderBeingMoved = TRUE; 113 videoSliderBeingMoved = TRUE;
114} 114}
115 115
116 116
117void VideoWidget::sliderReleased() { 117void VideoWidget::sliderReleased() {
118 videoSliderBeingMoved = FALSE; 118 videoSliderBeingMoved = FALSE;
119 if ( slider->width() == 0 ) 119 if ( slider->width() == 0 )
120 return; 120 return;
121 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); 121 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width());
122 mediaPlayerState->setPosition( val ); 122 mediaPlayerState->setPosition( val );
123} 123}
124 124
125 125
126void VideoWidget::setPosition( long i ) { 126void VideoWidget::setPosition( long i ) {
127 updateSlider( i, mediaPlayerState->length() ); 127 updateSlider( i, mediaPlayerState->length() );
128} 128}
129 129
130 130
131void VideoWidget::setLength( long max ) { 131void VideoWidget::setLength( long max ) {
132 updateSlider( mediaPlayerState->position(), max ); 132 updateSlider( mediaPlayerState->position(), max );
133} 133}
134 134
135 135
136void VideoWidget::setView( char view ) { 136void VideoWidget::setView( char view ) {
137 if ( view == 'v' ) { 137 if ( view == 'v' ) {
138 makeVisible(); 138 makeVisible();
139 } else { 139 } else {
140 // Effectively blank the view next time we show it so it looks nicer 140 // Effectively blank the view next time we show it so it looks nicer
141 scaledWidth = 0; 141 scaledWidth = 0;
142 scaledHeight = 0; 142 scaledHeight = 0;
143 hide(); 143 hide();
144 } 144 }
145} 145}
146 146
147 147
148void VideoWidget::updateSlider( long i, long max ) { 148void VideoWidget::updateSlider( long i, long max ) {
149 // Will flicker too much if we don't do this 149 // Will flicker too much if we don't do this
150 if ( max == 0 ) 150 if ( max == 0 )
151 return; 151 return;
152 int width = slider->width(); 152 int width = slider->width();
153 int val = int((double)i * width / max); 153 int val = int((double)i * width / max);
154 if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) { 154 if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) {
155 if ( slider->value() != val ) 155 if ( slider->value() != val )
156 slider->setValue( val ); 156 slider->setValue( val );
157 if ( slider->maxValue() != width ) 157 if ( slider->maxValue() != width )
158 slider->setMaxValue( width ); 158 slider->setMaxValue( width );
159 } 159 }
160} 160}
161 161
162 162
163void VideoWidget::setToggleButton( int i, bool down ) { 163void VideoWidget::setToggleButton( int i, bool down ) {
164 if ( down != videoButtons[i].isDown ) 164 if ( down != videoButtons[i].isDown )
165 toggleButton( i ); 165 toggleButton( i );
166} 166}
167 167
168 168
169void VideoWidget::toggleButton( int i ) { 169void VideoWidget::toggleButton( int i ) {
170 videoButtons[i].isDown = !videoButtons[i].isDown; 170 videoButtons[i].isDown = !videoButtons[i].isDown;
171 QPainter p(this); 171 QPainter p(this);
172 paintButton ( &p, i ); 172 paintButton ( &p, i );
173} 173}
174 174
175 175
176void VideoWidget::paintButton( QPainter *p, int i ) { 176void VideoWidget::paintButton( QPainter *p, int i ) {
177 int x = videoButtons[i].xPos; 177 int x = videoButtons[i].xPos;
178 int y = videoButtons[i].yPos; 178 int y = videoButtons[i].yPos;
179 int offset = 10 + videoButtons[i].isDown; 179 int offset = 10 + videoButtons[i].isDown;
180 p->drawPixmap( x, y, *pixmaps[videoButtons[i].isDown] ); 180 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 ); 181 p->drawPixmap( x + 1 + offset, y + offset, *pixmaps[2], 9 * videoButtons[i].controlType, 0, 9, 9 );
182} 182}
183 183
184 184
185void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { 185void VideoWidget::mouseMoveEvent( QMouseEvent *event ) {
186 for ( int i = 0; i < numButtons; i++ ) { 186 for ( int i = 0; i < numButtons; i++ ) {
187 int x = videoButtons[i].xPos; 187 int x = videoButtons[i].xPos;
188 int y = videoButtons[i].yPos; 188 int y = videoButtons[i].yPos;
189 if ( event->state() == QMouseEvent::LeftButton ) { 189 if ( event->state() == QMouseEvent::LeftButton ) {
190 // The test to see if the mouse click is inside the circular button or not 190 // 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) 191 // (compared with the radius squared to avoid a square-root of our distance)
192 int radius = 16; 192 int radius = 16;
193 QPoint center = QPoint( x + radius, y + radius ); 193 QPoint center = QPoint( x + radius, y + radius );
194 QPoint dXY = center - event->pos(); 194 QPoint dXY = center - event->pos();
195 int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y(); 195 int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y();
196 bool isOnButton = dist <= (radius * radius); 196 bool isOnButton = dist <= (radius * radius);
197 if ( isOnButton != videoButtons[i].isHeld ) { 197 if ( isOnButton != videoButtons[i].isHeld ) {
198 videoButtons[i].isHeld = isOnButton; 198 videoButtons[i].isHeld = isOnButton;
199 toggleButton(i); 199 toggleButton(i);
200 } 200 }
201 } else { 201 } else {
202 if ( videoButtons[i].isHeld ) { 202 if ( videoButtons[i].isHeld ) {
203 videoButtons[i].isHeld = FALSE; 203 videoButtons[i].isHeld = FALSE;
204 if ( !videoButtons[i].isToggle ) 204 if ( !videoButtons[i].isToggle )
205 setToggleButton( i, FALSE ); 205 setToggleButton( i, FALSE );
206 switch (i) { 206 switch (i) {
207 case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return; 207 case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return;
208 case VideoStop: mediaPlayerState->setPlaying(FALSE); return; 208 case VideoStop: mediaPlayerState->setPlaying(FALSE); return;
209 case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return; 209 case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return;
210 case VideoNext: mediaPlayerState->setNext(); return; 210 case VideoNext: mediaPlayerState->setNext(); return;
211 case VideoPrevious: mediaPlayerState->setPrev(); return; 211 case VideoPrevious: mediaPlayerState->setPrev(); return;
212 case VideoPlayList: mediaPlayerState->setList(); return; 212 case VideoPlayList: mediaPlayerState->setList(); return;
213 case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; 213 case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return;
214 } 214 }
215 } 215 }
216 } 216 }
217 } 217 }
218} 218}
219 219
220 220
221void VideoWidget::mousePressEvent( QMouseEvent *event ) { 221void VideoWidget::mousePressEvent( QMouseEvent *event ) {
222 mouseMoveEvent( event ); 222 mouseMoveEvent( event );
223} 223}
224 224
225 225
226void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { 226void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) {
227 if ( mediaPlayerState->fullscreen() ) { 227 if ( mediaPlayerState->fullscreen() ) {
228 mediaPlayerState->setFullscreen( FALSE ); 228 mediaPlayerState->setFullscreen( FALSE );
229 makeVisible(); 229 makeVisible();
230 } else { 230 } else {
231 mouseMoveEvent( event ); 231 mouseMoveEvent( event );
232 } 232 }
233} 233}
234 234
235 235
236void VideoWidget::makeVisible() { 236void VideoWidget::makeVisible() {
237 if ( mediaPlayerState->fullscreen() ) { 237 if ( mediaPlayerState->fullscreen() ) {
238 setBackgroundMode( QWidget::NoBackground ); 238 setBackgroundMode( QWidget::NoBackground );
239 showFullScreen(); 239 showFullScreen();
240 resize( qApp->desktop()->size() ); 240 resize( qApp->desktop()->size() );
241 slider->hide(); 241 slider->hide();
242 } else { 242 } else {
243 setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/metalFinish" ) ); 243 setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/metalFinish" ) );
244 showNormal(); 244 showNormal();
245 showMaximized(); 245 showMaximized();
246 slider->show(); 246 slider->show();
247 } 247 }
248} 248}
249 249
250 250
251void VideoWidget::paintEvent( QPaintEvent * ) { 251void VideoWidget::paintEvent( QPaintEvent * ) {
252 QPainter p( this ); 252 QPainter p( this );
253 253
254 if ( mediaPlayerState->fullscreen() ) { 254 if ( mediaPlayerState->fullscreen() ) {
255 // Clear the background 255 // Clear the background
256 p.setBrush( QBrush( Qt::black ) ); 256 p.setBrush( QBrush( Qt::black ) );
257 p.drawRect( rect() ); 257 p.drawRect( rect() );
258 258
259 // Draw the current frame 259 // Draw the current frame
260 //p.drawImage( ); // If using directpainter we won't have a copy except whats on the screen 260 //p.drawImage( ); // If using directpainter we won't have a copy except whats on the screen
261 } else { 261 } else {
262 // draw border 262 // draw border
263 qDrawShadePanel( &p, 4, 15, 230, 170, colorGroup(), TRUE, 5, NULL ); 263 qDrawShadePanel( &p, 4, 15, 230, 170, colorGroup(), TRUE, 5, NULL );
264 264
265 // Clear the movie screen first 265 // Clear the movie screen first
266 p.setBrush( QBrush( Qt::black ) ); 266 p.setBrush( QBrush( Qt::black ) );
267 p.drawRect( 9, 20, 220, 160 ); 267 p.drawRect( 9, 20, 220, 160 );
268 268
269 // draw current frame (centrally positioned from scaling to maintain aspect ratio) 269 // 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 ); 270 p.drawImage( 9 + (220 - scaledWidth) / 2, 20 + (160 - scaledHeight) / 2, *currentFrame, 0, 0, scaledWidth, scaledHeight );
271 271
272 // draw the buttons 272 // draw the buttons
273 for ( int i = 0; i < numButtons; i++ ) 273 for ( int i = 0; i < numButtons; i++ )
274 paintButton( &p, i ); 274 paintButton( &p, i );
275 275
276 // draw the slider 276 // draw the slider
277 slider->repaint( TRUE ); 277 slider->repaint( TRUE );
278 } 278 }
279} 279}
280 280
281 281
282void VideoWidget::closeEvent( QCloseEvent* ) { 282void VideoWidget::closeEvent( QCloseEvent* ) {
283 mediaPlayerState->setList(); 283 mediaPlayerState->setList();
284} 284}
285 285
286 286
287bool VideoWidget::playVideo() { 287bool VideoWidget::playVideo() {
288 bool result = FALSE; 288 bool result = FALSE;
289 289
290 int stream = 0; 290 int stream = 0;
291 291
292 int sw = mediaPlayerState->curDecoder()->videoWidth( stream ); 292 int sw = mediaPlayerState->curDecoder()->videoWidth( stream );
293 int sh = mediaPlayerState->curDecoder()->videoHeight( stream ); 293 int sh = mediaPlayerState->curDecoder()->videoHeight( stream );
294 int dd = QPixmap::defaultDepth(); 294 int dd = QPixmap::defaultDepth();
295 int w = height(); 295 int w = height();
296 int h = width(); 296 int h = width();
297 297
298 ColorFormat format = (dd == 16) ? RGB565 : BGRA8888; 298 ColorFormat format = (dd == 16) ? RGB565 : BGRA8888;
299 299
300 if ( mediaPlayerState->fullscreen() ) { 300 if ( mediaPlayerState->fullscreen() ) {
301#ifdef USE_DIRECT_PAINTER 301#ifdef USE_DIRECT_PAINTER
302 QDirectPainter p(this); 302 QDirectPainter p(this);
303 303
304 if ( ( qt_screen->transformOrientation() == 3 ) && 304 if ( ( qt_screen->transformOrientation() == 3 ) &&
305 ( ( dd == 16 ) || ( dd == 32 ) ) && ( p.numRects() == 1 ) ) { 305 ( ( dd == 16 ) || ( dd == 32 ) ) && ( p.numRects() == 1 ) ) {
306 306
307 w = 320; 307 w = 320;
308 h = 240; 308 h = 240;
309 309
310 if ( mediaPlayerState->scaled() ) { 310 if ( mediaPlayerState->scaled() ) {
311 // maintain aspect ratio 311 // maintain aspect ratio
312 if ( w * sh > sw * h ) 312 if ( w * sh > sw * h )
313 w = sw * h / sh; 313 w = sw * h / sh;
314 else 314 else
315 h = sh * w / sw; 315 h = sh * w / sw;
316 } else { 316 } else {
317 w = sw; 317 w = sw;
318 h = sh; 318 h = sh;
319 } 319 }
320 320
321 w--; // we can't allow libmpeg to overwrite. 321 w--; // we can't allow libmpeg to overwrite.
322 QPoint roff = qt_screen->mapToDevice( p.offset(), QSize( qt_screen->width(), qt_screen->height() ) ); 322 QPoint roff = qt_screen->mapToDevice( p.offset(), QSize( qt_screen->width(), qt_screen->height() ) );
323 323
324 int ox = roff.x() - height() + 2 + (height() - w) / 2; 324 int ox = roff.x() - height() + 2 + (height() - w) / 2;
325 int oy = roff.y() + (width() - h) / 2; 325 int oy = roff.y() + (width() - h) / 2;
326 int sx = 0, sy = 0; 326 int sx = 0, sy = 0;
327 327
328 uchar* fp = p.frameBuffer() + p.lineStep() * oy; 328 uchar* fp = p.frameBuffer() + p.lineStep() * oy;
329 fp += dd * ox / 8; 329 fp += dd * ox / 8;
330 uchar **jt = new uchar*[h]; 330 uchar **jt = new uchar*[h];
331 for ( int i = h; i; i-- ) { 331 for ( int i = h; i; i-- ) {
332 jt[h - i] = fp; 332 jt[h - i] = fp;
333 fp += p.lineStep(); 333 fp += p.lineStep();
334 } 334 }
335 335
336 result = mediaPlayerState->curDecoder()->videoReadScaledFrame( jt, sx, sy, sw, sh, w, h, format, 0) == 0; 336 result = mediaPlayerState->curDecoder()->videoReadScaledFrame( jt, sx, sy, sw, sh, w, h, format, 0) == 0;
337 337
338 delete [] jt; 338 delete [] jt;
339 } else { 339 } else {
340#endif 340#endif
341 QPainter p(this); 341 QPainter p(this);
342 342
343 w = 320; 343 w = 320;
344 h = 240; 344 h = 240;
345 345
346 if ( mediaPlayerState->scaled() ) { 346 if ( mediaPlayerState->scaled() ) {
347 // maintain aspect ratio 347 // maintain aspect ratio
348 if ( w * sh > sw * h ) 348 if ( w * sh > sw * h )
349 w = sw * h / sh; 349 w = sw * h / sh;
350 else 350 else
351 h = sh * w / sw; 351 h = sh * w / sw;
352 } else { 352 } else {
353 w = sw; 353 w = sw;
354 h = sh; 354 h = sh;
355 } 355 }
356 356
357 int bytes = ( dd == 16 ) ? 2 : 4; 357 int bytes = ( dd == 16 ) ? 2 : 4;
358 QImage tempFrame( w, h, bytes << 3 ); 358 QImage tempFrame( w, h, bytes << 3 );
359 result = mediaPlayerState->curDecoder()->videoReadScaledFrame( tempFrame.jumpTable(), 359 result = mediaPlayerState->curDecoder()->videoReadScaledFrame( tempFrame.jumpTable(),
360 0, 0, sw, sh, w, h, format, 0) == 0; 360 0, 0, sw, sh, w, h, format, 0) == 0;
361 if ( result && mediaPlayerState->fullscreen() ) { 361 if ( result && mediaPlayerState->fullscreen() ) {
362 362
363 int rw = h, rh = w; 363 int rw = h, rh = w;
364 QImage rotatedFrame( rw, rh, bytes << 3 ); 364 QImage rotatedFrame( rw, rh, bytes << 3 );
365 365
366 ushort* in = (ushort*)tempFrame.bits(); 366 ushort* in = (ushort*)tempFrame.bits();
367 ushort* out = (ushort*)rotatedFrame.bits(); 367 ushort* out = (ushort*)rotatedFrame.bits();
368 int spl = rotatedFrame.bytesPerLine() / bytes; 368 int spl = rotatedFrame.bytesPerLine() / bytes;
369 for (int x=0; x<h; x++) { 369 for (int x=0; x<h; x++) {
370 if ( bytes == 2 ) { 370 if ( bytes == 2 ) {
371 ushort* lout = out++ + (w - 1)*spl; 371 ushort* lout = out++ + (w - 1)*spl;
372 for (int y=0; y<w; y++) { 372 for (int y=0; y<w; y++) {
373 *lout=*in++; 373 *lout=*in++;
374 lout-=spl; 374 lout-=spl;
375 } 375 }
376 } else { 376 } else {
377 ulong* lout = ((ulong *)out)++ + (w - 1)*spl; 377 ulong* lout = ((ulong *)out)++ + (w - 1)*spl;
378 for (int y=0; y<w; y++) { 378 for (int y=0; y<w; y++) {
379 *lout=*((ulong*)in)++; 379 *lout=*((ulong*)in)++;
380 lout-=spl; 380 lout-=spl;
381 } 381 }
382 } 382 }
383 } 383 }
384 384
385 p.drawImage( (240 - rw) / 2, (320 - rh) / 2, rotatedFrame, 0, 0, rw, rh ); 385 p.drawImage( (240 - rw) / 2, (320 - rh) / 2, rotatedFrame, 0, 0, rw, rh );
386 } 386 }
387#ifdef USE_DIRECT_PAINTER 387#ifdef USE_DIRECT_PAINTER
388 } 388 }
389#endif 389#endif
390 } else { 390 } else {
391 391
392 w = 220; 392 w = 220;
393 h = 160; 393 h = 160;
394 394
395 // maintain aspect ratio 395 // maintain aspect ratio
396 if ( w * sh > sw * h ) 396 if ( w * sh > sw * h )
397 w = sw * h / sh; 397 w = sw * h / sh;
398 else 398 else
399 h = sh * w / sw; 399 h = sh * w / sw;
400 400
401 result = mediaPlayerState->curDecoder()->videoReadScaledFrame( currentFrame->jumpTable(), 0, 0, sw, sh, w, h, format, 0) == 0; 401 result = mediaPlayerState->curDecoder()->videoReadScaledFrame( currentFrame->jumpTable(), 0, 0, sw, sh, w, h, format, 0) == 0;
402 402
403 QPainter p( this ); 403 QPainter p( this );
404 404
405 // Image changed size, therefore need to blank the possibly unpainted regions first 405 // Image changed size, therefore need to blank the possibly unpainted regions first
406 if ( scaledWidth != w || scaledHeight != h ) { 406 if ( scaledWidth != w || scaledHeight != h ) {
407 p.setBrush( QBrush( Qt::black ) ); 407 p.setBrush( QBrush( Qt::black ) );
408 p.drawRect( 9, 20, 220, 160 ); 408 p.drawRect( 9, 20, 220, 160 );
409 } 409 }
410 410
411 scaledWidth = w; 411 scaledWidth = w;
412 scaledHeight = h; 412 scaledHeight = h;
413 413
414 if ( result ) { 414 if ( result ) {
415 p.drawImage( 9 + (220 - scaledWidth) / 2, 20 + (160 - scaledHeight) / 2, *currentFrame, 0, 0, scaledWidth, scaledHeight ); 415 p.drawImage( 9 + (220 - scaledWidth) / 2, 20 + (160 - scaledHeight) / 2, *currentFrame, 0, 0, scaledWidth, scaledHeight );
416 } 416 }
417 417
418 } 418 }
419 419
420 return result; 420 return result;
421} 421}
422 422
423 423
diff --git a/core/multimedia/opieplayer/wavplugin/Makefile.in b/core/multimedia/opieplayer/wavplugin/Makefile.in
index bcbe7f2..a46b925 100644
--- a/core/multimedia/opieplayer/wavplugin/Makefile.in
+++ b/core/multimedia/opieplayer/wavplugin/Makefile.in
@@ -1,109 +1,111 @@
1############################################################################# 1#############################################################################
2 2
3####### Compiler, tools and options 3####### Compiler, tools and options
4 4
5 CXX =$(SYSCONF_CXX) $(QT_CXX_MT) 5 CXX =$(SYSCONF_CXX) $(QT_CXX_MT)
6 CXXFLAGS=$(SYSCONF_CXXFLAGS_QT) $(SYSCONF_CXXFLAGS) $(SYSCONF_CXXFLAGS_LIB) 6 CXXFLAGS=$(SYSCONF_CXXFLAGS_QT) $(SYSCONF_CXXFLAGS) $(SYSCONF_CXXFLAGS_LIB)
7 CC =$(SYSCONF_CC) $(QT_C_MT) 7 CC =$(SYSCONF_CC) $(QT_C_MT)
8 CFLAGS =$(SYSCONF_CFLAGS) $(SYSCONF_CFLAGS_LIB) 8 CFLAGS =$(SYSCONF_CFLAGS) $(SYSCONF_CFLAGS_LIB)
9 INCPATH =-I$(OPIEDIR)/include -I.. 9 INCPATH =-I$(OPIEDIR)/include -I..
10 LFLAGS =$(SYSCONF_LFLAGS_QT) $(SYSCONF_RPATH_QT) $(SYSCONF_LFLAGS) $(QT_LFLAGS_MT) 10 LFLAGS =$(SYSCONF_LFLAGS_QT) $(SYSCONF_RPATH_QT) $(SYSCONF_LFLAGS) $(QT_LFLAGS_MT)
11 LIBS =$(SUBLIBS) -lqpe $(SYSCONF_LIBS_QT) $(SYSCONF_LIBS_QTAPP) 11 LIBS =$(SUBLIBS) -lqpe $(SYSCONF_LIBS_QT) $(SYSCONF_LIBS_QTAPP)
12 MOC =$(SYSCONF_MOC) 12 MOC =$(SYSCONF_MOC)
13 UIC =$(SYSCONF_UIC) 13 UIC =$(SYSCONF_UIC)
14 14
15####### Target 15####### Target
16 16
17DESTDIR = ../../plugins/codecs/ 17DESTDIR = ../../plugins/codecs/
18VER_MAJ = 1 18VER_MAJ = 1
19VER_MIN = 0 19VER_MIN = 0
20VER_PATCH = 0 20VER_PATCH = 0
21 TARGET= wavplugin 21 TARGET= wavplugin
22TARGET1 = lib$(TARGET).so.$(VER_MAJ) 22TARGET1 = lib$(TARGET).so.$(VER_MAJ)
23 23
24####### Files 24####### Files
25 25
26 HEADERS =wavplugin.h \ 26 HEADERS =wavplugin.h \
27 wavpluginimpl.h 27 wavpluginimpl.h
28 SOURCES =wavplugin.cpp \ 28 SOURCES =wavplugin.cpp \
29 wavpluginimpl.cpp 29 wavpluginimpl.cpp
30 OBJECTS =wavplugin.o \ 30 OBJECTS =wavplugin.o \
31 wavpluginimpl.o 31 wavpluginimpl.o
32INTERFACES = 32INTERFACES =
33UICDECLS = 33UICDECLS =
34UICIMPLS = 34UICIMPLS =
35 SRCMOC = 35 SRCMOC =
36 OBJMOC = 36 OBJMOC =
37 37
38 38
39####### Implicit rules 39####### Implicit rules
40 40
41.SUFFIXES: .cpp .cxx .cc .C .c 41.SUFFIXES: .cpp .cxx .cc .C .c
42 42
43.cpp.o: 43.cpp.o:
44 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< 44 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
45 45
46.cxx.o: 46.cxx.o:
47 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< 47 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
48 48
49.cc.o: 49.cc.o:
50 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< 50 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
51 51
52.C.o: 52.C.o:
53 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< 53 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
54 54
55.c.o: 55.c.o:
56 $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $< 56 $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $<
57 57
58####### Build rules 58####### Build rules
59 59
60 60
61all: $(DESTDIR)$(SYSCONF_LINK_TARGET) 61all: $(DESTDIR)$(SYSCONF_LINK_TARGET)
62 62
63$(DESTDIR)$(SYSCONF_LINK_TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) $(SUBLIBS) 63$(DESTDIR)$(SYSCONF_LINK_TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) $(SUBLIBS)
64 $(SYSCONF_LINK_LIB) 64 $(SYSCONF_LINK_LIB)
65 65
66moc: $(SRCMOC) 66moc: $(SRCMOC)
67 67
68tmake: 68tmake:
69 tmake wavplugin.pro 69 tmake wavplugin.pro
70 70
71clean: 71clean:
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
78listpromodules: 78listpromodules:
79 @echo 79 @echo
80 80
81listallmodules: 81listallmodules:
82 @echo 82 @echo
83 83
84listaddonpromodules: 84listaddonpromodules:
85 @echo 85 @echo
86 86
87listaddonentmodules: 87listaddonentmodules:
88 @echo 88 @echo
89 89
90 90
91REQUIRES= 91REQUIRES=
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
102wavplugin.o: wavplugin.cpp \ 102wavplugin.o: wavplugin.cpp \
103 wavplugin.h 103 wavplugin.h \
104 ../mediaplayerplugininterface.h
104 105
105wavpluginimpl.o: wavpluginimpl.cpp \ 106wavpluginimpl.o: wavpluginimpl.cpp \
106 wavplugin.h \ 107 wavplugin.h \
108 ../mediaplayerplugininterface.h \
107 wavpluginimpl.h 109 wavpluginimpl.h
108 110
109 111
diff --git a/core/multimedia/opieplayer/wavplugin/wavplugin.cpp b/core/multimedia/opieplayer/wavplugin/wavplugin.cpp
index a6bd974..7f63b3b 100644
--- a/core/multimedia/opieplayer/wavplugin/wavplugin.cpp
+++ b/core/multimedia/opieplayer/wavplugin/wavplugin.cpp
@@ -1,334 +1,341 @@
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
20#include <stdio.h> 22#include <stdio.h>
21#include <stdarg.h> 23#include <stdarg.h>
22#include <stdlib.h> 24#include <stdlib.h>
23#include <errno.h> 25#include <errno.h>
24#include <unistd.h> 26#include <unistd.h>
25#include <qfile.h> 27#include <qfile.h>
26#include "wavplugin.h" 28#include "wavplugin.h"
27 29
28 30
29 //#define debugMsg(a) qDebug(a) 31//#define debugMsg(a) qDebug(a)
30#define debugMsg(a) 32#define debugMsg(a)
31 33
32 34
33struct RiffChunk { 35struct RiffChunk {
34 char id[4]; 36 char id[4];
35 Q_UINT32 size; 37 Q_UINT32 size;
36 char data[4]; 38 char data[4];
37}; 39};
38 40
39 41
40struct ChunkData { 42struct ChunkData {
41 Q_INT16 formatTag; 43 Q_INT16 formatTag;
42 Q_INT16 channels; 44 Q_INT16 channels;
43 Q_INT32 samplesPerSec; 45 Q_INT32 samplesPerSec;
44 Q_INT32 avgBytesPerSec; 46 Q_INT32 avgBytesPerSec;
45 Q_INT16 blockAlign; 47 Q_INT16 blockAlign;
46 Q_INT16 wBitsPerSample; 48 Q_INT16 wBitsPerSample;
47}; 49};
48 50
49 51
50const int sound_buffer_size = 4096; 52const int sound_buffer_size = 512; // 4096; // you got to be kidding right?
51 53
52 54
53class WavPluginData { 55class WavPluginData {
54public: 56public:
55 QFile *input; 57 QFile *input;
56 58
57 int wavedata_remaining; 59 int wavedata_remaining;
58 ChunkData chunkdata; 60 ChunkData chunkdata;
59 RiffChunk chunk; 61 RiffChunk chunk;
60 uchar data[sound_buffer_size+32]; // +32 to handle badly aligned input data 62 uchar data[sound_buffer_size+32]; // +32 to handle badly aligned input data
61 int out,max; 63 int out,max;
62 int samples_due; 64 int samples_due;
63 int samples; 65 int samples;
64 66
65 WavPluginData() { 67 WavPluginData() {
66 max = out = sound_buffer_size; 68 max = out = sound_buffer_size;
67 wavedata_remaining = 0; 69 wavedata_remaining = 0;
68 samples_due = 0; 70 samples_due = 0;
69 samples = -1; 71 samples = -1;
70 } 72 }
71 73
72 // expands out samples to the frequency of 44kHz 74 // expands out samples to the frequency of 44kHz
73 bool add( short *output, long count, long& done, bool stereo ) 75 bool add( short *output, long count, long& done, bool stereo )
74 { 76 {
75 done = 0; 77 done = 0;
78 qApp->processEvents();
76 79
77 if ( input == 0 ) { 80 if ( input == 0 ) {
78 qDebug("no input"); 81 qDebug("no input");
79 return FALSE; 82 return FALSE;
80 } 83 }
81 84
82 while ( count ) { 85 while ( count ) {
83 int l,r; 86 int l,r;
84 if ( getSample(l, r) == FALSE ) { 87 if ( getSample(l, r) == FALSE ) {
85 qDebug("didn't get sample"); 88 qDebug("didn't get sample");
86 return FALSE; 89 return FALSE;
87 } 90 }
88 samples_due += 44100; 91 samples_due += chunkdata.samplesPerSec;
89 while ( count && (samples_due > chunkdata.samplesPerSec) ) { 92 while ( count && (samples_due > chunkdata.samplesPerSec) ) {
90 *output++ = l; 93 *output++ = l;
91 if ( stereo ) 94 if ( stereo )
92 *output++ = r; 95 *output++ = r;
93 samples_due -= chunkdata.samplesPerSec; 96 samples_due -= chunkdata.samplesPerSec;
94 count--; 97 count--;
95 done++; 98 done++;
96 } 99 }
97 } 100 }
98
99 return TRUE; 101 return TRUE;
100 } 102 }
101 103
102 bool initialise() { 104 bool initialise() {
103 if ( input == 0 ) 105 if ( input == 0 )
104 return FALSE; 106 return FALSE;
105 107
106 wavedata_remaining = -1; 108 wavedata_remaining = -1;
107 109
108 while ( wavedata_remaining == -1 ) { 110 while ( wavedata_remaining == -1 ) {
109 // Keep reading chunks... 111 // Keep reading chunks...
110 const int n = sizeof(chunk) - sizeof(chunk.data); 112 const int n = sizeof(chunk) - sizeof(chunk.data);
111 int t = input->readBlock( (char*)&chunk, n ); 113 int t = input->readBlock( (char*)&chunk, n );
112 if ( t != n ) { 114 if ( t != n ) {
113 if ( t == -1 ) 115 if ( t == -1 )
114 return FALSE; 116 return FALSE;
115 return TRUE; 117 return TRUE;
116 } 118 }
117 if ( qstrncmp(chunk.id,"data",4) == 0 ) { 119 if ( qstrncmp(chunk.id,"data",4) == 0 ) {
118 samples = wavedata_remaining = chunk.size; 120 samples = wavedata_remaining = chunk.size;
119 } else if ( qstrncmp(chunk.id,"RIFF",4) == 0 ) { 121 } else if ( qstrncmp(chunk.id,"RIFF",4) == 0 ) {
120 char d[4]; 122 char d[4];
121 if ( input->readBlock(d,4) != 4 ) { 123 if ( input->readBlock(d,4) != 4 ) {
122 return FALSE; 124 return FALSE;
123 } 125 }
124 if ( qstrncmp(d,"WAVE",4) != 0 ) { 126 if ( qstrncmp(d,"WAVE",4) != 0 ) {
125 // skip 127 // skip
126 if ( chunk.size > 1000000000 || !input->at(input->at()+chunk.size-4) ) { 128 if ( chunk.size > 1000000000 || !input->at(input->at()+chunk.size-4) ) {
127 return FALSE; 129 return FALSE;
128 } 130 }
129 } 131 }
130 } else if ( qstrncmp(chunk.id,"fmt ",4) == 0 ) { 132 } else if ( qstrncmp(chunk.id,"fmt ",4) == 0 ) {
131 if ( input->readBlock((char*)&chunkdata,sizeof(chunkdata)) != sizeof(chunkdata) ) { 133 if ( input->readBlock((char*)&chunkdata,sizeof(chunkdata)) != sizeof(chunkdata) ) {
132 return FALSE; 134 return FALSE;
133 } 135 }
134#define WAVE_FORMAT_PCM 1 136#define WAVE_FORMAT_PCM 1
135 if ( chunkdata.formatTag != WAVE_FORMAT_PCM ) { 137 if ( chunkdata.formatTag != WAVE_FORMAT_PCM ) {
136 qDebug("WAV file: UNSUPPORTED FORMAT %d",chunkdata.formatTag); 138 qDebug("WAV file: UNSUPPORTED FORMAT %d",chunkdata.formatTag);
137 return FALSE; 139 return FALSE;
138 } 140 }
139 } else { 141 } else {
140 // ignored chunk 142 // ignored chunk
141 if ( chunk.size > 1000000000 || !input->at(input->at()+chunk.size) ) { 143 if ( chunk.size > 1000000000 || !input->at(input->at()+chunk.size) ) {
142 return FALSE; 144 return FALSE;
143 } 145 }
144 } 146 }
145 } // while 147 } // while
146 148 qDebug("bits %d", chunkdata.wBitsPerSample);
147 return TRUE; 149 return TRUE;
148 } 150 }
149 151
150 152
151 // gets a sample from the file 153 // gets a sample from the file
152 bool getSample(int& l, int& r) 154 bool getSample(int& l, int& r)
153 { 155 {
154 l = r = 0; 156 l = r = 0;
155 157
156 if ( input == 0 ) 158 if ( input == 0 )
157 return FALSE; 159 return FALSE;
158 160
159 if ( (wavedata_remaining < 0) || !max ) 161 if ( (wavedata_remaining < 0) || !max )
160 return FALSE; 162 return FALSE;
161 163
162 if ( out >= max ) { 164 if ( out >= max ) {
163 max = input->readBlock( (char*)data, (uint)QMIN(sound_buffer_size,wavedata_remaining) ); 165 max = input->readBlock( (char*)data, (uint)QMIN(sound_buffer_size,wavedata_remaining) );
164 166
165 wavedata_remaining -= max; 167 wavedata_remaining -= max;
166 168
167 out = 0; 169 out = 0;
168 if ( max <= 0 ) { 170 if ( max <= 0 ) {
169 max = 0; 171 max = 0;
170 return TRUE; 172 return TRUE;
171 } 173 }
172 } 174 }
173 if ( chunkdata.wBitsPerSample == 8 ) { 175 if ( chunkdata.wBitsPerSample == 8 ) {
174 l = (data[out++] - 128) * 128; 176 l = (data[out++] - 128) * 128;
175 } else { 177 } else {
176 l = ((short*)data)[out/2]; 178 l = ((short*)data)[out/2];
177 out += 2; 179 out += 2;
178 } 180 }
179 if ( chunkdata.channels == 1 ) { 181 if ( chunkdata.channels == 1 ) {
180 r = l; 182 r = l;
181 } else { 183 } else {
182 if ( chunkdata.wBitsPerSample == 8 ) { 184 if ( chunkdata.wBitsPerSample == 8 ) {
183 r = (data[out++] - 128) * 128; 185 r = (data[out++] - 128) * 128;
184 } else { 186 } else {
185 r = ((short*)data)[out/2]; 187 r = ((short*)data)[out/2];
186 out += 2; 188 out += 2;
187 } 189 }
188 } 190 }
189 return TRUE; 191 return TRUE;
190 } // getSample 192 } // getSample
191 193
192}; 194};
193 195
194 196
195WavPlugin::WavPlugin() { 197WavPlugin::WavPlugin() {
196 d = new WavPluginData; 198 d = new WavPluginData;
197 d->input = 0; 199 d->input = 0;
198} 200}
199 201
200 202
201WavPlugin::~WavPlugin() { 203WavPlugin::~WavPlugin() {
202 close(); 204 close();
203 delete d; 205 delete d;
204} 206}
205 207
206 208
207bool WavPlugin::isFileSupported( const QString& path ) { 209bool WavPlugin::isFileSupported( const QString& path ) {
208 debugMsg( "WavPlugin::isFileSupported" ); 210// qDebug( "WavPlugin::isFileSupported" );
209 211
210 char *ext = strrchr( path.latin1(), '.' ); 212 char *ext = strrchr( path.latin1(), '.' );
211 213
212 // Test file extension 214 // Test file extension
213 if ( ext ) { 215 if ( ext ) {
214 if ( strncasecmp(ext, ".raw", 4) == 0 ) 216 if ( strncasecmp(ext, ".raw", 4) == 0 )
215 return TRUE; 217 return TRUE;
216 if ( strncasecmp(ext, ".wav", 4) == 0 ) 218 if ( strncasecmp(ext, ".wav", 4) == 0 )
217 return TRUE; 219 return TRUE;
218 if ( strncasecmp(ext, ".wave", 4) == 0 ) 220 if ( strncasecmp(ext, ".wave", 4) == 0 )
219 return TRUE; 221 return TRUE;
220 } 222 }
221 223
222 return FALSE; 224 return FALSE;
223} 225}
224 226
225 227
226bool WavPlugin::open( const QString& path ) { 228bool WavPlugin::open( const QString& path ) {
227 debugMsg( "WavPlugin::open" ); 229// qDebug( "WavPlugin::open" );
228 230
229 d->max = d->out = sound_buffer_size; 231 d->max = d->out = sound_buffer_size;
230 d->wavedata_remaining = 0; 232 d->wavedata_remaining = 0;
231 d->samples_due = 0; 233 d->samples_due = 0;
232 234
233 d->input = new QFile( path ); 235 d->input = new QFile( path );
234 if ( d->input->open(IO_ReadOnly) == FALSE ) { 236 if ( d->input->open(IO_ReadOnly) == FALSE ) {
235 qDebug("couldn't open file"); 237 qDebug("couldn't open file");
236 delete d->input; 238 delete d->input;
237 d->input = 0; 239 d->input = 0;
238 return FALSE; 240 return FALSE;
239 } 241 }
240 242
241 d->initialise(); 243 d->initialise();
242 244
243 return TRUE; 245 return TRUE;
244} 246}
245 247
246 248
247bool WavPlugin::close() { 249bool WavPlugin::close() {
248 debugMsg( "WavPlugin::close" ); 250// qDebug( "WavPlugin::close" );
249 251
250 d->input->close(); 252 d->input->close();
251 delete d->input; 253 delete d->input;
252 d->input = 0; 254 d->input = 0;
253 return TRUE; 255 return TRUE;
254} 256}
255 257
256 258
257bool WavPlugin::isOpen() { 259bool WavPlugin::isOpen() {
258 debugMsg( "WavPlugin::isOpen" ); 260// qDebug( "WavPlugin::isOpen" );
259 return ( d->input != 0 ); 261 return ( d->input != 0 );
260} 262}
261 263
262 264
263int WavPlugin::audioStreams() { 265int WavPlugin::audioStreams() {
264 debugMsg( "WavPlugin::audioStreams" ); 266// qDebug( "WavPlugin::audioStreams" );
265 return 1; 267 return 1;
266} 268}
267 269
268 270
269int WavPlugin::audioChannels( int ) { 271int WavPlugin::audioChannels( int ) {
270 debugMsg( "WavPlugin::audioChannels" ); 272// qDebug( "WavPlugin::audioChannels" );
271 return 2; // ### Always scale audio to stereo samples 273 return d->chunkdata.channels;// 2; // ### Always scale audio to stereo samples
272} 274}
273 275
274 276
275int WavPlugin::audioFrequency( int ) { 277int WavPlugin::audioFrequency( int ) {
276 debugMsg( "WavPlugin::audioFrequency" ); 278// qDebug( "WavPlugin::audioFrequency %d", d->chunkdata.samplesPerSec );
277 return 44100; // ### Always scale to frequency of 44100 279 return d->chunkdata.samplesPerSec; //44100; // ### Always scale to frequency of 44100
278} 280}
279 281
280 282
281int WavPlugin::audioSamples( int ) { 283int WavPlugin::audioSamples( int ) {
282 debugMsg( "WavPlugin::audioSamples" ); 284// qDebug( "WavPlugin::audioSamples" );
283 return d->samples * 2 / d->chunkdata.channels; // ### Scaled samples will be made stereo, 285 return d->samples / d->chunkdata.channels/2; // ### Scaled samples will be made stereo,
284 // Therefore if source is mono we will double the number of samples 286 // Therefore if source is mono we will double the number of samples
285} 287}
286 288
287 289
288bool WavPlugin::audioSetSample( long, int ) { 290bool WavPlugin::audioSetSample( long, int ) {
289 debugMsg( "WavPlugin::audioSetSample" ); 291// qDebug( "WavPlugin::audioSetSample" );
290 return FALSE; 292 return FALSE;
291} 293}
292 294
293 295
294long WavPlugin::audioGetSample( int ) { 296long WavPlugin::audioGetSample( int ) {
295 debugMsg( "WavPlugin::audioGetSample" ); 297// qDebug( "WavPlugin::audioGetSample" );
296 return 0; 298 return 0;
297} 299}
298 300
299/* 301/*
300bool WavPlugin::audioReadSamples( short *, int, long, int ) { 302bool WavPlugin::audioReadSamples( short *, int, long, int ) {
301 debugMsg( "WavPlugin::audioReadSamples" ); 303 debugMsg( "WavPlugin::audioReadSamples" );
302 return FALSE; 304 return FALSE;
303} 305}
304 306
305 307
306bool WavPlugin::audioReReadSamples( short *, int, long, int ) { 308bool WavPlugin::audioReReadSamples( short *, int, long, int ) {
307 debugMsg( "WavPlugin::audioReReadSamples" ); 309 debugMsg( "WavPlugin::audioReReadSamples" );
308 return FALSE; 310 return FALSE;
309} 311}
310 312
311 313
312bool WavPlugin::audioReadMonoSamples( short *output, long samples, long& samplesMade, int ) { 314bool WavPlugin::audioReadMonoSamples( short *output, long samples, long& samplesMade, int ) {
313 debugMsg( "WavPlugin::audioReadMonoSamples" ); 315 debugMsg( "WavPlugin::audioReadMonoSamples" );
314 return !d->add( output, samples, samplesMade, FALSE ); 316 return !d->add( output, samples, samplesMade, FALSE );
315} 317}
316 318
317 319
318bool WavPlugin::audioReadStereoSamples( short *output, long samples, long& samplesMade, int ) { 320bool WavPlugin::audioReadStereoSamples( short *output, long samples, long& samplesMade, int ) {
319 debugMsg( "WavPlugin::audioReadStereoSamples" ); 321 debugMsg( "WavPlugin::audioReadStereoSamples" );
320 return !d->add( output, samples, samplesMade, TRUE ); 322 return !d->add( output, samples, samplesMade, TRUE );
321} 323}
322*/ 324*/
323 325
324bool WavPlugin::audioReadSamples( short *output, int channels, long samples, long& samplesMade, int ) { 326bool WavPlugin::audioReadSamples( short *output, int channels, long samples, long& samplesMade, int ) {
325 debugMsg( "WavPlugin::audioReadSamples" ); 327// qDebug( "WavPlugin::audioReadSamples" );
326 return d->add( output, samples, samplesMade, channels != 1 ); 328 return d->add( output, samples, samplesMade, channels != 1 );
327} 329}
328 330
329double WavPlugin::getTime() { 331double WavPlugin::getTime() {
330 debugMsg( "WavPlugin::getTime" ); 332// qDebug( "WavPlugin::getTime" );
331 return 0.0; 333 return 0.0;
332} 334}
333 335
336int WavPlugin::audioBitsPerSample( int ) {
337// qDebug( "WavPlugin::audioFormat %d", d->chunkdata.wBitsPerSample );
338 return d->chunkdata.wBitsPerSample; //
339}
340
334 341
diff --git a/core/multimedia/opieplayer/wavplugin/wavplugin.h b/core/multimedia/opieplayer/wavplugin/wavplugin.h
index 64635ca..6afd67e 100644
--- a/core/multimedia/opieplayer/wavplugin/wavplugin.h
+++ b/core/multimedia/opieplayer/wavplugin/wavplugin.h
@@ -1,97 +1,107 @@
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
20#ifndef WAV_PLUGIN_H 22#ifndef WAV_PLUGIN_H
21#define WAV_PLUGIN_H 23#define WAV_PLUGIN_H
22 24
23 25
24#include <qstring.h> 26#include <qstring.h>
25#include <qapplication.h> 27#include <qapplication.h>
26#include "mediaplayerplugininterface.h" 28#include "../mediaplayerplugininterface.h"
29
30
31// #define OLD_MEDIAPLAYER_API
27 32
28 33
29class WavPluginData; 34class WavPluginData;
30 35
31 36
32class WavPlugin : public MediaPlayerDecoder { 37class WavPlugin : public MediaPlayerDecoder {
33 38
34public: 39public:
35 WavPlugin(); 40 WavPlugin();
36 ~WavPlugin(); 41 ~WavPlugin();
37 42
38 const char *pluginName() { return "WavPlugin"; } 43 const char *pluginName() { return "WavPlugin"; }
39 const char *pluginComment() { return "This is a simple plugin for playing wav files"; } 44 const char *pluginComment() { return "This is a simple plugin for playing wav files"; }
40 double pluginVersion() { return 1.0; } 45 double pluginVersion() { return 1.0; }
41 46
42 bool isFileSupported( const QString& ); 47 bool isFileSupported( const QString& );
43 bool open( const QString& ); 48 bool open( const QString& );
44 bool close(); 49 bool close();
45 bool isOpen(); 50 bool isOpen();
46 //const QString &fileInfo() { return strInfo = qApp->translate( "MediaPlayer", "No Information Available", "media plugin text" ); } 51 const QString &fileInfo() { return strInfo = ""; }
47 const QString &fileInfo() { return strInfo = QString(""); }
48 52
49 // If decoder doesn't support audio then return 0 here 53 // If decoder doesn't support audio then return 0 here
50 int audioStreams(); 54 int audioStreams();
51 int audioChannels( int stream ); 55 int audioChannels( int stream );
52 int audioFrequency( int stream ); 56 int audioFrequency( int stream );
57 int audioBitsPerSample( int stream );
53 int audioSamples( int stream ); 58 int audioSamples( int stream );
54 bool audioSetSample( long sample, int stream ); 59 bool audioSetSample( long sample, int stream );
55 long audioGetSample( int stream ); 60 long audioGetSample( int stream );
56 //bool audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream ); 61#ifdef OLD_MEDIAPLAYER_API
57 //bool audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream ); 62 bool audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream );
63 bool audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream );
64 bool audioReadSamples( short *output, int channel, long samples, int stream );
65 bool audioReReadSamples( short *output, int channel, long samples, int stream );
66#else
58 bool audioReadSamples( short *output, int channels, long samples, long& samplesRead, int stream ); 67 bool audioReadSamples( short *output, int channels, long samples, long& samplesRead, int stream );
59 //bool audioReadSamples( short *output, int channel, long samples, int stream ); 68#endif
60 //bool audioReReadSamples( short *output, int channel, long samples, int stream );
61 69
62 // If decoder doesn't support video then return 0 here 70 // If decoder doesn't support video then return 0 here
63 int videoStreams() { return 0; } 71 int videoStreams() { return 0; }
64 int videoWidth( int ) { return 0; } 72 int videoWidth( int ) { return 0; }
65 int videoHeight( int ) { return 0; } 73 int videoHeight( int ) { return 0; }
66 double videoFrameRate( int ) { return 0.0; } 74 double videoFrameRate( int ) { return 0.0; }
67 int videoFrames( int ) { return 0; } 75 int videoFrames( int ) { return 0; }
68 bool videoSetFrame( long, int ) { return FALSE; } 76 bool videoSetFrame( long, int ) { return FALSE; }
69 long videoGetFrame( int ) { return 0; } 77 long videoGetFrame( int ) { return 0; }
70 bool videoReadFrame( unsigned char **, int, int, int, int, ColorFormat, int ) { return FALSE; } 78 bool videoReadFrame( unsigned char **, int, int, int, int, ColorFormat, int ) { return FALSE; }
71 bool videoReadScaledFrame( unsigned char **, int, int, int, int, int, int, ColorFormat, int ) { return FALSE; } 79 bool videoReadScaledFrame( unsigned char **, int, int, int, int, int, int, ColorFormat, int ) { return FALSE; }
72 bool videoReadYUVFrame( char *, char *, char *, int, int, int, int, int ) { return FALSE; } 80 bool videoReadYUVFrame( char *, char *, char *, int, int, int, int, int ) { return FALSE; }
73 81
74 // Profiling 82 // Profiling
75 double getTime(); 83 double getTime();
76 84
77 // Ignore if these aren't supported 85 // Ignore if these aren't supported
78 bool setSMP( int ) { return FALSE; } 86 bool setSMP( int ) { return FALSE; }
79 bool setMMX( bool ) { return FALSE; } 87 bool setMMX( bool ) { return FALSE; }
80 88
81 // Capabilities 89 // Capabilities
82 bool supportsAudio() { return TRUE; } 90 bool supportsAudio() { return TRUE; }
83 bool supportsVideo() { return FALSE; } 91 bool supportsVideo() { return FALSE; }
84 bool supportsYUV() { return FALSE; } 92 bool supportsYUV() { return FALSE; }
85 bool supportsMMX() { return TRUE; } 93 bool supportsMMX() { return TRUE; }
86 bool supportsSMP() { return FALSE; } 94 bool supportsSMP() { return FALSE; }
87 bool supportsStereo() { return TRUE; } 95 bool supportsStereo() { return TRUE; }
88 bool supportsScaling() { return FALSE; } 96 bool supportsScaling() { return FALSE; }
89 97
98 long getPlayTime() { return -1; }
99
90private: 100private:
91 WavPluginData *d; 101 WavPluginData *d;
92 QString strInfo; 102 QString strInfo;
93 103
94}; 104};
95 105
96 106
97#endif 107#endif