File indexing completed on 2024-12-01 04:21:25

0001 /*
0002     Copyright (C) 2007-2008 Tanguy Krotoff <tkrotoff@gmail.com>
0003     Copyright (C) 2008 Lukas Durfina <lukas.durfina@gmail.com>
0004     Copyright (C) 2009 Fathi Boudra <fabo@kde.org>
0005     Copyright (C) 2009-2011 vlc-phonon AUTHORS <kde-multimedia@kde.org>
0006 
0007     This library is free software; you can redistribute it and/or
0008     modify it under the terms of the GNU Lesser General Public
0009     License as published by the Free Software Foundation; either
0010     version 2.1 of the License, or (at your option) any later version.
0011 
0012     This library is distributed in the hope that it will be useful,
0013     but WITHOUT ANY WARRANTY; without even the implied warranty of
0014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0015     Lesser General Public License for more details.
0016 
0017     You should have received a copy of the GNU Lesser General Public
0018     License along with this library.  If not, see <http://www.gnu.org/licenses/>.
0019 */
0020 
0021 #include "effect.h"
0022 
0023 #include "effectmanager.h"
0024 
0025 #include "mediaobject.h"
0026 
0027 namespace Phonon
0028 {
0029 namespace VLC
0030 {
0031 
0032 Effect::Effect(EffectManager *p_em, int i_effectId, QObject *p_parent)
0033     : QObject(p_parent)
0034     , SinkNode()
0035 {
0036     Q_UNUSED(p_em);
0037     Q_UNUSED(i_effectId);
0038 //    p_effectManager = p_em;
0039 //    const QList<EffectInfo> effects = p_effectManager->effects();
0040 
0041 //    if (i_effectId >= 0 && i_effectId < effects.size()) {
0042 //        i_effect_filter = effects[ i_effectId ]->filter();
0043 //        effect_type = effects[ i_effectId ]->type();
0044 //        setupEffectParams();
0045 //    } else {
0046 //        // effect ID out of range
0047 //        Q_ASSERT(0);
0048 //    }
0049 }
0050 
0051 Effect::~Effect()
0052 {
0053     parameterList.clear();
0054 }
0055 
0056 void Effect::handleConnectToMediaObject(MediaObject *)
0057 {
0058     switch (effect_type) {
0059     case EffectInfo::AudioEffect:
0060 //        libvlc_audio_filter_add(p_vlc_instance, (libvlc_audio_filter_names_t)i_effect_filter, vlc_exception);
0061 //        vlcExceptionRaised();
0062         break;
0063     case EffectInfo::VideoEffect:
0064 //        libvlc_video_filter_add(p_vlc_current_media_player, (libvlc_video_filter_names_t)i_effect_filter, vlc_exception);
0065 //        vlcExceptionRaised();
0066         break;
0067     }
0068 }
0069 
0070 void Effect::handleDisconnectFromMediaObject(MediaObject *)
0071 {
0072     switch (effect_type) {
0073     case EffectInfo::AudioEffect:
0074 //        libvlc_audio_filter_remove(p_vlc_instance, (libvlc_audio_filter_names_t)i_effect_filter, vlc_exception);
0075 //        vlcExceptionRaised();
0076         break;
0077     case EffectInfo::VideoEffect:
0078 //        libvlc_video_filter_remove(p_vlc_current_media_player, (libvlc_video_filter_names_t)i_effect_filter, vlc_exception);
0079 //        vlcExceptionRaised();
0080         break;
0081     }
0082 }
0083 
0084 void Effect::setupEffectParams()
0085 {
0086 //    libvlc_filter_parameter_list_t *p_list;
0087     switch (effect_type) {
0088     case EffectInfo::AudioEffect:
0089 //        p_list = libvlc_audio_filter_get_parameters(p_vlc_instance, (libvlc_audio_filter_names_t)i_effect_filter, vlc_exception );
0090 //        vlcExceptionRaised();
0091         break;
0092     case EffectInfo::VideoEffect:
0093 //        p_list = libvlc_video_filter_get_parameters(p_vlc_instance, (libvlc_video_filter_names_t)i_effect_filter, vlc_exception );
0094 //        vlcExceptionRaised();
0095         break;
0096     }
0097 //    if( !p_list )
0098 //        return;
0099 
0100 //    int i_index = 0;
0101 //    libvlc_filter_parameter_list_t *p_parameter_list = p_list;
0102 //    while (p_parameter_list) {
0103 //        switch (p_parameter_list->var_type) {
0104 //        case LIBVLC_BOOL: {
0105 //            const QString description = p_parameter_list->psz_description;
0106 //            parameterList.append(Phonon::EffectParameter(
0107 //                                     i_index,
0108 //                                     QString(p_parameter_list->psz_parameter_name),
0109 //                                     Phonon::EffectParameter::ToggledHint,   // hints
0110 //                                     QVariant((bool) p_parameter_list->default_value.b_bool),
0111 //                                     QVariant((bool) false),
0112 //                                     QVariant((bool) true),
0113 //                                     QVariantList(),
0114 //                                     description));
0115 //            break;
0116 //        }
0117 //        case LIBVLC_INT: {
0118 //            const QString description = p_parameter_list->psz_description;
0119 //            parameterList.append(Phonon::EffectParameter(
0120 //                                     i_index,
0121 //                                     QString(p_parameter_list->psz_parameter_name),
0122 //                                     EffectParameter::IntegerHint,   // hints
0123 //                                     QVariant((int) p_parameter_list->default_value.i_int),
0124 //                                     QVariant((int) p_parameter_list->min_value.i_int),
0125 //                                     QVariant((int) p_parameter_list->max_value.i_int),
0126 //                                     QVariantList(),
0127 //                                     description));
0128 //            break;
0129 //        }
0130 //        case LIBVLC_FLOAT: {
0131 //            const QString description = p_parameter_list->psz_description;
0132 //            parameterList.append(Phonon::EffectParameter(
0133 //                                     i_index,
0134 //                                     QString(p_parameter_list->psz_parameter_name),
0135 //                                     0,   // hints
0136 //                                     QVariant((double) p_parameter_list->default_value.f_float),
0137 //                                     QVariant((double) p_parameter_list->min_value.f_float),
0138 //                                     QVariant((double) p_parameter_list->max_value.f_float),
0139 //                                     QVariantList(),
0140 //                                     description));
0141 //            break;
0142 //        }
0143 //        case LIBVLC_STRING: {
0144 //            const QString description = p_parameter_list->psz_description;
0145 //            parameterList.append(Phonon::EffectParameter(
0146 //                                     i_index,
0147 //                                     QString(p_parameter_list->psz_parameter_name),
0148 //                                     0,   // hints
0149 //                                     QVariant((const char *) p_parameter_list->default_value.psz_string),
0150 //                                     NULL,
0151 //                                     NULL,
0152 //                                     QVariantList(),
0153 //                                     description));
0154 //            break;
0155 //        }
0156 //        }
0157 //        i_index++;
0158 //        p_parameter_list = p_parameter_list->p_next;
0159 //    }
0160 //    libvlc_filter_parameters_release(p_list);
0161 }
0162 
0163 QList<EffectParameter> Effect::parameters() const
0164 {
0165     return parameterList;
0166 }
0167 
0168 QVariant Effect::parameterValue(const EffectParameter &param) const
0169 {
0170     Q_UNUSED(param);
0171     return QVariant();
0172 }
0173 
0174 void Effect::setParameterValue(const EffectParameter &param, const QVariant &newValue)
0175 {
0176     Q_UNUSED(param);
0177     Q_UNUSED(newValue);
0178 //    libvlc_value_t value;
0179 //    libvlc_var_type_t type;
0180 //    switch (param.type()) {
0181 //    case QVariant::Bool:
0182 //        value.b_bool = newValue.toBool();
0183 //        type = LIBVLC_BOOL;
0184 //        break;
0185 //    case QVariant::Int:
0186 //        value.i_int = newValue.toInt();
0187 //        type = LIBVLC_INT;
0188 //        break;
0189 //    case QVariant::Double:
0190 //        value.f_float = (float) newValue.toDouble();
0191 //        type = LIBVLC_FLOAT;
0192 //        break;
0193 //    case QVariant::String:
0194 //        value.psz_string = newValue.toString().toAscii().data();
0195 //        type = LIBVLC_STRING;
0196 //        break;
0197 //    default:
0198 //        break;
0199 //    }
0200 //    switch (effect_type) {
0201 //    case EffectInfo::AudioEffect:
0202 //        libvlc_audio_filter_set_parameter(
0203 //            p_vlc_instance,
0204 //            // (libvlc_audio_filter_names_t) i_effect_filter,
0205 //            param.name().toAscii().data(),
0206 //            type,
0207 //            value,
0208 //            vlc_exception);
0209 //        vlcExceptionRaised();
0210 //        break;
0211 //    case EffectInfo::VideoEffect:
0212 //        libvlc_video_filter_set_parameter(
0213 //            p_vlc_current_media_player,
0214 //            (libvlc_video_filter_names_t) i_effect_filter,
0215 //            param.name().toAscii().data(),
0216 //            type,
0217 //            value,
0218 //            vlc_exception);
0219 //        vlcExceptionRaised();
0220 //        break;
0221 //    }
0222 }
0223 
0224 }
0225 } // Namespace Phonon::VLC