From 8a7f56ff76ea879c5fc23f51168f22b5b7a6fc41 Mon Sep 17 00:00:00 2001 From: z00562947 Date: Mon, 17 Feb 2025 15:31:30 +0800 Subject: [PATCH] add ndk interfaces Signed-off-by: z00562947 --- multimedia/media_foundation/core/BUILD.gn | 4 +- multimedia/media_foundation/media_types.h | 70 ++++++ .../player_framework/avimage_generator.h | 124 ++++++++++ .../avimage_generator/BUILD.gn | 36 +++ .../libavimage_generator.ndk.json | 18 ++ .../player_framework/avimage_generator_base.h | 79 ++++++ .../player_framework/avmetadata_extractor.h | 136 +++++++++++ .../avmetadata_extractor/BUILD.gn | 36 +++ .../libavmetadata_extractor.ndk.json | 22 ++ .../avmetadata_extractor_base.h | 225 ++++++++++++++++++ ndk_targets.gni | 6 +- 11 files changed, 754 insertions(+), 2 deletions(-) create mode 100644 multimedia/media_foundation/media_types.h create mode 100644 multimedia/player_framework/avimage_generator.h create mode 100644 multimedia/player_framework/avimage_generator/BUILD.gn create mode 100644 multimedia/player_framework/avimage_generator/libavimage_generator.ndk.json create mode 100644 multimedia/player_framework/avimage_generator_base.h create mode 100644 multimedia/player_framework/avmetadata_extractor.h create mode 100644 multimedia/player_framework/avmetadata_extractor/BUILD.gn create mode 100644 multimedia/player_framework/avmetadata_extractor/libavmetadata_extractor.ndk.json create mode 100644 multimedia/player_framework/avmetadata_extractor_base.h diff --git a/multimedia/media_foundation/core/BUILD.gn b/multimedia/media_foundation/core/BUILD.gn index 25a6ff245..e81ceb338 100644 --- a/multimedia/media_foundation/core/BUILD.gn +++ b/multimedia/media_foundation/core/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (C) 2022 Huawei Device Co., Ltd. +# Copyright (C) 2022-2025 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 @@ -17,6 +17,7 @@ import("//build/ohos/ndk/ndk.gni") ohos_ndk_headers("native_media_core_header") { dest_dir = "$ndk_headers_out_dir/multimedia/player_framework" sources = [ + "../media_types.h", "../native_avbuffer.h", "../native_avbuffer_info.h", "../native_averrors.h", @@ -38,6 +39,7 @@ ohos_ndk_library("libnative_media_core") { system_capability = "SystemCapability.Multimedia.Media.Core" system_capability_headers = [ + "multimedia/player_framework/media_types.h", "multimedia/player_framework/native_avbuffer.h", "multimedia/player_framework/native_avbuffer_info.h", "multimedia/player_framework/native_averrors.h", diff --git a/multimedia/media_foundation/media_types.h b/multimedia/media_foundation/media_types.h new file mode 100644 index 000000000..1ec6d447c --- /dev/null +++ b/multimedia/media_foundation/media_types.h @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2025 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 Core + * @{ + * + * @brief The Core module provides basic backbone capabilities for media frameworks, + * including functions such as memory, error codes, and media data structures. + * + * @syscap SystemCapability.Multimedia.Media.Core + * @since 16 + */ + +/** + * @file media_types.h + * + * @brief Declared the common media types definition. + * + * @kit AVCodecKit + * @library libnative_media_core.so + * @syscap SystemCapability.Multimedia.Media.Core + * @since 16 + */ + +#ifndef MEDIA_TYPES_H +#define MEDIA_TYPES_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Enumerates HDR types. + * + * @syscap SystemCapability.Multimedia.Media.Core + * @since 16 + */ +typedef enum OH_Core_HdrType { + /** + * This option is used to mark none HDR type. + */ + OH_CORE_HDR_TYPE_NONE = 0, + /** + * This option is used to mark HDR Vivid type. + */ + OH_CORE_HDR_TYPE_VIVID = 1, +} OH_Core_HdrType; + +#ifdef __cplusplus +} +#endif + +#endif // MEDIA_TYPES_H +/** @} */ \ No newline at end of file diff --git a/multimedia/player_framework/avimage_generator.h b/multimedia/player_framework/avimage_generator.h new file mode 100644 index 000000000..0ae5a5b28 --- /dev/null +++ b/multimedia/player_framework/avimage_generator.h @@ -0,0 +1,124 @@ +/* + * Copyright (C) 2025 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 AVImageGenerator + * @{ + * + * @brief Provides APIs for generating an image at the specific time from a video resource. + * + * @syscap SystemCapability.Multimedia.Media.AVImageGenerator + * @since 16 + */ + +/** + * @file avimage_generator.h + * + * @brief Defines the avimage generator APIs. Uses the Native APIs provided by Media AVImageGenerator + * to get an image at the specific time from a video resource. + * + * @syscap SystemCapability.Multimedia.Media.AVImageGenerator + * @kit MediaKit + * @library libavimage_generator.so + * @since 16 + */ + +#ifndef MULTIMEDIA_PLAYER_FRAMEWORK_NATIVE_AVIMAGE_GENERATOR_H +#define MULTIMEDIA_PLAYER_FRAMEWORK_NATIVE_AVIMAGE_GENERATOR_H + +#include +#include +#include +#include "native_averrors.h" +#include "avimage_generator_base.h" +#include "multimedia/image_framework/image/pixelmap_native.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Define OH_AVImageGenerator field. + * + * @syscap SystemCapability.Multimedia.Media.AVImageGenerator + * @since 16 + */ +typedef struct OH_AVImageGenerator OH_AVImageGenerator; + +/** + * @brief Create an image generator. + * + * @syscap SystemCapability.Multimedia.Media.AVImageGenerator + * @return Returns a pointer to an OH_AVImageGenerator instance for success, nullptr for failure. + * Possible failure causes: HstEngineFactory failed to CreateAVMetadataHelperEngine. + * @since 16 + */ +OH_AVImageGenerator* OH_AVImageGenerator_Create(void); + +/** + * @brief Sets the media file descriptor source for the image generator. + * + * @syscap SystemCapability.Multimedia.Media.AVImageGenerator + * @param generator Pointer to an OH_AVImageGenerator instance. + * @param fd Indicates the file descriptor of media source. + * @param offset Indicates the offset of media source in file descriptor. + * @param size Indicates the size of media source. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INPUT_DATA_ERROR} if input generator is nullptr or input param is invalid. + * @since 16 + */ +OH_AVErrCode OH_AVImageGenerator_SetFDSource(OH_AVImageGenerator* generator, + int32_t fd, int64_t offset, int64_t size); + +/** + * @brief Fetch an image at the specific time from a video resource. + * + * This function must be called after {@link SetFDSource}. + * + * @syscap SystemCapability.Multimedia.Media.AVImageGenerator + * @param generator Pointer to an OH_AVImageGenerator instance. + * @param timeUs The time expected to fetch picture from the video resource. The unit is microsecond(us). + * @param options The time options about the relationship between the given timeUs and a key frame, + * see {@link OH_AVImageGenerator_QueryOptions}. + * @param pixelMap The fetched output image from the video source. For details, see {@link OH_PixelmapNative}. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INPUT_DATA_ERROR} if input generator is nullptr or input param is invalid. + * {@link AV_ERR_OPERATE_NOT_PERMIT} if operation not allowed. + * @since 16 + */ +OH_AVErrCode OH_AVImageGenerator_FetchFrameByTime(OH_AVImageGenerator* generator, + int64_t timeUs, OH_AVImageGenerator_QueryOptions options, OH_PixelmapNative** pixelMap); + +/** + * @brief Release the resource used for AVImageGenerator. + * + * @syscap SystemCapability.Multimedia.Media.AVImageGenerator + * @param generator Pointer to an OH_AVImageGenerator instance. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INPUT_DATA_ERROR} if input generator is nullptr or input param is invalid. + * {@link AV_ERR_OPERATE_NOT_PERMIT} if operation not allowed. + * @since 16 + */ +OH_AVErrCode OH_AVImageGenerator_Release(OH_AVImageGenerator* generator); + +#ifdef __cplusplus +} +#endif + +#endif // MULTIMEDIA_PLAYER_FRAMEWORK_NATIVE_AVIMAGE_GENERATOR_H +/** @} */ diff --git a/multimedia/player_framework/avimage_generator/BUILD.gn b/multimedia/player_framework/avimage_generator/BUILD.gn new file mode 100644 index 000000000..44efe2ff3 --- /dev/null +++ b/multimedia/player_framework/avimage_generator/BUILD.gn @@ -0,0 +1,36 @@ +# Copyright (C) 2025 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. + +import("//build/ohos.gni") +import("//build/ohos/ndk/ndk.gni") +import("//foundation/multimedia/player_framework/config.gni") + +ohos_ndk_headers("avimage_generator_header") { + dest_dir = "$ndk_headers_out_dir/multimedia/player_framework" + sources = [ + "../avimage_generator.h", + "../avimage_generator_base.h", + ] +} + +ohos_ndk_library("libavimage_generator") { + ndk_description_file = "./libavimage_generator.ndk.json" + output_name = "avimage_generator" + output_extension = "so" + + system_capability = "SystemCapability.Multimedia.Media.AVImageGenerator" + system_capability_headers = [ + "multimedia/player_framework/avimage_generator.h", + "multimedia/player_framework/avimage_generator_base.h", + ] +} diff --git a/multimedia/player_framework/avimage_generator/libavimage_generator.ndk.json b/multimedia/player_framework/avimage_generator/libavimage_generator.ndk.json new file mode 100644 index 000000000..827ef053c --- /dev/null +++ b/multimedia/player_framework/avimage_generator/libavimage_generator.ndk.json @@ -0,0 +1,18 @@ +[ + { + "first_introduced": "16", + "name": "OH_AVImageGenerator_Create" + }, + { + "first_introduced": "16", + "name": "OH_AVImageGenerator_SetFDSource" + }, + { + "first_introduced": "16", + "name": "OH_AVImageGenerator_FetchFrameByTime" + }, + { + "first_introduced": "16", + "name": "OH_AVImageGenerator_Release" + } +] \ No newline at end of file diff --git a/multimedia/player_framework/avimage_generator_base.h b/multimedia/player_framework/avimage_generator_base.h new file mode 100644 index 000000000..56f001257 --- /dev/null +++ b/multimedia/player_framework/avimage_generator_base.h @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2025 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 AVImageGenerator + * @{ + * + * @brief Provides APIs for generating an image at the specific time from a video resource. + * + * @syscap SystemCapability.Multimedia.Media.AVImageGenerator + * @since 16 + */ + +/** + * @file avimage_generator_base.h + * + * @brief Defines the structure and enumeration for AVImageGenerator. + * + * @syscap SystemCapability.Multimedia.Media.AVImageGenerator + * @kit MediaKit + * @library libavimage_generator.so + * @since 16 + */ + +#ifndef MULTIMEDIA_PLAYER_FRAMEWORK_NATIVE_AVIMAGE_GENERATOR_BASE_H +#define MULTIMEDIA_PLAYER_FRAMEWORK_NATIVE_AVIMAGE_GENERATOR_BASE_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Enumerates the image query options about the relationship between the given timeUs and a key frame. + * + * @syscap SystemCapability.Multimedia.Media.AVImageGenerator + * @since 16 + */ +typedef enum OH_AVImageGenerator_QueryOptions { + /** + * This option is used to fetch a key frame from the given media + * resource that is located right after or at the given time. + */ + OH_AVIMAGE_GENERATOR_QUERY_NEXT_SYNC = 0, + /** + * This option is used to fetch a key frame from the given media + * resource that is located right before or at the given time. + */ + OH_AVIMAGE_GENERATOR_QUERY_PREVIOUS_SYNC = 1, + /** + * This option is used to fetch a key frame from the given media + * resource that is located closest to or at the given time. + */ + OH_AVIMAGE_GENERATOR_QUERY_CLOSEST_SYNC = 2, + /** + * This option is used to fetch a frame (maybe not keyframe) from + * the given media resource that is located closest to or at the given time. + */ + OH_AVIMAGE_GENERATOR_QUERY_CLOSEST = 3, +} OH_AVImageGenerator_QueryOptions; + +#ifdef __cplusplus +} +#endif +#endif // MULTIMEDIA_PLAYER_FRAMEWORK_NATIVE_AVMETADATA_EXTRACTOR_BASE_H +/** @} */ diff --git a/multimedia/player_framework/avmetadata_extractor.h b/multimedia/player_framework/avmetadata_extractor.h new file mode 100644 index 000000000..b6d5bba33 --- /dev/null +++ b/multimedia/player_framework/avmetadata_extractor.h @@ -0,0 +1,136 @@ +/* + * Copyright (C) 2025 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 AVMetadataExtractor + * @{ + * + * @brief Provides APIs of metadata capability for Media Source. + * + * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor + * @since 16 + */ + +/** + * @file avmetadata_extractor.h + * + * @brief Defines the avmetadata extractor APIs. Uses the Native APIs provided by Media AVMetadataExtractor + * to get metadata from the media source. + * + * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor + * @kit MediaKit + * @library libavmetadata_extractor.so + * @since 16 + */ + +#ifndef MULTIMEDIA_PLAYER_FRAMEWORK_NATIVE_AVMETADATA_EXTRACTOR_H +#define MULTIMEDIA_PLAYER_FRAMEWORK_NATIVE_AVMETADATA_EXTRACTOR_H + +#include +#include +#include +#include "native_averrors.h" +#include "avmetadata_extractor_base.h" +#include "native_avcodec_base.h" +#include "native_avformat.h" +#include "multimedia/image_framework/image/pixelmap_native.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Define OH_AVMetadataExtractor field. + * + * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor + * @since 16 + */ +typedef struct OH_AVMetadataExtractor OH_AVMetadataExtractor; + +/** + * @brief Create a metadata extractor. + * + * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor + * @return Returns a pointer to an OH_AVMetadataExtractor instance for success, nullptr for failure + * Possible failure causes: failed to HstEngineFactory::CreateAVMetadataHelperEngine. + * @since 16 + */ +OH_AVMetadataExtractor* OH_AVMetadataExtractor_Create(void); + +/** + * @brief Sets the media file descriptor source for the metadata extractor. + * + * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor + * @param extractor Pointer to an OH_AVMetadataExtractor instance. + * @param fd Indicates the file descriptor of media source. + * @param offset Indicates the offset of media source in file descriptor. + * @param size Indicates the size of media source. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INPUT_DATA_ERROR} if input extractor is nullptr or input param is invalid. + * @since 16 + */ +OH_AVErrCode OH_AVMetadataExtractor_SetFDSource(OH_AVMetadataExtractor* extractor, + int32_t fd, int64_t offset, int64_t size); + +/** + * @brief Extract metadata info from the media source. + * This function must be called after {@link SetFDSource}. + * + * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor + * @param extractor Pointer to an OH_AVMetadataExtractor instance. + * @param avMetadata Pointer to an {@link OH_AVFormat} instance, its content contains the fetched metadata info. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INPUT_DATA_ERROR} if input extractor is nullptr or input param is invalid. + * {@link AV_ERR_OPERATE_NOT_PERMIT} if operation not allowed. + * @since 16 + */ +OH_AVErrCode OH_AVMetadataExtractor_FetchMetadata(OH_AVMetadataExtractor* extractor, OH_AVFormat* avMetadata); + +/** + * @brief Fetch album cover from the audio source. + * This function must be called after {@link SetFDSource}. + * + * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor + * @param extractor Pointer to an OH_AVMetadataExtractor instance. + * @param pixelMap The fetched album cover from the audio source. For details, see {@link OH_PixelmapNative}. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INPUT_DATA_ERROR} if input extractor is nullptr or input param is invalid. + * {@link AV_ERR_OPERATE_NOT_PERMIT} if operation not allowed. + * @since 16 + */ +OH_AVErrCode OH_AVMetadataExtractor_FetchAlbumCover(OH_AVMetadataExtractor* extractor, OH_PixelmapNative** pixelMap); + +/** + * @brief Release the resource used for AVMetadataExtractor. + * + * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor + * @param extractor Pointer to an OH_AVMetadataExtractor instance. + * @return Function result code. + * {@link AV_ERR_OK} if the execution is successful. + * {@link AV_ERR_INPUT_DATA_ERROR} if input extractor is nullptr or input param is invalid. + * {@link AV_ERR_OPERATE_NOT_PERMIT} if operation not allowed. + * @since 16 + */ +OH_AVErrCode OH_AVMetadataExtractor_Release(OH_AVMetadataExtractor* extractor); + +#ifdef __cplusplus +} +#endif + +#endif // MULTIMEDIA_PLAYER_FRAMEWORK_NATIVE_AVMETADATA_EXTRACTOR_H +/** @} */ diff --git a/multimedia/player_framework/avmetadata_extractor/BUILD.gn b/multimedia/player_framework/avmetadata_extractor/BUILD.gn new file mode 100644 index 000000000..7d8ec2529 --- /dev/null +++ b/multimedia/player_framework/avmetadata_extractor/BUILD.gn @@ -0,0 +1,36 @@ +# Copyright (C) 2025 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. + +import("//build/ohos.gni") +import("//build/ohos/ndk/ndk.gni") +import("//foundation/multimedia/player_framework/config.gni") + +ohos_ndk_headers("avmetadata_extractor_header") { + dest_dir = "$ndk_headers_out_dir/multimedia/player_framework" + sources = [ + "../avmetadata_extractor.h", + "../avmetadata_extractor_base.h", + ] +} + +ohos_ndk_library("libavmetadata_extractor") { + ndk_description_file = "./libavmetadata_extractor.ndk.json" + output_name = "avmetadata_extractor" + output_extension = "so" + + system_capability = "SystemCapability.Multimedia.Media.AVMetadataExtractor" + system_capability_headers = [ + "multimedia/player_framework/avmetadata_extractor.h", + "multimedia/player_framework/avmetadata_extractor_base.h", + ] +} \ No newline at end of file diff --git a/multimedia/player_framework/avmetadata_extractor/libavmetadata_extractor.ndk.json b/multimedia/player_framework/avmetadata_extractor/libavmetadata_extractor.ndk.json new file mode 100644 index 000000000..f4c4de80d --- /dev/null +++ b/multimedia/player_framework/avmetadata_extractor/libavmetadata_extractor.ndk.json @@ -0,0 +1,22 @@ +[ + { + "first_introduced": "16", + "name": "OH_AVMetadataExtractor_Create" + }, + { + "first_introduced": "16", + "name": "OH_AVMetadataExtractor_SetFDSource" + }, + { + "first_introduced": "16", + "name": "OH_AVMetadataExtractor_FetchMetadata" + }, + { + "first_introduced": "16", + "name": "OH_AVMetadataExtractor_FetchAlbumCover" + }, + { + "first_introduced": "16", + "name": "OH_AVMetadataExtractor_Release" + } +] \ No newline at end of file diff --git a/multimedia/player_framework/avmetadata_extractor_base.h b/multimedia/player_framework/avmetadata_extractor_base.h new file mode 100644 index 000000000..75c18f5a5 --- /dev/null +++ b/multimedia/player_framework/avmetadata_extractor_base.h @@ -0,0 +1,225 @@ +/* + * Copyright (C) 2025 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 AVMetadataExtractor + * @{ + * + * @brief Provides APIs of metadata capability for Media Source. + * + * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor + * @since 16 + */ + +/** + * @file avmetadata_extractor_base.h + * + * @brief Defines the structure and enumeration for AVMetadataExtractor. + * + * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor + * @kit MediaKit + * @library libavmetadata_extractor.so + * @since 16 + */ + +#ifndef MULTIMEDIA_PLAYER_FRAMEWORK_NATIVE_AVMETADATA_EXTRACTOR_BASE_H +#define MULTIMEDIA_PLAYER_FRAMEWORK_NATIVE_AVMETADATA_EXTRACTOR_BASE_H + +#include + +#include "native_avformat.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +/** + * @brief Key to get the album title of the media source, value type is const char*. + * + * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor + * @since 16 + */ +static const char* OH_AVMETADATA_EXTRACTOR_ALBUM = "album"; + +/** + * @brief Key to get the album performer or artist associated, value type is const char*. + * + * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor + * @since 16 + */ +static const char* OH_AVMETADATA_EXTRACTOR_ALBUM_ARTIST = "albumArtist"; + +/** + * @brief Key to get the artist name, value type is const char*. + * + * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor + * @since 16 + */ +static const char* OH_AVMETADATA_EXTRACTOR_ARTIST = "artist"; + +/** + * @brief Key to get the author name, value type is const char*. + * + * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor + * @since 16 + */ +static const char* OH_AVMETADATA_EXTRACTOR_AUTHOR = "author"; + +/** + * @brief Key to get the created time of the media source, value type is const char*. + * + * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor + * @since 16 + */ +static const char* OH_AVMETADATA_EXTRACTOR_DATE_TIME = "dateTime"; + +/** + * @brief Key to get the created or modified time with the specific date format, value type is const char*. + * + * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor + * @since 16 + */ +static const char* OH_AVMETADATA_EXTRACTOR_DATE_TIME_FORMAT = "dateTimeFormat"; + +/** + * @brief Key to get the composer of the media source, value type is const char*. + * + * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor + * @since 16 + */ +static const char* OH_AVMETADATA_EXTRACTOR_COMPOSER = "composer"; + +/** + * @brief Key to get the playback duration of the media source, value type is int64_t, value unit is millisecond (ms). + * + * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor + * @since 16 + */ +static const char* OH_AVMETADATA_EXTRACTOR_DURATION = "duration"; + +/** + * @brief Key to get the content type or genre, value type is const char*. + * + * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor + * @since 16 + */ +static const char* OH_AVMETADATA_EXTRACTOR_GENRE = "genre"; + +/** + * @brief Key to get the value whether the media resource contains audio content, + * value type is int32_t. 1 means true and 0 means false. + * + * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor + * @since 16 + */ +static const char* OH_AVMETADATA_EXTRACTOR_HAS_AUDIO = "hasAudio"; + +/** + * @brief Key to get the value whether the media resource contains video content, + * value type is int32_t. 1 means true and 0 means false. + * + * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor + * @since 16 + */ +static const char* OH_AVMETADATA_EXTRACTOR_HAS_VIDEO = "hasVideo"; + +/** + * @brief Key to get the mime type of the media source, value type is const char*. + * Some example mime types include: "video/mp4", "audio/mp4", "audio/amr-wb". + * + * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor + * @since 16 + */ +static const char* OH_AVMETADATA_EXTRACTOR_MIME_TYPE = "mimeType"; + +/** + * @brief Key to get the number of tracks, value type is int32_t. + * + * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor + * @since 16 + */ +static const char* OH_AVMETADATA_EXTRACTOR_TRACK_COUNT = "trackCount"; + +/** + * @brief Key to get the audio sample rate, value type is int32_t. + * + * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor + * @since 16 + */ +static const char* OH_AVMETADATA_EXTRACTOR_SAMPLE_RATE = "sampleRate"; + +/** + * @brief Key to get the media source title, value type is const char*. + * + * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor + * @since 16 + */ +static const char* OH_AVMETADATA_EXTRACTOR_TITLE = "title"; + +/** + * @brief Key to get the video height if the media contains video, value type is int32_t. + * + * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor + * @since 16 + */ +static const char* OH_AVMETADATA_EXTRACTOR_VIDEO_HEIGHT = "videoHeight"; + +/** + * @brief Key to get the video width if the media contains video, value type is int32_t. + * + * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor + * @since 16 + */ +static const char* OH_AVMETADATA_EXTRACTOR_VIDEO_WIDTH = "videoWidth"; + +/** + * @brief Key to get the video rotation angle, value type is int32_t. + * + * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor + * @since 16 + */ +static const char* OH_AVMETADATA_EXTRACTOR_VIDEO_ORIENTATION = "videoOrientation"; + +/** + * @brief Key to get the information whether the video is HDR video, value type is int32_t. + * For details of the value, see {@link OH_Core_HdrType} defined in {@link media_types.h}. + * + * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor + * @since 16 + */ +static const char* OH_AVMETADATA_EXTRACTOR_VIDEO_IS_HDR_VIVID = "hdrType"; + +/** + * @brief Key to get the latitude value in the geographical location, value type is float. + * + * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor + * @since 16 + */ +static const char* OH_AVMETADATA_EXTRACTOR_LOCATION_LATITUDE = "latitude"; + +/** + * @brief Key to get the longitude value in the geographical location, value type is float. + * + * @syscap SystemCapability.Multimedia.Media.AVMetadataExtractor + * @since 16 + */ +static const char* OH_AVMETADATA_EXTRACTOR_LOCATION_LONGITUDE = "longitude"; + +#ifdef __cplusplus +} +#endif +#endif // MULTIMEDIA_PLAYER_FRAMEWORK_NATIVE_AVMETADATA_EXTRACTOR_BASE_H +/** @} */ diff --git a/ndk_targets.gni b/ndk_targets.gni index da0d52f11..b83bf2025 100644 --- a/ndk_targets.gni +++ b/ndk_targets.gni @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) 2021-2025 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 @@ -138,6 +138,10 @@ _ndk_library_targets = [ "//interface/sdk_c/multimedia/player_framework/avplayer:avplayer_header", "//interface/sdk_c/multimedia/player_framework/avrecorder:libavrecorder", "//interface/sdk_c/multimedia/player_framework/avrecorder:avrecorder_header", + "//interface/sdk_c/multimedia/player_framework/avmetadata_extractor:libavmetadata_extractor", + "//interface/sdk_c/multimedia/player_framework/avmetadata_extractor:avmetadata_extractor_header", + "//interface/sdk_c/multimedia/player_framework/avimage_generator:libavimage_generator", + "//interface/sdk_c/multimedia/player_framework/avimage_generator:avimage_generator_header", "//interface/sdk_c/multimedia/audio_framework:libohaudio_ndk", "//interface/sdk_c/multimedia/audio_framework:ohaudio_header", "//interface/sdk_c/multimedia/av_session:libohavsession_ndk", -- Gitee