File indexing completed on 2025-01-19 06:44:37
0001 /* 0002 * BluezQt - Asynchronous BlueZ wrapper library 0003 * 0004 * SPDX-FileCopyrightText: 2018 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_MEDIAENDPOINT_H 0010 #define BLUEZQT_MEDIAENDPOINT_H 0011 0012 #include <QObject> 0013 0014 #include "bluezqt_export.h" 0015 #include "request.h" 0016 0017 #include <memory> 0018 0019 class QDBusObjectPath; 0020 0021 namespace BluezQt 0022 { 0023 /** 0024 * @class BluezQt::MediaEndpoint MediaEndpoint.h <BluezQt/MediaEndpoint> 0025 * 0026 * Bluetooth MediaEndpoint. 0027 * 0028 * This class represents a Bluetooth MediaEndpoint. 0029 */ 0030 class BLUEZQT_EXPORT MediaEndpoint : public QObject 0031 { 0032 Q_OBJECT 0033 0034 public: 0035 /** Role which this MediaEndpoint acts as. */ 0036 enum class Role { 0037 AudioSource, 0038 AudioSink, 0039 }; 0040 0041 // KF6 TODO: use types from mediatypes.h 0042 /** Codec which this MediaEndpoint supports. */ 0043 enum class Codec { 0044 Sbc, 0045 Aac, 0046 }; 0047 0048 /** Configuration for MediaEndpoint construction. */ 0049 struct Configuration { 0050 Role role; 0051 Codec codec; 0052 }; 0053 0054 /** 0055 * Creates a new MediaEndpoint object. 0056 * 0057 * @param parent 0058 */ 0059 explicit MediaEndpoint(const Configuration &configuration, QObject *parent = nullptr); 0060 0061 /** 0062 * Destroys a MediaEndpoint object. 0063 */ 0064 ~MediaEndpoint() override; 0065 0066 /** 0067 * D-Bus object path of the MediaEndpoint. 0068 * 0069 * The path where the MediaEndpoint will be registered. 0070 * 0071 * @note You must provide valid object path! 0072 * 0073 * @return object path of MediaEndpoint 0074 */ 0075 virtual QDBusObjectPath objectPath() const; 0076 0077 /** 0078 * Properties of the endpoint. 0079 * 0080 * @return Properties of the endpoint 0081 */ 0082 virtual const QVariantMap &properties() const; 0083 0084 /** 0085 * Set configuration for the transport. 0086 * 0087 * @param transport transport to be configured 0088 * @param properties properties to be set for transport 0089 */ 0090 virtual void setConfiguration(const QString &transportObjectPath, const QVariantMap &properties); 0091 0092 /** 0093 * Select preferable configuration from the supported capabilities. 0094 * 0095 * @note There is no need to cache the selected configuration since on success 0096 * the configuration is send back as parameter of SetConfiguration. 0097 * 0098 * @param capabilities supported capabilities 0099 * @param request request to be used for sending reply 0100 */ 0101 virtual void selectConfiguration(const QByteArray &capabilities, const Request<QByteArray> &request); 0102 0103 /** 0104 * Clear transport configuration. 0105 */ 0106 virtual void clearConfiguration(const QString &transportObjectPath); 0107 0108 /** 0109 * Indicates that the MediaEndpoint was unregistered. 0110 * 0111 * This method gets called when the Bluetooth daemon 0112 * unregisters the MediaEndpoint. 0113 * 0114 * An MediaEndpoint can use it to do cleanup tasks. There is no need 0115 * to unregister the MediaEndpoint, because when this method gets called 0116 * it has already been unregistered. 0117 */ 0118 virtual void release(); 0119 0120 Q_SIGNALS: 0121 /** 0122 * Indicates that configuration was selected. 0123 */ 0124 void configurationSelected(const QByteArray &capabilities, const QByteArray &configuration); 0125 0126 /** 0127 * Indicates that configuration was set for transport. 0128 */ 0129 void configurationSet(const QString &transportObjectPath, const QVariantMap &properties); 0130 0131 /** 0132 * Indicates that configuration was cleared for transport. 0133 */ 0134 void configurationCleared(const QString &transportObjectPath); 0135 0136 private: 0137 std::unique_ptr<class MediaEndpointPrivate> const d; 0138 }; 0139 0140 } // namespace BluezQt 0141 0142 #endif // BLUEZQT_MEDIAENDPOINT_H