1 /* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef OHOS_DAUDIO_AUDIO_PARAM_H 17 #define OHOS_DAUDIO_AUDIO_PARAM_H 18 19 #include <string> 20 21 namespace OHOS { 22 namespace DistributedHardware { 23 typedef enum { 24 SAMPLE_RATE_8000 = 8000, 25 SAMPLE_RATE_11025 = 11025, 26 SAMPLE_RATE_12000 = 12000, 27 SAMPLE_RATE_16000 = 16000, 28 SAMPLE_RATE_22050 = 22050, 29 SAMPLE_RATE_24000 = 24000, 30 SAMPLE_RATE_32000 = 32000, 31 SAMPLE_RATE_44100 = 44100, 32 SAMPLE_RATE_48000 = 48000, 33 SAMPLE_RATE_64000 = 64000, 34 SAMPLE_RATE_96000 = 96000 35 } AudioSampleRate; 36 37 typedef enum { 38 SOURCE_TYPE_INVALID = -1, 39 SOURCE_TYPE_MIC, 40 SOURCE_TYPE_VOICE_CALL = 4, 41 SOURCE_TYPE_VOICE_COMMUNICATION = 7 42 } SourceType; 43 44 typedef enum { 45 MONO = 1, 46 STEREO = 2 47 } AudioChannel; 48 49 typedef enum { 50 SAMPLE_U8 = 0, 51 SAMPLE_S16LE = 1, 52 SAMPLE_S24LE = 2, 53 SAMPLE_S32LE = 3, 54 SAMPLE_F32LE = 4, 55 INVALID_WIDTH = -1 56 } AudioSampleFormat; 57 58 typedef enum { 59 AUDIO_CODEC_AAC = 0, 60 AUDIO_CODEC_FLAC = 1 61 } AudioCodecType; 62 63 typedef enum { 64 CONTENT_TYPE_UNKNOWN = 0, 65 CONTENT_TYPE_SPEECH = 1, 66 CONTENT_TYPE_MUSIC = 2, 67 CONTENT_TYPE_MOVIE = 3, 68 CONTENT_TYPE_SONIFICATION = 4, 69 CONTENT_TYPE_RINGTONE = 5 70 } ContentType; 71 72 typedef enum { 73 STREAM_USAGE_UNKNOWN = 0, 74 STREAM_USAGE_MEDIA = 1, 75 STREAM_USAGE_VOICE_COMMUNICATION = 2, 76 STREAM_USAGE_VOICE_ASSISTANT = 4, 77 STREAM_USAGE_MMAP = 5, 78 STREAM_USAGE_NOTIFICATION_RINGTONE = 6 79 } StreamUsage; 80 81 typedef enum { 82 NORMAL_MODE = 0, 83 MMAP_MODE = 1, 84 } PortOperationMode; 85 86 typedef struct AudioCommonParam { 87 AudioSampleRate sampleRate = SAMPLE_RATE_8000; 88 AudioChannel channelMask = MONO; 89 AudioSampleFormat bitFormat = SAMPLE_U8; 90 AudioCodecType codecType = AUDIO_CODEC_AAC; 91 uint32_t frameSize = 0; 92 } AudioCommonParam; 93 94 typedef struct AudioCaptureOptions { 95 SourceType sourceType = SOURCE_TYPE_INVALID; 96 PortOperationMode capturerFlags = NORMAL_MODE; 97 } AudioCaptureOptions; 98 99 typedef struct AudioRenderOptions { 100 ContentType contentType = CONTENT_TYPE_UNKNOWN; 101 StreamUsage streamUsage = STREAM_USAGE_UNKNOWN; 102 PortOperationMode renderFlags = NORMAL_MODE; 103 } AudioRenderOptions; 104 105 typedef struct AudioParamHDF { 106 AudioSampleRate sampleRate = SAMPLE_RATE_8000; 107 AudioChannel channelMask = MONO; 108 AudioSampleFormat bitFormat = SAMPLE_U8; 109 StreamUsage streamUsage = STREAM_USAGE_UNKNOWN; 110 uint32_t frameSize = 0; 111 uint32_t period = 0; 112 PortOperationMode renderFlags = NORMAL_MODE; 113 PortOperationMode capturerFlags = NORMAL_MODE; 114 std::string ext; 115 } AudioParamHDF; 116 117 typedef struct { 118 AudioCommonParam comParam; 119 AudioCaptureOptions captureOpts; 120 AudioRenderOptions renderOpts; 121 } AudioParam; 122 123 typedef enum { 124 STATE_UNKNOWN = -1, 125 STATE_CHANNEL_OPEN = 0, 126 STATE_CHANNEL_CLOSE = 1 127 } STATE; 128 129 typedef enum { 130 CAP_UNKNOWN = 0, 131 CAP_SPK = 1, 132 CAP_MIC = 2, 133 } PortCapType; 134 135 typedef struct { 136 int64_t tvSec; 137 int64_t tvNSec; 138 } CurrentTimeHDF; 139 140 typedef enum { 141 REF, 142 MIC1, 143 } StreamType; 144 } // namespace DistributedHardware 145 } // namespace OHOS 146 #endif // OHOS_DAUDIO_AUDIO_PARAM_H 147