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