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

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