]> git.sesse.net Git - vlc/blob - bindings/phonon/vlc/effect.cpp
Add some locking.
[vlc] / bindings / phonon / vlc / effect.cpp
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>                            *
6  *                                                                           *
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.          *
11  *                                                                           *
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.                           *
16  *                                                                           *
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  *****************************************************************************/
21
22 #include "effect.h"
23
24 #include "effectmanager.h"
25
26 #include "mediaobject.h"
27
28 namespace Phonon
29 {
30 namespace VLC {
31
32 Effect::Effect(EffectManager *p_em, int i_effectId, QObject *p_parent)
33         : SinkNode(p_parent)
34 {
35     p_effectManager = p_em;
36     QList<EffectInfo *> effects = p_effectManager->effects();
37
38     if (i_effectId >= 0 && i_effectId < effects.size()) {
39         i_effect_filter = effects[ i_effectId ]->filter();
40         effect_type = effects[ i_effectId ]->type();
41         setupEffectParams();
42     } else {
43         // effect ID out of range
44         Q_ASSERT(0);
45     }
46 }
47
48 Effect::~Effect()
49 {
50     parameterList.clear();
51 }
52
53 void Effect::connectToMediaObject(PrivateMediaObject *p_media_object)
54 {
55     SinkNode::connectToMediaObject(p_media_object);
56
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();
61         break;
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();
65         break;
66     }
67 }
68
69 void Effect::disconnectFromMediaObject(PrivateMediaObject *p_media_object)
70 {
71     SinkNode::disconnectFromMediaObject(p_media_object);
72
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();
77         break;
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();
81         break;
82     }
83 }
84
85 void Effect::setupEffectParams()
86 {
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();
92         break;
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();
96         break;
97     }
98 //    if( !p_list )
99 //        return;
100
101     int i_index = 0;
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(
108 //                                     i_index,
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),
114 //                                     QVariantList(),
115 //                                     description));
116 //            break;
117 //        }
118 //        case LIBVLC_INT: {
119 //            const QString description = p_parameter_list->psz_description;
120 //            parameterList.append(Phonon::EffectParameter(
121 //                                     i_index,
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),
127 //                                     QVariantList(),
128 //                                     description));
129 //            break;
130 //        }
131 //        case LIBVLC_FLOAT: {
132 //            const QString description = p_parameter_list->psz_description;
133 //            parameterList.append(Phonon::EffectParameter(
134 //                                     i_index,
135 //                                     QString(p_parameter_list->psz_parameter_name),
136 //                                     0,   // hints
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),
140 //                                     QVariantList(),
141 //                                     description));
142 //            break;
143 //        }
144 //        case LIBVLC_STRING: {
145 //            const QString description = p_parameter_list->psz_description;
146 //            parameterList.append(Phonon::EffectParameter(
147 //                                     i_index,
148 //                                     QString(p_parameter_list->psz_parameter_name),
149 //                                     0,   // hints
150 //                                     QVariant((const char *) p_parameter_list->default_value.psz_string),
151 //                                     NULL,
152 //                                     NULL,
153 //                                     QVariantList(),
154 //                                     description));
155 //            break;
156 //        }
157 //        }
158 //        i_index++;
159 //        p_parameter_list = p_parameter_list->p_next;
160 //    }
161 //    libvlc_filter_parameters_release(p_list);
162 }
163
164 QList<EffectParameter> Effect::parameters() const
165 {
166     return parameterList;
167 }
168
169 QVariant Effect::parameterValue(const EffectParameter & param) const
170 {
171     return QVariant();
172 }
173
174 void Effect::setParameterValue(const EffectParameter & param, const QVariant & newValue)
175 {
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;
182 //        break;
183 //    case QVariant::Int:
184 //        value.i_int = newValue.toInt();
185 //        type = LIBVLC_INT;
186 //        break;
187 //    case QVariant::Double:
188 //        value.f_float = (float) newValue.toDouble();
189 //        type = LIBVLC_FLOAT;
190 //        break;
191 //    case QVariant::String:
192 //        value.psz_string = newValue.toString().toAscii().data();
193 //        type = LIBVLC_STRING;
194 //        break;
195 //    default:
196 //        break;
197 //    }
198 //    switch (effect_type) {
199 //    case EffectInfo::AudioEffect:
200 //        libvlc_audio_filter_set_parameter(
201 //            p_vlc_instance,
202 //            // (libvlc_audio_filter_names_t) i_effect_filter,
203 //            param.name().toAscii().data(),
204 //            type,
205 //            value,
206 //            vlc_exception);
207 //        vlcExceptionRaised();
208 //        break;
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(),
214 //            type,
215 //            value,
216 //            vlc_exception);
217 //        vlcExceptionRaised();
218 //        break;
219 //    }
220 }
221
222 }
223 } // Namespace Phonon::VLC