| 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 | |
| 7 | This library 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 2.1 of the License, or (at your option) any later version. |
| 11 | |
| 12 | This library 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 library. If not, see <http://www.gnu.org/licenses/>. |
| 19 | */ |
| 20 | |
| 21 | #include "effect.h" |
| 22 | |
| 23 | #include "effectmanager.h" |
| 24 | |
| 25 | #include "mediaobject.h" |
| 26 | |
| 27 | namespace Phonon |
| 28 | { |
| 29 | namespace VLC |
| 30 | { |
| 31 | |
| 32 | Effect::Effect(EffectManager *p_em, int i_effectId, QObject *p_parent) |
| 33 | : QObject(p_parent) |
| 34 | , SinkNode() |
| 35 | { |
| 36 | Q_UNUSED(p_em); |
| 37 | Q_UNUSED(i_effectId); |
| 38 | // p_effectManager = p_em; |
| 39 | // const QList<EffectInfo> effects = p_effectManager->effects(); |
| 40 | |
| 41 | // if (i_effectId >= 0 && i_effectId < effects.size()) { |
| 42 | // i_effect_filter = effects[ i_effectId ]->filter(); |
| 43 | // effect_type = effects[ i_effectId ]->type(); |
| 44 | // setupEffectParams(); |
| 45 | // } else { |
| 46 | // // effect ID out of range |
| 47 | // Q_ASSERT(0); |
| 48 | // } |
| 49 | } |
| 50 | |
| 51 | Effect::~Effect() |
| 52 | { |
| 53 | parameterList.clear(); |
| 54 | } |
| 55 | |
| 56 | void Effect::handleConnectToMediaObject(MediaObject *) |
| 57 | { |
| 58 | switch (effect_type) { |
| 59 | case EffectInfo::AudioEffect: |
| 60 | // libvlc_audio_filter_add(p_vlc_instance, (libvlc_audio_filter_names_t)i_effect_filter, vlc_exception); |
| 61 | // vlcExceptionRaised(); |
| 62 | break; |
| 63 | case EffectInfo::VideoEffect: |
| 64 | // libvlc_video_filter_add(p_vlc_current_media_player, (libvlc_video_filter_names_t)i_effect_filter, vlc_exception); |
| 65 | // vlcExceptionRaised(); |
| 66 | break; |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | void Effect::handleDisconnectFromMediaObject(MediaObject *) |
| 71 | { |
| 72 | switch (effect_type) { |
| 73 | case EffectInfo::AudioEffect: |
| 74 | // libvlc_audio_filter_remove(p_vlc_instance, (libvlc_audio_filter_names_t)i_effect_filter, vlc_exception); |
| 75 | // vlcExceptionRaised(); |
| 76 | break; |
| 77 | case EffectInfo::VideoEffect: |
| 78 | // libvlc_video_filter_remove(p_vlc_current_media_player, (libvlc_video_filter_names_t)i_effect_filter, vlc_exception); |
| 79 | // vlcExceptionRaised(); |
| 80 | break; |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | void Effect::setupEffectParams() |
| 85 | { |
| 86 | // libvlc_filter_parameter_list_t *p_list; |
| 87 | switch (effect_type) { |
| 88 | case EffectInfo::AudioEffect: |
| 89 | // p_list = libvlc_audio_filter_get_parameters(p_vlc_instance, (libvlc_audio_filter_names_t)i_effect_filter, vlc_exception ); |
| 90 | // vlcExceptionRaised(); |
| 91 | break; |
| 92 | case EffectInfo::VideoEffect: |
| 93 | // p_list = libvlc_video_filter_get_parameters(p_vlc_instance, (libvlc_video_filter_names_t)i_effect_filter, vlc_exception ); |
| 94 | // vlcExceptionRaised(); |
| 95 | break; |
| 96 | } |
| 97 | // if( !p_list ) |
| 98 | // return; |
| 99 | |
| 100 | // int i_index = 0; |
| 101 | // libvlc_filter_parameter_list_t *p_parameter_list = p_list; |
| 102 | // while (p_parameter_list) { |
| 103 | // switch (p_parameter_list->var_type) { |
| 104 | // case LIBVLC_BOOL: { |
| 105 | // const QString description = p_parameter_list->psz_description; |
| 106 | // parameterList.append(Phonon::EffectParameter( |
| 107 | // i_index, |
| 108 | // QString(p_parameter_list->psz_parameter_name), |
| 109 | // Phonon::EffectParameter::ToggledHint, // hints |
| 110 | // QVariant((bool) p_parameter_list->default_value.b_bool), |
| 111 | // QVariant((bool) false), |
| 112 | // QVariant((bool) true), |
| 113 | // QVariantList(), |
| 114 | // description)); |
| 115 | // break; |
| 116 | // } |
| 117 | // case LIBVLC_INT: { |
| 118 | // const QString description = p_parameter_list->psz_description; |
| 119 | // parameterList.append(Phonon::EffectParameter( |
| 120 | // i_index, |
| 121 | // QString(p_parameter_list->psz_parameter_name), |
| 122 | // EffectParameter::IntegerHint, // hints |
| 123 | // QVariant((int) p_parameter_list->default_value.i_int), |
| 124 | // QVariant((int) p_parameter_list->min_value.i_int), |
| 125 | // QVariant((int) p_parameter_list->max_value.i_int), |
| 126 | // QVariantList(), |
| 127 | // description)); |
| 128 | // break; |
| 129 | // } |
| 130 | // case LIBVLC_FLOAT: { |
| 131 | // const QString description = p_parameter_list->psz_description; |
| 132 | // parameterList.append(Phonon::EffectParameter( |
| 133 | // i_index, |
| 134 | // QString(p_parameter_list->psz_parameter_name), |
| 135 | // 0, // hints |
| 136 | // QVariant((double) p_parameter_list->default_value.f_float), |
| 137 | // QVariant((double) p_parameter_list->min_value.f_float), |
| 138 | // QVariant((double) p_parameter_list->max_value.f_float), |
| 139 | // QVariantList(), |
| 140 | // description)); |
| 141 | // break; |
| 142 | // } |
| 143 | // case LIBVLC_STRING: { |
| 144 | // const QString description = p_parameter_list->psz_description; |
| 145 | // parameterList.append(Phonon::EffectParameter( |
| 146 | // i_index, |
| 147 | // QString(p_parameter_list->psz_parameter_name), |
| 148 | // 0, // hints |
| 149 | // QVariant((const char *) p_parameter_list->default_value.psz_string), |
| 150 | // NULL, |
| 151 | // NULL, |
| 152 | // QVariantList(), |
| 153 | // description)); |
| 154 | // break; |
| 155 | // } |
| 156 | // } |
| 157 | // i_index++; |
| 158 | // p_parameter_list = p_parameter_list->p_next; |
| 159 | // } |
| 160 | // libvlc_filter_parameters_release(p_list); |
| 161 | } |
| 162 | |
| 163 | QList<EffectParameter> Effect::parameters() const |
| 164 | { |
| 165 | return parameterList; |
| 166 | } |
| 167 | |
| 168 | QVariant Effect::parameterValue(const EffectParameter ¶m) const |
| 169 | { |
| 170 | Q_UNUSED(param); |
| 171 | return QVariant(); |
| 172 | } |
| 173 | |
| 174 | void Effect::setParameterValue(const EffectParameter ¶m, const QVariant &newValue) |
| 175 | { |
| 176 | Q_UNUSED(param); |
| 177 | Q_UNUSED(newValue); |
| 178 | // libvlc_value_t value; |
| 179 | // libvlc_var_type_t type; |
| 180 | // switch (param.type()) { |
| 181 | // case QVariant::Bool: |
| 182 | // value.b_bool = newValue.toBool(); |
| 183 | // type = LIBVLC_BOOL; |
| 184 | // break; |
| 185 | // case QVariant::Int: |
| 186 | // value.i_int = newValue.toInt(); |
| 187 | // type = LIBVLC_INT; |
| 188 | // break; |
| 189 | // case QVariant::Double: |
| 190 | // value.f_float = (float) newValue.toDouble(); |
| 191 | // type = LIBVLC_FLOAT; |
| 192 | // break; |
| 193 | // case QVariant::String: |
| 194 | // value.psz_string = newValue.toString().toAscii().data(); |
| 195 | // type = LIBVLC_STRING; |
| 196 | // break; |
| 197 | // default: |
| 198 | // break; |
| 199 | // } |
| 200 | // switch (effect_type) { |
| 201 | // case EffectInfo::AudioEffect: |
| 202 | // libvlc_audio_filter_set_parameter( |
| 203 | // p_vlc_instance, |
| 204 | // // (libvlc_audio_filter_names_t) i_effect_filter, |
| 205 | // param.name().toAscii().data(), |
| 206 | // type, |
| 207 | // value, |
| 208 | // vlc_exception); |
| 209 | // vlcExceptionRaised(); |
| 210 | // break; |
| 211 | // case EffectInfo::VideoEffect: |
| 212 | // libvlc_video_filter_set_parameter( |
| 213 | // p_vlc_current_media_player, |
| 214 | // (libvlc_video_filter_names_t) i_effect_filter, |
| 215 | // param.name().toAscii().data(), |
| 216 | // type, |
| 217 | // value, |
| 218 | // vlc_exception); |
| 219 | // vlcExceptionRaised(); |
| 220 | // break; |
| 221 | // } |
| 222 | } |
| 223 | |
| 224 | } |
| 225 | } // Namespace Phonon::VLC |
| 226 | |