1 /*
2  * Copyright (C) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef A2DP_SDP_H
17 #define A2DP_SDP_H
18 
19 #include <cstdint>
20 #include "a2dp_def.h"
21 #include "btstack.h"
22 #include "sdp.h"
23 
24 /**
25  * @brief The Bluetooth subsystem.
26  */
27 namespace OHOS {
28 namespace bluetooth {
29 #define A2DP_SDP_ATTRIBUTE_NUM 3
30 /**
31  * @brief This class provides a set of methods used to interact with the SDP protocol.
32  */
33 class A2dpSdpManager {
34 public:
35     /**
36      * @brief Constructor.
37      */
A2dpSdpManager()38     A2dpSdpManager(){};
39 
40     /**
41      * @brief Destructor.
42      */
43     ~A2dpSdpManager() = default;
44 
45     /**
46      * @brief The function is set the role of the profile.
47      * @param[in] The role of local profile
48      */
49     void SetProfileRole(uint8_t role);
50 
51     /**
52      * @brief Registers a record of the A2DP target service into the SDP protocol.
53      * @return @c BT_SUCCESS            : The function is executed successfully.
54      *         Other than @c BT_SUCCESS : The function is not executed successfully.
55      */
56     int RegisterService();
57 
58     /**
59      * @brief Unregisters a record of the A2DP target service from the SDP protocol.
60      */
61     int UnregisterService(void) const;
62 
63     /**
64      * @brief Finds a record of controller service from the SDP protocol.
65      * @param[in] addr     The address of the peer device.
66      * @param[in] a2dpInstance The instance of profile
67      * @param[in] callback The callback function that receives the search result.
68      * @return @c BT_SUCCESS            : The function is executed successfully.
69      *         Other than @c BT_SUCCESS : The function is not executed successfully.
70      */
71     int FindSnkService(const BtAddr &addr, void *a2dpInstance, void (*callback)
72         (const BtAddr *addr, const SdpService *serviceArray, uint16_t serviceNum, void *context)) const;
73 
74 private:
75     uint8_t role_ = A2DP_ROLE_SOURCE;
76     uint32_t sdpHandle_ = 0;  // A handle to the SDP service record got from the SDP protocol.
77 };
78 }  // namespace bluetooth
79 }  // namespace OHOS
80 
81 #endif  // A2DP_SDP_H
82