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