diff --git a/zh-cn/native_sdk/multimedia/audio_framework/audio_manager/native_audio_stream_manager.h b/zh-cn/native_sdk/multimedia/audio_framework/audio_manager/native_audio_stream_manager.h new file mode 100644 index 0000000000000000000000000000000000000000..7da277112e9e83782d31116c9a07c72e545bfe5a --- /dev/null +++ b/zh-cn/native_sdk/multimedia/audio_framework/audio_manager/native_audio_stream_manager.h @@ -0,0 +1,93 @@ +/* + * 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 OHAudio + * @{ + * + * @brief 提供音频模块C接口定义。 + * + * @syscap SystemCapability.Multimedia.Audio.Core + * + * @since 19 + */ + +/** + * @file native_audio_stream_manager.h + * + * @brief 声明与音频流管理器相关的接口。 + * + * 该文件接口用于创建audioStreamManager以及音频流设置和管理。 + * + * @library libohaudio.so + * @syscap SystemCapability.Multimedia.Audio.Core + * @kit AudioKit + * @since 19 + */ + +#ifndef NATIVE_AUDIO_STREAM_MANAGER_H +#define NATIVE_AUDIO_STREAM_MANAGER_H + +#include "native_audio_common.h" +#include "native_audiostream_base.h" +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief 声明音频流管理器,用于管理音频流相关功能。 + * + * @since 19 + */ +typedef struct OH_AudioStreamManager OH_AudioStreamManager; + +/** + * @brief 获取音频流管理器句柄。 + * + * @param streamManager 音频流管理器句柄 {@link #OH_AudioStreamManager}。 + * @return {@link OH_AudioCommon_Result}:\n + * AUDIOCOMMON_RESULT_SUCCESS = 0:函数执行成功。\n + * AUDIOCOMMON_RESULT_ERROR_SYSTEM = 6800301:系统状态错误。 + * @since 19 + */ +OH_AudioCommon_Result OH_AudioManager_GetAudioStreamManager(OH_AudioStreamManager **streamManager); + +/** + * @brief 获取当前音频流支持的direct通路播放模式。 + * + * @param audioStreamManager 音频流管理器句柄 {@link OH_AudioStreamManager}。 + * 通过 {@link OH_AudioManager_GetAudioStreamManager} 获取句柄。 + * @param streamInfo 音频流信息指针 {@link OH_AudioStreamInfo}。 + * @param usage 音频流使用场景 {@link OH_AudioStream_Usage}。 + * @param directPlaybackMode 指向 {@link OH_AudioStream_DirectPlaybackMode},用于获取当前音频流支持的direct通路播放模式。 + * @return {@link OH_AudioCommon_Result}:\n + * AUDIOCOMMON_RESULT_SUCCESS = 0:函数执行成功。\n + * AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM = 6800101:\n + * 1. 参数audioStreamManager为nullptr;\n + * 2. 参数streamInfo为nullptr;\n + * 3. 参数usage无效;\n + * 4. 参数directPlaybackMode为nullptr。 + * @since 19 + */ +OH_AudioCommon_Result OH_AudioStreamManager_GetDirectPlaybackSupport( + OH_AudioStreamManager *audioStreamManager, OH_AudioStreamInfo *streamInfo, + OH_AudioStream_Usage usage, OH_AudioStream_DirectPlaybackMode *directPlaybackMode); + +#ifdef __cplusplus +} +#endif + +#endif // NATIVE_AUDIO_STREAM_MANAGER_H +/** @} */ diff --git a/zh-cn/native_sdk/multimedia/audio_framework/common/native_audiostream_base.h b/zh-cn/native_sdk/multimedia/audio_framework/common/native_audiostream_base.h index ab12504fe726c5008d084885d348b17400b23799..5b3280237746903542c191e29fed2a929c2c77d9 100644 --- a/zh-cn/native_sdk/multimedia/audio_framework/common/native_audiostream_base.h +++ b/zh-cn/native_sdk/multimedia/audio_framework/common/native_audiostream_base.h @@ -39,6 +39,7 @@ #define NATIVE_AUDIOSTREAM_BASE_H #include +#include "multimedia/native_audio_channel_layout.h" #ifdef __cplusplus extern "C" { @@ -69,7 +70,14 @@ typedef enum { /** * 系统通用错误。 */ - AUDIOSTREAM_ERROR_SYSTEM = 3 + AUDIOSTREAM_ERROR_SYSTEM = 3, + + /** + * 不支持的音频格式,如不支持的编码类型、采样格式等。 + * + * @since 19 + */ + AUDIOSTREAM_ERROR_UNSUPPORTED_FORMAT = 4 } OH_AudioStream_Result; /** @@ -132,8 +140,46 @@ typedef enum { * @since 12 */ AUDIOSTREAM_ENCODING_TYPE_AUDIOVIVID = 1, + /** + * E_AC3编码。 + * + * @since 19 + */ + AUDIOSTREAM_ENCODING_TYPE_E_AC3 = 2, } OH_AudioStream_EncodingType; +/** + * @brief 定义音频流信息,用于描述基本音频格式。 + * + * @since 19 + */ +typedef struct OH_AudioStreamInfo { + /** + * @brief 音频流采样率。 + * + * @since 19 + */ + int32_t samplingRate; + /** + * @brief 音频流声道布局。 + * + * @since 19 + */ + OH_AudioChannelLayout channelLayout; + /** + * @brief 音频流编码类型。 + * + * @since 19 + */ + OH_AudioStream_EncodingType encodingType; + /** + * @brief 音频流采样格式。 + * + * @since 19 + */ + OH_AudioStream_SampleFormat sampleFormat; +} OH_AudioStreamInfo; + /** * @brief 定义音频流使用场景。 * @@ -219,6 +265,32 @@ typedef enum { AUDIOSTREAM_LATENCY_MODE_FAST = 1 } OH_AudioStream_LatencyMode; +/** + * @brief 定义音频流direct通路播放模式。 + * + * @since 19 + */ +typedef enum { + /** + * 该模式代表不支持direct通路播放。 + * + * @since 19 + */ + AUDIOSTREAM_DIRECT_PLAYBACK_NOT_SUPPORTED = 0, + /** + * 该模式代表支持不解码的direct通路播放。 + * + * @since 19 + */ + AUDIOSTREAM_DIRECT_PLAYBACK_BITSTREAM_SUPPORTED = 1, + /** + * 该模式代表支持pcm编码的direct通路播放。 + * + * @since 19 + */ + AUDIOSTREAM_DIRECT_PLAYBACK_PCM_SUPPORTED = 2 +} OH_AudioStream_DirectPlaybackMode; + /** * @brief 定义音频流音量模式。 *