File indexing completed on 2024-12-01 04:21:25
0001 /* 0002 Copyright (C) 2007-2008 Tanguy Krotoff <tkrotoff@gmail.com> 0003 Copyright (C) 2008 Lukas Durfina <lukas.durfina@gmail.com> 0004 Copyright (C) 2009 Fathi Boudra <fabo@kde.org> 0005 Copyright (C) 2009-2011 vlc-phonon AUTHORS <kde-multimedia@kde.org> 0006 Copyright (C) 2011 Harald Sitter <sitter@kde.org> 0007 0008 This library is free software; you can redistribute it and/or 0009 modify it under the terms of the GNU Lesser General Public 0010 License as published by the Free Software Foundation; either 0011 version 2.1 of the License, or (at your option) any later version. 0012 0013 This library is distributed in the hope that it will be useful, 0014 but WITHOUT ANY WARRANTY; without even the implied warranty of 0015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0016 Lesser General Public License for more details. 0017 0018 You should have received a copy of the GNU Lesser General Public 0019 License along with this library. If not, see <http://www.gnu.org/licenses/>. 0020 */ 0021 0022 #ifndef Phonon_VLC_BACKEND_H 0023 #define Phonon_VLC_BACKEND_H 0024 0025 #include <QtCore/QStringList> 0026 0027 #include <phonon/objectdescription.h> 0028 #include <phonon/backendinterface.h> 0029 0030 class LibVLC; 0031 0032 namespace Phonon 0033 { 0034 namespace VLC 0035 { 0036 class DeviceManager; 0037 class EffectManager; 0038 0039 /** \brief Backend class for Phonon-VLC. 0040 * 0041 * This class provides the special objects created by the backend and information about 0042 * various things that the backend supports. An object of this class is the root for 0043 * the backend plugin. 0044 * 0045 * Phonon will request the backend to create objects of various classes, like MediaObject, 0046 * AudioOutput, VideoWidget, Effect. There are also methods to handle the connections between 0047 * these objects. 0048 * 0049 * This class also provides information about the devices and effects that the backend supports. 0050 * These are audio output devices, audio capture devices, video capture devices, effects. 0051 */ 0052 0053 class Backend : public QObject, public BackendInterface 0054 { 0055 Q_OBJECT 0056 Q_PLUGIN_METADATA(IID "org.kde.phonon.vlc" FILE "phonon-vlc.json") 0057 Q_INTERFACES(Phonon::BackendInterface) 0058 0059 public: 0060 /** 0061 * Instance. Since there is no backend instance without actual Backend object 0062 * this class behaves likes a singleton. 0063 */ 0064 static Backend *self; 0065 0066 /** 0067 * Constructs the backend. Sets the backend properties, fetches the debug level from the 0068 * environment, initializes libVLC, constructs the device and effect managers, initializes 0069 * PulseAudio support. 0070 * 0071 * \param parent A parent object for the backend (passed to the QObject constructor) 0072 */ 0073 explicit Backend(QObject *parent = nullptr, const QVariantList & = QVariantList()); 0074 virtual ~Backend(); 0075 0076 /// \return The device manager that is associated with this backend object 0077 DeviceManager *deviceManager() const; 0078 0079 /// \return The effect manager that is associated with this backend object. 0080 EffectManager *effectManager() const; 0081 0082 /** 0083 * Creates a backend object of the desired class and with the desired parent. Extra arguments can be provided. 0084 * 0085 * \param c The class of object that is to be created 0086 * \param parent The object that will be the parent of the new object 0087 * \param args Optional arguments for the object creation 0088 * \return The desired object or NULL if the class is not implemented. 0089 */ 0090 QObject *createObject(BackendInterface::Class, QObject *parent, const QList<QVariant> &args) override; 0091 0092 /// \returns a list of all available mimetypes (hardcoded) 0093 QStringList availableMimeTypes() const override; 0094 0095 /** 0096 * Returns a list of indexes for the desired object types. It specifies a list of objects 0097 * of a particular category that the backend knows about. These indexes can be used with 0098 * objectDescriptionProperties() to get the properties of a particular object. 0099 * 0100 * \param type The type of objects for the list 0101 */ 0102 QList<int> objectDescriptionIndexes(ObjectDescriptionType type) const override; 0103 0104 /** 0105 * Returns a list of properties for a particular object of the desired category. 0106 * 0107 * \param type The type of object for the index 0108 * \param index The index for the object of the desired type 0109 * \return The property list. If the object is inexistent, an empty list is returned. 0110 */ 0111 QHash<QByteArray, QVariant> objectDescriptionProperties(ObjectDescriptionType type, int index) const override; 0112 0113 /** 0114 * Called when a connection between nodes is about to be changed 0115 * 0116 * \param objects A set of objects that will be involved in the change 0117 */ 0118 bool startConnectionChange(QSet<QObject *>) override; 0119 0120 /** 0121 * Connects two media nodes. The sink is informed that it should connect itself to the source. 0122 * 0123 * \param source The source media node for the connection 0124 * \param sink The sink media node for the connection 0125 * \return True if the connection was successful 0126 */ 0127 bool connectNodes(QObject *, QObject *) override; 0128 0129 /** 0130 * Disconnects two previously connected media nodes. It disconnects the sink node from the source node. 0131 * 0132 * \param source The source node for the disconnection 0133 * \param sink The sink node for the disconnection 0134 * \return True if the disconnection was successful 0135 */ 0136 bool disconnectNodes(QObject *, QObject *) override; 0137 0138 /** 0139 * Called after a connection between nodes has been changed 0140 * 0141 * \param objects Nodes involved in the disconnection 0142 */ 0143 bool endConnectionChange(QSet<QObject *>) override; 0144 0145 Q_SIGNALS: 0146 void objectDescriptionChanged(ObjectDescriptionType); 0147 0148 private: 0149 mutable QStringList m_supportedMimeTypes; 0150 0151 DeviceManager *m_deviceManager; 0152 EffectManager *m_effectManager; 0153 }; 0154 0155 } // namespace VLC 0156 } // namespace Phonon 0157 0158 #endif // Phonon_VLC_BACKEND_H