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