• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "dcamera_sink_callback.h"
17 
18 #include "anonymous_string.h"
19 #include "distributed_camera_errno.h"
20 #include "distributed_hardware_log.h"
21 
22 namespace OHOS {
23 namespace DistributedHardware {
~DCameraSinkCallback()24 DCameraSinkCallback::~DCameraSinkCallback()
25 {
26     privacyResCallback_.clear();
27 }
28 
OnNotifyResourceInfo(const ResourceEventType & type,const std::string & subtype,const std::string & networkId,bool & isSensitive,bool & isSameAccout)29 int32_t DCameraSinkCallback::OnNotifyResourceInfo(const ResourceEventType &type, const std::string &subtype,
30     const std::string &networkId, bool &isSensitive, bool &isSameAccout)
31 {
32     DHLOGI("DCameraSinkCallback OnNotifyResourceInfo type: %{public}d, subtype: %{public}s, networkId: %{public}s, "
33         "isSensitive: %{public}d, isSameAccout: %{public}d", (uint32_t)type, subtype.c_str(),
34         GetAnonyString(networkId).c_str(), isSensitive, isSameAccout);
35     int32_t ret = DCAMERA_OK;
36     std::lock_guard<std::mutex> lock(privacyResMutex_);
37     auto iter = privacyResCallback_.begin();
38     if (iter != privacyResCallback_.end()) {
39         if (*iter != nullptr) {
40             ret = (*iter)->OnPrivaceResourceMessage(type, subtype, networkId, isSensitive, isSameAccout);
41         }
42     }
43     return ret;
44 }
45 
PushPrivacyResCallback(const std::shared_ptr<PrivacyResourcesListener> & listener)46 void DCameraSinkCallback::PushPrivacyResCallback(const std::shared_ptr<PrivacyResourcesListener> &listener)
47 {
48     DHLOGI("push resource info callback.");
49     std::lock_guard<std::mutex> lock(privacyResMutex_);
50     privacyResCallback_.push_back(listener);
51 }
52 } // namespace DistributedHardware
53 } // namespace OHOS
54