• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023-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 "kits/native/include/camera/photo_output.h"
17 #include "impl/photo_output_impl.h"
18 #include "camera_log.h"
19 #include "hilog/log.h"
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
25 /**
26  * @since 11
27  * @version 1.0
28  */
OH_PhotoOutput_RegisterCallback(Camera_PhotoOutput * photoOutput,PhotoOutput_Callbacks * callback)29 Camera_ErrorCode OH_PhotoOutput_RegisterCallback(Camera_PhotoOutput* photoOutput, PhotoOutput_Callbacks* callback)
30 {
31     CHECK_AND_RETURN_RET_LOG(photoOutput != nullptr, CAMERA_INVALID_ARGUMENT,
32         "invaild argument! photoOutput is null!");
33     CHECK_AND_RETURN_RET_LOG(callback != nullptr, CAMERA_INVALID_ARGUMENT,
34         "invaild argument! callback is null!");
35     CHECK_AND_RETURN_RET_LOG(callback->onFrameStart!= nullptr, CAMERA_INVALID_ARGUMENT,
36         "invaild argument! callback onFrameStart is null!");
37     CHECK_AND_RETURN_RET_LOG(callback->onFrameEnd!= nullptr, CAMERA_INVALID_ARGUMENT,
38         "invaild argument! callback onFrameEnd is null!");
39     CHECK_AND_RETURN_RET_LOG(callback->onFrameShutter!= nullptr, CAMERA_INVALID_ARGUMENT,
40         "invaild argument! callback onFrameShutter is null!");
41     CHECK_AND_RETURN_RET_LOG(callback->onError!= nullptr, CAMERA_INVALID_ARGUMENT,
42         "invaild argument! callback onError is null!");
43 
44     photoOutput->RegisterCallback(callback);
45     return CAMERA_OK;
46 }
47 
48 /**
49  * @since 11
50  * @version 1.0
51  */
OH_PhotoOutput_UnregisterCallback(Camera_PhotoOutput * photoOutput,PhotoOutput_Callbacks * callback)52 Camera_ErrorCode OH_PhotoOutput_UnregisterCallback(Camera_PhotoOutput* photoOutput, PhotoOutput_Callbacks* callback)
53 {
54     CHECK_AND_RETURN_RET_LOG(photoOutput != nullptr, CAMERA_INVALID_ARGUMENT,
55         "invaild argument! photoOutput is null!");
56     CHECK_AND_RETURN_RET_LOG(callback != nullptr, CAMERA_INVALID_ARGUMENT,
57         "invaild argument! callback is null!");
58     CHECK_AND_RETURN_RET_LOG(callback->onFrameStart!= nullptr, CAMERA_INVALID_ARGUMENT,
59         "invaild argument! callback onFrameStart is null!");
60     CHECK_AND_RETURN_RET_LOG(callback->onFrameEnd!= nullptr, CAMERA_INVALID_ARGUMENT,
61         "invaild argument! callback onFrameEnd is null!");
62     CHECK_AND_RETURN_RET_LOG(callback->onError!= nullptr, CAMERA_INVALID_ARGUMENT,
63         "invaild argument! callback onError is null!");
64 
65     photoOutput->UnregisterCallback(callback);
66     return CAMERA_OK;
67 }
68 
69 /**
70  * @since 11
71  * @version 1.0
72  */
OH_PhotoOutput_Capture(Camera_PhotoOutput * photoOutput)73 Camera_ErrorCode OH_PhotoOutput_Capture(Camera_PhotoOutput* photoOutput)
74 {
75     CHECK_AND_RETURN_RET_LOG(photoOutput != nullptr, CAMERA_INVALID_ARGUMENT,
76         "invaild argument! photoOutput is null!");
77 
78     return photoOutput->Capture();
79 }
80 
81 /**
82  * @since 11
83  * @version 1.0
84  */
OH_PhotoOutput_Capture_WithCaptureSetting(Camera_PhotoOutput * photoOutput,Camera_PhotoCaptureSetting setting)85 Camera_ErrorCode OH_PhotoOutput_Capture_WithCaptureSetting(Camera_PhotoOutput* photoOutput,
86     Camera_PhotoCaptureSetting setting)
87 {
88     CHECK_AND_RETURN_RET_LOG(photoOutput != nullptr, CAMERA_INVALID_ARGUMENT,
89         "invaild argument! photoOutput is null!");
90 
91     return photoOutput->Capture_WithCaptureSetting(setting);
92 }
93 
94 /**
95  * @since 11
96  * @version 1.0
97  */
OH_PhotoOutput_Release(Camera_PhotoOutput * photoOutput)98 Camera_ErrorCode OH_PhotoOutput_Release(Camera_PhotoOutput* photoOutput)
99 {
100     CHECK_AND_RETURN_RET_LOG(photoOutput != nullptr, CAMERA_INVALID_ARGUMENT,
101         "invaild argument! photoOutput is null!");
102 
103     Camera_ErrorCode retCode = photoOutput->Release();
104     if (photoOutput != nullptr) {
105         delete photoOutput;
106     }
107     return retCode;
108 }
109 
110 /**
111  * @since 11
112  * @version 1.0
113  */
OH_PhotoOutput_IsMirrorSupported(Camera_PhotoOutput * photoOutput,bool * isSupported)114 Camera_ErrorCode OH_PhotoOutput_IsMirrorSupported(Camera_PhotoOutput* photoOutput, bool* isSupported)
115 {
116     CHECK_AND_RETURN_RET_LOG(photoOutput != nullptr, CAMERA_INVALID_ARGUMENT,
117         "invaild argument! photoOutput is null!");
118     CHECK_AND_RETURN_RET_LOG(isSupported != nullptr, CAMERA_INVALID_ARGUMENT,
119         "invaild argument! isSupported is null!");
120 
121     return photoOutput->IsMirrorSupported(isSupported);
122 }
123 
124 #ifdef __cplusplus
125 }
126 #endif