Changeset View
Changeset View
Standalone View
Standalone View
src/mediaendpoint_p.cpp
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | * BluezQt - Asynchronous Bluez wrapper library | ||||
3 | * | ||||
4 | * Copyright (C) 2018 Manuel Weichselbaumer <mincequi@web.de> | ||||
5 | * | ||||
6 | * This library is free software; you can redistribute it and/or | ||||
7 | * modify it under the terms of the GNU Lesser General Public | ||||
8 | * License as published by the Free Software Foundation; either | ||||
9 | * version 2.1 of the License, or (at your option) version 3, or any | ||||
10 | * later version accepted by the membership of KDE e.V. (or its | ||||
11 | * successor approved by the membership of KDE e.V.), which shall | ||||
12 | * act as a proxy defined in Section 6 of version 3 of the license. | ||||
13 | * | ||||
14 | * This library is distributed in the hope that it will be useful, | ||||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||
17 | * Lesser General Public License for more details. | ||||
18 | * | ||||
19 | * You should have received a copy of the GNU Lesser General Public | ||||
20 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||||
21 | */ | ||||
22 | | ||||
23 | #include "mediaendpoint_p.h" | ||||
24 | | ||||
25 | #include "a2dp-codecs.h" | ||||
26 | #include "services.h" | ||||
27 | | ||||
28 | namespace BluezQt | ||||
29 | { | ||||
30 | | ||||
31 | MediaEndpointPrivate::MediaEndpointPrivate(const MediaEndpoint::Configuration &configuration) | ||||
32 | : m_configuration(configuration) | ||||
33 | { | ||||
34 | init(configuration); | ||||
35 | } | ||||
36 | | ||||
37 | void MediaEndpointPrivate::init(const MediaEndpoint::Configuration &configuration) | ||||
38 | { | ||||
39 | const QString uuid = QStringLiteral("UUID"); | ||||
40 | const QString codec = QStringLiteral("Codec"); | ||||
41 | const QString capabilities = QStringLiteral("Capabilities"); | ||||
42 | | ||||
43 | QString objectPath = QStringLiteral("/MediaEndpoint"); | ||||
44 | | ||||
45 | switch (configuration.role) { | ||||
46 | case MediaEndpoint::Role::AudioSource: | ||||
47 | m_properties[uuid] = Services::AudioSource; | ||||
48 | objectPath += QStringLiteral("/Source"); | ||||
49 | break; | ||||
50 | case MediaEndpoint::Role::AudioSink: | ||||
51 | m_properties[uuid] = Services::AudioSink; | ||||
52 | objectPath += QStringLiteral("/Sink"); | ||||
53 | break; | ||||
54 | } | ||||
55 | | ||||
56 | switch (configuration.codec) { | ||||
57 | case MediaEndpoint::Codec::Sbc: | ||||
58 | m_properties[codec] = QVariant::fromValue(uchar(A2DP_CODEC_SBC)); | ||||
59 | m_properties[capabilities] = QByteArray(reinterpret_cast<const char*>(&sbcCapabilities), sizeof(sbcCapabilities)); | ||||
60 | objectPath += QStringLiteral("/Sbc"); | ||||
61 | break; | ||||
62 | case MediaEndpoint::Codec::Aac: | ||||
63 | m_properties[codec] = QVariant::fromValue(uchar(A2DP_CODEC_MPEG24)); | ||||
64 | m_properties[capabilities] = QByteArray(reinterpret_cast<const char*>(&aacCapabilities), sizeof(aacCapabilities)); | ||||
65 | objectPath += QStringLiteral("/Aac"); | ||||
66 | break; | ||||
67 | } | ||||
68 | | ||||
69 | m_objectPath.setPath(objectPath); | ||||
70 | } | ||||
71 | | ||||
72 | } // namespace BluezQt |