Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Toutes les fonctions  ·  Vues d'ensemble  · 

Tutorial: Creating Plugin For Cruxus Engine

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

QMediaCodecPlugin Class Definition for wavplay

    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

QMediaCodecPlugin Class Code for wavplay

see also QMediaCodecPlugin plugins/codecs/wavplay/wavplugin.cpp is an implementation of this class.

plugins/codecs/wavplay/wavdecoder.h

QMediaDecoder Class Definition for wavplay

    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

QMediaDecoder Class Code for wavplay

see also QMediaDecoder plugins/codecs/wavplay/wavdecoder.cpp is an implementation of this class.

Creating a new Cruxus plugin

Copy an existing plugin to use as a template.

  1. Create a new directory (eg. $HOME/src/libblah) and copy all the wavplay files to that directory.
        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).

  2. Build the new application.
        export QPEDIR=<qt-extended-build-directory>
        $QPEDIR/bin/qbuild
        $QPEDIR/bin/qbuild image
  3. Run Qt Extended.
        $QPEDIR/bin/runqtopia
  4. Try playing media file that your codec decodes.

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt qtextended4.4
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web