1 /* 2 * Copyright (c) 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 DCAMERA_SOFTBUS_LATENCY_H 17 #define DCAMERA_SOFTBUS_LATENCY_H 18 19 #include <string> 20 #include <map> 21 #include <mutex> 22 23 #include "single_instance.h" 24 25 namespace OHOS { 26 namespace DistributedHardware { 27 class DCameraSoftbusLatency { 28 DECLARE_SINGLE_INSTANCE_BASE(DCameraSoftbusLatency); 29 public: 30 int32_t StartSoftbusTimeSync(const std::string& devId); 31 int32_t StopSoftbusTimeSync(const std::string& devId); 32 void SetTimeSyncInfo(const int32_t microsecond, const std::string& devId); 33 int32_t GetTimeSyncInfo(const std::string& devId); 34 private: 35 DCameraSoftbusLatency() = default; 36 ~DCameraSoftbusLatency() = default; 37 38 private: 39 constexpr static int32_t REF_INITIAL = 0; 40 constexpr static int32_t REF_NORMAL = 1; 41 std::mutex offsetLock_; 42 std::mutex micLock_; 43 std::map<std::string, int32_t> offsets_; 44 std::map<std::string, int32_t> refCount_; 45 }; 46 } // namespace DistributedHardware 47 } // namespace OHOS 48 #endif // DCAMERA_SOFTBUS_LATENCY_H