1/*
2 * BluezQt - Asynchronous BlueZ wrapper library
3 *
4 * SPDX-FileCopyrightText: 2018 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_MEDIAENDPOINT_H
10#define BLUEZQT_MEDIAENDPOINT_H
11
12#include <QObject>
13
14#include "bluezqt_export.h"
15#include "request.h"
16
17#include <memory>
18
19class QDBusObjectPath;
20
21namespace BluezQt
22{
23/*!
24 * \inmodule BluezQt
25 * \class BluezQt::MediaEndpoint
26 * \inheaderfile BluezQt/MediaEndpoint
27 * \brief Bluetooth MediaEndpoint.
28 *
29 * This class represents a Bluetooth MediaEndpoint.
30 */
31class BLUEZQT_EXPORT MediaEndpoint : public QObject
32{
33 Q_OBJECT
34
35public:
36 /*!
37 * \enum BluezQt::MediaEndpoint::Role
38 * \brief Role which this MediaEndpoint acts as.
39 * \value AudioSource
40 * \value AudioSink
41 */
42 enum class Role {
43 AudioSource,
44 AudioSink,
45 };
46
47 // KF6 TODO: use types from mediatypes.h
48 /*!
49 * \enum BluezQt::MediaEndpoint::Codec
50 * \brief Codec which this MediaEndpoint supports.
51 * \value Sbc
52 * \value Aac
53 */
54 enum class Codec {
55 Sbc,
56 Aac,
57 };
58
59 /*!
60 * Configuration for MediaEndpoint construction.
61 * \inmodule BluezQt
62 */
63 struct Configuration {
64 /*!
65 *
66 */
67 Role role;
68
69 /*!
70 *
71 */
72 Codec codec;
73 };
74
75 /*!
76 * Creates a new MediaEndpoint object with the given \a configuration
77 * as a child of \a parent.
78 */
79 explicit MediaEndpoint(const Configuration &configuration, QObject *parent = nullptr);
80
81 ~MediaEndpoint() override;
82
83 /*!
84 * Returns the D-Bus object path of the MediaEndpoint.
85 *
86 * The path where the MediaEndpoint will be registered.
87 *
88 * \note You must provide valid object path!
89 */
90 virtual QDBusObjectPath objectPath() const;
91
92 /*!
93 * Returns the properties of the endpoint.
94 */
95 virtual const QVariantMap &properties() const;
96
97 /*!
98 * Set configuration for the transport at the \a transportObjectPath
99 * with the given \a properties.
100 */
101 virtual void setConfiguration(const QString &transportObjectPath, const QVariantMap &properties);
102
103 /*!
104 * Select preferable configuration from the supported \a capabilities with a \a request to be used for sending the reply.
105 *
106 * \note There is no need to cache the selected configuration since on success
107 * the configuration is send back as parameter of SetConfiguration.
108 */
109 virtual void selectConfiguration(const QByteArray &capabilities, const Request<QByteArray> &request);
110
111 /*!
112 * Clear the transport configuration at \a transportObjectPath.
113 */
114 virtual void clearConfiguration(const QString &transportObjectPath);
115
116 /*!
117 * Indicates that the MediaEndpoint was unregistered.
118 *
119 * This method gets called when the Bluetooth daemon
120 * unregisters the MediaEndpoint.
121 *
122 * A MediaEndpoint can use it to do cleanup tasks. There is no need
123 * to unregister the MediaEndpoint, because when this method gets called
124 * it has already been unregistered.
125 */
126 virtual void release();
127
128Q_SIGNALS:
129 /*!
130 * Indicates that the configuration was selected.
131 */
132 void configurationSelected(const QByteArray &capabilities, const QByteArray &configuration);
133
134 /*!
135 * Indicates that the configuration was set for transport.
136 */
137 void configurationSet(const QString &transportObjectPath, const QVariantMap &properties);
138
139 /*!
140 * Indicates that the configuration was cleared for transport.
141 */
142 void configurationCleared(const QString &transportObjectPath);
143
144private:
145 std::unique_ptr<class MediaEndpointPrivate> const d;
146};
147
148} // namespace BluezQt
149
150#endif // BLUEZQT_MEDIAENDPOINT_H
151

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