1/*
2 Copyright (C) 2007-2008 Tanguy Krotoff <tkrotoff@gmail.com>
3 Copyright (C) 2008 Lukas Durfina <lukas.durfina@gmail.com>
4 Copyright (C) 2009 Fathi Boudra <fabo@kde.org>
5 Copyright (C) 2009-2011 vlc-phonon AUTHORS <kde-multimedia@kde.org>
6 Copyright (C) 2011 Harald Sitter <sitter@kde.org>
7
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Lesser General Public
10 License as published by the Free Software Foundation; either
11 version 2.1 of the License, or (at your option) any later version.
12
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public
19 License along with this library. If not, see <http://www.gnu.org/licenses/>.
20*/
21
22#include "effectmanager.h"
23
24#include <vlc/vlc.h>
25#include <vlc/libvlc_version.h>
26
27#include "equalizereffect.h"
28
29#include "utils/debug.h"
30#include "utils/libvlc.h"
31
32namespace Phonon {
33namespace VLC {
34
35EffectInfo::EffectInfo(const QString &name, const QString &description,
36 const QString &author, int filter, Type type)
37 : m_name(name)
38 , m_description(description)
39 , m_author(author)
40 , m_filter(filter)
41 , m_type(type)
42{}
43
44EffectManager::EffectManager(QObject *parent)
45 : QObject(parent)
46{
47 if (!pvlc_libvlc)
48 return;
49
50 updateEffects();
51}
52
53EffectManager::~EffectManager()
54{
55 m_audioEffectList.clear();
56 m_videoEffectList.clear();
57
58 // EffectsList holds the same pointers as audio and video, so qDeleteAll on
59 // this container would cause a double freeing.
60 m_effectList.clear();
61}
62
63const QList<EffectInfo> EffectManager::audioEffects() const
64{
65 return m_audioEffectList;
66}
67
68const QList<EffectInfo> EffectManager::videoEffects() const
69{
70 return m_videoEffectList;
71}
72
73const QList<EffectInfo> EffectManager::effects() const
74{
75 return m_effectList;
76}
77
78QObject *EffectManager::createEffect(int id, QObject *parent)
79{
80 Q_UNUSED(id);
81 return new EqualizerEffect(parent);
82}
83
84void EffectManager::updateEffects()
85{
86 DEBUG_BLOCK;
87
88 m_effectList.clear();
89 m_audioEffectList.clear();
90 m_videoEffectList.clear();
91
92 // Generic effect activation etc is entirely kaput and equalizer has specific
93 // API anyway, so we simply manually insert it \o/
94
95 const QString eqName = QString("equalizer-%1bands").arg(a: QString::number(libvlc_audio_equalizer_get_band_count()));
96 m_audioEffectList.append(t: EffectInfo(
97 eqName,
98 QString(""),
99 QString(""),
100 0,
101 EffectInfo::AudioEffect));
102
103// int moduleCount = -1;
104// VLC_FOREACH_MODULE(module, libvlc_audio_filter_list_get(libvlc)) {
105// m_audioEffectList.append(new EffectInfo(module->psz_longname,
106// module->psz_help,
107// QString(),
108// ++moduleCount,
109// EffectInfo::AudioEffect));
110// }
111
112// moduleCount = -1;
113// VLC_FOREACH_MODULE(module, libvlc_video_filter_list_get(libvlc)) {
114// m_videoEffectList.append(new EffectInfo(module->psz_longname,
115// module->psz_help,
116// QString(),
117// ++moduleCount,
118// EffectInfo::VideoEffect));
119// }
120
121 m_effectList.append(l: m_audioEffectList);
122 m_effectList.append(l: m_videoEffectList);
123}
124
125} // namespace VLC
126} // namespace Phonon
127

source code of phonon-vlc/src/effectmanager.cpp