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 OH_RENDER_ENGINE_INTERFACE_H 17 #define OH_RENDER_ENGINE_INTERFACE_H 18 19 #include "render/graphics/graphics_render_info.h" 20 #include "external_window.h" 21 #include "native_avcodec_base.h" 22 23 namespace OHOS { 24 namespace Media { 25 26 #ifndef GL_TEXTURE_EXTERNAL_OES 27 #define GL_TEXTURE_EXTERNAL_OES 0x8D65 28 #endif 29 30 enum class GraphicsRenderResult : uint32_t { 31 SUCCESS, 32 ERROR, 33 }; 34 35 using RenderResultCallback = std::function<void(GraphicsRenderResult result)>; 36 37 class IGraphicsRenderEngine { 38 public: 39 static std::shared_ptr<IGraphicsRenderEngine> Create(OHNativeWindow* outputWindow); 40 41 // Init the graphics render engine, parameter window is the output surface of the rendering engine in surface mode. 42 // You can set it to xcomponent for screen preview, or as the input surface of the encoder to output data to the 43 // encoder after rendering, or as the input surface of components such as vpe for more complex operations. 44 virtual VEFError Init(OHNativeWindow* outputWindow) = 0; 45 46 // Uninitialize the rendering engine 47 // Before destructing the rendering engine, the caller needs to call this API to release some resources. 48 virtual VEFError UnInit() = 0; 49 50 // Start the graphics render engine 51 virtual VEFError StartRender() = 0; 52 53 // Stop the graphics render engine 54 virtual VEFError StopRender() = 0; 55 56 // Obtain the input surface of the rendering engine. 57 // You can set the obtained surface to the decoder. In this way, the data decoded by the decoder is directly sent 58 // to the rendering engine through the surface. You can also set the obtained surface to the VPE to process some 59 // complex operations, such as color space conversion. 60 virtual OHNativeWindow* GetInputWindow() = 0; 61 62 // Render frame data. Index indicates the PTS of the frame. This index is written to the output surface. 63 // During encoding, the encoder encodes this index as the PTS of the frame. 64 virtual VEFError Render(uint64_t index, 65 const std::shared_ptr<GraphicsRenderInfo>& effectInfo, 66 const RenderResultCallback& cb) = 0; 67 }; 68 } // namespace Media 69 } // namespace OHOS 70 71 #endif // OH_RENDER_ENGINE_INTERFACE_H 72