summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/phonon/waveout/backend.cpp
blob: 731475eb8c9d8dee25d937473a35e21b47ec66a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/*  This file is part of the KDE project.

Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).

This library is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 2.1 or 3 of the License.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with this library.  If not, see <http://www.gnu.org/licenses/>.
*/

#include "backend.h"


#include "audiooutput.h"
#include "mediaobject.h"



#include <QtCore/QSettings>
#include <QtCore/QSet>
#include <QtCore/QVariant>
#include <QtCore/QStringList>

#include <QtCore/QtPlugin>


QT_BEGIN_NAMESPACE

// export as Qt/KDE factory as required

Q_EXPORT_PLUGIN2(phonon_waveout, Phonon::WaveOut::Backend);

namespace Phonon
{
    namespace WaveOut
    {

        Backend::Backend(QObject *parent, const QVariantList &)
            : QObject(parent)
        {
        }

        Backend::~Backend()
        {
        }

        QObject *Backend::createObject(BackendInterface::Class c, QObject *parent, const QList<QVariant> &args)
        {
            Q_UNUSED(args);
            switch (c)
            {
            case MediaObjectClass:
                return new MediaObject(parent);
            case AudioOutputClass:
                return new AudioOutput(this, parent);
            default:
                return 0;
            }
        }

        bool Backend::supportsVideo() const
        {
            return false;
        }

        QStringList Backend::availableMimeTypes() const
        {
            QStringList ret;
            return ret;
        }


        QList<int> Backend::objectDescriptionIndexes(Phonon::ObjectDescriptionType type) const
        {
            QList<int> r;
            if (type == Phonon::AudioOutputDeviceType)
              r.append(0);
            return r;
        }

        QHash<QByteArray, QVariant> Backend::objectDescriptionProperties(Phonon::ObjectDescriptionType type, int index) const
        {
            Q_UNUSED(index);
            QHash<QByteArray, QVariant> r;
            if (type == Phonon::AudioOutputDeviceType) 
                r["name"] = QLatin1String("default audio device");
            return r;
        }


         bool Backend::connectNodes(QObject *node1, QObject *node2)
         {
             MediaObject *mediaObject = qobject_cast<MediaObject*> (node1);
             AudioOutput *audioOutput = qobject_cast<AudioOutput*> (node2);

             if (mediaObject && audioOutput)
                 mediaObject->setAudioOutput(audioOutput);
             return true;
         }

         bool Backend::disconnectNodes(QObject *node1, QObject *node2)
         {
             Q_UNUSED(node1);
             Q_UNUSED(node2);
             return true;
         }

         //transaction management
         bool Backend::startConnectionChange(QSet<QObject *>)
         {
             return true;
         }

         bool Backend::endConnectionChange(QSet<QObject *>)
         {
             return true;
         }

    }
}

QT_END_NAMESPACE

#include "moc_backend.cpp"