1 #ifndef __PLUGINFCLIENT_H__
2 #define __PLUGINFCLIENT_H__
6 #include "bclistboxitem.h"
8 #include "bcpopupmenu.h"
9 #include "bcmenuitem.h"
10 #include "bctextbox.h"
12 #include "pluginclient.h"
13 #include "pluginaclient.h"
14 #include "pluginvclient.h"
15 #include "pluginserver.h"
16 #include "pluginfclient.inc"
17 #include "preferences.inc"
20 #include "libavfilter/buffersrc.h"
21 #include "libavfilter/buffersink.h"
22 #include "libavformat/avformat.h"
23 #include "libavformat/avio.h"
24 #include "libavcodec/avcodec.h"
25 #include "libavfilter/avfilter.h"
26 #include "libavutil/avutil.h"
27 #include "libavutil/opt.h"
28 #include "libavutil/pixdesc.h"
29 #include "libswresample/swresample.h"
30 #include "libswscale/swscale.h"
33 class PluginFClient_OptName : public BC_ListBoxItem {
35 PluginFClient_Opt *opt;
37 PluginFClient_OptName(PluginFClient_Opt *opt);
40 class PluginFClient_OptValue : public BC_ListBoxItem {
42 PluginFClient_Opt *opt;
45 PluginFClient_OptValue(PluginFClient_Opt *opt);
48 class PluginFClient_Opt {
50 PluginFClientConfig *conf;
52 PluginFClient_OptName *item_name;
53 PluginFClient_OptValue *item_value;
55 char *get(char *vp, int sz=-1);
56 void set(const char *val);
58 int scalar(double d, char *rp);
60 int units(ArrayList<const AVOption *> &opts);
62 int get_range(float &fmn, float &fmx);
64 void set_float(float v);
67 void *filter_config();
68 const AVClass *filter_class();
70 PluginFClient_Opt(PluginFClientConfig *conf, const AVOption *opt);
75 PluginFFilter(PluginFFilter &that) {} //disable assign/copy
77 const AVFilter *filter;
79 AVFilterContext *fctx;
81 void *filter_config() { return fctx->priv; }
82 const AVClass *filter_class() { return filter->priv_class; }
83 const char *description() { return filter->description; }
85 int init(const char *name, PluginFClientConfig *conf);
87 static PluginFFilter *new_ffilter(const char *name, PluginFClientConfig *conf=0);
89 PluginClient* new_plugin(PluginServer*);
90 const char *filter_name() { return filter->name; }
98 class PluginFClientConfig : public ArrayList<PluginFClient_Opt *>
101 PluginFFilter *ffilt;
102 void *filter_config() { return ffilt->filter_config(); }
103 const AVClass *filter_class() { return ffilt->filter_class(); }
104 PluginFClient_Opt *get(int i) { return ArrayList<PluginFClient_Opt *>::get(i); }
106 const char *get(const char *name);
107 void set(const char *name, const char *val);
108 void copy_from(PluginFClientConfig &that);
109 int equivalent(PluginFClientConfig &that);
110 void interpolate(PluginFClientConfig &prev, PluginFClientConfig &next,
111 int64_t prev_frame, int64_t next_frame, int64_t current_frame);
112 void initialize(const char *name);
114 void dump(FILE *fp=stdout);
116 PluginFClientConfig();
117 ~PluginFClientConfig();
121 class PluginFClient_OptPanel : public BC_ListBox {
123 PluginFClient_OptPanel(PluginFClientWindow *fwin, int x, int y, int w, int h);
124 ~PluginFClient_OptPanel();
125 void create_objects();
126 int cursor_leave_event();
128 PluginFClientWindow *fwin;
129 ArrayList<BC_ListBoxItem*> items[2];
130 ArrayList<BC_ListBoxItem*> &opts;
131 ArrayList<BC_ListBoxItem*> &vals;
133 int selection_changed();
137 class PluginFClientReset : public BC_GenericButton {
139 PluginFClientWindow *fwin;
141 PluginFClientReset(PluginFClientWindow *fwin, int x, int y);
142 ~PluginFClientReset();
146 class PluginFClientUnits : public BC_PopupMenu {
148 PluginFClientWindow *fwin;
150 PluginFClientUnits(PluginFClientWindow *fwin, int x, int y, int w);
151 ~PluginFClientUnits();
155 class PluginFClientText : public BC_TextBox {
157 PluginFClientWindow *fwin;
159 PluginFClientText(PluginFClientWindow *fwin, int x, int y, int w);
160 ~PluginFClientText();
164 class PluginFClientApply : public BC_GenericButton {
166 PluginFClientWindow *fwin;
168 PluginFClientApply(PluginFClientWindow *fwin, int x, int y);
169 ~PluginFClientApply();
173 class PluginFClientPot : public BC_FPot
176 PluginFClientPot(PluginFClientWindow *fwin, int x, int y);
178 PluginFClientWindow *fwin;
181 class PluginFClientSlider : public BC_FSlider
184 PluginFClientSlider(PluginFClientWindow *fwin, int x, int y);
186 PluginFClientWindow *fwin;
189 class PluginFClientWindow : public PluginClientWindow
192 PluginFClientWindow(PluginFClient *ffmpeg);
193 ~PluginFClientWindow();
195 void create_objects();
196 void update(PluginFClient_Opt *oip);
198 void update_selected();
200 int resize_event(int w, int h);
202 PluginFClient *ffmpeg;
203 PluginFClient_OptPanel *panel;
204 int panel_x, panel_y, panel_w, panel_h;
205 BC_Title *type, *range;
206 PluginFClient_Opt *selected;
208 PluginFClientReset *reset;
209 PluginFClientUnits *units;
210 PluginFClientText *text;
211 PluginFClientApply *apply;
212 PluginFClientPot *pot;
213 PluginFClientSlider *slider;
216 class PluginFLogLevel {
219 PluginFLogLevel(int lvl) {
220 level = av_log_get_level();
221 if( level > lvl ) av_log_set_level(lvl);
223 ~PluginFLogLevel() { av_log_set_level(level); }
226 class PluginFClient {
229 PluginClient *plugin;
230 PluginFFilter *ffilt;
231 AVFilterContext *fsrc, *fsink;
232 int64_t plugin_position, filter_position;
234 char title[BCSTRLEN];
236 PluginFClient(PluginClient *plugin, const char *name);
238 static bool is_audio(const AVFilter *fp);
239 static bool is_video(const AVFilter *fp);
241 int64_t get_source_position() {
242 return plugin->get_source_position();
244 KeyFrame* get_prev_keyframe(int64_t position, int is_local=1) {
245 return plugin->get_prev_keyframe(position, is_local);
247 KeyFrame* get_next_keyframe(int64_t position, int is_local=1) {
248 return plugin->get_next_keyframe(position, is_local);
250 int64_t edl_to_local(int64_t position) {
251 return plugin->edl_to_local(position);
255 char *to_upper(char *bp, const char *sp);
256 void save_data(KeyFrame *keyframe);
257 void read_data(KeyFrame *keyframe);
258 void render_gui(void *data, int size);
262 PluginFClientConfig curr_config;
263 PLUGIN_CLASS_MEMBERS(PluginFClientConfig)
266 class PluginFAClient : public PluginAClient, public PluginFClient
269 PluginFAClient(PluginServer *server, const char *name);
271 const char *plugin_title() { return PluginFClient::plugin_title(); }
272 PluginClientWindow *new_window() { return PluginFClient::new_window(); }
275 int load_configuration() { return PluginFClient::load_configuration(); }
276 void save_data(KeyFrame *keyframe) { PluginFClient::save_data(keyframe); }
277 void read_data(KeyFrame *keyframe) { PluginFClient::read_data(keyframe); }
278 void update_gui() { PluginFClient::update_gui(); }
279 void render_gui(void *data, int size) { PluginFClient::render_gui(data, size); }
281 int is_realtime() { return 1; }
282 int is_multichannel() { return 1; }
283 int uses_gui() { return 1; }
284 int is_synthesis() { return 1; }
285 int get_inchannels();
286 int get_outchannels();
287 int process_buffer(int64_t size, Samples **buffer, int64_t start_position, int sample_rate);
290 class PluginFVClient : public PluginVClient, public PluginFClient, public FFVideoConvert
293 PluginFVClient(PluginServer *server, const char *name);
295 const char *plugin_title() { return PluginFClient::plugin_title(); }
296 PluginClientWindow *new_window() { return PluginFClient::new_window(); }
297 int activate(int width, int height, int color_model);
299 int load_configuration() { return PluginFClient::load_configuration(); }
300 void save_data(KeyFrame *keyframe) { PluginFClient::save_data(keyframe); }
301 void read_data(KeyFrame *keyframe) { PluginFClient::read_data(keyframe); }
302 void update_gui() { PluginFClient::update_gui(); }
303 void render_gui(void *data, int size) { PluginFClient::render_gui(data, size); }
305 int is_realtime() { return 1; }
306 int is_multichannel() { return 1; }
307 int uses_gui() { return 1; }
308 int is_synthesis() { return 1; }
309 int process_buffer(VFrame **frames, int64_t start_position, double frame_rate);