openharmony 鸿蒙 capi-image-receiver-mdk-h

2026-08-25 浏览 (1)

image_receiver_mdk.h

Overview

The file declares the APIs used to obtain image data from the native layer.

Library: libimage_receiver_ndk.z.so

File to include: <multimedia/image_framework/image_receiver_mdk.h>

System capability: SystemCapability.Multimedia.Image.Core

Since: 10

Related module: Image

Summary

Structs

Nametypedef KeywordDescription
OhosImageReceiverInfo-Describes the information about an image receiver.
ImageReceiverNative_ImageReceiverNativeDefines the data type name of the image receiver at the native layer.

Functions

Nametypedef KeywordDescription
typedef void (*OH_Image_Receiver_On_Callback)()OH_Image_Receiver_On_CallbackDefines the callbacks for the image receiver at the native layer.
int32_t OH_Image_Receiver_CreateImageReceiver(napi_env env, struct OhosImageReceiverInfo info, napi_value* res)-Creates an ImageReceiver object at the application layer.
ImageReceiverNative* OH_Image_Receiver_InitImageReceiverNative(napi_env env, napi_value source)-Initializes an ImageReceiverNative object through an ImageReceiver object.
int32_t OH_Image_Receiver_GetReceivingSurfaceId(const ImageReceiverNative* native, char* id, size_t len)-Obtains the receiver ID through an ImageReceiverNative object.
int32_t OH_Image_Receiver_ReadLatestImage(const ImageReceiverNative* native, napi_value* image)-Obtains the latest image through an ImageReceiverNative object.
int32_t OH_Image_Receiver_ReadNextImage(const ImageReceiverNative* native, napi_value* image)-Obtains the next image through an ImageReceiverNative object.
int32_t OH_Image_Receiver_On(const ImageReceiverNative* native, OH_Image_Receiver_On_Callback callback)-Registers an OH_Image_Receiver_On_Callback callback. This callback is triggered whenever a new image is received.
int32_t OH_Image_Receiver_GetSize(const ImageReceiverNative* native, struct OhosImageSize* size)-Obtains the size of the image receiver through an ImageReceiverNative object.
int32_t OH_Image_Receiver_GetCapacity(const ImageReceiverNative* native, int32_t* capacity)-Obtains the capacity of the image receiver through an ImageReceiverNative object.
int32_t OH_Image_Receiver_GetFormat(const ImageReceiverNative* native, int32_t* format)-Obtains the format of the image receiver through an ImageReceiverNative object.
int32_t OH_Image_Receiver_Release(ImageReceiverNative* native)-Releases an ImageReceiverNative object.
This function is not used to release an ImageReceiver object.

Function Description

OH_Image_Receiver_On_Callback()

typedef void (*OH_Image_Receiver_On_Callback)(void)

Description

Defines the callbacks for the image receiver at the native layer.

Since: 10

OH_Image_Receiver_CreateImageReceiver()

int32_t OH_Image_Receiver_CreateImageReceiver(napi_env env, struct OhosImageReceiverInfo info, napi_value* res)

Description

Creates an ImageReceiver object at the application layer.

Since: 10

Parameters

NameDescription
napi_env envPointer to the NAPI environment.
struct OhosImageReceiverInfo infoOptions for setting the ImageReceiver object.
napi_value* resPointer to the ImageReceiver object at the application layer.

Returns

TypeDescription
int32_tResult code defined in IRNdkErrCode:
IMAGE_RESULT_SUCCESS: The operation is successful.
IMAGE_RESULT_BAD_PARAMETER: A parameter is incorrect.
IMAGE_RESULT_JNI_ENV_ABNORMAL: The JNI environment is abnormal.
IMAGE_RESULT_INVALID_PARAMETER: A parameter is invalid.
IMAGE_RESULT_INVALID_PARAMETER: Obtaining parameters from the surface fails.
IMAGE_RESULT_CREATE_SURFACE_FAILED: The surface fails to be created.
IMAGE_RESULT_SURFACE_GRALLOC_BUFFER_FAILED: The buffer fails to be allocated to the surface.
IMAGE_RESULT_GET_SURFACE_FAILED: The surface fails to be obtained.
IMAGE_RESULT_MEDIA_RTSP_SURFACE_UNSUPPORT: The media RTSP surface is not supported.
IMAGE_RESULT_DATA_UNSUPPORT: The image type is not supported.
IMAGE_RESULT_MEDIA_DATA_UNSUPPORT: The media type is not supported.

OH_Image_Receiver_InitImageReceiverNative()

ImageReceiverNative* OH_Image_Receiver_InitImageReceiverNative(napi_env env, napi_value source)

Description

Initializes an ImageReceiverNative object through an ImageReceiver object.

Since: 10

Parameters

NameDescription
napi_env envPointer to the NAPI environment.
napi_value sourceImageReceiver object.

Returns

TypeDescription
ImageReceiverNative*Pointer to the ImageReceiverNative object obtained. If the operation fails, nullptr is returned.

See also

OH_Image_Receiver_Release

OH_Image_Receiver_GetReceivingSurfaceId()

