1/*
2 * BluezQt - Asynchronous BlueZ wrapper library
3 *
4 * SPDX-FileCopyrightText: 2019 Manuel Weichselbaumer <mincequi@web.de>
5 *
6 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
7 */
8
9#ifndef BLUEZQT_MEDIATRANSPORT_H
10#define BLUEZQT_MEDIATRANSPORT_H
11
12#include <QObject>
13
14#include "bluezqt_export.h"
15#include "mediatypes.h"
16#include "tpendingcall.h"
17
18#include <memory>
19
20namespace BluezQt
21{
22class PendingCall;
23
24/**
25 * @class BluezQt::MediaTransport mediatransport.h <BluezQt/MediaTransport>
26 *
27 * Media transport.
28 *
29 * This class represents a media transport interface.
30 */
31class BLUEZQT_EXPORT MediaTransport : public QObject
32{
33 Q_OBJECT
34 Q_PROPERTY(State state READ state NOTIFY stateChanged)
35 Q_PROPERTY(quint16 volume READ volume NOTIFY volumeChanged)
36
37public:
38 /** Indicates the state of the transport. */
39 enum class State {
40 Idle,
41 Pending,
42 Active,
43 };
44 Q_ENUM(State)
45
46 /**
47 * Destroys a MediaTransport object.
48 */
49 ~MediaTransport() override;
50
51 /**
52 * Returns the (audio) configuration of the transport.
53 *
54 * @return configuration of transport
55 */
56 AudioConfiguration audioConfiguration() const;
57
58 /**
59 * Returns the state of the transport.
60 *
61 * @return state of transport
62 */
63 State state() const;
64
65 /**
66 * Returns the volume of the transport.
67 *
68 * The volume is a percentage of the maximum. The value 0x00 corresponds to 0%.
69 * The value 0x7F corresponds to 100%. Scaling should be applied to achieve
70 * values between these two. The existence of this scale does not impose any
71 * restriction on the granularity of the volume control scale on the target.
72 * As this command specifies a percentage rather than an absolute dB level
73 * the controller should exercise caution when sending this command.
74 *
75 * @return volume of transport
76 */
77 quint16 volume() const;
78
79public Q_SLOTS:
80 /**
81 * Acquire transport file descriptor and the MTU for read
82 * and write respectively.
83 *
84 * Possible errors: PendingCall::NotAuthorized, PendingCall::Failed
85 *
86 * @return <fd, uint16, uint16> pending call
87 */
88 TPendingCall<QDBusUnixFileDescriptor, uint16_t, uint16_t> *acquire();
89
90 /**
91 * Acquire transport file descriptor only if the transport
92 * is in "pending" state at the time the message is
93 * received by BlueZ. Otherwise no request will be sent
94 * to the remote device and the function will just fail
95 * with org.bluez.Error.NotAvailable.
96 *
97 * Possible errors: PendingCall::NotAuthorized, PendingCall::Failed, PendingCall::NotAvailable
98 *
99 * @return <fd, uint16, uint16> pending call
100 */
101 TPendingCall<QDBusUnixFileDescriptor, uint16_t, uint16_t> *tryAcquire();
102
103 /**
104 * Releases file descriptor.
105 *
106 * @return void pending call
107 */
108 TPendingCall<void> *release();
109
110Q_SIGNALS:
111 /**
112 * Indicates that transport's state have changed.
113 */
114 void stateChanged(State state);
115
116 /**
117 * Indicates that transport's volume have changed.
118 */
119 void volumeChanged(quint16 volume);
120
121private:
122 BLUEZQT_NO_EXPORT explicit MediaTransport(const QString &path, const QVariantMap &properties);
123
124 std::unique_ptr<class MediaTransportPrivate> const d;
125
126 friend class MediaTransportPrivate;
127 friend class DevicePrivate;
128};
129
130} // namespace BluezQt
131
132#endif
133

source code of bluez-qt/src/mediatransport.h