From 459a0fe59e19c9d608b017a7134979890b87257d Mon Sep 17 00:00:00 2001 From: linziming Date: Mon, 18 Dec 2023 10:45:03 +0000 Subject: [PATCH] =?UTF-8?q?Media.Core=E8=83=BD=E5=8A=9B=E4=B8=8B=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: linziming Change-Id: I5bd527394712ba05e538af0e2c54202db733c14d --- README.en.md | 1 + README.md | 1 + .../libnative_media_codecbase.ndk.json | 2 + .../{av_codec => histreamer}/core/BUILD.gn | 8 +- .../core/libnative_media_core.ndk.json | 11 +- multimedia/histreamer/native_avbuffer.h | 130 ++++++++++++++++++ .../native_averrors.h | 0 .../native_avformat.h | 0 .../native_avmemory.h | 11 +- 9 files changed, 158 insertions(+), 6 deletions(-) rename multimedia/{av_codec => histreamer}/core/BUILD.gn (79%) rename multimedia/{av_codec => histreamer}/core/libnative_media_core.ndk.json (71%) create mode 100644 multimedia/histreamer/native_avbuffer.h rename multimedia/{av_codec => histreamer}/native_averrors.h (100%) rename multimedia/{av_codec => histreamer}/native_avformat.h (100%) rename multimedia/{av_codec => histreamer}/native_avmemory.h (89%) diff --git a/README.en.md b/README.en.md index 4559b64dd..5180963bc 100644 --- a/README.en.md +++ b/README.en.md @@ -31,6 +31,7 @@ This repository is used to store .h declaration files of C APIs. The OpenHarmony ├─multimedia | ├─audio_framework | ├─av_codec + | ├─histreamer | ├─image_framework | ├─player_framework ├─resourceschedule diff --git a/README.md b/README.md index 959da5d1f..3d56d9acc 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,7 @@ ├─multimedia | ├─audio_framework | ├─av_codec +| ├─histreamer | ├─image_framework | ├─player_framework ├─resourceschedule diff --git a/multimedia/av_codec/codec_base/libnative_media_codecbase.ndk.json b/multimedia/av_codec/codec_base/libnative_media_codecbase.ndk.json index 3e19fb31d..e1cae3c83 100644 --- a/multimedia/av_codec/codec_base/libnative_media_codecbase.ndk.json +++ b/multimedia/av_codec/codec_base/libnative_media_codecbase.ndk.json @@ -56,6 +56,8 @@ { "name": "OH_MD_KEY_DESCRIPTION" }, { "name": "OH_MD_KEY_LYRICS" }, { "name": "OH_MD_KEY_TRACK_COUNT" }, + { "name": "OH_AVCodec_GetCapability" }, + { "name": "OH_AVCodec_GetCapabilityByCategory" }, { "name": "OH_AVCapability_IsHardware" }, { "name": "OH_AVCapability_GetName" }, { "name": "OH_AVCapability_GetMaxSupportedInstances" }, diff --git a/multimedia/av_codec/core/BUILD.gn b/multimedia/histreamer/core/BUILD.gn similarity index 79% rename from multimedia/av_codec/core/BUILD.gn rename to multimedia/histreamer/core/BUILD.gn index 8d047d2eb..2ca09baa0 100644 --- a/multimedia/av_codec/core/BUILD.gn +++ b/multimedia/histreamer/core/BUILD.gn @@ -16,9 +16,10 @@ import("//build/ohos/ndk/ndk.gni") ohos_ndk_headers("native_media_core_header") { dest_dir = "$ndk_headers_out_dir/multimedia/player_framework" sources = [ - "//interface/sdk_c/multimedia/av_codec/native_averrors.h", - "//interface/sdk_c/multimedia/av_codec/native_avformat.h", - "//interface/sdk_c/multimedia/av_codec/native_avmemory.h", + "//interface/sdk_c/multimedia/histreamer/native_avbuffer.h", + "//interface/sdk_c/multimedia/histreamer/native_averrors.h", + "//interface/sdk_c/multimedia/histreamer/native_avformat.h", + "//interface/sdk_c/multimedia/histreamer/native_avmemory.h", ] } @@ -30,6 +31,7 @@ ohos_ndk_library("libnative_media_core") { system_capability = "SystemCapability.Multimedia.Media.Core" system_capability_headers = [ + "multimedia/player_framework/native_avbuffer.h", "multimedia/player_framework/native_averrors.h", "multimedia/player_framework/native_avformat.h", "multimedia/player_framework/native_avmemory.h", diff --git a/multimedia/av_codec/core/libnative_media_core.ndk.json b/multimedia/histreamer/core/libnative_media_core.ndk.json similarity index 71% rename from multimedia/av_codec/core/libnative_media_core.ndk.json rename to multimedia/histreamer/core/libnative_media_core.ndk.json index f7ceabdb5..06942afd5 100644 --- a/multimedia/av_codec/core/libnative_media_core.ndk.json +++ b/multimedia/histreamer/core/libnative_media_core.ndk.json @@ -21,6 +21,13 @@ { "name": "OH_AVMemory_GetAddr" }, { "name": "OH_AVMemory_GetSize" }, { "name": "OH_AVMemory_Destroy" }, - { "name": "OH_AVCodec_GetCapability" }, - { "name": "OH_AVCodec_GetCapabilityByCategory" } + { "name": "OH_AVBuffer_Create" }, + { "name": "OH_AVBuffer_Destroy" }, + { "name": "OH_AVBuffer_GetBufferAttr" }, + { "name": "OH_AVBuffer_SetBufferAttr" }, + { "name": "OH_AVBuffer_GetParameter" }, + { "name": "OH_AVBuffer_SetParameter" }, + { "name": "OH_AVBuffer_GetAddr" }, + { "name": "OH_AVBuffer_GetCapacity" }, + { "name": "OH_AVBuffer_GetNativeBuffer" } ] diff --git a/multimedia/histreamer/native_avbuffer.h b/multimedia/histreamer/native_avbuffer.h new file mode 100644 index 000000000..ce24df936 --- /dev/null +++ b/multimedia/histreamer/native_avbuffer.h @@ -0,0 +1,130 @@ +/* + * 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. + */ + +#ifndef NATIVE_AVBUFFER_H +#define NATIVE_AVBUFFER_H + +#include +#include +#include "native_avbuffer_info.h" +#include "native_averrors.h" +#include "native_avformat.h" + +#ifdef __cplusplus +extern "C" { +#endif +typedef struct OH_AVBuffer OH_AVBuffer; +typedef struct OH_NativeBuffer OH_NativeBuffer; + +/** + * @brief Create an OH_AVBuffer instance, It should be noted that the life cycle of the OH_AVBuffer instance pointed + * to by the return value * needs to be manually released by {@link OH_AVBuffer_Destroy}. + * @syscap SystemCapability.Multimedia.Media.Core + * @param capacity the buffer's capacity, bytes + * @return Returns a pointer to an OH_AVBuffer instance if the execution is successful, otherwise returns nullptr + * @since 11 + */ +OH_AVBuffer *OH_AVBuffer_Create(int32_t capacity); + +/** + * @brief Clear the internal resources of the buffer and destroy the buffer instance. + * @syscap SystemCapability.Multimedia.Media.Core + * @param buffer Encapsulate OH_AVBuffer structure instance pointer + * @return Returns AV_ERR_OK if the execution is successful, otherwise returns a specific error code, refer to + * {@link OH_AVErrCode} + * @since 11 + */ +OH_AVErrCode OH_AVBuffer_Destroy(OH_AVBuffer *buffer); + +/** + * @brief Get the buffer's attribute. + * @syscap SystemCapability.Multimedia.Media.Core + * @param buffer Encapsulate OH_AVBuffer structure instance pointer + * @param attr Encapsulate OH_AVCodecBufferAttr structure instance pointer, please refer to + * {@link OH_AVCodecBufferAttr} + * @return Returns AV_ERR_OK if the execution is successful, otherwise returns a specific error code, refer to + * {@link OH_AVErrCode} + * @since 11 + */ +OH_AVErrCode OH_AVBuffer_GetBufferAttr(OH_AVBuffer *buffer, OH_AVCodecBufferAttr *attr); + +/** + * @brief Set the buffer's attribute. + * @syscap SystemCapability.Multimedia.Media.Core + * @param buffer Encapsulate OH_AVBuffer structure instance pointer + * @param attr Encapsulate OH_AVCodecBufferAttr structure instance pointer, please refer to + * {@link OH_AVCodecBufferAttr} + * @return Returns AV_ERR_OK if the execution is successful, otherwise returns a specific error code, refer to + * {@link OH_AVErrCode} + * @since 11 + */ +OH_AVErrCode OH_AVBuffer_SetBufferAttr(OH_AVBuffer *buffer, const OH_AVCodecBufferAttr *attr); + +/** + * @brief Get the buffer's parameter. It should be noted that the life cycle of the OH_AVFormat instance pointed to + * by the return value * needs to be manually released by {@link OH_AVFormat_Destroy}. + * @syscap SystemCapability.Multimedia.Media.Core + * @param buffer Encapsulate OH_AVBuffer structure instance pointer + * @return Returns Encapsulate OH_AVFormat structure instance pointer if the execution is successful, + * otherwise returns nullptr + * @since 11 + */ +OH_AVFormat *OH_AVBuffer_GetParameter(OH_AVBuffer *buffer); + +/** + * @brief Set the buffer's parameter. + * @syscap SystemCapability.Multimedia.Media.Core + * @param buffer Encapsulate OH_AVBuffer structure instance pointer + * @param format Encapsulate OH_AVFormat structure instance pointer + * @return Returns AV_ERR_OK if the execution is successful, otherwise returns a specific error code, refer to + * {@link OH_AVErrCode} + * @since 11 + */ +OH_AVErrCode OH_AVBuffer_SetParameter(OH_AVBuffer *buffer, const OH_AVFormat *format); + +/** + * @brief Get the buffer's virtual address. + * @syscap SystemCapability.Multimedia.Media.Core + * @param buffer Encapsulate OH_AVBuffer structure instance pointer + * @return the buffer's virtual address if the buffer is valid, otherwise nullptr + * @since 11 + */ +uint8_t *OH_AVBuffer_GetAddr(OH_AVBuffer *buffer); + +/** + * @brief Get the buffer's capacity + * @syscap SystemCapability.Multimedia.Media.Core + * @param buffer Encapsulate OH_AVBuffer structure instance pointer + * @return the buffer's capacity if the buffer is valid, otherwise -1 + * @since 11 + */ +int32_t OH_AVBuffer_GetCapacity(OH_AVBuffer *buffer); + +/** + * @brief Get the OH_NativeBuffer instance pointer,It should be noted that the life cycle of the OH_AVBuffer + * instance pointed to by the return value * needs to be manually released by {@link OH_NativeBuffer_Unreference}. + * @syscap SystemCapability.Multimedia.Media.Core + * @param buffer Encapsulate OH_AVBuffer structure instance pointer + * @return Returns Encapsulate OH_NativeBuffer structure instance pointer is successful, + * otherwise returns nullptr + * @since 11 + */ +OH_NativeBuffer *OH_AVBuffer_GetNativeBuffer(OH_AVBuffer *buffer); + +#ifdef __cplusplus +} +#endif + +#endif // NATIVE_AVBUFFER_H diff --git a/multimedia/av_codec/native_averrors.h b/multimedia/histreamer/native_averrors.h similarity index 100% rename from multimedia/av_codec/native_averrors.h rename to multimedia/histreamer/native_averrors.h diff --git a/multimedia/av_codec/native_avformat.h b/multimedia/histreamer/native_avformat.h similarity index 100% rename from multimedia/av_codec/native_avformat.h rename to multimedia/histreamer/native_avformat.h diff --git a/multimedia/av_codec/native_avmemory.h b/multimedia/histreamer/native_avmemory.h similarity index 89% rename from multimedia/av_codec/native_avmemory.h rename to multimedia/histreamer/native_avmemory.h index a165d290a..489a4ff49 100644 --- a/multimedia/av_codec/native_avmemory.h +++ b/multimedia/histreamer/native_avmemory.h @@ -30,6 +30,8 @@ typedef struct OH_AVMemory OH_AVMemory; * @syscap SystemCapability.Multimedia.Media.Core * @param size the memory's size, bytes. * @return Returns a pointer to an OH_AVMemory instance, needs to be freed by OH_AVMemory_Destroy. + * @deprecated since 11 + * @useinstead OH_AVBuffer_Create * @since 10 */ OH_AVMemory *OH_AVMemory_Create(int32_t size); @@ -39,6 +41,8 @@ OH_AVMemory *OH_AVMemory_Create(int32_t size); * @syscap SystemCapability.Multimedia.Media.Core * @param mem Encapsulate OH_AVMemory structure instance pointer * @return the memory's virtual address if the memory is valid, otherwise nullptr. + * @deprecated since 11 + * @useinstead OH_AVBuffer_GetAddr * @since 9 * @version 1.0 */ @@ -49,17 +53,22 @@ uint8_t *OH_AVMemory_GetAddr(struct OH_AVMemory *mem); * @syscap SystemCapability.Multimedia.Media.Core * @param mem Encapsulate OH_AVMemory structure instance pointer * @return the memory's size if the memory is valid, otherwise -1. + * @deprecated since 11 + * @useinstead OH_AVBuffer_GetCapacity * @since 9 * @version 1.0 */ int32_t OH_AVMemory_GetSize(struct OH_AVMemory *mem); /** - * @brief Clear the internal resources of the memory and destroy the memory instance + * @brief Clear the internal resources of the memory and destroy the memory + * instance * @syscap SystemCapability.Multimedia.Media.Core * @param mem Encapsulate OH_AVMemory structure instance pointer * @return Returns AV_ERR_OK if the execution is successful, * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @deprecated since 11 + * @useinstead OH_AVBuffer_Destroy * @since 10 */ OH_AVErrCode OH_AVMemory_Destroy(struct OH_AVMemory *mem); -- Gitee