Diffstat (limited to 'core/multimedia/opieplayer/mediaplayerstate.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/multimedia/opieplayer/mediaplayerstate.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/core/multimedia/opieplayer/mediaplayerstate.cpp b/core/multimedia/opieplayer/mediaplayerstate.cpp index b700cd1..8b0fbbc 100644 --- a/core/multimedia/opieplayer/mediaplayerstate.cpp +++ b/core/multimedia/opieplayer/mediaplayerstate.cpp | |||
@@ -46,152 +46,152 @@ MediaPlayerState::MediaPlayerState( QObject *parent, const char *name ) | |||
46 | : QObject( parent, name ), decoder( NULL ), libmpeg3decoder( NULL ) { | 46 | : QObject( parent, name ), decoder( NULL ), libmpeg3decoder( NULL ) { |
47 | Config cfg( "OpiePlayer" ); | 47 | Config cfg( "OpiePlayer" ); |
48 | readConfig( cfg ); | 48 | readConfig( cfg ); |
49 | loadPlugins(); | 49 | loadPlugins(); |
50 | } | 50 | } |
51 | 51 | ||
52 | 52 | ||
53 | MediaPlayerState::~MediaPlayerState() { | 53 | MediaPlayerState::~MediaPlayerState() { |
54 | Config cfg( "OpiePlayer" ); | 54 | Config cfg( "OpiePlayer" ); |
55 | writeConfig( cfg ); | 55 | writeConfig( cfg ); |
56 | } | 56 | } |
57 | 57 | ||
58 | 58 | ||
59 | void MediaPlayerState::readConfig( Config& cfg ) { | 59 | void MediaPlayerState::readConfig( Config& cfg ) { |
60 | cfg.setGroup("Options"); | 60 | cfg.setGroup("Options"); |
61 | isFullscreen = cfg.readBoolEntry( "FullScreen" ); | 61 | isFullscreen = cfg.readBoolEntry( "FullScreen" ); |
62 | isScaled = cfg.readBoolEntry( "Scaling" ); | 62 | isScaled = cfg.readBoolEntry( "Scaling" ); |
63 | isLooping = cfg.readBoolEntry( "Looping" ); | 63 | isLooping = cfg.readBoolEntry( "Looping" ); |
64 | isShuffled = cfg.readBoolEntry( "Shuffle" ); | 64 | isShuffled = cfg.readBoolEntry( "Shuffle" ); |
65 | usePlaylist = cfg.readBoolEntry( "UsePlayList" ); | 65 | usePlaylist = cfg.readBoolEntry( "UsePlayList" ); |
66 | usePlaylist = TRUE; | 66 | usePlaylist = TRUE; |
67 | isPlaying = FALSE; | 67 | isPlaying = FALSE; |
68 | isPaused = FALSE; | 68 | isPaused = FALSE; |
69 | curPosition = 0; | 69 | curPosition = 0; |
70 | curLength = 0; | 70 | curLength = 0; |
71 | curView = 'l'; | 71 | curView = 'l'; |
72 | } | 72 | } |
73 | 73 | ||
74 | 74 | ||
75 | void MediaPlayerState::writeConfig( Config& cfg ) const { | 75 | void MediaPlayerState::writeConfig( Config& cfg ) const { |
76 | cfg.setGroup("Options"); | 76 | cfg.setGroup("Options"); |
77 | cfg.writeEntry("FullScreen", isFullscreen ); | 77 | cfg.writeEntry("FullScreen", isFullscreen ); |
78 | cfg.writeEntry("Scaling", isScaled ); | 78 | cfg.writeEntry("Scaling", isScaled ); |
79 | cfg.writeEntry("Looping", isLooping ); | 79 | cfg.writeEntry("Looping", isLooping ); |
80 | cfg.writeEntry("Shuffle", isShuffled ); | 80 | cfg.writeEntry("Shuffle", isShuffled ); |
81 | cfg.writeEntry("UsePlayList", usePlaylist ); | 81 | cfg.writeEntry("UsePlayList", usePlaylist ); |
82 | } | 82 | } |
83 | 83 | ||
84 | 84 | ||
85 | struct MediaPlayerPlugin { | 85 | struct MediaPlayerPlugin { |
86 | #ifndef QT_NO_COMPONENT | 86 | #ifndef QT_NO_COMPONENT |
87 | QLibrary *library; | 87 | QLibrary *library; |
88 | #endif | 88 | #endif |
89 | MediaPlayerPluginInterface *iface; | 89 | MediaPlayerPluginInterface *iface; |
90 | MediaPlayerDecoder *decoder; | 90 | MediaPlayerDecoder *decoder; |
91 | MediaPlayerEncoder *encoder; | 91 | MediaPlayerEncoder *encoder; |
92 | }; | 92 | }; |
93 | 93 | ||
94 | 94 | ||
95 | static QValueList<MediaPlayerPlugin> pluginList; | 95 | static QValueList<MediaPlayerPlugin> pluginList; |
96 | 96 | ||
97 | 97 | ||
98 | // Find the first decoder which supports this type of file | 98 | // Find the first decoder which supports this type of file |
99 | MediaPlayerDecoder *MediaPlayerState::newDecoder( const QString& file ) { | 99 | MediaPlayerDecoder *MediaPlayerState::newDecoder( const QString& file ) { |
100 | MediaPlayerDecoder *tmpDecoder = NULL; | 100 | MediaPlayerDecoder *tmpDecoder = NULL; |
101 | QValueList<MediaPlayerPlugin>::Iterator it; | 101 | QValueList<MediaPlayerPlugin>::Iterator it; |
102 | for ( it = pluginList.begin(); it != pluginList.end(); ++it ) { | 102 | for ( it = pluginList.begin(); it != pluginList.end(); ++it ) { |
103 | if ( (*it).decoder->isFileSupported( file ) ) { | 103 | if ( (*it).decoder->isFileSupported( file ) ) { |
104 | tmpDecoder = (*it).decoder; | 104 | tmpDecoder = (*it).decoder; |
105 | break; | 105 | break; |
106 | } | 106 | } |
107 | } | 107 | } |
108 | if(file.left(4)=="http") | 108 | if(file.left(4)=="http") |
109 | isStreaming = TRUE; | 109 | isStreaming = TRUE; |
110 | else | 110 | else |
111 | isStreaming = FALSE; | 111 | isStreaming = FALSE; |
112 | return decoder = tmpDecoder; | 112 | return decoder = tmpDecoder; |
113 | } | 113 | } |
114 | 114 | ||
115 | 115 | ||
116 | MediaPlayerDecoder *MediaPlayerState::curDecoder() { | 116 | MediaPlayerDecoder *MediaPlayerState::curDecoder() { |
117 | return decoder; | 117 | return decoder; |
118 | } | 118 | } |
119 | 119 | ||
120 | 120 | ||
121 | // ### hack to get true sample count | 121 | // ### hack to get true sample count |
122 | MediaPlayerDecoder *MediaPlayerState::libMpeg3Decoder() { | 122 | MediaPlayerDecoder *MediaPlayerState::libMpeg3Decoder() { |
123 | return libmpeg3decoder; | 123 | return libmpeg3decoder; |
124 | } | 124 | } |
125 | 125 | ||
126 | // ### hack to get true sample count | 126 | // ### hack to get true sample count |
127 | // MediaPlayerDecoder *MediaPlayerState::libWavDecoder() { | 127 | // MediaPlayerDecoder *MediaPlayerState::libWavDecoder() { |
128 | // return libwavdecoder; | 128 | // return libwavdecoder; |
129 | // } | 129 | // } |
130 | 130 | ||
131 | void MediaPlayerState::loadPlugins() { | 131 | void MediaPlayerState::loadPlugins() { |
132 | // odebug << "load plugins" << oendl; | 132 | // odebug << "load plugins" << oendl; |
133 | #ifndef QT_NO_COMPONENT | 133 | #ifndef QT_NO_COMPONENT |
134 | QValueList<MediaPlayerPlugin>::Iterator mit; | 134 | QValueList<MediaPlayerPlugin>::Iterator mit; |
135 | for ( mit = pluginList.begin(); mit != pluginList.end(); ++mit ) { | 135 | for ( mit = pluginList.begin(); mit != pluginList.end(); ++mit ) { |
136 | (*mit).iface->release(); | 136 | (*mit).iface->release(); |
137 | (*mit).library->unload(); | 137 | (*mit).library->unload(); |
138 | delete (*mit).library; | 138 | delete (*mit).library; |
139 | } | 139 | } |
140 | pluginList.clear(); | 140 | pluginList.clear(); |
141 | 141 | ||
142 | QString path = QPEApplication::qpeDir() + "/plugins/codecs"; | 142 | QString path = QPEApplication::qpeDir() + "plugins/codecs"; |
143 | QDir dir( path, "lib*.so" ); | 143 | QDir dir( path, "lib*.so" ); |
144 | QStringList list = dir.entryList(); | 144 | QStringList list = dir.entryList(); |
145 | QStringList::Iterator it; | 145 | QStringList::Iterator it; |
146 | for ( it = list.begin(); it != list.end(); ++it ) { | 146 | for ( it = list.begin(); it != list.end(); ++it ) { |
147 | MediaPlayerPluginInterface *iface = 0; | 147 | MediaPlayerPluginInterface *iface = 0; |
148 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 148 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
149 | // odebug << "querying: " << QString( path + "/" + *it ) << "" << oendl; | 149 | // odebug << "querying: " << QString( path + "/" + *it ) << "" << oendl; |
150 | 150 | ||
151 | if ( lib->queryInterface( IID_MediaPlayerPlugin, (QUnknownInterface**)&iface ) == QS_OK ) { | 151 | if ( lib->queryInterface( IID_MediaPlayerPlugin, (QUnknownInterface**)&iface ) == QS_OK ) { |
152 | 152 | ||
153 | // odebug << "loading: " << QString( path + "/" + *it ) << "" << oendl; | 153 | // odebug << "loading: " << QString( path + "/" + *it ) << "" << oendl; |
154 | 154 | ||
155 | MediaPlayerPlugin plugin; | 155 | MediaPlayerPlugin plugin; |
156 | plugin.library = lib; | 156 | plugin.library = lib; |
157 | plugin.iface = iface; | 157 | plugin.iface = iface; |
158 | plugin.decoder = plugin.iface->decoder(); | 158 | plugin.decoder = plugin.iface->decoder(); |
159 | plugin.encoder = plugin.iface->encoder(); | 159 | plugin.encoder = plugin.iface->encoder(); |
160 | pluginList.append( plugin ); | 160 | pluginList.append( plugin ); |
161 | 161 | ||
162 | // ### hack to get true sample count | 162 | // ### hack to get true sample count |
163 | if ( plugin.decoder->pluginName() == QString("LibMpeg3Plugin") ) | 163 | if ( plugin.decoder->pluginName() == QString("LibMpeg3Plugin") ) |
164 | libmpeg3decoder = plugin.decoder; | 164 | libmpeg3decoder = plugin.decoder; |
165 | 165 | ||
166 | } else { | 166 | } else { |
167 | delete lib; | 167 | delete lib; |
168 | } | 168 | } |
169 | } | 169 | } |
170 | #else | 170 | #else |
171 | pluginList.clear(); | 171 | pluginList.clear(); |
172 | 172 | ||
173 | MediaPlayerPlugin plugin0; | 173 | MediaPlayerPlugin plugin0; |
174 | plugin0.iface = new LibMpeg3PluginImpl; | 174 | plugin0.iface = new LibMpeg3PluginImpl; |
175 | plugin0.decoder = plugin0.iface->decoder(); | 175 | plugin0.decoder = plugin0.iface->decoder(); |
176 | plugin0.encoder = plugin0.iface->encoder(); | 176 | plugin0.encoder = plugin0.iface->encoder(); |
177 | pluginList.append( plugin0 ); | 177 | pluginList.append( plugin0 ); |
178 | 178 | ||
179 | MediaPlayerPlugin plugin1; | 179 | MediaPlayerPlugin plugin1; |
180 | plugin1.iface = new LibMadPluginImpl; | 180 | plugin1.iface = new LibMadPluginImpl; |
181 | plugin1.decoder = plugin1.iface->decoder(); | 181 | plugin1.decoder = plugin1.iface->decoder(); |
182 | plugin1.encoder = plugin1.iface->encoder(); | 182 | plugin1.encoder = plugin1.iface->encoder(); |
183 | pluginList.append( plugin1 ); | 183 | pluginList.append( plugin1 ); |
184 | 184 | ||
185 | MediaPlayerPlugin plugin2; | 185 | MediaPlayerPlugin plugin2; |
186 | plugin2.iface = new WavPluginImpl; | 186 | plugin2.iface = new WavPluginImpl; |
187 | plugin2.decoder = plugin2.iface->decoder(); | 187 | plugin2.decoder = plugin2.iface->decoder(); |
188 | plugin2.encoder = plugin2.iface->encoder(); | 188 | plugin2.encoder = plugin2.iface->encoder(); |
189 | pluginList.append( plugin2 ); | 189 | pluginList.append( plugin2 ); |
190 | #endif | 190 | #endif |
191 | 191 | ||
192 | if ( pluginList.count() ) | 192 | if ( pluginList.count() ) |
193 | MediaPlayerDebug(( "%i decoders found", pluginList.count() )); | 193 | MediaPlayerDebug(( "%i decoders found", pluginList.count() )); |
194 | else | 194 | else |
195 | MediaPlayerDebug(( "No decoders found" )); | 195 | MediaPlayerDebug(( "No decoders found" )); |
196 | } | 196 | } |
197 | 197 | ||