summaryrefslogtreecommitdiff
path: root/core/multimedia/opieplayer/mediaplayerstate.cpp
Unidiff
Diffstat (limited to 'core/multimedia/opieplayer/mediaplayerstate.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/mediaplayerstate.cpp60
1 files changed, 33 insertions, 27 deletions
diff --git a/core/multimedia/opieplayer/mediaplayerstate.cpp b/core/multimedia/opieplayer/mediaplayerstate.cpp
index 9b9d133..2a6bca3 100644
--- a/core/multimedia/opieplayer/mediaplayerstate.cpp
+++ b/core/multimedia/opieplayer/mediaplayerstate.cpp
@@ -5,57 +5,59 @@
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include <qpe/qpeapplication.h> 20#include <qpe/qpeapplication.h>
21#include <qpe/qlibrary.h> 21#include <qpe/qlibrary.h>
22#include <qpe/config.h> 22#include <qpe/config.h>
23#include <qvaluelist.h> 23#include <qvaluelist.h>
24#include <qobject.h> 24#include <qobject.h>
25#include <qdir.h> 25#include <qdir.h>
26#include "mediaplayerplugininterface.h" 26#include "mediaplayerplugininterface.h"
27#include "mediaplayerstate.h" 27#include "mediaplayerstate.h"
28 28
29
30
29#ifdef QT_NO_COMPONENT 31#ifdef QT_NO_COMPONENT
30// Plugins which are compiled in when no plugin architecture available 32// Plugins which are compiled in when no plugin architecture available
31#include "libmad/libmadpluginimpl.h" 33#include "libmad/libmadpluginimpl.h"
32#include "libmpeg3/libmpeg3pluginimpl.h" 34#include "libmpeg3/libmpeg3pluginimpl.h"
33#include "wavplugin/wavpluginimpl.h" 35#include "wavplugin/wavpluginimpl.h"
34#endif 36#endif
35 37
36 38
37 //#define MediaPlayerDebug(x)qDebug x 39//#define MediaPlayerDebug(x) qDebug x
38#define MediaPlayerDebug(x) 40#define MediaPlayerDebug(x)
39 41
40 42
41MediaPlayerState::MediaPlayerState( QObject *parent, const char *name ) 43MediaPlayerState::MediaPlayerState( QObject *parent, const char *name )
42 : QObject( parent, name ), decoder( NULL ), libmpeg3decoder( NULL ) { 44 : QObject( parent, name ), decoder( NULL ), libmpeg3decoder( NULL ) {
43 Config cfg( "MediaPlayer" ); 45 Config cfg( "MediaPlayer" );
44 readConfig( cfg ); 46 readConfig( cfg );
45 loadPlugins(); 47 loadPlugins();
46} 48}
47 49
48 50
49MediaPlayerState::~MediaPlayerState() { 51MediaPlayerState::~MediaPlayerState() {
50 Config cfg( "MediaPlayer" ); 52 Config cfg( "MediaPlayer" );
51 writeConfig( cfg ); 53 writeConfig( cfg );
52} 54}
53 55
54 56
55void MediaPlayerState::readConfig( Config& cfg ) { 57void MediaPlayerState::readConfig( Config& cfg ) {
56 cfg.setGroup("Options"); 58 cfg.setGroup("Options");
57 isFullscreen = cfg.readBoolEntry( "FullScreen" ); 59 isFullscreen = cfg.readBoolEntry( "FullScreen" );
58 isScaled = cfg.readBoolEntry( "Scaling" ); 60 isScaled = cfg.readBoolEntry( "Scaling" );
59 isLooping = cfg.readBoolEntry( "Looping" ); 61 isLooping = cfg.readBoolEntry( "Looping" );
60 isShuffled = cfg.readBoolEntry( "Shuffle" ); 62 isShuffled = cfg.readBoolEntry( "Shuffle" );
61 usePlaylist = cfg.readBoolEntry( "UsePlayList" ); 63 usePlaylist = cfg.readBoolEntry( "UsePlayList" );
@@ -74,112 +76,116 @@ void MediaPlayerState::writeConfig( Config& cfg ) const {
74 cfg.writeEntry("Looping", isLooping ); 76 cfg.writeEntry("Looping", isLooping );
75 cfg.writeEntry("Shuffle", isShuffled ); 77 cfg.writeEntry("Shuffle", isShuffled );
76 cfg.writeEntry("UsePlayList", usePlaylist ); 78 cfg.writeEntry("UsePlayList", usePlaylist );
77} 79}
78 80
79 81
80struct MediaPlayerPlugin { 82struct MediaPlayerPlugin {
81#ifndef QT_NO_COMPONENT 83#ifndef QT_NO_COMPONENT
82 QLibrary *library; 84 QLibrary *library;
83#endif 85#endif
84 MediaPlayerPluginInterface *iface; 86 MediaPlayerPluginInterface *iface;
85 MediaPlayerDecoder *decoder; 87 MediaPlayerDecoder *decoder;
86 MediaPlayerEncoder *encoder; 88 MediaPlayerEncoder *encoder;
87}; 89};
88 90
89 91
90static QValueList<MediaPlayerPlugin> pluginList; 92static QValueList<MediaPlayerPlugin> pluginList;
91 93
92 94
93// Find the first decoder which supports this type of file 95// Find the first decoder which supports this type of file
94MediaPlayerDecoder *MediaPlayerState::newDecoder( const QString& file ) { 96MediaPlayerDecoder *MediaPlayerState::newDecoder( const QString& file ) {
95 MediaPlayerDecoder *tmpDecoder = NULL; 97 MediaPlayerDecoder *tmpDecoder = NULL;
96 QValueList<MediaPlayerPlugin>::Iterator it; 98 QValueList<MediaPlayerPlugin>::Iterator it;
97 for ( it = pluginList.begin(); it != pluginList.end(); ++it ) { 99 for ( it = pluginList.begin(); it != pluginList.end(); ++it ) {
98 if ( (*it).decoder->isFileSupported( file ) ) { 100 if ( (*it).decoder->isFileSupported( file ) ) {
99 tmpDecoder = (*it).decoder; 101 tmpDecoder = (*it).decoder;
100 break; 102 break;
101 } 103 }
102 } 104 }
103 return decoder = tmpDecoder; 105 return decoder = tmpDecoder;
104} 106}
105 107
106 108
107MediaPlayerDecoder *MediaPlayerState::curDecoder() { 109MediaPlayerDecoder *MediaPlayerState::curDecoder() {
108 return decoder; 110 return decoder;
109} 111}
110 112
111 113
112// ### hack to get true sample count 114// ### hack to get true sample count
113MediaPlayerDecoder *MediaPlayerState::libMpeg3Decoder() { 115MediaPlayerDecoder *MediaPlayerState::libMpeg3Decoder() {
114 return libmpeg3decoder; 116 return libmpeg3decoder;
115} 117}
116 118
119// ### hack to get true sample count
120// MediaPlayerDecoder *MediaPlayerState::libWavDecoder() {
121// return libwavdecoder;
122// }
117 123
118void MediaPlayerState::loadPlugins() { 124void MediaPlayerState::loadPlugins() {
119 125
120#ifndef QT_NO_COMPONENT 126#ifndef QT_NO_COMPONENT
121 QValueList<MediaPlayerPlugin>::Iterator mit; 127 QValueList<MediaPlayerPlugin>::Iterator mit;
122 for ( mit = pluginList.begin(); mit != pluginList.end(); ++mit ) { 128 for ( mit = pluginList.begin(); mit != pluginList.end(); ++mit ) {
123 (*mit).iface->release(); 129 (*mit).iface->release();
124 (*mit).library->unload(); 130 (*mit).library->unload();
125 delete (*mit).library; 131 delete (*mit).library;
126 } 132 }
127 pluginList.clear(); 133 pluginList.clear();
128 134
129 QString path = QPEApplication::qpeDir() + "/plugins/codecs"; 135 QString path = QPEApplication::qpeDir() + "/plugins/codecs";
130 QDir dir( path, "lib*.so" ); 136 QDir dir( path, "lib*.so" );
131 QStringList list = dir.entryList(); 137 QStringList list = dir.entryList();
132 QStringList::Iterator it; 138 QStringList::Iterator it;
133 for ( it = list.begin(); it != list.end(); ++it ) { 139 for ( it = list.begin(); it != list.end(); ++it ) {
134 MediaPlayerPluginInterface *iface = 0; 140 MediaPlayerPluginInterface *iface = 0;
135 QLibrary *lib = new QLibrary( path + "/" + *it ); 141 QLibrary *lib = new QLibrary( path + "/" + *it );
136 142
137 MediaPlayerDebug(( "querying: %s", QString( path + "/" + *it ).latin1() )); 143 MediaPlayerDebug(( "querying: %s", QString( path + "/" + *it ).latin1() ));
138 144
139 if ( lib->queryInterface( IID_MediaPlayerPlugin, (QUnknownInterface**)&iface ) == QS_OK ) { 145 if ( lib->queryInterface( IID_MediaPlayerPlugin, (QUnknownInterface**)&iface ) == QS_OK ) {
140 146
141 MediaPlayerDebug(( "loading: %s", QString( path + "/" + *it ).latin1() )); 147 MediaPlayerDebug(( "loading: %s", QString( path + "/" + *it ).latin1() ));
142 148
143 MediaPlayerPlugin plugin; 149 MediaPlayerPlugin plugin;
144 plugin.library = lib; 150 plugin.library = lib;
145 plugin.iface = iface; 151 plugin.iface = iface;
146 plugin.decoder = plugin.iface->decoder(); 152 plugin.decoder = plugin.iface->decoder();
147 plugin.encoder = plugin.iface->encoder(); 153 plugin.encoder = plugin.iface->encoder();
148 pluginList.append( plugin ); 154 pluginList.append( plugin );
149 155
150 // ### hack to get true sample count 156 // ### hack to get true sample count
151 if ( plugin.decoder->pluginName() == QString("LibMpeg3Plugin") ) 157 if ( plugin.decoder->pluginName() == QString("LibMpeg3Plugin") )
152 libmpeg3decoder = plugin.decoder; 158 libmpeg3decoder = plugin.decoder;
153 159
154 } else { 160 } else {
155 delete lib; 161 delete lib;
156 } 162 }
157 } 163 }
158#else 164#else
159 pluginList.clear(); 165 pluginList.clear();
160 166
161 MediaPlayerPlugin plugin0; 167 MediaPlayerPlugin plugin0;
162 plugin0.iface = new LibMpeg3PluginImpl; 168 plugin0.iface = new LibMpeg3PluginImpl;
163 plugin0.decoder = plugin0.iface->decoder(); 169 plugin0.decoder = plugin0.iface->decoder();
164 plugin0.encoder = plugin0.iface->encoder(); 170 plugin0.encoder = plugin0.iface->encoder();
165 pluginList.append( plugin0 ); 171 pluginList.append( plugin0 );
166 172
167 MediaPlayerPlugin plugin1; 173 MediaPlayerPlugin plugin1;
168 plugin1.iface = new LibMadPluginImpl; 174 plugin1.iface = new LibMadPluginImpl;
169 plugin1.decoder = plugin1.iface->decoder(); 175 plugin1.decoder = plugin1.iface->decoder();
170 plugin1.encoder = plugin1.iface->encoder(); 176 plugin1.encoder = plugin1.iface->encoder();
171 pluginList.append( plugin1 ); 177 pluginList.append( plugin1 );
172 178
173 MediaPlayerPlugin plugin2; 179 MediaPlayerPlugin plugin2;
174 plugin2.iface = new WavPluginImpl; 180 plugin2.iface = new WavPluginImpl;
175 plugin2.decoder = plugin2.iface->decoder(); 181 plugin2.decoder = plugin2.iface->decoder();
176 plugin2.encoder = plugin2.iface->encoder(); 182 plugin2.encoder = plugin2.iface->encoder();
177 pluginList.append( plugin2 ); 183 pluginList.append( plugin2 );
178#endif 184#endif
179 185
180 if ( pluginList.count() ) 186 if ( pluginList.count() )
181 MediaPlayerDebug(( "%i decoders found", pluginList.count() )); 187 MediaPlayerDebug(( "%i decoders found", pluginList.count() ));
182 else 188 else
183 MediaPlayerDebug(( "No decoders found" )); 189 MediaPlayerDebug(( "No decoders found" ));
184} 190}
185 191