Home · All Namespaces · All Classes · Grouped Classes · Modules · Functions |
The Cruxus engine is a media engine created specifically for Qt Extended. Many plugins for this media engine already exist in the src/plugins/codecs and src/3rdparty/plugins/codecs directories including libmad (mp3), libtimidity (mid), tremor (ogg), wavplay (wav). To build using the cruxus engine use -mediaengines cruxus on the configure line to enable. Cruxus plugins are enabled and disabled by modifying src/general.pri and commenting or uncommenting before configuration.
NOTE: plugin codecs not provided in the source code can be obtained from qtextended.org.
It is also possible to build with multiple engines and the priority of use is determined by the order they appear in the configure line.
-mediaengines cruxus,helix,gstreamer
The following is the wav plugin used by cruxus for wav playback.
The basic process is as follows:
connectToInput(input) will be called to connect to the input stream.
The start() function of the QMediaDecoder is called this should start reading from the input stream and work out the playback parameter like frequency, channels and emit the signals lengthChanged(d->length), readyRead() and playerStateChanged(QtopiaMedia::Playing)
readData() function will be called to read and decode the input stream data emitting positionChanged(d->position) when needed.
Other functions required to be implemented are disconnectFromInput(), stop(), pause(), length(), seek(), setVolume(), volume(), setMuted(), isMuted().
plugins/codecs/wavplay/wavplugin.h
class WavPluginPrivate; class WavPlugin : public QObject, public QMediaCodecPlugin { Q_OBJECT Q_INTERFACES(QMediaCodecPlugin) public: WavPlugin(); ~WavPlugin(); QString name() const; QString comment() const; QStringList mimeTypes() const; QStringList fileExtensions() const; double version() const; bool canEncode() const; bool canDecode() const; QMediaEncoder* encoder(QString const& mimeType); QMediaDecoder* decoder(QString const& mimeType); private: WavPluginPrivate* d; };
plugins/codecs/wavplay/wavplugin.cpp
see also QMediaCodecPlugin plugins/codecs/wavplay/wavplugin.cpp is an implementation of this class.
plugins/codecs/wavplay/wavdecoder.h
class WavDecoderPrivate; class WavDecoder : public QMediaDecoder { Q_OBJECT public: WavDecoder(); ~WavDecoder(); QMediaDevice::Info const& dataType() const; bool connectToInput(QMediaDevice* input); void disconnectFromInput(QMediaDevice* input); void start(); void stop(); void pause(); quint64 length(); bool seek(qint64 ms); void setVolume(int volume); int volume(); void setMuted(bool mute); bool isMuted(); private: qint64 readData(char *data, qint64 maxlen); qint64 writeData(const char *data, qint64 len); WavDecoderPrivate* d; };
plugins/codecs/wavplay/wavdecoder.cpp
see also QMediaDecoder plugins/codecs/wavplay/wavdecoder.cpp is an implementation of this class.
Copy an existing plugin to use as a template.
mkdir $HOME/src/libblah cd $HOME/src/libblah cp -r <qt-extended-source-directory>/src/plugins/codecs/wavplay/* . chmod +w *
Edit and change name accordingly, replace functionality of each function accordingly (look at the many examples available already).
export QPEDIR=<qt-extended-build-directory> $QPEDIR/bin/qbuild $QPEDIR/bin/qbuild image
$QPEDIR/bin/runqtopia
Copyright © 2009 Trolltech | Trademarks | Qt Extended 4.4.3 |