From a229a2a2c557a1051bb7d4187df87cd51c9150b9 Mon Sep 17 00:00:00 2001 From: g00514389 Date: Tue, 25 Mar 2025 15:15:07 +0800 Subject: [PATCH] add new audio format related apis Signed-off-by: g00514389 --- .../native_audio_stream_manager.h | 104 ++++++++++++++++++ .../common/native_audiostream_base.h | 41 ++++++- 2 files changed, 144 insertions(+), 1 deletion(-) create mode 100644 multimedia/audio_framework/audio_manager/native_audio_stream_manager.h diff --git a/multimedia/audio_framework/audio_manager/native_audio_stream_manager.h b/multimedia/audio_framework/audio_manager/native_audio_stream_manager.h new file mode 100644 index 000000000..7c4b43439 --- /dev/null +++ b/multimedia/audio_framework/audio_manager/native_audio_stream_manager.h @@ -0,0 +1,104 @@ +/* + * 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 Provide the definition of the C interface for the audio module. + * + * @syscap SystemCapability.Multimedia.Audio.Core + * + * @since 12 + * @version 1.0 + */ + +/** + * @file native_audio_stream_manager.h + * + * @brief Declare audio stream manager related interfaces. + * + * This file interface is used for the creation of audioStreamManager + * as well as the audio stream settings and management. + * + * @library libohaudio.so + * @syscap SystemCapability.Multimedia.Audio.Core + * @kit AudioKit + * @since 19 + * @version 1.0 + */ + +#ifndef NATIVE_AUDIO_STREAM_MANAGER_H +#define NATIVE_AUDIO_STREAM_MANAGER_H + +#include "native_audiostream_base.h" +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Declaring the audio stream manager. + * The handle of audio stream manager used for audio stream settings and management. + * + * @since 19 + */ +typedef struct OH_AudioStreamManager OH_AudioStreamManager; + +/** + * @brief Query the audio stream manager handle. + * which should be set as the first parameter in stream management releated functions. + * + * @param audioStreamManager the {@link OH_AudioStreamManager} + * handle returned by {@link OH_AudioManager_GetAudioStreamManager}. + * @return Function result code: + * {@link AUDIOCOMMON_RESULT_SUCCESS} If the execution is successful. + * @since 19 + */ +OH_AudioCommon_Result OH_AudioManager_GetAudioStreamManager(OH_AudioStreamManager **audioStreamManager); + +/** + * @brief Gets the mode of direct playback available for a given audio format with current active device. + * + * @param audioStreamManager the {@link OH_AudioStreamManager} + * handle returned by {@link OH_AudioManager_GetAudioStreamManager}. + * @param encodingType the {@link OH_AudioStream_EncodingType}. + * @param format the {@link @OH_AudioStream_SampleFormat}. + * @param channelCount the channel count. + * @param smplingRate the sampling rate. + * @param usage the {@link OH_AudioStream_Usage}. + * @param directPlaybackMode the {@link OH_AudioStream_DirectPlaybackMode} + * pointer to a variable which receives the result. + * @return Function result code: + * {@link AUDIOCOMMON_RESULT_SUCCESS} If the execution is successful. + * {@link AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM}: + * 1.The param of audioStreamManager is nullptr; + * 2.The param of encodingType invalid; + * 3.The param of format invalid; + * 4.The param of channelCount invalid; + * 5.The param of samplingRate invalid; + * 6.The param of usage invalid; + * @since 19 + */ +OH_AudioCommon_Result OH_AudioStreamManager_GetDirectPlaybackSupport( + OH_AudioStreamManager *audioStreamManager, OH_AudioStream_EncodingType encodingType, + OH_AudioStream_SampleFormat format, int32_t channelCount, int32_t samplingRate, + OH_AudioStream_Usage usage, OH_AudioStream_DirectPlaybackMode *directPlaybackMode); + +#ifdef __cplusplus +} +#endif + +#endif // NATIVE_AUDIO_STREAM_MANAGER_H +/** @} */ diff --git a/multimedia/audio_framework/common/native_audiostream_base.h b/multimedia/audio_framework/common/native_audiostream_base.h index 6b1fb6cb6..49ccbbb96 100644 --- a/multimedia/audio_framework/common/native_audiostream_base.h +++ b/multimedia/audio_framework/common/native_audiostream_base.h @@ -78,7 +78,14 @@ typedef enum { * * @since 10 */ - AUDIOSTREAM_ERROR_SYSTEM = 3 + AUDIOSTREAM_ERROR_SYSTEM = 3, + + /** + * @error Unsupported audio format, such as unsupported encoding type, sample format etc. + * + * @since 19 + */ + AUDIOSTREAM_ERROR_UNSUPPORTED_FORMAT = 4 } OH_AudioStream_Result; /** @@ -159,6 +166,12 @@ typedef enum { * @since 12 */ AUDIOSTREAM_ENCODING_TYPE_AUDIOVIVID = 1, + /** + * E_AC3 encoding type. + * + * @since 19 + */ + AUDIOSTREAM_ENCODING_TYPE_E_AC3 = 2, } OH_AudioStream_EncodingType; /** @@ -275,6 +288,32 @@ typedef enum { AUDIOSTREAM_LATENCY_MODE_FAST = 1 } OH_AudioStream_LatencyMode; +/** + * @brief Enumerates audio direct playback modes. + * + * @since 19 + */ +typedef enum { + /** + * Direct playback is not supported. + * + * @since 19 + */ + AUDIOSTREAM_DIRECT_PLAYBACK_NOT_SUPPORTED = 0, + /** + * Direct playback mode which is bitstream pass-through such as compressed pass-through. + * + * @since 19 + */ + AUDIOSTREAM_DIRECT_PLAYBACK_BITSTREAM_SUPPORTED = 1, + /** + * Direct playback mode which is pcm pass-through, without any process such as resampling. + * + * @since 19 + */ + AUDIOSTREAM_DIRECT_PLAYBACK_PCM_SUPPORTED= 2 +} OH_AudioStream_DirectPlaybackMode; + /** * @brief Define the audio event. * -- Gitee