1 /* 2 * Copyright (c) 2021-2023 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_DCAMERA_SOURCE_CALLBACK_H 17 #define OHOS_DCAMERA_SOURCE_CALLBACK_H 18 19 #include <map> 20 #include <mutex> 21 22 #include "dcamera_source_callback_stub.h" 23 #include "idistributed_hardware_source.h" 24 25 namespace OHOS { 26 namespace DistributedHardware { 27 class DCameraSourceCallback : public DCameraSourceCallbackStub { 28 public: 29 DCameraSourceCallback() = default; 30 ~DCameraSourceCallback() override; 31 32 int32_t OnNotifyRegResult(const std::string& devId, const std::string& dhId, const std::string& reqId, 33 int32_t status, std::string& data) override; 34 int32_t OnNotifyUnregResult(const std::string& devId, const std::string& dhId, const std::string& reqId, 35 int32_t status, std::string& data) override; 36 37 void PushRegCallback(std::string& reqId, std::shared_ptr<RegisterCallback>& callback); 38 void PopRegCallback(std::string& reqId); 39 void PushUnregCallback(std::string& reqId, std::shared_ptr<UnregisterCallback>& callback); 40 void PopUnregCallback(std::string& reqId); 41 private: 42 std::map<std::string, std::shared_ptr<RegisterCallback>> regCallbacks_; 43 std::map<std::string, std::shared_ptr<UnregisterCallback>> unregCallbacks_; 44 std::mutex mapMutex_; 45 }; 46 } // namespace DistributedHardware 47 } // namespace OHOS 48 #endif // OHOS_DCAMERA_SOURCE_CALLBACK_H 49