1e41f4b71Sopenharmony_ci# Camera Recording Sample (C/C++)
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ciThis topic provides sample code that covers the complete recording process and the API calling sequence. For details about a single process (such as device input, session management, and recording), see the corresponding C/C++ development guide links provided in [Camera Development Preparations](camera-preparation.md).
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci## Development Process
6e41f4b71Sopenharmony_ci
7e41f4b71Sopenharmony_ciAfter obtaining the output stream capabilities supported by the camera, create a video stream. The development process is as follows:
8e41f4b71Sopenharmony_ci
9e41f4b71Sopenharmony_ci![Recording Development Process](figures/recording-ndk-development-process.png)
10e41f4b71Sopenharmony_ci
11e41f4b71Sopenharmony_ci## Sample Code
12e41f4b71Sopenharmony_ci
13e41f4b71Sopenharmony_ci1. Link the dynamic library in the CMake script.
14e41f4b71Sopenharmony_ci    ```txt
15e41f4b71Sopenharmony_ci        target_link_libraries(entry PUBLIC libohcamera.so libhilog_ndk.z.so)
16e41f4b71Sopenharmony_ci    ```
17e41f4b71Sopenharmony_ci
18e41f4b71Sopenharmony_ci2. Import the NDK APIs on the C++ side, and perform recording based on the surface ID passed in.
19e41f4b71Sopenharmony_ci    ```c++
20e41f4b71Sopenharmony_ci    #include "hilog/log.h"
21e41f4b71Sopenharmony_ci    #include "ohcamera/camera.h"
22e41f4b71Sopenharmony_ci    #include "ohcamera/camera_input.h"
23e41f4b71Sopenharmony_ci    #include "ohcamera/capture_session.h"
24e41f4b71Sopenharmony_ci    #include "ohcamera/photo_output.h"
25e41f4b71Sopenharmony_ci    #include "ohcamera/preview_output.h"
26e41f4b71Sopenharmony_ci    #include "ohcamera/video_output.h"
27e41f4b71Sopenharmony_ci    #include "ohcamera/camera_manager.h"
28e41f4b71Sopenharmony_ci
29e41f4b71Sopenharmony_ci    void OnCameraInputError(const Camera_Input* cameraInput, Camera_ErrorCode errorCode)
30e41f4b71Sopenharmony_ci    {
31e41f4b71Sopenharmony_ci        OH_LOG_INFO(LOG_APP, "OnCameraInput errorCode = %{public}d", errorCode);
32e41f4b71Sopenharmony_ci    }
33e41f4b71Sopenharmony_ci
34e41f4b71Sopenharmony_ci    CameraInput_Callbacks* GetCameraInputListener(void)
35e41f4b71Sopenharmony_ci    {
36e41f4b71Sopenharmony_ci        static CameraInput_Callbacks cameraInputCallbacks = {
37e41f4b71Sopenharmony_ci            .onError = OnCameraInputError
38e41f4b71Sopenharmony_ci        };
39e41f4b71Sopenharmony_ci        return &cameraInputCallbacks;
40e41f4b71Sopenharmony_ci    }
41e41f4b71Sopenharmony_ci
42e41f4b71Sopenharmony_ci    void CaptureSessionOnFocusStateChange(Camera_CaptureSession* session, Camera_FocusState focusState)
43e41f4b71Sopenharmony_ci    {
44e41f4b71Sopenharmony_ci        OH_LOG_INFO(LOG_APP, "CaptureSessionOnFocusStateChange");
45e41f4b71Sopenharmony_ci    }
46e41f4b71Sopenharmony_ci
47e41f4b71Sopenharmony_ci    void CaptureSessionOnError(Camera_CaptureSession* session, Camera_ErrorCode errorCode)
48e41f4b71Sopenharmony_ci    {
49e41f4b71Sopenharmony_ci        OH_LOG_INFO(LOG_APP, "CaptureSessionOnError = %{public}d", errorCode);
50e41f4b71Sopenharmony_ci    }
51e41f4b71Sopenharmony_ci
52e41f4b71Sopenharmony_ci    CaptureSession_Callbacks* GetCaptureSessionRegister(void)
53e41f4b71Sopenharmony_ci    {
54e41f4b71Sopenharmony_ci        static CaptureSession_Callbacks captureSessionCallbacks = {
55e41f4b71Sopenharmony_ci            .onFocusStateChange = CaptureSessionOnFocusStateChange,
56e41f4b71Sopenharmony_ci            .onError = CaptureSessionOnError
57e41f4b71Sopenharmony_ci        };
58e41f4b71Sopenharmony_ci        return &captureSessionCallbacks;
59e41f4b71Sopenharmony_ci    }
60e41f4b71Sopenharmony_ci
61e41f4b71Sopenharmony_ci    void VideoOutputOnFrameStart(Camera_VideoOutput* videoOutput)
62e41f4b71Sopenharmony_ci    {
63e41f4b71Sopenharmony_ci        OH_LOG_INFO(LOG_APP, "VideoOutputOnFrameStart");
64e41f4b71Sopenharmony_ci    }
65e41f4b71Sopenharmony_ci
66e41f4b71Sopenharmony_ci    void VideoOutputOnFrameEnd(Camera_VideoOutput* videoOutput, int32_t frameCount)
67e41f4b71Sopenharmony_ci    {
68e41f4b71Sopenharmony_ci        OH_LOG_INFO(LOG_APP, "VideoOutput frameCount = %{public}d", frameCount);
69e41f4b71Sopenharmony_ci    }
70e41f4b71Sopenharmony_ci
71e41f4b71Sopenharmony_ci    void VideoOutputOnError(Camera_VideoOutput* videoOutput, Camera_ErrorCode errorCode)
72e41f4b71Sopenharmony_ci    {
73e41f4b71Sopenharmony_ci        OH_LOG_INFO(LOG_APP, "VideoOutput errorCode = %{public}d", errorCode);
74e41f4b71Sopenharmony_ci    }
75e41f4b71Sopenharmony_ci
76e41f4b71Sopenharmony_ci    VideoOutput_Callbacks* GetVideoOutputListener(void)
77e41f4b71Sopenharmony_ci    {
78e41f4b71Sopenharmony_ci        static VideoOutput_Callbacks videoOutputListener = {
79e41f4b71Sopenharmony_ci            .onFrameStart = VideoOutputOnFrameStart,
80e41f4b71Sopenharmony_ci            .onFrameEnd = VideoOutputOnFrameEnd,
81e41f4b71Sopenharmony_ci            .onError = VideoOutputOnError
82e41f4b71Sopenharmony_ci        };
83e41f4b71Sopenharmony_ci        return &videoOutputListener;
84e41f4b71Sopenharmony_ci    }
85e41f4b71Sopenharmony_ci
86e41f4b71Sopenharmony_ci    void CameraManagerStatusCallback(Camera_Manager* cameraManager, Camera_StatusInfo* status)
87e41f4b71Sopenharmony_ci    {
88e41f4b71Sopenharmony_ci        OH_LOG_INFO(LOG_APP, "CameraManagerStatusCallback is called");
89e41f4b71Sopenharmony_ci    }
90e41f4b71Sopenharmony_ci
91e41f4b71Sopenharmony_ci    CameraManager_Callbacks* GetCameraManagerListener()
92e41f4b71Sopenharmony_ci    {
93e41f4b71Sopenharmony_ci        static CameraManager_Callbacks cameraManagerListener = {
94e41f4b71Sopenharmony_ci            .onCameraStatus = CameraManagerStatusCallback
95e41f4b71Sopenharmony_ci        };
96e41f4b71Sopenharmony_ci        return &cameraManagerListener;
97e41f4b71Sopenharmony_ci    }
98e41f4b71Sopenharmony_ci
99e41f4b71Sopenharmony_ci    NDKCamera::NDKCamera(char *previewId, char *videoId)
100e41f4b71Sopenharmony_ci    {
101e41f4b71Sopenharmony_ci        Camera_Manager* cameraManager = nullptr;
102e41f4b71Sopenharmony_ci        Camera_Device* cameras = nullptr;
103e41f4b71Sopenharmony_ci        Camera_CaptureSession* captureSession = nullptr;
104e41f4b71Sopenharmony_ci        Camera_OutputCapability* cameraOutputCapability = nullptr;
105e41f4b71Sopenharmony_ci        Camera_VideoOutput* videoOutput = nullptr;
106e41f4b71Sopenharmony_ci        const Camera_Profile* previewProfile = nullptr;
107e41f4b71Sopenharmony_ci        const Camera_Profile* photoProfile = nullptr;
108e41f4b71Sopenharmony_ci        const Camera_VideoProfile* videoProfile = nullptr;
109e41f4b71Sopenharmony_ci        Camera_PreviewOutput* previewOutput = nullptr;
110e41f4b71Sopenharmony_ci        Camera_PhotoOutput* photoOutput = nullptr;
111e41f4b71Sopenharmony_ci        Camera_Input* cameraInput = nullptr;
112e41f4b71Sopenharmony_ci        uint32_t size = 0;
113e41f4b71Sopenharmony_ci        uint32_t cameraDeviceIndex = 0;
114e41f4b71Sopenharmony_ci        char* videoSurfaceId = videoId;
115e41f4b71Sopenharmony_ci        char* previewSurfaceId = previewId;
116e41f4b71Sopenharmony_ci        // Create a CameraManager object.
117e41f4b71Sopenharmony_ci        Camera_ErrorCode ret = OH_Camera_GetCameraManager(&cameraManager);
118e41f4b71Sopenharmony_ci        if (cameraManager == nullptr || ret != CAMERA_OK) {
119e41f4b71Sopenharmony_ci            OH_LOG_ERROR(LOG_APP, "OH_Camera_GetCameraMananger failed.");
120e41f4b71Sopenharmony_ci        }
121e41f4b71Sopenharmony_ci        // Listen for camera status changes.
122e41f4b71Sopenharmony_ci        ret = OH_CameraManager_RegisterCallback(cameraManager, GetCameraManagerListener());
123e41f4b71Sopenharmony_ci        if (ret != CAMERA_OK) {
124e41f4b71Sopenharmony_ci            OH_LOG_ERROR(LOG_APP, "OH_CameraManager_RegisterCallback failed.");
125e41f4b71Sopenharmony_ci        }
126e41f4b71Sopenharmony_ci
127e41f4b71Sopenharmony_ci        // Obtain the camera list.
128e41f4b71Sopenharmony_ci        ret = OH_CameraManager_GetSupportedCameras(cameraManager, &cameras, &size);
129e41f4b71Sopenharmony_ci        if (cameras == nullptr || size < 0 || ret != CAMERA_OK) {
130e41f4b71Sopenharmony_ci            OH_LOG_ERROR(LOG_APP, "OH_CameraManager_GetSupportedCameras failed.");
131e41f4b71Sopenharmony_ci        }
132e41f4b71Sopenharmony_ci
133e41f4b71Sopenharmony_ci        for (int index = 0; index < size; index++) {
134e41f4b71Sopenharmony_ci            OH_LOG_ERROR(LOG_APP, "cameraId  =  %{public}s ", cameras[index].cameraId);              // Obtain the camera ID.
135e41f4b71Sopenharmony_ci            OH_LOG_ERROR(LOG_APP, "cameraPosition  =  %{public}d ", cameras[index].cameraPosition);  // Obtain the camera position.
136e41f4b71Sopenharmony_ci            OH_LOG_ERROR(LOG_APP, "cameraType  =  %{public}d ", cameras[index].cameraType);          // Obtain the camera type.
137e41f4b71Sopenharmony_ci            OH_LOG_ERROR(LOG_APP, "connectionType  =  %{public}d ", cameras[index].connectionType);  // Obtain the camera connection type.
138e41f4b71Sopenharmony_ci        }
139e41f4b71Sopenharmony_ci
140e41f4b71Sopenharmony_ci        // Obtain the output streams supported by the camera.
141e41f4b71Sopenharmony_ci        ret = OH_CameraManager_GetSupportedCameraOutputCapability(cameraManager, &cameras[cameraDeviceIndex],
142e41f4b71Sopenharmony_ci                                                                &cameraOutputCapability);
143e41f4b71Sopenharmony_ci        if (cameraOutputCapability == nullptr || ret != CAMERA_OK) {
144e41f4b71Sopenharmony_ci            OH_LOG_ERROR(LOG_APP, "OH_CameraManager_GetSupportedCameraOutputCapability failed.");
145e41f4b71Sopenharmony_ci        }
146e41f4b71Sopenharmony_ci
147e41f4b71Sopenharmony_ci        if (cameraOutputCapability->previewProfilesSize < 0) {
148e41f4b71Sopenharmony_ci            OH_LOG_ERROR(LOG_APP, "previewProfilesSize == null");
149e41f4b71Sopenharmony_ci        }
150e41f4b71Sopenharmony_ci        previewProfile = cameraOutputCapability->previewProfiles[0];
151e41f4b71Sopenharmony_ci
152e41f4b71Sopenharmony_ci        if (cameraOutputCapability->photoProfilesSize < 0) {
153e41f4b71Sopenharmony_ci            OH_LOG_ERROR(LOG_APP, "photoProfilesSize == null");
154e41f4b71Sopenharmony_ci        }
155e41f4b71Sopenharmony_ci        photoProfile = cameraOutputCapability->photoProfiles[0];
156e41f4b71Sopenharmony_ci
157e41f4b71Sopenharmony_ci        if (cameraOutputCapability->videoProfilesSize < 0) {
158e41f4b71Sopenharmony_ci            OH_LOG_ERROR(LOG_APP, "videorofilesSize == null");
159e41f4b71Sopenharmony_ci        }
160e41f4b71Sopenharmony_ci        videoProfile = cameraOutputCapability->videoProfiles[0];
161e41f4b71Sopenharmony_ci
162e41f4b71Sopenharmony_ci        // Create a VideoOutput instance.
163e41f4b71Sopenharmony_ci        ret = OH_CameraManager_CreateVideoOutput(cameraManager, videoProfile, videoSurfaceId, &videoOutput);
164e41f4b71Sopenharmony_ci        if (videoProfile == nullptr || videoOutput == nullptr || ret != CAMERA_OK) {
165e41f4b71Sopenharmony_ci            OH_LOG_ERROR(LOG_APP, "OH_CameraManager_CreateVideoOutput failed.");
166e41f4b71Sopenharmony_ci        }
167e41f4b71Sopenharmony_ci
168e41f4b71Sopenharmony_ci        // Listen for video output errors.
169e41f4b71Sopenharmony_ci        ret = OH_VideoOutput_RegisterCallback(videoOutput, GetVideoOutputListener());
170e41f4b71Sopenharmony_ci        if (ret != CAMERA_OK) {
171e41f4b71Sopenharmony_ci            OH_LOG_ERROR(LOG_APP, "OH_VideoOutput_RegisterCallback failed.");
172e41f4b71Sopenharmony_ci        }
173e41f4b71Sopenharmony_ci
174e41f4b71Sopenharmony_ci        // Create a session.
175e41f4b71Sopenharmony_ci        ret = OH_CameraManager_CreateCaptureSession(cameraManager, &captureSession);
176e41f4b71Sopenharmony_ci        if (captureSession == nullptr || ret != CAMERA_OK) {
177e41f4b71Sopenharmony_ci            OH_LOG_ERROR(LOG_APP, "OH_CameraManager_CreateCaptureSession failed.");
178e41f4b71Sopenharmony_ci        }
179e41f4b71Sopenharmony_ci        // Listen for session errors.
180e41f4b71Sopenharmony_ci        ret = OH_CaptureSession_RegisterCallback(captureSession, GetCaptureSessionRegister());
181e41f4b71Sopenharmony_ci        if (ret != CAMERA_OK) {
182e41f4b71Sopenharmony_ci            OH_LOG_ERROR(LOG_APP, "OH_CaptureSession_RegisterCallback failed.");
183e41f4b71Sopenharmony_ci        }
184e41f4b71Sopenharmony_ci
185e41f4b71Sopenharmony_ci        // Start configuration for the session.
186e41f4b71Sopenharmony_ci        ret = OH_CaptureSession_BeginConfig(captureSession);
187e41f4b71Sopenharmony_ci        if (ret != CAMERA_OK) {
188e41f4b71Sopenharmony_ci            OH_LOG_ERROR(LOG_APP, "OH_CaptureSession_BeginConfig failed.");
189e41f4b71Sopenharmony_ci        }
190e41f4b71Sopenharmony_ci
191e41f4b71Sopenharmony_ci        // Create a camera input stream.
192e41f4b71Sopenharmony_ci        ret = OH_CameraManager_CreateCameraInput(cameraManager, &cameras[cameraDeviceIndex], &cameraInput);
193e41f4b71Sopenharmony_ci        if (cameraInput == nullptr || ret != CAMERA_OK) {
194e41f4b71Sopenharmony_ci            OH_LOG_ERROR(LOG_APP, "OH_CameraManager_CreateCameraInput failed.");
195e41f4b71Sopenharmony_ci        }
196e41f4b71Sopenharmony_ci
197e41f4b71Sopenharmony_ci        // Listen for camera input errors.
198e41f4b71Sopenharmony_ci        ret = OH_CameraInput_RegisterCallback(cameraInput, GetCameraInputListener());
199e41f4b71Sopenharmony_ci        if (ret != CAMERA_OK) {
200e41f4b71Sopenharmony_ci            OH_LOG_ERROR(LOG_APP, "OH_CameraInput_RegisterCallback failed.");
201e41f4b71Sopenharmony_ci        }
202e41f4b71Sopenharmony_ci
203e41f4b71Sopenharmony_ci        // Open the camera.
204e41f4b71Sopenharmony_ci        ret = OH_CameraInput_Open(cameraInput);
205e41f4b71Sopenharmony_ci        if (ret != CAMERA_OK) {
206e41f4b71Sopenharmony_ci            OH_LOG_ERROR(LOG_APP, "OH_CameraInput_Open failed.");
207e41f4b71Sopenharmony_ci        }
208e41f4b71Sopenharmony_ci
209e41f4b71Sopenharmony_ci        // Add the camera input stream to the session.
210e41f4b71Sopenharmony_ci        ret = OH_CaptureSession_AddInput(captureSession, cameraInput);
211e41f4b71Sopenharmony_ci        if (ret != CAMERA_OK) {
212e41f4b71Sopenharmony_ci            OH_LOG_ERROR(LOG_APP, "OH_CaptureSession_AddInput failed.");
213e41f4b71Sopenharmony_ci        }
214e41f4b71Sopenharmony_ci
215e41f4b71Sopenharmony_ci        // Create a preview output stream. For details about the surfaceId parameter, see the <XComponent>. The preview stream is the surface provided by the <XComponent>.
216e41f4b71Sopenharmony_ci        ret = OH_CameraManager_CreatePreviewOutput(cameraManager, previewProfile, 0, &previewOutput);
217e41f4b71Sopenharmony_ci        if (previewProfile == nullptr || previewOutput == nullptr || ret != CAMERA_OK) {
218e41f4b71Sopenharmony_ci            OH_LOG_ERROR(LOG_APP, "OH_CameraManager_CreatePreviewOutput failed.");
219e41f4b71Sopenharmony_ci        }
220e41f4b71Sopenharmony_ci
221e41f4b71Sopenharmony_ci        // Add the preview output stream to the session.
222e41f4b71Sopenharmony_ci        ret = OH_CaptureSession_AddPreviewOutput(captureSession, previewOutput);
223e41f4b71Sopenharmony_ci        if (ret != CAMERA_OK) {
224e41f4b71Sopenharmony_ci            OH_LOG_ERROR(LOG_APP, "OH_CaptureSession_AddPreviewOutput failed.");
225e41f4b71Sopenharmony_ci        }
226e41f4b71Sopenharmony_ci
227e41f4b71Sopenharmony_ci        // Add the video output stream to the session.
228e41f4b71Sopenharmony_ci        ret = OH_CaptureSession_AddVideoOutput(captureSession, videoOutput);
229e41f4b71Sopenharmony_ci        if (ret != CAMERA_OK) {
230e41f4b71Sopenharmony_ci            OH_LOG_ERROR(LOG_APP, "OH_CaptureSession_AddVideoOutput failed.");
231e41f4b71Sopenharmony_ci        }
232e41f4b71Sopenharmony_ci
233e41f4b71Sopenharmony_ci        // Commit the session configuration.
234e41f4b71Sopenharmony_ci        ret = OH_CaptureSession_CommitConfig(captureSession);
235e41f4b71Sopenharmony_ci        if (ret != CAMERA_OK) {
236e41f4b71Sopenharmony_ci            OH_LOG_ERROR(LOG_APP, "OH_CaptureSession_CommitConfig failed.");
237e41f4b71Sopenharmony_ci        }
238e41f4b71Sopenharmony_ci
239e41f4b71Sopenharmony_ci        // Start the session.
240e41f4b71Sopenharmony_ci        ret = OH_CaptureSession_Start(captureSession);
241e41f4b71Sopenharmony_ci        if (ret != CAMERA_OK) {
242e41f4b71Sopenharmony_ci            OH_LOG_ERROR(LOG_APP, "OH_CaptureSession_Start failed.");
243e41f4b71Sopenharmony_ci        }
244e41f4b71Sopenharmony_ci
245e41f4b71Sopenharmony_ci        // Start the video output stream.
246e41f4b71Sopenharmony_ci        ret = OH_VideoOutput_Start(videoOutput);
247e41f4b71Sopenharmony_ci        if (ret != CAMERA_OK) {
248e41f4b71Sopenharmony_ci            OH_LOG_ERROR(LOG_APP, "OH_VideoOutput_Start failed.");
249e41f4b71Sopenharmony_ci        }
250e41f4b71Sopenharmony_ci
251e41f4b71Sopenharmony_ci        // Call avRecorder.start() on the TS side to start video recording.
252e41f4b71Sopenharmony_ci
253e41f4b71Sopenharmony_ci        // Stop the video output stream.
254e41f4b71Sopenharmony_ci        ret = OH_VideoOutput_Stop(videoOutput);
255e41f4b71Sopenharmony_ci        if (ret != CAMERA_OK) {
256e41f4b71Sopenharmony_ci            OH_LOG_ERROR(LOG_APP, "OH_VideoOutput_Stop failed.");
257e41f4b71Sopenharmony_ci        }
258e41f4b71Sopenharmony_ci
259e41f4b71Sopenharmony_ci        // Call avRecorder.stop() on the TS side to stop video recording.
260e41f4b71Sopenharmony_ci
261e41f4b71Sopenharmony_ci        // Stop the session.
262e41f4b71Sopenharmony_ci        ret = OH_CaptureSession_Stop(captureSession);
263e41f4b71Sopenharmony_ci        if (ret == CAMERA_OK) {
264e41f4b71Sopenharmony_ci            OH_LOG_INFO(LOG_APP, "OH_CaptureSession_Stop success ");
265e41f4b71Sopenharmony_ci        } else {
266e41f4b71Sopenharmony_ci            OH_LOG_ERROR(LOG_APP, "OH_CaptureSession_Stop failed. %d ", ret);
267e41f4b71Sopenharmony_ci        }
268e41f4b71Sopenharmony_ci
269e41f4b71Sopenharmony_ci        // Release the camera input stream.
270e41f4b71Sopenharmony_ci        ret = OH_CameraInput_Close(cameraInput);
271e41f4b71Sopenharmony_ci        if (ret == CAMERA_OK) {
272e41f4b71Sopenharmony_ci            OH_LOG_INFO(LOG_APP, "OH_CameraInput_Close success ");
273e41f4b71Sopenharmony_ci        } else {
274e41f4b71Sopenharmony_ci            OH_LOG_ERROR(LOG_APP, "OH_CameraInput_Close failed. %d ", ret);
275e41f4b71Sopenharmony_ci        }
276e41f4b71Sopenharmony_ci
277e41f4b71Sopenharmony_ci        // Release the preview output stream.
278e41f4b71Sopenharmony_ci        ret = OH_PreviewOutput_Release(previewOutput);
279e41f4b71Sopenharmony_ci        if (ret == CAMERA_OK) {
280e41f4b71Sopenharmony_ci            OH_LOG_INFO(LOG_APP, "OH_PreviewOutput_Release success ");
281e41f4b71Sopenharmony_ci        } else {
282e41f4b71Sopenharmony_ci            OH_LOG_ERROR(LOG_APP, "OH_PreviewOutput_Release failed. %d ", ret);
283e41f4b71Sopenharmony_ci        }
284e41f4b71Sopenharmony_ci
285e41f4b71Sopenharmony_ci        // Release the video output stream.
286e41f4b71Sopenharmony_ci        ret = OH_VideoOutput_Release(videoOutput);
287e41f4b71Sopenharmony_ci        if (ret == CAMERA_OK) {
288e41f4b71Sopenharmony_ci            OH_LOG_INFO(LOG_APP, "OH_VideoOutput_Release success ");
289e41f4b71Sopenharmony_ci        } else {
290e41f4b71Sopenharmony_ci            OH_LOG_ERROR(LOG_APP, "OH_VideoOutput_Release failed. %d ", ret);
291e41f4b71Sopenharmony_ci        }
292e41f4b71Sopenharmony_ci
293e41f4b71Sopenharmony_ci        // Release the session.
294e41f4b71Sopenharmony_ci        ret = OH_CaptureSession_Release(captureSession);
295e41f4b71Sopenharmony_ci        if (ret == CAMERA_OK) {
296e41f4b71Sopenharmony_ci            OH_LOG_INFO(LOG_APP, "OH_CaptureSession_Release success ");
297e41f4b71Sopenharmony_ci        } else {
298e41f4b71Sopenharmony_ci            OH_LOG_ERROR(LOG_APP, "OH_CaptureSession_Release failed. %d ", ret);
299e41f4b71Sopenharmony_ci        }
300e41f4b71Sopenharmony_ci    }
301e41f4b71Sopenharmony_ci    ```
302