From b6ad9c09a7584519808a931ddc14095e9da516b6 Mon Sep 17 00:00:00 2001 From: cold Date: Tue, 30 Jul 2024 10:01:33 +0800 Subject: [PATCH] add camera ndk interfaces Signed-off-by: cold --- multimedia/camera_framework/BUILD.gn | 2 + multimedia/camera_framework/camera.ndk.json | 36 ++++++++ multimedia/camera_framework/camera_manager.h | 14 +++ multimedia/camera_framework/photo_native.h | 89 +++++++++++++++++++ multimedia/camera_framework/photo_output.h | 92 ++++++++++++++++++++ 5 files changed, 233 insertions(+) create mode 100644 multimedia/camera_framework/photo_native.h diff --git a/multimedia/camera_framework/BUILD.gn b/multimedia/camera_framework/BUILD.gn index 5193d84e0..2773cb88b 100644 --- a/multimedia/camera_framework/BUILD.gn +++ b/multimedia/camera_framework/BUILD.gn @@ -23,6 +23,7 @@ ohos_ndk_headers("camera_ndk_header") { "./camera_manager.h", "./capture_session.h", "./metadata_output.h", + "./photo_native.h", "./photo_output.h", "./preview_output.h", "./video_output.h", @@ -44,5 +45,6 @@ ohos_ndk_library("libohcamera") { "ohcamera/photo_output.h", "ohcamera/preview_output.h", "ohcamera/video_output.h", + "ohcamera/photo_native.h", ] } diff --git a/multimedia/camera_framework/camera.ndk.json b/multimedia/camera_framework/camera.ndk.json index 52bbf5fc0..a7dc48282 100644 --- a/multimedia/camera_framework/camera.ndk.json +++ b/multimedia/camera_framework/camera.ndk.json @@ -83,6 +83,10 @@ "first_introduced": "12", "name": "OH_CameraManager_CreatePhotoOutputUsedInPreconfig" }, + { + "first_introduced": "12", + "name": "OH_CameraManager_CreatePhotoOutputWithoutSurface" + }, { "first_introduced": "11", "name": "OH_CameraManager_CreateVideoOutput" @@ -343,6 +347,22 @@ "first_introduced": "11", "name": "OH_PhotoOutput_Capture" }, + { + "first_introduced": "12", + "name": "OH_PhotoOutput_RegisterPhotoAvailableCallback" + }, + { + "first_introduced": "12", + "name": "OH_PhotoOutput_UnregisterPhotoAvailableCallback" + }, + { + "first_introduced": "12", + "name": "OH_PhotoOutput_RegisterPhotoAssetAvailableCallback" + }, + { + "first_introduced": "12", + "name": "OH_PhotoOutput_UnregisterPhotoAssetAvailableCallback" + }, { "first_introduced": "11", "name": "OH_PhotoOutput_Capture_WithCaptureSetting" @@ -363,6 +383,14 @@ "first_introduced": "12", "name": "OH_PhotoOutput_DeleteProfile" }, + { + "first_introduced": "12", + "name": "OH_PhotoOutput_IsMovingPhotoSupported" + }, + { + "first_introduced": "12", + "name": "OH_PhotoOutput_EnableMovingPhoto" + }, { "first_introduced": "11", "name": "OH_PreviewOutput_RegisterCallback" @@ -422,5 +450,13 @@ { "first_introduced": "12", "name": "OH_CameraDevice_GetCameraOrientation" + }, + { + "first_introduced": "12", + "name": "OH_PhotoNative_GetMainImage" + }, + { + "first_introduced": "12", + "name": "OH_PhotoNative_Release" } ] diff --git a/multimedia/camera_framework/camera_manager.h b/multimedia/camera_framework/camera_manager.h index 90e55cec7..ae649aea3 100644 --- a/multimedia/camera_framework/camera_manager.h +++ b/multimedia/camera_framework/camera_manager.h @@ -281,6 +281,20 @@ Camera_ErrorCode OH_CameraManager_CreatePhotoOutput(Camera_Manager* cameraManage Camera_ErrorCode OH_CameraManager_CreatePhotoOutputUsedInPreconfig(Camera_Manager* cameraManager, const char* surfaceId, Camera_PhotoOutput** photoOutput); +/** + * @brief Create a photo output instance without surfaceId. + * + * @param cameraManager the {@link Camera_Manager} instance. + * @param profile the {@link Camera_Profile} to create {@link Camera_PhotoOutput}. + * @param photoOutput the {@link Camera_PhotoOutput} will be created if the method call succeeds. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error. + * @since 12 + */ +Camera_ErrorCode OH_CameraManager_CreatePhotoOutputWithoutSurface(Camera_Manager *cameraManager, + const Camera_Profile *profile, Camera_PhotoOutput **photoOutput); + /** * @brief Create a video output instance. * diff --git a/multimedia/camera_framework/photo_native.h b/multimedia/camera_framework/photo_native.h new file mode 100644 index 000000000..216883119 --- /dev/null +++ b/multimedia/camera_framework/photo_native.h @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @addtogroup OH_Camera + * @{ + * + * @brief Provide the definition of the C interface for the camera module. + * + * @syscap SystemCapability.Multimedia.Camera.Core + * + * @since 12 + * @version 1.0 + */ + +/** + * @file photo_native.h + * + * @brief Declare the camera photo concepts. + * + * @library libohcamera.so + * @syscap SystemCapability.Multimedia.Camera.Core + * @since 12 + * @version 1.0 + */ + +#ifndef NATIVE_INCLUDE_PHOTO_NATIVE_H +#define NATIVE_INCLUDE_PHOTO_NATIVE_H + +#include +#include +#include "camera.h" +#include "multimedia/image_framework/image/image_native.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Camera photo object + * + * A pointer can be created using {@link OH_PhotoNative} method. + * + * @since 12 + * @version 1.0 + */ +typedef struct OH_PhotoNative OH_PhotoNative; + +/** + * @brief Get main image. + * + * @param photo the {@link OH_PhotoNative} instance. + * @param main the {@link OH_ImageNative} which use to get main image. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * @since 12 + * @version 1.0 + */ +Camera_ErrorCode OH_PhotoNative_GetMainImage(OH_PhotoNative* photo, OH_ImageNative* mainImage); + +/** + * @brief Release camera photo. + * + * @param photo the {@link OH_PhotoNative} instance to released. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * @since 12 + * @version 1.0 + */ +Camera_ErrorCode OH_PhotoNative_Release(OH_PhotoNative* photo); + +#ifdef __cplusplus +} +#endif + +#endif // NATIVE_INCLUDE_PHOTO_NATIVE_H +/** @} */ \ No newline at end of file diff --git a/multimedia/camera_framework/photo_output.h b/multimedia/camera_framework/photo_output.h index 273455d17..f26524075 100644 --- a/multimedia/camera_framework/photo_output.h +++ b/multimedia/camera_framework/photo_output.h @@ -42,6 +42,8 @@ #include #include #include "camera.h" +#include "photo_native.h" +#include "multimedia/media_library/media_asset_base_capi.h" #ifdef __cplusplus extern "C" { @@ -94,6 +96,24 @@ typedef void (*OH_PhotoOutput_OnFrameEnd)(Camera_PhotoOutput* photoOutput, int32 */ typedef void (*OH_PhotoOutput_OnError)(Camera_PhotoOutput* photoOutput, Camera_ErrorCode errorCode); +/** + * @brief Photo output available high-resolution images callback. + * + * @param photoOutput the {@link Camera_PhotoOutput} which deliver the callback. + * @param photo the {@link OH_PhotoNative} which delivered by the callback. + * @since 12 + */ +typedef void (*OH_PhotoOutput_PhotoAvailable)(Camera_PhotoOutput* photoOutput, OH_PhotoNative* photo); + +/** + * @brief Photo output photo asset available callback. + * + * @param photoOutput the {@link Camera_PhotoOutput} which deliver the callback. + * @param photoAsset the {@link OH_MediaAsset} which delivered by the callback. + * @since 12 + */ +typedef void (*OH_PhotoOutput_PhotoAssetAvailable)(Camera_PhotoOutput* photoOutput, OH_MediaAsset* photoAsset); + /** * @brief A listener for photo output. * @@ -145,6 +165,54 @@ Camera_ErrorCode OH_PhotoOutput_RegisterCallback(Camera_PhotoOutput* photoOutput */ Camera_ErrorCode OH_PhotoOutput_UnregisterCallback(Camera_PhotoOutput* photoOutput, PhotoOutput_Callbacks* callback); +/** + * @brief Register photo output photo available callback. + * + * @param photoOutput the {@link Camera_PhotoOutput} instance. + * @param callback the {@link OH_PhotoOutput_PhotoAvailable} to be registered. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * @since 12 + */ +Camera_ErrorCode OH_PhotoOutput_RegisterPhotoAvailableCallback(Camera_PhotoOutput* photoOutput, + OH_PhotoOutput_PhotoAvailable callback); + +/** + * @brief Unregister photo output photo available callback. + * + * @param photoOutput the {@link Camera_PhotoOutput} instance. + * @param callback the {@link PhotoOutput_Callbacks} to be unregistered. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * @since 12 + */ +Camera_ErrorCode OH_PhotoOutput_UnregisterPhotoAvailableCallback(Camera_PhotoOutput* photoOutput, + OH_PhotoOutput_PhotoAvailable callback); + +/** + * @brief Register photo output photo asset available callback. + * + * @param photoOutput the {@link Camera_PhotoOutput} instance. + * @param callback the {@link OH_PhotoOutput_PhotoAssetAvailable} to be registered. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * @since 12 + */ +Camera_ErrorCode OH_PhotoOutput_RegisterPhotoAssetAvailableCallback(Camera_PhotoOutput* photoOutput, + OH_PhotoOutput_PhotoAssetAvailable callback); + +/** + * @brief Unregister photo output photo asset available callback. + * + * @param photoOutput the {@link Camera_PhotoOutput} instance. + * @param callback the {@link OH_PhotoOutput_PhotoAssetAvailable} to be unregistered. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * @since 12 + */ +Camera_ErrorCode OH_PhotoOutput_UnregisterPhotoAssetAvailableCallback(Camera_PhotoOutput* photoOutput, + OH_PhotoOutput_PhotoAssetAvailable callback); + /** * @brief Capture photo. * @@ -215,6 +283,30 @@ Camera_ErrorCode OH_PhotoOutput_GetActiveProfile(Camera_PhotoOutput* photoOutput */ Camera_ErrorCode OH_PhotoOutput_DeleteProfile(Camera_Profile* profile); +/** + * @brief Check whether to support moving photo. + * + * @param photoOutput the {@link Camera_PhotoOutput} instance which used to check whether moving photo supported. + * @param isSupported the result of whether moving photo supported. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error. + * @since 12 + */ +Camera_ErrorCode OH_PhotoOutput_IsMovingPhotoSupported(Camera_PhotoOutput* photoOutput, bool* isSupported); + +/** + * @brief Enable moving photo or not. + * + * @param photoOutput the {@link Camera_PhotoOutput} instance which used to enable moving photo or not. + * @param enabled the flag of enable moving photo or not. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error. + * @since 12 + */ +Camera_ErrorCode OH_PhotoOutput_EnableMovingPhoto(Camera_PhotoOutput* photoOutput, bool enabled); + #ifdef __cplusplus } #endif -- Gitee