int32_t OH_Image_Receiver_GetReceivingSurfaceId(const ImageReceiverNative* native, char* id, size_t len)

Description

Obtains the receiver ID through an ImageReceiverNative object.

Since: 10

Parameters

NameDescription
const ImageReceiverNative* nativePointer to an ImageReceiverNative object.
char* idPointer to the buffer that stores the ID string obtained.
size_t lenSize of the buffer.

Returns

TypeDescription
int32_tResult code defined in IRNdkErrCode:
IMAGE_RESULT_SUCCESS: The operation is successful.
IMAGE_RESULT_BAD_PARAMETER: A parameter is incorrect.
IMAGE_RESULT_JNI_ENV_ABNORMAL: The JNI environment is abnormal.
IMAGE_RESULT_INVALID_PARAMETER: A parameter is invalid.
IMAGE_RESULT_INVALID_PARAMETER: Obtaining parameters from the surface fails.
IMAGE_RESULT_GET_SURFACE_FAILED: The surface fails to be obtained.
IMAGE_RESULT_DATA_UNSUPPORT: The image type is not supported.
IMAGE_RESULT_MEDIA_DATA_UNSUPPORT: The media type is not supported.

OH_Image_Receiver_ReadLatestImage()

int32_t OH_Image_Receiver_ReadLatestImage(const ImageReceiverNative* native, napi_value* image)

Description

Obtains the latest image through an ImageReceiverNative object.

This function can be called to receive data only after the OH_Image_Receiver_On_Callback callback is triggered. When the ImageNative object created by the Image object returned by this function is no longer needed, call OH_Image_Release to release the object. New data can be received only after the release.

Since: 10

Parameters

NameDescription
const ImageReceiverNative* nativePointer to an ImageReceiverNative object.
napi_value* imagePointer to an Image object at the application layer.

Returns

TypeDescription
int32_tResult code defined in IRNdkErrCode:
IMAGE_RESULT_SUCCESS: The operation is successful.
IMAGE_RESULT_BAD_PARAMETER: A parameter is incorrect.
IMAGE_RESULT_JNI_ENV_ABNORMAL: The JNI environment is abnormal.
IMAGE_RESULT_INVALID_PARAMETER: A parameter is invalid.
IMAGE_RESULT_INVALID_PARAMETER: Obtaining parameters from the surface fails.
IMAGE_RESULT_CREATE_SURFACE_FAILED: The surface fails to be created.
IMAGE_RESULT_SURFACE_GRALLOC_BUFFER_FAILED: The buffer fails to be allocated to the surface.
IMAGE_RESULT_GET_SURFACE_FAILED: The surface fails to be obtained.
IMAGE_RESULT_MEDIA_RTSP_SURFACE_UNSUPPORT: The media RTSP surface is not supported.
IMAGE_RESULT_DATA_UNSUPPORT: The image type is not supported.
IMAGE_RESULT_MEDIA_DATA_UNSUPPORT: The media type is not supported.

OH_Image_Receiver_ReadNextImage()

int32_t OH_Image_Receiver_ReadNextImage(const ImageReceiverNative* native, napi_value* image)

Description

Obtains the next image through an ImageReceiverNative object.

This function can be called to receive data only after the OH_Image_Receiver_On_Callback callback is triggered. When the ImageNative object created by the Image object returned by this function is no longer needed, call OH_Image_Release to release the object. New data can be received only after the release.

Since: 10

Parameters

NameDescription
const ImageReceiverNative* nativePointer to an ImageReceiverNative object.
napi_value* imagePointer to an Image object at the application layer.

Returns

TypeDescription
int32_tResult code defined in IRNdkErrCode:
IMAGE_RESULT_SUCCESS: The operation is successful.
IMAGE_RESULT_BAD_PARAMETER: A parameter is incorrect.
IMAGE_RESULT_JNI_ENV_ABNORMAL: The JNI environment is abnormal.
IMAGE_RESULT_INVALID_PARAMETER: A parameter is invalid.
IMAGE_RESULT_INVALID_PARAMETER: Obtaining parameters from the surface fails.
IMAGE_RESULT_CREATE_SURFACE_FAILED: The surface fails to be created.
IMAGE_RESULT_SURFACE_GRALLOC_BUFFER_FAILED: The buffer fails to be allocated to the surface.
IMAGE_RESULT_GET_SURFACE_FAILED: The surface fails to be obtained.
IMAGE_RESULT_MEDIA_RTSP_SURFACE_UNSUPPORT: The media RTSP surface is not supported.
IMAGE_RESULT_DATA_UNSUPPORT: The image type is not supported.
IMAGE_RESULT_MEDIA_DATA_UNSUPPORT: The media type is not supported.

OH_Image_Receiver_On()

int32_t OH_Image_Receiver_On(const ImageReceiverNative* native, OH_Image_Receiver_On_Callback callback)

Description

Registers an OH_Image_Receiver_On_Callback callback. This callback is triggered whenever a new image is received.

Since: 10

Parameters

NameDescription
const ImageReceiverNative* nativePointer to an ImageReceiverNative object.
OH_Image_Receiver_On_Callback callbackOH_Image_Receiver_On_Callback callback to register.

