1 /* 2 * Copyright (c) 2022 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 OHOS_DAUDIO_IPC_CALLBACK_H 17 #define OHOS_DAUDIO_IPC_CALLBACK_H 18 19 #include <map> 20 #include <mutex> 21 22 #include "daudio_ipc_callback_stub.h" 23 #include "idistributed_hardware_source.h" 24 25 namespace OHOS { 26 namespace DistributedHardware { 27 class DAudioIpcCallback : public DAudioIpcCallbackStub { 28 public: 29 DAudioIpcCallback() = default; 30 ~DAudioIpcCallback() override = default; 31 32 int32_t OnNotifyRegResult(const std::string &devId, const std::string &dhId, const std::string &reqId, 33 int32_t status, const std::string &resultData) override; 34 int32_t OnNotifyUnregResult(const std::string &devId, const std::string &dhId, const std::string &reqId, 35 int32_t status, const std::string &resultData) override; 36 37 void PushRegisterCallback(const std::string &reqId, const std::shared_ptr<RegisterCallback> &callback); 38 void PopRegisterCallback(const std::string &reqId); 39 void PushUnregisterCallback(const std::string &reqId, const std::shared_ptr<UnregisterCallback> &callback); 40 void PopUnregisterCallback(const std::string &reqId); 41 42 private: 43 std::mutex registerMapMtx_; 44 std::map<std::string, std::shared_ptr<RegisterCallback>> registerCallbackMap_; 45 std::mutex unregisterMapMtx_; 46 std::map<std::string, std::shared_ptr<UnregisterCallback>> unregisterCallbackMap_; 47 }; 48 } // DistributedHardware 49 } // OHOS 50 #endif // OHOS_DAUDIO_IPC_CALLBACK_H