• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023-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 
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 ArkAudioBufferAdapter : public virtual ArkWebBaseRefCounted {
132 public:
133     /*--ark web()--*/
134     virtual uint8_t* GetBuffer() = 0;
135 
136     /*--ark web()--*/
137     virtual int32_t GetLength() = 0;
138 
139     /*--ark web()--*/
140     virtual int64_t GetTimestamp() = 0;
141 
142     /*--ark web()--*/
143     virtual int32_t GetSourcetype() = 0;
144 
145     /*--ark web()--*/
146     virtual void SetBuffer(uint8_t* buffer) = 0;
147 
148     /*--ark web()--*/
149     virtual void SetLength(int32_t length) = 0;
150 
151     /*--ark web()--*/
152     virtual void SetTimestamp(int64_t timestamp) = 0;
153 
154     /*--ark web()--*/
155     virtual void SetSourcetype(int32_t sourcetype) = 0;
156 };
157 
158 /*--ark web(source=webcore)--*/
159 class ArkScreenCaptureCallbackAdapter : public virtual ArkWebBaseRefCounted {
160 public:
161     /*--ark web()--*/
162     virtual void OnError(int32_t errorCode) = 0;
163 
164     /*--ark web()--*/
165     virtual void OnAudioBufferAvailable(bool isReady, int32_t type) = 0;
166 
167     /*--ark web()--*/
168     virtual void OnVideoBufferAvailable(bool isReady) = 0;
169 
170     /*--ark web()--*/
171     virtual void OnStateChange(int32_t stateCode) = 0;
172 };
173 
174 /*--ark web(source=webview)--*/
175 class ArkScreenCaptureAdapter : public virtual ArkWebBaseRefCounted {
176 public:
177     /*--ark web()--*/
178     virtual int32_t Init(const ArkWebRefPtr<ArkScreenCaptureConfigAdapter> config) = 0;
179 
180     /*--ark web()--*/
181     virtual int32_t SetMicrophoneEnable(bool enable) = 0;
182 
183     /*--ark web()--*/
184     virtual int32_t StartCapture() = 0;
185 
186     /*--ark web()--*/
187     virtual int32_t StopCapture() = 0;
188 
189     /*--ark web()--*/
190     virtual int32_t SetCaptureCallback(const ArkWebRefPtr<ArkScreenCaptureCallbackAdapter> callback) = 0;
191 
192     /*--ark web()--*/
193     virtual ArkWebRefPtr<ArkSurfaceBufferAdapter> AcquireVideoBuffer() = 0;
194 
195     /*--ark web()--*/
196     virtual int32_t ReleaseVideoBuffer() = 0;
197 
198     /*--ark web()--*/
199     virtual int32_t AcquireAudioBuffer(
200         ArkWebRefPtr<ArkAudioBufferAdapter> audiobuffer, int32_t type) = 0;
201 
202     /*--ark web()--*/
203     virtual int32_t ReleaseAudioBuffer(int32_t type) = 0;
204 };
205 
206 } // namespace OHOS::ArkWeb
207 
208 #endif // ARK_SCREEN_CAPTURE_ADAPTER_H
209