File indexing completed on 2024-04-28 04:43:19

0001 /*
0002     Copyright (C) 2009-2010 vlc-phonon AUTHORS <kde-multimedia@kde.org>
0003 
0004     This library is free software; you can redistribute it and/or
0005     modify it under the terms of the GNU Lesser General Public
0006     License as published by the Free Software Foundation; either
0007     version 2.1 of the License, or (at your option) any later version.
0008 
0009     This library is distributed in the hope that it will be useful,
0010     but WITHOUT ANY WARRANTY; without even the implied warranty of
0011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012     Lesser General Public License for more details.
0013 
0014     You should have received a copy of the GNU Lesser General Public
0015     License along with this library.  If not, see <http://www.gnu.org/licenses/>.
0016 */
0017 
0018 #ifndef Phonon_VLC_DEVICEMANAGER_H
0019 #define Phonon_VLC_DEVICEMANAGER_H
0020 
0021 #include <QtCore/QObject>
0022 
0023 #include <phonon/ObjectDescription>
0024 
0025 namespace Phonon
0026 {
0027 namespace VLC
0028 {
0029 
0030 class Backend;
0031 
0032 /** \brief Container for information about devices supported by libVLC
0033  *
0034  * It includes a (hopefully unique) device identifier, a name identifier, a
0035  * description, a hardware identifier (may be a platform dependent device name),
0036  * and other relevant info.
0037  */
0038 class DeviceInfo
0039 {
0040 public:
0041     enum Capability {
0042         None            = 0x0000,
0043         AudioOutput     = 0x0001,
0044         AudioCapture    = 0x0002,
0045         VideoCapture    = 0x0004
0046     };
0047 public:
0048     /**
0049      * Constructs a device info object and sets it's device identifiers.
0050      */
0051     explicit DeviceInfo(const QString &name, bool isAdvanced = true);
0052 
0053     int id() const;
0054     const QString& name() const;
0055     const QString& description() const;
0056     bool isAdvanced() const;
0057     void setAdvanced(bool advanced);
0058     const DeviceAccessList& accessList() const;
0059     void addAccess(const DeviceAccess &access);
0060     quint16 capabilities() const;
0061     void setCapabilities(quint16 cap);
0062 
0063 private:
0064     int m_id;
0065     QString m_name;
0066     QString m_description;
0067     bool m_isAdvanced;
0068     DeviceAccessList m_accessList;
0069     quint16 m_capabilities;
0070 };
0071 
0072 /** \brief Keeps track of audio/video devices that libVLC supports
0073  *
0074  * This class maintains a device list. Types of devices:
0075  * \li audio output devices
0076  * \li audio capture devices
0077  * \li video capture devices
0078  *
0079  * Methods are provided to retrieve information about these devices.
0080  *
0081  * \see EffectManager
0082  */
0083 class DeviceManager : public QObject
0084 {
0085     Q_OBJECT
0086 
0087 public:
0088     /**
0089      * Constructs a device manager and immediately updates the devices.
0090      */
0091     explicit DeviceManager(Backend *parent);
0092 
0093     /**
0094      * Clears all the devices before destroying.
0095      */
0096     virtual ~DeviceManager();
0097 
0098     /**
0099      * \param type Only devices with a capability of this type are returned
0100      * The following are supported:
0101      * \li AudioOutputDeviceType
0102      * \li AudioCaptureDeviceType
0103      * \li VideoCaptureDeviceType
0104      *
0105      * \return A list of device identifiers that have capabilities that
0106      * match the desired type
0107      *
0108      * \note The capture devices are temporarily not implemented / removed
0109      */
0110     QList<int> deviceIds(ObjectDescriptionType type);
0111 
0112     /**
0113      * \param id The identifier for the device
0114      * \return Object description properties for a device
0115      */
0116     QHash<QByteArray, QVariant> deviceProperties(int id);
0117 
0118     /**
0119      * \param id The identifier for the device
0120      * \return Pointer to DeviceInfo, or NULL if the id is invalid
0121      */
0122     const DeviceInfo *device(int id) const;
0123 
0124 Q_SIGNALS:
0125     void deviceAdded(int);
0126     void deviceRemoved(int);
0127 
0128 public Q_SLOTS:
0129     /**
0130      * Update the current list of active devices. It probes for audio output devices,
0131      * audio capture devices, video capture devices. The methods depend on the
0132      * device types.
0133      */
0134     void updateDeviceList();
0135 
0136 private:
0137     static bool listContainsDevice(const QList<DeviceInfo> &list, int id);
0138 
0139 private:
0140     Backend *m_backend;
0141     QList<DeviceInfo> m_devices;
0142 };
0143 }
0144 } // namespace Phonon::VLC
0145 
0146 #endif // Phonon_VLC_DEVICEMANAGER_H