1 /* 2 * Copyright (c) 2023 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_SCREEN_CAPTURE_ADAPTER_H 17 #define ARK_SCREEN_CAPTURE_ADAPTER_H 18 #pragma once 19 20 #include "ohos_adapter/include/ark_graphic_adapter.h" 21 22 namespace OHOS::ArkWeb { 23 /*--ark web(source=webcore)--*/ 24 class ArkAudioCaptureInfoAdapter : public virtual ArkWebBaseRefCounted { 25 public: 26 /*--ark web()--*/ 27 virtual int32_t GetAudioSampleRate() = 0; 28 29 /*--ark web()--*/ 30 virtual int32_t GetAudioChannels() = 0; 31 32 /*--ark web()--*/ 33 virtual int32_t GetAudioSource() = 0; 34 }; 35 36 /*--ark web(source=webcore)--*/ 37 class ArkAudioEncInfoAdapter : public virtual ArkWebBaseRefCounted { 38 public: 39 /*--ark web()--*/ 40 virtual int32_t GetAudioBitrate() = 0; 41 42 /*--ark web()--*/ 43 virtual int32_t GetAudioCodecformat() = 0; 44 }; 45 46 /*--ark web(source=webcore)--*/ 47 class ArkAudioInfoAdapter : public virtual ArkWebBaseRefCounted { 48 public: 49 /*--ark web()--*/ 50 virtual ArkWebRefPtr<ArkAudioCaptureInfoAdapter> GetMicCapInfo() = 0; 51 52 /*--ark web()--*/ 53 virtual ArkWebRefPtr<ArkAudioCaptureInfoAdapter> GetInnerCapInfo() = 0; 54 55 /*--ark web()--*/ 56 virtual ArkWebRefPtr<ArkAudioEncInfoAdapter> GetAudioEncInfo() = 0; 57 }; 58 59 /*--ark web(source=webcore)--*/ 60 class ArkVideoCaptureInfoAdapter : public virtual ArkWebBaseRefCounted { 61 public: 62 /*--ark web()--*/ 63 virtual uint64_t GetDisplayId() = 0; 64 65 /*--ark web()--*/ 66 virtual ArkWebInt32List GetTaskIDs() = 0; 67 68 /*--ark web()--*/ 69 virtual int32_t GetVideoFrameWidth() = 0; 70 71 /*--ark web()--*/ 72 virtual int32_t GetVideoFrameHeight() = 0; 73 74 /*--ark web()--*/ 75 virtual int32_t GetVideoSourceType() = 0; 76 }; 77 78 /*--ark web(source=webcore)--*/ 79 class ArkVideoEncInfoAdapter : public virtual ArkWebBaseRefCounted { 80 public: 81 /*--ark web()--*/ 82 virtual int32_t GetVideoCodecFormat() = 0; 83 84 /*--ark web()--*/ 85 virtual int32_t GetVideoBitrate() = 0; 86 87 /*--ark web()--*/ 88 virtual int32_t GetVideoFrameRate() = 0; 89 }; 90 91 /*--ark web(source=webcore)--*/ 92 class ArkVideoInfoAdapter : public virtual ArkWebBaseRefCounted { 93 public: 94 /*--ark web()--*/ 95 virtual ArkWebRefPtr<ArkVideoCaptureInfoAdapter> GetVideoCapInfo() = 0; 96 97 /*--ark web()--*/ 98 virtual ArkWebRefPtr<ArkVideoEncInfoAdapter> GetVideoEncInfo() = 0; 99 }; 100 101 /*--ark web(source=webcore)--*/ 102 class ArkRecorderInfoAdapter : public virtual ArkWebBaseRefCounted { 103 public: 104 /*--ark web()--*/ 105 virtual ArkWebString GetUrl() = 0; 106 107 /*--ark web()--*/ 108 virtual int32_t GetFileFormat() = 0; 109 }; 110 111 /*--ark web(source=webcore)--*/ 112 class ArkScreenCaptureConfigAdapter : public virtual ArkWebBaseRefCounted { 113 public: 114 /*--ark web()--*/ 115 virtual int32_t GetCaptureMode() = 0; 116 117 /*--ark web()--*/ 118 virtual int32_t GetDataType() = 0; 119 120 /*--ark web()--*/ 121 virtual ArkWebRefPtr<ArkAudioInfoAdapter> GetAudioInfo() = 0; 122 123 /*--ark web()--*/ 124 virtual ArkWebRefPtr<ArkVideoInfoAdapter> GetVideoInfo() = 0; 125 126 /*--ark web()--*/ 127 virtual ArkWebRefPtr<ArkRecorderInfoAdapter> GetRecorderInfo() = 0; 128 }; 129 130 /*--ark web(source=webcore)--*/ 131 class ArkScreenCaptureCallbackAdapter : public virtual ArkWebBaseRefCounted { 132 public: 133 /*--ark web()--*/ 134 virtual void OnError(int32_t errorCode) = 0; 135 136 /*--ark web()--*/ 137 virtual void OnAudioBufferAvailable(bool isReady, int32_t type) = 0; 138 139 /*--ark web()--*/ 140 virtual void OnVideoBufferAvailable(bool isReady) = 0; 141 142 /*--ark web()--*/ 143 virtual void OnStateChange(int32_t stateCode) = 0; 144 }; 145 146 /*--ark web(source=webview)--*/ 147 class ArkScreenCaptureAdapter : public virtual ArkWebBaseRefCounted { 148 public: 149 /*--ark web()--*/ 150 virtual int32_t Init(const ArkWebRefPtr<ArkScreenCaptureConfigAdapter> config) = 0; 151 152 /*--ark web()--*/ 153 virtual int32_t SetMicrophoneEnable(bool enable) = 0; 154 155 /*--ark web()--*/ 156 virtual int32_t StartCapture() = 0; 157 158 /*--ark web()--*/ 159 virtual int32_t StopCapture() = 0; 160 161 /*--ark web()--*/ 162 virtual int32_t SetCaptureCallback(const ArkWebRefPtr<ArkScreenCaptureCallbackAdapter> callback) = 0; 163 164 /*--ark web()--*/ 165 virtual ArkWebRefPtr<ArkSurfaceBufferAdapter> AcquireVideoBuffer() = 0; 166 167 /*--ark web()--*/ 168 virtual int32_t ReleaseVideoBuffer() = 0; 169 }; 170 171 } // namespace OHOS::ArkWeb 172 173 #endif // ARK_SCREEN_CAPTURE_ADAPTER_H 174