File indexing completed on 2024-12-01 12:29:49
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 #include "mediaendpoint_p.h" 0010 0011 #include "a2dp-codecs.h" 0012 #include "services.h" 0013 0014 namespace BluezQt 0015 { 0016 MediaEndpointPrivate::MediaEndpointPrivate(const MediaEndpoint::Configuration &configuration) 0017 : m_configuration(configuration) 0018 { 0019 init(configuration); 0020 } 0021 0022 void MediaEndpointPrivate::init(const MediaEndpoint::Configuration &configuration) 0023 { 0024 const QString uuid = QStringLiteral("UUID"); 0025 const QString codec = QStringLiteral("Codec"); 0026 const QString capabilities = QStringLiteral("Capabilities"); 0027 0028 QString objectPath = QStringLiteral("/MediaEndpoint"); 0029 0030 switch (configuration.role) { 0031 case MediaEndpoint::Role::AudioSource: 0032 m_properties[uuid] = Services::AudioSource; 0033 objectPath += QStringLiteral("/Source"); 0034 break; 0035 case MediaEndpoint::Role::AudioSink: 0036 m_properties[uuid] = Services::AudioSink; 0037 objectPath += QStringLiteral("/Sink"); 0038 break; 0039 } 0040 0041 switch (configuration.codec) { 0042 case MediaEndpoint::Codec::Sbc: 0043 m_properties[codec] = QVariant::fromValue(uchar(A2DP_CODEC_SBC)); 0044 m_properties[capabilities] = QByteArray(reinterpret_cast<const char *>(&sbcCapabilities), sizeof(sbcCapabilities)); 0045 objectPath += QStringLiteral("/Sbc"); 0046 break; 0047 case MediaEndpoint::Codec::Aac: 0048 m_properties[codec] = QVariant::fromValue(uchar(A2DP_CODEC_MPEG24)); 0049 m_properties[capabilities] = QByteArray(reinterpret_cast<const char *>(&aacCapabilities), sizeof(aacCapabilities)); 0050 objectPath += QStringLiteral("/Aac"); 0051 break; 0052 } 0053 0054 m_objectPath.setPath(objectPath); 0055 } 0056 0057 } // namespace BluezQt