diff --git a/en/native_sdk/media/.gitignore b/en/native_sdk/media/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/en/native_sdk/media/OpenSLES_OpenHarmony.h b/en/native_sdk/media/OpenSLES_OpenHarmony.h new file mode 100644 index 0000000000000000000000000000000000000000..1812bba01654030ff12cd0f64d55c0a97f7400ed --- /dev/null +++ b/en/native_sdk/media/OpenSLES_OpenHarmony.h @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2022 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. + */ + +/** + * @file OpenSLES_OpenHarmony.h + * + * @brief Declares APIs for audio playback and audio recording operations. + * + * @since 9 + * @version 1.0 + */ + +#ifndef OPENSLES_OPENHARMONY_H +#define OPENSLES_OPENHARMONY_H + +#include +#include + +/*---------------------------------------------------------------------------*/ +/* Defines the OpenHarmony buffer queue interface. */ +/*---------------------------------------------------------------------------*/ + +extern const SLInterfaceID SL_IID_OH_BUFFERQUEUE; + +struct SLOHBufferQueueItf_; +typedef const struct SLOHBufferQueueItf_ * const * SLOHBufferQueueItf; + +/** + * @brief Called to return the audio file to be played for an audio playback operation, or a buffer that carries recording data in the filledBufferQ_ queue for an audio recording operation. + * + * @param self Indicates the BufferQueue object that calls this function. + * @param pContext Indicates the pointer to the audio file to be played or the pointer to the recording file to be stored. + * @param size Indicates the size of the buffer. + * @return + * @since 9 + * @version 1.0 + */ +typedef void (SLAPIENTRY *SlOHBufferQueueCallback) ( + SLOHBufferQueueItf caller, + void *pContext, + SLuint32 size +); + +/** Defines the OpenHarmony buffer queue state. **/ +typedef struct SLOHBufferQueueState_ { + SLuint32 count; + SLuint32 index; +} SLOHBufferQueueState; + +struct SLOHBufferQueueItf_ { +/** + * @brief Adds a buffer to the corresponding queue. + * + * For an audio playback operation, this function adds the buffer with audio data to the filledBufferQ_ queue. + * For an audio recording operation, this function adds the idle buffer after recording data storage to the freeBufferQ_ queue. + * + * @param self Indicates the BufferQueue object that calls this function. + * @param buffer Indicates the pointer to the buffer with audio data or the pointer to the idle buffer after the recording data is stored. + * @param size Indicates the size of the buffer. + * @return Returns SL_RESULT_SUCCESS if the operation is successful; returns SL_RESULT_PARAMETER_INVALID otherwise. + * @since 9 + * @version 1.0 + */ +SLresult (*Enqueue) ( + SLOHBufferQueueItf self, + const void *buffer, + SLuint32 size +); + +/** + * @brief Releases a BufferQueue object. + * + * @param self Indicates the BufferQueue object that calls this function. + * @return Returns SL_RESULT_SUCCESS if the operation is successful; returns SL_RESULT_PARAMETER_INVALID otherwise. + * @since 9 + * @version 1.0 + */ +SLresult (*Clear) ( + SLOHBufferQueueItf self +); + +/** + * @brief Obtains the state of a BufferQueue object. + * + * @param self Indicates the BufferQueue object that calls this function. + * @param state Indicates the pointer to the state of the BufferQueue object. + * @return Returns SL_RESULT_SUCCESS if the operation is successful; returns SL_RESULT_PARAMETER_INVALID otherwise. + * @since 9 + * @version 1.0 + */ +SLresult (*GetState) ( + SLOHBufferQueueItf self, + SLOHBufferQueueState *state +); + +/** + * @brief Obtains a buffer. + * + * For an audio playback operation, this function obtains an idle buffer from the freeBufferQ_ queue. + * For an audio recording operation, this function obtains the buffer that carries recording data from the filledBufferQ_ queue. + * + * @param self Indicates the BufferQueue object that calls this function. + * @param buffer Indicates the double pointer to the idle buffer or the buffer carrying recording data. + * @param size Indicates the size of the buffer. + * @return Returns SL_RESULT_SUCCESS if the operation is successful; returns SL_RESULT_PARAMETER_INVALID otherwise. + * @since 9 + * @version 1.0 + */ +SLresult (*GetBuffer) ( + SLOHBufferQueueItf self, + SLuint8** buffer, + SLuint32& size +); + +/** + * @brief Registers a callback. + * + * @param self Indicates the BufferQueue object that calls this function. + * @param callback Indicates the callback to be registered for the audio playback or recording operation. + * @param pContext Indicates the pointer to the audio file to be played for an audio playback operation or the pointer to the audio file to be recorded for an audio recording operation. + * @return Returns SL_RESULT_SUCCESS if the operation is successful; returns SL_RESULT_PARAMETER_INVALID otherwise. + * @since 9 + * @version 1.0 + */ +SLresult (*RegisterCallback) ( + SLOHBufferQueueItf self, + SlOHBufferQueueCallback callback, + void* pContext +); +}; +#endif diff --git a/en/native_sdk/media/image/image_pixel_map_napi.h b/en/native_sdk/media/image/image_pixel_map_napi.h new file mode 100644 index 0000000000000000000000000000000000000000..d33c82b200753a13bd18e60e387ff3cc61547c99 --- /dev/null +++ b/en/native_sdk/media/image/image_pixel_map_napi.h @@ -0,0 +1,144 @@ +/* + * Copyright (C) 2022 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 pixel map data and information. + * + * @Syscap SystemCapability.Multimedia.Image + * @since 8 + * @version 1.0 + */ + +/** + * @file image_pixel_map_napi.h + * + * @brief Declares the APIs that can lock, access, and unlock pixel map data. + * + * @since 8 + * @version 1.0 + */ + +#ifndef IMAGE_PIXEL_MAP_NAPI_H +#define IMAGE_PIXEL_MAP_NAPI_H +#include +#include "napi/native_api.h" +#include "napi/native_node_api.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Enumerates the error codes returned by a function. + * + * @since 8 + * @version 1.0 + */ +enum { + /** Operation success. */ + OHOS_IMAGE_RESULT_SUCCESS = 0, + /** Invalid value. */ + OHOS_IMAGE_RESULT_BAD_PARAMETER = -1, +}; + +/** + * @brief Enumerates the pixel formats. + * + * @since 8 + * @version 1.0 + */ +enum { + /** + * Unknown format. + */ + OHOS_PIXEL_MAP_FORMAT_NONE = 0, + /** + * 32-bit RGBA, with 8 bits each for R (red), G (green), B (blue), and A (alpha). The data is stored from the most significant bit to the least significant bit. + */ + OHOS_PIXEL_MAP_FORMAT_RGBA_8888 = 3, + /** + * 16-bit RGB, with 5, 6, and 5 bits for R, G, and B, respectively. + * The storage sequence is from the most significant bit to the least significant bit. + */ + OHOS_PIXEL_MAP_FORMAT_RGB_565 = 2, +}; + +/** + * @brief Defines the pixel map information. + * + * @since 8 + * @version 1.0 + */ +struct OhosPixelMapInfo { + /** Image width, in pixels. */ + uint32_t width; + /** Image height, in pixels. */ + uint32_t height; + /** Number of bytes in each line. */ + uint32_t rowSize; + /** Pixel format. */ + int32_t pixelFormat; +}; + +/** + * @brief Obtains the PixelMap information and stores the information to the {@link OhosPixelMapInfo} structure. + * + * @param env Indicates the NAPI environment pointer. + * @param value Indicates the PixelMap object at the application layer. + * @param info Indicates the pointer to the object that stores the information obtained. For details, see {@link OhosPixelMapInfo}. + * @return Returns 0 if the information is obtained and stored successfully; returns an error code otherwise. + * @see OhosPixelMapInfo + * @since 8 + * @version 1.0 + */ +int32_t OH_GetImageInfo(napi_env env, napi_value value, OhosPixelMapInfo *info); + +/** + * @brief Obtains the memory address of the PixelMap object data and locks the memory. + * + * After the function is executed successfully, *addrPtr is the address of the memory to be accessed. After the access operation is complete, you must use {@link OH_UnAccessPixels} to unlock the memory. Otherwise, the resources in the memory cannot be released. + * After being unlocked, the memory address cannot be accessed or operated. + * + * @param env Indicates the NAPI environment pointer. + * @param value Indicates the PixelMap object at the application layer. + * @param addrPtr Indicates the double pointer to the memory address. + * @see UnAccessPixels + * @return Returns {@link OHOS_IMAGE_RESULT_SUCCESS} if the operation is successful; returns an error code otherwise. + * @since 8 + * @version 1.0 + */ +int32_t OH_AccessPixels(napi_env env, napi_value value, void** addrPtr); + +/** + * @brief Unlocks the memory of the PixelMap object data. This function is used with {@link OH_AccessPixels} in pairs. + * + * @param env Indicates the NAPI environment pointer. + * @param value Indicates the PixelMap object at the application layer. + * @return Returns {@link OHOS_IMAGE_RESULT_SUCCESS} if the operation is successful; returns an error code otherwise. + * @see AccessPixels + * @since 8 + * @version 1.0 + */ +int32_t OH_UnAccessPixels(napi_env env, napi_value value); + +#ifdef __cplusplus +}; +#endif + +/** @} */ +#endif // IMAGE_PIXEL_MAP_NAPI_H diff --git a/zh-cn/native_sdk/media/image/image_pixel_map_napi.h b/zh-cn/native_sdk/media/image/image_pixel_map_napi.h index 3f6c47afe6008f66532e6314c3d7441466c97ae3..5bd673a88b75b518a89b97561b8c57f176bba629 100644 --- a/zh-cn/native_sdk/media/image/image_pixel_map_napi.h +++ b/zh-cn/native_sdk/media/image/image_pixel_map_napi.h @@ -68,12 +68,12 @@ enum { */ OHOS_PIXEL_MAP_FORMAT_NONE = 0, /** - * 32-bit RGBA. 由 R, G, B组成,包括 A 都需要占用 8 bits。存储顺序是从高位到地位. + * 32-bit RGBA. 由 R, G, B组成,包括 A 都需要占用 8 bits。存储顺序是从高位到低位. */ OHOS_PIXEL_MAP_FORMAT_RGBA_8888 = 3, /** * 16-bit RGB. 仅由 R, G, B 组成. - * 存储顺序是从高位到地位: 红色占用5 bits,绿色占用6 bits,蓝色占用5 bits. + * 存储顺序是从高位到低位: 红色占用5 bits,绿色占用6 bits,蓝色占用5 bits. */ OHOS_PIXEL_MAP_FORMAT_RGB_565 = 2, };