author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Fri, 19 Feb 2010 23:40:16 +0200 | |
branch | RCL_3 |
changeset 4 | 3b1da2848fc7 |
parent 3 | 41300fa6a67c |
child 8 | 3f74d0d4af4c |
permissions | -rw-r--r-- |
0 | 1 |
/* This file is part of the KDE project. |
2 |
||
3 |
Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 |
||
5 |
This library is free software: you can redistribute it and/or modify |
|
6 |
it under the terms of the GNU Lesser General Public License as published by |
|
7 |
the Free Software Foundation, either version 2.1 or 3 of the License. |
|
8 |
||
9 |
This library is distributed in the hope that it will be useful, |
|
10 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
GNU Lesser General Public License for more details. |
|
13 |
||
14 |
You should have received a copy of the GNU Lesser General Public License |
|
15 |
along with this library. If not, see <http://www.gnu.org/licenses/>. |
|
16 |
||
17 |
*/ |
|
18 |
||
19 |
#include <QStringList> |
|
20 |
#include <QtPlugin> |
|
21 |
||
22 |
#include <apgcli.h> // for RApaLsSession |
|
23 |
#include <apmrec.h> // for CDataTypeArray |
|
24 |
#include <apmstd.h> // for TDataType |
|
25 |
||
26 |
#include "abstractaudioeffect.h" |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
27 |
#include "ancestormovemonitor.h" |
0 | 28 |
#include "audiooutput.h" |
29 |
#include "audioplayer.h" |
|
30 |
#include "backend.h" |
|
31 |
#include "effectfactory.h" |
|
32 |
#include "mediaobject.h" |
|
33 |
#include "utils.h" |
|
34 |
#include "videowidget.h" |
|
35 |
||
36 |
QT_BEGIN_NAMESPACE |
|
37 |
||
38 |
using namespace Phonon; |
|
39 |
using namespace Phonon::MMF; |
|
40 |
||
41 |
/*! \class MMF::Backend |
|
42 |
\internal |
|
43 |
*/ |
|
44 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
45 |
Backend::Backend(QObject *parent) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
46 |
: QObject(parent) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
47 |
, m_ancestorMoveMonitor(new AncestorMoveMonitor(this)) |
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
48 |
, m_effectFactory(new EffectFactory(this)) |
0 | 49 |
{ |
50 |
TRACE_CONTEXT(Backend::Backend, EBackend); |
|
51 |
TRACE_ENTRY_0(); |
|
52 |
||
53 |
setProperty("identifier", QLatin1String("phonon_mmf")); |
|
54 |
setProperty("backendName", QLatin1String("MMF")); |
|
55 |
setProperty("backendComment", QLatin1String("Backend using Symbian Multimedia Framework (MMF)")); |
|
56 |
setProperty("backendVersion", QLatin1String("0.1")); |
|
57 |
setProperty("backendWebsite", QLatin1String("http://qt.nokia.com/")); |
|
58 |
||
59 |
TRACE_EXIT_0(); |
|
60 |
} |
|
61 |
||
62 |
QObject *Backend::createObject(BackendInterface::Class c, QObject *parent, const QList<QVariant> &args) |
|
63 |
{ |
|
64 |
TRACE_CONTEXT(Backend::createObject, EBackend); |
|
65 |
TRACE_ENTRY("class %d", c); |
|
66 |
||
67 |
QObject* result = 0; |
|
68 |
||
69 |
switch (c) { |
|
70 |
case AudioOutputClass: |
|
71 |
result = new AudioOutput(this, parent); |
|
72 |
break; |
|
73 |
||
74 |
case MediaObjectClass: |
|
75 |
result = new MediaObject(parent); |
|
76 |
break; |
|
77 |
||
78 |
case VolumeFaderEffectClass: |
|
79 |
case VisualizationClass: |
|
80 |
case VideoDataOutputClass: |
|
81 |
case EffectClass: |
|
82 |
{ |
|
83 |
Q_ASSERT(args.count() == 1); |
|
84 |
Q_ASSERT(args.first().type() == QVariant::Int); |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
85 |
const EffectFactory::Type type = |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
86 |
static_cast<EffectFactory::Type>(args.first().toInt()); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
87 |
return m_effectFactory->createAudioEffect(type, parent); |
0 | 88 |
} |
89 |
case VideoWidgetClass: |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
90 |
result = new VideoWidget(m_ancestorMoveMonitor.data(), qobject_cast<QWidget *>(parent)); |
0 | 91 |
break; |
92 |
||
93 |
default: |
|
94 |
TRACE_PANIC(InvalidBackendInterfaceClass); |
|
95 |
} |
|
96 |
||
97 |
TRACE_RETURN("0x%08x", result); |
|
98 |
} |
|
99 |
||
100 |
QList<int> Backend::objectDescriptionIndexes(ObjectDescriptionType type) const |
|
101 |
{ |
|
102 |
TRACE_CONTEXT(Backend::objectDescriptionIndexes, EAudioApi); |
|
103 |
TRACE_ENTRY_0(); |
|
104 |
QList<int> retval; |
|
105 |
||
106 |
switch(type) |
|
107 |
{ |
|
108 |
case EffectType: |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
109 |
retval.append(m_effectFactory->effectIndexes()); |
0 | 110 |
break; |
111 |
case AudioOutputDeviceType: |
|
112 |
// We only have one possible output device, but we need at least |
|
113 |
// one. |
|
114 |
retval.append(AudioOutput::AudioOutputDeviceID); |
|
115 |
break; |
|
116 |
default: |
|
117 |
; |
|
118 |
} |
|
119 |
||
120 |
TRACE_EXIT_0(); |
|
121 |
return retval; |
|
122 |
} |
|
123 |
||
124 |
QHash<QByteArray, QVariant> Backend::objectDescriptionProperties(ObjectDescriptionType type, int index) const |
|
125 |
{ |
|
126 |
TRACE_CONTEXT(Backend::connectNodes, EBackend); |
|
127 |
||
128 |
switch (type) { |
|
129 |
case EffectType: |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
130 |
return m_effectFactory->audioEffectDescriptions(EffectFactory::Type(index)); |
0 | 131 |
case AudioOutputDeviceType: |
132 |
return AudioOutput::audioOutputDescription(index); |
|
133 |
default: |
|
134 |
return QHash<QByteArray, QVariant>(); |
|
135 |
} |
|
136 |
} |
|
137 |
||
138 |
bool Backend::startConnectionChange(QSet<QObject *>) |
|
139 |
{ |
|
140 |
return true; |
|
141 |
} |
|
142 |
||
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
143 |
bool Backend::connectNodes(QObject *sourceObject, QObject *targetObject) |
0 | 144 |
{ |
145 |
TRACE_CONTEXT(Backend::connectNodes, EBackend); |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
146 |
TRACE_ENTRY("source 0x%08x target 0x%08x", sourceObject, targetObject); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
147 |
|
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
148 |
MediaNode *const source = qobject_cast<MediaNode *>(sourceObject); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
149 |
MediaNode *const target = qobject_cast<MediaNode *>(targetObject); |
0 | 150 |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
151 |
Q_ASSERT_X(source, Q_FUNC_INFO, "source is not a MediaNode"); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
152 |
Q_ASSERT_X(target, Q_FUNC_INFO, "target is not a MediaNode"); |
0 | 153 |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
154 |
return source->connectOutput(target); |
0 | 155 |
} |
156 |
||
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
157 |
bool Backend::disconnectNodes(QObject *sourceObject, QObject *targetObject) |
0 | 158 |
{ |
159 |
TRACE_CONTEXT(Backend::disconnectNodes, EBackend); |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
160 |
TRACE_ENTRY("source 0x%08x target 0x%08x", sourceObject, targetObject); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
161 |
|
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
162 |
MediaNode *const source = qobject_cast<MediaNode *>(sourceObject); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
163 |
MediaNode *const target = qobject_cast<MediaNode *>(targetObject); |
0 | 164 |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
165 |
Q_ASSERT_X(source, Q_FUNC_INFO, "source is not a MediaNode"); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
166 |
Q_ASSERT_X(target, Q_FUNC_INFO, "target is not a MediaNode"); |
0 | 167 |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
168 |
return source->disconnectOutput(target); |
0 | 169 |
} |
170 |
||
171 |
bool Backend::endConnectionChange(QSet<QObject *>) |
|
172 |
{ |
|
173 |
return true; |
|
174 |
} |
|
175 |
||
176 |
void getAvailableMimeTypesL(QStringList& result) |
|
177 |
{ |
|
178 |
RApaLsSession apaSession; |
|
179 |
User::LeaveIfError(apaSession.Connect()); |
|
180 |
CleanupClosePushL(apaSession); |
|
181 |
||
182 |
static const TInt DataTypeArrayGranularity = 8; |
|
183 |
CDataTypeArray* array = new(ELeave) CDataTypeArray(DataTypeArrayGranularity); |
|
184 |
CleanupStack::PushL(array); |
|
185 |
||
186 |
apaSession.GetSupportedDataTypesL(*array); |
|
187 |
||
188 |
for (TInt i = 0; i < array->Count(); ++i) { |
|
189 |
const TPtrC mimeType = array->At(i).Des(); |
|
190 |
const MediaType mediaType = Utils::mimeTypeToMediaType(mimeType); |
|
191 |
if (MediaTypeAudio == mediaType or MediaTypeVideo == mediaType) { |
|
192 |
result.append(qt_TDesC2QString(mimeType)); |
|
193 |
} |
|
194 |
} |
|
195 |
||
196 |
CleanupStack::PopAndDestroy(2); // apaSession, array |
|
197 |
} |
|
198 |
||
199 |
QStringList Backend::availableMimeTypes() const |
|
200 |
{ |
|
201 |
QStringList result; |
|
202 |
||
203 |
// There is no way to return an error from this function, so we just |
|
204 |
// have to trap and ignore exceptions... |
|
205 |
TRAP_IGNORE(getAvailableMimeTypesL(result)); |
|
206 |
||
207 |
result.sort(); |
|
208 |
||
209 |
return result; |
|
210 |
} |
|
211 |
||
212 |
Q_EXPORT_PLUGIN2(phonon_mmf, Phonon::MMF::Backend); |
|
213 |
||
214 |
QT_END_NAMESPACE |
|
215 |