1 /*
2 * Copyright (c) 2021 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_source_controller_channel_listener.h"
17
18 #include "distributed_camera_errno.h"
19 #include "distributed_hardware_log.h"
20
21 #include "dcamera_source_controller.h"
22
23 namespace OHOS {
24 namespace DistributedHardware {
DCameraSourceControllerChannelListener(std::shared_ptr<DCameraSourceController> & controller)25 DCameraSourceControllerChannelListener::DCameraSourceControllerChannelListener(
26 std::shared_ptr<DCameraSourceController>& controller) : controller_(controller)
27 {
28 }
29
~DCameraSourceControllerChannelListener()30 DCameraSourceControllerChannelListener::~DCameraSourceControllerChannelListener()
31 {
32 }
33
OnSessionState(int32_t state)34 void DCameraSourceControllerChannelListener::OnSessionState(int32_t state)
35 {
36 std::shared_ptr<DCameraSourceController> controller = controller_.lock();
37 if (controller == nullptr) {
38 DHLOGE("DCameraSourceController OnSessionState not found controller");
39 return;
40 }
41
42 controller->OnSessionState(state);
43 }
44
OnSessionError(int32_t eventType,int32_t eventReason,std::string detail)45 void DCameraSourceControllerChannelListener::OnSessionError(int32_t eventType, int32_t eventReason, std::string detail)
46 {
47 std::shared_ptr<DCameraSourceController> controller = controller_.lock();
48 if (controller == nullptr) {
49 DHLOGE("DCameraSourceController OnSessionError not found controller");
50 return;
51 }
52
53 controller->OnSessionError(eventType, eventReason, detail);
54 }
55
OnDataReceived(std::vector<std::shared_ptr<DataBuffer>> & buffers)56 void DCameraSourceControllerChannelListener::OnDataReceived(std::vector<std::shared_ptr<DataBuffer>>& buffers)
57 {
58 std::shared_ptr<DCameraSourceController> controller = controller_.lock();
59 if (controller == nullptr) {
60 DHLOGE("DCameraSourceController OnDataReceived not found controller");
61 return;
62 }
63
64 controller->OnDataReceived(buffers);
65 }
66 } // namespace DistributedHardware
67 } // namespace OHOS
68