author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 02 Feb 2010 00:43:10 +0200 | |
changeset 3 | 41300fa6a67c |
parent 0 | 1918ee327afb |
child 4 | 3b1da2848fc7 |
child 7 | f7bc934e204c |
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)) |
0 | 48 |
{ |
49 |
TRACE_CONTEXT(Backend::Backend, EBackend); |
|
50 |
TRACE_ENTRY_0(); |
|
51 |
||
52 |
setProperty("identifier", QLatin1String("phonon_mmf")); |
|
53 |
setProperty("backendName", QLatin1String("MMF")); |
|
54 |
setProperty("backendComment", QLatin1String("Backend using Symbian Multimedia Framework (MMF)")); |
|
55 |
setProperty("backendVersion", QLatin1String("0.1")); |
|
56 |
setProperty("backendWebsite", QLatin1String("http://qt.nokia.com/")); |
|
57 |
||
58 |
TRACE_EXIT_0(); |
|
59 |
} |
|
60 |
||
61 |
QObject *Backend::createObject(BackendInterface::Class c, QObject *parent, const QList<QVariant> &args) |
|
62 |
{ |
|
63 |
TRACE_CONTEXT(Backend::createObject, EBackend); |
|
64 |
TRACE_ENTRY("class %d", c); |
|
65 |
||
66 |
QObject* result = 0; |
|
67 |
||
68 |
switch (c) { |
|
69 |
case AudioOutputClass: |
|
70 |
result = new AudioOutput(this, parent); |
|
71 |
break; |
|
72 |
||
73 |
case MediaObjectClass: |
|
74 |
result = new MediaObject(parent); |
|
75 |
break; |
|
76 |
||
77 |
case VolumeFaderEffectClass: |
|
78 |
case VisualizationClass: |
|
79 |
case VideoDataOutputClass: |
|
80 |
case EffectClass: |
|
81 |
{ |
|
82 |
Q_ASSERT(args.count() == 1); |
|
83 |
Q_ASSERT(args.first().type() == QVariant::Int); |
|
84 |
const AbstractAudioEffect::Type effect = AbstractAudioEffect::Type(args.first().toInt()); |
|
85 |
||
86 |
return EffectFactory::createAudioEffect(effect, parent); |
|
87 |
} |
|
88 |
case VideoWidgetClass: |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
89 |
result = new VideoWidget(m_ancestorMoveMonitor.data(), qobject_cast<QWidget *>(parent)); |
0 | 90 |
break; |
91 |
||
92 |
default: |
|
93 |
TRACE_PANIC(InvalidBackendInterfaceClass); |
|
94 |
} |
|
95 |
||
96 |
TRACE_RETURN("0x%08x", result); |
|
97 |
} |
|
98 |
||
99 |
QList<int> Backend::objectDescriptionIndexes(ObjectDescriptionType type) const |
|
100 |
{ |
|
101 |
TRACE_CONTEXT(Backend::objectDescriptionIndexes, EAudioApi); |
|
102 |
TRACE_ENTRY_0(); |
|
103 |
QList<int> retval; |
|
104 |
||
105 |
switch(type) |
|
106 |
{ |
|
107 |
case EffectType: |
|
108 |
retval.append(EffectFactory::effectIndexes()); |
|
109 |
break; |
|
110 |
case AudioOutputDeviceType: |
|
111 |
// We only have one possible output device, but we need at least |
|
112 |
// one. |
|
113 |
retval.append(AudioOutput::AudioOutputDeviceID); |
|
114 |
break; |
|
115 |
default: |
|
116 |
; |
|
117 |
} |
|
118 |
||
119 |
TRACE_EXIT_0(); |
|
120 |
return retval; |
|
121 |
} |
|
122 |
||
123 |
QHash<QByteArray, QVariant> Backend::objectDescriptionProperties(ObjectDescriptionType type, int index) const |
|
124 |
{ |
|
125 |
TRACE_CONTEXT(Backend::connectNodes, EBackend); |
|
126 |
||
127 |
switch (type) { |
|
128 |
case EffectType: |
|
129 |
return EffectFactory::audioEffectDescriptions(AbstractAudioEffect::Type(index)); |
|
130 |
case AudioOutputDeviceType: |
|
131 |
return AudioOutput::audioOutputDescription(index); |
|
132 |
default: |
|
133 |
return QHash<QByteArray, QVariant>(); |
|
134 |
} |
|
135 |
} |
|
136 |
||
137 |
bool Backend::startConnectionChange(QSet<QObject *>) |
|
138 |
{ |
|
139 |
return true; |
|
140 |
} |
|
141 |
||
142 |
bool Backend::connectNodes(QObject *source, QObject *target) |
|
143 |
{ |
|
144 |
TRACE_CONTEXT(Backend::connectNodes, EBackend); |
|
145 |
TRACE_ENTRY("source 0x%08x target 0x%08x", source, target); |
|
146 |
Q_ASSERT(qobject_cast<MediaNode *>(source)); |
|
147 |
Q_ASSERT(qobject_cast<MediaNode *>(target)); |
|
148 |
||
149 |
MediaNode *const mediaSource = static_cast<MediaNode *>(source); |
|
150 |
MediaNode *const mediaTarget = static_cast<MediaNode *>(target); |
|
151 |
||
152 |
return mediaSource->connectMediaNode(mediaTarget); |
|
153 |
} |
|
154 |
||
155 |
bool Backend::disconnectNodes(QObject *source, QObject *target) |
|
156 |
{ |
|
157 |
TRACE_CONTEXT(Backend::disconnectNodes, EBackend); |
|
158 |
TRACE_ENTRY("source 0x%08x target 0x%08x", source, target); |
|
159 |
Q_ASSERT(qobject_cast<MediaNode *>(source)); |
|
160 |
Q_ASSERT(qobject_cast<MediaNode *>(target)); |
|
161 |
||
162 |
const bool result = static_cast<MediaNode *>(source)->disconnectMediaNode(static_cast<MediaNode *>(target)); |
|
163 |
||
164 |
TRACE_RETURN("%d", result); |
|
165 |
} |
|
166 |
||
167 |
bool Backend::endConnectionChange(QSet<QObject *>) |
|
168 |
{ |
|
169 |
return true; |
|
170 |
} |
|
171 |
||
172 |
void getAvailableMimeTypesL(QStringList& result) |
|
173 |
{ |
|
174 |
RApaLsSession apaSession; |
|
175 |
User::LeaveIfError(apaSession.Connect()); |
|
176 |
CleanupClosePushL(apaSession); |
|
177 |
||
178 |
static const TInt DataTypeArrayGranularity = 8; |
|
179 |
CDataTypeArray* array = new(ELeave) CDataTypeArray(DataTypeArrayGranularity); |
|
180 |
CleanupStack::PushL(array); |
|
181 |
||
182 |
apaSession.GetSupportedDataTypesL(*array); |
|
183 |
||
184 |
for (TInt i = 0; i < array->Count(); ++i) { |
|
185 |
const TPtrC mimeType = array->At(i).Des(); |
|
186 |
const MediaType mediaType = Utils::mimeTypeToMediaType(mimeType); |
|
187 |
if (MediaTypeAudio == mediaType or MediaTypeVideo == mediaType) { |
|
188 |
result.append(qt_TDesC2QString(mimeType)); |
|
189 |
} |
|
190 |
} |
|
191 |
||
192 |
CleanupStack::PopAndDestroy(2); // apaSession, array |
|
193 |
} |
|
194 |
||
195 |
QStringList Backend::availableMimeTypes() const |
|
196 |
{ |
|
197 |
QStringList result; |
|
198 |
||
199 |
// There is no way to return an error from this function, so we just |
|
200 |
// have to trap and ignore exceptions... |
|
201 |
TRAP_IGNORE(getAvailableMimeTypesL(result)); |
|
202 |
||
203 |
result.sort(); |
|
204 |
||
205 |
return result; |
|
206 |
} |
|
207 |
||
208 |
Q_EXPORT_PLUGIN2(phonon_mmf, Phonon::MMF::Backend); |
|
209 |
||
210 |
QT_END_NAMESPACE |
|
211 |