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_data_process_listener.h"
17 
18 #include "distributed_hardware_log.h"
19 
20 namespace OHOS {
21 namespace DistributedHardware {
DCameraSinkDataProcessListener(std::shared_ptr<DCameraSinkDataProcess> & dataProcess)22 DCameraSinkDataProcessListener::DCameraSinkDataProcessListener(
23     std::shared_ptr<DCameraSinkDataProcess>& dataProcess) : dataProcess_(dataProcess)
24 {
25 }
26 
OnProcessedVideoBuffer(const std::shared_ptr<DataBuffer> & videoResult)27 void DCameraSinkDataProcessListener::OnProcessedVideoBuffer(const std::shared_ptr<DataBuffer>& videoResult)
28 {
29     std::shared_ptr<DCameraSinkDataProcess> dataProcess = dataProcess_.lock();
30     if (dataProcess == nullptr) {
31         DHLOGE("DCameraSinkDataProcessListener::OnProcessedVideoBuffer dataProcess is null");
32         return;
33     }
34     dataProcess->OnProcessedVideoBuffer(videoResult);
35 }
36 
OnError(DataProcessErrorType errorType)37 void DCameraSinkDataProcessListener::OnError(DataProcessErrorType errorType)
38 {
39     std::shared_ptr<DCameraSinkDataProcess> dataProcess = dataProcess_.lock();
40     if (dataProcess == nullptr) {
41         DHLOGE("DCameraSinkDataProcessListener::OnError dataProcess is null");
42         return;
43     }
44     dataProcess->OnError(errorType);
45 }
46 } // namespace DistributedHardware
47 } // namespace OHOS