| 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 | #include "common.h"
|
|---|
| 19 | #include "backend.h"
|
|---|
| 20 | #include "medianode.h"
|
|---|
| 21 | #include "effectmanager.h"
|
|---|
| 22 | #include "audioeffect.h"
|
|---|
| 23 | #include "gsthelper.h"
|
|---|
| 24 |
|
|---|
| 25 | #include <gst/gst.h>
|
|---|
| 26 | #ifndef QT_NO_PHONON_EFFECT
|
|---|
| 27 | QT_BEGIN_NAMESPACE
|
|---|
| 28 |
|
|---|
| 29 | namespace Phonon
|
|---|
| 30 | {
|
|---|
| 31 | namespace Gstreamer
|
|---|
| 32 | {
|
|---|
| 33 | AudioEffect::AudioEffect(Backend *backend, int effectId, QObject *parent)
|
|---|
| 34 | : Effect(backend, parent, AudioSource | AudioSink)
|
|---|
| 35 | {
|
|---|
| 36 | static int count = 0;
|
|---|
| 37 | m_name = "AudioEffect" + QString::number(count++);
|
|---|
| 38 | QList<EffectInfo*> audioEffects = backend->effectManager()->audioEffects();
|
|---|
| 39 | if (effectId >= 0 && effectId < audioEffects.size()) {
|
|---|
| 40 | m_effectName = audioEffects[effectId]->name();
|
|---|
| 41 | init();
|
|---|
| 42 | } else {
|
|---|
| 43 | Q_ASSERT(0); // Effect ID out of range
|
|---|
| 44 | }
|
|---|
| 45 | }
|
|---|
| 46 |
|
|---|
| 47 | GstElement* AudioEffect::createEffectBin()
|
|---|
| 48 | {
|
|---|
| 49 | GstElement *audioBin = gst_bin_new(NULL);
|
|---|
| 50 |
|
|---|
| 51 | // We need a queue to handle tee-connections from parent node
|
|---|
| 52 | GstElement *queue= gst_element_factory_make ("queue", NULL);
|
|---|
| 53 | gst_bin_add(GST_BIN(audioBin), queue);
|
|---|
| 54 |
|
|---|
| 55 | GstElement *mconv= gst_element_factory_make ("audioconvert", NULL);
|
|---|
| 56 | gst_bin_add(GST_BIN(audioBin), mconv);
|
|---|
| 57 |
|
|---|
| 58 | m_effectElement = gst_element_factory_make (qPrintable(m_effectName), NULL);
|
|---|
| 59 | gst_bin_add(GST_BIN(audioBin), m_effectElement);
|
|---|
| 60 |
|
|---|
| 61 | //Link src pad
|
|---|
| 62 | GstPad *srcPad= gst_element_get_pad (m_effectElement, "src");
|
|---|
| 63 | gst_element_add_pad (audioBin, gst_ghost_pad_new ("src", srcPad));
|
|---|
| 64 | gst_object_unref (srcPad);
|
|---|
| 65 |
|
|---|
| 66 | //Link sink pad
|
|---|
| 67 | gst_element_link_many(queue, mconv, m_effectElement, (const char*)NULL);
|
|---|
| 68 | GstPad *sinkpad = gst_element_get_pad (queue, "sink");
|
|---|
| 69 | gst_element_add_pad (audioBin, gst_ghost_pad_new ("sink", sinkpad));
|
|---|
| 70 | gst_object_unref (sinkpad);
|
|---|
| 71 | return audioBin;
|
|---|
| 72 | }
|
|---|
| 73 |
|
|---|
| 74 | }
|
|---|
| 75 | } //namespace Phonon::Gstreamer
|
|---|
| 76 |
|
|---|
| 77 | QT_END_NAMESPACE
|
|---|
| 78 | #endif //QT_NO_PHONON_EFFECT
|
|---|
| 79 | #include "moc_audioeffect.cpp"
|
|---|