From 290d262b6a6c6e215a011228fd5192d3688de95c Mon Sep 17 00:00:00 2001 From: Cao Chuan Date: Wed, 15 Nov 2023 23:07:01 +0800 Subject: [PATCH 1/4] Add image creator ndk feature Signed-off-by: Cao Chuan --- multimedia/image_framework/BUILD.gn | 10 + .../include/image_creator_mdk.h | 244 ++++++++++++++++++ .../libimage_creator_ndk.ndk.json | 26 ++ 3 files changed, 280 insertions(+) create mode 100644 multimedia/image_framework/include/image_creator_mdk.h create mode 100644 multimedia/image_framework/libimage_creator_ndk.ndk.json diff --git a/multimedia/image_framework/BUILD.gn b/multimedia/image_framework/BUILD.gn index 833b5fb73..4b4089f10 100644 --- a/multimedia/image_framework/BUILD.gn +++ b/multimedia/image_framework/BUILD.gn @@ -62,3 +62,13 @@ ohos_ndk_headers("image_source_ndk_header") { dest_dir = "$ndk_headers_out_dir/multimedia/image_framework" sources = [ "./include/image_source_mdk.h" ] } + +ohos_ndk_library("libimage_creator_ndk") { + ndk_description_file = "./libimage_creator_ndk.ndk.json" + output_name = "image_creator_ndk" +} + +ohos_ndk_headers("image_creator_ndk_header") { + dest_dir = "$ndk_headers_out_dir/multimedia/image_framework" + sources = [ "./include/image_creator_mdk.h" ] +} diff --git a/multimedia/image_framework/include/image_creator_mdk.h b/multimedia/image_framework/include/image_creator_mdk.h new file mode 100644 index 000000000..fa1bd7af1 --- /dev/null +++ b/multimedia/image_framework/include/image_creator_mdk.h @@ -0,0 +1,244 @@ +/* + * Copyright (C) 2023 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 image + * @{ + * + * @brief Provides APIs for obtaining image data transfer to the native layer. + * + * + * @since 11 + * @version 4.1 + */ + +/** + * @file image_creator_mdk.h + * + * @brief Declares the APIs for obtaining image data transfer to the native layer. + * + * @library libimagendk.z.so + * @library libimage_creator_ndk.z.so + * @syscap SystemCapability.Multimedia.Image + * @since 11 + * @version 4.1 + */ + +#ifndef INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_CREATOR_MDK_H_ +#define INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_CREATOR_MDK_H_ +#include "napi/native_api.h" +#include "image_mdk_common.h" +#include "image_mdk.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Defines an ImageCreator object at the native layer. + * + * @since 11 + * @version 4.1 + */ +struct ImageCreatorNative_; + +/** + * @brief Defines the data type name of a native image creator. + * + * @since 11 + * @version 4.1 + */ +typedef struct ImageCreatorNative_ ImageCreatorNative; + +/** + * @brief Defines the callbacks for images at the native layer. + * + * @since 11 + * @version 4.1 + */ +typedef void (*OH_Image_Creator_On_Callback)(void); + +/** + * @brief Defines the information about an image creator. + * + * @since 11 + * @version 4.1 + */ +struct OhosImageCreatorInfo { + /* Default width of the image received by the consumer, in pixels. */ + int32_t width; + /* Default height of the image received by the consumer, in pixels. */ + int32_t height; + /* Image format {@link OHOS_IMAGE_FORMAT_JPEG} created by using the creator. */ + int32_t format; + /* Maximum number of images that can be cached. */ + int32_t capicity; +}; + +/** + * @brief Creates an ImageCreator object at the application layer. + * + * @param env Indicates the NAPI environment pointer. + * @param info Indicates the options for setting the ImageCreator object. + * @param res Indicates the pointer to the ImageCreator object obtained. + * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. + * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_SURFACE_GET_PARAMETER_FAILED - if Failed to obtain parameters for surface. + * returns {@link IRNdkErrCode} IMAGE_RESULT_CREATE_SURFACE_FAILED - if create surface failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_SURFACE_GRALLOC_BUFFER_FAILED - if surface gralloc buffer failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_GET_SURFACE_FAILED - if get sufrace failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_MEDIA_RTSP_SURFACE_UNSUPPORT - if media rtsp surface not support. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image type unsupported. + * returns {@link IRNdkErrCode} IMAGE_RESULT_MEDIA_DATA_UNSUPPORT - if media type unsupported. + * @since 11 + * @version 4.1 + */ +int32_t OH_Image_Creator_Create(napi_env env, struct OhosImageCreatorInfo info, napi_value* res); + +/** + * @brief Initializes an {@link ImageCreatorNative} object at the native layer + * through an ImageCreator object at the application layer. + * + * @param env Indicates the NAPI environment pointer. + * @param source Indicates an ImageCreator object. + * @return Returns the pointer to the {@link ImageCreatorNative} object obtained if the operation is successful; + * returns a null pointer otherwise. + * @see {@link OH_Image_Creator_Release} + * @since 11 + * @version 4.1 + */ +ImageCreatorNative* OH_Image_Creator_InitNative(napi_env env, napi_value source); + +/** + * @brief Obtains the creator ID through an {@link ImageCreatorNative} object. + * + * @param native Indicates the pointer to an {@link ImageCreatorNative} object at the native layer. + * @param id Indicates the pointer to the buffer that stores the ID string obtained. + * @param len Indicates the size of the buffer. + * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. + * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_SURFACE_GET_PARAMETER_FAILED - if Failed to obtain parameters for surface. + * returns {@link IRNdkErrCode} IMAGE_RESULT_GET_SURFACE_FAILED - if get sufrace failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image type unsupported. + * returns {@link IRNdkErrCode} IMAGE_RESULT_MEDIA_DATA_UNSUPPORT - if media type unsupported. + * @see ImageCreatorNative + * @since 11 + * @version 4.1 + */ +int32_t OH_Image_Creator_Dequeue(const ImageCreatorNative* native, napi_value* image); + +/** + * @brief Obtains the latest image through an {@link ImageCreatorNative} object. + * + * @param native Indicates the pointer to an {@link ImageCreatorNative} object at the native layer. + * @param image Indicates the pointer to an Image object at the application layer. + * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. + * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_SURFACE_GET_PARAMETER_FAILED - if Failed to obtain parameters for surface. + * returns {@link IRNdkErrCode} IMAGE_RESULT_CREATE_SURFACE_FAILED - if create surface failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_SURFACE_GRALLOC_BUFFER_FAILED - if surface gralloc buffer failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_GET_SURFACE_FAILED - if get sufrace failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_MEDIA_RTSP_SURFACE_UNSUPPORT - if media rtsp surface not support. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image type unsupported. + * returns {@link IRNdkErrCode} IMAGE_RESULT_SURFACE_REQUEST_BUFFER_FAILED - if request Buffer failed. + * @see ImageCreatorNative + * @since 11 + * @version 4.1 + */ +int32_t OH_Image_Creator_Queue(const ImageCreatorNative* native, napi_value image); + +/** + * @brief Registers an {@link OH_Image_Creator_On_Callback} callback event. + * + * This callback event is triggered whenever a new image is received. + * + * @param native Indicates the pointer to an {@link ImageCreatorNative} object at the native layer. + * @param callback Indicates the {@link OH_Image_Creator_On_Callback} callback event to register. + * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. + * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_GET_SURFACE_FAILED - if get sufrace failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image type unsupported. + * returns {@link IRNdkErrCode} IMAGE_RESULT_REGISTER_LISTENER_FAILED - if Failed to register listener. + * returns {@link IRNdkErrCode} IMAGE_RESULT_REGISTER_BUFFER_FAILED - if Failed to register buffer. + * @see ImageCreatorNative + * @since 11 + * @version 4.1 + */ +int32_t OH_Image_Creator_On(const ImageCreatorNative* native, OH_Image_Creator_On_Callback callback); + +/** + * @brief Obtains the capacity of the image creator through an {@link ImageCreatorNative} object. + * + * @param native Indicates the pointer to an {@link ImageCreatorNative} object at the native layer. + * @param capacity Indicates the pointer to the capacity obtained. + * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. + * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image type unsupported. + * @see ImageCreatorNative, OhosImageSize + * @since 11 + * @version 4.1 + */ +int32_t OH_Image_Creator_GetCapacity(const ImageCreatorNative* native, int32_t* capacity); + +/** + * @brief Obtains the format of the image creator through an {@link ImageCreatorNative} object. + * + * @param native Indicates the pointer to an {@link ImageCreatorNative} object at the native layer. + * @param format Indicates the pointer to the format obtained. + * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. + * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image type unsupported. + * @see ImageCreatorNative + + * @since 11 + * @version 4.1 + */ +int32_t OH_Image_Creator_GetFormat(const ImageCreatorNative* native, int32_t* format); + +/** + * @brief Releases an {@link ImageCreatorNative} object at the native layer. + * + * This API is not used to release an ImageCreator object at the application layer. + * + * @param native Indicates the pointer to an {@link ImageCreatorNative} object at the native layer. + * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. + * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. + * + * @see {@link OH_Image_Creator_InitNative} + * @see ImageCreatorNative + * @since 11 + * @version 4.1 + */ +int32_t OH_Image_Creator_Release(ImageCreatorNative* native); +#ifdef __cplusplus +}; +#endif +/** @} */ + +#endif // INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_CREATOR_MDK_H_ \ No newline at end of file diff --git a/multimedia/image_framework/libimage_creator_ndk.ndk.json b/multimedia/image_framework/libimage_creator_ndk.ndk.json new file mode 100644 index 000000000..9d5042ca6 --- /dev/null +++ b/multimedia/image_framework/libimage_creator_ndk.ndk.json @@ -0,0 +1,26 @@ +[ + { + "name": "OH_Image_Creator_Create" + }, + { + "name": "OH_Image_Creator_InitNative" + }, + { + "name": "OH_Image_Creator_Dequeue" + }, + { + "name": "OH_Image_Creator_Queue" + }, + { + "name": "OH_Image_Creator_On" + }, + { + "name": "OH_Image_Creator_GetCapacity" + }, + { + "name": "OH_Image_Creator_GetFormat" + }, + { + "name": "OH_Image_Creator_Release" + } +] -- Gitee From ba016a4ee032e1f1ba96df59260db5c3b05ca29a Mon Sep 17 00:00:00 2001 From: Cao Chuan Date: Thu, 16 Nov 2023 14:09:43 +0800 Subject: [PATCH 2/4] Fix api names Signed-off-by: Cao Chuan --- .../include/image_creator_mdk.h | 144 +++++++----------- .../libimage_creator_ndk.ndk.json | 16 +- 2 files changed, 65 insertions(+), 95 deletions(-) diff --git a/multimedia/image_framework/include/image_creator_mdk.h b/multimedia/image_framework/include/image_creator_mdk.h index fa1bd7af1..803498b9f 100644 --- a/multimedia/image_framework/include/image_creator_mdk.h +++ b/multimedia/image_framework/include/image_creator_mdk.h @@ -19,6 +19,9 @@ * * @brief Provides APIs for obtaining image data transfer to the native layer. * + * The channel for transmitting raw image data module part of image module. + * It provided a queue used to transmit raw image data from application layer + * to native layer components * * @since 11 * @version 4.1 @@ -29,6 +32,19 @@ * * @brief Declares the APIs for obtaining image data transfer to the native layer. * + * The image creator module used to obtain a image buffer and transmist raw image data + * via buffer to native layer components. + * + * The following steps are recommended for this process: + * Create an image creator object by calling OH_ImageCreator_Create function. + * And then covert the image creator object to ImageCreatorNative by OH_ImageCreator_InitNative. + * Next obtaining a image object by OH_ImageCreator_Dequeue and fill it with raw image data. + * Queueing the obtained image object by OH_ImageCreator_Queue and the native layer components can + * get the raw image data by graphic private inner apis + * We can register an event listener OH_ImageCreator_On_Callback by OH_ImageCreator_On listener any + * image data has been used. + * Finally, release the ImagePakcerNative by OH_ImageCreator_Release. + * * @library libimagendk.z.so * @library libimage_creator_ndk.z.so * @syscap SystemCapability.Multimedia.Image @@ -46,16 +62,10 @@ extern "C" { #endif -/** - * @brief Defines an ImageCreator object at the native layer. - * - * @since 11 - * @version 4.1 - */ struct ImageCreatorNative_; /** - * @brief Defines the data type name of a native image creator. + * @brief Defines an image creator object at the native layer for the image creator interface. * * @since 11 * @version 4.1 @@ -63,161 +73,126 @@ struct ImageCreatorNative_; typedef struct ImageCreatorNative_ ImageCreatorNative; /** - * @brief Defines the callbacks for images at the native layer. + * @brief Defines the callbacks for image creator at the native layer. * * @since 11 * @version 4.1 */ -typedef void (*OH_Image_Creator_On_Callback)(void); +typedef void (*OH_ImageCreator_On_Callback)(void); /** - * @brief Defines the information about an image creator. + * @brief Defines the image creator options. * * @since 11 * @version 4.1 */ -struct OhosImageCreatorInfo { - /* Default width of the image received by the consumer, in pixels. */ +struct OhosImageCreatorOpts { + /** Default width of the image creator, in pixels. */ int32_t width; - /* Default height of the image received by the consumer, in pixels. */ + /** Default height of the image creator, in pixels. */ int32_t height; - /* Image format {@link OHOS_IMAGE_FORMAT_JPEG} created by using the creator. */ + /** Image format created by using the creator. */ int32_t format; - /* Maximum number of images that can be cached. */ + /** Maximum number of images that can be cached. */ int32_t capicity; }; /** * @brief Creates an ImageCreator object at the application layer. * - * @param env Indicates the NAPI environment pointer. - * @param info Indicates the options for setting the ImageCreator object. - * @param res Indicates the pointer to the ImageCreator object obtained. + * @param env Indicates a pointer to the JavaScript Native Interface (JNI) environment. + * @param opts Indicates the encoding {@link OhosImageCreatorOpts}. + * @param res Indicates a pointer to the ImageCreator object created at the JavaScript native layer. * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. - * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_SURFACE_GET_PARAMETER_FAILED - if Failed to obtain parameters for surface. - * returns {@link IRNdkErrCode} IMAGE_RESULT_CREATE_SURFACE_FAILED - if create surface failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_SURFACE_GRALLOC_BUFFER_FAILED - if surface gralloc buffer failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_GET_SURFACE_FAILED - if get sufrace failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_MEDIA_RTSP_SURFACE_UNSUPPORT - if media rtsp surface not support. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image type unsupported. - * returns {@link IRNdkErrCode} IMAGE_RESULT_MEDIA_DATA_UNSUPPORT - if media type unsupported. + * returns {@link IRNdkErrCode} ERR_IMAGE_INVALID_PARAMETER - if invalid parameter. + * returns {@link IRNdkErrCode} ERR_IMAGE_INIT_ABNORMAL - if environment init abnormal. * @since 11 * @version 4.1 */ -int32_t OH_Image_Creator_Create(napi_env env, struct OhosImageCreatorInfo info, napi_value* res); +int32_t OH_ImageCreator_Create(napi_env env, struct OhosImageCreatorOpts opts, napi_value* res); /** * @brief Initializes an {@link ImageCreatorNative} object at the native layer * through an ImageCreator object at the application layer. * - * @param env Indicates the NAPI environment pointer. - * @param source Indicates an ImageCreator object. + * @param env Indicates a pointer to the JavaScript Native Interface (JNI) environment. + * @param source Indicates a JavaScript native API ImageCreator object. * @return Returns the pointer to the {@link ImageCreatorNative} object obtained if the operation is successful; * returns a null pointer otherwise. - * @see {@link OH_Image_Creator_Release} + * @see {@link OH_ImageCreator_Release} * @since 11 * @version 4.1 */ -ImageCreatorNative* OH_Image_Creator_InitNative(napi_env env, napi_value source); +ImageCreatorNative* OH_ImageCreator_InitNative(napi_env env, napi_value source); /** - * @brief Obtains the creator ID through an {@link ImageCreatorNative} object. + * @brief Obtains an image object from queue through an {@link ImageCreatorNative} object. * * @param native Indicates the pointer to an {@link ImageCreatorNative} object at the native layer. - * @param id Indicates the pointer to the buffer that stores the ID string obtained. - * @param len Indicates the size of the buffer. + * @param image Indicates the pointer to the buffer that stores image object obtained. * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. - * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_SURFACE_GET_PARAMETER_FAILED - if Failed to obtain parameters for surface. + * returns {@link IRNdkErrCode} IMAGE_RESULT_CREATE_SURFACE_FAILED - if create sufrace failed. * returns {@link IRNdkErrCode} IMAGE_RESULT_GET_SURFACE_FAILED - if get sufrace failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image type unsupported. - * returns {@link IRNdkErrCode} IMAGE_RESULT_MEDIA_DATA_UNSUPPORT - if media type unsupported. - * @see ImageCreatorNative + * @see {@link OH_ImageCreator_Queue} * @since 11 * @version 4.1 */ -int32_t OH_Image_Creator_Dequeue(const ImageCreatorNative* native, napi_value* image); +int32_t OH_ImageCreator_Dequeue(const ImageCreatorNative* native, napi_value* image); /** - * @brief Obtains the latest image through an {@link ImageCreatorNative} object. + * @brief Queues an image object into queue through an {@link ImageCreatorNative} object. * * @param native Indicates the pointer to an {@link ImageCreatorNative} object at the native layer. - * @param image Indicates the pointer to an Image object at the application layer. + * @param image Indicates image object obtained. * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. - * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_SURFACE_GET_PARAMETER_FAILED - if Failed to obtain parameters for surface. - * returns {@link IRNdkErrCode} IMAGE_RESULT_CREATE_SURFACE_FAILED - if create surface failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_SURFACE_GRALLOC_BUFFER_FAILED - if surface gralloc buffer failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_GET_SURFACE_FAILED - if get sufrace failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_MEDIA_RTSP_SURFACE_UNSUPPORT - if media rtsp surface not support. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image type unsupported. - * returns {@link IRNdkErrCode} IMAGE_RESULT_SURFACE_REQUEST_BUFFER_FAILED - if request Buffer failed. - * @see ImageCreatorNative + * returns {@link IRNdkErrCode} IMAGE_RESULT_MEDIA_DATA_UNSUPPORT - if invalid parameter. + * @see {@link OH_ImageCreator_Dequeue} * @since 11 * @version 4.1 */ -int32_t OH_Image_Creator_Queue(const ImageCreatorNative* native, napi_value image); +int32_t OH_ImageCreator_Queue(const ImageCreatorNative* native, napi_value image); /** - * @brief Registers an {@link OH_Image_Creator_On_Callback} callback event. + * @brief Registers an {@link OH_ImageCreator_On_Callback} callback event. * - * This callback event is triggered whenever a new image is received. + * This callback event is triggered whenever an image is release by consumer release surface. * * @param native Indicates the pointer to an {@link ImageCreatorNative} object at the native layer. - * @param callback Indicates the {@link OH_Image_Creator_On_Callback} callback event to register. + * @param callback Indicates the {@link OH_ImageCreator_On_Callback} callback event to register. * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. - * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_GET_SURFACE_FAILED - if get sufrace failed. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image type unsupported. - * returns {@link IRNdkErrCode} IMAGE_RESULT_REGISTER_LISTENER_FAILED - if Failed to register listener. - * returns {@link IRNdkErrCode} IMAGE_RESULT_REGISTER_BUFFER_FAILED - if Failed to register buffer. - * @see ImageCreatorNative * @since 11 * @version 4.1 */ -int32_t OH_Image_Creator_On(const ImageCreatorNative* native, OH_Image_Creator_On_Callback callback); +int32_t OH_ImageCreator_On(const ImageCreatorNative* native, OH_ImageCreator_On_Callback callback); /** - * @brief Obtains the capacity of the image creator through an {@link ImageCreatorNative} object. + * @brief Gets the capacity of the image creator through an {@link ImageCreatorNative} object. * * @param native Indicates the pointer to an {@link ImageCreatorNative} object at the native layer. * @param capacity Indicates the pointer to the capacity obtained. * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. - * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image type unsupported. - * @see ImageCreatorNative, OhosImageSize + * @see {@link OH_ImageCreator_Create} * @since 11 * @version 4.1 */ -int32_t OH_Image_Creator_GetCapacity(const ImageCreatorNative* native, int32_t* capacity); +int32_t OH_ImageCreator_GetCapacity(const ImageCreatorNative* native, int32_t* capacity); /** - * @brief Obtains the format of the image creator through an {@link ImageCreatorNative} object. + * @brief Gets the format of the image creator through an {@link ImageCreatorNative} object. * * @param native Indicates the pointer to an {@link ImageCreatorNative} object at the native layer. * @param format Indicates the pointer to the format obtained. * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. - * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image type unsupported. - * @see ImageCreatorNative - + * @see {@link OH_ImageCreator_Create} * @since 11 * @version 4.1 */ -int32_t OH_Image_Creator_GetFormat(const ImageCreatorNative* native, int32_t* format); +int32_t OH_ImageCreator_GetFormat(const ImageCreatorNative* native, int32_t* format); /** * @brief Releases an {@link ImageCreatorNative} object at the native layer. @@ -226,16 +201,11 @@ int32_t OH_Image_Creator_GetFormat(const ImageCreatorNative* native, int32_t* fo * * @param native Indicates the pointer to an {@link ImageCreatorNative} object at the native layer. * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. - * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. - * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. - * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. - * - * @see {@link OH_Image_Creator_InitNative} - * @see ImageCreatorNative + * @see {@link OH_ImageCreator_InitNative} * @since 11 * @version 4.1 */ -int32_t OH_Image_Creator_Release(ImageCreatorNative* native); +int32_t OH_ImageCreator_Release(ImageCreatorNative* native); #ifdef __cplusplus }; #endif diff --git a/multimedia/image_framework/libimage_creator_ndk.ndk.json b/multimedia/image_framework/libimage_creator_ndk.ndk.json index 9d5042ca6..8748e624e 100644 --- a/multimedia/image_framework/libimage_creator_ndk.ndk.json +++ b/multimedia/image_framework/libimage_creator_ndk.ndk.json @@ -1,26 +1,26 @@ [ { - "name": "OH_Image_Creator_Create" + "name": "OH_ImageCreator_Create" }, { - "name": "OH_Image_Creator_InitNative" + "name": "OH_ImageCreator_InitNative" }, { - "name": "OH_Image_Creator_Dequeue" + "name": "OH_ImageCreator_Dequeue" }, { - "name": "OH_Image_Creator_Queue" + "name": "OH_ImageCreator_Queue" }, { - "name": "OH_Image_Creator_On" + "name": "OH_ImageCreator_On" }, { - "name": "OH_Image_Creator_GetCapacity" + "name": "OH_ImageCreator_GetCapacity" }, { - "name": "OH_Image_Creator_GetFormat" + "name": "OH_ImageCreator_GetFormat" }, { - "name": "OH_Image_Creator_Release" + "name": "OH_ImageCreator_Release" } ] -- Gitee From 415ddd185ea6e199275c33a855ded1bc4c1f1dc1 Mon Sep 17 00:00:00 2001 From: Cao Chuan Date: Thu, 16 Nov 2023 17:31:12 +0800 Subject: [PATCH 3/4] Fix for code review Signed-off-by: Cao Chuan --- .../include/image_creator_mdk.h | 60 +++++++++++-------- .../libimage_creator_ndk.ndk.json | 8 +++ 2 files changed, 42 insertions(+), 26 deletions(-) diff --git a/multimedia/image_framework/include/image_creator_mdk.h b/multimedia/image_framework/include/image_creator_mdk.h index 803498b9f..20f634a5f 100644 --- a/multimedia/image_framework/include/image_creator_mdk.h +++ b/multimedia/image_framework/include/image_creator_mdk.h @@ -37,7 +37,7 @@ * * The following steps are recommended for this process: * Create an image creator object by calling OH_ImageCreator_Create function. - * And then covert the image creator object to ImageCreatorNative by OH_ImageCreator_InitNative. + * And then covert the image creator object to ImageCreator_Native by OH_ImageCreator_InitNative. * Next obtaining a image object by OH_ImageCreator_Dequeue and fill it with raw image data. * Queueing the obtained image object by OH_ImageCreator_Queue and the native layer components can * get the raw image data by graphic private inner apis @@ -62,7 +62,7 @@ extern "C" { #endif -struct ImageCreatorNative_; +struct ImageCreator_Native_; /** * @brief Defines an image creator object at the native layer for the image creator interface. @@ -70,7 +70,7 @@ struct ImageCreatorNative_; * @since 11 * @version 4.1 */ -typedef struct ImageCreatorNative_ ImageCreatorNative; +typedef struct ImageCreator_Native_ ImageCreator_Native; /** * @brief Defines the callbacks for image creator at the native layer. @@ -86,7 +86,7 @@ typedef void (*OH_ImageCreator_On_Callback)(void); * @since 11 * @version 4.1 */ -struct OhosImageCreatorOpts { +struct ImageCreator_Opts_ { /** Default width of the image creator, in pixels. */ int32_t width; /** Default height of the image creator, in pixels. */ @@ -97,11 +97,19 @@ struct OhosImageCreatorOpts { int32_t capicity; }; +/** + * @brief Defines alias of image creator options. + * + * @since 11 + * @version 4.1 + */ +typedef struct ImageCreator_Opts_ ImageCreator_Opts; + /** * @brief Creates an ImageCreator object at the application layer. * * @param env Indicates a pointer to the JavaScript Native Interface (JNI) environment. - * @param opts Indicates the encoding {@link OhosImageCreatorOpts}. + * @param opts Indicates the encoding {@link ImageCreator_Opts}. * @param res Indicates a pointer to the ImageCreator object created at the JavaScript native layer. * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. * returns {@link IRNdkErrCode} ERR_IMAGE_INVALID_PARAMETER - if invalid parameter. @@ -109,26 +117,26 @@ struct OhosImageCreatorOpts { * @since 11 * @version 4.1 */ -int32_t OH_ImageCreator_Create(napi_env env, struct OhosImageCreatorOpts opts, napi_value* res); +int32_t OH_ImageCreator_Create(napi_env env, ImageCreator_Opts opts, napi_value* res); /** - * @brief Initializes an {@link ImageCreatorNative} object at the native layer + * @brief Initializes an {@link ImageCreator_Native} object at the native layer * through an ImageCreator object at the application layer. * * @param env Indicates a pointer to the JavaScript Native Interface (JNI) environment. * @param source Indicates a JavaScript native API ImageCreator object. - * @return Returns the pointer to the {@link ImageCreatorNative} object obtained if the operation is successful; + * @return Returns the pointer to the {@link ImageCreator_Native} object obtained if the operation is successful; * returns a null pointer otherwise. * @see {@link OH_ImageCreator_Release} * @since 11 * @version 4.1 */ -ImageCreatorNative* OH_ImageCreator_InitNative(napi_env env, napi_value source); +ImageCreator_Native* OH_ImageCreator_InitNative(napi_env env, napi_value source); /** - * @brief Obtains an image object from queue through an {@link ImageCreatorNative} object. + * @brief Obtains an image object from queue through an {@link ImageCreator_Native} object. * - * @param native Indicates the pointer to an {@link ImageCreatorNative} object at the native layer. + * @param native Indicates the pointer to an {@link ImageCreator_Native} object at the native layer. * @param image Indicates the pointer to the buffer that stores image object obtained. * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. @@ -138,12 +146,12 @@ ImageCreatorNative* OH_ImageCreator_InitNative(napi_env env, napi_value source); * @since 11 * @version 4.1 */ -int32_t OH_ImageCreator_Dequeue(const ImageCreatorNative* native, napi_value* image); +int32_t OH_ImageCreator_Dequeue(const ImageCreator_Native* native, napi_value* image); /** - * @brief Queues an image object into queue through an {@link ImageCreatorNative} object. + * @brief Queues an image object into queue through an {@link ImageCreator_Native} object. * - * @param native Indicates the pointer to an {@link ImageCreatorNative} object at the native layer. + * @param native Indicates the pointer to an {@link ImageCreator_Native} object at the native layer. * @param image Indicates image object obtained. * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. @@ -152,26 +160,26 @@ int32_t OH_ImageCreator_Dequeue(const ImageCreatorNative* native, napi_value* im * @since 11 * @version 4.1 */ -int32_t OH_ImageCreator_Queue(const ImageCreatorNative* native, napi_value image); +int32_t OH_ImageCreator_Queue(const ImageCreator_Native* native, napi_value image); /** * @brief Registers an {@link OH_ImageCreator_On_Callback} callback event. * * This callback event is triggered whenever an image is release by consumer release surface. * - * @param native Indicates the pointer to an {@link ImageCreatorNative} object at the native layer. + * @param native Indicates the pointer to an {@link ImageCreator_Native} object at the native layer. * @param callback Indicates the {@link OH_ImageCreator_On_Callback} callback event to register. * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. * @since 11 * @version 4.1 */ -int32_t OH_ImageCreator_On(const ImageCreatorNative* native, OH_ImageCreator_On_Callback callback); +int32_t OH_ImageCreator_On(const ImageCreator_Native* native, OH_ImageCreator_On_Callback callback); /** - * @brief Gets the capacity of the image creator through an {@link ImageCreatorNative} object. + * @brief Gets the capacity of the image creator through an {@link ImageCreator_Native} object. * - * @param native Indicates the pointer to an {@link ImageCreatorNative} object at the native layer. + * @param native Indicates the pointer to an {@link ImageCreator_Native} object at the native layer. * @param capacity Indicates the pointer to the capacity obtained. * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. @@ -179,12 +187,12 @@ int32_t OH_ImageCreator_On(const ImageCreatorNative* native, OH_ImageCreator_On_ * @since 11 * @version 4.1 */ -int32_t OH_ImageCreator_GetCapacity(const ImageCreatorNative* native, int32_t* capacity); +int32_t OH_ImageCreator_GetCapacity(const ImageCreator_Native* native, int32_t* capacity); /** - * @brief Gets the format of the image creator through an {@link ImageCreatorNative} object. + * @brief Gets the format of the image creator through an {@link ImageCreator_Native} object. * - * @param native Indicates the pointer to an {@link ImageCreatorNative} object at the native layer. + * @param native Indicates the pointer to an {@link ImageCreator_Native} object at the native layer. * @param format Indicates the pointer to the format obtained. * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. @@ -192,20 +200,20 @@ int32_t OH_ImageCreator_GetCapacity(const ImageCreatorNative* native, int32_t* c * @since 11 * @version 4.1 */ -int32_t OH_ImageCreator_GetFormat(const ImageCreatorNative* native, int32_t* format); +int32_t OH_ImageCreator_GetFormat(const ImageCreator_Native* native, int32_t* format); /** - * @brief Releases an {@link ImageCreatorNative} object at the native layer. + * @brief Releases an {@link ImageCreator_Native} object at the native layer. * * This API is not used to release an ImageCreator object at the application layer. * - * @param native Indicates the pointer to an {@link ImageCreatorNative} object at the native layer. + * @param native Indicates the pointer to an {@link ImageCreator_Native} object at the native layer. * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. * @see {@link OH_ImageCreator_InitNative} * @since 11 * @version 4.1 */ -int32_t OH_ImageCreator_Release(ImageCreatorNative* native); +int32_t OH_ImageCreator_Release(ImageCreator_Native* native); #ifdef __cplusplus }; #endif diff --git a/multimedia/image_framework/libimage_creator_ndk.ndk.json b/multimedia/image_framework/libimage_creator_ndk.ndk.json index 8748e624e..c33eef08b 100644 --- a/multimedia/image_framework/libimage_creator_ndk.ndk.json +++ b/multimedia/image_framework/libimage_creator_ndk.ndk.json @@ -1,26 +1,34 @@ [ { + "first_introduced": "11", "name": "OH_ImageCreator_Create" }, { + "first_introduced": "11", "name": "OH_ImageCreator_InitNative" }, { + "first_introduced": "11", "name": "OH_ImageCreator_Dequeue" }, { + "first_introduced": "11", "name": "OH_ImageCreator_Queue" }, { + "first_introduced": "11", "name": "OH_ImageCreator_On" }, { + "first_introduced": "11", "name": "OH_ImageCreator_GetCapacity" }, { + "first_introduced": "11", "name": "OH_ImageCreator_GetFormat" }, { + "first_introduced": "11", "name": "OH_ImageCreator_Release" } ] -- Gitee From a1b91848ef4455a0ef87d2ca2536b20f649c1caf Mon Sep 17 00:00:00 2001 From: Cao Chuan Date: Fri, 17 Nov 2023 16:57:58 +0800 Subject: [PATCH 4/4] Fix for code scan Signed-off-by: Cao Chuan --- multimedia/image_framework/include/image_creator_mdk.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/multimedia/image_framework/include/image_creator_mdk.h b/multimedia/image_framework/include/image_creator_mdk.h index 20f634a5f..1dceef651 100644 --- a/multimedia/image_framework/include/image_creator_mdk.h +++ b/multimedia/image_framework/include/image_creator_mdk.h @@ -22,7 +22,7 @@ * The channel for transmitting raw image data module part of image module. * It provided a queue used to transmit raw image data from application layer * to native layer components - * + * * @since 11 * @version 4.1 */ @@ -31,7 +31,7 @@ * @file image_creator_mdk.h * * @brief Declares the APIs for obtaining image data transfer to the native layer. - * + * * The image creator module used to obtain a image buffer and transmist raw image data * via buffer to native layer components. * -- Gitee