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 | #include "mediaendpoint_p.h" |
10 | |
11 | #include "a2dp-codecs.h" |
12 | #include "services.h" |
13 | |
14 | namespace BluezQt |
15 | { |
16 | MediaEndpointPrivate::MediaEndpointPrivate(const MediaEndpoint::Configuration &configuration) |
17 | : m_configuration(configuration) |
18 | { |
19 | init(configuration); |
20 | } |
21 | |
22 | void MediaEndpointPrivate::init(const MediaEndpoint::Configuration &configuration) |
23 | { |
24 | const QString uuid = QStringLiteral("UUID"); |
25 | const QString codec = QStringLiteral("Codec"); |
26 | const QString capabilities = QStringLiteral("Capabilities"); |
27 | |
28 | QString objectPath = QStringLiteral("/MediaEndpoint"); |
29 | |
30 | switch (configuration.role) { |
31 | case MediaEndpoint::Role::AudioSource: |
32 | m_properties[uuid] = Services::AudioSource; |
33 | objectPath += QStringLiteral("/Source"); |
34 | break; |
35 | case MediaEndpoint::Role::AudioSink: |
36 | m_properties[uuid] = Services::AudioSink; |
37 | objectPath += QStringLiteral("/Sink"); |
38 | break; |
39 | } |
40 | |
41 | switch (configuration.codec) { |
42 | case MediaEndpoint::Codec::Sbc: |
43 | m_properties[codec] = QVariant::fromValue(value: uchar(A2DP_CODEC_SBC)); |
44 | m_properties[capabilities] = QByteArray(reinterpret_cast<const char *>(&sbcCapabilities), sizeof(sbcCapabilities)); |
45 | objectPath += QStringLiteral("/Sbc"); |
46 | break; |
47 | case MediaEndpoint::Codec::Aac: |
48 | m_properties[codec] = QVariant::fromValue(value: uchar(A2DP_CODEC_MPEG24)); |
49 | m_properties[capabilities] = QByteArray(reinterpret_cast<const char *>(&aacCapabilities), sizeof(aacCapabilities)); |
50 | objectPath += QStringLiteral("/Aac"); |
51 | break; |
52 | } |
53 | |
54 | m_objectPath.setPath(objectPath); |
55 | } |
56 | |
57 | } // namespace BluezQt |
58 |