• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 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 TELEPHONY_DISTRIBUTED_DATA_SINK_CONTROLLER_H
17 #define TELEPHONY_DISTRIBUTED_DATA_SINK_CONTROLLER_H
18 
19 #include <map>
20 #include "ffrt.h"
21 #include "distributed_data_controller.h"
22 
23 namespace OHOS {
24 namespace Telephony {
25 class DistributedDataSinkController : public DistributedDataController,
26                                       public std::enable_shared_from_this<DistributedDataSinkController> {
27 public:
28     DistributedDataSinkController() = default;
29     ~DistributedDataSinkController() override = default;
OnDeviceOnline(const std::string & devId,const std::string & devName,AudioDeviceType devType)30     void OnDeviceOnline(const std::string &devId, const std::string &devName, AudioDeviceType devType) override {}
OnDeviceOffline(const std::string & devId,const std::string & devName,AudioDeviceType devType)31     void OnDeviceOffline(const std::string &devId, const std::string &devName, AudioDeviceType devType) override {}
32     void OnCallCreated(const sptr<CallBase> &call, const std::string &devId) override;
33     void OnCallDestroyed() override;
34     void ProcessCallInfo(const sptr<CallBase> &call, DistributedDataType type) override;
35     void OnConnected() override;
36 
37 protected:
38     void HandleRecvMsg(int32_t msgType, const cJSON *msg) override;
39 
40 private:
41     void ConnectRemote(const std::string &devId);
42     void CheckLocalData(const sptr<CallBase> &call, DistributedDataType type);
43     std::string CreateDataReqMsg(DistributedMsgType msgType, uint32_t itemType, const std::string &num);
44     void SendDataQueryReq();
45     void HandleDataQueryRsp(const cJSON *msg);
46     void UpdateCallName(sptr<CallBase> &call, const cJSON *msg);
47     void UpdateCallLocation(sptr<CallBase> &call, const cJSON *msg);
48     void ReportCallInfo(const sptr<CallBase> &call);
49     std::string CreateCurrentDataReqMsg(const std::string &num);
50     void SendCurrentDataQueryReq();
51     void HandleCurrentDataQueryRsp(const cJSON *msg);
52 
53 private:
54     ffrt::mutex mutex_{};
55     std::map<std::string, uint32_t> queryInfo_{};
56 };
57 
58 } // namespace Telephony
59 } // namespace OHOS
60 
61 #endif // TELEPHONY_DISTRIBUTED_DATA_SINK_CONTROLLER_H
62