| 1 | /* |
| 2 | Copyright (C) 2009-2010 vlc-phonon AUTHORS <kde-multimedia@kde.org> |
| 3 | |
| 4 | This library is free software; you can redistribute it and/or |
| 5 | modify it under the terms of the GNU Lesser General Public |
| 6 | License as published by the Free Software Foundation; either |
| 7 | version 2.1 of the License, or (at your option) any later version. |
| 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 GNU |
| 12 | Lesser General Public License for more details. |
| 13 | |
| 14 | You should have received a copy of the GNU Lesser General Public |
| 15 | License along with this library. If not, see <http://www.gnu.org/licenses/>. |
| 16 | */ |
| 17 | |
| 18 | #ifndef Phonon_VLC_DEVICEMANAGER_H |
| 19 | #define Phonon_VLC_DEVICEMANAGER_H |
| 20 | |
| 21 | #include <QtCore/QObject> |
| 22 | |
| 23 | #include <phonon/ObjectDescription> |
| 24 | |
| 25 | namespace Phonon |
| 26 | { |
| 27 | namespace VLC |
| 28 | { |
| 29 | |
| 30 | class Backend; |
| 31 | |
| 32 | /** \brief Container for information about devices supported by libVLC |
| 33 | * |
| 34 | * It includes a (hopefully unique) device identifier, a name identifier, a |
| 35 | * description, a hardware identifier (may be a platform dependent device name), |
| 36 | * and other relevant info. |
| 37 | */ |
| 38 | class DeviceInfo |
| 39 | { |
| 40 | public: |
| 41 | enum Capability { |
| 42 | None = 0x0000, |
| 43 | AudioOutput = 0x0001, |
| 44 | AudioCapture = 0x0002, |
| 45 | VideoCapture = 0x0004 |
| 46 | }; |
| 47 | public: |
| 48 | /** |
| 49 | * Constructs a device info object and sets it's device identifiers. |
| 50 | */ |
| 51 | explicit DeviceInfo(const QString &name, bool isAdvanced = true); |
| 52 | |
| 53 | int id() const; |
| 54 | const QString& name() const; |
| 55 | const QString& description() const; |
| 56 | bool isAdvanced() const; |
| 57 | void setAdvanced(bool advanced); |
| 58 | const DeviceAccessList& accessList() const; |
| 59 | void addAccess(const DeviceAccess &access); |
| 60 | quint16 capabilities() const; |
| 61 | void setCapabilities(quint16 cap); |
| 62 | |
| 63 | private: |
| 64 | int m_id; |
| 65 | QString m_name; |
| 66 | QString m_description; |
| 67 | bool m_isAdvanced; |
| 68 | DeviceAccessList m_accessList; |
| 69 | quint16 m_capabilities; |
| 70 | }; |
| 71 | |
| 72 | /** \brief Keeps track of audio/video devices that libVLC supports |
| 73 | * |
| 74 | * This class maintains a device list. Types of devices: |
| 75 | * \li audio output devices |
| 76 | * \li audio capture devices |
| 77 | * \li video capture devices |
| 78 | * |
| 79 | * Methods are provided to retrieve information about these devices. |
| 80 | * |
| 81 | * \see EffectManager |
| 82 | */ |
| 83 | class DeviceManager : public QObject |
| 84 | { |
| 85 | Q_OBJECT |
| 86 | |
| 87 | public: |
| 88 | /** |
| 89 | * Constructs a device manager and immediately updates the devices. |
| 90 | */ |
| 91 | explicit DeviceManager(Backend *parent); |
| 92 | |
| 93 | /** |
| 94 | * Clears all the devices before destroying. |
| 95 | */ |
| 96 | virtual ~DeviceManager(); |
| 97 | |
| 98 | /** |
| 99 | * \param type Only devices with a capability of this type are returned |
| 100 | * The following are supported: |
| 101 | * \li AudioOutputDeviceType |
| 102 | * \li AudioCaptureDeviceType |
| 103 | * \li VideoCaptureDeviceType |
| 104 | * |
| 105 | * \return A list of device identifiers that have capabilities that |
| 106 | * match the desired type |
| 107 | * |
| 108 | * \note The capture devices are temporarily not implemented / removed |
| 109 | */ |
| 110 | QList<int> deviceIds(ObjectDescriptionType type); |
| 111 | |
| 112 | /** |
| 113 | * \param id The identifier for the device |
| 114 | * \return Object description properties for a device |
| 115 | */ |
| 116 | QHash<QByteArray, QVariant> deviceProperties(int id); |
| 117 | |
| 118 | /** |
| 119 | * \param id The identifier for the device |
| 120 | * \return Pointer to DeviceInfo, or NULL if the id is invalid |
| 121 | */ |
| 122 | const DeviceInfo *device(int id) const; |
| 123 | |
| 124 | Q_SIGNALS: |
| 125 | void deviceAdded(int); |
| 126 | void deviceRemoved(int); |
| 127 | |
| 128 | public Q_SLOTS: |
| 129 | /** |
| 130 | * Update the current list of active devices. It probes for audio output devices, |
| 131 | * audio capture devices, video capture devices. The methods depend on the |
| 132 | * device types. |
| 133 | */ |
| 134 | void updateDeviceList(); |
| 135 | |
| 136 | private: |
| 137 | static bool listContainsDevice(const QList<DeviceInfo> &list, int id); |
| 138 | |
| 139 | private: |
| 140 | Backend *m_backend; |
| 141 | QList<DeviceInfo> m_devices; |
| 142 | }; |
| 143 | } |
| 144 | } // namespace Phonon::VLC |
| 145 | |
| 146 | #endif // Phonon_VLC_DEVICEMANAGER_H |
| 147 | |