src/3rdparty/phonon/mmf/mmf_medianode.h
changeset 18 2f34d5167611
parent 0 1918ee327afb
equal deleted inserted replaced
3:41300fa6a67c 18:2f34d5167611
    18 
    18 
    19 #ifndef PHONON_MMF_MEDIANODE_H
    19 #ifndef PHONON_MMF_MEDIANODE_H
    20 #define PHONON_MMF_MEDIANODE_H
    20 #define PHONON_MMF_MEDIANODE_H
    21 
    21 
    22 #include <QObject>
    22 #include <QObject>
    23 #include <Phonon/EffectInterface>
    23 #include <phonon/effectinterface.h>
    24 #include "audioplayer.h"
    24 #include "audioplayer.h"
    25 
    25 
    26 QT_BEGIN_NAMESPACE
    26 QT_BEGIN_NAMESPACE
    27 
    27 
    28 /**
    28 /**
    41 class MediaObject;
    41 class MediaObject;
    42 
    42 
    43 /**
    43 /**
    44  * @short Base class for all nodes in the MMF backend.
    44  * @short Base class for all nodes in the MMF backend.
    45  *
    45  *
    46  * MediaNode is the base class for all nodes in the chain for MMF. Currently
    46  * MediaNode is the base class for all nodes created by the MMF
    47  * they are:
    47  * backend.
    48  *
    48  *
    49  * - MediaObject: a source of media
    49  * These nodes may be one of the following types:
    50  * - AbstractEffect: supplying audio effects
       
    51  * - AudioOutput: pretty much a dummy interface, but is also MediaNode in order
       
    52  *   to simplify connection/disconnection.
       
    53  *
    50  *
    54  * MediaNode provides spectatability into the chain, and also allows the
    51  * - MediaObject
    55  * connection code to be written in a polymorphic manner, instead of putting it
    52  *      This represents the source of media data.  It encapsulates the
    56  * all in the Backend class. Due to that MMF has no concept of chaining, the
    53  *      appropriate MMF client API for playing audio or video.
    57  * order of the nodes in the graph has no meaning.
    54  * - AudioOutput
       
    55  *      This represents the audio output device.  Since the MMF client API
       
    56  *      does not expose the output device directly, this backend node
       
    57  *      simply forwards volume control commands to the MediaObject.
       
    58  * - VideoWidget
       
    59  *      A native widget on which video will be rendered.
       
    60  * - An audio effect, derived form AbstractAudioEffect
       
    61  *
       
    62  * Because the MMF API does not support the concept of a media filter graph,
       
    63  * this class must ensure the following:
       
    64  *
       
    65  * - Each media graph contains at most one MediaObject instance.
       
    66  * - Every non-MediaObject node holds a reference to the MediaObject.  This
       
    67  * allows commands to be sent through the graph to the encapsulated MMF client
       
    68  * API.
    58  */
    69  */
    59 class MediaNode : public QObject
    70 class MediaNode : public QObject
    60 {
    71 {
    61     Q_OBJECT
    72     Q_OBJECT
    62 public:
    73 public:
    63     MediaNode(QObject *parent);
    74     MediaNode(QObject *parent);
       
    75     ~MediaNode();
    64 
    76 
    65     virtual bool connectMediaNode(MediaNode *target);
    77     bool connectOutput(MediaNode *output);
    66     virtual bool disconnectMediaNode(MediaNode *target);
    78     bool disconnectOutput(MediaNode *output);
    67     void setSource(MediaNode *source);
       
    68 
    79 
    69     MediaNode *source() const;
    80     virtual void connectMediaObject(MediaObject *mediaObject) = 0;
    70     MediaNode *target() const;
    81     virtual void disconnectMediaObject(MediaObject *mediaObject) = 0;
    71 
       
    72 protected:
       
    73     /**
       
    74      * When connectMediaNode() is called and a MediaObject is part of
       
    75      * the its graph, this function will be called for each MediaNode in the
       
    76      * graph for which it hasn't been called yet.
       
    77      *
       
    78      * The caller guarantees that @p mo is always non-null.
       
    79      */
       
    80     virtual bool activateOnMediaObject(MediaObject *mo) = 0;
       
    81 
    82 
    82 private:
    83 private:
    83     /**
    84     bool isMediaObject() const;
    84      * Finds a MediaObject anywhere in the graph @p target is apart of, and
       
    85      * calls activateOnMediaObject() for all MediaNodes in the graph for which
       
    86      * it hasn't been applied to already.
       
    87      */
       
    88     bool applyNodesOnMediaObject(MediaNode *target);
       
    89 
    85 
    90     MediaNode * m_source;
    86     void updateMediaObject();
    91     MediaNode * m_target;
    87     void setMediaObject(MediaObject *mediaObject);
    92     bool        m_isApplied;
    88 
       
    89     typedef QList<const MediaNode *> NodeList;
       
    90     void visit(QList<MediaNode *>& visited, MediaObject*& mediaObject);
       
    91 
       
    92 private:
       
    93     MediaObject *       m_mediaObject;
       
    94 
       
    95     // All nodes except MediaObject may have an input
       
    96     MediaNode *         m_input;
       
    97 
       
    98     // Only MediaObject can have more than one output
       
    99     QList<MediaNode *>  m_outputs;
    93 };
   100 };
       
   101 
    94 }
   102 }
    95 }
   103 }
    96 
   104 
    97 QT_END_NAMESPACE
   105 QT_END_NAMESPACE
    98 
   106