• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 AUDIO_SYSTEM_MANAGER_ADAPTER_H
17 #define AUDIO_SYSTEM_MANAGER_ADAPTER_H
18 
19 #include "audio_renderer_adapter.h"
20 
21 namespace OHOS::NWeb {
22 enum class AudioAdapterStreamType {
23     STREAM_DEFAULT = -1,
24     STREAM_VOICE_CALL = 0,
25     STREAM_MUSIC = 1,
26     STREAM_RING = 2,
27     STREAM_MEDIA = 3,
28     STREAM_VOICE_ASSISTANT = 4,
29     STREAM_SYSTEM = 5,
30     STREAM_ALARM = 6,
31     STREAM_NOTIFICATION = 7,
32     STREAM_BLUETOOTH_SCO = 8,
33     STREAM_ENFORCED_AUDIBLE = 9,
34     STREAM_DTMF = 10,
35     STREAM_TTS =  11,
36     STREAM_ACCESSIBILITY = 12,
37     STREAM_RECORDING = 13,
38     STREAM_ALL = 100
39 };
40 
41 struct AudioAdapterInterrupt {
42     AudioAdapterStreamUsage streamUsage;
43     AudioAdapterContentType contentType;
44     AudioAdapterStreamType streamType;
45     uint32_t sessionID;
46     bool pauseWhenDucked;
47 };
48 
49 class AudioManagerCallbackAdapter {
50 public:
51     AudioManagerCallbackAdapter() = default;
52 
53     virtual ~AudioManagerCallbackAdapter() = default;
54 
55     virtual void OnSuspend() = 0;
56 
57     virtual void OnResume() = 0;
58 };
59 
60 class AudioSystemManagerAdapter {
61 public:
62     AudioSystemManagerAdapter() = default;
63 
64     virtual ~AudioSystemManagerAdapter() = default;
65 
66     virtual bool HasAudioOutputDevices() const = 0;
67 
68     virtual bool HasAudioInputDevices() const = 0;
69 
70     virtual int32_t RequestAudioFocus(const AudioAdapterInterrupt &audioInterrupt) = 0;
71 
72     virtual int32_t AbandonAudioFocus(const AudioAdapterInterrupt &audioInterrupt) = 0;
73 
74     virtual int32_t SetAudioManagerInterruptCallback(const std::shared_ptr<AudioManagerCallbackAdapter> &callback) = 0;
75 
76     virtual int32_t UnsetAudioManagerInterruptCallback() = 0;
77 };
78 } // namespace OHOS::NWeb
79 
80 #endif // AUDIO_RENDERER_ADAPTER_H