1 /*
2  * Copyright (c) 2023 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 "stream_operator_service_callback.h"
17 #include "camera_service_type_converter.h"
18 
19 namespace OHOS::Camera {
StreamOperatorServiceCallback(OHOS::sptr<IStreamOperatorCallback> streamOperatorCallback)20 StreamOperatorServiceCallback::StreamOperatorServiceCallback(OHOS::sptr<IStreamOperatorCallback> streamOperatorCallback)
21     : streamOperatorCallback_(streamOperatorCallback)
22 {
23 }
24 
OnCaptureStarted(int32_t captureId,const std::vector<int32_t> & streamIds)25 int32_t StreamOperatorServiceCallback::OnCaptureStarted(int32_t captureId, const std::vector<int32_t> &streamIds)
26 {
27     CHECK_IF_PTR_NULL_RETURN_VALUE(streamOperatorCallback_, OHOS::HDI::Camera::V1_0::INVALID_ARGUMENT);
28     return streamOperatorCallback_->OnCaptureStarted(captureId, streamIds);
29 }
30 
OnCaptureEnded(int32_t captureId,const std::vector<VdiCaptureEndedInfo> & infos)31 int32_t StreamOperatorServiceCallback::OnCaptureEnded(int32_t captureId, const std::vector<VdiCaptureEndedInfo> &infos)
32 {
33     CHECK_IF_PTR_NULL_RETURN_VALUE(streamOperatorCallback_, OHOS::HDI::Camera::V1_0::INVALID_ARGUMENT);
34     std::vector<CaptureEndedInfo> hdiInfos;
35     for (auto info : infos) {
36         CaptureEndedInfo hdiInfo;
37         ConvertCaptureEndedInfoVdiToHdi(info, hdiInfo);
38         hdiInfos.push_back(hdiInfo);
39     }
40     return streamOperatorCallback_->OnCaptureEnded(captureId, hdiInfos);
41 }
42 
OnCaptureError(int32_t captureId,const std::vector<VdiCaptureErrorInfo> & infos)43 int32_t StreamOperatorServiceCallback::OnCaptureError(int32_t captureId, const std::vector<VdiCaptureErrorInfo> &infos)
44 {
45     CHECK_IF_PTR_NULL_RETURN_VALUE(streamOperatorCallback_, OHOS::HDI::Camera::V1_0::INVALID_ARGUMENT);
46     std::vector<CaptureErrorInfo> hdiInfos;
47     for (auto info : infos) {
48         CaptureErrorInfo hdiInfo;
49         ConvertCaptureErrorInfoVdiToHdi(info, hdiInfo);
50         hdiInfos.push_back(hdiInfo);
51     }
52     return streamOperatorCallback_->OnCaptureError(captureId, hdiInfos);
53 }
54 
OnFrameShutter(int32_t captureId,const std::vector<int32_t> & streamIds,uint64_t timestamp)55 int32_t StreamOperatorServiceCallback::OnFrameShutter(int32_t captureId,
56     const std::vector<int32_t> &streamIds, uint64_t timestamp)
57 {
58     CHECK_IF_PTR_NULL_RETURN_VALUE(streamOperatorCallback_, OHOS::HDI::Camera::V1_0::INVALID_ARGUMENT);
59     return streamOperatorCallback_->OnFrameShutter(captureId, streamIds, timestamp);
60 }
61 
62 } // end namespace OHOS::Camera
63