1 /*
2 * Copyright 2024 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #include "avrcp_sdp_service.h"
18
19 #include <mutex>
20
21 #include "stack/include/avrc_api.h"
22 #include "stack/include/bt_uuid16.h"
23
24 namespace bluetooth::avrcp {
25 std::shared_ptr<AvrcpSdpService> AvrcpSdpService::instance_ = nullptr; // Static member definition
26
Get()27 std::shared_ptr<AvrcpSdpService> AvrcpSdpService::Get() {
28 static std::once_flag onceFlag;
29 std::call_once(onceFlag, []() { instance_ = std::make_shared<AvrcpSdpService>(); });
30 return instance_;
31 }
32
AddRecord(const AvrcpSdpRecord & add_sdp_record_request,uint16_t & request_id)33 uint16_t AvrcpSdpService::AddRecord(const AvrcpSdpRecord& add_sdp_record_request,
34 uint16_t& request_id) {
35 if (add_sdp_record_request.service_uuid == UUID_SERVCLASS_AV_REM_CTRL_TARGET) {
36 return target_sdp_record_helper_.AddRecord(add_sdp_record_request, request_id);
37 } else if (add_sdp_record_request.service_uuid == UUID_SERVCLASS_AV_REMOTE_CONTROL) {
38 return control_sdp_record_helper_.AddRecord(add_sdp_record_request, request_id);
39 }
40 return AVRC_FAIL;
41 }
42
EnableCovertArt(const uint16_t service_uuid,uint16_t cover_art_psm,const uint16_t request_id)43 uint16_t AvrcpSdpService::EnableCovertArt(const uint16_t service_uuid, uint16_t cover_art_psm,
44 const uint16_t request_id) {
45 if (service_uuid == UUID_SERVCLASS_AV_REM_CTRL_TARGET) {
46 return target_sdp_record_helper_.EnableCovertArt(cover_art_psm, request_id);
47 } else if (service_uuid == UUID_SERVCLASS_AV_REMOTE_CONTROL) {
48 return control_sdp_record_helper_.EnableCovertArt(cover_art_psm, request_id);
49 }
50 return AVRC_FAIL;
51 }
52
DisableCovertArt(const uint16_t service_uuid,const uint16_t request_id)53 uint16_t AvrcpSdpService::DisableCovertArt(const uint16_t service_uuid, const uint16_t request_id) {
54 if (service_uuid == UUID_SERVCLASS_AV_REM_CTRL_TARGET) {
55 return target_sdp_record_helper_.DisableCovertArt(request_id);
56 } else if (service_uuid == UUID_SERVCLASS_AV_REMOTE_CONTROL) {
57 return control_sdp_record_helper_.DisableCovertArt(request_id);
58 }
59 return AVRC_FAIL;
60 }
61
RemoveRecord(const uint16_t service_uuid,const uint16_t request_id)62 uint16_t AvrcpSdpService::RemoveRecord(const uint16_t service_uuid, const uint16_t request_id) {
63 if (service_uuid == UUID_SERVCLASS_AV_REM_CTRL_TARGET) {
64 return target_sdp_record_helper_.RemoveRecord(request_id);
65 } else if (service_uuid == UUID_SERVCLASS_AV_REMOTE_CONTROL) {
66 return control_sdp_record_helper_.RemoveRecord(request_id);
67 }
68 return AVRC_FAIL;
69 }
70
71 } // namespace bluetooth::avrcp
72