1 /*****************************************************************************
2 * VLC backend for the Phonon library *
3 * Copyright (C) 2007-2008 Tanguy Krotoff <tkrotoff@gmail.com> *
4 * Copyright (C) 2008 Lukas Durfina <lukas.durfina@gmail.com> *
5 * Copyright (C) 2009 Fathi Boudra <fabo@kde.org> *
7 * This program is free software; you can redistribute it and/or *
8 * modify it under the terms of the GNU Lesser General Public *
9 * License as published by the Free Software Foundation; either *
10 * version 3 of the License, or (at your option) any later version. *
12 * This program is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
15 * Lesser General Public License for more details. *
17 * You should have received a copy of the GNU Lesser General Public *
18 * License along with this package; if not, write to the Free Software *
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
20 *****************************************************************************/
24 #include "effectmanager.h"
26 #include "mediaobject.h"
32 Effect::Effect(EffectManager *p_em, int i_effectId, QObject *p_parent)
35 p_effectManager = p_em;
36 QList<EffectInfo *> effects = p_effectManager->effects();
38 if (i_effectId >= 0 && i_effectId < effects.size()) {
39 i_effect_filter = effects[ i_effectId ]->filter();
40 effect_type = effects[ i_effectId ]->type();
43 // effect ID out of range
50 parameterList.clear();
53 void Effect::connectToMediaObject(PrivateMediaObject *p_media_object)
55 SinkNode::connectToMediaObject(p_media_object);
57 switch (effect_type) {
58 case EffectInfo::AudioEffect:
59 // libvlc_audio_filter_add(p_vlc_instance, (libvlc_audio_filter_names_t)i_effect_filter, vlc_exception);
60 // vlcExceptionRaised();
62 case EffectInfo::VideoEffect:
63 // libvlc_video_filter_add(p_vlc_current_media_player, (libvlc_video_filter_names_t)i_effect_filter, vlc_exception);
64 // vlcExceptionRaised();
69 void Effect::disconnectFromMediaObject(PrivateMediaObject *p_media_object)
71 SinkNode::disconnectFromMediaObject(p_media_object);
73 switch (effect_type) {
74 case EffectInfo::AudioEffect:
75 // libvlc_audio_filter_remove(p_vlc_instance, (libvlc_audio_filter_names_t)i_effect_filter, vlc_exception);
76 // vlcExceptionRaised();
78 case EffectInfo::VideoEffect:
79 // libvlc_video_filter_remove(p_vlc_current_media_player, (libvlc_video_filter_names_t)i_effect_filter, vlc_exception);
80 // vlcExceptionRaised();
85 void Effect::setupEffectParams()
87 // libvlc_filter_parameter_list_t *p_list;
88 switch (effect_type) {
89 case EffectInfo::AudioEffect:
90 // p_list = libvlc_audio_filter_get_parameters(p_vlc_instance, (libvlc_audio_filter_names_t)i_effect_filter, vlc_exception );
91 // vlcExceptionRaised();
93 case EffectInfo::VideoEffect:
94 // p_list = libvlc_video_filter_get_parameters(p_vlc_instance, (libvlc_video_filter_names_t)i_effect_filter, vlc_exception );
95 // vlcExceptionRaised();
102 // libvlc_filter_parameter_list_t *p_parameter_list = p_list;
103 // while (p_parameter_list) {
104 // switch (p_parameter_list->var_type) {
105 // case LIBVLC_BOOL: {
106 // const QString description = p_parameter_list->psz_description;
107 // parameterList.append(Phonon::EffectParameter(
109 // QString(p_parameter_list->psz_parameter_name),
110 // Phonon::EffectParameter::ToggledHint, // hints
111 // QVariant((bool) p_parameter_list->default_value.b_bool),
112 // QVariant((bool) false),
113 // QVariant((bool) true),
118 // case LIBVLC_INT: {
119 // const QString description = p_parameter_list->psz_description;
120 // parameterList.append(Phonon::EffectParameter(
122 // QString(p_parameter_list->psz_parameter_name),
123 // EffectParameter::IntegerHint, // hints
124 // QVariant((int) p_parameter_list->default_value.i_int),
125 // QVariant((int) p_parameter_list->min_value.i_int),
126 // QVariant((int) p_parameter_list->max_value.i_int),
131 // case LIBVLC_FLOAT: {
132 // const QString description = p_parameter_list->psz_description;
133 // parameterList.append(Phonon::EffectParameter(
135 // QString(p_parameter_list->psz_parameter_name),
137 // QVariant((double) p_parameter_list->default_value.f_float),
138 // QVariant((double) p_parameter_list->min_value.f_float),
139 // QVariant((double) p_parameter_list->max_value.f_float),
144 // case LIBVLC_STRING: {
145 // const QString description = p_parameter_list->psz_description;
146 // parameterList.append(Phonon::EffectParameter(
148 // QString(p_parameter_list->psz_parameter_name),
150 // QVariant((const char *) p_parameter_list->default_value.psz_string),
159 // p_parameter_list = p_parameter_list->p_next;
161 // libvlc_filter_parameters_release(p_list);
164 QList<EffectParameter> Effect::parameters() const
166 return parameterList;
169 QVariant Effect::parameterValue(const EffectParameter & param) const
174 void Effect::setParameterValue(const EffectParameter & param, const QVariant & newValue)
176 // libvlc_value_t value;
177 // libvlc_var_type_t type;
178 // switch (param.type()) {
179 // case QVariant::Bool:
180 // value.b_bool = newValue.toBool();
181 // type = LIBVLC_BOOL;
183 // case QVariant::Int:
184 // value.i_int = newValue.toInt();
185 // type = LIBVLC_INT;
187 // case QVariant::Double:
188 // value.f_float = (float) newValue.toDouble();
189 // type = LIBVLC_FLOAT;
191 // case QVariant::String:
192 // value.psz_string = newValue.toString().toAscii().data();
193 // type = LIBVLC_STRING;
198 // switch (effect_type) {
199 // case EffectInfo::AudioEffect:
200 // libvlc_audio_filter_set_parameter(
202 // // (libvlc_audio_filter_names_t) i_effect_filter,
203 // param.name().toAscii().data(),
207 // vlcExceptionRaised();
209 // case EffectInfo::VideoEffect:
210 // libvlc_video_filter_set_parameter(
211 // p_vlc_current_media_player,
212 // (libvlc_video_filter_names_t) i_effect_filter,
213 // param.name().toAscii().data(),
217 // vlcExceptionRaised();
223 } // Namespace Phonon::VLC