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 30 | 5dc02b23752f |
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 |
#include "common.h" |
|
19 |
#include "backend.h" |
|
20 |
#include "audiooutput.h" |
|
21 |
#include "audioeffect.h" |
|
22 |
#include "mediaobject.h" |
|
23 |
#include "videowidget.h" |
|
24 |
#include "devicemanager.h" |
|
25 |
#include "effectmanager.h" |
|
26 |
#include "message.h" |
|
27 |
#include "volumefadereffect.h" |
|
28 |
#include <gst/interfaces/propertyprobe.h> |
|
29 |
||
30 |
#include <QtCore/QSet> |
|
31 |
#include <QtCore/QVariant> |
|
32 |
#include <QtCore/QtPlugin> |
|
33 |
||
34 |
QT_BEGIN_NAMESPACE |
|
35 |
||
36 |
Q_EXPORT_PLUGIN2(phonon_gstreamer, Phonon::Gstreamer::Backend) |
|
37 |
||
38 |
namespace Phonon |
|
39 |
{ |
|
40 |
namespace Gstreamer |
|
41 |
{ |
|
42 |
||
43 |
class MediaNode; |
|
44 |
||
45 |
Backend::Backend(QObject *parent, const QVariantList &) |
|
46 |
: QObject(parent) |
|
47 |
, m_deviceManager(0) |
|
48 |
, m_effectManager(0) |
|
49 |
, m_debugLevel(Warning) |
|
50 |
, m_isValid(false) |
|
51 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
52 |
// In order to support reloading, we only set the app name once... |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
53 |
static bool first = true; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
54 |
if (first) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
55 |
first = false; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
56 |
g_set_application_name(qApp->applicationName().toUtf8()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
57 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
58 |
|
0 | 59 |
GError *err = 0; |
60 |
bool wasInit = gst_init_check(0, 0, &err); //init gstreamer: must be called before any gst-related functions |
|
61 |
if (err) |
|
62 |
g_error_free(err); |
|
63 |
||
64 |
qRegisterMetaType<Message>("Message"); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
65 |
#ifndef QT_NO_PROPERTIES |
0 | 66 |
setProperty("identifier", QLatin1String("phonon_gstreamer")); |
67 |
setProperty("backendName", QLatin1String("Gstreamer")); |
|
68 |
setProperty("backendComment", QLatin1String("Gstreamer plugin for Phonon")); |
|
69 |
setProperty("backendVersion", QLatin1String("0.2")); |
|
70 |
setProperty("backendWebsite", QLatin1String("http://qt.nokia.com/")); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
71 |
#endif //QT_NO_PROPERTIES |
0 | 72 |
|
73 |
//check if we should enable debug output |
|
74 |
QString debugLevelString = qgetenv("PHONON_GST_DEBUG"); |
|
75 |
int debugLevel = debugLevelString.toInt(); |
|
76 |
if (debugLevel > 3) //3 is maximum |
|
77 |
debugLevel = 3; |
|
78 |
m_debugLevel = (DebugLevel)debugLevel; |
|
79 |
||
80 |
if (wasInit) { |
|
81 |
m_isValid = checkDependencies(); |
|
82 |
gchar *versionString = gst_version_string(); |
|
83 |
logMessage(QString("Using %0").arg(versionString)); |
|
84 |
g_free(versionString); |
|
85 |
} |
|
86 |
if (!m_isValid) |
|
87 |
qWarning("Phonon::GStreamer::Backend: Failed to initialize GStreamer"); |
|
88 |
||
89 |
m_deviceManager = new DeviceManager(this); |
|
90 |
m_effectManager = new EffectManager(this); |
|
91 |
} |
|
92 |
||
93 |
Backend::~Backend() |
|
94 |
{ |
|
95 |
} |
|
96 |
||
97 |
gboolean Backend::busCall(GstBus *bus, GstMessage *msg, gpointer data) |
|
98 |
{ |
|
99 |
Q_UNUSED(bus); |
|
100 |
Q_ASSERT(msg); |
|
101 |
||
102 |
MediaObject *mediaObject = static_cast<MediaObject*>(data); |
|
103 |
Q_ASSERT(mediaObject); |
|
104 |
||
105 |
Message message(msg, mediaObject); |
|
106 |
QMetaObject::invokeMethod(mediaObject->backend(), "handleBusMessage", Qt::QueuedConnection, Q_ARG(Message, message)); |
|
107 |
||
108 |
return true; |
|
109 |
} |
|
110 |
||
111 |
/*** |
|
112 |
* !reimp |
|
113 |
*/ |
|
114 |
QObject *Backend::createObject(BackendInterface::Class c, QObject *parent, const QList<QVariant> &args) |
|
115 |
{ |
|
116 |
// Return nothing if dependencies are not met |
|
117 |
||
118 |
switch (c) { |
|
119 |
case MediaObjectClass: |
|
120 |
return new MediaObject(this, parent); |
|
121 |
||
122 |
case AudioOutputClass: { |
|
123 |
AudioOutput *ao = new AudioOutput(this, parent); |
|
124 |
m_audioOutputs.append(ao); |
|
125 |
return ao; |
|
126 |
} |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
127 |
#ifndef QT_NO_PHONON_EFFECT |
0 | 128 |
case EffectClass: |
129 |
return new AudioEffect(this, args[0].toInt(), parent); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
130 |
#endif //QT_NO_PHONON_EFFECT |
0 | 131 |
case AudioDataOutputClass: |
132 |
logMessage("createObject() : AudioDataOutput not implemented"); |
|
133 |
break; |
|
134 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
135 |
#ifndef QT_NO_PHONON_VIDEO |
0 | 136 |
case VideoDataOutputClass: |
137 |
logMessage("createObject() : VideoDataOutput not implemented"); |
|
138 |
break; |
|
139 |
||
140 |
case VideoWidgetClass: { |
|
141 |
QWidget *widget = qobject_cast<QWidget*>(parent); |
|
142 |
return new VideoWidget(this, widget); |
|
143 |
} |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
144 |
#endif //QT_NO_PHONON_VIDEO |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
145 |
#ifndef QT_NO_PHONON_VOLUMEFADEREFFECT |
0 | 146 |
case VolumeFaderEffectClass: |
147 |
return new VolumeFaderEffect(this, parent); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
148 |
#endif //QT_NO_PHONON_VOLUMEFADEREFFECT |
0 | 149 |
|
150 |
case VisualizationClass: //Fall through |
|
151 |
default: |
|
152 |
logMessage("createObject() : Backend object not available"); |
|
153 |
} |
|
154 |
return 0; |
|
155 |
} |
|
156 |
||
157 |
// Returns true if all dependencies are met |
|
158 |
// and gstreamer is usable, otherwise false |
|
159 |
bool Backend::isValid() const |
|
160 |
{ |
|
161 |
return m_isValid; |
|
162 |
} |
|
163 |
||
164 |
bool Backend::supportsVideo() const |
|
165 |
{ |
|
166 |
return isValid(); |
|
167 |
} |
|
168 |
||
169 |
bool Backend::checkDependencies() const |
|
170 |
{ |
|
171 |
bool success = false; |
|
172 |
// Verify that gst-plugins-base is installed |
|
173 |
GstElementFactory *acFactory = gst_element_factory_find ("audioconvert"); |
|
174 |
if (acFactory) { |
|
175 |
gst_object_unref(acFactory); |
|
176 |
success = true; |
|
177 |
// Check if gst-plugins-good is installed |
|
178 |
GstElementFactory *csFactory = gst_element_factory_find ("videobalance"); |
|
179 |
if (csFactory) { |
|
180 |
gst_object_unref(csFactory); |
|
181 |
} else { |
|
182 |
QString message = tr("Warning: You do not seem to have the package gstreamer0.10-plugins-good installed.\n" |
|
183 |
" Some video features have been disabled."); |
|
184 |
qDebug() << message; |
|
185 |
} |
|
186 |
} else { |
|
187 |
qWarning() << tr("Warning: You do not seem to have the base GStreamer plugins installed.\n" |
|
188 |
" All audio and video support has been disabled"); |
|
189 |
} |
|
190 |
return success; |
|
191 |
} |
|
192 |
||
193 |
/*** |
|
194 |
* !reimp |
|
195 |
*/ |
|
196 |
QStringList Backend::availableMimeTypes() const |
|
197 |
{ |
|
198 |
QStringList availableMimeTypes; |
|
199 |
||
200 |
if (!isValid()) |
|
201 |
return availableMimeTypes; |
|
202 |
||
203 |
GstElementFactory *mpegFactory; |
|
204 |
// Add mp3 as a separate mime type as people are likely to look for it. |
|
205 |
if ((mpegFactory = gst_element_factory_find ("ffmpeg")) || |
|
206 |
(mpegFactory = gst_element_factory_find ("mad"))) { |
|
207 |
availableMimeTypes << QLatin1String("audio/x-mp3"); |
|
208 |
gst_object_unref(GST_OBJECT(mpegFactory)); |
|
209 |
} |
|
210 |
||
211 |
// Iterate over all audio and video decoders and extract mime types from sink caps |
|
212 |
GList* factoryList = gst_registry_get_feature_list(gst_registry_get_default (), GST_TYPE_ELEMENT_FACTORY); |
|
213 |
for (GList* iter = g_list_first(factoryList) ; iter != NULL ; iter = g_list_next(iter)) { |
|
214 |
GstPluginFeature *feature = GST_PLUGIN_FEATURE(iter->data); |
|
215 |
QString klass = gst_element_factory_get_klass(GST_ELEMENT_FACTORY(feature)); |
|
216 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
217 |
if (klass == QLatin1String("Codec/Decoder") || |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
218 |
klass == QLatin1String("Codec/Decoder/Audio") || |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
219 |
klass == QLatin1String("Codec/Decoder/Video") || |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
220 |
klass == QLatin1String("Codec/Demuxer") || |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
221 |
klass == QLatin1String("Codec/Demuxer/Audio") || |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
222 |
klass == QLatin1String("Codec/Demuxer/Video") || |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
223 |
klass == QLatin1String("Codec/Parser") || |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
224 |
klass == QLatin1String("Codec/Parser/Audio") || |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
225 |
klass == QLatin1String("Codec/Parser/Video")) { |
0 | 226 |
|
227 |
const GList *static_templates; |
|
228 |
GstElementFactory *factory = GST_ELEMENT_FACTORY(feature); |
|
229 |
static_templates = gst_element_factory_get_static_pad_templates(factory); |
|
230 |
||
231 |
for (; static_templates != NULL ; static_templates = static_templates->next) { |
|
232 |
GstStaticPadTemplate *padTemplate = (GstStaticPadTemplate *) static_templates->data; |
|
233 |
if (padTemplate && padTemplate->direction == GST_PAD_SINK) { |
|
234 |
GstCaps *caps = gst_static_pad_template_get_caps (padTemplate); |
|
235 |
||
236 |
if (caps) { |
|
237 |
const GstStructure* capsStruct = gst_caps_get_structure (caps, 0); |
|
238 |
QString mime = QString::fromUtf8(gst_structure_get_name (capsStruct)); |
|
239 |
if (!availableMimeTypes.contains(mime)) |
|
240 |
availableMimeTypes.append(mime); |
|
241 |
} |
|
242 |
} |
|
243 |
} |
|
244 |
} |
|
245 |
} |
|
246 |
g_list_free(factoryList); |
|
247 |
availableMimeTypes.sort(); |
|
248 |
return availableMimeTypes; |
|
249 |
} |
|
250 |
||
251 |
/*** |
|
252 |
* !reimp |
|
253 |
*/ |
|
254 |
QList<int> Backend::objectDescriptionIndexes(ObjectDescriptionType type) const |
|
255 |
{ |
|
256 |
QList<int> list; |
|
257 |
||
258 |
if (!isValid()) |
|
259 |
return list; |
|
260 |
||
261 |
switch (type) { |
|
262 |
case Phonon::AudioOutputDeviceType: { |
|
263 |
QList<AudioDevice> deviceList = deviceManager()->audioOutputDevices(); |
|
264 |
for (int dev = 0 ; dev < deviceList.size() ; ++dev) |
|
265 |
list.append(deviceList[dev].id); |
|
266 |
break; |
|
267 |
} |
|
268 |
break; |
|
269 |
||
270 |
case Phonon::EffectType: { |
|
271 |
QList<EffectInfo*> effectList = effectManager()->audioEffects(); |
|
272 |
for (int eff = 0 ; eff < effectList.size() ; ++eff) |
|
273 |
list.append(eff); |
|
274 |
break; |
|
275 |
} |
|
276 |
break; |
|
277 |
default: |
|
278 |
break; |
|
279 |
} |
|
280 |
return list; |
|
281 |
} |
|
282 |
||
283 |
/*** |
|
284 |
* !reimp |
|
285 |
*/ |
|
286 |
QHash<QByteArray, QVariant> Backend::objectDescriptionProperties(ObjectDescriptionType type, int index) const |
|
287 |
{ |
|
288 |
||
289 |
QHash<QByteArray, QVariant> ret; |
|
290 |
||
291 |
if (!isValid()) |
|
292 |
return ret; |
|
293 |
||
294 |
switch (type) { |
|
295 |
case Phonon::AudioOutputDeviceType: { |
|
296 |
QList<AudioDevice> audioDevices = deviceManager()->audioOutputDevices(); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
297 |
foreach(const AudioDevice &device, audioDevices) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
298 |
if (device.id == index) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
299 |
ret.insert("name", device.gstId); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
300 |
ret.insert("description", device.description); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
301 |
ret.insert("icon", QLatin1String("audio-card")); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
302 |
break; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
303 |
} |
0 | 304 |
} |
305 |
} |
|
306 |
break; |
|
307 |
||
308 |
case Phonon::EffectType: { |
|
309 |
QList<EffectInfo*> effectList = effectManager()->audioEffects(); |
|
310 |
if (index >= 0 && index <= effectList.size()) { |
|
311 |
const EffectInfo *effect = effectList[index]; |
|
312 |
ret.insert("name", effect->name()); |
|
313 |
ret.insert("description", effect->description()); |
|
314 |
ret.insert("author", effect->author()); |
|
315 |
} else |
|
316 |
Q_ASSERT(1); // Since we use list position as ID, this should not happen |
|
317 |
} |
|
318 |
default: |
|
319 |
break; |
|
320 |
} |
|
321 |
return ret; |
|
322 |
} |
|
323 |
||
324 |
/*** |
|
325 |
* !reimp |
|
326 |
*/ |
|
327 |
bool Backend::startConnectionChange(QSet<QObject *> objects) |
|
328 |
{ |
|
329 |
foreach (QObject *object, objects) { |
|
330 |
MediaNode *sourceNode = qobject_cast<MediaNode *>(object); |
|
331 |
MediaObject *media = sourceNode->root(); |
|
332 |
if (media) { |
|
333 |
media->saveState(); |
|
334 |
return true; |
|
335 |
} |
|
336 |
} |
|
337 |
return true; |
|
338 |
} |
|
339 |
||
340 |
/*** |
|
341 |
* !reimp |
|
342 |
*/ |
|
343 |
bool Backend::connectNodes(QObject *source, QObject *sink) |
|
344 |
{ |
|
345 |
if (isValid()) { |
|
346 |
MediaNode *sourceNode = qobject_cast<MediaNode *>(source); |
|
347 |
MediaNode *sinkNode = qobject_cast<MediaNode *>(sink); |
|
348 |
if (sourceNode && sinkNode) { |
|
349 |
if (sourceNode->connectNode(sink)) { |
|
350 |
sourceNode->root()->invalidateGraph(); |
|
351 |
logMessage(QString("Backend connected %0 to %1").arg(source->metaObject()->className()).arg(sink->metaObject()->className())); |
|
352 |
return true; |
|
353 |
} |
|
354 |
} |
|
355 |
} |
|
356 |
logMessage(QString("Linking %0 to %1 failed").arg(source->metaObject()->className()).arg(sink->metaObject()->className()), Warning); |
|
357 |
return false; |
|
358 |
} |
|
359 |
||
360 |
/*** |
|
361 |
* !reimp |
|
362 |
*/ |
|
363 |
bool Backend::disconnectNodes(QObject *source, QObject *sink) |
|
364 |
{ |
|
365 |
MediaNode *sourceNode = qobject_cast<MediaNode *>(source); |
|
366 |
MediaNode *sinkNode = qobject_cast<MediaNode *>(sink); |
|
367 |
||
368 |
if (sourceNode && sinkNode) |
|
369 |
return sourceNode->disconnectNode(sink); |
|
370 |
else |
|
371 |
return false; |
|
372 |
} |
|
373 |
||
374 |
/*** |
|
375 |
* !reimp |
|
376 |
*/ |
|
377 |
bool Backend::endConnectionChange(QSet<QObject *> objects) |
|
378 |
{ |
|
379 |
foreach (QObject *object, objects) { |
|
380 |
MediaNode *sourceNode = qobject_cast<MediaNode *>(object); |
|
381 |
MediaObject *media = sourceNode->root(); |
|
382 |
if (media) { |
|
383 |
media->resumeState(); |
|
384 |
return true; |
|
385 |
} |
|
386 |
} |
|
387 |
return true; |
|
388 |
} |
|
389 |
||
390 |
/*** |
|
391 |
* Request bus messages for this mediaobject |
|
392 |
*/ |
|
393 |
void Backend::addBusWatcher(MediaObject* node) |
|
394 |
{ |
|
395 |
Q_ASSERT(node); |
|
396 |
GstBus *bus = gst_pipeline_get_bus (GST_PIPELINE(node->pipeline())); |
|
397 |
gst_bus_add_watch (bus, busCall, node); |
|
398 |
gst_object_unref(bus); |
|
399 |
} |
|
400 |
||
401 |
/*** |
|
402 |
* Ignore bus messages for this mediaobject |
|
403 |
*/ |
|
404 |
void Backend::removeBusWatcher(MediaObject* node) |
|
405 |
{ |
|
406 |
Q_ASSERT(node); |
|
407 |
g_source_remove_by_user_data(node); |
|
408 |
} |
|
409 |
||
410 |
/*** |
|
411 |
* Polls each mediaobject's pipeline and delivers |
|
412 |
* pending any pending messages |
|
413 |
*/ |
|
414 |
void Backend::handleBusMessage(Message message) |
|
415 |
{ |
|
416 |
MediaObject *mediaObject = message.source(); |
|
417 |
mediaObject->handleBusMessage(message); |
|
418 |
} |
|
419 |
||
420 |
DeviceManager* Backend::deviceManager() const |
|
421 |
{ |
|
422 |
return m_deviceManager; |
|
423 |
} |
|
424 |
||
425 |
EffectManager* Backend::effectManager() const |
|
426 |
{ |
|
427 |
return m_effectManager; |
|
428 |
} |
|
429 |
||
430 |
/** |
|
431 |
* Returns a debuglevel that is determined by the |
|
432 |
* PHONON_GSTREAMER_DEBUG environment variable. |
|
433 |
* |
|
434 |
* Warning - important warnings |
|
435 |
* Info - general info |
|
436 |
* Debug - gives extra info |
|
437 |
*/ |
|
438 |
Backend::DebugLevel Backend::debugLevel() const |
|
439 |
{ |
|
440 |
return m_debugLevel; |
|
441 |
} |
|
442 |
||
443 |
/*** |
|
444 |
* Prints a conditional debug message based on the current debug level |
|
445 |
* If obj is provided, classname and objectname will be printed as well |
|
446 |
* |
|
447 |
* see debugLevel() |
|
448 |
*/ |
|
449 |
void Backend::logMessage(const QString &message, int priority, QObject *obj) const |
|
450 |
{ |
|
451 |
if (debugLevel() > 0) { |
|
452 |
QString output; |
|
453 |
if (obj) { |
|
454 |
// Strip away namespace from className |
|
455 |
QString className(obj->metaObject()->className()); |
|
456 |
int nameLength = className.length() - className.lastIndexOf(':') - 1; |
|
457 |
className = className.right(nameLength); |
|
458 |
output.sprintf("%s %s (%s %p)", message.toLatin1().constData(), |
|
459 |
obj->objectName().toLatin1().constData(), |
|
460 |
className.toLatin1().constData(), obj); |
|
461 |
} |
|
462 |
else { |
|
463 |
output = message; |
|
464 |
} |
|
465 |
if (priority <= (int)debugLevel()) { |
|
466 |
qDebug() << QString("PGST(%1): %2").arg(priority).arg(output); |
|
467 |
} |
|
468 |
} |
|
469 |
} |
|
470 |
||
471 |
} |
|
472 |
} |
|
473 |
||
474 |
QT_END_NAMESPACE |
|
475 |
||
476 |
#include "moc_backend.cpp" |