| 1 | /* This file is part of the KDE project.
|
|---|
| 2 |
|
|---|
| 3 | Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|---|
| 4 |
|
|---|
| 5 | This library is free software: you can redistribute it and/or modify
|
|---|
| 6 | it under the terms of the GNU Lesser General Public License as published by
|
|---|
| 7 | the Free Software Foundation, either version 2.1 or 3 of the License.
|
|---|
| 8 |
|
|---|
| 9 | This library is distributed in the hope that it will be useful,
|
|---|
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 12 | GNU Lesser General Public License for more details.
|
|---|
| 13 |
|
|---|
| 14 | You should have received a copy of the GNU Lesser General Public License
|
|---|
| 15 | along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|---|
| 16 |
|
|---|
| 17 | */
|
|---|
| 18 |
|
|---|
| 19 | #include "mediaobject.h"
|
|---|
| 20 |
|
|---|
| 21 | #include "abstractaudioeffect.h"
|
|---|
| 22 | #include "audioplayer.h"
|
|---|
| 23 | #include "mmf_videoplayer.h"
|
|---|
| 24 |
|
|---|
| 25 | QT_BEGIN_NAMESPACE
|
|---|
| 26 |
|
|---|
| 27 | using namespace Phonon;
|
|---|
| 28 | using namespace Phonon::MMF;
|
|---|
| 29 |
|
|---|
| 30 | /*! \class MMF::AbstractAudioEffect
|
|---|
| 31 | \internal
|
|---|
| 32 | */
|
|---|
| 33 |
|
|---|
| 34 | /*! \namespace Phonon::MMF
|
|---|
| 35 | \internal
|
|---|
| 36 | */
|
|---|
| 37 |
|
|---|
| 38 | AbstractAudioEffect::AbstractAudioEffect(QObject *parent,
|
|---|
| 39 | const QList<EffectParameter> ¶ms)
|
|---|
| 40 | : MediaNode::MediaNode(parent)
|
|---|
| 41 | , m_player(0)
|
|---|
| 42 | , m_params(params)
|
|---|
| 43 | {
|
|---|
| 44 | }
|
|---|
| 45 |
|
|---|
| 46 | QList<EffectParameter> AbstractAudioEffect::parameters() const
|
|---|
| 47 | {
|
|---|
| 48 | return m_params;
|
|---|
| 49 | }
|
|---|
| 50 |
|
|---|
| 51 | QVariant AbstractAudioEffect::parameterValue(const EffectParameter &queriedParam) const
|
|---|
| 52 | {
|
|---|
| 53 | const QVariant &val = m_values.value(queriedParam.id());
|
|---|
| 54 |
|
|---|
| 55 | if (val.isNull())
|
|---|
| 56 | return queriedParam.defaultValue();
|
|---|
| 57 | else
|
|---|
| 58 | return val;
|
|---|
| 59 | }
|
|---|
| 60 |
|
|---|
| 61 | void AbstractAudioEffect::setParameterValue(const EffectParameter ¶m,
|
|---|
| 62 | const QVariant &newValue)
|
|---|
| 63 | {
|
|---|
| 64 | m_values.insert(param.id(), newValue);
|
|---|
| 65 | parameterChanged(param.id(), newValue);
|
|---|
| 66 | // TODO: handle audio effect errors
|
|---|
| 67 | TRAP_IGNORE(m_effect->ApplyL());
|
|---|
| 68 | }
|
|---|
| 69 |
|
|---|
| 70 | void AbstractAudioEffect::connectMediaObject(MediaObject *mediaObject)
|
|---|
| 71 | {
|
|---|
| 72 | Q_ASSERT_X(!m_player, Q_FUNC_INFO, "Player already connected");
|
|---|
| 73 | Q_ASSERT_X(!m_effect.data(), Q_FUNC_INFO, "Effect already created");
|
|---|
| 74 |
|
|---|
| 75 | AbstractMediaPlayer *const player =
|
|---|
| 76 | qobject_cast<AbstractMediaPlayer *>(mediaObject->abstractPlayer());
|
|---|
| 77 |
|
|---|
| 78 | if (player) {
|
|---|
| 79 | m_player = player;
|
|---|
| 80 |
|
|---|
| 81 | if (AudioPlayer *audioPlayer = qobject_cast<AudioPlayer *>(player)) {
|
|---|
| 82 | connectAudioPlayer(audioPlayer->nativePlayer());
|
|---|
| 83 | applyParameters();
|
|---|
| 84 | // TODO: handle audio effect errors
|
|---|
| 85 | TRAP_IGNORE(m_effect->EnableL());
|
|---|
| 86 | }
|
|---|
| 87 | }
|
|---|
| 88 | }
|
|---|
| 89 |
|
|---|
| 90 | void AbstractAudioEffect::disconnectMediaObject(MediaObject * /*mediaObject*/)
|
|---|
| 91 | {
|
|---|
| 92 | m_player = 0;
|
|---|
| 93 | m_effect.reset();
|
|---|
| 94 | }
|
|---|
| 95 |
|
|---|
| 96 | QT_END_NAMESPACE
|
|---|
| 97 |
|
|---|