1 /*
2  * Copyright (c) 2021-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 #include "dcamera_sink_controller_state_callback.h"
17 
18 #include "distributed_hardware_log.h"
19 
20 namespace OHOS {
21 namespace DistributedHardware {
DCameraSinkControllerStateCallback(std::shared_ptr<DCameraSinkController> & controller)22 DCameraSinkControllerStateCallback::DCameraSinkControllerStateCallback(
23     std::shared_ptr<DCameraSinkController>& controller) : controller_(controller)
24 {
25 }
26 
OnStateChanged(std::shared_ptr<DCameraEvent> & event)27 void DCameraSinkControllerStateCallback::OnStateChanged(std::shared_ptr<DCameraEvent>& event)
28 {
29     std::shared_ptr<DCameraSinkController> controller = controller_.lock();
30     if (controller == nullptr) {
31         DHLOGE("DCameraSinkControllerStateCallback::OnStateChanged controller is null");
32         return;
33     }
34     controller->OnStateChanged(event);
35 }
36 
OnMetadataResult(std::vector<std::shared_ptr<DCameraSettings>> & settings)37 void DCameraSinkControllerStateCallback::OnMetadataResult(std::vector<std::shared_ptr<DCameraSettings>>& settings)
38 {
39     std::shared_ptr<DCameraSinkController> controller = controller_.lock();
40     if (controller == nullptr) {
41         DHLOGE("DCameraSinkControllerStateCallback::OnMetadataResult controller is null");
42         return;
43     }
44     controller->OnMetadataResult(settings);
45 }
46 } // namespace DistributedHardware
47 } // namespace OHOS