• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2025 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 <array>
27 #include <unistd.h>
28 #include <unordered_map>
29 #include <parcel.h>
30 #include <audio_source_type.h>
31 #include <audio_device_info.h>
32 #include <audio_interrupt_info.h>
33 #include <audio_session_info.h>
34 #include <audio_stream_info.h>
35 #include <audio_asr.h>
36 
37 namespace OHOS {
38 namespace AudioStandard {
39 namespace {
40 constexpr int32_t INVALID_PID = -1;
41 constexpr int32_t CLEAR_PID = 0;
42 constexpr int32_t SYSTEM_PID = 1;
43 constexpr int32_t CLEAR_UID = 0;
44 constexpr int32_t SYSTEM_UID = 1;
45 constexpr int32_t INVALID_UID = -1;
46 constexpr int32_t NETWORK_ID_SIZE = 80;
47 constexpr int32_t DEFAULT_VOLUME_GROUP_ID = 1;
48 constexpr int32_t AUDIO_FLAG_INVALID = -1;
49 constexpr int32_t AUDIO_FLAG_NORMAL = 0;
50 constexpr int32_t AUDIO_FLAG_MMAP = 1;
51 constexpr int32_t AUDIO_FLAG_VOIP_FAST = 2;
52 constexpr int32_t AUDIO_FLAG_DIRECT = 3;
53 constexpr int32_t AUDIO_FLAG_VOIP_DIRECT = 4;
54 constexpr int32_t AUDIO_FLAG_FORCED_NORMAL = 10;
55 constexpr int32_t AUDIO_USAGE_NORMAL = 0;
56 constexpr int32_t AUDIO_USAGE_VOIP = 1;
57 constexpr uint32_t STREAM_FLAG_FAST = 1;
58 constexpr float MAX_STREAM_SPEED_LEVEL = 4.0f;
59 constexpr float MIN_STREAM_SPEED_LEVEL = 0.125f;
60 constexpr int32_t EMPTY_UID = 0;
61 constexpr int32_t AUDIO_NORMAL_MANAGER_TYPE = 0;
62 constexpr int32_t AUDIO_DIRECT_MANAGER_TYPE = 2;
63 
64 constexpr uint32_t MIN_STREAMID = 100000;
65 constexpr uint32_t MAX_STREAMID = UINT32_MAX - MIN_STREAMID;
66 
67 const float MIN_FLOAT_VOLUME = 0.0f;
68 const float MAX_FLOAT_VOLUME = 1.0f;
69 
70 const char* MICROPHONE_PERMISSION = "ohos.permission.MICROPHONE";
71 const char* MODIFY_AUDIO_SETTINGS_PERMISSION = "ohos.permission.MODIFY_AUDIO_SETTINGS";
72 const char* ACCESS_NOTIFICATION_POLICY_PERMISSION = "ohos.permission.ACCESS_NOTIFICATION_POLICY";
73 const char* CAPTURER_VOICE_DOWNLINK_PERMISSION = "ohos.permission.CAPTURE_VOICE_DOWNLINK_AUDIO";
74 const char* RECORD_VOICE_CALL_PERMISSION = "ohos.permission.RECORD_VOICE_CALL";
75 
76 const char* PRIMARY_WAKEUP = "Built_in_wakeup";
77 const char* INNER_CAPTURER_SINK = "InnerCapturerSink_";
78 const char* REMOTE_CAST_INNER_CAPTURER_SINK_NAME = "RemoteCastInnerCapturer";
79 const char* DUP_STREAM = "DupStream";
80 }
81 
82 #ifdef FEATURE_DTMF_TONE
83 // Maximun number of sine waves in a tone segment
84 constexpr uint32_t TONEINFO_MAX_WAVES = 3;
85 //Maximun number of SupportedTones
86 constexpr uint32_t MAX_SUPPORTED_TONEINFO_SIZE = 65535;
87 // Maximun number of segments in a tone descriptor
88 constexpr uint32_t TONEINFO_MAX_SEGMENTS = 12;
89 constexpr uint32_t TONEINFO_INF = 0xFFFFFFFF;
90 class ToneSegment : public Parcelable {
91 public:
92     uint32_t duration;
93     uint16_t waveFreq[TONEINFO_MAX_WAVES+1];
94     uint16_t loopCnt;
95     uint16_t loopIndx;
Marshalling(Parcel & parcel)96     bool Marshalling(Parcel &parcel) const override
97     {
98         parcel.WriteUint32(duration);
99         parcel.WriteUint16(loopCnt);
100         parcel.WriteUint16(loopIndx);
101         for (uint32_t i = 0; i < TONEINFO_MAX_WAVES + 1; i++) {
102             parcel.WriteUint16(waveFreq[i]);
103         }
104         return true;
105     }
Unmarshalling(Parcel & parcel)106     void Unmarshalling(Parcel &parcel)
107     {
108         duration = parcel.ReadUint32();
109         loopCnt = parcel.ReadUint16();
110         loopIndx = parcel.ReadUint16();
111         for (uint32_t i = 0; i < TONEINFO_MAX_WAVES + 1; i++) {
112             waveFreq[i] = parcel.ReadUint16();
113         }
114     }
115 };
116 
117 class ToneInfo : public Parcelable {
118 public:
119     ToneSegment segments[TONEINFO_MAX_SEGMENTS+1];
120     uint32_t segmentCnt;
121     uint32_t repeatCnt;
122     uint32_t repeatSegment;
Marshalling(Parcel & parcel)123     bool Marshalling(Parcel &parcel) const override
124     {
125         parcel.WriteUint32(segmentCnt);
126         parcel.WriteUint32(repeatCnt);
127         parcel.WriteUint32(repeatSegment);
128         if (!(segmentCnt >= 0 && segmentCnt <= TONEINFO_MAX_SEGMENTS + 1)) {
129             return false;
130         }
131         for (uint32_t i = 0; i < segmentCnt; i++) {
132             segments[i].Marshalling(parcel);
133         }
134         return true;
135     }
Unmarshalling(Parcel & parcel)136     void Unmarshalling(Parcel &parcel)
137     {
138         segmentCnt = parcel.ReadUint32();
139         repeatCnt = parcel.ReadUint32();
140         repeatSegment = parcel.ReadUint32();
141         if (!(segmentCnt >= 0 && segmentCnt <= TONEINFO_MAX_SEGMENTS + 1)) {
142             return;
143         }
144         for (uint32_t i = 0; i < segmentCnt; i++) {
145             segments[i].Unmarshalling(parcel);
146         }
147     }
148 };
149 #endif
150 
151 enum VolumeAdjustType {
152     /**
153      * Adjust volume up
154      */
155     VOLUME_UP = 0,
156     /**
157      * Adjust volume down
158      */
159     VOLUME_DOWN = 1,
160 };
161 
162 enum ChannelBlendMode {
163     /**
164      * No channel process.
165      */
166     MODE_DEFAULT = 0,
167     /**
168      * Blend left and right channel.
169      */
170     MODE_BLEND_LR = 1,
171     /**
172      * Replicate left to right channel.
173      */
174     MODE_ALL_LEFT = 2,
175     /**
176      * Replicate right to left channel.
177      */
178     MODE_ALL_RIGHT = 3,
179 };
180 
181 enum ConnectType {
182     /**
183      * Group connect type of local device
184      */
185     CONNECT_TYPE_LOCAL = 0,
186     /**
187      * Group connect type of distributed device
188      */
189     CONNECT_TYPE_DISTRIBUTED
190 };
191 
192 typedef AudioStreamType AudioVolumeType;
193 
194 enum VolumeFlag {
195     /**
196      * Show system volume bar
197      */
198     FLAG_SHOW_SYSTEM_UI = 1,
199 };
200 
201 enum AudioOffloadType {
202     /**
203      * Indicates audio offload state default.
204      */
205     OFFLOAD_DEFAULT = -1,
206     /**
207      * Indicates audio offload state : screen is active & app is foreground.
208      */
209     OFFLOAD_ACTIVE_FOREGROUND = 0,
210     /**
211      * Indicates audio offload state : screen is active & app is background.
212      */
213     OFFLOAD_ACTIVE_BACKGROUND = 1,
214     /**
215      * Indicates audio offload state : screen is inactive & app is background.
216      */
217     OFFLOAD_INACTIVE_BACKGROUND = 3,
218 };
219 
220 enum FocusType {
221     /**
222      * Recording type.
223      */
224     FOCUS_TYPE_RECORDING = 0,
225 };
226 
227 enum AudioErrors {
228     /**
229      * Common errors.
230      */
231     ERROR_INVALID_PARAM = 6800101,
232     ERROR_NO_MEMORY     = 6800102,
233     ERROR_ILLEGAL_STATE = 6800103,
234     ERROR_UNSUPPORTED   = 6800104,
235     ERROR_TIMEOUT       = 6800105,
236     /**
237      * Audio specific errors.
238      */
239     ERROR_STREAM_LIMIT  = 6800201,
240     /**
241      * Default error.
242      */
243     ERROR_SYSTEM        = 6800301
244 };
245 
246 // Ringer Mode
247 enum AudioRingerMode {
248     RINGER_MODE_SILENT = 0,
249     RINGER_MODE_VIBRATE = 1,
250     RINGER_MODE_NORMAL = 2
251 };
252 
253 /**
254  * Enumerates audio stream privacy type for playback capture.
255  */
256 enum AudioPrivacyType {
257     PRIVACY_TYPE_PUBLIC = 0,
258     PRIVACY_TYPE_PRIVATE = 1
259 };
260 
261 /**
262 * Enumerates the renderer playback speed.
263 */
264 enum AudioRendererRate {
265     RENDER_RATE_NORMAL = 0,
266     RENDER_RATE_DOUBLE = 1,
267     RENDER_RATE_HALF = 2,
268 };
269 
270 /**
271 * media safe volume status
272 */
273 enum SafeStatus : int32_t {
274     SAFE_UNKNOWN = -1,
275     SAFE_INACTIVE = 0,
276     SAFE_ACTIVE = 1,
277 };
278 
279 enum CallbackChange : int32_t {
280     CALLBACK_UNKNOWN = 0,
281     CALLBACK_FOCUS_INFO_CHANGE,
282     CALLBACK_RENDERER_STATE_CHANGE,
283     CALLBACK_CAPTURER_STATE_CHANGE,
284     CALLBACK_MICMUTE_STATE_CHANGE,
285     CALLBACK_AUDIO_SESSION,
286     CALLBACK_PREFERRED_OUTPUT_DEVICE_CHANGE,
287     CALLBACK_PREFERRED_INPUT_DEVICE_CHANGE,
288     CALLBACK_SET_VOLUME_KEY_EVENT,
289     CALLBACK_SET_DEVICE_CHANGE,
290     CALLBACK_SET_RINGER_MODE,
291     CALLBACK_APP_VOLUME_CHANGE,
292     CALLBACK_SELF_APP_VOLUME_CHANGE,
293     CALLBACK_SET_MIC_STATE_CHANGE,
294     CALLBACK_SPATIALIZATION_ENABLED_CHANGE,
295     CALLBACK_HEAD_TRACKING_ENABLED_CHANGE,
296     CALLBACK_SET_MICROPHONE_BLOCKED,
297     CALLBACK_DEVICE_CHANGE_WITH_INFO,
298     CALLBACK_HEAD_TRACKING_DATA_REQUESTED_CHANGE,
299     CALLBACK_NN_STATE_CHANGE,
300     CALLBACK_SET_AUDIO_SCENE_CHANGE,
301     CALLBACK_SPATIALIZATION_ENABLED_CHANGE_FOR_CURRENT_DEVICE,
302     CALLBACK_DISTRIBUTED_OUTPUT_CHANGE,
303     CALLBACK_MAX,
304 };
305 
306 constexpr CallbackChange CALLBACK_ENUMS[] = {
307     CALLBACK_UNKNOWN,
308     CALLBACK_FOCUS_INFO_CHANGE,
309     CALLBACK_RENDERER_STATE_CHANGE,
310     CALLBACK_CAPTURER_STATE_CHANGE,
311     CALLBACK_MICMUTE_STATE_CHANGE,
312     CALLBACK_AUDIO_SESSION,
313     CALLBACK_PREFERRED_OUTPUT_DEVICE_CHANGE,
314     CALLBACK_PREFERRED_INPUT_DEVICE_CHANGE,
315     CALLBACK_SET_VOLUME_KEY_EVENT,
316     CALLBACK_SET_DEVICE_CHANGE,
317     CALLBACK_SET_VOLUME_KEY_EVENT,
318     CALLBACK_SET_DEVICE_CHANGE,
319     CALLBACK_SET_RINGER_MODE,
320     CALLBACK_SET_MIC_STATE_CHANGE,
321     CALLBACK_SPATIALIZATION_ENABLED_CHANGE,
322     CALLBACK_HEAD_TRACKING_ENABLED_CHANGE,
323     CALLBACK_SET_MICROPHONE_BLOCKED,
324     CALLBACK_DEVICE_CHANGE_WITH_INFO,
325     CALLBACK_HEAD_TRACKING_DATA_REQUESTED_CHANGE,
326     CALLBACK_NN_STATE_CHANGE,
327     CALLBACK_SET_AUDIO_SCENE_CHANGE,
328     CALLBACK_SPATIALIZATION_ENABLED_CHANGE_FOR_CURRENT_DEVICE,
329     CALLBACK_DISTRIBUTED_OUTPUT_CHANGE,
330 };
331 
332 static_assert((sizeof(CALLBACK_ENUMS) / sizeof(CallbackChange)) == static_cast<size_t>(CALLBACK_MAX),
333     "check CALLBACK_ENUMS");
334 
335 struct VolumeEvent {
336     AudioVolumeType volumeType;
337     int32_t volume;
338     bool updateUi;
339     int32_t volumeGroupId;
340     std::string networkId;
341     AudioVolumeMode volumeMode;
MarshallingVolumeEvent342     bool Marshalling(Parcel &parcel) const
343     {
344         return parcel.WriteInt32(static_cast<int32_t>(volumeType))
345             && parcel.WriteInt32(volume)
346             && parcel.WriteBool(updateUi)
347             && parcel.WriteInt32(volumeGroupId)
348             && parcel.WriteString(networkId)
349             && parcel.WriteInt32(static_cast<int32_t>(volumeMode));
350     }
UnmarshallingVolumeEvent351     void Unmarshalling(Parcel &parcel)
352     {
353         volumeType = static_cast<AudioVolumeType>(parcel.ReadInt32());
354         volume = parcel.ReadInt32();
355         updateUi = parcel.ReadInt32();
356         volumeGroupId = parcel.ReadInt32();
357         networkId = parcel.ReadString();
358         volumeMode = static_cast<AudioVolumeMode>(parcel.ReadInt32());
359     }
360 };
361 
362 struct AudioParameters {
363     AudioSampleFormat format;
364     AudioChannel channels;
365     AudioSamplingRate samplingRate;
366     AudioEncodingType encoding;
367     ContentType contentType;
368     StreamUsage usage;
369     DeviceRole deviceRole;
370     DeviceType deviceType;
371     AudioVolumeMode mode;
372 };
373 
374 struct A2dpDeviceConfigInfo {
375     DeviceStreamInfo streamInfo;
376     bool absVolumeSupport = false;
377     int32_t volumeLevel = -1;
378     bool mute = false;
379 };
380 
381 enum PlayerType : int32_t {
382     PLAYER_TYPE_DEFAULT = 0,
383 
384     // AudioFramework internal type.
385     PLAYER_TYPE_OH_AUDIO_RENDERER = 100,
386     PLAYER_TYPE_ARKTS_AUDIO_RENDERER = 101,
387     PLAYER_TYPE_CJ_AUDIO_RENDERER = 102,
388     PLAYER_TYPE_OPENSL_ES = 103,
389 
390     // Indicates a type from the system internals, but not from the AudioFramework.
391     PLAYER_TYPE_SOUND_POOL = 1000,
392     PLAYER_TYPE_AV_PLAYER = 1001,
393     PLAYER_TYPE_SYSTEM_WEBVIEW = 1002,
394     PLAYER_TYPE_TONE_PLAYER = 1003,
395 };
396 
397 struct AudioRendererInfo {
398     ContentType contentType = CONTENT_TYPE_UNKNOWN;
399     StreamUsage streamUsage = STREAM_USAGE_UNKNOWN;
400     int32_t rendererFlags = AUDIO_FLAG_NORMAL;
401     AudioVolumeMode volumeMode = AUDIOSTREAM_VOLUMEMODE_SYSTEM_GLOBAL;
402     std::string sceneType = "";
403     bool spatializationEnabled = false;
404     bool headTrackingEnabled = false;
405     int32_t originalFlag = AUDIO_FLAG_NORMAL;
406     AudioPipeType pipeType = PIPE_TYPE_UNKNOWN;
407     AudioSamplingRate samplingRate = SAMPLE_RATE_8000;
408     uint8_t encodingType = 0;
409     uint64_t channelLayout = 0ULL;
410     AudioSampleFormat format = SAMPLE_S16LE;
411     bool isOffloadAllowed = true;
412     bool isSatellite = false;
413     PlayerType playerType = PLAYER_TYPE_DEFAULT;
414     // Expected length of audio stream to be played.
415     // Currently only used for making decisions on fade-in and fade-out strategies.
416     // 0 is the default value, it is considered that no
417     uint64_t expectedPlaybackDurationBytes = 0;
418     int32_t effectMode = 1;
419 
MarshallingAudioRendererInfo420     bool Marshalling(Parcel &parcel) const
421     {
422         return parcel.WriteInt32(static_cast<int32_t>(contentType))
423             && parcel.WriteInt32(static_cast<int32_t>(streamUsage))
424             && parcel.WriteInt32(rendererFlags)
425             && parcel.WriteInt32(originalFlag)
426             && parcel.WriteString(sceneType)
427             && parcel.WriteBool(spatializationEnabled)
428             && parcel.WriteBool(headTrackingEnabled)
429             && parcel.WriteInt32(static_cast<int32_t>(pipeType))
430             && parcel.WriteInt32(static_cast<int32_t>(samplingRate))
431             && parcel.WriteUint8(encodingType)
432             && parcel.WriteUint64(channelLayout)
433             && parcel.WriteInt32(format)
434             && parcel.WriteBool(isOffloadAllowed)
435             && parcel.WriteInt32(playerType)
436             && parcel.WriteUint64(expectedPlaybackDurationBytes)
437             && parcel.WriteInt32(effectMode)
438             && parcel.WriteInt32(static_cast<int32_t>(volumeMode));
439     }
UnmarshallingAudioRendererInfo440     void Unmarshalling(Parcel &parcel)
441     {
442         contentType = static_cast<ContentType>(parcel.ReadInt32());
443         streamUsage = static_cast<StreamUsage>(parcel.ReadInt32());
444         rendererFlags = parcel.ReadInt32();
445         originalFlag = parcel.ReadInt32();
446         sceneType = parcel.ReadString();
447         spatializationEnabled = parcel.ReadBool();
448         headTrackingEnabled = parcel.ReadBool();
449         pipeType = static_cast<AudioPipeType>(parcel.ReadInt32());
450         samplingRate = static_cast<AudioSamplingRate>(parcel.ReadInt32());
451         encodingType = parcel.ReadUint8();
452         channelLayout = parcel.ReadUint64();
453         format = static_cast<AudioSampleFormat>(parcel.ReadInt32());
454         isOffloadAllowed = parcel.ReadBool();
455         playerType = static_cast<PlayerType>(parcel.ReadInt32());
456         expectedPlaybackDurationBytes = parcel.ReadUint64();
457         effectMode = parcel.ReadInt32();
458         volumeMode = static_cast<AudioVolumeMode>(parcel.ReadInt32());
459     }
460 };
461 
462 class AudioCapturerInfo {
463 public:
464     SourceType sourceType = SOURCE_TYPE_INVALID;
465     int32_t capturerFlags = 0;
466     int32_t originalFlag = AUDIO_FLAG_NORMAL;
467     AudioPipeType pipeType = PIPE_TYPE_UNKNOWN;
468     AudioSamplingRate samplingRate = SAMPLE_RATE_8000;
469     uint8_t encodingType = 0;
470     uint64_t channelLayout = 0ULL;
471     std::string sceneType = "";
472 
AudioCapturerInfo(SourceType sourceType_,int32_t capturerFlags_)473     AudioCapturerInfo(SourceType sourceType_, int32_t capturerFlags_) : sourceType(sourceType_),
474         capturerFlags(capturerFlags_) {}
AudioCapturerInfo(const AudioCapturerInfo & audioCapturerInfo)475     AudioCapturerInfo(const AudioCapturerInfo &audioCapturerInfo)
476     {
477         *this = audioCapturerInfo;
478     }
479     AudioCapturerInfo() = default;
480     ~AudioCapturerInfo()= default;
Marshalling(Parcel & parcel)481     bool Marshalling(Parcel &parcel) const
482     {
483         return parcel.WriteInt32(static_cast<int32_t>(sourceType)) &&
484             parcel.WriteInt32(capturerFlags) &&
485             parcel.WriteInt32(originalFlag) &&
486             parcel.WriteInt32(static_cast<int32_t>(pipeType)) &&
487             parcel.WriteInt32(static_cast<int32_t>(samplingRate)) &&
488             parcel.WriteUint8(encodingType) &&
489             parcel.WriteUint64(channelLayout) &&
490             parcel.WriteString(sceneType);
491     }
Unmarshalling(Parcel & parcel)492     void Unmarshalling(Parcel &parcel)
493     {
494         sourceType = static_cast<SourceType>(parcel.ReadInt32());
495         capturerFlags = parcel.ReadInt32();
496         originalFlag = parcel.ReadInt32();
497         pipeType = static_cast<AudioPipeType>(parcel.ReadInt32());
498         samplingRate = static_cast<AudioSamplingRate>(parcel.ReadInt32());
499         encodingType = parcel.ReadUint8();
500         channelLayout = parcel.ReadUint64();
501         sceneType = parcel.ReadString();
502     }
503 };
504 
505 struct AudioRendererDesc {
506     ContentType contentType = CONTENT_TYPE_UNKNOWN;
507     StreamUsage streamUsage = STREAM_USAGE_UNKNOWN;
508 };
509 
510 struct AudioRendererOptions {
511     AudioStreamInfo streamInfo;
512     AudioRendererInfo rendererInfo;
513     AudioPrivacyType privacyType = PRIVACY_TYPE_PUBLIC;
514     AudioSessionStrategy strategy = { AudioConcurrencyMode::INVALID };
515 };
516 
517 struct MicStateChangeEvent {
518     bool mute;
519 };
520 
521 enum AudioScene : int32_t {
522     /**
523      * Invalid
524      */
525     AUDIO_SCENE_INVALID = -1,
526     /**
527      * Default audio scene
528      */
529     AUDIO_SCENE_DEFAULT,
530     /**
531      * Ringing audio scene
532      * Only available for system api.
533      */
534     AUDIO_SCENE_RINGING,
535     /**
536      * Phone call audio scene
537      * Only available for system api.
538      */
539     AUDIO_SCENE_PHONE_CALL,
540     /**
541      * Voice chat audio scene
542      */
543     AUDIO_SCENE_PHONE_CHAT,
544     /**
545      * AvSession set call start flag
546      */
547     AUDIO_SCENE_CALL_START,
548     /**
549      * AvSession set call end flag
550      */
551     AUDIO_SCENE_CALL_END,
552     /**
553      * Voice ringing audio scene
554      * Only available for system api.
555      */
556     AUDIO_SCENE_VOICE_RINGING,
557     /**
558      * Max
559      */
560     AUDIO_SCENE_MAX,
561 };
562 
563 enum AudioDeviceUsage : uint32_t {
564     /**
565      * Media output devices.
566      * @syscap SystemCapability.Multimedia.Audio.Device
567      * @systemapi
568      * @since 11
569      */
570     MEDIA_OUTPUT_DEVICES = 1,
571     /**
572      * Media input devices.
573      * @syscap SystemCapability.Multimedia.Audio.Device
574      * @systemapi
575      * @since 11
576      */
577     MEDIA_INPUT_DEVICES = 2,
578     /**
579      * All media devices.
580      * @syscap SystemCapability.Multimedia.Audio.Device
581      * @systemapi
582      * @since 11
583      */
584     ALL_MEDIA_DEVICES = 3,
585     /**
586      * Call output devices.
587      * @syscap SystemCapability.Multimedia.Audio.Device
588      * @systemapi
589      * @since 11
590      */
591     CALL_OUTPUT_DEVICES = 4,
592     /**
593      * Call input devices.
594      * @syscap SystemCapability.Multimedia.Audio.Device
595      * @systemapi
596      * @since 11
597      */
598     CALL_INPUT_DEVICES = 8,
599     /**
600      * All call devices.
601      * @syscap SystemCapability.Multimedia.Audio.Device
602      * @systemapi
603      * @since 11
604      */
605     ALL_CALL_DEVICES = 12,
606     /**
607      * All devices.
608      * @syscap SystemCapability.Multimedia.Audio.Device
609      * @systemapi
610      * @since 11
611      */
612     D_ALL_DEVICES = 15,
613 };
614 
615 enum FilterMode : uint32_t {
616     INCLUDE = 0,
617     EXCLUDE,
618     MAX_FILTER_MODE
619 };
620 
621 // 1.If the size of usages or pids is 0, FilterMode will not work.
622 // 2.Filters will only works with FileterMode INCLUDE or EXCLUDE while the vector size is not zero.
623 // 3.If usages and pids are both not empty, the result is the intersection of the two Filter.
624 // 4.If usages.size() == 0, defalut usages will be filtered with FilterMode::INCLUDE.
625 // 5.Default usages are MEDIA MUSIC MOVIE GAME and BOOK.
626 struct CaptureFilterOptions {
627     std::vector<StreamUsage> usages;
628     FilterMode usageFilterMode {FilterMode::INCLUDE};
629     std::vector<int32_t> pids;
630     FilterMode pidFilterMode {FilterMode::INCLUDE};
631 
632     bool operator ==(CaptureFilterOptions& filter)
633     {
634         std::sort(filter.usages.begin(), filter.usages.end());
635         std::sort(filter.pids.begin(), filter.pids.end());
636         std::sort(usages.begin(), usages.end());
637         std::sort(pids.begin(), pids.end());
638         return (filter.usages == usages && filter.usageFilterMode == usageFilterMode
639             && filter.pids == pids && filter.pidFilterMode == pidFilterMode);
640     }
641 };
642 
643 struct AudioPlaybackCaptureConfig {
644     CaptureFilterOptions filterOptions;
645     bool silentCapture {false}; // To be deprecated since 12
646 
647     bool operator ==(AudioPlaybackCaptureConfig& filter)
648     {
649         return (filter.filterOptions == filterOptions && filter.silentCapture == silentCapture);
650     }
651 };
652 
653 struct AudioCapturerOptions {
654     AudioStreamInfo streamInfo;
655     AudioCapturerInfo capturerInfo;
656     AudioPlaybackCaptureConfig playbackCaptureConfig;
657     AudioSessionStrategy strategy = { AudioConcurrencyMode::INVALID };
658 };
659 
660 struct AppInfo {
661     int32_t appUid { INVALID_UID };
662     uint32_t appTokenId { 0 };
663     int32_t appPid { 0 };
664     uint64_t appFullTokenId { 0 };
665 };
666 
667 struct BufferQueueState {
668     uint32_t numBuffers;
669     uint32_t currentIndex;
670 };
671 
672 enum AudioRenderMode {
673     RENDER_MODE_NORMAL,
674     RENDER_MODE_CALLBACK
675 };
676 
677 enum AudioCaptureMode {
678     CAPTURE_MODE_NORMAL,
679     CAPTURE_MODE_CALLBACK
680 };
681 
682 struct SinkInfo {
683     uint32_t sinkId; // sink id
684     std::string sinkName;
685     std::string adapterName;
686 };
687 
688 struct SinkInput {
689     int32_t streamId;
690     AudioStreamType streamType;
691 
692     // add for routing stream.
693     int32_t uid; // client uid
694     int32_t pid; // client pid
695     uint32_t paStreamId; // streamId
696     uint32_t deviceSinkId; // sink id
697     std::string sinkName; // sink name
698     int32_t statusMark; // mark the router status
699     uint64_t startTime; // when this router is created
MarshallingSinkInput700     bool Marshalling(Parcel &parcel) const
701     {
702         return parcel.WriteInt32(streamId) &&
703                parcel.WriteInt32(static_cast<int32_t>(streamType)) &&
704                parcel.WriteInt32(uid) &&
705                parcel.WriteInt32(pid) &&
706                parcel.WriteUint32(paStreamId);
707     }
UnmarshallingSinkInput708     void Unmarshalling(Parcel &parcel)
709     {
710         streamId = parcel.ReadInt32();
711         streamType = static_cast<AudioStreamType>(parcel.ReadInt32());
712         uid = parcel.ReadInt32();
713         pid = parcel.ReadInt32();
714         paStreamId = parcel.ReadUint32();
715     }
716 };
717 
718 struct SourceOutput {
719     int32_t streamId;
720     AudioStreamType streamType;
721 
722     // add for routing stream.
723     int32_t uid; // client uid
724     int32_t pid; // client pid
725     uint32_t paStreamId; // streamId
726     uint32_t deviceSourceId; // sink id
727     int32_t statusMark; // mark the router status
728     uint64_t startTime; // when this router is created
729 };
730 
731 typedef uint32_t AudioIOHandle;
732 
FLOAT_COMPARE_EQ(const float & x,const float & y)733 static inline bool FLOAT_COMPARE_EQ(const float& x, const float& y)
734 {
735     return (std::abs((x) - (y)) <= (std::numeric_limits<float>::epsilon()));
736 }
737 
738 enum AudioServiceIndex {
739     HDI_SERVICE_INDEX = 0,
740     AUDIO_SERVICE_INDEX
741 };
742 
743 /**
744  * @brief Enumerates the rendering states of the current device.
745  */
746 enum RendererState {
747     /** INVALID state */
748     RENDERER_INVALID = -1,
749     /** Create New Renderer instance */
750     RENDERER_NEW,
751     /** Reneder Prepared state */
752     RENDERER_PREPARED,
753     /** Rendere Running state */
754     RENDERER_RUNNING,
755     /** Renderer Stopped state */
756     RENDERER_STOPPED,
757     /** Renderer Released state */
758     RENDERER_RELEASED,
759     /** Renderer Paused state */
760     RENDERER_PAUSED
761 };
762 
763 /**
764  * @brief Enumerates the capturing states of the current device.
765  */
766 enum CapturerState {
767     /** Capturer INVALID state */
768     CAPTURER_INVALID = -1,
769     /** Create new capturer instance */
770     CAPTURER_NEW,
771     /** Capturer Prepared state */
772     CAPTURER_PREPARED,
773     /** Capturer Running state */
774     CAPTURER_RUNNING,
775     /** Capturer Stopped state */
776     CAPTURER_STOPPED,
777     /** Capturer Released state */
778     CAPTURER_RELEASED,
779     /** Capturer Paused state */
780     CAPTURER_PAUSED
781 };
782 
783 enum State {
784     /** INVALID */
785     INVALID = -1,
786     /** New */
787     NEW,
788     /** Prepared */
789     PREPARED,
790     /** Running */
791     RUNNING,
792     /** Stopped */
793     STOPPED,
794     /** Released */
795     RELEASED,
796     /** Paused */
797     PAUSED,
798     /** Stopping */
799     STOPPING
800 };
801 
802 struct StreamSwitchingInfo {
803     bool isSwitching_ = false;
804     State state_ = INVALID;
805 };
806 
807 struct AudioRegisterTrackerInfo {
808     uint32_t sessionId;
809     int32_t clientPid;
810     State state;
811     AudioRendererInfo rendererInfo;
812     AudioCapturerInfo capturerInfo;
813     int32_t channelCount;
814     uint32_t appTokenId;
815 };
816 
817 enum StateChangeCmdType {
818     CMD_FROM_CLIENT = 0,
819     CMD_FROM_SYSTEM = 1
820 };
821 
822 enum AudioMode {
823     AUDIO_MODE_PLAYBACK,
824     AUDIO_MODE_RECORD
825 };
826 
827 // LEGACY_INNER_CAP: Called from hap build with api < 12, work normally.
828 // LEGACY_MUTE_CAP: Called from hap build with api >= 12, will cap mute data.
829 // MODERN_INNER_CAP: Called from SA with inner-cap right, work with filter.
830 enum InnerCapMode : uint32_t {
831     LEGACY_INNER_CAP = 0,
832     LEGACY_MUTE_CAP,
833     MODERN_INNER_CAP,
834     INVALID_CAP_MODE
835 };
836 
837 struct AudioProcessConfig {
838     int32_t callerUid = INVALID_UID;
839 
840     AppInfo appInfo;
841 
842     AudioStreamInfo streamInfo;
843 
844     AudioMode audioMode = AUDIO_MODE_PLAYBACK;
845 
846     AudioRendererInfo rendererInfo;
847 
848     AudioCapturerInfo capturerInfo;
849 
850     AudioStreamType streamType = STREAM_DEFAULT;
851 
852     DeviceType deviceType = DEVICE_TYPE_INVALID;
853 
854     bool isInnerCapturer = false;
855 
856     bool isWakeupCapturer = false;
857 
858     uint32_t originalSessionId = 0;
859 
860     AudioPrivacyType privacyType = PRIVACY_TYPE_PUBLIC;
861 
862     InnerCapMode innerCapMode {InnerCapMode::INVALID_CAP_MODE};
863 
864     int32_t innerCapId = 0;
865 };
866 
867 struct Volume {
868     bool isMute = false;
869     float volumeFloat = 1.0f;
870     uint32_t volumeInt = 0;
871 };
872 
873 enum StreamSetState {
874     STREAM_PAUSE,
875     STREAM_RESUME,
876     STREAM_MUTE,
877     STREAM_UNMUTE
878 };
879 
880 enum SwitchState {
881     SWITCH_STATE_WAITING,
882     SWITCH_STATE_TIMEOUT,
883     SWITCH_STATE_CREATED,
884     SWITCH_STATE_STARTED,
885     SWITCH_STATE_FINISHED
886 };
887 
888 struct SwitchStreamInfo {
889     uint32_t sessionId = 0;
890     int32_t callerUid = INVALID_UID;
891     int32_t appUid = INVALID_UID;
892     int32_t appPid = 0;
893     uint32_t appTokenId = 0;
894     CapturerState nextState = CAPTURER_INVALID;
895     bool operator==(const SwitchStreamInfo& info) const
896     {
897         return sessionId == info.sessionId && callerUid == info.callerUid &&
898             appUid == info.appUid && appPid == info.appPid && appTokenId == info.appTokenId;
899     }
900     bool operator!=(const SwitchStreamInfo& info) const
901     {
902         return !(*this == info);
903     }
904 
905     bool operator<(const SwitchStreamInfo& info) const
906     {
907         if (sessionId != info.sessionId) {
908             return sessionId < info.sessionId;
909         }
910         if (callerUid != info.callerUid) {
911             return callerUid < info.callerUid;
912         }
913         if (appUid != info.appUid) {
914             return appUid < info.appUid;
915         }
916         if (appPid != info.appPid) {
917             return appPid < info.appPid;
918         }
919         return appTokenId < info.appTokenId;
920     }
921 
922     bool operator<=(const SwitchStreamInfo& info) const
923     {
924         return *this < info || *this == info;
925     }
926     bool operator>(const SwitchStreamInfo& info) const
927     {
928         return !(*this <= info);
929     }
930     bool operator>=(const SwitchStreamInfo& info) const
931     {
932         return !(*this < info);
933     }
934 };
935 
936 struct StreamSetStateEventInternal {
937     StreamSetState streamSetState;
938     StreamUsage streamUsage;
939 };
940 
941 enum AudioPin {
942     AUDIO_PIN_NONE = 0, // Invalid pin
943     AUDIO_PIN_OUT_SPEAKER = 1 << 0, // Speaker output pin
944     AUDIO_PIN_OUT_HEADSET = 1 << 1, // Wired headset pin for output
945     AUDIO_PIN_OUT_LINEOUT = 1 << 2, // Line-out pin
946     AUDIO_PIN_OUT_HDMI = 1 << 3, // HDMI output pin
947     AUDIO_PIN_OUT_USB = 1 << 4, // USB output pin
948     AUDIO_PIN_OUT_USB_EXT = 1 << 5, // Extended USB output pin
949     AUDIO_PIN_OUT_BLUETOOTH_SCO = 1 << 6, // Bluetooth SCO output pin
950     AUDIO_PIN_OUT_DAUDIO_DEFAULT = 1 << 7, // Daudio default output pin
951     AUDIO_PIN_OUT_HEADPHONE = 1 << 8, // Wired headphone output pin
952     AUDIO_PIN_OUT_USB_HEADSET = 1 << 9,  // Arm usb output pin
953     AUDIO_PIN_OUT_DP = 1 << 11,
954     AUDIO_PIN_IN_MIC = 1 << 27 | 1 << 0, // Microphone input pin
955     AUDIO_PIN_IN_HS_MIC = 1 << 27 | 1 << 1, // Wired headset microphone pin for input
956     AUDIO_PIN_IN_LINEIN = 1 << 27 | 1 << 2, // Line-in pin
957     AUDIO_PIN_IN_USB_EXT = 1 << 27 | 1 << 3, // Extended USB input pin
958     AUDIO_PIN_IN_BLUETOOTH_SCO_HEADSET = 1 << 27 | 1 << 4, // Bluetooth SCO headset input pin
959     AUDIO_PIN_IN_DAUDIO_DEFAULT = 1 << 27 | 1 << 5, // Daudio default input pin
960     AUDIO_PIN_IN_USB_HEADSET = 1 << 27 | 1 << 6,  // Arm usb input pin
961 };
962 
963 enum AudioParamKey {
964     NONE = 0,
965     VOLUME = 1,
966     INTERRUPT = 2,
967     PARAM_KEY_STATE = 5,
968     A2DP_SUSPEND_STATE = 6,  // for bluetooth sink
969     BT_HEADSET_NREC = 7,
970     BT_WBS = 8,
971     A2DP_OFFLOAD_STATE = 9, // for a2dp offload
972     GET_DP_DEVICE_INFO = 10, // for dp sink
973     USB_DEVICE = 101, // Check USB device type ARM or HIFI
974     PERF_INFO = 201,
975     MMI = 301,
976     PARAM_KEY_LOWPOWER = 1000,
977 };
978 
979 struct DStatusInfo {
980     char networkId[NETWORK_ID_SIZE];
981     AudioPin hdiPin = AUDIO_PIN_NONE;
982     int32_t mappingVolumeId = 0;
983     int32_t mappingInterruptId = 0;
984     int32_t deviceId;
985     int32_t channelMasks;
986     std::string deviceName = "";
987     bool isConnected = false;
988     std::string macAddress;
989     DeviceStreamInfo streamInfo = {};
990     ConnectType connectType = CONNECT_TYPE_LOCAL;
991 };
992 
993 struct AudioRendererDataInfo {
994     uint8_t *buffer;
995     size_t flag;
996 };
997 
998 enum AudioPermissionState {
999     AUDIO_PERMISSION_START = 0,
1000     AUDIO_PERMISSION_STOP = 1,
1001 };
1002 
1003 class AudioRendererPolicyServiceDiedCallback {
1004 public:
1005     virtual ~AudioRendererPolicyServiceDiedCallback() = default;
1006 
1007     /**
1008      * Called when audio policy service died.
1009      * @since 10
1010      */
1011     virtual void OnAudioPolicyServiceDied() = 0;
1012 };
1013 
1014 class AudioCapturerPolicyServiceDiedCallback {
1015 public:
1016     virtual ~AudioCapturerPolicyServiceDiedCallback() = default;
1017 
1018     /**
1019      * Called when audio policy service died.
1020      * @since 10
1021      */
1022     virtual void OnAudioPolicyServiceDied() = 0;
1023 };
1024 
1025 class AudioStreamPolicyServiceDiedCallback {
1026 public:
1027     virtual ~AudioStreamPolicyServiceDiedCallback() = default;
1028 
1029     /**
1030      * Called when audio policy service died.
1031      * @since 11
1032      */
1033     virtual void OnAudioPolicyServiceDied() = 0;
1034 };
1035 
1036 /**
1037  * Describes three-dimensional value.
1038  * @since 11
1039  */
1040 struct Vector3D {
1041     /**
1042      * X-axis value.
1043      * @since 11
1044      */
1045     float x;
1046     /**
1047      * Y-axis value.
1048      * @since 11
1049      */
1050     float y;
1051     /**
1052      * Z-axis value.
1053      * @since 11
1054      */
1055     float z;
1056 };
1057 
1058 struct SessionInfo {
1059     SourceType sourceType;
1060     uint32_t rate;
1061     uint32_t channels;
1062 };
1063 
1064 enum CastType {
1065     CAST_TYPE_NULL = 0,
1066     CAST_TYPE_ALL,
1067     CAST_TYPE_PROJECTION,
1068     CAST_TYPE_COOPERATION,
1069 };
1070 
1071 class AudioPnpDeviceChangeCallback {
1072 public:
1073     virtual ~AudioPnpDeviceChangeCallback() = default;
1074     virtual void OnPnpDeviceStatusChanged(const std::string &info) = 0;
1075     virtual void OnMicrophoneBlocked(const std::string &info) = 0;
1076 };
1077 
1078 struct SourceInfo {
1079     SourceType sourceType_;
1080     uint32_t rate_;
1081     uint32_t channels_;
1082 };
1083 
1084 /**
1085  * @brief Device group used by set/get volume.
1086  */
1087 enum DeviceGroup {
1088     /** Invalid device group */
1089     DEVICE_GROUP_INVALID = -1,
1090     /** Built in device */
1091     DEVICE_GROUP_BUILT_IN,
1092     /** Wired device */
1093     DEVICE_GROUP_WIRED,
1094     /** Wireless device */
1095     DEVICE_GROUP_WIRELESS,
1096     /** Remote cast device */
1097     DEVICE_GROUP_REMOTE_CAST,
1098     /* earpiece device*/
1099     DEVICE_GROUP_EARPIECE,
1100 };
1101 
GetVolumeGroupForDevice(DeviceType deviceType)1102 static inline DeviceGroup GetVolumeGroupForDevice(DeviceType deviceType)
1103 {
1104     static const std::map<DeviceType, DeviceGroup> DEVICE_GROUP_FOR_VOLUME = {
1105         {DEVICE_TYPE_EARPIECE, DEVICE_GROUP_EARPIECE}, {DEVICE_TYPE_SPEAKER, DEVICE_GROUP_BUILT_IN},
1106         {DEVICE_TYPE_DP, DEVICE_GROUP_BUILT_IN}, {DEVICE_TYPE_WIRED_HEADSET, DEVICE_GROUP_WIRED},
1107         {DEVICE_TYPE_USB_HEADSET, DEVICE_GROUP_WIRED}, {DEVICE_TYPE_USB_ARM_HEADSET, DEVICE_GROUP_WIRED},
1108         {DEVICE_TYPE_BLUETOOTH_A2DP, DEVICE_GROUP_WIRELESS}, {DEVICE_TYPE_BLUETOOTH_SCO, DEVICE_GROUP_WIRELESS},
1109         {DEVICE_TYPE_REMOTE_CAST, DEVICE_GROUP_REMOTE_CAST}, {DEVICE_TYPE_HDMI, DEVICE_GROUP_BUILT_IN},
1110     };
1111     auto it = DEVICE_GROUP_FOR_VOLUME.find(deviceType);
1112     return it == DEVICE_GROUP_FOR_VOLUME.end() ? DEVICE_GROUP_INVALID : it->second;
1113 }
1114 
1115 enum RouterType {
1116     /**
1117      * None router.
1118      * @since 12
1119      */
1120     ROUTER_TYPE_NONE = 0,
1121     /**
1122      * Default router.
1123      * @since 12
1124      */
1125     ROUTER_TYPE_DEFAULT,
1126     /**
1127      * Stream filter router.
1128      * @since 12
1129      */
1130     ROUTER_TYPE_STREAM_FILTER,
1131     /**
1132      * Package filter router.
1133      * @since 12
1134      */
1135     ROUTER_TYPE_PACKAGE_FILTER,
1136     /**
1137      * Cockpit phone router.
1138      * @since 12
1139      */
1140     ROUTER_TYPE_COCKPIT_PHONE,
1141     /**
1142      * Privacy priority router.
1143      * @since 12
1144      */
1145     ROUTER_TYPE_PRIVACY_PRIORITY,
1146     /**
1147      * Public priority router.
1148      * @since 12
1149      */
1150     ROUTER_TYPE_PUBLIC_PRIORITY,
1151     /**
1152      * Pair device router.
1153      * @since 12
1154      */
1155     ROUTER_TYPE_PAIR_DEVICE,
1156     /**
1157      * User select router.
1158      * @since 12
1159      */
1160     ROUTER_TYPE_USER_SELECT,
1161 
1162     /**
1163      * App select router.
1164      * @since 12
1165      */
1166     ROUTER_TYPE_APP_SELECT,
1167 };
1168 
1169 enum RenderMode {
1170     /**
1171      * Primary render mode.
1172      * @since 12
1173      */
1174     PRIMARY,
1175     /**
1176      * VOIP render mode.
1177      * @since 12
1178      */
1179     VOIP,
1180     /**
1181      * Offload render mode.
1182      * @since 12
1183      */
1184     OFFLOAD,
1185     /**
1186      * Low latency render mode.
1187      * @since 12
1188      */
1189     LOW_LATENCY,
1190 };
1191 
1192 enum WriteDataCallbackType {
1193     /**
1194      * Use OH_AudioRenderer_Callbacks.OH_AudioRenderer_OnWriteData
1195      * @since 12
1196      */
1197     WRITE_DATA_CALLBACK_WITHOUT_RESULT = 0,
1198     /**
1199      * Use OH_AudioRenderer_OnWriteDataCallback.
1200      * @since 12
1201      */
1202     WRITE_DATA_CALLBACK_WITH_RESULT = 1
1203 };
1204 
1205 enum ReadDataCallbackType {
1206     /**
1207      * Use OH_AudioCapturer_Callbacks.OH_AudioCapturer_OnReadData
1208      * @since 12
1209      */
1210     READ_DATA_CALLBACK_WITHOUT_RESULT = 0,
1211     /**
1212      * Use OH_AudioCapturer_OnReadDataCallback.
1213      * @since 12
1214      */
1215     READ_DATA_CALLBACK_WITH_RESULT = 1
1216 };
1217 
1218 enum StreamEventCallbackType {
1219     /**
1220      * Use OH_AudioCapturer_Callbacks.OH_AudioCapturer_OnStreamEvent
1221      * @since 12
1222      */
1223     STREAM_EVENT_CALLBACK_WITHOUT_RESULT = 0,
1224     /**
1225      * Use OH_AudioCapturer_OnStreamEventCallback.
1226      * @since 12
1227      */
1228     STREAM_EVENT_CALLBACK_WITH_RESULT = 1
1229 };
1230 
1231 enum InterruptEventCallbackType {
1232     /**
1233      * Use OH_AudioRenderer_Callbacks.OH_AudioRenderer_OnInterruptEvent
1234      * @since 12
1235      */
1236     INTERRUPT_EVENT_CALLBACK_WITHOUT_RESULT = 0,
1237     /**
1238      * Use OH_AudioRenderer_OnInterruptEventCallback.
1239      * @since 12
1240      */
1241     INTERRUPT_EVENT_CALLBACK_WITH_RESULT = 1
1242 };
1243 
1244 enum ErrorCallbackType {
1245     /**
1246      * Use OH_AudioRenderer_Callbacks.OH_AudioRenderer_OnError
1247      *
1248      * @since 12
1249      */
1250     ERROR_CALLBACK_WITHOUT_RESULT = 0,
1251     /**
1252      * Use OH_AudioRenderer_OnErrorCallback.
1253      * @since 12
1254      */
1255     ERROR_CALLBACK_WITH_RESULT = 1
1256 };
1257 
1258 enum PolicyType {
1259     EDM_POLICY_TYPE = 0,
1260     PRIVACY_POLCIY_TYPE = 1,
1261     TEMPORARY_POLCIY_TYPE = 2,
1262 };
1263 
1264 enum SuscribeResultCode {
1265     SUCCESS_SUBSCRIBE = 0,
1266     /**
1267      * Volume button input error
1268      */
1269     ERR_SUBSCRIBE_INVALID_PARAM,
1270      /**
1271      * The keyOption creation failed
1272      */
1273     ERR_SUBSCRIBE_KEY_OPTION_NULL,
1274      /**
1275      * The im pointer creation failed
1276      */
1277     ERR_SUBSCRIBE_MMI_NULL,
1278     /**
1279      * Volume key multimode subscription results
1280      */
1281     ERR_MODE_SUBSCRIBE,
1282 };
1283 
1284 enum RendererStage {
1285     RENDERER_STAGE_UNKNOWN = 0,
1286     RENDERER_STAGE_START_OK = 0x10,
1287     RENDERER_STAGE_START_FAIL = 0x11,
1288     RENDERER_STAGE_PAUSE_OK = 0x20,
1289     RENDERER_STAGE_STOP_OK = 0x30,
1290     RENDERER_STAGE_STANDBY_BEGIN = 0x40,
1291     RENDERER_STAGE_STANDBY_END = 0x41,
1292     RENDERER_STAGE_SET_VOLUME_ZERO = 0x50,
1293     RENDERER_STAGE_SET_VOLUME_NONZERO = 0x51,
1294 };
1295 
1296 enum CapturerStage {
1297     CAPTURER_STAGE_START_OK = 0x10,
1298     CAPTURER_STAGE_START_FAIL = 0x11,
1299     CAPTURER_STAGE_PAUSE_OK = 0x20,
1300     CAPTURER_STAGE_STOP_OK = 0x30,
1301 };
1302 
1303 
1304 enum RestoreStatus : int32_t {
1305     NO_NEED_FOR_RESTORE = 0,
1306     NEED_RESTORE,
1307     RESTORING,
1308     RESTORE_ERROR,
1309 };
1310 
1311 enum RestoreReason : int32_t {
1312     DEFAULT_REASON = 0,
1313     DEVICE_CHANGED,
1314     STREAM_CONCEDED,
1315     STREAM_SPLIT,
1316     SERVER_DIED,
1317 };
1318 
1319 enum CheckPosTimeRes : int32_t {
1320     CHECK_SUCCESS = 0,
1321     CHECK_FAILED,
1322     NEED_MODIFY,
1323 };
1324 
1325 struct RestoreInfo {
1326     RestoreReason restoreReason = DEFAULT_REASON;
1327     int32_t deviceChangeReason = 0;
1328     int32_t targetStreamFlag = AUDIO_FLAG_NORMAL;
1329 };
1330 } // namespace AudioStandard
1331 } // namespace OHOS
1332 #endif // AUDIO_INFO_H
1333