File indexing completed on 2024-12-08 12:15:35

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