src/3rdparty/phonon/mmf/backend.cpp
changeset 7 f7bc934e204c
parent 3 41300fa6a67c
equal deleted inserted replaced
3:41300fa6a67c 7:f7bc934e204c
    22 #include <apgcli.h> // for RApaLsSession
    22 #include <apgcli.h> // for RApaLsSession
    23 #include <apmrec.h> // for CDataTypeArray
    23 #include <apmrec.h> // for CDataTypeArray
    24 #include <apmstd.h> // for TDataType
    24 #include <apmstd.h> // for TDataType
    25 
    25 
    26 #include "abstractaudioeffect.h"
    26 #include "abstractaudioeffect.h"
    27 #include "ancestormovemonitor.h"
       
    28 #include "audiooutput.h"
    27 #include "audiooutput.h"
    29 #include "audioplayer.h"
    28 #include "audioplayer.h"
    30 #include "backend.h"
    29 #include "backend.h"
    31 #include "effectfactory.h"
    30 #include "effectfactory.h"
    32 #include "mediaobject.h"
    31 #include "mediaobject.h"
    42   \internal
    41   \internal
    43 */
    42 */
    44 
    43 
    45 Backend::Backend(QObject *parent)
    44 Backend::Backend(QObject *parent)
    46     : QObject(parent)
    45     : QObject(parent)
       
    46 #ifndef PHONON_MMF_VIDEO_SURFACES
    47     , m_ancestorMoveMonitor(new AncestorMoveMonitor(this))
    47     , m_ancestorMoveMonitor(new AncestorMoveMonitor(this))
       
    48 #endif
       
    49     , m_effectFactory(new EffectFactory(this))
    48 {
    50 {
    49     TRACE_CONTEXT(Backend::Backend, EBackend);
    51     TRACE_CONTEXT(Backend::Backend, EBackend);
    50     TRACE_ENTRY_0();
    52     TRACE_ENTRY_0();
    51 
    53 
    52     setProperty("identifier",     QLatin1String("phonon_mmf"));
    54     setProperty("identifier",     QLatin1String("phonon_mmf"));
    79     case VideoDataOutputClass:
    81     case VideoDataOutputClass:
    80     case EffectClass:
    82     case EffectClass:
    81     {
    83     {
    82         Q_ASSERT(args.count() == 1);
    84         Q_ASSERT(args.count() == 1);
    83         Q_ASSERT(args.first().type() == QVariant::Int);
    85         Q_ASSERT(args.first().type() == QVariant::Int);
    84         const AbstractAudioEffect::Type effect = AbstractAudioEffect::Type(args.first().toInt());
    86         const EffectFactory::Type type =
    85 
    87             static_cast<EffectFactory::Type>(args.first().toInt());
    86         return EffectFactory::createAudioEffect(effect, parent);
    88         return m_effectFactory->createAudioEffect(type, parent);
    87     }
    89     }
       
    90 
    88     case VideoWidgetClass:
    91     case VideoWidgetClass:
    89         result = new VideoWidget(m_ancestorMoveMonitor.data(), qobject_cast<QWidget *>(parent));
    92     {
       
    93         VideoWidget *widget = new VideoWidget(qobject_cast<QWidget *>(parent));
       
    94 #ifndef PHONON_MMF_VIDEO_SURFACES
       
    95         widget->setAncestorMoveMonitor(m_ancestorMoveMonitor.data());
       
    96 #endif
       
    97         result = widget;
       
    98     }
    90         break;
    99         break;
    91 
   100 
    92     default:
   101     default:
    93         TRACE_PANIC(InvalidBackendInterfaceClass);
   102         TRACE_PANIC(InvalidBackendInterfaceClass);
    94     }
   103     }
   103     QList<int> retval;
   112     QList<int> retval;
   104 
   113 
   105     switch(type)
   114     switch(type)
   106     {
   115     {
   107         case EffectType:
   116         case EffectType:
   108             retval.append(EffectFactory::effectIndexes());
   117             retval.append(m_effectFactory->effectIndexes());
   109             break;
   118             break;
   110         case AudioOutputDeviceType:
   119         case AudioOutputDeviceType:
   111             // We only have one possible output device, but we need at least
   120             // We only have one possible output device, but we need at least
   112             // one.
   121             // one.
   113             retval.append(AudioOutput::AudioOutputDeviceID);
   122             retval.append(AudioOutput::AudioOutputDeviceID);
   124 {
   133 {
   125     TRACE_CONTEXT(Backend::connectNodes, EBackend);
   134     TRACE_CONTEXT(Backend::connectNodes, EBackend);
   126 
   135 
   127     switch (type) {
   136     switch (type) {
   128         case EffectType:
   137         case EffectType:
   129             return EffectFactory::audioEffectDescriptions(AbstractAudioEffect::Type(index));
   138             return m_effectFactory->audioEffectDescriptions(EffectFactory::Type(index));
   130         case AudioOutputDeviceType:
   139         case AudioOutputDeviceType:
   131             return AudioOutput::audioOutputDescription(index);
   140             return AudioOutput::audioOutputDescription(index);
   132         default:
   141         default:
   133             return QHash<QByteArray, QVariant>();
   142             return QHash<QByteArray, QVariant>();
   134     }
   143     }
   137 bool Backend::startConnectionChange(QSet<QObject *>)
   146 bool Backend::startConnectionChange(QSet<QObject *>)
   138 {
   147 {
   139     return true;
   148     return true;
   140 }
   149 }
   141 
   150 
   142 bool Backend::connectNodes(QObject *source, QObject *target)
   151 bool Backend::connectNodes(QObject *sourceObject, QObject *targetObject)
   143 {
   152 {
   144     TRACE_CONTEXT(Backend::connectNodes, EBackend);
   153     TRACE_CONTEXT(Backend::connectNodes, EBackend);
   145     TRACE_ENTRY("source 0x%08x target 0x%08x", source, target);
   154     TRACE_ENTRY("source 0x%08x target 0x%08x", sourceObject, targetObject);
   146     Q_ASSERT(qobject_cast<MediaNode *>(source));
   155 
   147     Q_ASSERT(qobject_cast<MediaNode *>(target));
   156     MediaNode *const source = qobject_cast<MediaNode *>(sourceObject);
   148 
   157     MediaNode *const target = qobject_cast<MediaNode *>(targetObject);
   149     MediaNode *const mediaSource = static_cast<MediaNode *>(source);
   158 
   150     MediaNode *const mediaTarget = static_cast<MediaNode *>(target);
   159     Q_ASSERT_X(source, Q_FUNC_INFO, "source is not a MediaNode");
   151 
   160     Q_ASSERT_X(target, Q_FUNC_INFO, "target is not a MediaNode");
   152     return mediaSource->connectMediaNode(mediaTarget);
   161 
   153 }
   162     return source->connectOutput(target);
   154 
   163 }
   155 bool Backend::disconnectNodes(QObject *source, QObject *target)
   164 
       
   165 bool Backend::disconnectNodes(QObject *sourceObject, QObject *targetObject)
   156 {
   166 {
   157     TRACE_CONTEXT(Backend::disconnectNodes, EBackend);
   167     TRACE_CONTEXT(Backend::disconnectNodes, EBackend);
   158     TRACE_ENTRY("source 0x%08x target 0x%08x", source, target);
   168     TRACE_ENTRY("source 0x%08x target 0x%08x", sourceObject, targetObject);
   159     Q_ASSERT(qobject_cast<MediaNode *>(source));
   169 
   160     Q_ASSERT(qobject_cast<MediaNode *>(target));
   170     MediaNode *const source = qobject_cast<MediaNode *>(sourceObject);
   161 
   171     MediaNode *const target = qobject_cast<MediaNode *>(targetObject);
   162     const bool result = static_cast<MediaNode *>(source)->disconnectMediaNode(static_cast<MediaNode *>(target));
   172 
   163 
   173     Q_ASSERT_X(source, Q_FUNC_INFO, "source is not a MediaNode");
   164     TRACE_RETURN("%d", result);
   174     Q_ASSERT_X(target, Q_FUNC_INFO, "target is not a MediaNode");
       
   175 
       
   176     return source->disconnectOutput(target);
   165 }
   177 }
   166 
   178 
   167 bool Backend::endConnectionChange(QSet<QObject *>)
   179 bool Backend::endConnectionChange(QSet<QObject *>)
   168 {
   180 {
   169     return true;
   181     return true;