Returns

TypeDescription
int32_tResult code defined in IRNdkErrCode:
IMAGE_RESULT_SUCCESS: The operation is successful.
IMAGE_RESULT_BAD_PARAMETER: A parameter is incorrect.
IMAGE_RESULT_JNI_ENV_ABNORMAL: The JNI environment is abnormal.
IMAGE_RESULT_INVALID_PARAMETER: A parameter is invalid.
IMAGE_RESULT_INVALID_PARAMETER: Obtaining parameters from the surface fails.
IMAGE_RESULT_GET_SURFACE_FAILED: The surface fails to be obtained.
IMAGE_RESULT_DATA_UNSUPPORT: The image type is not supported.
IMAGE_RESULT_MEDIA_DATA_UNSUPPORT: The media type is not supported.

OH_Image_Receiver_GetSize()

int32_t OH_Image_Receiver_GetSize(const ImageReceiverNative* native, struct OhosImageSize* size)

Description

Obtains the size of the image receiver through an ImageReceiverNative object.

Since: 10

Parameters

NameDescription
const ImageReceiverNative* nativePointer to an ImageReceiverNative object.
struct OhosImageSize* sizePointer to the OhosImageSize object obtained.

Returns

TypeDescription
int32_tResult code defined in IRNdkErrCode:
IMAGE_RESULT_SUCCESS: The operation is successful.
IMAGE_RESULT_BAD_PARAMETER: A parameter is incorrect.
IMAGE_RESULT_JNI_ENV_ABNORMAL: The JNI environment is abnormal.
IMAGE_RESULT_INVALID_PARAMETER: A parameter is invalid.
IMAGE_RESULT_DATA_UNSUPPORT: The image type is not supported.

OH_Image_Receiver_GetCapacity()

int32_t OH_Image_Receiver_GetCapacity(const ImageReceiverNative* native, int32_t* capacity)

Description

Obtains the capacity of the image receiver through an ImageReceiverNative object.

Since: 10

Parameters

NameDescription
const ImageReceiverNative* nativePointer to an ImageReceiverNative object.
int32_t* capacityPointer to the capacity obtained.

Returns

TypeDescription
int32_tResult code defined in IRNdkErrCode:
IMAGE_RESULT_SUCCESS: The operation is successful.
IMAGE_RESULT_BAD_PARAMETER: A parameter is incorrect.
IMAGE_RESULT_JNI_ENV_ABNORMAL: The JNI environment is abnormal.
IMAGE_RESULT_INVALID_PARAMETER: A parameter is invalid.
IMAGE_RESULT_DATA_UNSUPPORT: The image type is not supported.

OH_Image_Receiver_GetFormat()

int32_t OH_Image_Receiver_GetFormat(const ImageReceiverNative* native, int32_t* format)

Description

Obtains the format of the image receiver through an ImageReceiverNative object.

Since: 10

Parameters

NameDescription
const ImageReceiverNative* nativePointer to an ImageReceiverNative object.
int32_t* formatPointer to the format obtained.

Returns

TypeDescription
int32_tResult code defined in IRNdkErrCode:
IMAGE_RESULT_SUCCESS: The operation is successful.
IMAGE_RESULT_BAD_PARAMETER: A parameter is incorrect.
IMAGE_RESULT_JNI_ENV_ABNORMAL: The JNI environment is abnormal.
IMAGE_RESULT_INVALID_PARAMETER: A parameter is invalid.
IMAGE_RESULT_DATA_UNSUPPORT: The image type is not supported.

OH_Image_Receiver_Release()

int32_t OH_Image_Receiver_Release(ImageReceiverNative* native)

Description

Releases an ImageReceiverNative object.

This function is not used to release an ImageReceiver object.

Since: 10

Parameters

NameDescription
ImageReceiverNative* nativePointer to an ImageReceiverNative object.

Returns

TypeDescription
int32_tResult code defined in IRNdkErrCode:
IMAGE_RESULT_SUCCESS: The operation is successful.
IMAGE_RESULT_BAD_PARAMETER: A parameter is incorrect.
IMAGE_RESULT_INVALID_PARAMETER: A parameter is invalid.
IMAGE_RESULT_DATA_UNSUPPORT: The image type is not supported.

你可能感兴趣的鸿蒙文章

openharmony 鸿蒙 capi-image-nativemodule-oh-pixelmap-hdrmetadatavalue

openharmony 鸿蒙 capi-image-imagepacker-opts-

openharmony 鸿蒙 capi-image-nativemodule-image-region

openharmony 鸿蒙 capi-image-imagepacker-native-

openharmony 鸿蒙 capi-image-imagenative-

openharmony 鸿蒙 capi-image-processing-h

openharmony 鸿蒙 capi-image-ohosimagesourcesupportedformat

openharmony 鸿蒙 capi-image-nativemodule-image-size

openharmony 鸿蒙 capi-image-mdk-h

openharmony 鸿蒙 capi-image-ohosimagesourcedelaytimelist

  • 所属分类: 后端技术
  • 本文标签: 鸿蒙 软件
  • 版权声明: 本文链接 https://seaxiang.com/blog/U3cExigL