• 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 ARK_AUDIO_SYSTEM_MANAGER_ADAPTER_H
17 #define ARK_AUDIO_SYSTEM_MANAGER_ADAPTER_H
18 #pragma once
19 
20 #include "ohos_adapter/include/ark_audio_device_desc_adapter_vector.h"
21 
22 #include "base/include/ark_web_base_ref_counted.h"
23 #include "base/include/ark_web_types.h"
24 
25 namespace OHOS::ArkWeb {
26 
27 /*--ark web(source=webcore)--*/
28 class ArkAudioInterruptAdapter : public virtual ArkWebBaseRefCounted {
29 public:
30     /*--ark web()--*/
31     virtual int32_t GetStreamUsage() = 0;
32 
33     /*--ark web()--*/
34     virtual int32_t GetContentType() = 0;
35 
36     /*--ark web()--*/
37     virtual int32_t GetStreamType() = 0;
38 
39     /*--ark web()--*/
40     virtual uint32_t GetSessionID() = 0;
41 
42     /*--ark web()--*/
43     virtual bool GetPauseWhenDucked() = 0;
44 };
45 
46 /*--ark web(source=webview)--*/
47 class ArkAudioDeviceDescAdapter : public virtual ArkWebBaseRefCounted {
48 public:
49     /*--ark web()--*/
50     virtual int32_t GetDeviceId() = 0;
51 
52     /*--ark web()--*/
53     virtual ArkWebString GetDeviceName() = 0;
54 };
55 
56 /*--ark web(source=webcore)--*/
57 class ArkAudioManagerCallbackAdapter : public virtual ArkWebBaseRefCounted {
58 public:
59     /*--ark web()--*/
60     virtual void OnSuspend() = 0;
61 
62     /*--ark web()--*/
63     virtual void OnResume() = 0;
64 };
65 
66 /*--ark web(source=webcore)--*/
67 class ArkAudioManagerDeviceChangeCallbackAdapter : public virtual ArkWebBaseRefCounted {
68 public:
69     /*--ark web()--*/
70     virtual void OnDeviceChange() = 0;
71 };
72 
73 /*--ark web(source=webview)--*/
74 class ArkAudioSystemManagerAdapter : public virtual ArkWebBaseRefCounted {
75 public:
76     /*--ark web()--*/
77     virtual bool HasAudioOutputDevices() = 0;
78 
79     /*--ark web()--*/
80     virtual bool HasAudioInputDevices() = 0;
81 
82     /*--ark web()--*/
83     virtual int32_t RequestAudioFocus(const ArkWebRefPtr<ArkAudioInterruptAdapter> audioInterrupt) = 0;
84 
85     /*--ark web()--*/
86     virtual int32_t AbandonAudioFocus(const ArkWebRefPtr<ArkAudioInterruptAdapter> audioInterrupt) = 0;
87 
88     /*--ark web()--*/
89     virtual int32_t SetAudioManagerInterruptCallback(ArkWebRefPtr<ArkAudioManagerCallbackAdapter> callback) = 0;
90 
91     /*--ark web()--*/
92     virtual int32_t UnsetAudioManagerInterruptCallback() = 0;
93 
94     /*--ark web()--*/
95     virtual ArkAudioDeviceDescAdapterVector GetDevices(int32_t flag) = 0;
96 
97     /*--ark web()--*/
98     virtual int32_t SelectAudioDeviceById(int32_t deviceId, bool isInput) = 0;
99 
100     /*--ark web()--*/
101     virtual int32_t SetDeviceChangeCallback(ArkWebRefPtr<ArkAudioManagerDeviceChangeCallbackAdapter> callback) = 0;
102 
103     /*--ark web()--*/
104     virtual int32_t UnsetDeviceChangeCallback() = 0;
105 
106     /*--ark web()--*/
107     virtual ArkWebRefPtr<ArkAudioDeviceDescAdapter> GetDefaultOutputDevice() = 0;
108 
109     /*--ark web()--*/
110     virtual ArkWebRefPtr<ArkAudioDeviceDescAdapter> GetDefaultInputDevice() = 0;
111 
112     /*--ark web()--*/
113     virtual bool SetLanguage(const ArkWebString& language) = 0;
114 };
115 
116 } // namespace OHOS::ArkWeb
117 
118 #endif // ARK_AUDIO_SYSTEM_MANAGER_ADAPTER_H
119