• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-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 #ifndef AUDIO_INFO_H
16 #define AUDIO_INFO_H
17 
18 #ifdef __MUSL__
19 #include <stdint.h>
20 #endif // __MUSL__
21 
22 #include <cmath>
23 #include <limits>
24 #include <string>
25 #include <vector>
26 #include <unistd.h>
27 
28 namespace OHOS {
29 namespace AudioStandard {
30 constexpr int32_t MAX_NUM_STREAMS = 3;
31 constexpr int32_t RENDERER_STREAM_USAGE_SHIFT = 16;
32 constexpr int32_t MINIMUM_BUFFER_SIZE_MSEC = 5;
33 constexpr int32_t MAXIMUM_BUFFER_SIZE_MSEC = 20;
34 constexpr int32_t MIN_SERVICE_COUNT = 2;
35 constexpr int32_t ROOT_UID = 0;
36 constexpr int32_t INVALID_UID = -1;
37 constexpr int32_t NETWORK_ID_SIZE = 80;
38 constexpr int32_t DEFAULT_VOLUME_GROUP_ID = 1;
39 constexpr int32_t DEFAULT_VOLUME_INTERRUPT_ID = 1;
40 const std::string MICROPHONE_PERMISSION = "ohos.permission.MICROPHONE";
41 const std::string MANAGE_AUDIO_CONFIG = "ohos.permission.MANAGE_AUDIO_CONFIG";
42 const std::string MODIFY_AUDIO_SETTINGS_PERMISSION = "ohos.permission.MODIFY_AUDIO_SETTINGS";
43 const std::string ACCESS_NOTIFICATION_POLICY_PERMISSION = "ohos.permission.ACCESS_NOTIFICATION_POLICY";
44 const std::string USE_BLUETOOTH_PERMISSION = "ohos.permission.USE_BLUETOOTH";
45 const std::string LOCAL_NETWORK_ID = "LocalDevice";
46 
47 // Maximun number of sine waves in a tone segment
48 constexpr uint32_t TONEINFO_MAX_WAVES = 3;
49 
50 // Maximun number of segments in a tone descriptor
51 constexpr uint32_t TONEINFO_MAX_SEGMENTS = 12;
52 constexpr uint32_t TONEINFO_INF = 0xFFFFFFFF;
53 class ToneSegment {
54 public:
55     uint32_t duration;
56     uint16_t waveFreq[TONEINFO_MAX_WAVES+1];
57     uint16_t loopCnt;
58     uint16_t loopIndx;
59 };
60 
61 class ToneInfo {
62 public:
63     ToneSegment segments[TONEINFO_MAX_SEGMENTS+1];
64     uint32_t segmentCnt;
65     uint32_t repeatCnt;
66     uint32_t repeatSegment;
ToneInfo()67     ToneInfo() {}
68 };
69 
70 enum DeviceFlag {
71     /**
72      * Device flag none.
73      */
74     NONE_DEVICES_FLAG = 0,
75     /**
76      * Indicates all output audio devices.
77      */
78     OUTPUT_DEVICES_FLAG = 1,
79     /**
80      * Indicates all input audio devices.
81      */
82     INPUT_DEVICES_FLAG = 2,
83     /**
84      * Indicates all audio devices.
85      */
86     ALL_DEVICES_FLAG = 3,
87     /**
88      * Indicates all distributed output audio devices.
89      */
90     DISTRIBUTED_OUTPUT_DEVICES_FLAG = 4,
91     /**
92      * Indicates all distributed input audio devices.
93      */
94     DISTRIBUTED_INPUT_DEVICES_FLAG = 8,
95     /**
96      * Indicates all distributed audio devices.
97      */
98     ALL_DISTRIBUTED_DEVICES_FLAG = 12,
99     /**
100      * Indicates all local and distributed audio devices.
101      */
102     ALL_L_D_DEVICES_FLAG = 15,
103     /**
104      * Device flag max count.
105      */
106     DEVICE_FLAG_MAX
107 };
108 
109 enum DeviceRole {
110     /**
111      * Device role none.
112      */
113     DEVICE_ROLE_NONE = -1,
114     /**
115      * Input device role.
116      */
117     INPUT_DEVICE = 1,
118     /**
119      * Output device role.
120      */
121     OUTPUT_DEVICE = 2,
122     /**
123      * Device role max count.
124      */
125     DEVICE_ROLE_MAX
126 };
127 
128 enum DeviceType {
129     /**
130      * Indicates device type none.
131      */
132     DEVICE_TYPE_NONE = -1,
133     /**
134      * Indicates invalid device
135      */
136     DEVICE_TYPE_INVALID = 0,
137     /**
138      * Indicates a built-in earpiece device
139      */
140     DEVICE_TYPE_EARPIECE = 1,
141     /**
142      * Indicates a speaker built in a device.
143      */
144     DEVICE_TYPE_SPEAKER = 2,
145     /**
146      * Indicates a headset, which is the combination of a pair of headphones and a microphone.
147      */
148     DEVICE_TYPE_WIRED_HEADSET = 3,
149     /**
150      * Indicates a pair of wired headphones.
151      */
152     DEVICE_TYPE_WIRED_HEADPHONES = 4,
153     /**
154      * Indicates a Bluetooth device used for telephony.
155      */
156     DEVICE_TYPE_BLUETOOTH_SCO = 7,
157     /**
158      * Indicates a Bluetooth device supporting the Advanced Audio Distribution Profile (A2DP).
159      */
160     DEVICE_TYPE_BLUETOOTH_A2DP = 8,
161     /**
162      * Indicates a microphone built in a device.
163      */
164     DEVICE_TYPE_MIC = 15,
165     /**
166      * Indicates a microphone built in a device.
167      */
168     DEVICE_TYPE_USB_HEADSET = 22,
169     /**
170      * Indicates a debug sink device
171      */
172     DEVICE_TYPE_FILE_SINK = 50,
173     /**
174      * Indicates a debug source device
175      */
176     DEVICE_TYPE_FILE_SOURCE = 51,
177     /**
178      * Indicates default device
179      */
180     DEVICE_TYPE_DEFAULT = 1000,
181     /**
182      * Indicates device type max count.
183      */
184     DEVICE_TYPE_MAX
185 };
186 
187 enum ConnectType {
188     /**
189      * Group connect type of local device
190      */
191     CONNECT_TYPE_LOCAL = 0,
192     /**
193      * Group connect type of distributed device
194      */
195     CONNECT_TYPE_DISTRIBUTED
196 };
197 
198 enum ActiveDeviceType {
199     ACTIVE_DEVICE_TYPE_NONE = -1,
200     SPEAKER = 2,
201     BLUETOOTH_SCO = 7,
202     FILE_SINK_DEVICE = 50,
203     ACTIVE_DEVICE_TYPE_MAX
204 };
205 
206 enum AudioStreamType {
207     /**
208      * Indicates audio streams default.
209      */
210     STREAM_DEFAULT = -1,
211     /**
212      * Indicates audio streams of voices in calls.
213      */
214     STREAM_VOICE_CALL = 0,
215     /**
216      * Indicates audio streams for music playback.
217      */
218     STREAM_MUSIC = 1,
219     /**
220      * Indicates audio streams for ringtones.
221      */
222     STREAM_RING = 2,
223     /**
224      * Indicates audio streams media.
225      */
226     STREAM_MEDIA = 3,
227     /**
228      * Indicates Audio streams for voice assistant
229      */
230     STREAM_VOICE_ASSISTANT = 4,
231     /**
232      * Indicates audio streams for system sounds.
233      */
234     STREAM_SYSTEM = 5,
235     /**
236      * Indicates audio streams for alarms.
237      */
238     STREAM_ALARM = 6,
239     /**
240      * Indicates audio streams for notifications.
241      */
242     STREAM_NOTIFICATION = 7,
243     /**
244      * Indicates audio streams for voice calls routed through a connected Bluetooth device.
245      */
246     STREAM_BLUETOOTH_SCO = 8,
247     /**
248      * Indicates audio streams for enforced audible.
249      */
250     STREAM_ENFORCED_AUDIBLE = 9,
251     /**
252      * Indicates audio streams for dual-tone multi-frequency (DTMF) tones.
253      */
254     STREAM_DTMF = 10,
255     /**
256      * Indicates audio streams exclusively transmitted through the speaker (text-to-speech) of a device.
257      */
258     STREAM_TTS =  11,
259     /**
260      * Indicates audio streams used for prompts in terms of accessibility.
261      */
262     STREAM_ACCESSIBILITY = 12,
263     /**
264      * Indicates special scene used for recording.
265      */
266     STREAM_RECORDING = 13,
267     /**
268      * Indicates audio streams used for only one volume bar of a device.
269      */
270     STREAM_ALL = 100
271 };
272 
273 typedef AudioStreamType AudioVolumeType;
274 
275 enum FocusType {
276     /**
277      * Recording type.
278      */
279     FOCUS_TYPE_RECORDING = 0,
280 };
281 
282 enum API_VERSION {
283     API_7 = 7,
284     API_8 = 8,
285     API_9 = 9
286 };
287 
288 enum AudioErrors {
289     /**
290      * Common errors.
291      */
292     ERROR_INVALID_PARAM = 6800101,
293     ERROR_NO_MEMORY     = 6800102,
294     ERROR_ILLEGAL_STATE = 6800103,
295     ERROR_UNSUPPORTED   = 6800104,
296     ERROR_TIMEOUT       = 6800105,
297     /**
298      * Audio specific errors.
299      */
300     ERROR_STREAM_LIMIT  = 6800201,
301     /**
302      * Default error.
303      */
304     ERROR_SYSTEM        = 6800301
305 };
306 
307 enum CommunicationDeviceType {
308     /**
309      * Speaker.
310      * @since 7
311      * @syscap SystemCapability.Multimedia.Audio.Communication
312      */
313     COMMUNICATION_SPEAKER = 2
314 };
315 
316 enum InterruptMode {
317     SHARE_MODE = 0,
318     INDEPENDENT_MODE = 1
319 };
320 
321 enum AudioEncodingType {
322     ENCODING_PCM = 0,
323     ENCODING_INVALID = -1
324 };
325 
326 // Ringer Mode
327 enum AudioRingerMode {
328     RINGER_MODE_NORMAL = 0,
329     RINGER_MODE_SILENT = 1,
330     RINGER_MODE_VIBRATE = 2
331 };
332 
333 // format
334 enum AudioSampleFormat {
335     SAMPLE_U8 = 0,
336     SAMPLE_S16LE = 1,
337     SAMPLE_S24LE = 2,
338     SAMPLE_S32LE = 3,
339     SAMPLE_F32LE = 4,
340     INVALID_WIDTH = -1
341 };
342 
343 // channel
344 enum AudioChannel {
345     MONO = 1,
346     STEREO = 2,
347     CHANNEL_3 = 3,
348     CHANNEL_4 = 4,
349     CHANNEL_5 = 5,
350     CHANNEL_6 = 6,
351     CHANNEL_7 = 7,
352     CHANNEL_8 = 8
353 };
354 
355 
356 /**
357  * Enumerates the audio interrupt request type.
358  */
359 enum InterruptRequestType {
360     INTERRUPT_REQUEST_TYPE_DEFAULT = 0,
361 };
362 
363 /**
364  * Enumerates audio interrupt request result type.
365  */
366 enum InterruptRequestResultType {
367     INTERRUPT_REQUEST_GRANT = 0,
368     INTERRUPT_REQUEST_REJECT = 1
369 };
370 
371 // sampling rate
372 enum AudioSamplingRate {
373     SAMPLE_RATE_8000 = 8000,
374     SAMPLE_RATE_11025 = 11025,
375     SAMPLE_RATE_12000 = 12000,
376     SAMPLE_RATE_16000 = 16000,
377     SAMPLE_RATE_22050 = 22050,
378     SAMPLE_RATE_24000 = 24000,
379     SAMPLE_RATE_32000 = 32000,
380     SAMPLE_RATE_44100 = 44100,
381     SAMPLE_RATE_48000 = 48000,
382     SAMPLE_RATE_64000 = 64000,
383     SAMPLE_RATE_96000 = 96000
384 };
385 
386 typedef enum {
387     /** Invalid audio source */
388     AUDIO_SOURCE_INVALID = -1,
389     /** Default audio source */
390     AUDIO_SOURCE_DEFAULT = 0,
391     /** Microphone */
392     AUDIO_MIC = 1,
393     /** Uplink voice */
394     AUDIO_VOICE_UPLINK = 2,
395     /** Downlink voice */
396     AUDIO_VOICE_DOWNLINK = 3,
397     /** Voice call */
398     AUDIO_VOICE_CALL = 4,
399     /** Camcorder */
400     AUDIO_CAMCORDER = 5,
401     /** Voice recognition */
402     AUDIO_VOICE_RECOGNITION = 6,
403     /** Voice communication */
404     AUDIO_VOICE_COMMUNICATION = 7,
405     /** Remote submix */
406     AUDIO_REMOTE_SUBMIX = 8,
407     /** Unprocessed audio */
408     AUDIO_UNPROCESSED = 9,
409     /** Voice performance */
410     AUDIO_VOICE_PERFORMANCE = 10,
411     /** Echo reference */
412     AUDIO_ECHO_REFERENCE = 1997,
413     /** Radio tuner */
414     AUDIO_RADIO_TUNER = 1998,
415     /** Hotword */
416     AUDIO_HOTWORD = 1999,
417     /** Extended remote submix */
418     AUDIO_REMOTE_SUBMIX_EXTEND = 10007,
419 } AudioSourceType;
420 
421 struct AudioStreamParams {
422     uint32_t samplingRate;
423     uint8_t encoding;
424     uint8_t format;
425     uint8_t channels;
426 };
427 
428 /**
429 * Enumerates the audio content type.
430 */
431 enum ContentType {
432     CONTENT_TYPE_UNKNOWN = 0,
433     CONTENT_TYPE_SPEECH = 1,
434     CONTENT_TYPE_MUSIC = 2,
435     CONTENT_TYPE_MOVIE = 3,
436     CONTENT_TYPE_SONIFICATION = 4,
437     CONTENT_TYPE_RINGTONE = 5
438 };
439 
440 /**
441 * Enumerates the stream usage.
442 */
443 enum StreamUsage {
444     STREAM_USAGE_UNKNOWN = 0,
445     STREAM_USAGE_MEDIA = 1,
446     STREAM_USAGE_VOICE_COMMUNICATION = 2,
447     STREAM_USAGE_VOICE_ASSISTANT = 3,
448     STREAM_USAGE_NOTIFICATION_RINGTONE = 6
449 };
450 
451 /**
452 * Enumerates the capturer source type
453 */
454 enum SourceType {
455     SOURCE_TYPE_INVALID = -1,
456     SOURCE_TYPE_MIC,
457     SOURCE_TYPE_VOICE_RECOGNITION = 1,
458     SOURCE_TYPE_VOICE_COMMUNICATION = 7
459 };
460 
461 /**
462 * Enumerates the renderer playback speed.
463 */
464 enum AudioRendererRate {
465     RENDER_RATE_NORMAL = 0,
466     RENDER_RATE_DOUBLE = 1,
467     RENDER_RATE_HALF = 2,
468 };
469 
470 enum InterruptType {
471     INTERRUPT_TYPE_BEGIN = 1,
472     INTERRUPT_TYPE_END = 2,
473 };
474 
475 enum InterruptHint {
476     INTERRUPT_HINT_NONE = 0,
477     INTERRUPT_HINT_RESUME,
478     INTERRUPT_HINT_PAUSE,
479     INTERRUPT_HINT_STOP,
480     INTERRUPT_HINT_DUCK,
481     INTERRUPT_HINT_UNDUCK
482 };
483 
484 enum InterruptForceType {
485     /**
486      * Force type, system change audio state.
487      */
488     INTERRUPT_FORCE = 0,
489     /**
490      * Share type, application change audio state.
491      */
492     INTERRUPT_SHARE
493 };
494 
495 enum ActionTarget {
496     CURRENT = 0,
497     INCOMING,
498     BOTH
499 };
500 
501 struct InterruptEvent {
502     /**
503      * Interrupt event type, begin or end
504      */
505     InterruptType eventType;
506     /**
507      * Interrupt force type, force or share
508      */
509     InterruptForceType forceType;
510     /**
511      * Interrupt hint type. In force type, the audio state already changed,
512      * but in share mode, only provide a hint for application to decide.
513      */
514     InterruptHint hintType;
515 };
516 
517 // Used internally only by AudioFramework
518 struct InterruptEventInternal {
519     InterruptType eventType;
520     InterruptForceType forceType;
521     InterruptHint hintType;
522     float duckVolume;
523 };
524 
525 struct AudioFocusEntry {
526     InterruptForceType forceType;
527     InterruptHint hintType;
528     ActionTarget actionOn;
529     bool isReject;
530 };
531 
532 struct AudioInterrupt {
533     StreamUsage streamUsage;
534     ContentType contentType;
535     AudioStreamType streamType;
536     uint32_t sessionID;
537     bool pauseWhenDucked;
538 };
539 
540 struct VolumeEvent {
541     AudioStreamType volumeType;
542     int32_t volume;
543     bool updateUi;
544     int32_t volumeGroupId;
545     std::string networkId;
546 };
547 
548 struct AudioParameters {
549     AudioSampleFormat format;
550     AudioChannel channels;
551     AudioSamplingRate samplingRate;
552     AudioEncodingType encoding;
553     ContentType contentType;
554     StreamUsage usage;
555     DeviceRole deviceRole;
556     DeviceType deviceType;
557 };
558 
559 struct AudioStreamInfo {
560     AudioSamplingRate samplingRate;
561     AudioEncodingType encoding;
562     AudioSampleFormat format;
563     AudioChannel channels;
564 };
565 
566 struct AudioRendererInfo {
567     ContentType contentType = CONTENT_TYPE_UNKNOWN;
568     StreamUsage streamUsage = STREAM_USAGE_UNKNOWN;
569     int32_t rendererFlags = 0;
570 };
571 
572 struct AudioCapturerInfo {
573     SourceType sourceType = SOURCE_TYPE_INVALID;
574     int32_t capturerFlags = 0;
575 };
576 
577 struct AudioRendererDesc {
578     ContentType contentType = CONTENT_TYPE_UNKNOWN;
579     StreamUsage streamUsage = STREAM_USAGE_UNKNOWN;
580 };
581 
582 struct AudioRendererOptions {
583     AudioStreamInfo streamInfo;
584     AudioRendererInfo rendererInfo;
585 };
586 
587 struct MicStateChangeEvent {
588     bool mute;
589 };
590 
591 enum DeviceChangeType {
592     CONNECT = 0,
593     DISCONNECT = 1,
594 };
595 
596 enum AudioScene {
597     /**
598      * Default audio scene
599      */
600     AUDIO_SCENE_DEFAULT,
601     /**
602      * Ringing audio scene
603      * Only available for system api.
604      */
605     AUDIO_SCENE_RINGING,
606     /**
607      * Phone call audio scene
608      * Only available for system api.
609      */
610     AUDIO_SCENE_PHONE_CALL,
611     /**
612      * Voice chat audio scene
613      */
614     AUDIO_SCENE_PHONE_CHAT,
615 };
616 
617 struct AudioCapturerOptions {
618     AudioStreamInfo streamInfo;
619     AudioCapturerInfo capturerInfo;
620 };
621 
622 struct AppInfo {
623     int32_t appUid { INVALID_UID };
624     uint32_t appTokenId { 0 };
625     int32_t appPid { 0 };
626 };
627 
628 // Supported audio parameters for both renderer and capturer
629 const std::vector<AudioSampleFormat> AUDIO_SUPPORTED_FORMATS {
630     SAMPLE_U8,
631     SAMPLE_S16LE,
632     SAMPLE_S24LE,
633     SAMPLE_S32LE
634 };
635 
636 const std::vector<AudioChannel> RENDERER_SUPPORTED_CHANNELS {
637     MONO,
638     STEREO,
639     CHANNEL_3,
640     CHANNEL_4,
641     CHANNEL_5,
642     CHANNEL_6,
643     CHANNEL_7,
644     CHANNEL_8
645 };
646 
647 const std::vector<AudioChannel> CAPTURER_SUPPORTED_CHANNELS {
648     MONO,
649     STEREO,
650     CHANNEL_3,
651     CHANNEL_4,
652     CHANNEL_5,
653     CHANNEL_6
654 };
655 
656 const std::vector<AudioEncodingType> AUDIO_SUPPORTED_ENCODING_TYPES {
657     ENCODING_PCM
658 };
659 
660 const std::vector<AudioSamplingRate> AUDIO_SUPPORTED_SAMPLING_RATES {
661     SAMPLE_RATE_8000,
662     SAMPLE_RATE_11025,
663     SAMPLE_RATE_12000,
664     SAMPLE_RATE_16000,
665     SAMPLE_RATE_22050,
666     SAMPLE_RATE_24000,
667     SAMPLE_RATE_32000,
668     SAMPLE_RATE_44100,
669     SAMPLE_RATE_48000,
670     SAMPLE_RATE_64000,
671     SAMPLE_RATE_96000
672 };
673 
674 struct BufferDesc {
675     uint8_t* buffer;
676     size_t bufLength;
677     size_t dataLength;
678 };
679 
680 struct BufferQueueState {
681     uint32_t numBuffers;
682     uint32_t currentIndex;
683 };
684 
685 enum AudioRenderMode {
686     RENDER_MODE_NORMAL,
687     RENDER_MODE_CALLBACK
688 };
689 
690 enum AudioCaptureMode {
691     CAPTURE_MODE_NORMAL,
692     CAPTURE_MODE_CALLBACK
693 };
694 
695 struct SinkInfo {
696     uint32_t sinkId; // sink id
697     std::string sinkName;
698     std::string adapterName;
699 };
700 
701 struct SinkInput {
702     int32_t streamId;
703     AudioStreamType streamType;
704 
705     // add for routing stream.
706     int32_t uid; // client uid
707     int32_t pid; // client pid
708     uint32_t paStreamId; // streamId
709     uint32_t deviceSinkId; // sink id
710     std::string sinkName; // sink name
711     int32_t statusMark; // mark the router status
712     uint64_t startTime; // when this router is created
713 };
714 
715 struct SourceOutput {
716     int32_t streamId;
717     AudioStreamType streamType;
718 
719     // add for routing stream.
720     int32_t uid; // client uid
721     int32_t pid; // client pid
722     uint32_t paStreamId; // streamId
723     uint32_t deviceSourceId; // sink id
724     int32_t statusMark; // mark the router status
725     uint64_t startTime; // when this router is created
726 };
727 
728 typedef uint32_t AudioIOHandle;
729 
FLOAT_COMPARE_EQ(const float & x,const float & y)730 static inline bool FLOAT_COMPARE_EQ(const float& x, const float& y)
731 {
732     return (std::abs((x) - (y)) <= (std::numeric_limits<float>::epsilon()));
733 }
734 
735 // Below APIs are added to handle compilation error in call manager
736 // Once call manager adapt to new interrupt APIs, this will be removed
737 enum InterruptActionType {
738     TYPE_ACTIVATED = 0,
739     TYPE_INTERRUPT = 1
740 };
741 
742 struct InterruptAction {
743     InterruptActionType actionType;
744     InterruptType interruptType;
745     InterruptHint interruptHint;
746     bool activated;
747 };
748 
749 enum AudioServiceIndex {
750     HDI_SERVICE_INDEX = 0,
751     AUDIO_SERVICE_INDEX
752 };
753 
754 /**
755  * @brief Enumerates the rendering states of the current device.
756  */
757 enum RendererState {
758     /** INVALID state */
759     RENDERER_INVALID = -1,
760     /** Create New Renderer instance */
761     RENDERER_NEW,
762     /** Reneder Prepared state */
763     RENDERER_PREPARED,
764     /** Rendere Running state */
765     RENDERER_RUNNING,
766     /** Renderer Stopped state */
767     RENDERER_STOPPED,
768     /** Renderer Released state */
769     RENDERER_RELEASED,
770     /** Renderer Paused state */
771     RENDERER_PAUSED
772 };
773 
774 /**
775  * @brief Enumerates the capturing states of the current device.
776  */
777 enum CapturerState {
778     /** Capturer INVALID state */
779     CAPTURER_INVALID = -1,
780     /** Create new capturer instance */
781     CAPTURER_NEW,
782     /** Capturer Prepared state */
783     CAPTURER_PREPARED,
784     /** Capturer Running state */
785     CAPTURER_RUNNING,
786     /** Capturer Stopped state */
787     CAPTURER_STOPPED,
788     /** Capturer Released state */
789     CAPTURER_RELEASED,
790     /** Capturer Paused state */
791     CAPTURER_PAUSED
792 };
793 
794 enum AudioMode {
795     AUDIO_MODE_PLAYBACK,
796     AUDIO_MODE_RECORD
797 };
798 
799 struct DeviceInfo {
800     DeviceType deviceType;
801     DeviceRole deviceRole;
802     int32_t deviceId;
803     int32_t channelMasks;
804     std::string deviceName;
805     std::string macAddress;
806     AudioStreamInfo audioStreamInfo;
807     std::string networkId;
808 };
809 
810 enum StreamSetState {
811     STREAM_PAUSE,
812     STREAM_RESUME
813 };
814 
815 struct StreamSetStateEventInternal {
816     StreamSetState streamSetState;
817     AudioStreamType audioStreamType;
818 };
819 
820 struct AudioRendererChangeInfo {
821     int32_t clientUID;
822     int32_t sessionId;
823     AudioRendererInfo rendererInfo;
824     RendererState rendererState;
825     DeviceInfo outputDeviceInfo;
826 };
827 
828 struct AudioCapturerChangeInfo {
829     int32_t clientUID;
830     int32_t sessionId;
831     AudioCapturerInfo capturerInfo;
832     CapturerState capturerState;
833     DeviceInfo inputDeviceInfo;
834 };
835 
836 struct AudioStreamChangeInfo {
837     AudioRendererChangeInfo audioRendererChangeInfo;
838     AudioCapturerChangeInfo audioCapturerChangeInfo;
839 };
840 
841 enum AudioPin {
842     AUDIO_PIN_NONE = 0,
843     AUDIO_PIN_OUT_SPEAKER = 1,
844     AUDIO_PIN_OUT_HEADSET = 2,
845     AUDIO_PIN_OUT_LINEOUT = 4,
846     AUDIO_PIN_OUT_HDMI = 8,
847     AUDIO_PIN_OUT_USB = 16,
848     AUDIO_PIN_OUT_USB_EXT = 32,
849     AUDIO_PIN_OUT_DAUDIO_DEFAULT = 64,
850     AUDIO_PIN_IN_MIC = 134217729,
851     AUDIO_PIN_IN_HS_MIC = 134217730,
852     AUDIO_PIN_IN_LINEIN = 134217732,
853     AUDIO_PIN_IN_USB_EXT = 134217736,
854     AUDIO_PIN_IN_DAUDIO_DEFAULT = 134217744,
855 };
856 
857 enum AudioParamKey {
858     NONE = 0,
859     VOLUME = 1,
860     INTERRUPT = 2,
861     RENDER_STATE = 5,
862     PARAM_KEY_LOWPOWER = 1000,
863 };
864 
865 struct DStatusInfo {
866     char networkId[NETWORK_ID_SIZE];
867     AudioPin hdiPin = AUDIO_PIN_NONE;
868     int32_t mappingVolumeId = 0;
869     int32_t mappingInterruptId = 0;
870     int32_t deviceId;
871     int32_t channelMasks;
872     std::string deviceName = "";
873     bool isConnected = false;
874     std::string macAddress;
875     AudioStreamInfo streamInfo = {};
876     ConnectType connectType = CONNECT_TYPE_LOCAL;
877 };
878 
879 struct AudioRendererDataInfo {
880     uint8_t *buffer;
881     size_t flag;
882 };
883 
884 enum AudioPermissionState {
885     AUDIO_PERMISSION_START = 0,
886     AUDIO_PERMISSION_STOP = 1,
887 };
888 
889 enum StateChangeCmdType {
890     CMD_FROM_CLIENT = 0,
891     CMD_FROM_SYSTEM = 1
892 };
893 } // namespace AudioStandard
894 } // namespace OHOS
895 #endif // AUDIO_INFO_H
896