| 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 <gst/interfaces/propertyprobe.h> |
| 19 |
#include "effectmanager.h" |
| 20 |
#include "backend.h" |
| 21 |
#include "gsthelper.h" |
| 22 |
|
| 23 |
/* |
| 24 |
* This class manages the list of currently |
| 25 |
* available audio effects. |
| 26 |
*/ |
| 27 |
|
| 28 |
QT_BEGIN_NAMESPACE |
| 29 |
|
| 30 |
namespace Phonon |
| 31 |
{ |
| 32 |
namespace Gstreamer |
| 33 |
{ |
| 34 |
|
| 35 |
EffectInfo::EffectInfo(const QString &name, const QString&description, const QString&author) |
| 36 |
: m_name(name) |
| 37 |
, m_description(description) |
| 38 |
, m_author(author) {} |
| 39 |
|
| 40 |
EffectManager::EffectManager(Backend *backend) |
| 41 |
: QObject(backend) |
| 42 |
, m_backend(backend) |
| 43 |
{ |
| 44 |
GList* factoryList = gst_registry_get_feature_list(gst_registry_get_default (), GST_TYPE_ELEMENT_FACTORY); |
| 45 |
QString name, klass, description, author; |
| 46 |
for (GList* iter = g_list_first(factoryList) ; iter != NULL ; iter = g_list_next(iter)) { |
| 47 |
GstPluginFeature *feature = GST_PLUGIN_FEATURE(iter->data); |
| 48 |
klass = gst_element_factory_get_klass(GST_ELEMENT_FACTORY(feature)); |
| 49 |
if ( klass == "Filter/Effect/Audio" ) { |
| 50 |
name = GST_PLUGIN_FEATURE_NAME(feature); |
| 51 |
|
| 52 |
// These plugins simply make no sense to the frontend: |
| 53 |
// "audiorate" Should be internal |
| 54 |
// "volume" not needed |
| 55 |
// "equalizer-nbands" not really useful at the moment |
| 56 |
|
| 57 |
// These plugins simply don't work or have major stability issues: |
| 58 |
// "iir" Does not seem to do much at the moment |
| 59 |
// "audioinvert" Only works for some streams, should be invesigated |
| 60 |
// "lpwsinc" Crashes for large values of filter kernel |
| 61 |
// "name" Crashes for large values of filter kernel |
| 62 |
|
| 63 |
// Seems to be working, but not well tested: |
| 64 |
// name == "rglimiter" Seems functional |
| 65 |
// name == "rgvolume" Seems to be working |
| 66 |
|
| 67 |
QString pluginString = qgetenv("PHONON_GST_ALL_EFFECTS"); |
| 68 |
bool acceptAll = pluginString.toInt(); |
| 69 |
|
| 70 |
if (acceptAll |
| 71 |
// Plugins that have been accepted so far |
| 72 |
|| name == "audiopanorama" |
| 73 |
|| name == "audioamplify" |
| 74 |
|| name == "audiodynamic" |
| 75 |
|| name == "equalizer-10bands" |
| 76 |
|| name == "speed") |
| 77 |
{ |
| 78 |
description = gst_element_factory_get_description (GST_ELEMENT_FACTORY(feature)); |
| 79 |
author = gst_element_factory_get_author (GST_ELEMENT_FACTORY(feature)); |
| 80 |
EffectInfo *effect = new EffectInfo(name, description, author); |
| 81 |
m_audioEffectList.append(effect); |
| 82 |
} |
| 83 |
} |
| 84 |
} |
| 85 |
g_list_free(factoryList); |
| 86 |
} |
| 87 |
|
| 88 |
EffectManager::~EffectManager() |
| 89 |
{ |
| 90 |
qDeleteAll(m_audioEffectList); |
| 91 |
m_audioEffectList.clear(); |
| 92 |
} |
| 93 |
|
| 94 |
/** |
| 95 |
* Returns a list of available audio effects |
| 96 |
*/ |
| 97 |
const QList<EffectInfo*> EffectManager::audioEffects() const |
| 98 |
{ |
| 99 |
return m_audioEffectList; |
| 100 |
} |
| 101 |
|
| 102 |
} |
| 103 |
} |
| 104 |
|
| 105 |
QT_END_NAMESPACE |