File indexing completed on 2025-01-26 06:48:14
0001 /* 0002 * BluezQt - Asynchronous BlueZ wrapper library 0003 * 0004 * SPDX-FileCopyrightText: 2019 Manuel Weichselbaumer <mincequi@web.de> 0005 * 0006 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0007 */ 0008 0009 #ifndef BLUEZQT_MEDIATRANSPORT_H 0010 #define BLUEZQT_MEDIATRANSPORT_H 0011 0012 #include <QObject> 0013 0014 #include "bluezqt_export.h" 0015 #include "mediatypes.h" 0016 #include "tpendingcall.h" 0017 0018 #include <memory> 0019 0020 namespace BluezQt 0021 { 0022 class PendingCall; 0023 0024 /** 0025 * @class BluezQt::MediaTransport mediatransport.h <BluezQt/MediaTransport> 0026 * 0027 * Media transport. 0028 * 0029 * This class represents a media transport interface. 0030 */ 0031 class BLUEZQT_EXPORT MediaTransport : public QObject 0032 { 0033 Q_OBJECT 0034 Q_PROPERTY(State state READ state NOTIFY stateChanged) 0035 Q_PROPERTY(quint16 volume READ volume NOTIFY volumeChanged) 0036 0037 public: 0038 /** Indicates the state of the transport. */ 0039 enum class State { 0040 Idle, 0041 Pending, 0042 Active, 0043 }; 0044 Q_ENUM(State) 0045 0046 /** 0047 * Destroys a MediaTransport object. 0048 */ 0049 ~MediaTransport() override; 0050 0051 /** 0052 * Returns the (audio) configuration of the transport. 0053 * 0054 * @return configuration of transport 0055 */ 0056 AudioConfiguration audioConfiguration() const; 0057 0058 /** 0059 * Returns the state of the transport. 0060 * 0061 * @return state of transport 0062 */ 0063 State state() const; 0064 0065 /** 0066 * Returns the volume of the transport. 0067 * 0068 * The volume is a percentage of the maximum. The value 0x00 corresponds to 0%. 0069 * The value 0x7F corresponds to 100%. Scaling should be applied to achieve 0070 * values between these two. The existence of this scale does not impose any 0071 * restriction on the granularity of the volume control scale on the target. 0072 * As this command specifies a percentage rather than an absolute dB level 0073 * the controller should exercise caution when sending this command. 0074 * 0075 * @return volume of transport 0076 */ 0077 quint16 volume() const; 0078 0079 public Q_SLOTS: 0080 /** 0081 * Acquire transport file descriptor and the MTU for read 0082 * and write respectively. 0083 * 0084 * Possible errors: PendingCall::NotAuthorized, PendingCall::Failed 0085 * 0086 * @return <fd, uint16, uint16> pending call 0087 */ 0088 TPendingCall<QDBusUnixFileDescriptor, uint16_t, uint16_t> *acquire(); 0089 0090 /** 0091 * Acquire transport file descriptor only if the transport 0092 * is in "pending" state at the time the message is 0093 * received by BlueZ. Otherwise no request will be sent 0094 * to the remote device and the function will just fail 0095 * with org.bluez.Error.NotAvailable. 0096 * 0097 * Possible errors: PendingCall::NotAuthorized, PendingCall::Failed, PendingCall::NotAvailable 0098 * 0099 * @return <fd, uint16, uint16> pending call 0100 */ 0101 TPendingCall<QDBusUnixFileDescriptor, uint16_t, uint16_t> *tryAcquire(); 0102 0103 /** 0104 * Releases file descriptor. 0105 * 0106 * @return void pending call 0107 */ 0108 TPendingCall<void> *release(); 0109 0110 Q_SIGNALS: 0111 /** 0112 * Indicates that transport's state have changed. 0113 */ 0114 void stateChanged(State state); 0115 0116 /** 0117 * Indicates that transport's volume have changed. 0118 */ 0119 void volumeChanged(quint16 volume); 0120 0121 private: 0122 BLUEZQT_NO_EXPORT explicit MediaTransport(const QString &path, const QVariantMap &properties); 0123 0124 std::unique_ptr<class MediaTransportPrivate> const d; 0125 0126 friend class MediaTransportPrivate; 0127 friend class DevicePrivate; 0128 }; 0129 0130 } // namespace BluezQt 0131 0132 #endif