• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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_MEDIA_CODEC_ENCODER_ADAPTER_H
17 #define ARK_MEDIA_CODEC_ENCODER_ADAPTER_H
18 #pragma once
19 
20 #include "ohos_adapter/include/ark_graphic_adapter.h"
21 
22 namespace OHOS::ArkWeb {
23 
24 /*--ark web(source=library)--*/
25 class ArkCapabilityDataAdapter : public virtual ArkWebBaseRefCounted {
26 public:
27     /*--ark web()--*/
28     virtual int32_t GetMaxWidth() = 0;
29 
30     /*--ark web()--*/
31     virtual int32_t GetMaxHeight() = 0;
32 
33     /*--ark web()--*/
34     virtual int32_t GetMaxframeRate() = 0;
35 };
36 
37 /*--ark web(source=library)--*/
38 class ArkCodecFormatAdapter : public virtual ArkWebBaseRefCounted {
39 public:
40     /*--ark web()--*/
41     virtual int32_t GetWidth() = 0;
42 
43     /*--ark web()--*/
44     virtual int32_t GetHeight() = 0;
45 };
46 
47 /*--ark web(source=library)--*/
48 class ArkBufferInfoAdapter : public virtual ArkWebBaseRefCounted {
49 public:
50     /*--ark web()--*/
51     virtual int64_t GetPresentationTimeUs() = 0;
52 
53     /*--ark web()--*/
54     virtual int32_t GetSize() = 0;
55 
56     /*--ark web()--*/
57     virtual int32_t GetOffset() = 0;
58 };
59 
60 /*--ark web(source=library)--*/
61 class ArkOhosBufferAdapter : public virtual ArkWebBaseRefCounted {
62 public:
63     /*--ark web()--*/
64     virtual uint8_t* GetAddr() = 0;
65 
66     /*--ark web()--*/
67     virtual uint32_t GetBufferSize() = 0;
68 };
69 
70 /*--ark web(source=web core)--*/
71 class ArkCodecConfigParaAdapter : public virtual ArkWebBaseRefCounted {
72 public:
73     /*--ark web()--*/
74     virtual int32_t GetWidth() = 0;
75 
76     /*--ark web()--*/
77     virtual int32_t GetHeight() = 0;
78 
79     /*--ark web()--*/
80     virtual int64_t GetBitRate() = 0;
81 
82     /*--ark web()--*/
83     virtual double GetFrameRate() = 0;
84 };
85 
86 /*--ark web(source=web core)--*/
87 class ArkCodecCallbackAdapter : public virtual ArkWebBaseRefCounted {
88 public:
89     /*--ark web()--*/
90     virtual void OnError(int32_t errorType, int32_t errorCode) = 0;
91 
92     /*--ark web()--*/
93     virtual void OnStreamChanged(const ArkWebRefPtr<ArkCodecFormatAdapter> format) = 0;
94 
95     /*--ark web()--*/
96     virtual void OnNeedInputData(uint32_t index, ArkWebRefPtr<ArkOhosBufferAdapter> buffer) = 0;
97 
98     /*--ark web()--*/
99     virtual void OnNeedOutputData(uint32_t index, ArkWebRefPtr<ArkBufferInfoAdapter> info, int32_t flag,
100         ArkWebRefPtr<ArkOhosBufferAdapter> buffer) = 0;
101 };
102 
103 /*--ark web(source=library)--*/
104 class ArkMediaCodecAdapter : public virtual ArkWebBaseRefCounted {
105 public:
106     /*--ark web()--*/
107     virtual int32_t CreateVideoCodecByMime(const ArkWebString mimetype) = 0;
108 
109     /*--ark web()--*/
110     virtual int32_t CreateVideoCodecByName(const ArkWebString name) = 0;
111 
112     /*--ark web()--*/
113     virtual int32_t SetCodecCallback(const ArkWebRefPtr<ArkCodecCallbackAdapter> callback) = 0;
114 
115     /*--ark web()--*/
116     virtual int32_t Configure(const ArkWebRefPtr<ArkCodecConfigParaAdapter> config) = 0;
117 
118     /*--ark web()--*/
119     virtual int32_t Prepare() = 0;
120 
121     /*--ark web()--*/
122     virtual int32_t Start() = 0;
123 
124     /*--ark web()--*/
125     virtual int32_t Stop() = 0;
126 
127     /*--ark web()--*/
128     virtual int32_t Reset() = 0;
129 
130     /*--ark web()--*/
131     virtual int32_t Release() = 0;
132 
133     /*--ark web()--*/
134     virtual ArkWebRefPtr<ArkProducerSurfaceAdapter> CreateInputSurface() = 0;
135 
136     /*--ark web()--*/
137     virtual int32_t ReleaseOutputBuffer(uint32_t index, bool isRender) = 0;
138 
139     /*--ark web()--*/
140     virtual int32_t RequestKeyFrameSoon() = 0;
141 };
142 
143 /*--ark web(source=library)--*/
144 class ArkMediaCodecListAdapter : public virtual ArkWebBaseRefCounted {
145 public:
146     /*--ark web()--*/
147     virtual ArkWebRefPtr<ArkCapabilityDataAdapter> GetCodecCapability(const ArkWebString mime, const bool isCodec) = 0;
148 };
149 
150 } // namespace OHOS::ArkWeb
151 
152 #endif // ARK_MEDIA_CODEC_ENCODER_ADAPTER_H
153