| 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 "effect.h"
|
|---|
| 19 | #include "common.h"
|
|---|
| 20 | #include "audiooutput.h"
|
|---|
| 21 | #include "backend.h"
|
|---|
| 22 | #include "medianode.h"
|
|---|
| 23 | #include "effectmanager.h"
|
|---|
| 24 | #include "gsthelper.h"
|
|---|
| 25 |
|
|---|
| 26 | #include <gst/gst.h>
|
|---|
| 27 |
|
|---|
| 28 | #ifndef QT_NO_PHONON_EFFECT
|
|---|
| 29 | QT_BEGIN_NAMESPACE
|
|---|
| 30 | namespace Phonon
|
|---|
| 31 | {
|
|---|
| 32 | namespace Gstreamer
|
|---|
| 33 | {
|
|---|
| 34 | Effect::Effect(Backend *backend, QObject *parent, NodeDescription description)
|
|---|
| 35 | : QObject(parent),
|
|---|
| 36 | MediaNode(backend, description)
|
|---|
| 37 | , m_effectBin(0)
|
|---|
| 38 | , m_effectElement(0)
|
|---|
| 39 | {
|
|---|
| 40 | }
|
|---|
| 41 |
|
|---|
| 42 | void Effect::init()
|
|---|
| 43 | {
|
|---|
| 44 | m_effectBin = createEffectBin();
|
|---|
| 45 | if (m_effectBin) {
|
|---|
| 46 | setupEffectParams();
|
|---|
| 47 | gst_object_ref (GST_OBJECT (m_effectBin)); // Take ownership
|
|---|
| 48 | gst_object_sink (GST_OBJECT (m_effectBin));
|
|---|
| 49 | m_isValid = true;
|
|---|
| 50 | }
|
|---|
| 51 | }
|
|---|
| 52 |
|
|---|
| 53 | Effect::~Effect()
|
|---|
| 54 | {
|
|---|
| 55 | if (m_effectBin) {
|
|---|
| 56 | gst_element_set_state (m_effectBin, GST_STATE_NULL);
|
|---|
| 57 | gst_object_unref (m_effectBin);
|
|---|
| 58 | }
|
|---|
| 59 | }
|
|---|
| 60 |
|
|---|
| 61 | void Effect::setupEffectParams()
|
|---|
| 62 | {
|
|---|
| 63 |
|
|---|
| 64 | Q_ASSERT(m_effectElement);
|
|---|
| 65 |
|
|---|
| 66 | //query and store parameters
|
|---|
| 67 | if (m_effectElement) {
|
|---|
| 68 | GParamSpec **property_specs;
|
|---|
| 69 | guint propertyCount, i;
|
|---|
| 70 | property_specs = g_object_class_list_properties(G_OBJECT_GET_CLASS (m_effectElement), &propertyCount);
|
|---|
| 71 | for (i = 0; i < propertyCount; i++) {
|
|---|
| 72 | GParamSpec *param = property_specs[i];
|
|---|
| 73 | if (param->flags & G_PARAM_WRITABLE) {
|
|---|
| 74 | QString propertyName = g_param_spec_get_name (param);
|
|---|
| 75 |
|
|---|
| 76 | // These properties should not be exposed to the front-end
|
|---|
| 77 | if (propertyName == "qos" || propertyName == "name" || propertyName == "async-handling")
|
|---|
| 78 | continue;
|
|---|
| 79 |
|
|---|
| 80 | switch(param->value_type) {
|
|---|
| 81 | case G_TYPE_UINT:
|
|---|
| 82 | m_parameterList.append(Phonon::EffectParameter(i, propertyName,
|
|---|
| 83 | 0, //hints
|
|---|
| 84 | G_PARAM_SPEC_UINT(param)->default_value,
|
|---|
| 85 | G_PARAM_SPEC_UINT(param)->minimum,
|
|---|
| 86 | G_PARAM_SPEC_UINT(param)->maximum));
|
|---|
| 87 | break;
|
|---|
| 88 |
|
|---|
| 89 | case G_TYPE_STRING:
|
|---|
| 90 | m_parameterList.append(Phonon::EffectParameter(i, propertyName,
|
|---|
| 91 | 0, //hints
|
|---|
| 92 | G_PARAM_SPEC_STRING(param)->default_value,
|
|---|
| 93 | 0,
|
|---|
| 94 | 0));
|
|---|
| 95 | break;
|
|---|
| 96 |
|
|---|
| 97 | case G_TYPE_INT:
|
|---|
| 98 | m_parameterList.append(Phonon::EffectParameter(i, propertyName,
|
|---|
| 99 | EffectParameter::IntegerHint, //hints
|
|---|
| 100 | QVariant(G_PARAM_SPEC_INT(param)->default_value),
|
|---|
| 101 | QVariant(G_PARAM_SPEC_INT(param)->minimum),
|
|---|
| 102 | QVariant(G_PARAM_SPEC_INT(param)->maximum)));
|
|---|
| 103 | break;
|
|---|
| 104 |
|
|---|
| 105 | case G_TYPE_FLOAT:
|
|---|
| 106 | m_parameterList.append(Phonon::EffectParameter(i, propertyName,
|
|---|
| 107 | 0, //hints
|
|---|
| 108 | QVariant((double)G_PARAM_SPEC_FLOAT(param)->default_value),
|
|---|
| 109 | QVariant((double)G_PARAM_SPEC_FLOAT(param)->minimum),
|
|---|
| 110 | QVariant((double)G_PARAM_SPEC_FLOAT(param)->maximum)));
|
|---|
| 111 | break;
|
|---|
| 112 |
|
|---|
| 113 | case G_TYPE_DOUBLE:
|
|---|
|
|---|