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_sink_controller_channel_listener.h"
17
18 #include "distributed_hardware_log.h"
19
20 namespace OHOS {
21 namespace DistributedHardware {
DCameraSinkControllerChannelListener(std::shared_ptr<DCameraSinkController> & controller)22 DCameraSinkControllerChannelListener::DCameraSinkControllerChannelListener(
23 std::shared_ptr<DCameraSinkController>& controller) : controller_(controller)
24 {
25 }
26
OnSessionState(int32_t state)27 void DCameraSinkControllerChannelListener::OnSessionState(int32_t state)
28 {
29 std::shared_ptr<DCameraSinkController> controller = controller_.lock();
30 if (controller == nullptr) {
31 DHLOGE("DCameraSinkControllerChannelListener::OnSessionState controller is null");
32 return;
33 }
34 controller->OnSessionState(state);
35 }
36
OnSessionError(int32_t eventType,int32_t eventReason,std::string detail)37 void DCameraSinkControllerChannelListener::OnSessionError(int32_t eventType, int32_t eventReason, std::string detail)
38 {
39 std::shared_ptr<DCameraSinkController> controller = controller_.lock();
40 if (controller == nullptr) {
41 DHLOGE("DCameraSinkControllerChannelListener::OnSessionError controller is null");
42 return;
43 }
44 controller->OnSessionError(eventType, eventReason, detail);
45 }
46
OnDataReceived(std::vector<std::shared_ptr<DataBuffer>> & buffers)47 void DCameraSinkControllerChannelListener::OnDataReceived(std::vector<std::shared_ptr<DataBuffer>>& buffers)
48 {
49 std::shared_ptr<DCameraSinkController> controller = controller_.lock();
50 if (controller == nullptr) {
51 DHLOGE("DCameraSinkControllerChannelListener::OnReceivedData controller is null");
52 return;
53 }
54 controller->OnDataReceived(buffers);
55 }
56 } // namespace DistributedHardware
57 } // namespace OHOS