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_RENDERER_ADAPTER_H 17 #define ARK_AUDIO_RENDERER_ADAPTER_H 18 #pragma once 19 20 #include "base/include/ark_web_base_ref_counted.h" 21 #include "base/include/ark_web_types.h" 22 23 namespace OHOS::ArkWeb { 24 25 /*--ark web(source=webcore)--*/ 26 class ArkAudioRendererOptionsAdapter : public virtual ArkWebBaseRefCounted { 27 public: 28 /*--ark web()--*/ 29 virtual int32_t GetSamplingRate() = 0; 30 31 /*--ark web()--*/ 32 virtual int32_t GetEncodingType() = 0; 33 34 /*--ark web()--*/ 35 virtual int32_t GetSampleFormat() = 0; 36 37 /*--ark web()--*/ 38 virtual int32_t GetChannel() = 0; 39 40 /*--ark web()--*/ 41 virtual int32_t GetContentType() = 0; 42 43 /*--ark web()--*/ 44 virtual int32_t GetStreamUsage() = 0; 45 46 /*--ark web()--*/ 47 virtual int32_t GetRenderFlags() = 0; 48 49 /*--ark web()--*/ 50 virtual int32_t GetConcurrencyMode() = 0; 51 }; 52 53 /*--ark web(source=webcore)--*/ 54 class ArkAudioRendererCallbackAdapter : public virtual ArkWebBaseRefCounted { 55 public: 56 /*--ark web()--*/ 57 virtual void OnSuspend() = 0; 58 59 /*--ark web()--*/ 60 virtual void OnResume() = 0; 61 }; 62 63 /*--ark web(source=webcore)--*/ 64 class ArkAudioOutputChangeCallbackAdapter : public virtual ArkWebBaseRefCounted { 65 public: 66 /*--ark web()--*/ 67 virtual void OnOutputDeviceChange(int32_t reason) = 0; 68 }; 69 70 /*--ark web(source=webview)--*/ 71 class ArkAudioRendererAdapter : public virtual ArkWebBaseRefCounted { 72 public: 73 /*--ark web()--*/ 74 virtual int32_t Create(const ArkWebRefPtr<ArkAudioRendererOptionsAdapter> options, ArkWebString& str) = 0; 75 76 /*--ark web()--*/ 77 virtual bool Start() = 0; 78 79 /*--ark web()--*/ 80 virtual bool Pause() = 0; 81 82 /*--ark web()--*/ 83 virtual bool Stop() = 0; 84 85 /*--ark web()--*/ 86 virtual bool Release2() = 0; 87 88 /*--ark web()--*/ 89 virtual int32_t Write(uint8_t* buffer, size_t bufferSize) = 0; 90 91 /*--ark web()--*/ 92 virtual int32_t GetLatency(uint64_t& latency) = 0; 93 94 /*--ark web()--*/ 95 virtual int32_t SetVolume(float volume) = 0; 96 97 /*--ark web()--*/ 98 virtual float GetVolume() = 0; 99 100 /*--ark web()--*/ 101 virtual int32_t SetAudioRendererCallback(const ArkWebRefPtr<ArkAudioRendererCallbackAdapter> callback) = 0; 102 103 /*--ark web()--*/ 104 virtual void SetInterruptMode(bool audioExclusive) = 0; 105 106 /*--ark web()--*/ 107 virtual bool IsRendererStateRunning() = 0; 108 109 /*--ark web()--*/ 110 virtual int32_t SetAudioOutputChangeCallback(const ArkWebRefPtr<ArkAudioOutputChangeCallbackAdapter> callback) = 0; 111 112 /** 113 * @brief SetAudioSilentMode, when isSilentMode is true, audio_render will not interrupt other andio output 114 */ 115 /*--ark web()--*/ 116 virtual void SetAudioSilentMode(bool isSilentMode) = 0; 117 118 /*--ark web()--*/ 119 virtual bool Flush() = 0; 120 }; 121 122 } // namespace OHOS::ArkWeb 123 124 #endif // ARK_AUDIO_RENDERER_ADAPTER_H 125