1/*
2 Copyright (C) 2007-2008 Tanguy Krotoff <tkrotoff@gmail.com>
3 Copyright (C) 2008 Lukas Durfina <lukas.durfina@gmail.com>
4 Copyright (C) 2009 Fathi Boudra <fabo@kde.org>
5 Copyright (C) 2009-2011 vlc-phonon AUTHORS <kde-multimedia@kde.org>
6 Copyright (C) 2011 Harald Sitter <sitter@kde.org>
7
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Lesser General Public
10 License as published by the Free Software Foundation; either
11 version 2.1 of the License, or (at your option) any later version.
12
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public
19 License along with this library. If not, see <http://www.gnu.org/licenses/>.
20*/
21
22#ifndef Phonon_VLC_BACKEND_H
23#define Phonon_VLC_BACKEND_H
24
25#include <QtCore/QStringList>
26
27#include <phonon/objectdescription.h>
28#include <phonon/backendinterface.h>
29
30class LibVLC;
31
32namespace Phonon
33{
34namespace VLC
35{
36class DeviceManager;
37class EffectManager;
38
39/** \brief Backend class for Phonon-VLC.
40 *
41 * This class provides the special objects created by the backend and information about
42 * various things that the backend supports. An object of this class is the root for
43 * the backend plugin.
44 *
45 * Phonon will request the backend to create objects of various classes, like MediaObject,
46 * AudioOutput, VideoWidget, Effect. There are also methods to handle the connections between
47 * these objects.
48 *
49 * This class also provides information about the devices and effects that the backend supports.
50 * These are audio output devices, audio capture devices, video capture devices, effects.
51 */
52
53class Backend : public QObject, public BackendInterface
54{
55 Q_OBJECT
56 Q_PLUGIN_METADATA(IID "org.kde.phonon.vlc" FILE "phonon-vlc.json")
57 Q_INTERFACES(Phonon::BackendInterface)
58
59public:
60 /**
61 * Instance. Since there is no backend instance without actual Backend object
62 * this class behaves likes a singleton.
63 */
64 static Backend *self;
65
66 /**
67 * Constructs the backend. Sets the backend properties, fetches the debug level from the
68 * environment, initializes libVLC, constructs the device and effect managers, initializes
69 * PulseAudio support.
70 *
71 * \param parent A parent object for the backend (passed to the QObject constructor)
72 */
73 explicit Backend(QObject *parent = nullptr, const QVariantList & = QVariantList());
74 virtual ~Backend();
75
76 /// \return The device manager that is associated with this backend object
77 DeviceManager *deviceManager() const;
78
79 /// \return The effect manager that is associated with this backend object.
80 EffectManager *effectManager() const;
81
82 /**
83 * Creates a backend object of the desired class and with the desired parent. Extra arguments can be provided.
84 *
85 * \param c The class of object that is to be created
86 * \param parent The object that will be the parent of the new object
87 * \param args Optional arguments for the object creation
88 * \return The desired object or NULL if the class is not implemented.
89 */
90 QObject *createObject(BackendInterface::Class, QObject *parent, const QList<QVariant> &args) override;
91
92 /// \returns a list of all available mimetypes (hardcoded)
93 QStringList availableMimeTypes() const override;
94
95 /**
96 * Returns a list of indexes for the desired object types. It specifies a list of objects
97 * of a particular category that the backend knows about. These indexes can be used with
98 * objectDescriptionProperties() to get the properties of a particular object.
99 *
100 * \param type The type of objects for the list
101 */
102 QList<int> objectDescriptionIndexes(ObjectDescriptionType type) const override;
103
104 /**
105 * Returns a list of properties for a particular object of the desired category.
106 *
107 * \param type The type of object for the index
108 * \param index The index for the object of the desired type
109 * \return The property list. If the object is inexistent, an empty list is returned.
110 */
111 QHash<QByteArray, QVariant> objectDescriptionProperties(ObjectDescriptionType type, int index) const override;
112
113 /**
114 * Called when a connection between nodes is about to be changed
115 *
116 * \param objects A set of objects that will be involved in the change
117 */
118 bool startConnectionChange(QSet<QObject *>) override;
119
120 /**
121 * Connects two media nodes. The sink is informed that it should connect itself to the source.
122 *
123 * \param source The source media node for the connection
124 * \param sink The sink media node for the connection
125 * \return True if the connection was successful
126 */
127 bool connectNodes(QObject *, QObject *) override;
128
129 /**
130 * Disconnects two previously connected media nodes. It disconnects the sink node from the source node.
131 *
132 * \param source The source node for the disconnection
133 * \param sink The sink node for the disconnection
134 * \return True if the disconnection was successful
135 */
136 bool disconnectNodes(QObject *, QObject *) override;
137
138 /**
139 * Called after a connection between nodes has been changed
140 *
141 * \param objects Nodes involved in the disconnection
142 */
143 bool endConnectionChange(QSet<QObject *>) override;
144
145Q_SIGNALS:
146 void objectDescriptionChanged(ObjectDescriptionType);
147
148private:
149 mutable QStringList m_supportedMimeTypes;
150
151 DeviceManager *m_deviceManager;
152 EffectManager *m_effectManager;
153};
154
155} // namespace VLC
156} // namespace Phonon
157
158#endif // Phonon_VLC_BACKEND_H
159

source code of phonon-vlc/src/backend.h