diff --git a/multimedia/audio_framework/audio_renderer/native_audiorenderer.h b/multimedia/audio_framework/audio_renderer/native_audiorenderer.h index 8b201d9789ff39032c418d16398d732681438f0b..389bce20d4ad67530f3f142d1e6cbbcbcbd3bfdf 100644 --- a/multimedia/audio_framework/audio_renderer/native_audiorenderer.h +++ b/multimedia/audio_framework/audio_renderer/native_audiorenderer.h @@ -226,6 +226,28 @@ OH_AudioStream_Result OH_AudioRenderer_GetTimestamp(OH_AudioRenderer* renderer, * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. */ OH_AudioStream_Result OH_AudioRenderer_GetFrameSizeInCallback(OH_AudioRenderer* renderer, int32_t* frameSize); + +/* + * Query the current audio effect mode. + * + * @since 11 + * + * @param renderer Reference created by OH_AudioStreamBuilder_GenerateRenderer() + * @param effectMode Pointer to a variable to receive the current audio effect mode. + * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. + */ +OH_AudioStream_Result OH_AudioRenderer_GetAudioEffectMode(OH_AudioRenderer* renderer, OH_AudioEffectMode* effectMode); + +/* + * Set the current audio effect mode. + * + * @since 11 + * + * @param renderer Reference created by OH_AudioStreamBuilder_GenerateRenderer() + * @param effectMode is the variable that will be set for the audio effect mode. + * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. + */ +OH_AudioStream_Result OH_AudioRenderer_SetAudioEffectMode(OH_AudioRenderer* renderer, OH_AudioEffectMode effectMode); #ifdef __cplusplus } #endif diff --git a/multimedia/audio_framework/common/native_audio_channel_layout.h b/multimedia/audio_framework/common/native_audio_channel_layout.h new file mode 100644 index 0000000000000000000000000000000000000000..f37e3705856bc8d9a9ef2c8c84d4595d75f42543 --- /dev/null +++ b/multimedia/audio_framework/common/native_audio_channel_layout.h @@ -0,0 +1,151 @@ +/* + * 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. + */ +#include + +/** + * Audio Channel Set + * A 64-bit integer with bits set for each channel. + * @since 11 + */ +enum AudioChannelSet: uint64_t { + FRONT_LEFT = 1ULL << 0U, + FRONT_RIGHT = 1ULL << 1U, + FRONT_CENTER = 1ULL << 2U, + LOW_FREQUENCY = 1ULL << 3U, + BACK_LEFT = 1ULL << 4U, + BACK_RIGHT = 1ULL << 5U, + FRONT_LEFT_OF_CENTER = 1ULL << 6U, + FRONT_RIGHT_OF_CENTER = 1ULL << 7U, + BACK_CENTER = 1ULL << 8U, + SIDE_LEFT = 1ULL << 9U, + SIDE_RIGHT = 1ULL << 10U, + TOP_CENTER = 1ULL << 11U, + TOP_FRONT_LEFT = 1ULL << 12U, + TOP_FRONT_RIGHT = 1ULL << 13U, + TOP_FRONT_CENTER = 1ULL << 14U, + TOP_BACK_LEFT = 1ULL << 15U, + TOP_BACK_RIGHT = 1ULL << 16U, + TOP_BACK_CENTER = 1ULL << 17U, + STEREO_LEFT = 1ULL << 29U, + STEREO_RIGHT = 1ULL << 30U, + WIDE_LEFT = 1ULL << 31U, + WIDE_RIGHT = 1ULL << 32U, + SURROUND_DIRECT_LEFT = 1ULL << 33U, + SURROUND_DIRECT_RIGHT = 1ULL << 34U, + LOW_FREQUENCY_2 = 1ULL << 35U, + TOP_SIDE_LEFT = 1ULL << 36U, + TOP_SIDE_RIGHT = 1ULL << 37U, + BOTTOM_FRONT_LEFT = 1ULL << 38U, + BOTTOM_FRONT_RIGHT = 1ULL << 39U, + BOTTOM_FRONT_CENTER = 1ULL << 40U +}; + +/** + * Number of HOA Order. + * A 64-bit integer specifies the HOA order. + * @since 11 + */ + +enum AmbAttributeSet: uint64_t { + /** AMB Order */ + AMB_ORD_1 = 1ULL << 0U, + AMB_ORD_2 = 2ULL << 0U, + AMB_ORD_3 = 3ULL << 0U, + /** AMB Component Ordering */ + AMB_COM_ACN = 0ULL << 8U, + AMB_COM_FUMA = 1ULL << 8U, + /** AMB Normalization */ + AMB_NOR_N3D = 0ULL << 12U, + AMB_NOR_SN3D = 1ULL << 12U, + /** AMB Mode Marker */ + AMB_MODE = 1 << 44U +} + +/** + * Audio AudioChannel Layout + * A 64-bit integer indicates that the appearance and order of the speakers for recording or playback. + * @since 11 + */ +enum AudioChannelLayout: uint64_t { + CH_LAYOUT_UNKNOWN = 0ULL, + /** Channel count: 1*/ + CH_LAYOUT_MONO = FRONT_CENTER, + /** Channel count: 2*/ + CH_LAYOUT_STEREO = FRONT_LEFT | FRONT_RIGHT, + CH_LAYOUT_STEREO_DOWNMIX = STEREO_LEFT | STEREO_RIGHT, + /** Channel count: 3*/ + CH_LAYOUT_2POINT1 = CH_LAYOUT_STEREO | LOW_FREQUENCY, + CH_LAYOUT_3POINT0 = CH_LAYOUT_STEREO | BACK_CENTER, + CH_LAYOUT_SURROUND = CH_LAYOUT_STEREO | FRONT_CENTER, + /** Channel count: 4*/ + CH_LAYOUT_3POINT1 = CH_LAYOUT_SURROUND | LOW_FREQUENCY, + CH_LAYOUT_4POINT0 = CH_LAYOUT_SURROUND | BACK_CENTER, + CH_LAYOUT_QUAD_SIDE = CH_LAYOUT_STEREO | SIDE_LEFT | SIDE_RIGHT, + CH_LAYOUT_QUAD = CH_LAYOUT_STEREO | BACK_LEFT | BACK_RIGHT, + CH_LAYOUT_2POINT0POINT2 = CH_LAYOUT_STEREO | TOP_SIDE_LEFT | TOP_SIDE_RIGHT, + CH_LAYOUT_AMB_ORDER1_ACN_N3D = AMB_MODE | AMB_ORD_1 | AMB_COM_ACN | AMB_NOR_N3D, + CH_LAYOUT_AMB_ORDER1_ACN_SN3D = AMB_MODE | AMB_ORD_1 | AMB_COM_ACN | AMB_NOR_SN3D, + CH_LAYOUT_AMB_ORDER1_FUMA = AMB_MODE | AMB_ORD_1 | AMB_COM_FUMA + /** Channel count: 5*/ + CH_LAYOUT_4POINT1 = CH_LAYOUT_4POINT0 | LOW_FREQUENCY, + CH_LAYOUT_5POINT0 = CH_LAYOUT_SURROUND | SIDE_LEFT | SIDE_RIGHT, + CH_LAYOUT_5POINT0_BACK = CH_LAYOUT_SURROUND | BACK_LEFT | BACK_RIGHT, + CH_LAYOUT_2POINT1POINT2 = CH_LAYOUT_2POINT0POINT2 | LOW_FREQUENCY, + CH_LAYOUT_3POINT0POINT2 = CH_LAYOUT_2POINT0POINT2 | FRONT_CENTER, + /** Channel count: 6*/ + CH_LAYOUT_5POINT1 = CH_LAYOUT_5POINT0 | LOW_FREQUENCY, + CH_LAYOUT_5POINT1_BACK = CH_LAYOUT_5POINT0_BACK | LOW_FREQUENCY, + CH_LAYOUT_6POINT0 = CH_LAYOUT_5POINT0 | BACK_CENTER, + CH_LAYOUT_HEXAGONAL = CH_LAYOUT_5POINT0_BACK | BACK_CENTER, + CH_LAYOUT_3POINT1POINT2 = CH_LAYOUT_3POINT0POINT2 |LOW_FREQUENCY, + CH_LAYOUT_6POINT0_FRONT = CH_LAYOUT_2_2 | FRONT_LEFT_OF_CENTER | FRONT_RIGHT_OF_CENTER, + /** Channel count: 7*/ + CH_LAYOUT_6POINT1 = CH_LAYOUT_5POINT1 | BACK_CENTER, + CH_LAYOUT_6POINT1_BACK = CH_LAYOUT_5POINT1_BACK | BACK_CENTER, + CH_LAYOUT_6POINT1_FRONT = CH_LAYOUT_6POINT0_FRONT | LOW_FREQUENCY, + CH_LAYOUT_7POINT0 = CH_LAYOUT_5POINT0 | BACK_LEFT | BACK_RIGHT, + CH_LAYOUT_7POINT0_FRONT = CH_LAYOUT_5POINT0 | FRONT_LEFT_OF_CENTER | FRONT_RIGHT_OF_CENTER, + /** Channel count: 8*/ + CH_LAYOUT_7POINT1 = CH_LAYOUT_5POINT1 | BACK_LEFT | BACK_RIGHT, + CH_LAYOUT_OCTAGONAL = CH_LAYOUT_5POINT0 | BACK_CENTER | BACK_LEFT | BACK_RIGHT, + CH_LAYOUT_5POINT1POINT2 = CH_LAYOUT_5POINT1_BACK | TOP_SIDE_LEFT | TOP_SIDE_RIGHT, + CH_LAYOUT_7POINT1_WIDE = CH_LAYOUT_5POINT1 | FRONT_LEFT_OF_CENTER | FRONT_RIGHT_OF_CENTER, + CH_LAYOUT_7POINT1_WIDE_BACK = CH_LAYOUT_5POINT1_BACK | FRONT_LEFT_OF_CENTER | FRONT_RIGHT_OF_CENTER, + /** Channel count: 9*/ + CH_LAYOUT_AMB_ORDER2_ACN_N3D = AMB_MODE | AMB_ORD_2 | AMB_COM_ACN | AMB_NOR_N3D, + CH_LAYOUT_AMB_ORDER2_ACN_SN3D = AMB_MODE | AMB_ORD_2 | AMB_COM_ACN | AMB_NOR_SN3D, + CH_LAYOUT_AMB_ORDER2_FUMA = AMB_MODE | AMB_ORD_2 | AMB_COM_FUMA, + /** Channel count: 10*/ + CH_LAYOUT_5POINT1POINT4 = CH_LAYOUT_5POINT1_BACK | TOP_FRONT_LEFT | TOP_FRONT_RIGHT | + TOP_BACK_LEFT |TOP_BACK_RIGHT, + CH_LAYOUT_7POINT1POINT2 = CH_LAYOUT_7POINT1 | TOP_SIDE_LEFT | TOP_SIDE_RIGHT, + /** Channel count: 12*/ + CH_LAYOUT_7POINT1POINT4 = CH_LAYOUT_7POINT1 | TOP_FRONT_LEFT | TOP_FRONT_RIGHT | TOP_BACK_LEFT | TOP_BACK_RIGHT, + CH_LAYOUT_10POINT2 = FRONT_LEFT | FRONT_RIGHT | FRONT_CENTER | TOP_FRONT_LEFT | TOP_FRONT_RIGHT + | BACK_LEFT | BACK_RIGHT | BACK_CENTER | SIDE_LEFT | SIDE_RIGHT | WIDE_LEFT | WIDE_RIGHT, + /** Channel count: 14*/ + CH_LAYOUT_9POINT1POINT4 = CH_LAYOUT_7POINT1POINT4 | WIDE_LEFT | WIDE_RIGHT, + /** Channel count: 16*/ + CH_LAYOUT_9POINT1POINT6 = CH_LAYOUT_9POINT1POINT4 | TOP_SIDE_LEFT | TOP_SIDE_RIGHT, + CH_LAYOUT_HEXADECAGONAL = CH_LAYOUT_OCTAGONAL | WIDE_LEFT | WIDE_RIGHT | TOP_BACK_LEFT | + TOP_BACK_RIGHT | TOP_BACK_CENTER | TOP_FRONT_CENTER | TOP_FRONT_LEFT | TOP_FRONT_RIGHT, + CH_LAYOUT_AMB_ORDER3_ACN_N3D = AMB_MODE | AMB_ORD_3 | AMB_COM_ACN | AMB_NOR_N3D, + CH_LAYOUT_AMB_ORDER3_ACN_SN3D = AMB_MODE | AMB_ORD_3 | AMB_COM_ACN | AMB_NOR_SN3D, + CH_LAYOUT_AMB_ORDER3_FUMA = AMB_MODE | AMB_ORD_3| AMB_COM_FUMA, + /** Channel count: 24*/ + CH_LAYOUT_22POINT2 = CH_LAYOUT_7POINT1POINT4 | FRONT_LEFT_OF_CENTER | FRONT_RIGHT_OF_CENTER | BACK_CENTER | + TOP_CENTER | TOP_FRONT_CENTER | TOP_BACK_CENTER | TOP_SIDE_LEFT | TOP_SIDE_RIGHT | + BOTTOM_FRONT_LEFT | BOTTOM_FRONT_RIGHT | BOTTOM_FRONT_CENTER | LOW_FREQUENCY_2, +}; \ No newline at end of file diff --git a/multimedia/audio_framework/common/native_audiostream_base.h b/multimedia/audio_framework/common/native_audiostream_base.h index 4d4cc435bd72da7efc52bb702493ef3a09afb23f..844561be4c26b45ffcad2880942f879355033ab5 100644 --- a/multimedia/audio_framework/common/native_audiostream_base.h +++ b/multimedia/audio_framework/common/native_audiostream_base.h @@ -144,6 +144,12 @@ typedef enum { * @since 10 */ AUDIOSTREAM_ENCODING_TYPE_RAW = 0, + /** + * AudioVivid encoding type. + * + * @since 11 + */ + AUDIOSTREAM_ENCODING_TYPE_AUDIOVIVID = 1, } OH_AudioStream_EncodingType; /** @@ -549,6 +555,52 @@ typedef struct OH_AudioCapturer_Callbacks_Struct { void* userData, OH_AudioStream_Result error); } OH_AudioCapturer_Callbacks; + +/** + * Defines the audio effect mode. + * + * @since 11 + */ +typedef enum { + /** + * Audio Effect Mode effect none. + * @syscap SystemCapability.Multimedia.Audio.Renderer + * @since 11 + */ + EFFECT_NONE = 0, + /** + * Audio Effect Mode effect default. + * @syscap SystemCapability.Multimedia.Audio.Renderer + * @since 11 + */ + EFFECT_DEFAULT = 1, +} OH_AudioEffectMode; + +/** + * This function pointer will point to the callback function that + * is used to write audio data with metadata + * + * @since 11 + */ +typedef OH_AudioStream_Result (*OH_AudioRenderer_WriteDataWithMetadata_Callback)( + OH_AudioRenderer* renderer, + void* userData, + void* audioData, + int32_t audioDataSize, + void* metadata, + int32_t metadataSize +); + +/** + * This function pointer will point to the callback function that + * is used to write audio data by avbuffer + * + * @since 11 + */ +typedef OH_AudioStream_Result (*OH_AudioRenderer_WriteAVBuffer_Callback)( + OH_AudioRenderer* renderer, + void* userData, + OH_AVBuffer* avBuffer); #ifdef __cplusplus } #endif diff --git a/multimedia/audio_framework/common/native_audiostreambuilder.h b/multimedia/audio_framework/common/native_audiostreambuilder.h index 99d94288e42ee0dc85f0b48b05ff81314f47b3e5..b27e0c14e6c0c3f97c2c72a3e9bd4326c546581f 100644 --- a/multimedia/audio_framework/common/native_audiostreambuilder.h +++ b/multimedia/audio_framework/common/native_audiostreambuilder.h @@ -199,6 +199,44 @@ OH_AudioStream_Result OH_AudioStreamBuilder_GenerateRenderer(OH_AudioStreamBuild */ OH_AudioStream_Result OH_AudioStreamBuilder_GenerateCapturer(OH_AudioStreamBuilder* builder, OH_AudioCapturer** audioCapturer); + +/* + * Set the channel layout to the stream client + * + * @since 11 + * + * @param builder Reference provided by OH_AudioStreamBuilder_Create() + * @param channelLayout is the layout of the speaker. + * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. + */ +OH_AudioStream_Result OH_AudioStreamBuilder_SetChannelLayout(OH_AudioStreamBuilder* builder, + uint64_t channelLayout); + +/* + * Set the callback of the metadata writing to the renderer client + * + * @since 11 + * + * @param builder Reference provided by OH_AudioStreamBuilder_Create() + * @param callback Callback to the functions that will write the audio data with metadata to the renderer. + * @param userData Pointer to an application data structure that will be passed to the callback functions. + * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. + */ +OH_AudioStream_Result OH_AudioStreamBuilder_WriteDataWithMetadataCallback(OH_AudioStreamBuilder* builder, + OH_AudioRenderer_WriteDataWithMetadata_Callback callback, void* userData); + +/* + * Set the callback of the AVBuffer writing to the renderer client + * + * @since 11 + * + * @param builder Reference provided by OH_AudioStreamBuilder_Create() + * @param callback Callback to the functions that will write the audio data by AVBuffer to the renderer. + * @param userData Pointer to an application data structure that will be passed to the callback functions. + * @return {@link #AUDIOSTREAM_SUCCESS} or an undesired error. + */ +OH_AudioStream_Result OH_AudioStreamBuilder_SetWriteAVBufferCallback(OH_AudioStreamBuilder* builder, + OH_AudioRenderer_WriteAVBuffer_Callback callback, void* userData); #ifdef __cplusplus } #endif