25 files changed, 505 insertions, 285 deletions
diff --git a/core/multimedia/opieplayer/audiodevice.cpp b/core/multimedia/opieplayer/audiodevice.cpp index 9a10eb4..5fef792 100644 --- a/core/multimedia/opieplayer/audiodevice.cpp +++ b/core/multimedia/opieplayer/audiodevice.cpp | |||
@@ -142,107 +142,108 @@ void AudioDevice::setVolume( unsigned int leftVolume, unsigned int rightVolume, | |||
142 | WAVEFORMATEX formatData; | 142 | WAVEFORMATEX formatData; |
143 | formatData.cbSize = sizeof(WAVEFORMATEX); | 143 | formatData.cbSize = sizeof(WAVEFORMATEX); |
144 | formatData.wFormatTag = WAVE_FORMAT_PCM; | 144 | formatData.wFormatTag = WAVE_FORMAT_PCM; |
145 | formatData.nAvgBytesPerSec = 4 * 44000; | 145 | formatData.nAvgBytesPerSec = 4 * 44000; |
146 | formatData.nBlockAlign = 4; | 146 | formatData.nBlockAlign = 4; |
147 | formatData.nChannels = 2; | 147 | formatData.nChannels = 2; |
148 | formatData.nSamplesPerSec = 44000; | 148 | formatData.nSamplesPerSec = 44000; |
149 | formatData.wBitsPerSample = 16; | 149 | formatData.wBitsPerSample = 16; |
150 | waveOutOpen(&handle, WAVE_MAPPER, &formatData, 0L, 0L, CALLBACK_NULL); | 150 | waveOutOpen(&handle, WAVE_MAPPER, &formatData, 0L, 0L, CALLBACK_NULL); |
151 | unsigned int volume = (rightVolume << 16) | leftVolume; | 151 | unsigned int volume = (rightVolume << 16) | leftVolume; |
152 | if ( waveOutSetVolume( handle, volume ) ) | 152 | if ( waveOutSetVolume( handle, volume ) ) |
153 | // qDebug( "set volume of audio device failed" ); | 153 | // qDebug( "set volume of audio device failed" ); |
154 | waveOutClose( handle ); | 154 | waveOutClose( handle ); |
155 | #else | 155 | #else |
156 | // Volume can be from 0 to 100 which is 101 distinct values | 156 | // Volume can be from 0 to 100 which is 101 distinct values |
157 | unsigned int rV = (rightVolume * 101) >> 16; | 157 | unsigned int rV = (rightVolume * 101) >> 16; |
158 | 158 | ||
159 | # if 0 | 159 | # if 0 |
160 | unsigned int lV = (leftVolume * 101) >> 16; | 160 | unsigned int lV = (leftVolume * 101) >> 16; |
161 | unsigned int volume = ((rV << 8) & 0xFF00) | (lV & 0x00FF); | 161 | unsigned int volume = ((rV << 8) & 0xFF00) | (lV & 0x00FF); |
162 | int mixerHandle = 0; | 162 | int mixerHandle = 0; |
163 | if ( ( mixerHandle = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 163 | if ( ( mixerHandle = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
164 | if(ioctl( mixerHandle, MIXER_WRITE(0), &volume ) ==-1) | 164 | if(ioctl( mixerHandle, MIXER_WRITE(0), &volume ) ==-1) |
165 | perror("ioctl(\"MIXER_WRITE\")"); | 165 | perror("ioctl(\"MIXER_WRITE\")"); |
166 | close( mixerHandle ); | 166 | close( mixerHandle ); |
167 | } else | 167 | } else |
168 | perror("open(\"/dev/mixer\")"); | 168 | perror("open(\"/dev/mixer\")"); |
169 | 169 | ||
170 | # else | 170 | # else |
171 | // This is the way this has to be done now I guess, doesn't allow for | 171 | // This is the way this has to be done now I guess, doesn't allow for |
172 | // independant right and left channel setting, or setting for different outputs | 172 | // independant right and left channel setting, or setting for different outputs |
173 | Config cfg("Sound"); | 173 | Config cfg("Sound"); |
174 | cfg.setGroup("System"); | 174 | cfg.setGroup("System"); |
175 | cfg.writeEntry("Volume",(int)rV); | 175 | cfg.writeEntry("Volume",(int)rV); |
176 | # endif | 176 | # endif |
177 | 177 | ||
178 | #endif | 178 | #endif |
179 | // qDebug( "setting volume to: 0x%x", volume ); | 179 | // qDebug( "setting volume to: 0x%x", volume ); |
180 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) | 180 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) |
181 | // Send notification that the volume has changed | 181 | // Send notification that the volume has changed |
182 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << muted; | 182 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << muted; |
183 | #endif | 183 | #endif |
184 | } | 184 | } |
185 | 185 | ||
186 | 186 | ||
187 | 187 | ||
188 | 188 | ||
189 | AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) { | 189 | AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) { |
190 | d = new AudioDevicePrivate; | 190 | qDebug("creating new audio device"); |
191 | d = new AudioDevicePrivate; | ||
191 | d->frequency = f; | 192 | d->frequency = f; |
192 | d->channels = chs; | 193 | d->channels = chs; |
193 | d->bytesPerSample = bps; | 194 | d->bytesPerSample = bps; |
194 | // qDebug("%d",bps); | 195 | qDebug("%d",bps); |
195 | int format=0; | 196 | int format=0; |
196 | if( bps == 8) format = AFMT_U8; | 197 | if( bps == 8) format = AFMT_U8; |
197 | else if( bps <= 0) format = AFMT_S16_LE; | 198 | else if( bps <= 0) format = AFMT_S16_LE; |
198 | else format = AFMT_S16_LE; | 199 | else format = AFMT_S16_LE; |
199 | 200 | ||
200 | // qDebug("AD- freq %d, channels %d, b/sample %d, bitrate %d",f,chs,bps,format); | 201 | qDebug("AD- freq %d, channels %d, b/sample %d, bitrate %d",f,chs,bps,format); |
201 | connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( volumeChanged(bool) ) ); | 202 | connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( volumeChanged(bool) ) ); |
202 | 203 | ||
203 | 204 | ||
204 | int fragments = 0x10000 * 8 + sound_fragment_shift; | 205 | int fragments = 0x10000 * 8 + sound_fragment_shift; |
205 | int capabilities = 0; | 206 | int capabilities = 0; |
206 | 207 | ||
207 | #ifdef KEEP_DEVICE_OPEN | 208 | #ifdef KEEP_DEVICE_OPEN |
208 | if ( AudioDevicePrivate::dspFd == 0 ) { | 209 | if ( AudioDevicePrivate::dspFd == 0 ) { |
209 | #endif | 210 | #endif |
210 | if ( ( d->handle = ::open( "/dev/dsp", O_WRONLY ) ) < 0 ) { | 211 | if ( ( d->handle = ::open( "/dev/dsp", O_WRONLY ) ) < 0 ) { |
211 | perror("open(\"/dev/dsp\") sending to /dev/null instead"); | 212 | perror("open(\"/dev/dsp\") sending to /dev/null instead"); |
212 | d->handle = ::open( "/dev/null", O_WRONLY ); | 213 | d->handle = ::open( "/dev/null", O_WRONLY ); |
213 | } | 214 | } |
214 | #ifdef KEEP_DEVICE_OPEN | 215 | #ifdef KEEP_DEVICE_OPEN |
215 | AudioDevicePrivate::dspFd = d->handle; | 216 | AudioDevicePrivate::dspFd = d->handle; |
216 | } else { | 217 | } else { |
217 | d->handle = AudioDevicePrivate::dspFd; | 218 | d->handle = AudioDevicePrivate::dspFd; |
218 | } | 219 | } |
219 | #endif | 220 | #endif |
220 | 221 | ||
221 | if(ioctl( d->handle, SNDCTL_DSP_GETCAPS, &capabilities )==-1) | 222 | if(ioctl( d->handle, SNDCTL_DSP_GETCAPS, &capabilities )==-1) |
222 | perror("ioctl(\"SNDCTL_DSP_GETCAPS\")"); | 223 | perror("ioctl(\"SNDCTL_DSP_GETCAPS\")"); |
223 | if(ioctl( d->handle, SNDCTL_DSP_SETFRAGMENT, &fragments )==-1) | 224 | if(ioctl( d->handle, SNDCTL_DSP_SETFRAGMENT, &fragments )==-1) |
224 | perror("ioctl(\"SNDCTL_DSP_SETFRAGMENT\")"); | 225 | perror("ioctl(\"SNDCTL_DSP_SETFRAGMENT\")"); |
225 | if(ioctl( d->handle, SNDCTL_DSP_SETFMT, & format )==-1) | 226 | if(ioctl( d->handle, SNDCTL_DSP_SETFMT, & format )==-1) |
226 | perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); | 227 | perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); |
227 | qDebug("freq %d", d->frequency); | 228 | qDebug("freq %d", d->frequency); |
228 | if(ioctl( d->handle, SNDCTL_DSP_SPEED, &d->frequency )==-1) | 229 | if(ioctl( d->handle, SNDCTL_DSP_SPEED, &d->frequency )==-1) |
229 | perror("ioctl(\"SNDCTL_DSP_SPEED\")"); | 230 | perror("ioctl(\"SNDCTL_DSP_SPEED\")"); |
230 | qDebug("channels %d",d->channels); | 231 | qDebug("channels %d",d->channels); |
231 | if ( ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels ) == -1 ) { | 232 | if ( ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels ) == -1 ) { |
232 | d->channels = ( d->channels == 1 ) ? 2 : d->channels; | 233 | d->channels = ( d->channels == 1 ) ? 2 : d->channels; |
233 | if(ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels )==-1) | 234 | if(ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels )==-1) |
234 | perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); | 235 | perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); |
235 | } | 236 | } |
236 | 237 | ||
237 | d->bufferSize = sound_fragment_bytes; | 238 | d->bufferSize = sound_fragment_bytes; |
238 | d->unwrittenBuffer = new char[d->bufferSize]; | 239 | d->unwrittenBuffer = new char[d->bufferSize]; |
239 | d->unwritten = 0; | 240 | d->unwritten = 0; |
240 | d->can_GETOSPACE = TRUE; // until we find otherwise | 241 | d->can_GETOSPACE = TRUE; // until we find otherwise |
241 | 242 | ||
242 | //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 ); |
243 | //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 ); |
244 | //if ( capabilities & DSP_CAP_BATCH ) qDebug( "Sound card has local buffer" ); | 245 | //if ( capabilities & DSP_CAP_BATCH ) qDebug( "Sound card has local buffer" ); |
245 | //if ( capabilities & DSP_CAP_REALTIME )qDebug( "Sound card has realtime sync" ); | 246 | //if ( capabilities & DSP_CAP_REALTIME )qDebug( "Sound card has realtime sync" ); |
246 | //if ( capabilities & DSP_CAP_TRIGGER ) qDebug( "Sound card has precise trigger" ); | 247 | //if ( capabilities & DSP_CAP_TRIGGER ) qDebug( "Sound card has precise trigger" ); |
247 | //if ( capabilities & DSP_CAP_MMAP ) qDebug( "Sound card can mmap" ); | 248 | //if ( capabilities & DSP_CAP_MMAP ) qDebug( "Sound card can mmap" ); |
248 | } | 249 | } |
diff --git a/core/multimedia/opieplayer/inputDialog.cpp b/core/multimedia/opieplayer/inputDialog.cpp new file mode 100644 index 0000000..b443747 --- a/dev/null +++ b/core/multimedia/opieplayer/inputDialog.cpp | |||
@@ -0,0 +1,45 @@ | |||
1 | /**************************************************************************** | ||
2 | ** Form implementation generated from reading ui file 'inputDialog.ui' | ||
3 | ** | ||
4 | ** Created: Sat Mar 2 07:55:03 2002 | ||
5 | ** by: The User Interface Compiler (uic) | ||
6 | ** | ||
7 | ** WARNING! All changes made in this file will be lost! | ||
8 | ****************************************************************************/ | ||
9 | #include "inputDialog.h" | ||
10 | |||
11 | #include <qlineedit.h> | ||
12 | #include <qlayout.h> | ||
13 | #include <qvariant.h> | ||
14 | #include <qtooltip.h> | ||
15 | #include <qwhatsthis.h> | ||
16 | |||
17 | /* | ||
18 | * Constructs a InputDialog which is a child of 'parent', with the | ||
19 | * name 'name' and widget flags set to 'f' | ||
20 | * | ||
21 | * The dialog will by default be modeless, unless you set 'modal' to | ||
22 | * TRUE to construct a modal dialog. | ||
23 | */ | ||
24 | InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) | ||
25 | : QDialog( parent, name, modal, fl ) | ||
26 | { | ||
27 | if ( !name ) | ||
28 | setName( "InputDialog" ); | ||
29 | resize( 234, 50 ); | ||
30 | setMaximumSize( QSize( 240, 50 ) ); | ||
31 | setCaption( tr(name ) ); | ||
32 | |||
33 | LineEdit1 = new QLineEdit( this, "LineEdit1" ); | ||
34 | LineEdit1->setGeometry( QRect( 10, 10, 216, 22 ) ); | ||
35 | } | ||
36 | |||
37 | /* | ||
38 | * Destroys the object and frees any allocated resources | ||
39 | */ | ||
40 | InputDialog::~InputDialog() | ||
41 | { | ||
42 | inputText= LineEdit1->text(); | ||
43 | |||
44 | } | ||
45 | |||
diff --git a/core/multimedia/opieplayer/inputDialog.h b/core/multimedia/opieplayer/inputDialog.h new file mode 100644 index 0000000..26d5cd0 --- a/dev/null +++ b/core/multimedia/opieplayer/inputDialog.h | |||
@@ -0,0 +1,31 @@ | |||
1 | /**************************************************************************** | ||
2 | ** Form interface generated from reading ui file 'inputDialog.ui' | ||
3 | ** | ||
4 | ** Created: Sat Mar 2 07:54:46 2002 | ||
5 | ** by: The User Interface Compiler (uic) | ||
6 | ** | ||
7 | ** WARNING! All changes made in this file will be lost! | ||
8 | ****************************************************************************/ | ||
9 | #ifndef INPUTDIALOG_H | ||
10 | #define INPUTDIALOG_H | ||
11 | |||
12 | #include <qvariant.h> | ||
13 | #include <qdialog.h> | ||
14 | class QVBoxLayout; | ||
15 | class QHBoxLayout; | ||
16 | class QGridLayout; | ||
17 | class QLineEdit; | ||
18 | |||
19 | class InputDialog : public QDialog | ||
20 | { | ||
21 | Q_OBJECT | ||
22 | |||
23 | public: | ||
24 | InputDialog( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); | ||
25 | ~InputDialog(); | ||
26 | QString inputText; | ||
27 | QLineEdit* LineEdit1; | ||
28 | |||
29 | }; | ||
30 | |||
31 | #endif // INPUTDIALOG_H | ||
diff --git a/core/multimedia/opieplayer/libmad/libmadplugin.h b/core/multimedia/opieplayer/libmad/libmadplugin.h index d163458..b240b77 100644 --- a/core/multimedia/opieplayer/libmad/libmadplugin.h +++ b/core/multimedia/opieplayer/libmad/libmadplugin.h | |||
@@ -1,104 +1,104 @@ | |||
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 | #include <qstring.h> | 23 | #include <qstring.h> |
24 | //#include <qpe/mediaplayerplugininterface.h> | 24 | #include <qpe/mediaplayerplugininterface.h> |
25 | #include "../mediaplayerplugininterface.h" | 25 | /* #include "../mediaplayerplugininterface.h" */ |
26 | 26 | ||
27 | 27 | ||
28 | // #define OLD_MEDIAPLAYER_API | 28 | // #define OLD_MEDIAPLAYER_API |
29 | 29 | ||
30 | 30 | ||
31 | class LibMadPluginData; | 31 | class LibMadPluginData; |
32 | 32 | ||
33 | 33 | ||
34 | class LibMadPlugin : public MediaPlayerDecoder { | 34 | class LibMadPlugin : public MediaPlayerDecoder { |
35 | 35 | ||
36 | public: | 36 | public: |
37 | LibMadPlugin(); | 37 | LibMadPlugin(); |
38 | ~LibMadPlugin(); | 38 | ~LibMadPlugin(); |
39 | 39 | ||
40 | const char *pluginName() { return "LibMadPlugin"; } | 40 | const char *pluginName() { return "LibMadPlugin"; } |
41 | const char *pluginComment() { return "This is the libmad library that has been wrapped as a plugin"; } | 41 | const char *pluginComment() { return "This is the libmad library that has been wrapped as a plugin"; } |
42 | double pluginVersion() { return 1.0; } | 42 | double pluginVersion() { return 1.0; } |
43 | 43 | ||
44 | bool isFileSupported( const QString& ); | 44 | bool isFileSupported( const QString& ); |
45 | bool open( const QString& ); | 45 | bool open( const QString& ); |
46 | bool close(); | 46 | bool close(); |
47 | bool isOpen(); | 47 | bool isOpen(); |
48 | const QString &fileInfo() { return info; } | 48 | const QString &fileInfo() { return info; } |
49 | 49 | ||
50 | // If decoder doesn't support audio then return 0 here | 50 | // If decoder doesn't support audio then return 0 here |
51 | int audioStreams(); | 51 | int audioStreams(); |
52 | int audioChannels( int stream ); | 52 | int audioChannels( int stream ); |
53 | int audioFrequency( int stream ); | 53 | int audioFrequency( int stream ); |
54 | int audioSamples( int stream ); | 54 | int audioSamples( int stream ); |
55 | bool audioSetSample( long sample, int stream ); | 55 | bool audioSetSample( long sample, int stream ); |
56 | int audioBitsPerSample(int) {return 0;} | 56 | /* int audioBitsPerSample(int) {return 0;} */ |
57 | long audioGetSample( int stream ); | 57 | long audioGetSample( int stream ); |
58 | #ifdef OLD_MEDIAPLAYER_API | 58 | #ifdef OLD_MEDIAPLAYER_API |
59 | bool audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream ); | 59 | bool audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream ); |
60 | bool audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream ); | 60 | bool audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream ); |
61 | bool audioReadSamples( short *output, int channel, long samples, int stream ); | 61 | bool audioReadSamples( short *output, int channel, long samples, int stream ); |
62 | bool audioReReadSamples( short *output, int channel, long samples, int stream ); | 62 | bool audioReReadSamples( short *output, int channel, long samples, int stream ); |
63 | #else | 63 | #else |
64 | bool audioReadSamples( short *output, int channels, long samples, long& samplesRead, int stream ); | 64 | bool audioReadSamples( short *output, int channels, long samples, long& samplesRead, int stream ); |
65 | #endif | 65 | #endif |
66 | 66 | ||
67 | 67 | ||
68 | bool read(); | 68 | bool read(); |
69 | bool decode( short *output, long samples, long& samplesRead ); | 69 | bool decode( short *output, long samples, long& samplesRead ); |
70 | void printID3Tags(); | 70 | void printID3Tags(); |
71 | 71 | ||
72 | 72 | ||
73 | // If decoder doesn't support video then return 0 here | 73 | // If decoder doesn't support video then return 0 here |
74 | int videoStreams() { return 0; } | 74 | int videoStreams() { return 0; } |
75 | int videoWidth( int ) { return 0; } | 75 | int videoWidth( int ) { return 0; } |
76 | int videoHeight( int ) { return 0; } | 76 | int videoHeight( int ) { return 0; } |
77 | double videoFrameRate( int ) { return 0.0; } | 77 | double videoFrameRate( int ) { return 0.0; } |
78 | int videoFrames( int ) { return 0; } | 78 | int videoFrames( int ) { return 0; } |
79 | bool videoSetFrame( long, int ) { return FALSE; } | 79 | bool videoSetFrame( long, int ) { return FALSE; } |
80 | long videoGetFrame( int ) { return 0; } | 80 | long videoGetFrame( int ) { return 0; } |
81 | bool videoReadFrame( unsigned char **, int, int, int, int, ColorFormat, int ) { return FALSE; } | 81 | bool videoReadFrame( unsigned char **, int, int, int, int, ColorFormat, int ) { return FALSE; } |
82 | bool videoReadScaledFrame( unsigned char **, int, int, int, int, int, int, ColorFormat, int ) { return FALSE; } | 82 | bool videoReadScaledFrame( unsigned char **, int, int, int, int, int, int, ColorFormat, int ) { return FALSE; } |
83 | bool videoReadYUVFrame( char *, char *, char *, int, int, int, int, int ) { return FALSE; } | 83 | bool videoReadYUVFrame( char *, char *, char *, int, int, int, int, int ) { return FALSE; } |
84 | 84 | ||
85 | // Profiling | 85 | // Profiling |
86 | double getTime(); | 86 | double getTime(); |
87 | 87 | ||
88 | // Ignore if these aren't supported | 88 | // Ignore if these aren't supported |
89 | bool setSMP( int ) { return FALSE; } | 89 | bool setSMP( int ) { return FALSE; } |
90 | bool setMMX( bool ) { return FALSE; } | 90 | bool setMMX( bool ) { return FALSE; } |
91 | 91 | ||
92 | // Capabilities | 92 | // Capabilities |
93 | bool supportsAudio() { return TRUE; } | 93 | bool supportsAudio() { return TRUE; } |
94 | bool supportsVideo() { return FALSE; } | 94 | bool supportsVideo() { return FALSE; } |
95 | bool supportsYUV() { return FALSE; } | 95 | bool supportsYUV() { return FALSE; } |
96 | bool supportsMMX() { return TRUE; } | 96 | bool supportsMMX() { return TRUE; } |
97 | bool supportsSMP() { return FALSE; } | 97 | bool supportsSMP() { return FALSE; } |
98 | bool supportsStereo() { return TRUE; } | 98 | bool supportsStereo() { return TRUE; } |
99 | bool supportsScaling() { return FALSE; } | 99 | bool supportsScaling() { return FALSE; } |
100 | 100 | ||
101 | long getPlayTime() { return -1; } | 101 | long getPlayTime() { return -1; } |
102 | 102 | ||
103 | private: | 103 | private: |
104 | LibMadPluginData *d; | 104 | LibMadPluginData *d; |
diff --git a/core/multimedia/opieplayer/libmad/libmadpluginimpl.cpp b/core/multimedia/opieplayer/libmad/libmadpluginimpl.cpp index 028c658..67779e8 100644 --- a/core/multimedia/opieplayer/libmad/libmadpluginimpl.cpp +++ b/core/multimedia/opieplayer/libmad/libmadpluginimpl.cpp | |||
@@ -1,70 +1,70 @@ | |||
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 "libmadplugin.h" | 20 | #include "libmadplugin.h" |
21 | #include "libmadpluginimpl.h" | 21 | #include "libmadpluginimpl.h" |
22 | 22 | ||
23 | 23 | ||
24 | LibMadPluginImpl::LibMadPluginImpl() | 24 | LibMadPluginImpl::LibMadPluginImpl() |
25 | : libmadplugin(0), ref(0) | 25 | : libmadplugin(0), ref(0) |
26 | { | 26 | { |
27 | } | 27 | } |
28 | 28 | ||
29 | 29 | ||
30 | LibMadPluginImpl::~LibMadPluginImpl() | 30 | LibMadPluginImpl::~LibMadPluginImpl() |
31 | { | 31 | { |
32 | if ( libmadplugin ) | 32 | if ( libmadplugin ) |
33 | delete libmadplugin; | 33 | delete libmadplugin; |
34 | } | 34 | } |
35 | 35 | ||
36 | 36 | ||
37 | MediaPlayerDecoder *LibMadPluginImpl::decoder() | 37 | MediaPlayerDecoder *LibMadPluginImpl::decoder() |
38 | { | 38 | { |
39 | if ( !libmadplugin ) | 39 | if ( !libmadplugin ) |
40 | libmadplugin = new LibMadPlugin; | 40 | libmadplugin = new LibMadPlugin; |
41 | return libmadplugin; | 41 | return libmadplugin; |
42 | } | 42 | } |
43 | 43 | ||
44 | 44 | ||
45 | MediaPlayerEncoder *LibMadPluginImpl::encoder() | 45 | MediaPlayerEncoder *LibMadPluginImpl::encoder() |
46 | { | 46 | { |
47 | return NULL; | 47 | return NULL; |
48 | } | 48 | } |
49 | 49 | ||
50 | 50 | ||
51 | #ifndef QT_NO_COMPONENT | 51 | #ifndef QT_NO_COMPONENT |
52 | 52 | ||
53 | 53 | ||
54 | QRESULT LibMadPluginImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) | 54 | QRESULT LibMadPluginImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) |
55 | { | 55 | { |
56 | *iface = 0; | 56 | *iface = 0; |
57 | if ( ( uuid == IID_QUnknown ) || ( uuid == IID_MediaPlayerPlugin ) ) | 57 | if ( ( uuid == IID_QUnknown ) || ( uuid == IID_MediaPlayerPlugin ) ) |
58 | *iface = this, (*iface)->addRef(); | 58 | *iface = this, (*iface)->addRef(); |
59 | return QS_OK; | 59 | return QS_OK; |
60 | } | 60 | } |
61 | 61 | ||
62 | 62 | ||
63 | Q_EXPORT_INTERFACE() | 63 | Q_EXPORT_INTERFACE() |
64 | { | 64 | { |
65 | Q_CREATE_INSTANCE( LibMadPluginImpl ) | 65 | Q_CREATE_INSTANCE( LibMadPluginImpl ) |
66 | } | 66 | } |
67 | 67 | ||
68 | 68 | ||
69 | #endif | 69 | #endif |
70 | 70 | ||
diff --git a/core/multimedia/opieplayer/libmad/libmadpluginimpl.h b/core/multimedia/opieplayer/libmad/libmadpluginimpl.h index bc864ee..9b35b90 100644 --- a/core/multimedia/opieplayer/libmad/libmadpluginimpl.h +++ b/core/multimedia/opieplayer/libmad/libmadpluginimpl.h | |||
@@ -1,52 +1,52 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef LIBMAD_PLUGIN_IMPL_H | 20 | #ifndef LIBMAD_PLUGIN_IMPL_H |
21 | #define LIBMAD_PLUGIN_IMPL_H | 21 | #define LIBMAD_PLUGIN_IMPL_H |
22 | 22 | ||
23 | //#include <qpe/mediaplayerplugininterface.h> | 23 | #include <qpe/mediaplayerplugininterface.h> |
24 | #include "../mediaplayerplugininterface.h" | 24 | //#include "../mediaplayerplugininterface.h" |
25 | 25 | ||
26 | 26 | ||
27 | class LibMadPlugin; | 27 | class LibMadPlugin; |
28 | 28 | ||
29 | 29 | ||
30 | class LibMadPluginImpl : public MediaPlayerPluginInterface | 30 | class LibMadPluginImpl : public MediaPlayerPluginInterface |
31 | { | 31 | { |
32 | public: | 32 | public: |
33 | LibMadPluginImpl(); | 33 | LibMadPluginImpl(); |
34 | virtual ~LibMadPluginImpl(); | 34 | virtual ~LibMadPluginImpl(); |
35 | 35 | ||
36 | #ifndef QT_NO_COMPONENT | 36 | #ifndef QT_NO_COMPONENT |
37 | 37 | ||
38 | QRESULT queryInterface( const QUuid&, QUnknownInterface** ); | 38 | QRESULT queryInterface( const QUuid&, QUnknownInterface** ); |
39 | Q_REFCOUNT | 39 | Q_REFCOUNT |
40 | 40 | ||
41 | #endif | 41 | #endif |
42 | 42 | ||
43 | virtual MediaPlayerDecoder *decoder(); | 43 | virtual MediaPlayerDecoder *decoder(); |
44 | virtual MediaPlayerEncoder *encoder(); | 44 | virtual MediaPlayerEncoder *encoder(); |
45 | private: | 45 | private: |
46 | LibMadPlugin *libmadplugin; | 46 | LibMadPlugin *libmadplugin; |
47 | ulong ref; | 47 | ulong ref; |
48 | }; | 48 | }; |
49 | 49 | ||
50 | 50 | ||
51 | #endif | 51 | #endif |
52 | 52 | ||
diff --git a/core/multimedia/opieplayer/libmpeg3/libmpeg3plugin.h b/core/multimedia/opieplayer/libmpeg3/libmpeg3plugin.h index bd31706..b573e84 100644 --- a/core/multimedia/opieplayer/libmpeg3/libmpeg3plugin.h +++ b/core/multimedia/opieplayer/libmpeg3/libmpeg3plugin.h | |||
@@ -1,122 +1,121 @@ | |||
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 | #include <qstring.h> | 23 | #include <qstring.h> |
24 | #include <qapplication.h> | 24 | #include <qapplication.h> |
25 | #include "libmpeg3.h" | 25 | #include "libmpeg3.h" |
26 | #include "mpeg3protos.h" | 26 | #include "mpeg3protos.h" |
27 | //#include <qpe/mediaplayerplugininterface.h> | 27 | #include <qpe/mediaplayerplugininterface.h> |
28 | #include "../mediaplayerplugininterface.h" | ||
29 | 28 | ||
30 | 29 | ||
31 | // #define OLD_MEDIAPLAYER_API | 30 | // #define OLD_MEDIAPLAYER_API |
32 | 31 | ||
33 | 32 | ||
34 | class LibMpeg3Plugin : public MediaPlayerDecoder { | 33 | class LibMpeg3Plugin : public MediaPlayerDecoder { |
35 | 34 | ||
36 | public: | 35 | public: |
37 | LibMpeg3Plugin() { file = NULL; } | 36 | LibMpeg3Plugin() { file = NULL; } |
38 | ~LibMpeg3Plugin() { close(); } | 37 | ~LibMpeg3Plugin() { close(); } |
39 | 38 | ||
40 | const char *pluginName() { return "LibMpeg3Plugin"; } | 39 | const char *pluginName() { return "LibMpeg3Plugin"; } |
41 | const char *pluginComment() { return "This is the libmpeg3 library writen by ... which has been modified by trolltech to use fixed point maths"; } | 40 | const char *pluginComment() { return "This is the libmpeg3 library writen by ... which has been modified by trolltech to use fixed point maths"; } |
42 | double pluginVersion() { return 1.0; } | 41 | double pluginVersion() { return 1.0; } |
43 | 42 | ||
44 | bool isFileSupported( const QString& fileName ) { return mpeg3_check_sig( (char *)fileName.latin1() ) == 1; } | 43 | bool isFileSupported( const QString& fileName ) { return mpeg3_check_sig( (char *)fileName.latin1() ) == 1; } |
45 | bool open( const QString& fileName ) { file = mpeg3_open( (char *)fileName.latin1() ); return file != NULL; } | 44 | bool open( const QString& fileName ) { file = mpeg3_open( (char *)fileName.latin1() ); return file != NULL; } |
46 | bool close() { if ( file ) { int r = mpeg3_close( file ); file = NULL; return r == 1; } return FALSE; } | 45 | bool close() { if ( file ) { int r = mpeg3_close( file ); file = NULL; return r == 1; } return FALSE; } |
47 | bool isOpen() { return file != NULL; } | 46 | bool isOpen() { return file != NULL; } |
48 | const QString &fileInfo() { return strInfo = ""; } | 47 | const QString &fileInfo() { return strInfo = ""; } |
49 | 48 | ||
50 | // If decoder doesn't support audio then return 0 here | 49 | // If decoder doesn't support audio then return 0 here |
51 | int audioStreams() { return file ? mpeg3_total_astreams( file ) : 0; } | 50 | int audioStreams() { return file ? mpeg3_total_astreams( file ) : 0; } |
52 | int audioChannels( int stream ) { return file ? mpeg3_audio_channels( file, stream ) : 0; } | 51 | int audioChannels( int stream ) { return file ? mpeg3_audio_channels( file, stream ) : 0; } |
53 | int audioFrequency( int stream ) { return file ? mpeg3_sample_rate( file, stream ) : 0; } | 52 | int audioFrequency( int stream ) { return file ? mpeg3_sample_rate( file, stream ) : 0; } |
54 | int audioBitsPerSample(int) { return 0;} | 53 | /* int audioBitsPerSample(int) { return 0;} */ |
55 | int audioSamples( int stream ) { return file ? mpeg3_audio_samples( file, stream ) : 0; } | 54 | int audioSamples( int stream ) { return file ? mpeg3_audio_samples( file, stream ) : 0; } |
56 | bool audioSetSample( long sample, int stream ) { return file ? mpeg3_set_sample( file, sample, stream) == 1 : FALSE; } | 55 | bool audioSetSample( long sample, int stream ) { return file ? mpeg3_set_sample( file, sample, stream) == 1 : FALSE; } |
57 | long audioGetSample( int stream ) { return file ? mpeg3_get_sample( file, stream ) : 0; } | 56 | long audioGetSample( int stream ) { return file ? mpeg3_get_sample( file, stream ) : 0; } |
58 | #ifdef OLD_MEDIAPLAYER_API | 57 | #ifdef OLD_MEDIAPLAYER_API |
59 | bool audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream ); | 58 | bool audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream ); |
60 | bool audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream ); | 59 | bool audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream ); |
61 | bool audioReadSamples( short *output, int channel, long samples, int stream ); | 60 | bool audioReadSamples( short *output, int channel, long samples, int stream ); |
62 | bool audioReReadSamples( short *output, int channel, long samples, int stream ); | 61 | bool audioReReadSamples( short *output, int channel, long samples, int stream ); |
63 | #else | 62 | #else |
64 | bool audioReadSamples( short *output, int channels, long samples, long& samplesRead, int stream ); | 63 | bool audioReadSamples( short *output, int channels, long samples, long& samplesRead, int stream ); |
65 | #endif | 64 | #endif |
66 | 65 | ||
67 | // If decoder doesn't support video then return 0 here | 66 | // If decoder doesn't support video then return 0 here |
68 | int videoStreams() { return file ? mpeg3_total_vstreams( file ) : 0; } | 67 | int videoStreams() { return file ? mpeg3_total_vstreams( file ) : 0; } |
69 | int videoWidth( int stream ) { return file ? mpeg3_video_width( file, stream ) : 0; } | 68 | int videoWidth( int stream ) { return file ? mpeg3_video_width( file, stream ) : 0; } |
70 | int videoHeight( int stream ) { return file ? mpeg3_video_height( file, stream ) : 0; } | 69 | int videoHeight( int stream ) { return file ? mpeg3_video_height( file, stream ) : 0; } |
71 | double videoFrameRate( int stream ) { return file ? mpeg3_frame_rate( file, stream ) : 0.0; } | 70 | double videoFrameRate( int stream ) { return file ? mpeg3_frame_rate( file, stream ) : 0.0; } |
72 | int videoFrames( int stream ) | 71 | int videoFrames( int stream ) |
73 | { return file ? mpeg3_video_frames( file, stream ) : 0; } | 72 | { return file ? mpeg3_video_frames( file, stream ) : 0; } |
74 | /* | 73 | /* |
75 | { | 74 | { |
76 | if ( file ) { | 75 | if ( file ) { |
77 | int frames = mpeg3_video_frames( file, stream ); | 76 | int frames = mpeg3_video_frames( file, stream ); |
78 | if ( frames == 1 ) { | 77 | if ( frames == 1 ) { |
79 | int res = mpeg3_seek_percentage( file, 0.99 ); | 78 | int res = mpeg3_seek_percentage( file, 0.99 ); |
80 | printf("res: %i\n", res ); | 79 | printf("res: %i\n", res ); |
81 | mpeg3video_seek( file->vtrack[stream]->video ); | 80 | mpeg3video_seek( file->vtrack[stream]->video ); |
82 | frames = mpeg3_get_frame( file, stream ); | 81 | frames = mpeg3_get_frame( file, stream ); |
83 | mpeg3_seek_percentage( file, 0.0 ); | 82 | mpeg3_seek_percentage( file, 0.0 ); |
84 | } | 83 | } |
85 | return frames; | 84 | return frames; |
86 | } | 85 | } |
87 | return 0; | 86 | return 0; |
88 | } | 87 | } |
89 | */ | 88 | */ |
90 | bool videoSetFrame( long frame, int stream ) { return file ? mpeg3_set_frame( file, frame, stream) == 1 : FALSE; } | 89 | bool videoSetFrame( long frame, int stream ) { return file ? mpeg3_set_frame( file, frame, stream) == 1 : FALSE; } |
91 | long videoGetFrame( int stream ) { return file ? mpeg3_get_frame( file, stream ) : 0; } | 90 | long videoGetFrame( int stream ) { return file ? mpeg3_get_frame( file, stream ) : 0; } |
92 | bool videoReadFrame( unsigned char **output_rows, int in_x, int in_y, int in_w, int in_h, ColorFormat color_model, int stream ); | 91 | 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 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 ); | 92 | 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 videoReadYUVFrame( char *y_output, char *u_output, char *v_output, int in_x, int in_y, int in_w, int in_h, int stream ); | 93 | 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 | 94 | ||
96 | // Profiling | 95 | // Profiling |
97 | double getTime() { return file ? mpeg3_get_time( file ) : 0.0; } | 96 | double getTime() { return file ? mpeg3_get_time( file ) : 0.0; } |
98 | 97 | ||
99 | // Ignore if these aren't supported | 98 | // Ignore if these aren't supported |
100 | bool setSMP( int cpus ) { return file ? mpeg3_set_cpus( file, cpus ) == 1 : FALSE; } | 99 | bool setSMP( int cpus ) { return file ? mpeg3_set_cpus( file, cpus ) == 1 : FALSE; } |
101 | bool setMMX( bool useMMX ) { return file ? mpeg3_set_mmx( file, useMMX ) == 1 : FALSE; } | 100 | bool setMMX( bool useMMX ) { return file ? mpeg3_set_mmx( file, useMMX ) == 1 : FALSE; } |
102 | 101 | ||
103 | // Capabilities | 102 | // Capabilities |
104 | bool supportsAudio() { return TRUE; } | 103 | bool supportsAudio() { return TRUE; } |
105 | bool supportsVideo() { return TRUE; } | 104 | bool supportsVideo() { return TRUE; } |
106 | bool supportsYUV() { return TRUE; } | 105 | bool supportsYUV() { return TRUE; } |
107 | bool supportsMMX() { return TRUE; } | 106 | bool supportsMMX() { return TRUE; } |
108 | bool supportsSMP() { return TRUE; } | 107 | bool supportsSMP() { return TRUE; } |
109 | bool supportsStereo() { return TRUE; } | 108 | bool supportsStereo() { return TRUE; } |
110 | bool supportsScaling() { return TRUE; } | 109 | bool supportsScaling() { return TRUE; } |
111 | 110 | ||
112 | long getPlayTime() { return -1; } | 111 | long getPlayTime() { return -1; } |
113 | 112 | ||
114 | private: | 113 | private: |
115 | mpeg3_t *file; | 114 | mpeg3_t *file; |
116 | QString strInfo; | 115 | QString strInfo; |
117 | 116 | ||
118 | }; | 117 | }; |
119 | 118 | ||
120 | 119 | ||
121 | #endif | 120 | #endif |
122 | 121 | ||
diff --git a/core/multimedia/opieplayer/libmpeg3/libmpeg3pluginimpl.cpp b/core/multimedia/opieplayer/libmpeg3/libmpeg3pluginimpl.cpp index e7216af..bf3f372 100644 --- a/core/multimedia/opieplayer/libmpeg3/libmpeg3pluginimpl.cpp +++ b/core/multimedia/opieplayer/libmpeg3/libmpeg3pluginimpl.cpp | |||
@@ -1,70 +1,70 @@ | |||
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 "libmpeg3plugin.h" | 20 | #include "libmpeg3plugin.h" |
21 | #include "libmpeg3pluginimpl.h" | 21 | #include "libmpeg3pluginimpl.h" |
22 | 22 | ||
23 | 23 | ||
24 | LibMpeg3PluginImpl::LibMpeg3PluginImpl() | 24 | LibMpeg3PluginImpl::LibMpeg3PluginImpl() |
25 | : libmpeg3plugin(0), ref(0) | 25 | : libmpeg3plugin(0), ref(0) |
26 | { | 26 | { |
27 | } | 27 | } |
28 | 28 | ||
29 | 29 | ||
30 | LibMpeg3PluginImpl::~LibMpeg3PluginImpl() | 30 | LibMpeg3PluginImpl::~LibMpeg3PluginImpl() |
31 | { | 31 | { |
32 | if ( libmpeg3plugin ) | 32 | if ( libmpeg3plugin ) |
33 | delete libmpeg3plugin; | 33 | delete libmpeg3plugin; |
34 | } | 34 | } |
35 | 35 | ||
36 | 36 | ||
37 | MediaPlayerDecoder *LibMpeg3PluginImpl::decoder() | 37 | MediaPlayerDecoder *LibMpeg3PluginImpl::decoder() |
38 | { | 38 | { |
39 | if ( !libmpeg3plugin ) | 39 | if ( !libmpeg3plugin ) |
40 | libmpeg3plugin = new LibMpeg3Plugin; | 40 | libmpeg3plugin = new LibMpeg3Plugin; |
41 | return libmpeg3plugin; | 41 | return libmpeg3plugin; |
42 | } | 42 | } |
43 | 43 | ||
44 | 44 | ||
45 | MediaPlayerEncoder *LibMpeg3PluginImpl::encoder() | 45 | MediaPlayerEncoder *LibMpeg3PluginImpl::encoder() |
46 | { | 46 | { |
47 | return NULL; | 47 | return NULL; |
48 | } | 48 | } |
49 | 49 | ||
50 | 50 | ||
51 | #ifndef QT_NO_COMPONENT | 51 | #ifndef QT_NO_COMPONENT |
52 | 52 | ||
53 | 53 | ||
54 | QRESULT LibMpeg3PluginImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) | 54 | QRESULT LibMpeg3PluginImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) |
55 | { | 55 | { |
56 | *iface = 0; | 56 | *iface = 0; |
57 | if ( ( uuid == IID_QUnknown ) || ( uuid == IID_MediaPlayerPlugin ) ) | 57 | if ( ( uuid == IID_QUnknown ) || ( uuid == IID_MediaPlayerPlugin ) ) |
58 | *iface = this, (*iface)->addRef(); | 58 | *iface = this, (*iface)->addRef(); |
59 | return QS_OK; | 59 | return QS_OK; |
60 | } | 60 | } |
61 | 61 | ||
62 | 62 | ||
63 | Q_EXPORT_INTERFACE() | 63 | Q_EXPORT_INTERFACE() |
64 | { | 64 | { |
65 | Q_CREATE_INSTANCE( LibMpeg3PluginImpl ) | 65 | Q_CREATE_INSTANCE( LibMpeg3PluginImpl ) |
66 | } | 66 | } |
67 | 67 | ||
68 | 68 | ||
69 | #endif | 69 | #endif |
70 | 70 | ||
diff --git a/core/multimedia/opieplayer/libmpeg3/libmpeg3pluginimpl.h b/core/multimedia/opieplayer/libmpeg3/libmpeg3pluginimpl.h index a2f5211..ef3743e 100644 --- a/core/multimedia/opieplayer/libmpeg3/libmpeg3pluginimpl.h +++ b/core/multimedia/opieplayer/libmpeg3/libmpeg3pluginimpl.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 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 | //#include <qpe/mediaplayerplugininterface.h> | 23 | #include <qpe/mediaplayerplugininterface.h> |
24 | #include "../mediaplayerplugininterface.h" | 24 | //#include "../mediaplayerplugininterface.h" |
25 | 25 | ||
26 | 26 | ||
27 | class LibMpeg3Plugin; | 27 | class LibMpeg3Plugin; |
28 | 28 | ||
29 | 29 | ||
30 | class LibMpeg3PluginImpl : public MediaPlayerPluginInterface | 30 | class LibMpeg3PluginImpl : public MediaPlayerPluginInterface |
31 | { | 31 | { |
32 | public: | 32 | public: |
33 | LibMpeg3PluginImpl(); | 33 | LibMpeg3PluginImpl(); |
34 | virtual ~LibMpeg3PluginImpl(); | 34 | virtual ~LibMpeg3PluginImpl(); |
35 | 35 | ||
36 | #ifndef QT_NO_COMPONENT | 36 | #ifndef QT_NO_COMPONENT |
37 | 37 | ||
38 | QRESULT queryInterface( const QUuid&, QUnknownInterface** ); | 38 | QRESULT queryInterface( const QUuid&, QUnknownInterface** ); |
39 | Q_REFCOUNT | 39 | Q_REFCOUNT |
40 | 40 | ||
41 | #endif | 41 | #endif |
42 | 42 | ||
43 | virtual MediaPlayerDecoder *decoder(); | 43 | virtual MediaPlayerDecoder *decoder(); |
44 | virtual MediaPlayerEncoder *encoder(); | 44 | virtual MediaPlayerEncoder *encoder(); |
45 | 45 | ||
46 | private: | 46 | private: |
47 | LibMpeg3Plugin *libmpeg3plugin; | 47 | LibMpeg3Plugin *libmpeg3plugin; |
48 | ulong ref; | 48 | ulong ref; |
49 | }; | 49 | }; |
50 | 50 | ||
51 | 51 | ||
52 | #endif | 52 | #endif |
53 | 53 | ||
diff --git a/core/multimedia/opieplayer/loopcontrol.cpp b/core/multimedia/opieplayer/loopcontrol.cpp index 90a7cc6..cb8de8a 100644 --- a/core/multimedia/opieplayer/loopcontrol.cpp +++ b/core/multimedia/opieplayer/loopcontrol.cpp | |||
@@ -1,168 +1,169 @@ | |||
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 | 20 | // L.J.Potter added changes Fri 02-15-2002 |
21 | 21 | ||
22 | 22 | ||
23 | #include <qpe/qpeapplication.h> | 23 | #include <qpe/qpeapplication.h> |
24 | 24 | ||
25 | #ifdef Q_WS_QWS | 25 | #ifdef Q_WS_QWS |
26 | #include <qpe/qcopenvelope_qws.h> | 26 | #include <qpe/qcopenvelope_qws.h> |
27 | #endif | 27 | #endif |
28 | #include <stdio.h> | 28 | #include <stdio.h> |
29 | #include <stdlib.h> | 29 | #include <stdlib.h> |
30 | #include <string.h> | 30 | #include <string.h> |
31 | #include <pthread.h> | 31 | #include <pthread.h> |
32 | #include <errno.h> | 32 | #include <errno.h> |
33 | #include <unistd.h> | 33 | #include <unistd.h> |
34 | #include "loopcontrol.h" | 34 | #include "loopcontrol.h" |
35 | #include "videowidget.h" | 35 | #include "videowidget.h" |
36 | #include "audiodevice.h" | 36 | #include "audiodevice.h" |
37 | #include "mediaplayerplugininterface.h" | 37 | #include <qpe/mediaplayerplugininterface.h> |
38 | #include "mediaplayerstate.h" | 38 | #include "mediaplayerstate.h" |
39 | 39 | ||
40 | 40 | ||
41 | extern VideoWidget *videoUI; // now only needed to tell it to play a frame | 41 | extern VideoWidget *videoUI; // now only needed to tell it to play a frame |
42 | extern MediaPlayerState *mediaPlayerState; | 42 | extern MediaPlayerState *mediaPlayerState; |
43 | 43 | ||
44 | 44 | ||
45 | //#define DecodeLoopDebug(x) qDebug x | 45 | //#define DecodeLoopDebug(x) qDebug x |
46 | #define DecodeLoopDebug(x) | 46 | #define DecodeLoopDebug(x) |
47 | 47 | ||
48 | 48 | ||
49 | static char *audioBuffer = NULL; | 49 | static char *audioBuffer = NULL; |
50 | static AudioDevice *audioDevice = NULL; | 50 | static AudioDevice *audioDevice = NULL; |
51 | static bool disabledSuspendScreenSaver = FALSE; | 51 | static bool disabledSuspendScreenSaver = FALSE; |
52 | static bool previousSuspendMode = FALSE; | 52 | static bool previousSuspendMode = FALSE; |
53 | 53 | ||
54 | 54 | ||
55 | pthread_t audio_tid; | 55 | pthread_t audio_tid; |
56 | pthread_attr_t audio_attr; | 56 | pthread_attr_t audio_attr; |
57 | bool threadOkToGo = FALSE; | 57 | bool threadOkToGo = FALSE; |
58 | 58 | ||
59 | 59 | ||
60 | class Mutex { | 60 | class Mutex { |
61 | public: | 61 | public: |
62 | Mutex() { | 62 | Mutex() { |
63 | pthread_mutexattr_t attr; | 63 | pthread_mutexattr_t attr; |
64 | pthread_mutexattr_init( &attr ); | 64 | pthread_mutexattr_init( &attr ); |
65 | pthread_mutex_init( &mutex, &attr ); | 65 | pthread_mutex_init( &mutex, &attr ); |
66 | pthread_mutexattr_destroy( &attr ); | 66 | pthread_mutexattr_destroy( &attr ); |
67 | } | 67 | } |
68 | 68 | ||
69 | ~Mutex() { | 69 | ~Mutex() { |
70 | pthread_mutex_destroy( &mutex ); | 70 | pthread_mutex_destroy( &mutex ); |
71 | } | 71 | } |
72 | 72 | ||
73 | void lock() { | 73 | void lock() { |
74 | pthread_mutex_lock( &mutex ); | 74 | pthread_mutex_lock( &mutex ); |
75 | } | 75 | } |
76 | 76 | ||
77 | void unlock() { | 77 | void unlock() { |
78 | pthread_mutex_unlock( &mutex ); | 78 | pthread_mutex_unlock( &mutex ); |
79 | } | 79 | } |
80 | private: | 80 | private: |
81 | pthread_mutex_t mutex; | 81 | pthread_mutex_t mutex; |
82 | }; | 82 | }; |
83 | 83 | ||
84 | 84 | ||
85 | void *startAudioThread( void *ptr ) { | 85 | void *startAudioThread( void *ptr ) { |
86 | LoopControl *mpegView = (LoopControl *)ptr; | 86 | LoopControl *mpegView = (LoopControl *)ptr; |
87 | while ( TRUE ) { | 87 | while ( TRUE ) { |
88 | if ( threadOkToGo && mpegView->moreAudio ) | 88 | if ( threadOkToGo && mpegView->moreAudio ) |
89 | mpegView->startAudio(); | 89 | mpegView->startAudio(); |
90 | else | 90 | else |
91 | usleep( 10000 ); // Semi-buzy-wait till we are playing again | 91 | usleep( 10000 ); // Semi-buzy-wait till we are playing again |
92 | } | 92 | } |
93 | return 0; | 93 | return 0; |
94 | } | 94 | } |
95 | 95 | ||
96 | 96 | ||
97 | Mutex *audioMutex; | 97 | Mutex *audioMutex; |
98 | 98 | ||
99 | 99 | ||
100 | LoopControl::LoopControl( QObject *parent, const char *name ) | 100 | LoopControl::LoopControl( QObject *parent, const char *name ) |
101 | : QObject( parent, name ) { | 101 | : QObject( parent, name ) { |
102 | isMuted = FALSE; | 102 | isMuted = FALSE; |
103 | connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( setMute(bool) ) ); | 103 | connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( setMute(bool) ) ); |
104 | 104 | //qDebug("starting loopcontrol"); | |
105 | audioMutex = new Mutex; | 105 | audioMutex = new Mutex; |
106 | 106 | ||
107 | pthread_attr_init(&audio_attr); | 107 | pthread_attr_init(&audio_attr); |
108 | #define USE_REALTIME_AUDIO_THREAD | 108 | #define USE_REALTIME_AUDIO_THREAD |
109 | #ifdef USE_REALTIME_AUDIO_THREAD | 109 | #ifdef USE_REALTIME_AUDIO_THREAD |
110 | // Attempt to set it to real-time round robin | 110 | // Attempt to set it to real-time round robin |
111 | if ( pthread_attr_setschedpolicy( &audio_attr, SCHED_RR ) == 0 ) { | 111 | if ( pthread_attr_setschedpolicy( &audio_attr, SCHED_RR ) == 0 ) { |
112 | sched_param params; | 112 | sched_param params; |
113 | params.sched_priority = 50; | 113 | params.sched_priority = 50; |
114 | pthread_attr_setschedparam(&audio_attr,¶ms); | 114 | pthread_attr_setschedparam(&audio_attr,¶ms); |
115 | } else { | 115 | } else { |
116 | qDebug( "Error setting up a realtime thread, reverting to using a normal thread." ); | 116 | qDebug( "Error setting up a realtime thread, reverting to using a normal thread." ); |
117 | pthread_attr_destroy(&audio_attr); | 117 | pthread_attr_destroy(&audio_attr); |
118 | pthread_attr_init(&audio_attr); | 118 | pthread_attr_init(&audio_attr); |
119 | } | 119 | } |
120 | #endif | 120 | #endif |
121 | //qDebug("create audio thread"); | ||
121 | pthread_create(&audio_tid, &audio_attr, (void * (*)(void *))startAudioThread, this); | 122 | pthread_create(&audio_tid, &audio_attr, (void * (*)(void *))startAudioThread, this); |
122 | } | 123 | } |
123 | 124 | ||
124 | 125 | ||
125 | LoopControl::~LoopControl() { | 126 | LoopControl::~LoopControl() { |
126 | stop(); | 127 | stop(); |
127 | } | 128 | } |
128 | 129 | ||
129 | 130 | ||
130 | static long prev_frame = 0; | 131 | static long prev_frame = 0; |
131 | static int currentSample = 0; | 132 | static int currentSample = 0; |
132 | 133 | ||
133 | 134 | ||
134 | void LoopControl::timerEvent( QTimerEvent *te ) { | 135 | void LoopControl::timerEvent( QTimerEvent *te ) { |
135 | 136 | ||
136 | if ( te->timerId() == videoId ) | 137 | if ( te->timerId() == videoId ) |
137 | startVideo(); | 138 | startVideo(); |
138 | 139 | ||
139 | if ( te->timerId() == sliderId ) { | 140 | if ( te->timerId() == sliderId ) { |
140 | if ( hasAudioChannel && !hasVideoChannel && moreAudio ) { | 141 | if ( hasAudioChannel && !hasVideoChannel && moreAudio ) { |
141 | mediaPlayerState->updatePosition( audioSampleCounter ); | 142 | mediaPlayerState->updatePosition( audioSampleCounter ); |
142 | } else if ( hasVideoChannel && moreVideo ) { | 143 | } else if ( hasVideoChannel && moreVideo ) { |
143 | mediaPlayerState->updatePosition( current_frame ); | 144 | mediaPlayerState->updatePosition( current_frame ); |
144 | } | 145 | } |
145 | } | 146 | } |
146 | 147 | ||
147 | if ( !moreVideo && !moreAudio ) { | 148 | if ( !moreVideo && !moreAudio ) { |
148 | mediaPlayerState->setPlaying( FALSE ); | 149 | mediaPlayerState->setPlaying( FALSE ); |
149 | mediaPlayerState->setNext(); | 150 | mediaPlayerState->setNext(); |
150 | } | 151 | } |
151 | } | 152 | } |
152 | 153 | ||
153 | 154 | ||
154 | void LoopControl::setPosition( long pos ) { | 155 | void LoopControl::setPosition( long pos ) { |
155 | audioMutex->lock(); | 156 | audioMutex->lock(); |
156 | 157 | ||
157 | if ( hasVideoChannel && hasAudioChannel ) { | 158 | if ( hasVideoChannel && hasAudioChannel ) { |
158 | playtime.restart(); | 159 | playtime.restart(); |
159 | playtime = playtime.addMSecs( long((double)-pos * 1000.0 / framerate) ); | 160 | playtime = playtime.addMSecs( long((double)-pos * 1000.0 / framerate) ); |
160 | current_frame = pos + 1; | 161 | current_frame = pos + 1; |
161 | mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); | 162 | mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); |
162 | prev_frame = current_frame - 1; | 163 | prev_frame = current_frame - 1; |
163 | currentSample = (int)( (double)current_frame * freq / framerate ); | 164 | currentSample = (int)( (double)current_frame * freq / framerate ); |
164 | mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream ); | 165 | mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream ); |
165 | audioSampleCounter = currentSample - 1; | 166 | audioSampleCounter = currentSample - 1; |
166 | } else if ( hasVideoChannel ) { | 167 | } else if ( hasVideoChannel ) { |
167 | playtime.restart(); | 168 | playtime.restart(); |
168 | playtime = playtime.addMSecs( long((double)-pos * 1000.0 / framerate) ); | 169 | playtime = playtime.addMSecs( long((double)-pos * 1000.0 / framerate) ); |
@@ -175,120 +176,120 @@ void LoopControl::setPosition( long pos ) { | |||
175 | currentSample = pos + 1; | 176 | currentSample = pos + 1; |
176 | mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream ); | 177 | mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream ); |
177 | audioSampleCounter = currentSample - 1; | 178 | audioSampleCounter = currentSample - 1; |
178 | } | 179 | } |
179 | 180 | ||
180 | audioMutex->unlock(); | 181 | audioMutex->unlock(); |
181 | } | 182 | } |
182 | 183 | ||
183 | 184 | ||
184 | void LoopControl::startVideo() { | 185 | void LoopControl::startVideo() { |
185 | 186 | ||
186 | if ( moreVideo ) { | 187 | if ( moreVideo ) { |
187 | 188 | ||
188 | if ( mediaPlayerState->curDecoder() ) { | 189 | if ( mediaPlayerState->curDecoder() ) { |
189 | 190 | ||
190 | if ( hasAudioChannel && !isMuted ) { | 191 | if ( hasAudioChannel && !isMuted ) { |
191 | 192 | ||
192 | current_frame = long( playtime.elapsed() * framerate / 1000 ); | 193 | current_frame = long( playtime.elapsed() * framerate / 1000 ); |
193 | 194 | ||
194 | if ( prev_frame != -1 && current_frame <= prev_frame ) | 195 | if ( prev_frame != -1 && current_frame <= prev_frame ) |
195 | return; | 196 | return; |
196 | 197 | ||
197 | } else { | 198 | } else { |
198 | // Don't skip | 199 | // Don't skip |
199 | current_frame++; | 200 | current_frame++; |
200 | } | 201 | } |
201 | 202 | ||
202 | if ( prev_frame == -1 || current_frame > prev_frame ) { | 203 | if ( prev_frame == -1 || current_frame > prev_frame ) { |
203 | if ( current_frame > prev_frame + 1 ) { | 204 | if ( current_frame > prev_frame + 1 ) { |
204 | mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); | 205 | mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); |
205 | } | 206 | } |
206 | moreVideo = videoUI->playVideo(); | 207 | moreVideo = videoUI->playVideo(); |
207 | prev_frame = current_frame; | 208 | prev_frame = current_frame; |
208 | } | 209 | } |
209 | 210 | ||
210 | } else { | 211 | } else { |
211 | 212 | ||
212 | moreVideo = FALSE; | 213 | moreVideo = FALSE; |
213 | killTimer( videoId ); | 214 | killTimer( videoId ); |
214 | 215 | ||
215 | } | 216 | } |
216 | 217 | ||
217 | } | 218 | } |
218 | } | 219 | } |
219 | 220 | ||
220 | 221 | ||
221 | void LoopControl::startAudio() { | 222 | void LoopControl::startAudio() { |
222 | 223 | ||
224 | //qDebug("start audio"); | ||
223 | audioMutex->lock(); | 225 | audioMutex->lock(); |
224 | |||
225 | if ( moreAudio ) { | 226 | if ( moreAudio ) { |
226 | 227 | ||
227 | if ( !isMuted && mediaPlayerState->curDecoder() ) { | 228 | if ( !isMuted && mediaPlayerState->curDecoder() ) { |
228 | 229 | ||
229 | currentSample = audioSampleCounter + 1; | 230 | currentSample = audioSampleCounter + 1; |
230 | 231 | ||
231 | if ( currentSample != audioSampleCounter + 1 ) | 232 | if ( currentSample != audioSampleCounter + 1 ) |
232 | qDebug("out of sync with decoder %i %i", currentSample, audioSampleCounter); | 233 | qDebug("out of sync with decoder %i %i", currentSample, audioSampleCounter); |
233 | 234 | ||
234 | long samplesRead = 0; | 235 | long samplesRead = 0; |
235 | bool readOk=mediaPlayerState->curDecoder()->audioReadSamples( (short*)audioBuffer, channels, 1024, samplesRead, stream ); | 236 | bool readOk=mediaPlayerState->curDecoder()->audioReadSamples( (short*)audioBuffer, channels, 1024, samplesRead, stream ); |
236 | long sampleWeShouldBeAt = long( playtime.elapsed() ) * freq / 1000; | 237 | long sampleWeShouldBeAt = long( playtime.elapsed() ) * freq / 1000; |
237 | long sampleWaitTime = currentSample - sampleWeShouldBeAt; | 238 | long sampleWaitTime = currentSample - sampleWeShouldBeAt; |
238 | 239 | ||
239 | if ( ( sampleWaitTime > 2000 ) && ( sampleWaitTime < 20000 ) ) { | 240 | // if ( ( sampleWaitTime > 2000 ) && ( sampleWaitTime < 20000 ) ) { |
240 | usleep( (long)((double)sampleWaitTime * 1000000.0 / freq) ); | 241 | // usleep( (long)((double)sampleWaitTime * 1000000.0 / freq) ); |
241 | } | 242 | // } |
242 | else if ( sampleWaitTime <= -5000 ) { | 243 | // else if ( sampleWaitTime <= -5000 ) { |
243 | qDebug("need to catch up by: %li (%i,%li)", -sampleWaitTime, currentSample, sampleWeShouldBeAt ); | 244 | // qDebug("need to catch up by: %li (%i,%li)", -sampleWaitTime, currentSample, sampleWeShouldBeAt ); |
244 | //mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream ); | 245 | // //mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream ); |
245 | currentSample = sampleWeShouldBeAt; | 246 | // currentSample = sampleWeShouldBeAt; |
246 | } | 247 | // } |
247 | 248 | ||
248 | audioDevice->write( audioBuffer, samplesRead * 2 * channels ); | 249 | audioDevice->write( audioBuffer, samplesRead * 2 * channels ); |
249 | audioSampleCounter = currentSample + samplesRead - 1; | 250 | audioSampleCounter = currentSample + samplesRead - 1; |
250 | 251 | ||
251 | moreAudio = readOk && (audioSampleCounter <= total_audio_samples); | 252 | moreAudio = readOk && (audioSampleCounter <= total_audio_samples); |
252 | 253 | ||
253 | } else { | 254 | } else { |
254 | 255 | ||
255 | moreAudio = FALSE; | 256 | moreAudio = FALSE; |
256 | 257 | ||
257 | } | 258 | } |
258 | 259 | ||
259 | } | 260 | } |
260 | 261 | ||
261 | audioMutex->unlock(); | 262 | audioMutex->unlock(); |
262 | } | 263 | } |
263 | 264 | ||
264 | 265 | ||
265 | void LoopControl::killTimers() { | 266 | void LoopControl::killTimers() { |
266 | 267 | ||
267 | audioMutex->lock(); | 268 | audioMutex->lock(); |
268 | 269 | ||
269 | if ( hasVideoChannel ) | 270 | if ( hasVideoChannel ) |
270 | killTimer( videoId ); | 271 | killTimer( videoId ); |
271 | killTimer( sliderId ); | 272 | killTimer( sliderId ); |
272 | threadOkToGo = FALSE; | 273 | threadOkToGo = FALSE; |
273 | 274 | ||
274 | audioMutex->unlock(); | 275 | audioMutex->unlock(); |
275 | } | 276 | } |
276 | 277 | ||
277 | 278 | ||
278 | void LoopControl::startTimers() { | 279 | void LoopControl::startTimers() { |
279 | 280 | ||
280 | audioMutex->lock(); | 281 | audioMutex->lock(); |
281 | 282 | ||
282 | moreVideo = FALSE; | 283 | moreVideo = FALSE; |
283 | moreAudio = FALSE; | 284 | moreAudio = FALSE; |
284 | 285 | ||
285 | if ( hasVideoChannel ) { | 286 | if ( hasVideoChannel ) { |
286 | moreVideo = TRUE; | 287 | moreVideo = TRUE; |
287 | int mSecsBetweenFrames = (int)(100 / framerate); // 10% of the real value | 288 | int mSecsBetweenFrames = (int)(100 / framerate); // 10% of the real value |
288 | videoId = startTimer( mSecsBetweenFrames ); | 289 | videoId = startTimer( mSecsBetweenFrames ); |
289 | } | 290 | } |
290 | 291 | ||
291 | if ( hasAudioChannel ) { | 292 | if ( hasAudioChannel ) { |
292 | moreAudio = TRUE; | 293 | moreAudio = TRUE; |
293 | threadOkToGo = TRUE; | 294 | threadOkToGo = TRUE; |
294 | } | 295 | } |
@@ -346,124 +347,129 @@ void LoopControl::stop( bool willPlayAgainShortly ) { | |||
346 | } | 347 | } |
347 | } | 348 | } |
348 | 349 | ||
349 | 350 | ||
350 | bool LoopControl::init( const QString& filename ) { | 351 | bool LoopControl::init( const QString& filename ) { |
351 | stop(); | 352 | stop(); |
352 | 353 | ||
353 | audioMutex->lock(); | 354 | audioMutex->lock(); |
354 | 355 | ||
355 | fileName = filename; | 356 | fileName = filename; |
356 | stream = 0; // only play stream 0 for now | 357 | stream = 0; // only play stream 0 for now |
357 | current_frame = total_video_frames = total_audio_samples = 0; | 358 | current_frame = total_video_frames = total_audio_samples = 0; |
358 | 359 | ||
359 | qDebug( "Using the %s decoder", mediaPlayerState->curDecoder()->pluginName() ); | 360 | qDebug( "Using the %s decoder", mediaPlayerState->curDecoder()->pluginName() ); |
360 | 361 | ||
361 | // ### Hack to use libmpeg3plugin to get the number of audio samples if we are using the libmad plugin | 362 | // ### Hack to use libmpeg3plugin to get the number of audio samples if we are using the libmad plugin |
362 | if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibMadPlugin") ) { | 363 | if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibMadPlugin") ) { |
363 | if ( mediaPlayerState->libMpeg3Decoder() && mediaPlayerState->libMpeg3Decoder()->open( filename ) ) { | 364 | if ( mediaPlayerState->libMpeg3Decoder() && mediaPlayerState->libMpeg3Decoder()->open( filename ) ) { |
364 | total_audio_samples = mediaPlayerState->libMpeg3Decoder()->audioSamples( 0 ); | 365 | total_audio_samples = mediaPlayerState->libMpeg3Decoder()->audioSamples( 0 ); |
365 | mediaPlayerState->libMpeg3Decoder()->close(); | 366 | mediaPlayerState->libMpeg3Decoder()->close(); |
366 | } | 367 | } |
367 | } | 368 | } |
368 | 369 | ||
369 | if ( !mediaPlayerState->curDecoder()|| !mediaPlayerState->curDecoder()->open( filename ) ) { | 370 | if ( !mediaPlayerState->curDecoder()|| !mediaPlayerState->curDecoder()->open( filename ) ) { |
370 | audioMutex->unlock(); | 371 | audioMutex->unlock(); |
371 | return FALSE; | 372 | return FALSE; |
372 | } | 373 | } |
373 | 374 | ||
374 | hasAudioChannel = mediaPlayerState->curDecoder()->audioStreams() > 0; | 375 | hasAudioChannel = mediaPlayerState->curDecoder()->audioStreams() > 0; |
375 | hasVideoChannel = mediaPlayerState->curDecoder()->videoStreams() > 0; | 376 | hasVideoChannel = mediaPlayerState->curDecoder()->videoStreams() > 0; |
376 | 377 | ||
377 | if ( hasAudioChannel ) { | 378 | if ( hasAudioChannel ) { |
378 | int astream = 0; | 379 | int astream = 0; |
379 | 380 | ||
380 | channels = mediaPlayerState->curDecoder()->audioChannels( astream ); | 381 | channels = mediaPlayerState->curDecoder()->audioChannels( astream ); |
381 | qDebug( "LC- channels = %d", channels ); | 382 | qDebug( "LC- channels = %d", channels ); |
382 | 383 | ||
383 | if ( !total_audio_samples ) | 384 | if ( !total_audio_samples ) |
384 | total_audio_samples = mediaPlayerState->curDecoder()->audioSamples( astream ); | 385 | total_audio_samples = mediaPlayerState->curDecoder()->audioSamples( astream ); |
385 | 386 | ||
386 | // total_audio_samples += 1000; | 387 | // total_audio_samples += 1000; |
387 | 388 | ||
388 | mediaPlayerState->setLength( total_audio_samples ); | 389 | mediaPlayerState->setLength( total_audio_samples ); |
389 | 390 | ||
390 | freq = mediaPlayerState->curDecoder()->audioFrequency( astream ); | 391 | freq = mediaPlayerState->curDecoder()->audioFrequency( astream ); |
391 | qDebug( "LC- frequency = %d", freq ); | 392 | qDebug( "LC- frequency = %d", freq ); |
392 | 393 | ||
393 | audioSampleCounter = 0; | 394 | audioSampleCounter = 0; |
394 | 395 | int bits_per_sample; | |
395 | int bits_per_sample = mediaPlayerState->curDecoder()->audioBitsPerSample( astream); | 396 | if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibWavPlugin") ) { |
397 | bits_per_sample =(int) mediaPlayerState->curDecoder()->getTime(); | ||
398 | qDebug("using stupid hack"); | ||
399 | } else { | ||
400 | bits_per_sample=0; | ||
401 | } | ||
396 | 402 | ||
397 | audioDevice = new AudioDevice( freq, channels, bits_per_sample); | 403 | audioDevice = new AudioDevice( freq, channels, bits_per_sample); |
398 | audioBuffer = new char[ audioDevice->bufferSize() ]; | 404 | audioBuffer = new char[ audioDevice->bufferSize() ]; |
399 | channels = audioDevice->channels(); | 405 | channels = audioDevice->channels(); |
400 | 406 | ||
401 | //### must check which frequency is actually used. | 407 | //### must check which frequency is actually used. |
402 | static const int size = 1; | 408 | static const int size = 1; |
403 | short int buf[size]; | 409 | short int buf[size]; |
404 | long samplesRead = 0; | 410 | long samplesRead = 0; |
405 | mediaPlayerState->curDecoder()->audioReadSamples( buf, channels, size, samplesRead, stream ); | 411 | mediaPlayerState->curDecoder()->audioReadSamples( buf, channels, size, samplesRead, stream ); |
406 | } | 412 | } |
407 | 413 | ||
408 | if ( hasVideoChannel ) { | 414 | if ( hasVideoChannel ) { |
409 | total_video_frames = mediaPlayerState->curDecoder()->videoFrames( stream ); | 415 | total_video_frames = mediaPlayerState->curDecoder()->videoFrames( stream ); |
410 | 416 | ||
411 | mediaPlayerState->setLength( total_video_frames ); | 417 | mediaPlayerState->setLength( total_video_frames ); |
412 | 418 | ||
413 | framerate = mediaPlayerState->curDecoder()->videoFrameRate( stream ); | 419 | framerate = mediaPlayerState->curDecoder()->videoFrameRate( stream ); |
414 | DecodeLoopDebug(( "Frame rate %g total %ld", framerate, total_video_frames )); | 420 | DecodeLoopDebug(( "Frame rate %g total %ld", framerate, total_video_frames )); |
415 | 421 | ||
416 | if ( framerate <= 1.0 ) { | 422 | if ( framerate <= 1.0 ) { |
417 | DecodeLoopDebug(( "Crazy frame rate, resetting to sensible" )); | 423 | DecodeLoopDebug(( "Crazy frame rate, resetting to sensible" )); |
418 | framerate = 25; | 424 | framerate = 25; |
419 | } | 425 | } |
420 | 426 | ||
421 | if ( total_video_frames == 1 ) { | 427 | if ( total_video_frames == 1 ) { |
422 | DecodeLoopDebug(( "Cannot seek to frame" )); | 428 | DecodeLoopDebug(( "Cannot seek to frame" )); |
423 | } | 429 | } |
424 | 430 | ||
425 | } | 431 | } |
426 | 432 | ||
427 | current_frame = 0; | 433 | current_frame = 0; |
428 | prev_frame = -1; | 434 | prev_frame = -1; |
429 | 435 | ||
430 | connect( mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( setPosition( long ) ) ); | 436 | connect( mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( setPosition( long ) ) ); |
431 | connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( setPaused( bool ) ) ); | 437 | connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( setPaused( bool ) ) ); |
432 | 438 | ||
433 | audioMutex->unlock(); | 439 | audioMutex->unlock(); |
434 | 440 | ||
435 | return TRUE; | 441 | return TRUE; |
436 | } | 442 | } |
437 | 443 | ||
438 | 444 | ||
439 | void LoopControl::play() { | 445 | void LoopControl::play() { |
440 | 446 | qDebug("LC- play"); | |
441 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 447 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
442 | if ( !disabledSuspendScreenSaver || previousSuspendMode != hasVideoChannel ) { | 448 | if ( !disabledSuspendScreenSaver || previousSuspendMode != hasVideoChannel ) { |
443 | disabledSuspendScreenSaver = TRUE; | 449 | disabledSuspendScreenSaver = TRUE; |
444 | previousSuspendMode = hasVideoChannel; | 450 | previousSuspendMode = hasVideoChannel; |
445 | // Stop the screen from blanking and power saving state | 451 | // Stop the screen from blanking and power saving state |
446 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) | 452 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) |
447 | << ( hasVideoChannel ? QPEApplication::Disable : QPEApplication::DisableSuspend ); | 453 | << ( hasVideoChannel ? QPEApplication::Disable : QPEApplication::DisableSuspend ); |
448 | } | 454 | } |
449 | #endif | 455 | #endif |
450 | 456 | ||
451 | playtime.start(); | 457 | playtime.start(); |
452 | startTimers(); | 458 | startTimers(); |
453 | } | 459 | } |
454 | 460 | ||
455 | 461 | ||
456 | void LoopControl::setMute( bool on ) { | 462 | void LoopControl::setMute( bool on ) { |
457 | if ( on != isMuted ) { | 463 | if ( on != isMuted ) { |
458 | isMuted = on; | 464 | isMuted = on; |
459 | if ( !on ) { | 465 | if ( !on ) { |
460 | // Force an update of the position | 466 | // Force an update of the position |
461 | mediaPlayerState->setPosition( mediaPlayerState->position() + 1 ); | 467 | mediaPlayerState->setPosition( mediaPlayerState->position() + 1 ); |
462 | mediaPlayerState->setPosition( mediaPlayerState->position() - 1 ); | 468 | mediaPlayerState->setPosition( mediaPlayerState->position() - 1 ); |
463 | // Resume playing audio | 469 | // Resume playing audio |
464 | moreAudio = TRUE; | 470 | moreAudio = TRUE; |
465 | } | 471 | } |
466 | } | 472 | } |
467 | } | 473 | } |
468 | 474 | ||
469 | 475 | ||
diff --git a/core/multimedia/opieplayer/main.cpp b/core/multimedia/opieplayer/main.cpp index 720a1ca..4f43ff6 100644 --- a/core/multimedia/opieplayer/main.cpp +++ b/core/multimedia/opieplayer/main.cpp | |||
@@ -2,55 +2,55 @@ | |||
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include <qpe/qpeapplication.h> | 20 | #include <qpe/qpeapplication.h> |
21 | #include "mediaplayerstate.h" | 21 | #include "mediaplayerstate.h" |
22 | #include "playlistwidget.h" | 22 | #include "playlistwidget.h" |
23 | #include "audiowidget.h" | 23 | #include "audiowidget.h" |
24 | #include "videowidget.h" | 24 | #include "videowidget.h" |
25 | #include "loopcontrol.h" | 25 | #include "loopcontrol.h" |
26 | #include "mediaplayer.h" | 26 | #include "mediaplayer.h" |
27 | 27 | ||
28 | MediaPlayerState *mediaPlayerState; | 28 | MediaPlayerState *mediaPlayerState; |
29 | PlayListWidget *playList; | 29 | PlayListWidget *playList; |
30 | AudioWidget *audioUI; | 30 | AudioWidget *audioUI; |
31 | VideoWidget *videoUI; | 31 | VideoWidget *videoUI; |
32 | LoopControl *loopControl; | 32 | LoopControl *loopControl; |
33 | 33 | ||
34 | 34 | ||
35 | int main(int argc, char **argv) { | 35 | int main(int argc, char **argv) { |
36 | QPEApplication a(argc,argv); | 36 | QPEApplication a(argc,argv); |
37 | 37 | ||
38 | MediaPlayerState st( 0, "mediaPlayerState" ); | 38 | MediaPlayerState st( 0, "mediaPlayerState" ); |
39 | mediaPlayerState = &st; | 39 | mediaPlayerState = &st; |
40 | PlayListWidget pl( 0, "playList" ); | 40 | PlayListWidget pl( 0, "playList" ); |
41 | playList = &pl; | 41 | playList = &pl; |
42 | AudioWidget aw( 0, "audioUI" ); | 42 | AudioWidget aw( 0, "audioUI" ); |
43 | audioUI = &aw; | 43 | audioUI = &aw; |
44 | VideoWidget vw( 0, "videoUI" ); | 44 | VideoWidget vw( 0, "videoUI" ); |
45 | videoUI = &vw; | 45 | videoUI = &vw; |
46 | LoopControl lc( 0, "loopControl" ); | 46 | LoopControl lc( 0, "loopControl" ); |
47 | loopControl = &lc; | 47 | loopControl = &lc; |
48 | MediaPlayer mp( 0, "mediaPlayer" ); | 48 | MediaPlayer mp( 0, "mediaPlayer" ); |
49 | 49 | ||
50 | pl.setCaption( MediaPlayer::tr("Media Player") ); | 50 | pl.setCaption( MediaPlayer::tr("OpiePlayer") ); |
51 | a.showMainDocumentWidget(&pl); | 51 | a.showMainDocumentWidget(&pl); |
52 | 52 | ||
53 | return a.exec(); | 53 | return a.exec(); |
54 | } | 54 | } |
55 | 55 | ||
56 | 56 | ||
diff --git a/core/multimedia/opieplayer/mediaplayer.cpp b/core/multimedia/opieplayer/mediaplayer.cpp index ce42c2c..c971a3c 100644 --- a/core/multimedia/opieplayer/mediaplayer.cpp +++ b/core/multimedia/opieplayer/mediaplayer.cpp | |||
@@ -3,181 +3,176 @@ | |||
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include <qpe/qpeapplication.h> | 21 | #include <qpe/qpeapplication.h> |
22 | #include <qpe/qlibrary.h> | 22 | #include <qpe/qlibrary.h> |
23 | #include <qpe/resource.h> | 23 | #include <qpe/resource.h> |
24 | #include <qpe/config.h> | 24 | #include <qpe/config.h> |
25 | 25 | ||
26 | #include <qmainwindow.h> | 26 | #include <qmainwindow.h> |
27 | #include <qmessagebox.h> | 27 | #include <qmessagebox.h> |
28 | #include <qwidgetstack.h> | 28 | #include <qwidgetstack.h> |
29 | #include <qfile.h> | 29 | #include <qfile.h> |
30 | 30 | ||
31 | #include "mediaplayer.h" | 31 | #include "mediaplayer.h" |
32 | #include "playlistwidget.h" | 32 | #include "playlistwidget.h" |
33 | #include "audiowidget.h" | 33 | #include "audiowidget.h" |
34 | #include "loopcontrol.h" | 34 | #include "loopcontrol.h" |
35 | #include "audiodevice.h" | 35 | #include "audiodevice.h" |
36 | 36 | ||
37 | #include "mediaplayerstate.h" | 37 | #include "mediaplayerstate.h" |
38 | 38 | ||
39 | 39 | ||
40 | extern AudioWidget *audioUI; | 40 | extern AudioWidget *audioUI; |
41 | extern PlayListWidget *playList; | 41 | extern PlayListWidget *playList; |
42 | extern LoopControl *loopControl; | 42 | extern LoopControl *loopControl; |
43 | extern MediaPlayerState *mediaPlayerState; | 43 | extern MediaPlayerState *mediaPlayerState; |
44 | 44 | ||
45 | 45 | ||
46 | MediaPlayer::MediaPlayer( QObject *parent, const char *name ) | 46 | MediaPlayer::MediaPlayer( QObject *parent, const char *name ) |
47 | : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) { | 47 | : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) { |
48 | 48 | ||
49 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); | 49 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); |
50 | connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); | 50 | connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); |
51 | connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); | 51 | connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); |
52 | connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); | 52 | connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); |
53 | 53 | ||
54 | connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); | 54 | connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); |
55 | connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); | 55 | connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); |
56 | connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); | 56 | connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); |
57 | connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); | 57 | connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); |
58 | } | 58 | } |
59 | 59 | ||
60 | 60 | ||
61 | MediaPlayer::~MediaPlayer() { | 61 | MediaPlayer::~MediaPlayer() { |
62 | } | 62 | } |
63 | 63 | ||
64 | 64 | ||
65 | void MediaPlayer::pauseCheck( bool b ) { | 65 | void MediaPlayer::pauseCheck( bool b ) { |
66 | // Only pause if playing | 66 | // Only pause if playing |
67 | if ( b && !mediaPlayerState->playing() ) | 67 | if ( b && !mediaPlayerState->playing() ) |
68 | mediaPlayerState->setPaused( FALSE ); | 68 | mediaPlayerState->setPaused( FALSE ); |
69 | } | 69 | } |
70 | 70 | ||
71 | 71 | ||
72 | void MediaPlayer::play() { | 72 | void MediaPlayer::play() { |
73 | mediaPlayerState->setPlaying( FALSE ); | 73 | mediaPlayerState->setPlaying( FALSE ); |
74 | mediaPlayerState->setPlaying( TRUE ); | 74 | mediaPlayerState->setPlaying( TRUE ); |
75 | } | 75 | } |
76 | 76 | ||
77 | 77 | ||
78 | void MediaPlayer::setPlaying( bool play ) { | 78 | void MediaPlayer::setPlaying( bool play ) { |
79 | |||
80 | if ( !play ) { | 79 | if ( !play ) { |
81 | mediaPlayerState->setPaused( FALSE ); | 80 | mediaPlayerState->setPaused( FALSE ); |
82 | loopControl->stop( FALSE ); | 81 | loopControl->stop( FALSE ); |
83 | return; | 82 | return; |
84 | } | 83 | } |
85 | 84 | ||
86 | if ( mediaPlayerState->paused() ) { | 85 | if ( mediaPlayerState->paused() ) { |
87 | mediaPlayerState->setPaused( FALSE ); | 86 | mediaPlayerState->setPaused( FALSE ); |
88 | return; | 87 | return; |
89 | } | 88 | } |
90 | 89 | ||
91 | const DocLnk *playListCurrent = playList->current(); | 90 | const DocLnk *playListCurrent = playList->current(); |
92 | |||
93 | if ( playListCurrent != NULL ) { | 91 | if ( playListCurrent != NULL ) { |
94 | loopControl->stop( TRUE ); | 92 | loopControl->stop( TRUE ); |
95 | currentFile = playListCurrent; | 93 | currentFile = playListCurrent; |
96 | } | 94 | } |
97 | |||
98 | if ( currentFile == NULL ) { | 95 | if ( currentFile == NULL ) { |
99 | QMessageBox::critical( 0, tr( "No file"), tr( "Error: There is no file selected" ) ); | 96 | QMessageBox::critical( 0, tr( "No file"), tr( "Error: There is no file selected" ) ); |
100 | mediaPlayerState->setPlaying( FALSE ); | 97 | mediaPlayerState->setPlaying( FALSE ); |
101 | return; | 98 | return; |
102 | } | 99 | } |
103 | |||
104 | if ( !QFile::exists( currentFile->file() ) ) { | 100 | if ( !QFile::exists( currentFile->file() ) ) { |
105 | QMessageBox::critical( 0, tr( "File not found"), tr( "The following file was not found: <i>" ) + currentFile->file() + "</i>" ); | 101 | QMessageBox::critical( 0, tr( "File not found"), tr( "The following file was not found: <i>" ) + currentFile->file() + "</i>" ); |
106 | mediaPlayerState->setPlaying( FALSE ); | 102 | mediaPlayerState->setPlaying( FALSE ); |
107 | return; | 103 | return; |
108 | } | 104 | } |
109 | 105 | ||
110 | if ( !mediaPlayerState->newDecoder( currentFile->file() ) ) { | 106 | if ( !mediaPlayerState->newDecoder( currentFile->file() ) ) { |
111 | QMessageBox::critical( 0, tr( "No decoder found"), tr( "Sorry, no appropriate decoders found for this file: <i>" ) + currentFile->file() + "</i>" ); | 107 | QMessageBox::critical( 0, tr( "No decoder found"), tr( "Sorry, no appropriate decoders found for this file: <i>" ) + currentFile->file() + "</i>" ); |
112 | mediaPlayerState->setPlaying( FALSE ); | 108 | mediaPlayerState->setPlaying( FALSE ); |
113 | return; | 109 | return; |
114 | } | 110 | } |
115 | 111 | ||
116 | if ( !loopControl->init( currentFile->file() ) ) { | 112 | if ( !loopControl->init( currentFile->file() ) ) { |
117 | QMessageBox::critical( 0, tr( "Error opening file"), tr( "Sorry, an error occured trying to play the file: <i>" ) + currentFile->file() + "</i>" ); | 113 | QMessageBox::critical( 0, tr( "Error opening file"), tr( "Sorry, an error occured trying to play the file: <i>" ) + currentFile->file() + "</i>" ); |
118 | mediaPlayerState->setPlaying( FALSE ); | 114 | mediaPlayerState->setPlaying( FALSE ); |
119 | return; | 115 | return; |
120 | } | 116 | } |
121 | |||
122 | long seconds = loopControl->totalPlaytime(); | 117 | long seconds = loopControl->totalPlaytime(); |
123 | QString time; time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); | 118 | QString time; time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); |
124 | QString tickerText = tr( " File: " ) + currentFile->name() + tr(", Length: ") + time; | 119 | QString tickerText = tr( " File: " ) + currentFile->name() + tr(", Length: ") + time; |
125 | QString fileInfo = mediaPlayerState->curDecoder()->fileInfo(); | 120 | QString fileInfo = mediaPlayerState->curDecoder()->fileInfo(); |
126 | if ( !fileInfo.isEmpty() ) | 121 | if ( !fileInfo.isEmpty() ) |
127 | tickerText += ", " + fileInfo; | 122 | tickerText += ", " + fileInfo; |
128 | audioUI->setTickerText( tickerText + "." ); | 123 | audioUI->setTickerText( tickerText + "." ); |
129 | 124 | ||
130 | loopControl->play(); | 125 | loopControl->play(); |
131 | 126 | ||
132 | mediaPlayerState->setView( loopControl->hasVideo() ? 'v' : 'a' ); | 127 | mediaPlayerState->setView( loopControl->hasVideo() ? 'v' : 'a' ); |
133 | } | 128 | } |
134 | 129 | ||
135 | 130 | ||
136 | void MediaPlayer::prev() { | 131 | void MediaPlayer::prev() { |
137 | if ( playList->prev() ) | 132 | if ( playList->prev() ) |
138 | play(); | 133 | play(); |
139 | else if ( mediaPlayerState->looping() ) { | 134 | else if ( mediaPlayerState->looping() ) { |
140 | if ( playList->last() ) | 135 | if ( playList->last() ) |
141 | play(); | 136 | play(); |
142 | } else | 137 | } else |
143 | mediaPlayerState->setList(); | 138 | mediaPlayerState->setList(); |
144 | } | 139 | } |
145 | 140 | ||
146 | 141 | ||
147 | void MediaPlayer::next() { | 142 | void MediaPlayer::next() { |
148 | if ( playList->next() ) | 143 | if ( playList->next() ) |
149 | play(); | 144 | play(); |
150 | else if ( mediaPlayerState->looping() ) { | 145 | else if ( mediaPlayerState->looping() ) { |
151 | if ( playList->first() ) | 146 | if ( playList->first() ) |
152 | play(); | 147 | play(); |
153 | } else | 148 | } else |
154 | mediaPlayerState->setList(); | 149 | mediaPlayerState->setList(); |
155 | } | 150 | } |
156 | 151 | ||
157 | 152 | ||
158 | void MediaPlayer::startDecreasingVolume() { | 153 | void MediaPlayer::startDecreasingVolume() { |
159 | volumeDirection = -1; | 154 | volumeDirection = -1; |
160 | startTimer( 100 ); | 155 | startTimer( 100 ); |
161 | AudioDevice::decreaseVolume(); | 156 | AudioDevice::decreaseVolume(); |
162 | } | 157 | } |
163 | 158 | ||
164 | 159 | ||
165 | void MediaPlayer::startIncreasingVolume() { | 160 | void MediaPlayer::startIncreasingVolume() { |
166 | volumeDirection = +1; | 161 | volumeDirection = +1; |
167 | startTimer( 100 ); | 162 | startTimer( 100 ); |
168 | AudioDevice::increaseVolume(); | 163 | AudioDevice::increaseVolume(); |
169 | } | 164 | } |
170 | 165 | ||
171 | 166 | ||
172 | void MediaPlayer::stopChangingVolume() { | 167 | void MediaPlayer::stopChangingVolume() { |
173 | killTimers(); | 168 | killTimers(); |
174 | } | 169 | } |
175 | 170 | ||
176 | 171 | ||
177 | void MediaPlayer::timerEvent( QTimerEvent * ) { | 172 | void MediaPlayer::timerEvent( QTimerEvent * ) { |
178 | if ( volumeDirection == +1 ) | 173 | if ( volumeDirection == +1 ) |
179 | AudioDevice::increaseVolume(); | 174 | AudioDevice::increaseVolume(); |
180 | else if ( volumeDirection == -1 ) | 175 | else if ( volumeDirection == -1 ) |
181 | AudioDevice::decreaseVolume(); | 176 | AudioDevice::decreaseVolume(); |
182 | } | 177 | } |
183 | 178 | ||
diff --git a/core/multimedia/opieplayer/mediaplayer.h b/core/multimedia/opieplayer/mediaplayer.h index 73f8124..d6e90cb 100644 --- a/core/multimedia/opieplayer/mediaplayer.h +++ b/core/multimedia/opieplayer/mediaplayer.h | |||
@@ -4,55 +4,55 @@ | |||
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef MEDIA_PLAYER_H | 20 | #ifndef MEDIA_PLAYER_H |
21 | #define MEDIA_PLAYER_H | 21 | #define MEDIA_PLAYER_H |
22 | 22 | ||
23 | #include <qmainwindow.h> | 23 | #include <qmainwindow.h> |
24 | #include <qframe.h> | 24 | #include <qframe.h> |
25 | #include <qpe/qlibrary.h> | 25 | #include <qpe/qlibrary.h> |
26 | #include <qpe/mediaplayerplugininterface.h> | 26 | #include <qpe/mediaplayerplugininterface.h> |
27 | 27 | ||
28 | 28 | ||
29 | class DocLnk; | 29 | class DocLnk; |
30 | 30 | ||
31 | 31 | ||
32 | class MediaPlayer : public QObject { | 32 | class MediaPlayer : public QObject { |
33 | Q_OBJECT | 33 | Q_OBJECT |
34 | public: | 34 | public: |
35 | MediaPlayer( QObject *parent, const char *name ); | 35 | MediaPlayer( QObject *parent, const char *name ); |
36 | ~MediaPlayer(); | 36 | ~MediaPlayer(); |
37 | 37 | ||
38 | private slots: | 38 | private slots: |
39 | void setPlaying( bool ); | 39 | void setPlaying( bool ); |
40 | void pauseCheck( bool ); | 40 | void pauseCheck( bool ); |
41 | void play(); | 41 | void play(); |
42 | void next(); | 42 | void next(); |
43 | void prev(); | 43 | void prev(); |
44 | void startIncreasingVolume(); | 44 | void startIncreasingVolume(); |
45 | void startDecreasingVolume(); | 45 | void startDecreasingVolume(); |
46 | void stopChangingVolume(); | 46 | void stopChangingVolume(); |
47 | 47 | ||
48 | protected: | 48 | protected: |
49 | void timerEvent( QTimerEvent *e ); | 49 | void timerEvent( QTimerEvent *e ); |
50 | 50 | ||
51 | private: | 51 | private: |
52 | int volumeDirection; | 52 | int volumeDirection; |
53 | const DocLnk*currentFile; | 53 | const DocLnk *currentFile; |
54 | }; | 54 | }; |
55 | 55 | ||
56 | 56 | ||
57 | #endif // MEDIA_PLAYER_H | 57 | #endif // MEDIA_PLAYER_H |
58 | 58 | ||
diff --git a/core/multimedia/opieplayer/mediaplayerplugininterface.h b/core/multimedia/opieplayer/mediaplayerplugininterface.h index 339b2e4..97e4066 100644 --- a/core/multimedia/opieplayer/mediaplayerplugininterface.h +++ b/core/multimedia/opieplayer/mediaplayerplugininterface.h | |||
@@ -1,111 +1,124 @@ | |||
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 | # ifndef IID_OpiePlayerPlugin |
27 | // {F56F6CE0-1333-41FD-9B46-C0AF44D0B006} | ||
28 | # define IID_OpiePlayerPlugin QUuid( 0xF56F6CE0, 0x1333, 0x41FD, 0x9B, 0x46, 0xC0, 0xAF, 0x44, 0xD0, 0xB0, 0x06); | ||
29 | # endif | ||
27 | # ifndef IID_MediaPlayerPlugin | 30 | # ifndef IID_MediaPlayerPlugin |
31 | // {c0093632-b44c-4cf7-a279-d82fe8a8890c} | ||
28 | # define IID_MediaPlayerPlugin QUuid( 0xc0093632, 0xb44c, 0x4cf7, 0xa2, 0x79, 0xd8, 0x2f, 0xe8, 0xa8, 0x89, 0x0c ) | 32 | # define IID_MediaPlayerPlugin QUuid( 0xc0093632, 0xb44c, 0x4cf7, 0xa2, 0x79, 0xd8, 0x2f, 0xe8, 0xa8, 0x89, 0x0c ) |
29 | # endif | 33 | # endif |
30 | #endif | 34 | #endif |
31 | 35 | ||
32 | 36 | ||
33 | enum ColorFormat { | 37 | enum ColorFormat { |
34 | RGB565, | 38 | RGB565, |
35 | BGR565, | 39 | BGR565, |
36 | RGBA8888, | 40 | RGBA8888, |
37 | BGRA8888 | 41 | BGRA8888 |
38 | }; | 42 | }; |
39 | 43 | ||
40 | 44 | ||
41 | class MediaPlayerDecoder { | 45 | class MediaPlayerDecoder { |
42 | 46 | ||
43 | public: | 47 | public: |
44 | virtual ~MediaPlayerDecoder() { }; | 48 | virtual ~MediaPlayerDecoder() { }; |
45 | 49 | ||
46 | // About Plugin | 50 | // About Plugin |
47 | virtual const char *pluginName() = 0; | 51 | virtual const char *pluginName() = 0; |
48 | virtual const char *pluginComment() = 0; | 52 | virtual const char *pluginComment() = 0; |
49 | virtual double pluginVersion() = 0; | 53 | virtual double pluginVersion() = 0; |
50 | 54 | ||
51 | virtual bool isFileSupported( const QString& file ) = 0; | 55 | virtual bool isFileSupported( const QString& file ) = 0; |
52 | virtual bool open( const QString& file ) = 0; | 56 | virtual bool open( const QString& file ) = 0; |
53 | virtual bool close() = 0; | 57 | virtual bool close() = 0; |
54 | virtual bool isOpen() = 0; | 58 | virtual bool isOpen() = 0; |
55 | virtual const QString &fileInfo() = 0; | 59 | virtual const QString &fileInfo() = 0; |
56 | 60 | ||
57 | // If decoder doesn't support audio then return 0 here | 61 | // If decoder doesn't support audio then return 0 here |
58 | virtual int audioStreams() = 0; | 62 | virtual int audioStreams() = 0; |
59 | virtual int audioChannels( int stream ) = 0; | 63 | virtual int audioChannels( int stream ) = 0; |
60 | virtual int audioFrequency( int stream ) = 0; | 64 | virtual int audioFrequency( int stream ) = 0; |
61 | virtual int audioSamples( int stream ) = 0; | 65 | virtual int audioSamples( int stream ) = 0; |
62 | virtual bool audioSetSample( long sample, int stream ) = 0; | 66 | virtual bool audioSetSample( long sample, int stream ) = 0; |
63 | virtual long audioGetSample( int stream ) = 0; | 67 | virtual long audioGetSample( int stream ) = 0; |
64 | virtual bool audioReadSamples( short *samples, int channels, long samples, long& samplesRead, int stream ) = 0; | 68 | virtual bool audioReadSamples( short *samples, int channels, long samples, long& samplesRead, int stream ) = 0; |
65 | 69 | ||
66 | // If decoder doesn't support video then return 0 here | 70 | // If decoder doesn't support video then return 0 here |
67 | virtual int videoStreams() = 0; | 71 | virtual int videoStreams() = 0; |
68 | virtual int videoWidth( int stream ) = 0; | 72 | virtual int videoWidth( int stream ) = 0; |
69 | virtual int videoHeight( int stream ) = 0; | 73 | virtual int videoHeight( int stream ) = 0; |
70 | virtual double videoFrameRate( int stream ) = 0; // frames per second (this may change to frames/1000secs) | 74 | virtual double videoFrameRate( int stream ) = 0; // frames per second (this may change to frames/1000secs) |
71 | virtual int videoFrames( int stream ) = 0; | 75 | virtual int videoFrames( int stream ) = 0; |
72 | virtual bool videoSetFrame( long sample, int stream ) = 0; | 76 | virtual bool videoSetFrame( long sample, int stream ) = 0; |
73 | virtual long videoGetFrame( int stream ) = 0; | 77 | virtual long videoGetFrame( int stream ) = 0; |
74 | virtual bool videoReadFrame( unsigned char **output_rows, int in_x, int in_y, int in_w, int in_h, ColorFormat color_model, int stream ) = 0; | 78 | virtual bool videoReadFrame( unsigned char **output_rows, int in_x, int in_y, int in_w, int in_h, ColorFormat color_model, int stream ) = 0; |
75 | virtual bool videoReadScaledFrame( unsigned char **output_rows, int in_x, int in_y, int in_w, int in_h, int out_w, int out_h, ColorFormat color_model, int stream ) = 0; | 79 | virtual bool videoReadScaledFrame( unsigned char **output_rows, int in_x, int in_y, int in_w, int in_h, int out_w, int out_h, ColorFormat color_model, int stream ) = 0; |
76 | virtual bool videoReadYUVFrame( char *y_output, char *u_output, char *v_output, int in_x, int in_y, int in_w, int in_h, int stream ) = 0; | 80 | virtual bool videoReadYUVFrame( char *y_output, char *u_output, char *v_output, int in_x, int in_y, int in_w, int in_h, int stream ) = 0; |
77 | 81 | ||
78 | // Profiling | 82 | // Profiling |
79 | virtual double getTime() = 0; | 83 | virtual double getTime() = 0; |
80 | 84 | ||
81 | // Ignore if these aren't supported | 85 | // Ignore if these aren't supported |
82 | virtual bool setSMP( int cpus ) = 0; | 86 | virtual bool setSMP( int cpus ) = 0; |
83 | virtual bool setMMX( bool useMMX ) = 0; | 87 | virtual bool setMMX( bool useMMX ) = 0; |
84 | 88 | ||
85 | // Capabilities | 89 | // Capabilities |
86 | virtual bool supportsAudio() = 0; | 90 | virtual bool supportsAudio() = 0; |
87 | virtual bool supportsVideo() = 0; | 91 | virtual bool supportsVideo() = 0; |
88 | virtual bool supportsYUV() = 0; | 92 | virtual bool supportsYUV() = 0; |
89 | virtual bool supportsMMX() = 0; | 93 | virtual bool supportsMMX() = 0; |
90 | virtual bool supportsSMP() = 0; | 94 | virtual bool supportsSMP() = 0; |
91 | virtual bool supportsStereo() = 0; | 95 | virtual bool supportsStereo() = 0; |
92 | virtual bool supportsScaling() = 0; | 96 | virtual bool supportsScaling() = 0; |
93 | 97 | ||
94 | // File Properies | 98 | // File Properies |
95 | virtual long getPlayTime() { return -1; } | 99 | virtual long getPlayTime() { return -1; } |
100 | #ifdef IID_OpiePlayerPlugin | ||
96 | virtual int audioBitsPerSample( int stream ) = 0; | 101 | virtual int audioBitsPerSample( int stream ) = 0; |
102 | #endif | ||
97 | }; | 103 | }; |
98 | 104 | ||
99 | 105 | ||
100 | class MediaPlayerEncoder; | 106 | class MediaPlayerEncoder; |
101 | 107 | ||
102 | 108 | ||
103 | struct MediaPlayerPluginInterface : public QUnknownInterface | 109 | struct MediaPlayerPluginInterface : public QUnknownInterface |
104 | { | 110 | { |
105 | virtual MediaPlayerDecoder *decoder() = 0; | 111 | virtual MediaPlayerDecoder *decoder() = 0; |
106 | virtual MediaPlayerEncoder *encoder() = 0; | 112 | virtual MediaPlayerEncoder *encoder() = 0; |
107 | }; | 113 | }; |
108 | 114 | ||
115 | #ifdef IID_OpiePlayerPlugin | ||
116 | struct OpiePlayerPluginInterface : public QUnknownInterface | ||
117 | { | ||
118 | virtual MediaPlayerDecoder *decoder() = 0; | ||
119 | virtual MediaPlayerEncoder *encoder() = 0; | ||
120 | }; | ||
121 | #endif | ||
109 | 122 | ||
110 | #endif | 123 | #endif |
111 | 124 | ||
diff --git a/core/multimedia/opieplayer/mediaplayerstate.cpp b/core/multimedia/opieplayer/mediaplayerstate.cpp index 13741f6..a960c49 100644 --- a/core/multimedia/opieplayer/mediaplayerstate.cpp +++ b/core/multimedia/opieplayer/mediaplayerstate.cpp | |||
@@ -1,190 +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 <qpe/mediaplayerplugininterface.h> |
27 | #include "mediaplayerstate.h" | 27 | #include "mediaplayerstate.h" |
28 | 28 | ||
29 | 29 | ||
30 | |||
30 | #ifdef QT_NO_COMPONENT | 31 | #ifdef QT_NO_COMPONENT |
31 | // Plugins which are compiled in when no plugin architecture available | 32 | // Plugins which are compiled in when no plugin architecture available |
32 | #include "libmad/libmadpluginimpl.h" | 33 | #include "libmad/libmadpluginimpl.h" |
33 | #include "libmpeg3/libmpeg3pluginimpl.h" | 34 | #include "libmpeg3/libmpeg3pluginimpl.h" |
34 | #include "wavplugin/wavpluginimpl.h" | 35 | #include "wavplugin/wavpluginimpl.h" |
35 | #endif | 36 | #endif |
36 | 37 | ||
37 | 38 | ||
38 | //#define MediaPlayerDebug(x) qDebug x | 39 | //#define MediaPlayerDebug(x) qDebug x |
39 | #define MediaPlayerDebug(x) | 40 | #define MediaPlayerDebug(x) |
40 | 41 | ||
41 | 42 | ||
42 | MediaPlayerState::MediaPlayerState( QObject *parent, const char *name ) | 43 | MediaPlayerState::MediaPlayerState( QObject *parent, const char *name ) |
43 | : QObject( parent, name ), decoder( NULL ), libmpeg3decoder( NULL ) { | 44 | : QObject( parent, name ), decoder( NULL ), libmpeg3decoder( NULL ) { |
44 | Config cfg( "MediaPlayer" ); | 45 | Config cfg( "MediaPlayer" ); |
45 | readConfig( cfg ); | 46 | readConfig( cfg ); |
46 | loadPlugins(); | 47 | loadPlugins(); |
47 | } | 48 | } |
48 | 49 | ||
49 | 50 | ||
50 | MediaPlayerState::~MediaPlayerState() { | 51 | MediaPlayerState::~MediaPlayerState() { |
51 | Config cfg( "MediaPlayer" ); | 52 | Config cfg( "MediaPlayer" ); |
52 | writeConfig( cfg ); | 53 | writeConfig( cfg ); |
53 | } | 54 | } |
54 | 55 | ||
55 | 56 | ||
56 | void MediaPlayerState::readConfig( Config& cfg ) { | 57 | void MediaPlayerState::readConfig( Config& cfg ) { |
57 | cfg.setGroup("Options"); | 58 | cfg.setGroup("Options"); |
58 | isFullscreen = cfg.readBoolEntry( "FullScreen" ); | 59 | isFullscreen = cfg.readBoolEntry( "FullScreen" ); |
59 | isScaled = cfg.readBoolEntry( "Scaling" ); | 60 | isScaled = cfg.readBoolEntry( "Scaling" ); |
60 | isLooping = cfg.readBoolEntry( "Looping" ); | 61 | isLooping = cfg.readBoolEntry( "Looping" ); |
61 | isShuffled = cfg.readBoolEntry( "Shuffle" ); | 62 | isShuffled = cfg.readBoolEntry( "Shuffle" ); |
62 | usePlaylist = cfg.readBoolEntry( "UsePlayList" ); | 63 | usePlaylist = cfg.readBoolEntry( "UsePlayList" ); |
64 | usePlaylist = TRUE; | ||
63 | isPlaying = FALSE; | 65 | isPlaying = FALSE; |
64 | isPaused = FALSE; | 66 | isPaused = FALSE; |
65 | curPosition = 0; | 67 | curPosition = 0; |
66 | curLength = 0; | 68 | curLength = 0; |
67 | curView = 'l'; | 69 | curView = 'l'; |
68 | } | 70 | } |
69 | 71 | ||
70 | 72 | ||
71 | void MediaPlayerState::writeConfig( Config& cfg ) const { | 73 | void MediaPlayerState::writeConfig( Config& cfg ) const { |
72 | cfg.setGroup("Options"); | 74 | cfg.setGroup("Options"); |
73 | cfg.writeEntry("FullScreen", isFullscreen ); | 75 | cfg.writeEntry("FullScreen", isFullscreen ); |
74 | cfg.writeEntry("Scaling", isScaled ); | 76 | cfg.writeEntry("Scaling", isScaled ); |
75 | cfg.writeEntry("Looping", isLooping ); | 77 | cfg.writeEntry("Looping", isLooping ); |
76 | cfg.writeEntry("Shuffle", isShuffled ); | 78 | cfg.writeEntry("Shuffle", isShuffled ); |
77 | cfg.writeEntry("UsePlayList", usePlaylist ); | 79 | cfg.writeEntry("UsePlayList", usePlaylist ); |
78 | } | 80 | } |
79 | 81 | ||
80 | 82 | ||
81 | struct MediaPlayerPlugin { | 83 | struct MediaPlayerPlugin { |
82 | #ifndef QT_NO_COMPONENT | 84 | #ifndef QT_NO_COMPONENT |
83 | QLibrary *library; | 85 | QLibrary *library; |
84 | #endif | 86 | #endif |
85 | MediaPlayerPluginInterface *iface; | 87 | MediaPlayerPluginInterface *iface; |
86 | MediaPlayerDecoder *decoder; | 88 | MediaPlayerDecoder *decoder; |
87 | MediaPlayerEncoder *encoder; | 89 | MediaPlayerEncoder *encoder; |
88 | }; | 90 | }; |
89 | 91 | ||
90 | 92 | ||
91 | static QValueList<MediaPlayerPlugin> pluginList; | 93 | static QValueList<MediaPlayerPlugin> pluginList; |
92 | 94 | ||
93 | 95 | ||
94 | // Find the first decoder which supports this type of file | 96 | // Find the first decoder which supports this type of file |
95 | MediaPlayerDecoder *MediaPlayerState::newDecoder( const QString& file ) { | 97 | MediaPlayerDecoder *MediaPlayerState::newDecoder( const QString& file ) { |
96 | MediaPlayerDecoder *tmpDecoder = NULL; | 98 | MediaPlayerDecoder *tmpDecoder = NULL; |
97 | QValueList<MediaPlayerPlugin>::Iterator it; | 99 | QValueList<MediaPlayerPlugin>::Iterator it; |
98 | for ( it = pluginList.begin(); it != pluginList.end(); ++it ) { | 100 | for ( it = pluginList.begin(); it != pluginList.end(); ++it ) { |
99 | if ( (*it).decoder->isFileSupported( file ) ) { | 101 | if ( (*it).decoder->isFileSupported( file ) ) { |
100 | tmpDecoder = (*it).decoder; | 102 | tmpDecoder = (*it).decoder; |
101 | break; | 103 | break; |
102 | } | 104 | } |
103 | } | 105 | } |
104 | return decoder = tmpDecoder; | 106 | return decoder = tmpDecoder; |
105 | } | 107 | } |
106 | 108 | ||
107 | 109 | ||
108 | MediaPlayerDecoder *MediaPlayerState::curDecoder() { | 110 | MediaPlayerDecoder *MediaPlayerState::curDecoder() { |
109 | return decoder; | 111 | return decoder; |
110 | } | 112 | } |
111 | 113 | ||
112 | 114 | ||
113 | // ### hack to get true sample count | 115 | // ### hack to get true sample count |
114 | MediaPlayerDecoder *MediaPlayerState::libMpeg3Decoder() { | 116 | MediaPlayerDecoder *MediaPlayerState::libMpeg3Decoder() { |
115 | return libmpeg3decoder; | 117 | return libmpeg3decoder; |
116 | } | 118 | } |
117 | 119 | ||
118 | // ### hack to get true sample count | 120 | // ### hack to get true sample count |
119 | // MediaPlayerDecoder *MediaPlayerState::libWavDecoder() { | 121 | // MediaPlayerDecoder *MediaPlayerState::libWavDecoder() { |
120 | // return libwavdecoder; | 122 | // return libwavdecoder; |
121 | // } | 123 | // } |
122 | 124 | ||
123 | void MediaPlayerState::loadPlugins() { | 125 | void MediaPlayerState::loadPlugins() { |
124 | 126 | qDebug("load plugins"); | |
125 | #ifndef QT_NO_COMPONENT | 127 | #ifndef QT_NO_COMPONENT |
126 | QValueList<MediaPlayerPlugin>::Iterator mit; | 128 | QValueList<MediaPlayerPlugin>::Iterator mit; |
127 | for ( mit = pluginList.begin(); mit != pluginList.end(); ++mit ) { | 129 | for ( mit = pluginList.begin(); mit != pluginList.end(); ++mit ) { |
128 | (*mit).iface->release(); | 130 | (*mit).iface->release(); |
129 | (*mit).library->unload(); | 131 | (*mit).library->unload(); |
130 | delete (*mit).library; | 132 | delete (*mit).library; |
131 | } | 133 | } |
132 | pluginList.clear(); | 134 | pluginList.clear(); |
133 | 135 | ||
134 | QString path = QPEApplication::qpeDir() + "/plugins/codecs"; | 136 | QString path = QPEApplication::qpeDir() + "/plugins/codecs"; |
135 | QDir dir( path, "lib*.so" ); | 137 | QDir dir( path, "lib*.so" ); |
136 | QStringList list = dir.entryList(); | 138 | QStringList list = dir.entryList(); |
137 | QStringList::Iterator it; | 139 | QStringList::Iterator it; |
138 | for ( it = list.begin(); it != list.end(); ++it ) { | 140 | for ( it = list.begin(); it != list.end(); ++it ) { |
139 | MediaPlayerPluginInterface *iface = 0; | 141 | MediaPlayerPluginInterface *iface = 0; |
140 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 142 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
141 | 143 | // qDebug( "querying: %s", QString( path + "/" + *it ).latin1() ); | |
142 | MediaPlayerDebug(( "querying: %s", QString( path + "/" + *it ).latin1() )); | ||
143 | 144 | ||
144 | if ( lib->queryInterface( IID_MediaPlayerPlugin, (QUnknownInterface**)&iface ) == QS_OK ) { | 145 | if ( lib->queryInterface( IID_MediaPlayerPlugin, (QUnknownInterface**)&iface ) == QS_OK ) { |
145 | 146 | ||
146 | MediaPlayerDebug(( "loading: %s", QString( path + "/" + *it ).latin1() )); | 147 | // qDebug( "loading: %s", QString( path + "/" + *it ).latin1() ); |
147 | 148 | ||
148 | MediaPlayerPlugin plugin; | 149 | MediaPlayerPlugin plugin; |
149 | plugin.library = lib; | 150 | plugin.library = lib; |
150 | plugin.iface = iface; | 151 | plugin.iface = iface; |
151 | plugin.decoder = plugin.iface->decoder(); | 152 | plugin.decoder = plugin.iface->decoder(); |
152 | plugin.encoder = plugin.iface->encoder(); | 153 | plugin.encoder = plugin.iface->encoder(); |
153 | pluginList.append( plugin ); | 154 | pluginList.append( plugin ); |
154 | 155 | ||
155 | // ### hack to get true sample count | 156 | // ### hack to get true sample count |
156 | if ( plugin.decoder->pluginName() == QString("LibMpeg3Plugin") ) | 157 | if ( plugin.decoder->pluginName() == QString("LibMpeg3Plugin") ) |
157 | libmpeg3decoder = plugin.decoder; | 158 | libmpeg3decoder = plugin.decoder; |
158 | 159 | ||
159 | } else { | 160 | } else { |
160 | delete lib; | 161 | delete lib; |
161 | } | 162 | } |
162 | } | 163 | } |
163 | #else | 164 | #else |
164 | pluginList.clear(); | 165 | pluginList.clear(); |
165 | 166 | ||
166 | MediaPlayerPlugin plugin0; | 167 | MediaPlayerPlugin plugin0; |
167 | plugin0.iface = new LibMpeg3PluginImpl; | 168 | plugin0.iface = new LibMpeg3PluginImpl; |
168 | plugin0.decoder = plugin0.iface->decoder(); | 169 | plugin0.decoder = plugin0.iface->decoder(); |
169 | plugin0.encoder = plugin0.iface->encoder(); | 170 | plugin0.encoder = plugin0.iface->encoder(); |
170 | pluginList.append( plugin0 ); | 171 | pluginList.append( plugin0 ); |
171 | 172 | ||
172 | MediaPlayerPlugin plugin1; | 173 | MediaPlayerPlugin plugin1; |
173 | plugin1.iface = new LibMadPluginImpl; | 174 | plugin1.iface = new LibMadPluginImpl; |
174 | plugin1.decoder = plugin1.iface->decoder(); | 175 | plugin1.decoder = plugin1.iface->decoder(); |
175 | plugin1.encoder = plugin1.iface->encoder(); | 176 | plugin1.encoder = plugin1.iface->encoder(); |
176 | pluginList.append( plugin1 ); | 177 | pluginList.append( plugin1 ); |
177 | 178 | ||
178 | MediaPlayerPlugin plugin2; | 179 | MediaPlayerPlugin plugin2; |
179 | plugin2.iface = new WavPluginImpl; | 180 | plugin2.iface = new WavPluginImpl; |
180 | plugin2.decoder = plugin2.iface->decoder(); | 181 | plugin2.decoder = plugin2.iface->decoder(); |
181 | plugin2.encoder = plugin2.iface->encoder(); | 182 | plugin2.encoder = plugin2.iface->encoder(); |
182 | pluginList.append( plugin2 ); | 183 | pluginList.append( plugin2 ); |
183 | #endif | 184 | #endif |
184 | 185 | ||
185 | if ( pluginList.count() ) | 186 | if ( pluginList.count() ) |
186 | MediaPlayerDebug(( "%i decoders found", pluginList.count() )); | 187 | MediaPlayerDebug(( "%i decoders found", pluginList.count() )); |
187 | else | 188 | else |
188 | MediaPlayerDebug(( "No decoders found" )); | 189 | MediaPlayerDebug(( "No decoders found" )); |
189 | } | 190 | } |
190 | 191 | ||
diff --git a/core/multimedia/opieplayer/mediaplayerstate.h b/core/multimedia/opieplayer/mediaplayerstate.h index e82c263..ad273f1 100644 --- a/core/multimedia/opieplayer/mediaplayerstate.h +++ b/core/multimedia/opieplayer/mediaplayerstate.h | |||
@@ -1,116 +1,119 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the 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 | #include <qobject.h> | 24 | #include <qobject.h> |
24 | 25 | ||
25 | 26 | ||
26 | class MediaPlayerDecoder; | 27 | class MediaPlayerDecoder; |
27 | class Config; | 28 | class Config; |
28 | 29 | ||
29 | 30 | ||
30 | class MediaPlayerState : public QObject { | 31 | class MediaPlayerState : public QObject { |
31 | Q_OBJECT | 32 | Q_OBJECT |
32 | public: | 33 | public: |
33 | MediaPlayerState( QObject *parent, const char *name ); | 34 | MediaPlayerState( QObject *parent, const char *name ); |
34 | ~MediaPlayerState(); | 35 | ~MediaPlayerState(); |
35 | 36 | ||
36 | bool fullscreen() { return isFullscreen; } | 37 | |
37 | bool scaled() { return isScaled; } | 38 | bool fullscreen() { return isFullscreen; } |
38 | bool looping() { return isLooping; } | 39 | bool scaled() { return isScaled; } |
39 | bool shuffled() { return isShuffled; } | 40 | bool looping() { return isLooping; } |
40 | bool playlist() { return usePlaylist; } | 41 | bool shuffled() { return isShuffled; } |
41 | bool paused() { return isPaused; } | 42 | bool playlist() { return usePlaylist; } |
42 | bool playing() { return isPlaying; } | 43 | bool paused() { return isPaused; } |
43 | long position() { return curPosition; } | 44 | bool playing() { return isPlaying; } |
44 | long length() { return curLength; } | 45 | long position() { return curPosition; } |
45 | char view() { return curView; } | 46 | long length() { return curLength; } |
47 | char view() { return curView; } | ||
46 | 48 | ||
47 | MediaPlayerDecoder *newDecoder( const QString& file ); | 49 | MediaPlayerDecoder *newDecoder( const QString& file ); |
48 | MediaPlayerDecoder *curDecoder(); | 50 | MediaPlayerDecoder *curDecoder(); |
49 | MediaPlayerDecoder *libMpeg3Decoder(); // ### Yucky hack needed to use libmpeg3plugin to get the | 51 | MediaPlayerDecoder *libMpeg3Decoder(); // ### Yucky hack needed to use libmpeg3plugin to get the |
50 | // number of audio samples if we are using the libmad plugin | 52 | // number of audio samples if we are using the libmad plugin |
51 | public slots: | 53 | public slots: |
52 | void setFullscreen( bool b ) { if ( isFullscreen == b ) return; isFullscreen = b; emit fullscreenToggled(b); } | 54 | void setFullscreen( bool b ) { if ( isFullscreen == b ) return; isFullscreen = b; emit fullscreenToggled(b); } |
53 | void setScaled( bool b ) { if ( isScaled == b ) return; isScaled = b; emit scaledToggled(b); } | 55 | void setScaled( bool b ) { if ( isScaled == b ) return; isScaled = b; emit scaledToggled(b); } |
54 | void setLooping( bool b ) { if ( isLooping == b ) return; isLooping = b; emit loopingToggled(b); } | 56 | void setLooping( bool b ) { if ( isLooping == b ) return; isLooping = b; emit loopingToggled(b); } |
55 | void setShuffled( bool b ) { if ( isShuffled == b ) return; isShuffled = b; emit shuffledToggled(b); } | 57 | void setShuffled( bool b ) { if ( isShuffled == b ) return; isShuffled = b; emit shuffledToggled(b); } |
56 | void setPlaylist( bool b ) { if ( usePlaylist == b ) return; usePlaylist = b; emit playlistToggled(b); } | 58 | void setPlaylist( bool b ) { if ( usePlaylist == b ) return; usePlaylist = b; emit playlistToggled(b); } |
57 | void setPaused( bool b ) { if ( isPaused == b ) return; isPaused = b; emit pausedToggled(b); } | 59 | void setPaused( bool b ) { if ( isPaused == b ) return; isPaused = b; emit pausedToggled(b); } |
58 | void setPlaying( bool b ) { if ( isPlaying == b ) return; isPlaying = b; emit playingToggled(b); } | 60 | void setPlaying( bool b ) { if ( isPlaying == b ) return; isPlaying = b; emit playingToggled(b); } |
59 | void setPosition( long p ) { if ( curPosition == p ) return; curPosition = p; emit positionChanged(p); } | 61 | void setPosition( long p ) { if ( curPosition == p ) return; curPosition = p; emit positionChanged(p); } |
60 | void updatePosition( long p ){ if ( curPosition == p ) return; curPosition = p; emit positionUpdated(p); } | 62 | void updatePosition( long p ){ if ( curPosition == p ) return; curPosition = p; emit positionUpdated(p); } |
61 | void setLength( long l ) { if ( curLength == l ) return; curLength = l; emit lengthChanged(l); } | 63 | void setLength( long l ) { if ( curLength == l ) return; curLength = l; emit lengthChanged(l); } |
62 | void setView( char v ) { if ( curView == v ) return; curView = v; emit viewChanged(v); } | 64 | void setView( char v ) { if ( curView == v ) return; curView = v; emit viewChanged(v); } |
63 | 65 | ||
64 | void setPrev() { emit prev(); } | 66 | void setPrev() { emit prev(); } |
65 | void setNext() { emit next(); } | 67 | void setNext() { emit next(); } |
66 | void setList() { setPlaying( FALSE ); setView('l'); } | 68 | void setList() { setPlaying( FALSE ); setView('l'); } |
67 | void setVideo() { setView('v'); } | 69 | void setVideo() { setView('v'); } |
68 | void setAudio() { setView('a'); } | 70 | void setAudio() { setView('a'); } |
69 | 71 | ||
70 | void toggleFullscreen() { setFullscreen( !isFullscreen ); } | 72 | void toggleFullscreen() { setFullscreen( !isFullscreen ); } |
71 | void toggleScaled() { setScaled( !isScaled); } | 73 | void toggleScaled() { setScaled( !isScaled); } |
72 | void toggleLooping() { setLooping( !isLooping); } | 74 | void toggleLooping() { setLooping( !isLooping); } |
73 | void toggleShuffled() { setShuffled( !isShuffled); } | 75 | void toggleShuffled() { setShuffled( !isShuffled); } |
74 | void togglePlaylist() { setPlaylist( !usePlaylist); } | 76 | void togglePlaylist() { setPlaylist( !usePlaylist); } |
75 | void togglePaused() { setPaused( !isPaused); } | 77 | void togglePaused() { setPaused( !isPaused); } |
76 | void togglePlaying() { setPlaying( !isPlaying); } | 78 | void togglePlaying() { setPlaying( !isPlaying); } |
77 | 79 | ||
78 | signals: | 80 | signals: |
79 | void fullscreenToggled( bool ); | 81 | void fullscreenToggled( bool ); |
80 | void scaledToggled( bool ); | 82 | void scaledToggled( bool ); |
81 | void loopingToggled( bool ); | 83 | void loopingToggled( bool ); |
82 | void shuffledToggled( bool ); | 84 | void shuffledToggled( bool ); |
83 | void playlistToggled( bool ); | 85 | void playlistToggled( bool ); |
84 | void pausedToggled( bool ); | 86 | void pausedToggled( bool ); |
85 | void playingToggled( bool ); | 87 | void playingToggled( bool ); |
86 | void positionChanged( long ); // When the slider is moved | 88 | void positionChanged( long ); // When the slider is moved |
87 | void positionUpdated( long ); // When the media file progresses | 89 | void positionUpdated( long ); // When the media file progresses |
88 | void lengthChanged( long ); | 90 | void lengthChanged( long ); |
89 | void viewChanged( char ); | 91 | void viewChanged( char ); |
90 | 92 | ||
91 | void prev(); | 93 | void prev(); |
92 | void next(); | 94 | void next(); |
93 | 95 | ||
94 | private: | 96 | private: |
95 | bool isFullscreen; | 97 | bool isFullscreen; |
96 | bool isScaled; | 98 | bool isScaled; |
97 | bool isLooping; | 99 | bool isLooping; |
98 | bool isShuffled; | 100 | bool isShuffled; |
99 | bool usePlaylist; | 101 | bool usePlaylist; |
100 | bool isPaused; | 102 | bool isPaused; |
101 | bool isPlaying; | 103 | bool isPlaying; |
102 | long curPosition; | 104 | long curPosition; |
103 | long curLength; | 105 | long curLength; |
104 | char curView; | 106 | char curView; |
105 | 107 | ||
106 | MediaPlayerDecoder *decoder; | 108 | MediaPlayerDecoder *decoder; |
107 | MediaPlayerDecoder *libmpeg3decoder; | 109 | MediaPlayerDecoder *libmpeg3decoder; |
110 | // MediaPlayerDecoder *libwavdecoder; | ||
108 | 111 | ||
109 | void loadPlugins(); | 112 | void loadPlugins(); |
110 | void readConfig( Config& cfg ); | 113 | void readConfig( Config& cfg ); |
111 | void writeConfig( Config& cfg ) const; | 114 | void writeConfig( Config& cfg ) const; |
112 | }; | 115 | }; |
113 | 116 | ||
114 | 117 | ||
115 | #endif // MEDIA_PLAYER_STATE_H | 118 | #endif // MEDIA_PLAYER_STATE_H |
116 | 119 | ||
diff --git a/core/multimedia/opieplayer/mpegplayer.pro b/core/multimedia/opieplayer/mpegplayer.pro index 41f2de0..5bea541 100644 --- a/core/multimedia/opieplayer/mpegplayer.pro +++ b/core/multimedia/opieplayer/mpegplayer.pro | |||
@@ -1,22 +1,25 @@ | |||
1 | TEMPLATE = app | 1 | TEMPLATE = app |
2 | CONFIG = qt warn_on release | 2 | CONFIG = qt warn_on release |
3 | #release | 3 | #release |
4 | DESTDIR = $(OPIEDIR)/bin | 4 | DESTDIR = $(OPIEDIR)/bin |
5 | HEADERS = loopcontrol.h mediaplayerplugininterface.h playlistselection.h mediaplayerstate.h \ | 5 | HEADERS = loopcontrol.h mediaplayerplugininterface.h playlistselection.h mediaplayerstate.h \ |
6 | videowidget.h audiowidget.h playlistwidget.h mediaplayer.h audiodevice.h | 6 | videowidget.h audiowidget.h playlistwidget.h mediaplayer.h audiodevice.h inputDialog.h |
7 | SOURCES = main.cpp \ | 7 | SOURCES = main.cpp \ |
8 | loopcontrol.cpp playlistselection.cpp mediaplayerstate.cpp \ | 8 | loopcontrol.cpp playlistselection.cpp mediaplayerstate.cpp \ |
9 | videowidget.cpp audiowidget.cpp playlistwidget.cpp mediaplayer.cpp audiodevice.cpp | 9 | videowidget.cpp audiowidget.cpp playlistwidget.cpp mediaplayer.cpp audiodevice.cpp inputDialog.cpp |
10 | TARGET = mpegplayer | 10 | TARGET = mpegplayer |
11 | INCLUDEPATH += $(OPIEDIR)/include | 11 | INCLUDEPATH += $(OPIEDIR)/include |
12 | DEPENDPATH += $(OPIEDIR)/include | 12 | DEPENDPATH += $(OPIEDIR)/include |
13 | LIBS += -lqpe -lpthread | 13 | LIBS += -lqpe -lpthread |
14 | 14 | ||
15 | # INTERFACES = | 15 | # INTERFACES = |
16 | # INCLUDEPATH += $(OPIEDIR)/include | 16 | # INCLUDEPATH += $(OPIEDIR)/include |
17 | # CONFIG+=static | 17 | # CONFIG+=static |
18 | # TMAKE_CXXFLAGS += -DQPIM_STANDALONE | 18 | # TMAKE_CXXFLAGS += -DQPIM_STANDALONE |
19 | # LIBS += libmpeg3/libmpeg3.a -lpthread | 19 | # LIBS += libmpeg3/libmpeg3.a -lpthread |
20 | # LIBS += $(OPIEDIR)/plugins/codecs/liblibmadplugin.so | 20 | # LIBS += $(OPIEDIR)/plugins/codecs/liblibmadplugin.so |
21 | 21 | ||
22 | INCLUDEPATH += $(OPIEDIR)/include | ||
23 | DEPENDPATH += $(OPIEDIR)/include | ||
24 | |||
22 | TRANSLATIONS = ../i18n/de/mpegplayer.ts | 25 | TRANSLATIONS = ../i18n/de/mpegplayer.ts |
diff --git a/core/multimedia/opieplayer/playlistselection.cpp b/core/multimedia/opieplayer/playlistselection.cpp index 2c62e86..d70df51 100644 --- a/core/multimedia/opieplayer/playlistselection.cpp +++ b/core/multimedia/opieplayer/playlistselection.cpp | |||
@@ -10,99 +10,99 @@ | |||
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 | class PlayListSelectionItem : public QListViewItem { | 33 | class PlayListSelectionItem : public QListViewItem { |
34 | public: | 34 | public: |
35 | PlayListSelectionItem( QListView *parent, const DocLnk *f ) : QListViewItem( parent ), fl( f ) { | 35 | PlayListSelectionItem( QListView *parent, const DocLnk *f ) : QListViewItem( parent ), fl( f ) { |
36 | setText( 0, f->name() ); | 36 | setText( 0, f->name() ); |
37 | setPixmap( 0, f->pixmap() ); | 37 | setPixmap( 0, f->pixmap() ); |
38 | } | 38 | } |
39 | 39 | ||
40 | ~PlayListSelectionItem() { | 40 | ~PlayListSelectionItem() { |
41 | }; | 41 | }; |
42 | 42 | ||
43 | const DocLnk *file() const { return fl; } | 43 | const DocLnk *file() const { return fl; } |
44 | 44 | ||
45 | private: | 45 | private: |
46 | const DocLnk *fl; | 46 | const DocLnk *fl; |
47 | }; | 47 | }; |
48 | 48 | ||
49 | 49 | ||
50 | PlayListSelection::PlayListSelection( QWidget *parent, const char *name ) | 50 | PlayListSelection::PlayListSelection( QWidget *parent, const char *name ) |
51 | : QListView( parent, name ) | 51 | : QListView( parent, name ) |
52 | { | 52 | { |
53 | // #ifdef USE_PLAYLIST_BACKGROUND | 53 | // #ifdef USE_PLAYLIST_BACKGROUND |
54 | setStaticBackground( TRUE ); | 54 | setStaticBackground( TRUE ); |
55 | // setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/background" ) ); | 55 | // setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/background" ) ); |
56 | setBackgroundPixmap( Resource::loadPixmap( "opielogo" ) ); | 56 | setBackgroundPixmap( Resource::loadPixmap( "opielogo" ) ); |
57 | // #endif | 57 | // #endif |
58 | addColumn("Title",236); | 58 | // addColumn("Title",236); |
59 | setAllColumnsShowFocus( TRUE ); | 59 | // setAllColumnsShowFocus( TRUE ); |
60 | addColumn( tr( "Playlist Selection" ) ); | 60 | addColumn( tr( "Playlist Selection" ) ); |
61 | header()->hide(); | 61 | header()->hide(); |
62 | setSorting( -1, FALSE ); | 62 | setSorting( -1, FALSE ); |
63 | } | 63 | } |
64 | 64 | ||
65 | 65 | ||
66 | PlayListSelection::~PlayListSelection() { | 66 | PlayListSelection::~PlayListSelection() { |
67 | } | 67 | } |
68 | 68 | ||
69 | 69 | ||
70 | // #ifdef USE_PLAYLIST_BACKGROUND | 70 | // #ifdef USE_PLAYLIST_BACKGROUND |
71 | void PlayListSelection::drawBackground( QPainter *p, const QRect &r ) { | 71 | void PlayListSelection::drawBackground( QPainter *p, const QRect &r ) { |
72 | p->fillRect( r, QBrush( white ) ); | 72 | p->fillRect( r, QBrush( white ) ); |
73 | // QImage logo = Resource::loadImage( "mpegplayer/background" ); | 73 | // QImage logo = Resource::loadImage( "mpegplayer/background" ); |
74 | QImage logo = Resource::loadImage( "opielogo" ); | 74 | QImage logo = Resource::loadImage( "opielogo" ); |
75 | if ( !logo.isNull() ) | 75 | if ( !logo.isNull() ) |
76 | p->drawImage( (width() - logo.width()) / 2, (height() - logo.height()) / 2, logo ); | 76 | p->drawImage( (width() - logo.width()) / 2, (height() - logo.height()) / 2, logo ); |
77 | } | 77 | } |
78 | // #endif | 78 | // #endif |
79 | 79 | ||
80 | 80 | ||
81 | void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) { | 81 | void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) { |
82 | if ( event->state() == QMouseEvent::LeftButton ) { | 82 | if ( event->state() == QMouseEvent::LeftButton ) { |
83 | QListViewItem *currentItem = selectedItem(); | 83 | QListViewItem *currentItem = selectedItem(); |
84 | QListViewItem *itemUnder = itemAt( QPoint( event->pos().x(), event->pos().y() - contentsY() ) ); | 84 | QListViewItem *itemUnder = itemAt( QPoint( event->pos().x(), event->pos().y() - contentsY() ) ); |
85 | if ( currentItem && currentItem->itemAbove() == itemUnder ) | 85 | if ( currentItem && currentItem->itemAbove() == itemUnder ) |
86 | moveSelectedUp(); | 86 | moveSelectedUp(); |
87 | else if ( currentItem && currentItem->itemBelow() == itemUnder ) | 87 | else if ( currentItem && currentItem->itemBelow() == itemUnder ) |
88 | moveSelectedDown(); | 88 | moveSelectedDown(); |
89 | } | 89 | } |
90 | } | 90 | } |
91 | 91 | ||
92 | 92 | ||
93 | const DocLnk *PlayListSelection::current() { | 93 | const DocLnk *PlayListSelection::current() { |
94 | PlayListSelectionItem *item = (PlayListSelectionItem *)selectedItem(); | 94 | PlayListSelectionItem *item = (PlayListSelectionItem *)selectedItem(); |
95 | if ( item ) | 95 | if ( item ) |
96 | return item->file(); | 96 | return item->file(); |
97 | return NULL; | 97 | return NULL; |
98 | } | 98 | } |
99 | 99 | ||
100 | 100 | ||
101 | void PlayListSelection::addToSelection( const DocLnk &lnk ) { | 101 | void PlayListSelection::addToSelection( const DocLnk &lnk ) { |
102 | PlayListSelectionItem *item = new PlayListSelectionItem( this, new DocLnk( lnk ) ); | 102 | PlayListSelectionItem *item = new PlayListSelectionItem( this, new DocLnk( lnk ) ); |
103 | QListViewItem *current = selectedItem(); | 103 | QListViewItem *current = selectedItem(); |
104 | if ( current ) | 104 | if ( current ) |
105 | item->moveItem( current ); | 105 | item->moveItem( current ); |
106 | setSelected( item, TRUE ); | 106 | setSelected( item, TRUE ); |
107 | ensureItemVisible( selectedItem() ); | 107 | ensureItemVisible( selectedItem() ); |
108 | } | 108 | } |
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index 202f351..7862d8d 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp | |||
@@ -1,649 +1,762 @@ | |||
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 | // code added by L. J. Potter Sat 03-02-2002 06:17:54 | ||
20 | 21 | ||
21 | #include <qpe/qpemenubar.h> | 22 | #include <qpe/qpemenubar.h> |
22 | #include <qpe/qpetoolbar.h> | 23 | #include <qpe/qpetoolbar.h> |
23 | #include <qpe/fileselector.h> | 24 | #include <qpe/fileselector.h> |
24 | #include <qpe/qpeapplication.h> | 25 | #include <qpe/qpeapplication.h> |
25 | 26 | ||
26 | #include <qpe/applnk.h> | 27 | #include <qpe/applnk.h> |
27 | #include <qpe/config.h> | 28 | #include <qpe/config.h> |
28 | #include <qpe/global.h> | 29 | #include <qpe/global.h> |
29 | #include <qpe/resource.h> | 30 | #include <qpe/resource.h> |
30 | #include <qaction.h> | 31 | #include <qaction.h> |
31 | #include <qimage.h> | 32 | #include <qimage.h> |
32 | #include <qfile.h> | 33 | #include <qfile.h> |
33 | #include <qlayout.h> | 34 | #include <qlayout.h> |
34 | #include <qlabel.h> | 35 | #include <qlabel.h> |
35 | #include <qlist.h> | 36 | #include <qlist.h> |
36 | #include <qlistbox.h> | 37 | #include <qlistbox.h> |
37 | #include <qmainwindow.h> | 38 | #include <qmainwindow.h> |
38 | #include <qmessagebox.h> | 39 | #include <qmessagebox.h> |
39 | #include <qtoolbutton.h> | 40 | #include <qtoolbutton.h> |
40 | #include <qtabwidget.h> | 41 | #include <qtabwidget.h> |
41 | #include <qlistview.h> | 42 | #include <qlistview.h> |
42 | #include <qpoint.h> | 43 | #include <qpoint.h> |
44 | #include <qlineedit.h> | ||
45 | #include <qpushbutton.h> | ||
46 | |||
43 | //#include <qtimer.h> | 47 | //#include <qtimer.h> |
44 | 48 | ||
45 | #include "playlistselection.h" | 49 | #include "playlistselection.h" |
46 | #include "playlistwidget.h" | 50 | #include "playlistwidget.h" |
47 | #include "mediaplayerstate.h" | 51 | #include "mediaplayerstate.h" |
48 | 52 | ||
53 | #include "fileBrowser.h" | ||
54 | #include "inputDialog.h" | ||
55 | |||
49 | #include <stdlib.h> | 56 | #include <stdlib.h> |
50 | 57 | ||
51 | #define BUTTONS_ON_TOOLBAR | 58 | #define BUTTONS_ON_TOOLBAR |
52 | #define SIDE_BUTTONS | 59 | #define SIDE_BUTTONS |
53 | #define CAN_SAVE_LOAD_PLAYLISTS | 60 | #define CAN_SAVE_LOAD_PLAYLISTS |
54 | 61 | ||
55 | extern MediaPlayerState *mediaPlayerState; | 62 | extern MediaPlayerState *mediaPlayerState; |
56 | 63 | ||
57 | // class myFileSelector { | 64 | // class myFileSelector { |
58 | 65 | ||
59 | // }; | 66 | // }; |
60 | class PlayListWidgetPrivate { | 67 | class PlayListWidgetPrivate { |
61 | public: | 68 | public: |
62 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; | 69 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; |
63 | QFrame *playListFrame; | 70 | QFrame *playListFrame; |
64 | FileSelector *files; | 71 | FileSelector *files; |
65 | PlayListSelection *selectedFiles; | 72 | PlayListSelection *selectedFiles; |
66 | bool setDocumentUsed; | 73 | bool setDocumentUsed; |
67 | DocLnk *current; | 74 | DocLnk *current; |
68 | }; | 75 | }; |
69 | 76 | ||
70 | 77 | ||
71 | class ToolButton : public QToolButton { | 78 | class ToolButton : public QToolButton { |
72 | public: | 79 | public: |
73 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) | 80 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) |
74 | : QToolButton( parent, name ) { | 81 | : QToolButton( parent, name ) { |
75 | setTextLabel( name ); | 82 | setTextLabel( name ); |
76 | setPixmap( Resource::loadPixmap( icon ) ); | 83 | setPixmap( Resource::loadPixmap( icon ) ); |
77 | setAutoRaise( TRUE ); | 84 | setAutoRaise( TRUE ); |
78 | setFocusPolicy( QWidget::NoFocus ); | 85 | setFocusPolicy( QWidget::NoFocus ); |
79 | setToggleButton( t ); | 86 | setToggleButton( t ); |
80 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); | 87 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); |
81 | QPEMenuToolFocusManager::manager()->addWidget( this ); | 88 | QPEMenuToolFocusManager::manager()->addWidget( this ); |
82 | } | 89 | } |
83 | }; | 90 | }; |
84 | 91 | ||
85 | 92 | ||
86 | class MenuItem : public QAction { | 93 | class MenuItem : public QAction { |
87 | public: | 94 | public: |
88 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) | 95 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) |
89 | : QAction( text, QString::null, 0, 0 ) { | 96 | : QAction( text, QString::null, 0, 0 ) { |
90 | connect( this, SIGNAL( activated() ), handler, slot ); | 97 | connect( this, SIGNAL( activated() ), handler, slot ); |
91 | addTo( parent ); | 98 | addTo( parent ); |
92 | } | 99 | } |
93 | }; | 100 | }; |
94 | 101 | ||
95 | 102 | ||
96 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | 103 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) |
97 | : QMainWindow( parent, name, fl ) { | 104 | : QMainWindow( parent, name, fl ) { |
98 | 105 | ||
99 | d = new PlayListWidgetPrivate; | 106 | d = new PlayListWidgetPrivate; |
100 | d->setDocumentUsed = FALSE; | 107 | d->setDocumentUsed = FALSE; |
101 | d->current = NULL; | 108 | d->current = NULL; |
102 | // menuTimer = new QTimer( this ,"menu timer"), | 109 | // menuTimer = new QTimer( this ,"menu timer"), |
103 | // connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); | 110 | // connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); |
104 | 111 | ||
105 | setBackgroundMode( PaletteButton ); | 112 | setBackgroundMode( PaletteButton ); |
106 | 113 | ||
107 | setCaption( tr("OpiePlayer") ); | 114 | setCaption( tr("OpiePlayer") ); |
108 | setIcon( Resource::loadPixmap( "MPEGPlayer" ) ); | 115 | setIcon( Resource::loadPixmap( "MPEGPlayer" ) ); |
109 | 116 | ||
110 | setToolBarsMovable( FALSE ); | 117 | setToolBarsMovable( FALSE ); |
111 | 118 | ||
112 | // Create Toolbar | 119 | // Create Toolbar |
113 | QPEToolBar *toolbar = new QPEToolBar( this ); | 120 | QPEToolBar *toolbar = new QPEToolBar( this ); |
114 | toolbar->setHorizontalStretchable( TRUE ); | 121 | toolbar->setHorizontalStretchable( TRUE ); |
115 | 122 | ||
116 | // Create Menubar | 123 | // Create Menubar |
117 | QPEMenuBar *menu = new QPEMenuBar( toolbar ); | 124 | QPEMenuBar *menu = new QPEMenuBar( toolbar ); |
118 | menu->setMargin( 0 ); | 125 | menu->setMargin( 0 ); |
119 | 126 | ||
120 | QPEToolBar *bar = new QPEToolBar( this ); | 127 | QPEToolBar *bar = new QPEToolBar( this ); |
121 | bar->setLabel( tr( "Play Operations" ) ); | 128 | bar->setLabel( tr( "Play Operations" ) ); |
122 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ),"mpegplayer/add_to_playlist",this , SLOT(addSelected()) ); | 129 | // d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "mpegplayer/play_current_list", |
123 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "mpegplayer/remove_from_playlist", this , SLOT(removeSelected()) ); | 130 | // this , SLOT( addSelected()) ); |
124 | d->tbPlay = new ToolButton( bar, tr( "Play" ),"mpegplayer/play", mediaPlayerState, SLOT( setPlaying(bool)), TRUE ); | 131 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet("close"),"",bar,"close"); |
125 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ), "mpegplayer/shuffle", mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); | 132 | tbDeletePlaylist->setFlat(TRUE); |
126 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"mpegplayer/loop", mediaPlayerState, SLOT(setLooping(bool)), TRUE ); | 133 | tbDeletePlaylist->setFixedSize(20,20); |
134 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); | ||
135 | |||
136 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "mpegplayer/add_to_playlist", | ||
137 | this , SLOT(addSelected()) ); | ||
138 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "mpegplayer/remove_from_playlist", | ||
139 | this , SLOT(removeSelected()) ); | ||
140 | // d->tbPlay = new ToolButton( bar, tr( "Play" ), "mpegplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE ); | ||
141 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "mpegplayer/play", | ||
142 | this , SLOT( btnPlay(bool) ), TRUE ); | ||
143 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"mpegplayer/shuffle", | ||
144 | mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); | ||
145 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"mpegplayer/loop", | ||
146 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); | ||
147 | tbDeletePlaylist->hide(); | ||
127 | 148 | ||
128 | QPopupMenu *pmPlayList = new QPopupMenu( this ); | 149 | QPopupMenu *pmPlayList = new QPopupMenu( this ); |
129 | menu->insertItem( tr( "File" ), pmPlayList ); | 150 | menu->insertItem( tr( "File" ), pmPlayList ); |
130 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); | 151 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); |
131 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); | 152 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); |
132 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); | 153 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); |
133 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); | 154 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); |
134 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); | 155 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); |
135 | new MenuItem( pmPlayList, tr( "Load PlayList" ), this, SLOT( loadList() ) ); | 156 | // new MenuItem( pmPlayList, tr( "Load PlayList" ), this, SLOT( loadList() ) ); |
136 | 157 | ||
137 | QPopupMenu *pmView = new QPopupMenu( this ); | 158 | QPopupMenu *pmView = new QPopupMenu( this ); |
138 | menu->insertItem( tr( "View" ), pmView ); | 159 | menu->insertItem( tr( "View" ), pmView ); |
139 | 160 | ||
140 | fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); | 161 | fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); |
141 | connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); | 162 | connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); |
142 | fullScreenButton->addTo(pmView); | 163 | fullScreenButton->addTo(pmView); |
143 | scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("mpegplayer/scale"), QString::null, 0, this, 0); | 164 | scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("mpegplayer/scale"), QString::null, 0, this, 0); |
144 | connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); | 165 | connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); |
145 | scaleButton->addTo(pmView); | 166 | scaleButton->addTo(pmView); |
146 | 167 | ||
147 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); | 168 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); |
148 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); | 169 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); |
149 | 170 | ||
150 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); | 171 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); |
151 | 172 | ||
152 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); | 173 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); |
153 | tabWidget->setTabShape(QTabWidget::Triangular); | 174 | tabWidget->setTabShape(QTabWidget::Triangular); |
154 | 175 | ||
155 | QWidget *pTab; | 176 | QWidget *pTab; |
156 | pTab = new QWidget( tabWidget, "pTab" ); | 177 | pTab = new QWidget( tabWidget, "pTab" ); |
157 | playlistView = new QListView( pTab, "Videoview" ); | 178 | playlistView = new QListView( pTab, "Videoview" ); |
158 | playlistView->setMinimumSize(236,260); | 179 | playlistView->setMinimumSize(236,260); |
159 | tabWidget->insertTab( pTab,"Playlist"); | 180 | tabWidget->insertTab( pTab,"Playlist"); |
160 | 181 | ||
161 | // Add the playlist area | 182 | // Add the playlist area |
162 | 183 | ||
163 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); | 184 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); |
164 | d->playListFrame = vbox3; | 185 | d->playListFrame = vbox3; |
165 | d->playListFrame ->setMinimumSize(235,260); | 186 | d->playListFrame ->setMinimumSize(235,260); |
166 | 187 | ||
167 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); | 188 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); |
168 | 189 | ||
169 | d->selectedFiles = new PlayListSelection( hbox2); | 190 | d->selectedFiles = new PlayListSelection( hbox2); |
170 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); | 191 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); |
171 | 192 | ||
172 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch | 193 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch |
173 | new ToolButton( vbox1, tr( "Move Up" ), "mpegplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); | 194 | new ToolButton( vbox1, tr( "Move Up" ), "mpegplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); |
174 | new ToolButton( vbox1, tr( "Remove" ), "mpegplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); | 195 | new ToolButton( vbox1, tr( "Remove" ), "mpegplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); |
175 | new ToolButton( vbox1, tr( "Move Down" ), "mpegplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); | 196 | new ToolButton( vbox1, tr( "Move Down" ), "mpegplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); |
176 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch | 197 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch |
177 | 198 | ||
178 | QWidget *aTab; | 199 | QWidget *aTab; |
179 | aTab = new QWidget( tabWidget, "aTab" ); | 200 | aTab = new QWidget( tabWidget, "aTab" ); |
180 | audioView = new QListView( aTab, "Audioview" ); | 201 | audioView = new QListView( aTab, "Audioview" ); |
181 | audioView->setMinimumSize(233,260); | 202 | audioView->setMinimumSize(233,260); |
182 | audioView->addColumn( "Title",150); | 203 | audioView->addColumn( "Title",150); |
183 | audioView->addColumn("Size", 45); | 204 | audioView->addColumn("Size", 45); |
184 | audioView->addColumn("Media",35); | 205 | audioView->addColumn("Media",35); |
185 | audioView->setColumnAlignment(1, Qt::AlignRight); | 206 | audioView->setColumnAlignment(1, Qt::AlignRight); |
186 | audioView->setColumnAlignment(2, Qt::AlignRight); | 207 | audioView->setColumnAlignment(2, Qt::AlignRight); |
187 | tabWidget->insertTab(aTab,"Audio"); | 208 | tabWidget->insertTab(aTab,"Audio"); |
188 | // audioView | 209 | // audioView |
189 | Global::findDocuments(&files, "audio/*"); | 210 | Global::findDocuments(&files, "audio/*"); |
190 | QListIterator<DocLnk> dit( files.children() ); | 211 | QListIterator<DocLnk> dit( files.children() ); |
191 | QString storage; | 212 | QString storage; |
192 | for ( ; dit.current(); ++dit ) { | 213 | for ( ; dit.current(); ++dit ) { |
193 | QListViewItem * newItem; | 214 | QListViewItem * newItem; |
194 | if(dit.current()->file().find("/mnt/cf") != -1 ) storage="CF"; | 215 | if(dit.current()->file().find("/mnt/cf") != -1 ) storage="CF"; |
195 | else if(dit.current()->file().find("/mnt/hda") != -1 ) storage="CF"; | 216 | else if(dit.current()->file().find("/mnt/hda") != -1 ) storage="CF"; |
196 | else if(dit.current()->file().find("/mnt/card") != -1 ) storage="SD"; | 217 | else if(dit.current()->file().find("/mnt/card") != -1 ) storage="SD"; |
197 | else storage="RAM"; | 218 | else storage="RAM"; |
198 | if ( QFile( dit.current()->file()).exists() ) { | 219 | if ( QFile( dit.current()->file()).exists() ) { |
199 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage); | 220 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage); |
200 | newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/musicfile" )); | 221 | newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/musicfile" )); |
201 | } | 222 | } |
202 | } | 223 | } |
203 | // videowidget | 224 | // videowidget |
204 | 225 | ||
205 | QWidget *vTab; | 226 | QWidget *vTab; |
206 | vTab = new QWidget( tabWidget, "vTab" ); | 227 | vTab = new QWidget( tabWidget, "vTab" ); |
207 | videoView = new QListView( vTab, "Videoview" ); | 228 | videoView = new QListView( vTab, "Videoview" ); |
208 | videoView->setMinimumSize(233,260); | 229 | videoView->setMinimumSize(233,260); |
209 | 230 | ||
210 | videoView->addColumn("Title",150); | 231 | videoView->addColumn("Title",150); |
211 | videoView->addColumn("Size",45); | 232 | videoView->addColumn("Size",45); |
212 | videoView->addColumn("Media",35); | 233 | videoView->addColumn("Media",35); |
213 | videoView->setColumnAlignment(1, Qt::AlignRight); | 234 | videoView->setColumnAlignment(1, Qt::AlignRight); |
214 | videoView->setColumnAlignment(2, Qt::AlignRight); | 235 | videoView->setColumnAlignment(2, Qt::AlignRight); |
215 | 236 | ||
216 | tabWidget->insertTab( vTab,"Video"); | 237 | tabWidget->insertTab( vTab,"Video"); |
217 | 238 | ||
218 | Global::findDocuments(&vFiles, "video/*"); | 239 | Global::findDocuments(&vFiles, "video/*"); |
219 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 240 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
220 | for ( ; Vdit.current(); ++Vdit ) { | 241 | for ( ; Vdit.current(); ++Vdit ) { |
221 | if( Vdit.current()->file().find("/mnt/cf") != -1 ) storage="CF"; | 242 | if( Vdit.current()->file().find("/mnt/cf") != -1 ) storage="CF"; |
222 | else if( Vdit.current()->file().find("/mnt/hda") != -1 ) storage="CF"; | 243 | else if( Vdit.current()->file().find("/mnt/hda") != -1 ) storage="CF"; |
223 | else if( Vdit.current()->file().find("/mnt/card") != -1 ) storage="SD"; | 244 | else if( Vdit.current()->file().find("/mnt/card") != -1 ) storage="SD"; |
224 | else storage="RAM"; | 245 | else storage="RAM"; |
225 | QListViewItem * newItem; | 246 | QListViewItem * newItem; |
226 | if ( QFile( Vdit.current()->file()).exists() ) { | 247 | if ( QFile( Vdit.current()->file()).exists() ) { |
227 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage); | 248 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage); |
228 | newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/videofile" )); | 249 | newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/videofile" )); |
229 | } | 250 | } |
230 | } | 251 | } |
231 | // add the library area | ||
232 | QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); | ||
233 | 252 | ||
234 | // connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); | 253 | //playlists list |
235 | // connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); | 254 | QWidget *LTab; |
255 | LTab = new QWidget( tabWidget, "LTab" ); | ||
256 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy | ||
257 | playLists->setMinimumSize(233,260);; | ||
258 | tabWidget->insertTab(LTab,"Lists"); | ||
259 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); | ||
260 | // connect( playLists, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); | ||
236 | 261 | ||
237 | connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | ||
238 | connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | ||
239 | 262 | ||
240 | connect( audioView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint&, int ) ), | 263 | // add the library area |
241 | this, SLOT( addToSelection( QListViewItem *, const QPoint&, int )) ); | 264 | QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); |
242 | connect( videoView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint&, int ) ), | ||
243 | this, SLOT( addToSelection( QListViewItem *, const QPoint&, int )) ); | ||
244 | 265 | ||
245 | 266 | ||
246 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); | 267 | connect( audioView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), |
247 | // connect( d->files, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); | 268 | this, SLOT( fauxPlay( QListViewItem *) ) ); |
248 | // connect( d->files, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); | 269 | connect( videoView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), |
249 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); | 270 | this, SLOT( fauxPlay( QListViewItem *)) ); |
250 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); | ||
251 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); | ||
252 | 271 | ||
253 | // connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), fullScreenButton, SLOT( setOn( bool ) ) ); | 272 | // connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); |
254 | // connect( mediaPlayerState, SIGNAL( scaledToggled( bool ) ), scaleButton, SLOT( setEnabled( bool ) ) ); | 273 | // connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); |
255 | // connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), fullScreenButton, SLOT( setEnabled( bool ) ) ); | ||
256 | 274 | ||
257 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); | 275 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
276 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | ||
258 | 277 | ||
259 | connect( d->selectedFiles, SIGNAL( clicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); | 278 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); |
279 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); | ||
280 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); | ||
281 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); | ||
282 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); | ||
283 | |||
284 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); | ||
260 | // connect( d->selectedFiles, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); | 285 | // connect( d->selectedFiles, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); |
261 | 286 | ||
262 | setCentralWidget( vbox5 ); | 287 | setCentralWidget( vbox5 ); |
263 | 288 | ||
264 | Config cfg( "MediaPlayer" ); | 289 | Config cfg( "MediaPlayer" ); |
265 | readConfig( cfg ); | 290 | readConfig( cfg ); |
266 | 291 | ||
267 | initializeStates(); | 292 | initializeStates(); |
268 | } | 293 | } |
269 | 294 | ||
270 | 295 | ||
271 | PlayListWidget::~PlayListWidget() { | 296 | PlayListWidget::~PlayListWidget() { |
272 | Config cfg( "MediaPlayer" ); | 297 | Config cfg( "MediaPlayer" ); |
273 | writeConfig( cfg ); | 298 | writeConfig( cfg ); |
274 | 299 | ||
275 | if ( d->current ) | 300 | if ( d->current ) |
276 | delete d->current; | 301 | delete d->current; |
277 | delete d; | 302 | delete d; |
278 | } | 303 | } |
279 | 304 | ||
280 | 305 | ||
281 | void PlayListWidget::initializeStates() { | 306 | void PlayListWidget::initializeStates() { |
282 | 307 | ||
283 | d->tbPlay->setOn( mediaPlayerState->playing() ); | 308 | d->tbPlay->setOn( mediaPlayerState->playing() ); |
284 | d->tbLoop->setOn( mediaPlayerState->looping() ); | 309 | d->tbLoop->setOn( mediaPlayerState->looping() ); |
285 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); | 310 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); |
286 | // d->tbFull->setOn( mediaPlayerState->fullscreen() ); | 311 | // d->tbFull->setOn( mediaPlayerState->fullscreen() ); |
287 | // d->tbScale->setOn( mediaPlayerState->scaled() ); | 312 | // d->tbScale->setOn( mediaPlayerState->scaled() ); |
288 | // d->tbScale->setEnabled( mediaPlayerState->fullscreen() ); | 313 | // d->tbScale->setEnabled( mediaPlayerState->fullscreen() ); |
289 | // setPlaylist( mediaPlayerState->playlist() ); | 314 | // setPlaylist( mediaPlayerState->playlist() ); |
315 | setPlaylist( true); | ||
316 | d->selectedFiles->first(); | ||
317 | |||
290 | } | 318 | } |
291 | 319 | ||
292 | 320 | ||
293 | void PlayListWidget::readConfig( Config& cfg ) { | 321 | void PlayListWidget::readConfig( Config& cfg ) { |
294 | cfg.setGroup("PlayList"); | 322 | cfg.setGroup("PlayList"); |
295 | 323 | ||
296 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 324 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
297 | 325 | ||
298 | for ( int i = 0; i < noOfFiles; i++ ) { | 326 | for ( int i = 0; i < noOfFiles; i++ ) { |
299 | QString entryName; | 327 | QString entryName; |
300 | entryName.sprintf( "File%i", i + 1 ); | 328 | entryName.sprintf( "File%i", i + 1 ); |
301 | QString linkFile = cfg.readEntry( entryName ); | 329 | QString linkFile = cfg.readEntry( entryName ); |
302 | DocLnk lnk( linkFile ); | 330 | DocLnk lnk( linkFile ); |
303 | if ( lnk.isValid() ) | 331 | if ( lnk.isValid() ) |
304 | d->selectedFiles->addToSelection( lnk ); | 332 | d->selectedFiles->addToSelection( lnk ); |
305 | |||
306 | } | 333 | } |
307 | } | 334 | } |
308 | 335 | ||
309 | 336 | ||
310 | void PlayListWidget::writeConfig( Config& cfg ) const { | 337 | void PlayListWidget::writeConfig( Config& cfg ) const { |
311 | cfg.setGroup("PlayList"); | 338 | cfg.setGroup("PlayList"); |
312 | 339 | ||
313 | int noOfFiles = 0; | 340 | int noOfFiles = 0; |
314 | 341 | ||
315 | d->selectedFiles->first(); | 342 | d->selectedFiles->first(); |
316 | do { | 343 | do { |
317 | const DocLnk *lnk = d->selectedFiles->current(); | 344 | const DocLnk *lnk = d->selectedFiles->current(); |
318 | if ( lnk ) { | 345 | if ( lnk ) { |
319 | QString entryName; | 346 | QString entryName; |
320 | entryName.sprintf( "File%i", noOfFiles + 1 ); | 347 | entryName.sprintf( "File%i", noOfFiles + 1 ); |
321 | cfg.writeEntry( entryName, lnk->linkFile() ); | 348 | cfg.writeEntry( entryName, lnk->linkFile() ); |
322 | // if this link does exist, add it so we have the file | 349 | // if this link does exist, add it so we have the file |
323 | // next time... | 350 | // next time... |
324 | if ( !QFile::exists( lnk->linkFile() ) ) { | 351 | if ( !QFile::exists( lnk->linkFile() ) ) { |
325 | // the way writing lnks doesn't really check for out | 352 | // the way writing lnks doesn't really check for out |
326 | // of disk space, but check it anyway. | 353 | // of disk space, but check it anyway. |
327 | if ( !lnk->writeLink() ) { | 354 | if ( !lnk->writeLink() ) { |
328 | QMessageBox::critical( 0, tr("Out of space"), | 355 | QMessageBox::critical( 0, tr("Out of space"), |
329 | tr( "There was a problem saving " | 356 | tr( "There was a problem saving " |
330 | "the playlist.\n" | 357 | "the playlist.\n" |
331 | "Your playlist " | 358 | "Your playlist " |
332 | "may be missing some entries\n" | 359 | "may be missing some entries\n" |
333 | "the next time you start it." ) | 360 | "the next time you start it." ) |
334 | ); | 361 | ); |
335 | } | 362 | } |
336 | } | 363 | } |
337 | noOfFiles++; | 364 | noOfFiles++; |
338 | } | 365 | } |
339 | } while ( d->selectedFiles->next() ); | 366 | } while ( d->selectedFiles->next() ); |
340 | 367 | ||
341 | cfg.writeEntry("NumberOfFiles", noOfFiles ); | 368 | cfg.writeEntry("NumberOfFiles", noOfFiles ); |
369 | |||
370 | |||
342 | } | 371 | } |
343 | 372 | ||
344 | 373 | ||
345 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 374 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
346 | d->setDocumentUsed = FALSE; | 375 | qDebug("add"); |
376 | d->setDocumentUsed = FALSE; | ||
347 | if ( mediaPlayerState->playlist() ) | 377 | if ( mediaPlayerState->playlist() ) |
348 | d->selectedFiles->addToSelection( lnk ); | 378 | d->selectedFiles->addToSelection( lnk ); |
349 | else | 379 | else |
350 | mediaPlayerState->setPlaying( TRUE ); | 380 | mediaPlayerState->setPlaying( TRUE ); |
351 | } | 381 | } |
352 | 382 | ||
353 | 383 | ||
354 | void PlayListWidget::addToSelection( QListViewItem *it ,const QPoint & p, int index) { | ||
355 | qDebug("add"); | ||
356 | // d->selectedFiles->addToSelection( lnk ); | ||
357 | // } | ||
358 | // else | ||
359 | // mediaPlayerState->setPlaying( TRUE ); | ||
360 | // | ||
361 | } | ||
362 | |||
363 | |||
364 | void PlayListWidget::clearList() { | 384 | void PlayListWidget::clearList() { |
365 | while ( first() ) | 385 | while ( first() ) |
366 | d->selectedFiles->removeSelected(); | 386 | d->selectedFiles->removeSelected(); |
367 | } | 387 | } |
368 | 388 | ||
369 | 389 | ||
370 | void PlayListWidget::addAllToList() { | 390 | void PlayListWidget::addAllToList() { |
371 | DocLnkSet files; | 391 | DocLnkSet files; |
372 | Global::findDocuments(&files, "video/*;audio/*"); | 392 | Global::findDocuments(&files, "video/*;audio/*"); |
373 | QListIterator<DocLnk> dit( files.children() ); | 393 | QListIterator<DocLnk> dit( files.children() ); |
374 | for ( ; dit.current(); ++dit ) | 394 | for ( ; dit.current(); ++dit ) |
375 | d->selectedFiles->addToSelection( **dit ); | 395 | d->selectedFiles->addToSelection( **dit ); |
376 | } | 396 | } |
377 | 397 | ||
378 | 398 | ||
379 | void PlayListWidget::addAllMusicToList() { | 399 | void PlayListWidget::addAllMusicToList() { |
380 | DocLnkSet files; | 400 | DocLnkSet files; |
381 | Global::findDocuments(&files, "audio/*"); | 401 | Global::findDocuments(&files, "audio/*"); |
382 | QListIterator<DocLnk> dit( files.children() ); | 402 | QListIterator<DocLnk> dit( files.children() ); |
383 | for ( ; dit.current(); ++dit ) | 403 | for ( ; dit.current(); ++dit ) |
384 | d->selectedFiles->addToSelection( **dit ); | 404 | d->selectedFiles->addToSelection( **dit ); |
385 | } | 405 | } |
386 | 406 | ||
387 | 407 | ||
388 | void PlayListWidget::addAllVideoToList() { | 408 | void PlayListWidget::addAllVideoToList() { |
389 | DocLnkSet files; | 409 | DocLnkSet files; |
390 | Global::findDocuments(&files, "video/*"); | 410 | Global::findDocuments(&files, "video/*"); |
391 | QListIterator<DocLnk> dit( files.children() ); | 411 | QListIterator<DocLnk> dit( files.children() ); |
392 | for ( ; dit.current(); ++dit ) | 412 | for ( ; dit.current(); ++dit ) |
393 | d->selectedFiles->addToSelection( **dit ); | 413 | d->selectedFiles->addToSelection( **dit ); |
394 | } | 414 | } |
395 | 415 | ||
396 | 416 | ||
397 | void PlayListWidget::setDocument(const QString& fileref) { | 417 | void PlayListWidget::setDocument(const QString& fileref) { |
398 | if ( fileref.isNull() ) { | 418 | if ( fileref.isNull() ) { |
399 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); | 419 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); |
400 | return; | 420 | return; |
401 | } | 421 | } |
402 | if ( mediaPlayerState->playlist() ) | 422 | if ( mediaPlayerState->playlist() ) |
403 | addToSelection( DocLnk( fileref ) ); | 423 | addToSelection( DocLnk( fileref ) ); |
404 | else { | 424 | else { |
405 | d->setDocumentUsed = TRUE; | 425 | d->setDocumentUsed = TRUE; |
406 | if ( d->current ) | 426 | if ( d->current ) |
407 | delete d->current; | 427 | delete d->current; |
408 | d->current = new DocLnk( fileref ); | 428 | d->current = new DocLnk( fileref ); |
409 | } | 429 | } |
410 | mediaPlayerState->setPlaying( FALSE ); | 430 | mediaPlayerState->setPlaying( FALSE ); |
411 | mediaPlayerState->setPlaying( TRUE ); | 431 | mediaPlayerState->setPlaying( TRUE ); |
412 | } | 432 | } |
413 | 433 | ||
414 | 434 | ||
415 | void PlayListWidget::setActiveWindow() { | 435 | void PlayListWidget::setActiveWindow() { |
416 | // When we get raised we need to ensure that it switches views | 436 | // When we get raised we need to ensure that it switches views |
417 | char origView = mediaPlayerState->view(); | 437 | char origView = mediaPlayerState->view(); |
418 | mediaPlayerState->setView( 'l' ); // invalidate | 438 | mediaPlayerState->setView( 'l' ); // invalidate |
419 | mediaPlayerState->setView( origView ); // now switch back | 439 | mediaPlayerState->setView( origView ); // now switch back |
420 | } | 440 | } |
421 | 441 | ||
422 | 442 | ||
423 | void PlayListWidget::useSelectedDocument() { | 443 | void PlayListWidget::useSelectedDocument() { |
424 | d->setDocumentUsed = FALSE; | 444 | d->setDocumentUsed = FALSE; |
425 | } | 445 | } |
426 | 446 | ||
427 | 447 | ||
428 | const DocLnk *PlayListWidget::current() { | 448 | const DocLnk *PlayListWidget::current() { |
429 | if ( mediaPlayerState->playlist() ) | 449 | |
430 | return d->selectedFiles->current(); | 450 | // qDebug("in Playlist widget ::current"); |
451 | if ( mediaPlayerState->playlist() ) { | ||
452 | return d->selectedFiles->current(); | ||
453 | } | ||
431 | else if ( d->setDocumentUsed && d->current ) { | 454 | else if ( d->setDocumentUsed && d->current ) { |
432 | return d->current; | 455 | return d->current; |
433 | } else | 456 | } else { |
434 | return d->files->selected(); | 457 | return d->files->selected(); |
458 | } | ||
435 | } | 459 | } |
436 | 460 | ||
437 | 461 | ||
438 | bool PlayListWidget::prev() { | 462 | bool PlayListWidget::prev() { |
439 | if ( mediaPlayerState->playlist() ) { | 463 | if ( mediaPlayerState->playlist() ) { |
440 | if ( mediaPlayerState->shuffled() ) { | 464 | if ( mediaPlayerState->shuffled() ) { |
441 | const DocLnk *cur = current(); | 465 | const DocLnk *cur = current(); |
442 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 466 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
443 | for ( int i = 0; i < j; i++ ) { | 467 | for ( int i = 0; i < j; i++ ) { |
444 | if ( !d->selectedFiles->next() ) | 468 | if ( !d->selectedFiles->next() ) |
445 | d->selectedFiles->first(); | 469 | d->selectedFiles->first(); |
446 | } | 470 | } |
447 | if ( cur == current() ) | 471 | if ( cur == current() ) |
448 | if ( !d->selectedFiles->next() ) | 472 | if ( !d->selectedFiles->next() ) |
449 | d->selectedFiles->first(); | 473 | d->selectedFiles->first(); |
450 | return TRUE; | 474 | return TRUE; |
451 | } else { | 475 | } else { |
452 | if ( !d->selectedFiles->prev() ) { | 476 | if ( !d->selectedFiles->prev() ) { |
453 | if ( mediaPlayerState->looping() ) { | 477 | if ( mediaPlayerState->looping() ) { |
454 | return d->selectedFiles->last(); | 478 | return d->selectedFiles->last(); |
455 | } else { | 479 | } else { |
456 | return FALSE; | 480 | return FALSE; |
457 | } | 481 | } |
458 | } | 482 | } |
459 | return TRUE; | 483 | return TRUE; |
460 | } | 484 | } |
461 | } else { | 485 | } else { |
462 | return mediaPlayerState->looping(); | 486 | return mediaPlayerState->looping(); |
463 | } | 487 | } |
464 | } | 488 | } |
465 | 489 | ||
466 | 490 | ||
467 | bool PlayListWidget::next() { | 491 | bool PlayListWidget::next() { |
468 | if ( mediaPlayerState->playlist() ) { | 492 | if ( mediaPlayerState->playlist() ) { |
469 | if ( mediaPlayerState->shuffled() ) { | 493 | if ( mediaPlayerState->shuffled() ) { |
470 | return prev(); | 494 | return prev(); |
471 | } else { | 495 | } else { |
472 | if ( !d->selectedFiles->next() ) { | 496 | if ( !d->selectedFiles->next() ) { |
473 | if ( mediaPlayerState->looping() ) { | 497 | if ( mediaPlayerState->looping() ) { |
474 | return d->selectedFiles->first(); | 498 | return d->selectedFiles->first(); |
475 | } else { | 499 | } else { |
476 | return FALSE; | 500 | return FALSE; |
477 | } | 501 | } |
478 | } | 502 | } |
479 | return TRUE; | 503 | return TRUE; |
480 | } | 504 | } |
481 | } else { | 505 | } else { |
482 | return mediaPlayerState->looping(); | 506 | return mediaPlayerState->looping(); |
483 | } | 507 | } |
484 | } | 508 | } |
485 | 509 | ||
486 | 510 | ||
487 | bool PlayListWidget::first() { | 511 | bool PlayListWidget::first() { |
488 | if ( mediaPlayerState->playlist() ) | 512 | if ( mediaPlayerState->playlist() ) |
489 | return d->selectedFiles->first(); | 513 | return d->selectedFiles->first(); |
490 | else | 514 | else |
491 | return mediaPlayerState->looping(); | 515 | return mediaPlayerState->looping(); |
492 | } | 516 | } |
493 | 517 | ||
494 | 518 | ||
495 | bool PlayListWidget::last() { | 519 | bool PlayListWidget::last() { |
496 | if ( mediaPlayerState->playlist() ) | 520 | if ( mediaPlayerState->playlist() ) |
497 | return d->selectedFiles->last(); | 521 | return d->selectedFiles->last(); |
498 | else | 522 | else |
499 | return mediaPlayerState->looping(); | 523 | return mediaPlayerState->looping(); |
500 | } | 524 | } |
501 | 525 | ||
502 | 526 | ||
503 | void PlayListWidget::saveList() { | 527 | void PlayListWidget::saveList() { |
528 | |||
504 | QString filename; | 529 | QString filename; |
505 | // pseudo code | 530 | InputDialog *fileDlg; |
506 | // filename = QLineEdit->getText(); | 531 | fileDlg=new InputDialog(this,"Save Playlist",TRUE, 0); |
507 | Config cfg( filename + ".playlist" ); | 532 | fileDlg->exec(); |
508 | writeConfig( cfg ); | 533 | if( fileDlg->result() == 1 ) { |
534 | filename = fileDlg->LineEdit1->text();//+".playlist"; | ||
535 | qDebug("saving playlist "+filename+".playlist"); | ||
536 | |||
537 | // DocLnk *lnk; | ||
538 | // lnk.setName( filename); //sets file name | ||
539 | // // lnk.setComment(title); | ||
540 | // lnk.setFile( filename+".playlist"); //sets File property | ||
541 | // lnk.setType("player/plain");// hey is this a REGISTERED mime type?!?!? ;D | ||
542 | // lnk.setIcon("MPEGPlayer"); | ||
543 | // if(!lnk.writeLink()) | ||
544 | // qDebug("Writing doclink did not work"); | ||
545 | |||
546 | Config cfg( filename +".playlist"); | ||
547 | writeConfig( cfg ); | ||
548 | } | ||
549 | DocLnk lnk; | ||
550 | lnk.setName( filename); //sets file name | ||
551 | // lnk.setComment(title); | ||
552 | lnk.setFile(QPEApplication::qpeDir()+"Settings/"+filename+".playlist.conf"); //sets File property | ||
553 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D | ||
554 | lnk.setIcon("MPEGPlayer"); | ||
555 | if(!lnk.writeLink()) | ||
556 | qDebug("Writing doclink did not work"); | ||
557 | |||
558 | if(fileDlg) | ||
559 | delete fileDlg; | ||
509 | } | 560 | } |
510 | 561 | ||
511 | 562 | ||
512 | void PlayListWidget::loadList() { | 563 | void PlayListWidget::loadList( const DocLnk & lnk) { |
513 | QString filename; | 564 | |
514 | // pseudo code | 565 | clearList(); |
515 | // filename = FileSelector->openFile( "*.playlist" ); | 566 | Config cfg( lnk.file()); |
516 | Config cfg( filename + ".playlist" ); | 567 | readConfig(cfg); |
517 | readConfig( cfg ); | 568 | tabWidget->setCurrentPage(0); |
569 | setCaption("OpiePlayer: "+lnk.name()); | ||
518 | } | 570 | } |
519 | 571 | ||
520 | 572 | ||
521 | void PlayListWidget::setPlaylist( bool shown ) { | 573 | void PlayListWidget::setPlaylist( bool shown ) { |
522 | if ( shown ) | 574 | if ( shown ) |
523 | d->playListFrame->show(); | 575 | d->playListFrame->show(); |
524 | else | 576 | else |
525 | d->playListFrame->hide(); | 577 | d->playListFrame->hide(); |
526 | } | 578 | } |
527 | 579 | ||
528 | 580 | ||
529 | void PlayListWidget::setView( char view ) { | 581 | void PlayListWidget::setView( char view ) { |
530 | if ( view == 'l' ) | 582 | if ( view == 'l' ) |
531 | showMaximized(); | 583 | showMaximized(); |
532 | else | 584 | else |
533 | hide(); | 585 | hide(); |
534 | } | 586 | } |
535 | 587 | ||
536 | void PlayListWidget::addSelected() { | 588 | void PlayListWidget::addSelected() { |
537 | // QMessageBox::message("Note","Bozo the clown thinks\nthere's something actually here"); | 589 | |
538 | int tabPage=tabWidget->currentPageIndex(); | 590 | switch (tabWidget->currentPageIndex()) { |
539 | switch (tabPage) { | 591 | case 0: //playlist |
540 | case 0: //playlist | ||
541 | break; | 592 | break; |
542 | case 1: { //audio | 593 | case 1: { //audio |
543 | addToSelection( audioView->selectedItem() ); | 594 | addToSelection( audioView->selectedItem() ); |
544 | } | 595 | } |
545 | break; | 596 | break; |
546 | case 2: { // video | 597 | case 2: { // video |
547 | addToSelection( videoView->selectedItem() ); | 598 | addToSelection( videoView->selectedItem() ); |
548 | } | 599 | } |
549 | break; | 600 | break; |
550 | }; | 601 | }; |
551 | } | 602 | } |
552 | 603 | ||
553 | void PlayListWidget::removeSelected() { | 604 | void PlayListWidget::removeSelected() { |
554 | d->selectedFiles->removeSelected( ); | 605 | d->selectedFiles->removeSelected( ); |
555 | } | 606 | } |
556 | 607 | ||
557 | 608 | ||
558 | void PlayListWidget::playIt( QListViewItem *it) { | 609 | void PlayListWidget::playIt( QListViewItem *it) { |
559 | // d->setDocumentUsed = FALSE; | 610 | // d->setDocumentUsed = FALSE; |
560 | mediaPlayerState->setPlaying(true); | 611 | mediaPlayerState->setPlaying(TRUE); |
561 | } | 612 | } |
562 | 613 | ||
563 | void PlayListWidget::addToSelection( QListViewItem *it) { | 614 | void PlayListWidget::addToSelection( QListViewItem *it) { |
564 | d->setDocumentUsed = FALSE; | 615 | d->setDocumentUsed = FALSE; |
565 | 616 | ||
566 | if(it) { | 617 | if(it) { |
567 | qDebug("add to selection"); | 618 | // qDebug("add to selection"); |
568 | int tabPage=tabWidget->currentPageIndex(); | 619 | switch (tabWidget->currentPageIndex()) { |
569 | switch (tabPage) { | 620 | case 1: { |
570 | case 1: { | 621 | // qDebug("case 1"); |
622 | QListIterator<DocLnk> dit( files.children() ); | ||
623 | for ( ; dit.current(); ++dit ) { | ||
624 | // qDebug(dit.current()->name()); | ||
625 | if( dit.current()->name() == it->text(0)) { | ||
626 | d->selectedFiles->addToSelection( **dit ); | ||
627 | } | ||
628 | } | ||
629 | } | ||
630 | break; | ||
631 | case 2: { | ||
632 | // qDebug("case 2"); | ||
633 | QListIterator<DocLnk> dit( vFiles.children() ); | ||
634 | for ( ; dit.current(); ++dit ) { | ||
635 | // qDebug(dit.current()->name()); | ||
636 | if( dit.current()->name() == it->text(0)) { | ||
637 | d->selectedFiles->addToSelection( **dit ); | ||
638 | } | ||
639 | } | ||
640 | } | ||
641 | break; | ||
642 | case 0: | ||
643 | break; | ||
644 | }; | ||
645 | tabWidget->setCurrentPage(0); | ||
646 | // mediaPlayerState->setPlaying( TRUE ); | ||
647 | } | ||
648 | } | ||
649 | |||
650 | void PlayListWidget::tabChanged(QWidget *widg) { | ||
651 | |||
652 | switch ( tabWidget->currentPageIndex()) { | ||
653 | case 0: | ||
654 | { | ||
655 | if( !tbDeletePlaylist->isHidden()) | ||
656 | tbDeletePlaylist->hide(); | ||
657 | d->tbRemoveFromList->setEnabled(TRUE); | ||
658 | d->tbAddToList->setEnabled(FALSE); | ||
659 | } | ||
660 | break; | ||
661 | case 1: | ||
662 | { | ||
663 | if( !tbDeletePlaylist->isHidden()) | ||
664 | tbDeletePlaylist->hide(); | ||
665 | d->tbRemoveFromList->setEnabled(FALSE); | ||
666 | d->tbAddToList->setEnabled(TRUE); | ||
667 | } | ||
668 | break; | ||
669 | case 2: | ||
670 | { | ||
671 | if( !tbDeletePlaylist->isHidden()) | ||
672 | tbDeletePlaylist->hide(); | ||
673 | d->tbRemoveFromList->setEnabled(FALSE); | ||
674 | d->tbAddToList->setEnabled(TRUE); | ||
675 | } | ||
676 | break; | ||
677 | case 3: | ||
678 | { | ||
679 | if( tbDeletePlaylist->isHidden()) | ||
680 | tbDeletePlaylist->show(); | ||
681 | playLists->reread(); | ||
682 | } | ||
683 | break; | ||
684 | }; | ||
685 | } | ||
686 | |||
687 | /* | ||
688 | list is right clicked*/ | ||
689 | void PlayListWidget::fauxPlay(QListViewItem *it) { | ||
690 | |||
691 | switch (tabWidget->currentPageIndex()) { | ||
692 | case 0: //playlist | ||
693 | break; | ||
694 | case 1: { //audio | ||
571 | QListIterator<DocLnk> dit( files.children() ); | 695 | QListIterator<DocLnk> dit( files.children() ); |
572 | for ( ; dit.current(); ++dit ) { | 696 | for ( ; dit.current(); ++dit ) { |
697 | // qDebug(dit.current()->name()); | ||
573 | if( dit.current()->name() == it->text(0)) { | 698 | if( dit.current()->name() == it->text(0)) { |
574 | d->selectedFiles->addToSelection( **dit ); | 699 | d->selectedFiles->addToSelection( **dit ); |
575 | } | 700 | } |
576 | } | 701 | } |
577 | } | 702 | } |
578 | break; | 703 | break; |
579 | case 2: { | 704 | case 2: { // video |
580 | QListIterator<DocLnk> dit( vFiles.children() ); | 705 | QListIterator<DocLnk> dit( vFiles.children() ); |
581 | for ( ; dit.current(); ++dit ) { | 706 | for ( ; dit.current(); ++dit ) { |
582 | qDebug(dit.current()->name()); | 707 | // qDebug(dit.current()->name()); |
583 | if( dit.current()->name() == it->text(0)) { | 708 | if( dit.current()->name() == it->text(0)) { |
584 | d->selectedFiles->addToSelection( **dit ); | 709 | d->selectedFiles->addToSelection( **dit ); |
585 | } | 710 | } |
586 | } | 711 | } |
587 | } | 712 | } |
588 | break; | 713 | break; |
589 | case 0: | ||
590 | break; | ||
591 | }; | 714 | }; |
592 | tabWidget->setCurrentPage(0); | 715 | mediaPlayerState->setPlaying( TRUE ); |
593 | // mediaPlayerState->setPlaying( TRUE ); | 716 | // tabWidget->setCurrentPage(0); |
594 | } | 717 | d->selectedFiles->removeSelected(); |
595 | } | 718 | } |
596 | 719 | ||
597 | void PlayListWidget::tabChanged(QWidget *widg) { | 720 | /* |
598 | 721 | play button is pressed*/ | |
599 | int tabPage=tabWidget->currentPageIndex(); | 722 | void PlayListWidget::btnPlay(bool b) { // this is fugly |
600 | switch (tabPage) { | 723 | switch ( tabWidget->currentPageIndex()) { |
601 | case 0: | 724 | case 0: |
602 | { | 725 | { |
603 | d->tbRemoveFromList->setEnabled(TRUE); | 726 | mediaPlayerState->setPlaying(b); |
604 | d->tbAddToList->setEnabled(FALSE); | ||
605 | } | 727 | } |
606 | break; | 728 | break; |
607 | case 1: | 729 | case 1: |
608 | { | 730 | { |
609 | d->tbRemoveFromList->setEnabled(FALSE); | 731 | addToSelection( audioView->selectedItem() ); |
610 | d->tbAddToList->setEnabled(TRUE); | 732 | mediaPlayerState->setPlaying(b); |
611 | } | 733 | d->selectedFiles->removeSelected( ); |
612 | break; | 734 | tabWidget->setCurrentPage(1); |
613 | case 2: | 735 | } |
614 | { | 736 | break; |
615 | d->tbRemoveFromList->setEnabled(FALSE); | 737 | case 2: |
616 | d->tbAddToList->setEnabled(TRUE); | 738 | { |
617 | } | 739 | addToSelection( videoView->selectedItem() ); |
618 | break; | 740 | mediaPlayerState->setPlaying(b); |
619 | }; | 741 | d->selectedFiles->removeSelected( ); |
620 | } | 742 | tabWidget->setCurrentPage(2); |
621 | 743 | } | |
622 | // void PlayListWidget::cancelMenuTimer() { | 744 | break; |
623 | // if( menuTimer->isActive() ) | 745 | }; |
624 | // menuTimer->stop(); | ||
625 | // } | ||
626 | |||
627 | // void PlayListWidget::showFileMenu() { | ||
628 | |||
629 | // } | ||
630 | |||
631 | // void PlayListWidget::contentsMousePressEvent( QMouseEvent * e ) | ||
632 | // { | ||
633 | // // QListView::contentsMousePressEvent( e ); | ||
634 | // menuTimer->start( 750, TRUE ); | ||
635 | // } | ||
636 | 746 | ||
747 | } | ||
637 | 748 | ||
638 | // void PlayListWidget::contentsMouseReleaseEvent( QMouseEvent * e ) | 749 | void PlayListWidget::deletePlaylist() { |
639 | // { | 750 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
640 | // // QListView::contentsMouseReleaseEvent( e ); | 751 | (tr("You really want to delete\nthis playlist?")), |
641 | // menuTimer->stop(); | 752 | (tr("Yes")), (tr("No")), 0 )){ |
642 | // } | 753 | case 0: // Yes clicked, |
643 | // // void PlayListWidget::setFullScreen() { | 754 | QFile().remove(playLists->selected()->file()); |
644 | // mediaPlayerState->toggleFullscreen( ); | 755 | QFile().remove(playLists->selected()->linkFile()); |
645 | // } | 756 | playLists->reread(); |
757 | break; | ||
758 | case 1: // Cancel | ||
759 | break; | ||
760 | }; | ||
646 | 761 | ||
647 | // void PlayListWidget::setScaled() { | 762 | } |
648 | // mediaPlayerState->toggleScaled(); | ||
649 | // } | ||
diff --git a/core/multimedia/opieplayer/playlistwidget.h b/core/multimedia/opieplayer/playlistwidget.h index 5b05f11..46272a0 100644 --- a/core/multimedia/opieplayer/playlistwidget.h +++ b/core/multimedia/opieplayer/playlistwidget.h | |||
@@ -1,96 +1,102 @@ | |||
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 | #include <qmainwindow.h> | 23 | #include <qmainwindow.h> |
24 | #include <qpe/applnk.h> | 24 | #include <qpe/applnk.h> |
25 | #include <qtabwidget.h> | 25 | #include <qtabwidget.h> |
26 | #include <fileselector.h> | ||
27 | #include <qpushbutton.h> | ||
28 | |||
26 | /* #include <qtimer.h> */ | 29 | /* #include <qtimer.h> */ |
27 | 30 | ||
28 | 31 | ||
29 | class PlayListWidgetPrivate; | 32 | class PlayListWidgetPrivate; |
30 | class Config; | 33 | class Config; |
31 | class QListViewItem; | 34 | class QListViewItem; |
32 | class QListView; | 35 | class QListView; |
33 | class QPoint; | 36 | class QPoint; |
34 | class QAction; | 37 | class QAction; |
35 | class QLabel; | 38 | class QLabel; |
36 | 39 | ||
37 | class PlayListWidget : public QMainWindow { | 40 | class PlayListWidget : public QMainWindow { |
38 | Q_OBJECT | 41 | Q_OBJECT |
39 | public: | 42 | public: |
40 | PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 ); | 43 | PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 ); |
41 | ~PlayListWidget(); | 44 | ~PlayListWidget(); |
42 | QTabWidget * tabWidget; | 45 | QTabWidget * tabWidget; |
43 | QAction *fullScreenButton, *scaleButton; | 46 | QAction *fullScreenButton, *scaleButton; |
44 | DocLnkSet files; | 47 | DocLnkSet files; |
45 | DocLnkSet vFiles; | 48 | DocLnkSet vFiles; |
46 | QListView *audioView, *videoView, *playlistView; | 49 | QListView *audioView, *videoView, *playlistView; |
47 | QLabel *libString; | 50 | QLabel *libString; |
48 | // retrieve the current playlist entry (media file link) | 51 | // retrieve the current playlist entry (media file link) |
49 | const DocLnk *current(); | 52 | const DocLnk *current(); |
50 | void useSelectedDocument(); | 53 | void useSelectedDocument(); |
51 | /* QTimer * menuTimer; */ | 54 | /* QTimer * menuTimer; */ |
52 | 55 | FileSelector* playLists; | |
56 | QPushButton *tbDeletePlaylist; | ||
53 | public slots: | 57 | public slots: |
54 | void setDocument( const QString& fileref ); | 58 | void setDocument( const QString& fileref ); |
55 | void addToSelection( const DocLnk& ); // Add a media file to the playlist | 59 | void addToSelection( const DocLnk& ); // Add a media file to the playlist |
56 | void addToSelection( QListViewItem* ); // Add a media file to the playlist | 60 | void addToSelection( QListViewItem* ); // Add a media file to the playlist |
57 | void addToSelection( QListViewItem*, const QPoint&,int ); // Add a media file to the playlist | ||
58 | void setActiveWindow(); // need to handle this to show the right view | 61 | void setActiveWindow(); // need to handle this to show the right view |
59 | void setPlaylist( bool ); // Show/Hide the playlist | 62 | void setPlaylist( bool ); // Show/Hide the playlist |
60 | void setView( char ); | 63 | void setView( char ); |
61 | void clearList(); | 64 | void clearList(); |
62 | void addAllToList(); | 65 | void addAllToList(); |
63 | void addAllMusicToList(); | 66 | void addAllMusicToList(); |
64 | void addAllVideoToList(); | 67 | void addAllVideoToList(); |
65 | void saveList(); // Save the playlist | 68 | void saveList(); // Save the playlist |
66 | void loadList(); // Load a playlist | 69 | void loadList( const DocLnk &); // Load a playlist |
67 | void playIt( QListViewItem *); | 70 | void playIt( QListViewItem *); |
71 | void fauxPlay(QListViewItem *); | ||
72 | void btnPlay(bool); | ||
73 | void deletePlaylist(); | ||
68 | bool first(); | 74 | bool first(); |
69 | bool last(); | 75 | bool last(); |
70 | bool next(); | 76 | bool next(); |
71 | bool prev(); | 77 | bool prev(); |
72 | void addSelected(); | 78 | void addSelected(); |
73 | void removeSelected(); | 79 | void removeSelected(); |
74 | void tabChanged(QWidget*); | 80 | void tabChanged(QWidget*); |
75 | /* void setFullScreen(); */ | 81 | /* void setFullScreen(); */ |
76 | /* void setScaled(); */ | 82 | /* void setScaled(); */ |
77 | protected: | 83 | protected: |
78 | /* void contentsMousePressEvent( QMouseEvent * e ); */ | 84 | /* void contentsMousePressEvent( QMouseEvent * e ); */ |
79 | /* void contentsMouseReleaseEvent( QMouseEvent * e ); */ | 85 | /* void contentsMouseReleaseEvent( QMouseEvent * e ); */ |
80 | 86 | ||
81 | private: | 87 | private: |
82 | void initializeStates(); | 88 | void initializeStates(); |
83 | void readConfig( Config& cfg ); | 89 | void readConfig( Config& cfg ); |
84 | void writeConfig( Config& cfg ) const; | 90 | void writeConfig( Config& cfg ) const; |
85 | PlayListWidgetPrivate *d; // Private implementation data | 91 | PlayListWidgetPrivate *d; // Private implementation data |
86 | 92 | ||
87 | protected slots: | 93 | protected slots: |
88 | /* void cancelMenuTimer(); */ | 94 | /* void cancelMenuTimer(); */ |
89 | /* void showFileMenu(); */ | 95 | /* void showFileMenu(); */ |
90 | 96 | ||
91 | 97 | ||
92 | }; | 98 | }; |
93 | 99 | ||
94 | 100 | ||
95 | #endif // PLAY_LIST_WIDGET_H | 101 | #endif // PLAY_LIST_WIDGET_H |
96 | 102 | ||
diff --git a/core/multimedia/opieplayer/videowidget.cpp b/core/multimedia/opieplayer/videowidget.cpp index 1f128a4..be838c4 100644 --- a/core/multimedia/opieplayer/videowidget.cpp +++ b/core/multimedia/opieplayer/videowidget.cpp | |||
@@ -1,69 +1,69 @@ | |||
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 <qpe/mediaplayerplugininterface.h> |
22 | #include <qwidget.h> | 22 | #include <qwidget.h> |
23 | #include <qpainter.h> | 23 | #include <qpainter.h> |
24 | #include <qpixmap.h> | 24 | #include <qpixmap.h> |
25 | #include <qslider.h> | 25 | #include <qslider.h> |
26 | #include <qdrawutil.h> | 26 | #include <qdrawutil.h> |
27 | #include "videowidget.h" | 27 | #include "videowidget.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 | ||
38 | extern MediaPlayerState *mediaPlayerState; | 38 | extern MediaPlayerState *mediaPlayerState; |
39 | 39 | ||
40 | 40 | ||
41 | static const int xo = 2; // movable x offset | 41 | static const int xo = 2; // movable x offset |
42 | static const int yo = 0; // movable y offset | 42 | static const int yo = 0; // movable y offset |
43 | 43 | ||
44 | 44 | ||
45 | struct MediaButton { | 45 | struct 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) |
53 | MediaButton videoButtons[] = { | 53 | MediaButton 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 | ||
64 | static const int numButtons = (sizeof(videoButtons)/sizeof(MediaButton)); | 64 | static const int numButtons = (sizeof(videoButtons)/sizeof(MediaButton)); |
65 | 65 | ||
66 | 66 | ||
67 | VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : | 67 | VideoWidget::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("OpiePlayer") ); | 69 | setCaption( tr("OpiePlayer") ); |
diff --git a/core/multimedia/opieplayer/wavplugin/wavplugin.cpp b/core/multimedia/opieplayer/wavplugin/wavplugin.cpp index 7ac63c0..4a0da16 100644 --- a/core/multimedia/opieplayer/wavplugin/wavplugin.cpp +++ b/core/multimedia/opieplayer/wavplugin/wavplugin.cpp | |||
@@ -25,114 +25,116 @@ | |||
25 | #include <errno.h> | 25 | #include <errno.h> |
26 | #include <unistd.h> | 26 | #include <unistd.h> |
27 | #include <qfile.h> | 27 | #include <qfile.h> |
28 | #include "wavplugin.h" | 28 | #include "wavplugin.h" |
29 | 29 | ||
30 | //#define debugMsg(a) qDebug(a) | 30 | //#define debugMsg(a) qDebug(a) |
31 | #define debugMsg(a) | 31 | #define debugMsg(a) |
32 | 32 | ||
33 | 33 | ||
34 | struct RiffChunk { | 34 | struct RiffChunk { |
35 | char id[4]; | 35 | char id[4]; |
36 | Q_UINT32 size; | 36 | Q_UINT32 size; |
37 | char data[4]; | 37 | char data[4]; |
38 | }; | 38 | }; |
39 | 39 | ||
40 | 40 | ||
41 | struct ChunkData { | 41 | struct ChunkData { |
42 | Q_INT16 formatTag; | 42 | Q_INT16 formatTag; |
43 | Q_INT16 channels; | 43 | Q_INT16 channels; |
44 | Q_INT32 samplesPerSec; | 44 | Q_INT32 samplesPerSec; |
45 | Q_INT32 avgBytesPerSec; | 45 | Q_INT32 avgBytesPerSec; |
46 | Q_INT16 blockAlign; | 46 | Q_INT16 blockAlign; |
47 | Q_INT16 wBitsPerSample; | 47 | Q_INT16 wBitsPerSample; |
48 | }; | 48 | }; |
49 | 49 | ||
50 | 50 | ||
51 | const int sound_buffer_size = 512; // 4096; // you got to be kidding right? | 51 | const int sound_buffer_size = 512; // 4096; // you got to be kidding right? |
52 | 52 | ||
53 | 53 | ||
54 | class WavPluginData { | 54 | class WavPluginData { |
55 | public: | 55 | public: |
56 | QFile *input; | 56 | QFile *input; |
57 | 57 | ||
58 | int wavedata_remaining; | 58 | int wavedata_remaining; |
59 | ChunkData chunkdata; | 59 | ChunkData chunkdata; |
60 | RiffChunk chunk; | 60 | RiffChunk chunk; |
61 | uchar data[sound_buffer_size+32]; // +32 to handle badly aligned input data | 61 | uchar data[sound_buffer_size+32]; // +32 to handle badly aligned input data |
62 | int out,max; | 62 | int out,max; |
63 | int samples_due; | 63 | int samples_due; |
64 | int samples; | 64 | int samples; |
65 | 65 | ||
66 | WavPluginData() { | 66 | WavPluginData() { |
67 | max = out = sound_buffer_size; | 67 | max = out = sound_buffer_size; |
68 | wavedata_remaining = 0; | 68 | wavedata_remaining = 0; |
69 | samples_due = 0; | 69 | samples_due = 0; |
70 | samples = -1; | 70 | samples = -1; |
71 | } | 71 | } |
72 | 72 | ||
73 | // expands out samples to the frequency of 44kHz | 73 | // expands out samples to the frequency of 44kHz //not any more |
74 | bool add( short *output, long count, long& done, bool stereo ) | 74 | bool add( short *output, long count, long& done, bool stereo ) |
75 | { | 75 | { |
76 | done = 0; | 76 | done = 0; |
77 | qApp->processEvents(); | 77 | qApp->processEvents(); |
78 | 78 | ||
79 | if ( input == 0 ) { | 79 | if ( input == 0 ) { |
80 | qDebug("no input"); | 80 | qDebug("no input"); |
81 | return FALSE; | 81 | return FALSE; |
82 | } | 82 | } |
83 | 83 | ||
84 | while ( count ) { | 84 | while ( count ) { |
85 | int l,r; | 85 | int l,r; |
86 | if ( getSample(l, r) == FALSE ) { | 86 | if ( getSample(l, r) == FALSE ) { |
87 | qDebug("didn't get sample"); | 87 | qDebug("didn't get sample"); |
88 | return FALSE; | 88 | return FALSE; |
89 | } | 89 | } |
90 | samples_due += chunkdata.samplesPerSec; | 90 | samples_due += chunkdata.samplesPerSec; |
91 | printf("samples due %d\r", samples_due); | ||
92 | fflush(stdout); | ||
91 | while ( count && (samples_due > chunkdata.samplesPerSec) ) { | 93 | while ( count && (samples_due > chunkdata.samplesPerSec) ) { |
92 | *output++ = l; | 94 | *output++ = l; |
93 | if ( stereo ) | 95 | if ( stereo ) |
94 | *output++ = r; | 96 | *output++ = r; |
95 | samples_due -= chunkdata.samplesPerSec; | 97 | samples_due -= chunkdata.samplesPerSec; |
96 | count--; | 98 | count--; |
97 | done++; | 99 | done++; |
98 | } | 100 | } |
99 | } | 101 | } |
100 | return TRUE; | 102 | return TRUE; |
101 | } | 103 | } |
102 | 104 | ||
103 | bool initialise() { | 105 | bool initialise() { |
104 | if ( input == 0 ) | 106 | if ( input == 0 ) |
105 | return FALSE; | 107 | return FALSE; |
106 | 108 | ||
107 | wavedata_remaining = -1; | 109 | wavedata_remaining = -1; |
108 | 110 | ||
109 | while ( wavedata_remaining == -1 ) { | 111 | while ( wavedata_remaining == -1 ) { |
110 | // Keep reading chunks... | 112 | // Keep reading chunks... |
111 | const int n = sizeof(chunk) - sizeof(chunk.data); | 113 | const int n = sizeof(chunk) - sizeof(chunk.data); |
112 | int t = input->readBlock( (char*)&chunk, n ); | 114 | int t = input->readBlock( (char*)&chunk, n ); |
113 | if ( t != n ) { | 115 | if ( t != n ) { |
114 | if ( t == -1 ) | 116 | if ( t == -1 ) |
115 | return FALSE; | 117 | return FALSE; |
116 | return TRUE; | 118 | return TRUE; |
117 | } | 119 | } |
118 | if ( qstrncmp(chunk.id,"data",4) == 0 ) { | 120 | if ( qstrncmp(chunk.id,"data",4) == 0 ) { |
119 | samples = wavedata_remaining = chunk.size; | 121 | samples = wavedata_remaining = chunk.size; |
120 | } else if ( qstrncmp(chunk.id,"RIFF",4) == 0 ) { | 122 | } else if ( qstrncmp(chunk.id,"RIFF",4) == 0 ) { |
121 | char d[4]; | 123 | char d[4]; |
122 | if ( input->readBlock(d,4) != 4 ) { | 124 | if ( input->readBlock(d,4) != 4 ) { |
123 | return FALSE; | 125 | return FALSE; |
124 | } | 126 | } |
125 | if ( qstrncmp(d,"WAVE",4) != 0 ) { | 127 | if ( qstrncmp(d,"WAVE",4) != 0 ) { |
126 | // skip | 128 | // skip |
127 | if ( chunk.size > 1000000000 || !input->at(input->at()+chunk.size-4) ) { | 129 | if ( chunk.size > 1000000000 || !input->at(input->at()+chunk.size-4) ) { |
128 | return FALSE; | 130 | return FALSE; |
129 | } | 131 | } |
130 | } | 132 | } |
131 | } else if ( qstrncmp(chunk.id,"fmt ",4) == 0 ) { | 133 | } else if ( qstrncmp(chunk.id,"fmt ",4) == 0 ) { |
132 | if ( input->readBlock((char*)&chunkdata,sizeof(chunkdata)) != sizeof(chunkdata) ) { | 134 | if ( input->readBlock((char*)&chunkdata,sizeof(chunkdata)) != sizeof(chunkdata) ) { |
133 | return FALSE; | 135 | return FALSE; |
134 | } | 136 | } |
135 | #define WAVE_FORMAT_PCM 1 | 137 | #define WAVE_FORMAT_PCM 1 |
136 | if ( chunkdata.formatTag != WAVE_FORMAT_PCM ) { | 138 | if ( chunkdata.formatTag != WAVE_FORMAT_PCM ) { |
137 | qDebug("WAV file: UNSUPPORTED FORMAT %d",chunkdata.formatTag); | 139 | qDebug("WAV file: UNSUPPORTED FORMAT %d",chunkdata.formatTag); |
138 | return FALSE; | 140 | return FALSE; |
@@ -283,58 +285,58 @@ int WavPlugin::audioSamples( int ) { | |||
283 | // qDebug( "WavPlugin::audioSamples" ); | 285 | // qDebug( "WavPlugin::audioSamples" ); |
284 | return d->samples / d->chunkdata.channels/2; // ### Scaled samples will be made stereo, | 286 | return d->samples / d->chunkdata.channels/2; // ### Scaled samples will be made stereo, |
285 | // Therefore if source is mono we will double the number of samples | 287 | // Therefore if source is mono we will double the number of samples |
286 | } | 288 | } |
287 | 289 | ||
288 | 290 | ||
289 | bool WavPlugin::audioSetSample( long, int ) { | 291 | bool WavPlugin::audioSetSample( long, int ) { |
290 | // qDebug( "WavPlugin::audioSetSample" ); | 292 | // qDebug( "WavPlugin::audioSetSample" ); |
291 | return FALSE; | 293 | return FALSE; |
292 | } | 294 | } |
293 | 295 | ||
294 | 296 | ||
295 | long WavPlugin::audioGetSample( int ) { | 297 | long WavPlugin::audioGetSample( int ) { |
296 | // qDebug( "WavPlugin::audioGetSample" ); | 298 | // qDebug( "WavPlugin::audioGetSample" ); |
297 | return 0; | 299 | return 0; |
298 | } | 300 | } |
299 | 301 | ||
300 | /* | 302 | /* |
301 | bool WavPlugin::audioReadSamples( short *, int, long, int ) { | 303 | bool WavPlugin::audioReadSamples( short *, int, long, int ) { |
302 | debugMsg( "WavPlugin::audioReadSamples" ); | 304 | debugMsg( "WavPlugin::audioReadSamples" ); |
303 | return FALSE; | 305 | return FALSE; |
304 | } | 306 | } |
305 | 307 | ||
306 | 308 | ||
307 | bool WavPlugin::audioReReadSamples( short *, int, long, int ) { | 309 | bool WavPlugin::audioReReadSamples( short *, int, long, int ) { |
308 | debugMsg( "WavPlugin::audioReReadSamples" ); | 310 | debugMsg( "WavPlugin::audioReReadSamples" ); |
309 | return FALSE; | 311 | return FALSE; |
310 | } | 312 | } |
311 | 313 | ||
312 | 314 | ||
313 | bool WavPlugin::audioReadMonoSamples( short *output, long samples, long& samplesMade, int ) { | 315 | bool WavPlugin::audioReadMonoSamples( short *output, long samples, long& samplesMade, int ) { |
314 | debugMsg( "WavPlugin::audioReadMonoSamples" ); | 316 | debugMsg( "WavPlugin::audioReadMonoSamples" ); |
315 | return !d->add( output, samples, samplesMade, FALSE ); | 317 | return !d->add( output, samples, samplesMade, FALSE ); |
316 | } | 318 | } |
317 | 319 | ||
318 | 320 | ||
319 | bool WavPlugin::audioReadStereoSamples( short *output, long samples, long& samplesMade, int ) { | 321 | bool WavPlugin::audioReadStereoSamples( short *output, long samples, long& samplesMade, int ) { |
320 | debugMsg( "WavPlugin::audioReadStereoSamples" ); | 322 | debugMsg( "WavPlugin::audioReadStereoSamples" ); |
321 | return !d->add( output, samples, samplesMade, TRUE ); | 323 | return !d->add( output, samples, samplesMade, TRUE ); |
322 | } | 324 | } |
323 | */ | 325 | */ |
324 | 326 | ||
325 | bool WavPlugin::audioReadSamples( short *output, int channels, long samples, long& samplesMade, int ) { | 327 | bool WavPlugin::audioReadSamples( short *output, int channels, long samples, long& samplesMade, int ) { |
326 | // qDebug( "WavPlugin::audioReadSamples" ); | 328 | // qDebug( "WavPlugin::audioReadSamples" ); |
327 | return d->add( output, samples, samplesMade, channels != 1 ); | 329 | return d->add( output, samples, samplesMade, channels != 1 ); |
328 | } | 330 | } |
329 | 331 | ||
330 | double WavPlugin::getTime() { | 332 | double WavPlugin::getTime() { |
331 | // qDebug( "WavPlugin::getTime" ); | 333 | // qDebug( "WavPlugin::getTime" ); //this is a stupid hack here!! |
332 | return 0.0; | 334 | return d->chunkdata.wBitsPerSample; /*0.0*/; |
333 | } | 335 | } |
334 | 336 | ||
335 | int WavPlugin::audioBitsPerSample( int ) { | 337 | // int WavPlugin::audioBitsPerSample( int ) { |
336 | // qDebug( "WavPlugin::audioFormat %d", d->chunkdata.wBitsPerSample ); | 338 | // // qDebug( "WavPlugin::audioFormat %d", d->chunkdata.wBitsPerSample ); |
337 | return d->chunkdata.wBitsPerSample; // | 339 | // return d->chunkdata.wBitsPerSample; // |
338 | } | 340 | // } |
339 | 341 | ||
340 | 342 | ||
diff --git a/core/multimedia/opieplayer/wavplugin/wavplugin.h b/core/multimedia/opieplayer/wavplugin/wavplugin.h index 6ae6e06..1c8ba14 100644 --- a/core/multimedia/opieplayer/wavplugin/wavplugin.h +++ b/core/multimedia/opieplayer/wavplugin/wavplugin.h | |||
@@ -1,104 +1,105 @@ | |||
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 | 20 | // L.J.Potter added changes Fri 02-15-2002 |
21 | 21 | ||
22 | #ifndef WAV_PLUGIN_H | 22 | #ifndef WAV_PLUGIN_H |
23 | #define WAV_PLUGIN_H | 23 | #define WAV_PLUGIN_H |
24 | 24 | ||
25 | #include <qstring.h> | 25 | #include <qstring.h> |
26 | #include <qapplication.h> | 26 | #include <qapplication.h> |
27 | #include "../mediaplayerplugininterface.h" | 27 | /* #include "../mediaplayerplugininterface.h" */ |
28 | #include <qpe/mediaplayerplugininterface.h> | ||
28 | 29 | ||
29 | 30 | ||
30 | // #define OLD_MEDIAPLAYER_API | 31 | // #define OLD_MEDIAPLAYER_API |
31 | 32 | ||
32 | 33 | ||
33 | class WavPluginData; | 34 | class WavPluginData; |
34 | 35 | ||
35 | 36 | ||
36 | class WavPlugin : public MediaPlayerDecoder { | 37 | class WavPlugin : public MediaPlayerDecoder { |
37 | 38 | ||
38 | public: | 39 | public: |
39 | WavPlugin(); | 40 | WavPlugin(); |
40 | ~WavPlugin(); | 41 | ~WavPlugin(); |
41 | 42 | ||
42 | const char *pluginName() { return "WavPlugin"; } | 43 | const char *pluginName() { return "WavPlugin"; } |
43 | 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"; } |
44 | double pluginVersion() { return 1.0; } | 45 | double pluginVersion() { return 1.0; } |
45 | 46 | ||
46 | bool isFileSupported( const QString& ); | 47 | bool isFileSupported( const QString& ); |
47 | bool open( const QString& ); | 48 | bool open( const QString& ); |
48 | bool close(); | 49 | bool close(); |
49 | bool isOpen(); | 50 | bool isOpen(); |
50 | const QString &fileInfo() { return strInfo = ""; } | 51 | const QString &fileInfo() { return strInfo = ""; } |
51 | 52 | ||
52 | // If decoder doesn't support audio then return 0 here | 53 | // If decoder doesn't support audio then return 0 here |
53 | int audioStreams(); | 54 | int audioStreams(); |
54 | int audioChannels( int stream ); | 55 | int audioChannels( int stream ); |
55 | int audioFrequency( int stream ); | 56 | int audioFrequency( int stream ); |
56 | int audioBitsPerSample( int stream ); | 57 | /* int audioBitsPerSample( int stream ); */ |
57 | int audioSamples( int stream ); | 58 | int audioSamples( int stream ); |
58 | bool audioSetSample( long sample, int stream ); | 59 | bool audioSetSample( long sample, int stream ); |
59 | long audioGetSample( int stream ); | 60 | long audioGetSample( int stream ); |
60 | #ifdef OLD_MEDIAPLAYER_API | 61 | #ifdef OLD_MEDIAPLAYER_API |
61 | bool audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream ); | 62 | bool audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream ); |
62 | bool audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream ); | 63 | bool audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream ); |
63 | bool audioReadSamples( short *output, int channel, long samples, int stream ); | 64 | bool audioReadSamples( short *output, int channel, long samples, int stream ); |
64 | bool audioReReadSamples( short *output, int channel, long samples, int stream ); | 65 | bool audioReReadSamples( short *output, int channel, long samples, int stream ); |
65 | #else | 66 | #else |
66 | 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 ); |
67 | #endif | 68 | #endif |
68 | 69 | ||
69 | // If decoder doesn't support video then return 0 here | 70 | // If decoder doesn't support video then return 0 here |
70 | int videoStreams() { return 0; } | 71 | int videoStreams() { return 0; } |
71 | int videoWidth( int ) { return 0; } | 72 | int videoWidth( int ) { return 0; } |
72 | int videoHeight( int ) { return 0; } | 73 | int videoHeight( int ) { return 0; } |
73 | double videoFrameRate( int ) { return 0.0; } | 74 | double videoFrameRate( int ) { return 0.0; } |
74 | int videoFrames( int ) { return 0; } | 75 | int videoFrames( int ) { return 0; } |
75 | bool videoSetFrame( long, int ) { return FALSE; } | 76 | bool videoSetFrame( long, int ) { return FALSE; } |
76 | long videoGetFrame( int ) { return 0; } | 77 | long videoGetFrame( int ) { return 0; } |
77 | 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; } |
78 | 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; } |
79 | 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; } |
80 | 81 | ||
81 | // Profiling | 82 | // Profiling |
82 | double getTime(); | 83 | double getTime(); |
83 | 84 | ||
84 | // Ignore if these aren't supported | 85 | // Ignore if these aren't supported |
85 | bool setSMP( int ) { return FALSE; } | 86 | bool setSMP( int ) { return FALSE; } |
86 | bool setMMX( bool ) { return FALSE; } | 87 | bool setMMX( bool ) { return FALSE; } |
87 | 88 | ||
88 | // Capabilities | 89 | // Capabilities |
89 | bool supportsAudio() { return TRUE; } | 90 | bool supportsAudio() { return TRUE; } |
90 | bool supportsVideo() { return FALSE; } | 91 | bool supportsVideo() { return FALSE; } |
91 | bool supportsYUV() { return FALSE; } | 92 | bool supportsYUV() { return FALSE; } |
92 | bool supportsMMX() { return TRUE; } | 93 | bool supportsMMX() { return TRUE; } |
93 | bool supportsSMP() { return FALSE; } | 94 | bool supportsSMP() { return FALSE; } |
94 | bool supportsStereo() { return TRUE; } | 95 | bool supportsStereo() { return TRUE; } |
95 | bool supportsScaling() { return FALSE; } | 96 | bool supportsScaling() { return FALSE; } |
96 | 97 | ||
97 | long getPlayTime() { return -1; } | 98 | long getPlayTime() { return -1; } |
98 | 99 | ||
99 | private: | 100 | private: |
100 | WavPluginData *d; | 101 | WavPluginData *d; |
101 | QString strInfo; | 102 | QString strInfo; |
102 | 103 | ||
103 | }; | 104 | }; |
104 | 105 | ||
diff --git a/core/multimedia/opieplayer/wavplugin/wavpluginimpl.cpp b/core/multimedia/opieplayer/wavplugin/wavpluginimpl.cpp index 2923180..c232d7b 100644 --- a/core/multimedia/opieplayer/wavplugin/wavpluginimpl.cpp +++ b/core/multimedia/opieplayer/wavplugin/wavpluginimpl.cpp | |||
@@ -1,69 +1,69 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include "wavplugin.h" | 20 | #include "wavplugin.h" |
21 | #include "wavpluginimpl.h" | 21 | #include "wavpluginimpl.h" |
22 | 22 | ||
23 | WavPluginImpl::WavPluginImpl() | 23 | WavPluginImpl::WavPluginImpl() |
24 | : libmadplugin(0), ref(0) | 24 | : libmadplugin(0), ref(0) |
25 | { | 25 | { |
26 | } | 26 | } |
27 | 27 | ||
28 | 28 | ||
29 | WavPluginImpl::~WavPluginImpl() | 29 | WavPluginImpl::~WavPluginImpl() |
30 | { | 30 | { |
31 | if ( libmadplugin ) | 31 | if ( libmadplugin ) |
32 | delete libmadplugin; | 32 | delete libmadplugin; |
33 | } | 33 | } |
34 | 34 | ||
35 | 35 | ||
36 | MediaPlayerDecoder *WavPluginImpl::decoder() | 36 | MediaPlayerDecoder *WavPluginImpl::decoder() |
37 | { | 37 | { |
38 | if ( !libmadplugin ) | 38 | if ( !libmadplugin ) |
39 | libmadplugin = new WavPlugin; | 39 | libmadplugin = new WavPlugin; |
40 | return libmadplugin; | 40 | return libmadplugin; |
41 | } | 41 | } |
42 | 42 | ||
43 | 43 | ||
44 | MediaPlayerEncoder *WavPluginImpl::encoder() | 44 | MediaPlayerEncoder *WavPluginImpl::encoder() |
45 | { | 45 | { |
46 | return NULL; | 46 | return NULL; |
47 | } | 47 | } |
48 | 48 | ||
49 | 49 | ||
50 | #ifndef QT_NO_COMPONENT | 50 | #ifndef QT_NO_COMPONENT |
51 | 51 | ||
52 | 52 | ||
53 | QRESULT WavPluginImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) | 53 | QRESULT WavPluginImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) |
54 | { | 54 | { |
55 | *iface = 0; | 55 | *iface = 0; |
56 | if ( ( uuid == IID_QUnknown ) || ( uuid == IID_MediaPlayerPlugin ) ) | 56 | if ( ( uuid == IID_QUnknown ) || ( uuid == IID_MediaPlayerPlugin ) ) |
57 | *iface = this, (*iface)->addRef(); | 57 | *iface = this, (*iface)->addRef(); |
58 | return QS_OK; | 58 | return QS_OK; |
59 | } | 59 | } |
60 | 60 | ||
61 | 61 | ||
62 | Q_EXPORT_INTERFACE() | 62 | Q_EXPORT_INTERFACE() |
63 | { | 63 | { |
64 | Q_CREATE_INSTANCE( WavPluginImpl ) | 64 | Q_CREATE_INSTANCE( WavPluginImpl ) |
65 | } | 65 | } |
66 | 66 | ||
67 | 67 | ||
68 | #endif | 68 | #endif |
69 | 69 | ||
diff --git a/core/multimedia/opieplayer/wavplugin/wavpluginimpl.h b/core/multimedia/opieplayer/wavplugin/wavpluginimpl.h index 10f9305..fb1fa73 100644 --- a/core/multimedia/opieplayer/wavplugin/wavpluginimpl.h +++ b/core/multimedia/opieplayer/wavplugin/wavpluginimpl.h | |||
@@ -1,52 +1,53 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef WAV_PLUGIN_IMPL_H | 20 | #ifndef WAV_PLUGIN_IMPL_H |
21 | #define WAV_PLUGIN_IMPL_H | 21 | #define WAV_PLUGIN_IMPL_H |
22 | 22 | ||
23 | #include "../mediaplayerplugininterface.h" | 23 | |
24 | /* #include "../mediaplayerplugininterface.h" */ | ||
24 | 25 | ||
25 | 26 | ||
26 | class WavPlugin; | 27 | class WavPlugin; |
27 | 28 | ||
28 | 29 | ||
29 | class WavPluginImpl : public MediaPlayerPluginInterface | 30 | class WavPluginImpl : public MediaPlayerPluginInterface |
30 | { | 31 | { |
31 | public: | 32 | public: |
32 | WavPluginImpl(); | 33 | WavPluginImpl(); |
33 | virtual ~WavPluginImpl(); | 34 | virtual ~WavPluginImpl(); |
34 | 35 | ||
35 | #ifndef QT_NO_COMPONENT | 36 | #ifndef QT_NO_COMPONENT |
36 | 37 | ||
37 | QRESULT queryInterface( const QUuid&, QUnknownInterface** ); | 38 | QRESULT queryInterface( const QUuid&, QUnknownInterface** ); |
38 | Q_REFCOUNT | 39 | Q_REFCOUNT |
39 | 40 | ||
40 | #endif | 41 | #endif |
41 | 42 | ||
42 | virtual MediaPlayerDecoder *decoder(); | 43 | virtual MediaPlayerDecoder *decoder(); |
43 | virtual MediaPlayerEncoder *encoder(); | 44 | virtual MediaPlayerEncoder *encoder(); |
44 | 45 | ||
45 | private: | 46 | private: |
46 | WavPlugin *libmadplugin; | 47 | WavPlugin *libmadplugin; |
47 | ulong ref; | 48 | ulong ref; |
48 | }; | 49 | }; |
49 | 50 | ||
50 | 51 | ||
51 | #endif | 52 | #endif |
52 | 53 | ||