src/3rdparty/phonon/mmf/abstractaudioeffect.h
changeset 18 2f34d5167611
parent 0 1918ee327afb
child 8 3f74d0d4af4c
equal deleted inserted replaced
3:41300fa6a67c 18:2f34d5167611
    17 */
    17 */
    18 
    18 
    19 #ifndef PHONON_MMF_ABSTRACTEFFECT_H
    19 #ifndef PHONON_MMF_ABSTRACTEFFECT_H
    20 #define PHONON_MMF_ABSTRACTEFFECT_H
    20 #define PHONON_MMF_ABSTRACTEFFECT_H
    21 
    21 
    22 #include "mmf_medianode.h"
       
    23 
       
    24 #include <QScopedPointer>
    22 #include <QScopedPointer>
    25 
    23 
    26 #include <AudioEffectBase.h>
    24 #include <AudioEffectBase.h>
    27 
    25 
    28 #include <Phonon/EffectInterface>
    26 #include <phonon/effectinterface.h>
    29 #include <Phonon/EffectParameter>
    27 
    30 #include "audioplayer.h"
    28 #include "audioplayer.h"
       
    29 #include "effectparameter.h"
       
    30 #include "mmf_medianode.h"
       
    31 #include "mmf_videoplayer.h"
       
    32 
       
    33 class CMdaAudioOutputStream;
    31 
    34 
    32 QT_BEGIN_NAMESPACE
    35 QT_BEGIN_NAMESPACE
    33 
    36 
    34 namespace Phonon
    37 namespace Phonon
    35 {
    38 {
    36 namespace MMF
    39 namespace MMF
    37 {
    40 {
       
    41 class AbstractPlayer;
       
    42 class AbstractMediaPlayer;
    38 
    43 
    39 /**
    44 /**
    40  * @short Base class for all effects for MMF.
    45  * @short Base class for all effects for MMF.
    41  *
    46  *
    42  * Adhering to Phonon with MMF is cumbersome because of a number of reasons:
    47  * Adhering to Phonon with MMF is cumbersome because of a number of reasons:
    59     Q_INTERFACES(Phonon::EffectInterface)
    64     Q_INTERFACES(Phonon::EffectInterface)
    60 public:
    65 public:
    61     AbstractAudioEffect(QObject *parent,
    66     AbstractAudioEffect(QObject *parent,
    62                         const QList<EffectParameter> &params);
    67                         const QList<EffectParameter> &params);
    63 
    68 
    64     virtual QList<EffectParameter> parameters() const;
    69     // Phonon::EffectInterface
    65     virtual QVariant parameterValue(const EffectParameter &param) const;
    70     virtual QList<Phonon::EffectParameter> parameters() const;
    66     virtual void setParameterValue(const EffectParameter &,
    71     virtual QVariant parameterValue(const Phonon::EffectParameter &param) const;
       
    72     virtual void setParameterValue(const Phonon::EffectParameter &,
    67                                    const QVariant &newValue);
    73                                    const QVariant &newValue);
    68 
    74 
    69     virtual bool disconnectMediaNode(MediaNode *target);
    75     // Parameters which are shared by all effects
    70 
    76     enum CommonParameters
    71     enum Type
       
    72     {
    77     {
    73         EffectAudioEqualizer = 1,
    78         ParameterEnable = 0,
    74         EffectBassBoost,
    79         ParameterBase // must be last entry in enum
    75         EffectDistanceAttenuation,
       
    76         EffectEnvironmentalReverb,
       
    77         EffectListenerOrientation,
       
    78         EffectLoudness,
       
    79         EffectSourceOrientation,
       
    80         EffectStereoWidening
       
    81     };
    80     };
    82 
    81 
       
    82 public Q_SLOTS:
       
    83     void abstractPlayerChanged(AbstractPlayer *player);
       
    84     void stateChanged(Phonon::State newState,
       
    85                       Phonon::State oldState);
       
    86 
    83 protected:
    87 protected:
    84     virtual bool activateOn(CPlayerType *player) = 0;
    88     // MediaNode
    85     virtual void parameterChanged(const int id,
    89     void connectMediaObject(MediaObject *mediaObject);
    86                                   const QVariant &value) = 0;
    90     void disconnectMediaObject(MediaObject *mediaObject);
    87 
    91 
    88     /**
    92     virtual void createEffect(AudioPlayer::NativePlayer *player) = 0;
    89      * Part of the implementation of AbstractAudioEffect. Forwards the call to
       
    90      * activateOn(), essentially.
       
    91      */
       
    92     virtual bool activateOnMediaObject(MediaObject *mo);
       
    93 
    93 
       
    94     // Effect-specific parameter changed
       
    95     virtual int effectParameterChanged(const EffectParameter &param,
       
    96                                   const QVariant &value);
       
    97 
       
    98 private:
       
    99     void createEffect();
       
   100     void setEnabled(bool enabled);
       
   101     const EffectParameter& internalParameter(int id) const;
       
   102     int parameterChanged(const EffectParameter &param,
       
   103             const QVariant &value);
       
   104 
       
   105 protected:
    94     QScopedPointer<CAudioEffect>    m_effect;
   106     QScopedPointer<CAudioEffect>    m_effect;
       
   107 
    95 private:
   108 private:
    96     const QList<EffectParameter>    m_params;
   109     const QList<EffectParameter>    m_params;
       
   110     AbstractMediaPlayer *           m_player;
    97     QHash<int, QVariant>            m_values;
   111     QHash<int, QVariant>            m_values;
    98 };
   112 };
       
   113 
    99 }
   114 }
       
   115 }
       
   116 
       
   117 
       
   118 // Macro for defining functions which depend on the native class name
       
   119 // for each of the effects.  Using this reduces repetition of boilerplate
       
   120 // in the implementations of the backend effect nodes.
       
   121 
       
   122 #define PHONON_MMF_DEFINE_EFFECT_FUNCTIONS(Effect)                      \
       
   123                                                                         \
       
   124 void Effect##::createEffect(AudioPlayer::NativePlayer *player)          \
       
   125 {                                                                       \
       
   126     C##Effect *ptr = 0;                                                 \
       
   127     QT_TRAP_THROWING(ptr = C##Effect::NewL(*player));                   \
       
   128     m_effect.reset(ptr);                                                \
       
   129 }                                                                       \
       
   130                                                                         \
       
   131 C##Effect* Effect::concreteEffect()                                     \
       
   132 {                                                                       \
       
   133     return static_cast<C##Effect *>(m_effect.data());                   \
   100 }
   134 }
   101 
   135 
   102 QT_END_NAMESPACE
   136 QT_END_NAMESPACE
   103 
   137 
   104 #endif
   138 #endif