blob: 0419fd051b34bf91749443b4a9e5d134af6102f9 [file] [log] [blame]
fei.dengf7a0cd32023-08-29 09:36:37 +00001/*
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
20typedef void (*pluginMsgCallback)(void *handle, int msg, void *detail);
21typedef void (*pluginBufferReleaseCallback)(void *handle,void *data);
22typedef void (*pluginBufferDisplayedCallback)(void *handle,void *data);
23typedef void (*pluginBufferDropedCallback)(void *handle,void *data);
24
25typedef 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 */
37typedef 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.deng7ac1aeb2023-12-05 01:38:57 +000049 PLUGIN_KEY_PIXEL_ASPECT_RATIO, //set/get pixel aspect ratio,value type is double
fei.dengf1f5fc32023-12-06 06:22:20 +000050 PLUGIN_KEY_CURRENT_OUTPUT, //set/get signal output,value type is int
fei.deng7ac1aeb2023-12-05 01:38:57 +000051 PLUGIN_KEY_VIDEO_FRAME_RATE, //set/get video frame rate,value type is RenderFraction
fei.dengf7a0cd32023-08-29 09:36:37 +000052} PluginKey;
53
54/**
55 * render plugin interface
56 * api sequence:
57 * 1.new RenderPlugin
58 * 2.plugin->init
59 * 3.plugin->setuserData
60 * 4.plugin->openDisplay
61 * 5.plugin->openWindow
62 * 6.plugin->set
63 * 7.plugin->displayFrame
64 * ......
65 * after running ,stop plugin
66 * 8.plugin->closeWindow
67 * 9.plugin->closeDisplay
68 * 10.plugin->release
69 * 11.delete RenderPlugin
70 *
71 */
72class RenderPlugin {
73 public:
74 RenderPlugin() {};
75 virtual ~RenderPlugin() {};
76 /**
77 * @brief init render plugin
78 *
79 */
80 virtual void init() = 0;
81 /**
82 * @brief release render plugin
83 *
84 */
85 virtual void release() = 0;
86 /**
87 * @brief register callback to plugin
88 *
89 * @param userData user data
90 * @param callback user callback function
91 */
92 virtual void setCallback(void *userData, PluginCallback *callback) = 0;
93 /**
94 * @brief open display from compositor
95 *
96 * @return 0 success,other value if failure
97 */
98 virtual int openDisplay() = 0;
99 /**
100 * @brief open window from compositor
101 *
102 * @return 0 success,other value if failure
103 */
104 virtual int openWindow() = 0;
105 /**
106 * @brief prepare RenderBuffer before displaying frame
107 *
108 * @param buffer video frame buffer
109 * @return 0 success,other value if failure
110 */
111 virtual int prepareFrame(RenderBuffer *buffer) = 0;
112 /**
113 * @brief sending a video frame to compositor
114 *
115 * @param buffer video frame buffer
116 * @param displayTime the frame render realtime
117 * @return 0 success,other value if failure
118 */
119 virtual int displayFrame(RenderBuffer *buffer, int64_t displayTime) = 0;
120 /**
121 * @brief flush buffers those obtained by plugin
122 *
123 * @return 0 success,other value if failure
124 */
125 virtual int flush() = 0;
126 /**
127 * @brief pause plugin
128 *
129 * @return 0 success,other value if failure
130 */
131 virtual int pause() = 0;
132 /**
133 * @brief resume plugin
134 *
135 * @return 0 success,other value if failure
136 */
137 virtual int resume() = 0;
138 /**
139 * @brief close display
140 *
141 * @return 0 success,other value if failure
142 */
143 virtual int closeDisplay() = 0;
144 /**
145 * @brief close window
146 *
147 * @return 0 success,other value if failure
148 */
149 virtual int closeWindow() = 0;
150 /**
151 * @brief get property from plugin
152 * the value must map the key type,the detail please see
153 * enum _PluginKey
154 *
155 * @param key property key
156 * @param value property value
157 * @return 0 success,other value if failure
158 */
159 virtual int getValue(PluginKey key, void *value) = 0;
160 /**
161 * @brief set property to plugin
162 * the value must map the key type,refer to PluginKey
163 *
164 * @param key property key
165 * @param value property value
166 * @return 0 success,other value if failure
167 */
168 virtual int setValue(PluginKey key, void *value) = 0;
169};
170#ifdef __cplusplus
171extern "C" {
172#endif
173
174/**
175 * make a render lib plugin instance
176 * @param id instance id
177 * @return the pointer to render lib plugin instance
178 */
179void *makePluginInstance(int id);
180
181/**
182 * destroy render lib plugin instance that created by makePluginInstance
183 * @param the handle point of video render plugin instance
184 */
185void destroyPluginInstance(void *);
186
187#ifdef __cplusplus
188}
189#endif
190
191#endif /*__RENDER_PLUGIN_H__*/