author | llornkcor <llornkcor> | 2002-02-25 05:10:32 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-02-25 05:10:32 (UTC) |
commit | 1bebd27631a6c9d1ab967cbb32dd4e796b3b0402 (patch) (unidiff) | |
tree | 8ce49800cba26f6f2c33de74a71d4efe0338843f /core/multimedia/opieplayer/mediaplayerstate.cpp | |
parent | d948361c1b475fab4660b28fbf5ec21fd34d923f (diff) | |
download | opie-1bebd27631a6c9d1ab967cbb32dd4e796b3b0402.zip opie-1bebd27631a6c9d1ab967cbb32dd4e796b3b0402.tar.gz opie-1bebd27631a6c9d1ab967cbb32dd4e796b3b0402.tar.bz2 |
fixed 2
Diffstat (limited to 'core/multimedia/opieplayer/mediaplayerstate.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/multimedia/opieplayer/mediaplayerstate.cpp | 67 |
1 files changed, 36 insertions, 31 deletions
diff --git a/core/multimedia/opieplayer/mediaplayerstate.cpp b/core/multimedia/opieplayer/mediaplayerstate.cpp index 7e82166..13741f6 100644 --- a/core/multimedia/opieplayer/mediaplayerstate.cpp +++ b/core/multimedia/opieplayer/mediaplayerstate.cpp | |||
@@ -1,50 +1,51 @@ | |||
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 | #include <qpe/qpeapplication.h> | 20 | #include <qpe/qpeapplication.h> |
21 | #include <qpe/qlibrary.h> | 21 | #include <qpe/qlibrary.h> |
22 | #include <qpe/mediaplayerplugininterface.h> | ||
23 | #include <qpe/config.h> | 22 | #include <qpe/config.h> |
24 | #include <qvaluelist.h> | 23 | #include <qvaluelist.h> |
25 | #include <qobject.h> | 24 | #include <qobject.h> |
26 | #include <qdir.h> | 25 | #include <qdir.h> |
26 | #include "mediaplayerplugininterface.h" | ||
27 | #include "mediaplayerstate.h" | 27 | #include "mediaplayerstate.h" |
28 | 28 | ||
29 | |||
29 | #ifdef QT_NO_COMPONENT | 30 | #ifdef QT_NO_COMPONENT |
30 | // Plugins which are compiled in when no plugin architecture available | 31 | // Plugins which are compiled in when no plugin architecture available |
31 | #include "libmad/libmadpluginimpl.h" | 32 | #include "libmad/libmadpluginimpl.h" |
32 | #include "libmpeg3/libmpeg3pluginimpl.h" | 33 | #include "libmpeg3/libmpeg3pluginimpl.h" |
33 | #include "wavplugin/wavpluginimpl.h" | 34 | #include "wavplugin/wavpluginimpl.h" |
34 | #endif | 35 | #endif |
35 | 36 | ||
36 | 37 | ||
37 | #define MediaPlayerDebug(x)qDebug x | 38 | //#define MediaPlayerDebug(x) qDebug x |
38 | //#define MediaPlayerDebug(x) | 39 | #define MediaPlayerDebug(x) |
39 | 40 | ||
40 | 41 | ||
41 | MediaPlayerState::MediaPlayerState( QObject *parent, const char *name ) | 42 | MediaPlayerState::MediaPlayerState( QObject *parent, const char *name ) |
42 | : QObject( parent, name ), decoder( NULL ), libmpeg3decoder( NULL ) { | 43 | : QObject( parent, name ), decoder( NULL ), libmpeg3decoder( NULL ) { |
43 | Config cfg( "MediaPlayer" ); | 44 | Config cfg( "MediaPlayer" ); |
44 | readConfig( cfg ); | 45 | readConfig( cfg ); |
45 | loadPlugins(); | 46 | loadPlugins(); |
46 | } | 47 | } |
47 | 48 | ||
48 | 49 | ||
49 | MediaPlayerState::~MediaPlayerState() { | 50 | MediaPlayerState::~MediaPlayerState() { |
50 | Config cfg( "MediaPlayer" ); | 51 | Config cfg( "MediaPlayer" ); |
@@ -86,100 +87,104 @@ struct MediaPlayerPlugin { | |||
86 | MediaPlayerEncoder *encoder; | 87 | MediaPlayerEncoder *encoder; |
87 | }; | 88 | }; |
88 | 89 | ||
89 | 90 | ||
90 | static QValueList<MediaPlayerPlugin> pluginList; | 91 | static QValueList<MediaPlayerPlugin> pluginList; |
91 | 92 | ||
92 | 93 | ||
93 | // Find the first decoder which supports this type of file | 94 | // Find the first decoder which supports this type of file |
94 | MediaPlayerDecoder *MediaPlayerState::newDecoder( const QString& file ) { | 95 | MediaPlayerDecoder *MediaPlayerState::newDecoder( const QString& file ) { |
95 | MediaPlayerDecoder *tmpDecoder = NULL; | 96 | MediaPlayerDecoder *tmpDecoder = NULL; |
96 | QValueList<MediaPlayerPlugin>::Iterator it; | 97 | QValueList<MediaPlayerPlugin>::Iterator it; |
97 | for ( it = pluginList.begin(); it != pluginList.end(); ++it ) { | 98 | for ( it = pluginList.begin(); it != pluginList.end(); ++it ) { |
98 | if ( (*it).decoder->isFileSupported( file ) ) { | 99 | if ( (*it).decoder->isFileSupported( file ) ) { |
99 | tmpDecoder = (*it).decoder; | 100 | tmpDecoder = (*it).decoder; |
100 | break; | 101 | break; |
101 | } | 102 | } |
102 | } | 103 | } |
103 | return decoder = tmpDecoder; | 104 | return decoder = tmpDecoder; |
104 | } | 105 | } |
105 | 106 | ||
106 | 107 | ||
107 | MediaPlayerDecoder *MediaPlayerState::curDecoder() { | 108 | MediaPlayerDecoder *MediaPlayerState::curDecoder() { |
108 | return decoder; | 109 | return decoder; |
109 | } | 110 | } |
110 | 111 | ||
111 | 112 | ||
112 | // ### hack to get true sample count | 113 | // ### hack to get true sample count |
113 | MediaPlayerDecoder *MediaPlayerState::libMpeg3Decoder() { | 114 | MediaPlayerDecoder *MediaPlayerState::libMpeg3Decoder() { |
114 | return libmpeg3decoder; | 115 | return libmpeg3decoder; |
115 | } | 116 | } |
116 | 117 | ||
118 | // ### hack to get true sample count | ||
119 | // MediaPlayerDecoder *MediaPlayerState::libWavDecoder() { | ||
120 | // return libwavdecoder; | ||
121 | // } | ||
117 | 122 | ||
118 | void MediaPlayerState::loadPlugins() { | 123 | void MediaPlayerState::loadPlugins() { |
119 | 124 | ||
120 | #ifndef QT_NO_COMPONENT | 125 | #ifndef QT_NO_COMPONENT |
121 | QValueList<MediaPlayerPlugin>::Iterator mit; | 126 | QValueList<MediaPlayerPlugin>::Iterator mit; |
122 | for ( mit = pluginList.begin(); mit != pluginList.end(); ++mit ) { | 127 | for ( mit = pluginList.begin(); mit != pluginList.end(); ++mit ) { |
123 | (*mit).iface->release(); | 128 | (*mit).iface->release(); |
124 | (*mit).library->unload(); | 129 | (*mit).library->unload(); |
125 | delete (*mit).library; | 130 | delete (*mit).library; |
126 | } | 131 | } |
127 | pluginList.clear(); | 132 | pluginList.clear(); |
128 | 133 | ||
129 | QString path = QPEApplication::qpeDir() + "/plugins/codecs"; | 134 | QString path = QPEApplication::qpeDir() + "/plugins/codecs"; |
130 | QDir dir( path, "lib*.so" ); | 135 | QDir dir( path, "lib*.so" ); |
131 | QStringList list = dir.entryList(); | 136 | QStringList list = dir.entryList(); |
132 | QStringList::Iterator it; | 137 | QStringList::Iterator it; |
133 | for ( it = list.begin(); it != list.end(); ++it ) { | 138 | for ( it = list.begin(); it != list.end(); ++it ) { |
134 | MediaPlayerPluginInterface *iface = 0; | 139 | MediaPlayerPluginInterface *iface = 0; |
135 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 140 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
136 | 141 | ||
137 | MediaPlayerDebug(( "querying: %s", QString( path + "/" + *it ).latin1() )); | 142 | MediaPlayerDebug(( "querying: %s", QString( path + "/" + *it ).latin1() )); |
138 | 143 | ||
139 | if ( lib->queryInterface( IID_MediaPlayerPlugin, (QUnknownInterface**)&iface ) == QS_OK ) { | 144 | if ( lib->queryInterface( IID_MediaPlayerPlugin, (QUnknownInterface**)&iface ) == QS_OK ) { |
140 | 145 | ||
141 | MediaPlayerDebug(( "loading: %s", QString( path + "/" + *it ).latin1() )); | 146 | MediaPlayerDebug(( "loading: %s", QString( path + "/" + *it ).latin1() )); |
142 | 147 | ||
143 | MediaPlayerPlugin plugin; | 148 | MediaPlayerPlugin plugin; |
144 | plugin.library = lib; | 149 | plugin.library = lib; |
145 | plugin.iface = iface; | 150 | plugin.iface = iface; |
146 | plugin.decoder = plugin.iface->decoder(); | 151 | plugin.decoder = plugin.iface->decoder(); |
147 | plugin.encoder = plugin.iface->encoder(); | 152 | plugin.encoder = plugin.iface->encoder(); |
148 | pluginList.append( plugin ); | 153 | pluginList.append( plugin ); |
149 | 154 | ||
150 | // ### hack to get true sample count | 155 | // ### hack to get true sample count |
151 | if ( plugin.decoder->pluginName() == QString("LibMpeg3Plugin") ) | 156 | if ( plugin.decoder->pluginName() == QString("LibMpeg3Plugin") ) |
152 | libmpeg3decoder = plugin.decoder; | 157 | libmpeg3decoder = plugin.decoder; |
153 | 158 | ||
154 | } else { | 159 | } else { |
155 | delete lib; | 160 | delete lib; |
156 | } | 161 | } |
157 | } | 162 | } |
158 | #else | 163 | #else |
159 | pluginList.clear(); | 164 | pluginList.clear(); |
160 | 165 | ||
161 | MediaPlayerPlugin plugin0; | 166 | MediaPlayerPlugin plugin0; |
162 | plugin0.iface = new LibMpeg3PluginImpl; | 167 | plugin0.iface = new LibMpeg3PluginImpl; |
163 | plugin0.decoder = plugin0.iface->decoder(); | 168 | plugin0.decoder = plugin0.iface->decoder(); |
164 | plugin0.encoder = plugin0.iface->encoder(); | 169 | plugin0.encoder = plugin0.iface->encoder(); |
165 | pluginList.append( plugin0 ); | 170 | pluginList.append( plugin0 ); |
166 | 171 | ||
167 | MediaPlayerPlugin plugin1; | 172 | MediaPlayerPlugin plugin1; |
168 | plugin1.iface = new LibMadPluginImpl; | 173 | plugin1.iface = new LibMadPluginImpl; |
169 | plugin1.decoder = plugin1.iface->decoder(); | 174 | plugin1.decoder = plugin1.iface->decoder(); |
170 | plugin1.encoder = plugin1.iface->encoder(); | 175 | plugin1.encoder = plugin1.iface->encoder(); |
171 | pluginList.append( plugin1 ); | 176 | pluginList.append( plugin1 ); |
172 | 177 | ||
173 | MediaPlayerPlugin plugin2; | 178 | MediaPlayerPlugin plugin2; |
174 | plugin2.iface = new WavPluginImpl; | 179 | plugin2.iface = new WavPluginImpl; |
175 | plugin2.decoder = plugin2.iface->decoder(); | 180 | plugin2.decoder = plugin2.iface->decoder(); |
176 | plugin2.encoder = plugin2.iface->encoder(); | 181 | plugin2.encoder = plugin2.iface->encoder(); |
177 | pluginList.append( plugin2 ); | 182 | pluginList.append( plugin2 ); |
178 | #endif | 183 | #endif |
179 | 184 | ||
180 | if ( pluginList.count() ) | 185 | if ( pluginList.count() ) |
181 | MediaPlayerDebug(( "%i decoders found", pluginList.count() )); | 186 | MediaPlayerDebug(( "%i decoders found", pluginList.count() )); |
182 | else | 187 | else |
183 | MediaPlayerDebug(( "No decoders found" )); | 188 | MediaPlayerDebug(( "No decoders found" )); |
184 | } | 189 | } |
185 | 190 | ||