fei.deng | f7a0cd3 | 2023-08-29 09:36:37 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2021 Amlogic Corporation. |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | #ifndef __RENDER_PLUGIN_H__ |
| 17 | #define __RENDER_PLUGIN_H__ |
| 18 | #include "render_common.h" |
| 19 | |
| 20 | typedef void (*pluginMsgCallback)(void *handle, int msg, void *detail); |
| 21 | typedef void (*pluginBufferReleaseCallback)(void *handle,void *data); |
| 22 | typedef void (*pluginBufferDisplayedCallback)(void *handle,void *data); |
| 23 | typedef void (*pluginBufferDropedCallback)(void *handle,void *data); |
| 24 | |
| 25 | typedef struct _PluginCallback { |
| 26 | pluginMsgCallback doMsgCallback; |
| 27 | pluginBufferReleaseCallback doBufferReleaseCallback; |
| 28 | pluginBufferDisplayedCallback doBufferDisplayedCallback; |
| 29 | pluginBufferDropedCallback doBufferDropedCallback; |
| 30 | } PluginCallback; |
| 31 | |
| 32 | /** |
| 33 | * @brief plugin key type |
| 34 | * it is used by set/get function |
| 35 | * |
| 36 | */ |
| 37 | typedef enum _PluginKey { |
| 38 | PLUGIN_KEY_WINDOW_SIZE, //value type is PluginRect point |
| 39 | PLUGIN_KEY_FRAME_SIZE, //value type is PluginFrameSize point |
| 40 | PLUGIN_KEY_VIDEO_FORMAT, //value type is uint32_t,detail see RenderVideoFormat that is in render_lib.h |
| 41 | PLUGIN_KEY_VIDEO_PIP, //is pip window, int type of value |
| 42 | PLUGIN_KEY_VIDEOTUNNEL_ID,//set/get videotunnel instance id when videotunnel plugin is selected |
| 43 | PLUGIN_KEY_KEEP_LAST_FRAME, //set/get keep last frame when play end ,value type is int, 0 not keep, 1 keep |
| 44 | PLUGIN_KEY_HIDE_VIDEO, //set/get hide video,it effect immediatialy,value type is int, 0 not hide, 1 hide |
| 45 | PLUGIN_KEY_FORCE_ASPECT_RATIO, //set/get force pixel aspect ratio,value type is int, 1 is force,0 is not force |
| 46 | PLUGIN_KEY_SELECT_DISPLAY_OUTPUT,//set/get selected displayt output,value type is int,0 is primary output, 1 is extend output |
| 47 | PLUGIN_KEY_IMMEDIATELY_OUTPUT, //set/get immediately output video frame to display, 0 is default value off, 1 is on |
| 48 | PLUGIN_KEY_CROP_FRAME_SIZE, //set/get crop frame size,value type is PluginRect |
fei.deng | 7ac1aeb | 2023-12-05 01:38:57 +0000 | [diff] [blame] | 49 | PLUGIN_KEY_PIXEL_ASPECT_RATIO, //set/get pixel aspect ratio,value type is double |
fei.deng | f1f5fc3 | 2023-12-06 06:22:20 +0000 | [diff] [blame] | 50 | PLUGIN_KEY_CURRENT_OUTPUT, //set/get signal output,value type is int |
fei.deng | 7ac1aeb | 2023-12-05 01:38:57 +0000 | [diff] [blame] | 51 | PLUGIN_KEY_VIDEO_FRAME_RATE, //set/get video frame rate,value type is RenderFraction |
le.han | bf4baf3 | 2024-02-28 03:28:11 +0000 | [diff] [blame] | 52 | PLUGIN_KEY_KEEP_LAST_FRAME_ON_FLUSH, //set/get keep last frame when seeking,value type is int, 0 not keep, 1 keep |
fei.deng | 1c94a34 | 2024-08-05 19:33:28 +0800 | [diff] [blame] | 53 | PLUGIN_KEY_ZORDER, //set/get zorder of video plane,value type is int |
fei.deng | 96aa7f7 | 2024-09-29 15:46:52 +0800 | [diff] [blame] | 54 | PLUGIN_KEY_ROTATE_VIDEO, //set/get video rotate,value type is int,rotate from 0 to 360 |
fei.deng | f862f9c | 2024-10-24 16:46:55 +0800 | [diff] [blame] | 55 | PLUGIN_KET_VIDEO_HWC_LATENCY, //get video hwc latency vsync count |
fei.deng | f7a0cd3 | 2023-08-29 09:36:37 +0000 | [diff] [blame] | 56 | } PluginKey; |
| 57 | |
| 58 | /** |
| 59 | * render plugin interface |
| 60 | * api sequence: |
| 61 | * 1.new RenderPlugin |
| 62 | * 2.plugin->init |
| 63 | * 3.plugin->setuserData |
| 64 | * 4.plugin->openDisplay |
| 65 | * 5.plugin->openWindow |
| 66 | * 6.plugin->set |
| 67 | * 7.plugin->displayFrame |
| 68 | * ...... |
| 69 | * after running ,stop plugin |
| 70 | * 8.plugin->closeWindow |
| 71 | * 9.plugin->closeDisplay |
| 72 | * 10.plugin->release |
| 73 | * 11.delete RenderPlugin |
| 74 | * |
| 75 | */ |
| 76 | class RenderPlugin { |
| 77 | public: |
| 78 | RenderPlugin() {}; |
| 79 | virtual ~RenderPlugin() {}; |
| 80 | /** |
| 81 | * @brief init render plugin |
| 82 | * |
| 83 | */ |
| 84 | virtual void init() = 0; |
| 85 | /** |
| 86 | * @brief release render plugin |
| 87 | * |
| 88 | */ |
| 89 | virtual void release() = 0; |
| 90 | /** |
| 91 | * @brief register callback to plugin |
| 92 | * |
| 93 | * @param userData user data |
| 94 | * @param callback user callback function |
| 95 | */ |
| 96 | virtual void setCallback(void *userData, PluginCallback *callback) = 0; |
| 97 | /** |
| 98 | * @brief open display from compositor |
| 99 | * |
| 100 | * @return 0 success,other value if failure |
| 101 | */ |
| 102 | virtual int openDisplay() = 0; |
| 103 | /** |
| 104 | * @brief open window from compositor |
| 105 | * |
| 106 | * @return 0 success,other value if failure |
| 107 | */ |
| 108 | virtual int openWindow() = 0; |
| 109 | /** |
| 110 | * @brief prepare RenderBuffer before displaying frame |
| 111 | * |
| 112 | * @param buffer video frame buffer |
| 113 | * @return 0 success,other value if failure |
| 114 | */ |
| 115 | virtual int prepareFrame(RenderBuffer *buffer) = 0; |
| 116 | /** |
| 117 | * @brief sending a video frame to compositor |
| 118 | * |
| 119 | * @param buffer video frame buffer |
| 120 | * @param displayTime the frame render realtime |
| 121 | * @return 0 success,other value if failure |
| 122 | */ |
| 123 | virtual int displayFrame(RenderBuffer *buffer, int64_t displayTime) = 0; |
| 124 | /** |
| 125 | * @brief flush buffers those obtained by plugin |
| 126 | * |
| 127 | * @return 0 success,other value if failure |
| 128 | */ |
| 129 | virtual int flush() = 0; |
| 130 | /** |
| 131 | * @brief pause plugin |
| 132 | * |
| 133 | * @return 0 success,other value if failure |
| 134 | */ |
| 135 | virtual int pause() = 0; |
| 136 | /** |
| 137 | * @brief resume plugin |
| 138 | * |
| 139 | * @return 0 success,other value if failure |
| 140 | */ |
| 141 | virtual int resume() = 0; |
| 142 | /** |
| 143 | * @brief close display |
| 144 | * |
| 145 | * @return 0 success,other value if failure |
| 146 | */ |
| 147 | virtual int closeDisplay() = 0; |
| 148 | /** |
| 149 | * @brief close window |
| 150 | * |
| 151 | * @return 0 success,other value if failure |
| 152 | */ |
| 153 | virtual int closeWindow() = 0; |
| 154 | /** |
| 155 | * @brief get property from plugin |
| 156 | * the value must map the key type,the detail please see |
| 157 | * enum _PluginKey |
| 158 | * |
| 159 | * @param key property key |
| 160 | * @param value property value |
| 161 | * @return 0 success,other value if failure |
| 162 | */ |
| 163 | virtual int getValue(PluginKey key, void *value) = 0; |
| 164 | /** |
| 165 | * @brief set property to plugin |
| 166 | * the value must map the key type,refer to PluginKey |
| 167 | * |
| 168 | * @param key property key |
| 169 | * @param value property value |
| 170 | * @return 0 success,other value if failure |
| 171 | */ |
| 172 | virtual int setValue(PluginKey key, void *value) = 0; |
| 173 | }; |
| 174 | #ifdef __cplusplus |
| 175 | extern "C" { |
| 176 | #endif |
| 177 | |
| 178 | /** |
| 179 | * make a render lib plugin instance |
| 180 | * @param id instance id |
| 181 | * @return the pointer to render lib plugin instance |
| 182 | */ |
| 183 | void *makePluginInstance(int id); |
| 184 | |
| 185 | /** |
| 186 | * destroy render lib plugin instance that created by makePluginInstance |
| 187 | * @param the handle point of video render plugin instance |
| 188 | */ |
| 189 | void destroyPluginInstance(void *); |
| 190 | |
| 191 | #ifdef __cplusplus |
| 192 | } |
| 193 | #endif |
| 194 | |
| 195 | #endif /*__RENDER_PLUGIN_H__*/ |