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);
63 void *filter_config();
64 const AVClass *filter_class();
66 PluginFClient_Opt(PluginFClientConfig *conf, const AVOption *opt);
71 PluginFFilter(PluginFFilter &that) {} //disable assign/copy
75 AVFilterContext *fctx;
77 void *filter_config() { return fctx->priv; }
78 const AVClass *filter_class() { return filter->priv_class; }
79 const char *description() { return filter->description; }
81 int init(const char *name, PluginFClientConfig *conf);
83 static PluginFFilter *new_ffilter(const char *name, PluginFClientConfig *conf=0);
85 PluginClient* new_plugin(PluginServer*);
86 const char *filter_name() { return filter->name; }
94 class PluginFClientConfig : public ArrayList<PluginFClient_Opt *>
98 void *filter_config() { return ffilt->filter_config(); }
99 const AVClass *filter_class() { return ffilt->filter_class(); }
100 PluginFClient_Opt *get(int i) { return ArrayList<PluginFClient_Opt *>::get(i); }
102 const char *get(const char *name);
103 void set(const char *name, const char *val);
104 void copy_from(PluginFClientConfig &that);
105 int equivalent(PluginFClientConfig &that);
106 void interpolate(PluginFClientConfig &prev, PluginFClientConfig &next,
107 int64_t prev_frame, int64_t next_frame, int64_t current_frame);
108 void initialize(const char *name);
110 void dump(FILE *fp=stdout);
112 PluginFClientConfig();
113 ~PluginFClientConfig();
117 class PluginFClient_OptPanel : public BC_ListBox {
119 PluginFClient_OptPanel(PluginFClientWindow *fwin, int x, int y, int w, int h);
120 ~PluginFClient_OptPanel();
121 void create_objects();
122 int cursor_leave_event();
124 PluginFClientWindow *fwin;
125 ArrayList<BC_ListBoxItem*> items[2];
126 ArrayList<BC_ListBoxItem*> &opts;
127 ArrayList<BC_ListBoxItem*> &vals;
129 int selection_changed();
133 class PluginFClientReset : public BC_GenericButton {
135 PluginFClientWindow *fwin;
137 PluginFClientReset(PluginFClientWindow *fwin, int x, int y);
138 ~PluginFClientReset();
142 class PluginFClientUnits : public BC_PopupMenu {
144 PluginFClientWindow *fwin;
146 PluginFClientUnits(PluginFClientWindow *fwin, int x, int y, int w);
147 ~PluginFClientUnits();
151 class PluginFClientText : public BC_TextBox {
153 PluginFClientWindow *fwin;
155 PluginFClientText(PluginFClientWindow *fwin, int x, int y, int w);
156 ~PluginFClientText();
160 class PluginFClientApply : public BC_GenericButton {
162 PluginFClientWindow *fwin;
164 PluginFClientApply(PluginFClientWindow *fwin, int x, int y);
165 ~PluginFClientApply();
169 class PluginFClientWindow : public PluginClientWindow
172 PluginFClientWindow(PluginFClient *ffmpeg);
173 ~PluginFClientWindow();
175 void create_objects();
176 void update(PluginFClient_Opt *oip);
178 int resize_event(int w, int h);
180 PluginFClient *ffmpeg;
181 PluginFClient_OptPanel *panel;
182 int panel_x, panel_y, panel_w, panel_h;
183 BC_Title *type, *range;
184 PluginFClient_Opt *selected;
186 PluginFClientReset *reset;
187 PluginFClientUnits *units;
188 PluginFClientText *text;
189 PluginFClientApply *apply;
192 class PluginFLogLevel {
195 PluginFLogLevel(int lvl) {
196 level = av_log_get_level();
197 if( level > lvl ) av_log_set_level(lvl);
199 ~PluginFLogLevel() { av_log_set_level(level); }
202 class PluginFClient {
205 PluginClient *plugin;
206 PluginFFilter *ffilt;
207 AVFilterContext *fsrc, *fsink;
208 int64_t plugin_position, filter_position;
210 char title[BCSTRLEN];
212 PluginFClient(PluginClient *plugin, const char *name);
214 static bool is_audio(AVFilter *fp);
215 static bool is_video(AVFilter *fp);
217 int64_t get_source_position() {
218 return plugin->get_source_position();
220 KeyFrame* get_prev_keyframe(int64_t position, int is_local=1) {
221 return plugin->get_prev_keyframe(position, is_local);
223 KeyFrame* get_next_keyframe(int64_t position, int is_local=1) {
224 return plugin->get_next_keyframe(position, is_local);
226 int64_t edl_to_local(int64_t position) {
227 return plugin->edl_to_local(position);
231 char *to_upper(char *bp, const char *sp);
232 void save_data(KeyFrame *keyframe);
233 void read_data(KeyFrame *keyframe);
234 void render_gui(void *data, int size);
238 PluginFClientConfig curr_config;
239 PLUGIN_CLASS_MEMBERS(PluginFClientConfig)
242 class PluginFAClient : public PluginAClient, public PluginFClient
245 PluginFAClient(PluginServer *server, const char *name);
247 const char *plugin_title() { return PluginFClient::plugin_title(); }
248 PluginClientWindow *new_window() { return PluginFClient::new_window(); }
251 int load_configuration() { return PluginFClient::load_configuration(); }
252 void save_data(KeyFrame *keyframe) { PluginFClient::save_data(keyframe); }
253 void read_data(KeyFrame *keyframe) { PluginFClient::read_data(keyframe); }
254 void update_gui() { PluginFClient::update_gui(); }
255 void render_gui(void *data, int size) { PluginFClient::render_gui(data, size); }
257 int is_realtime() { return 1; }
258 int is_multichannel() { return 1; }
259 int uses_gui() { return 1; }
260 int is_synthesis() { return 1; }
261 int get_inchannels();
262 int get_outchannels();
263 int process_buffer(int64_t size, Samples **buffer, int64_t start_position, int sample_rate);
266 class PluginFVClient : public PluginVClient, public PluginFClient, public FFVideoConvert
269 PluginFVClient(PluginServer *server, const char *name);
271 const char *plugin_title() { return PluginFClient::plugin_title(); }
272 PluginClientWindow *new_window() { return PluginFClient::new_window(); }
273 int activate(int width, int height, int color_model);
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 process_buffer(VFrame **frames, int64_t start_position, double frame_rate);