00001 #ifndef PLUGINCLIENT_H
00002 #define PLUGINCLIENT_H
00003
00004
00005
00006 #define BCASTDIR "~/.bcast/"
00007
00008 class PluginClient;
00009
00010
00011 #include "arraylist.h"
00012 #include "condition.h"
00013 #include "edlsession.inc"
00014 #include "keyframe.h"
00015 #include "mainprogress.inc"
00016 #include "maxbuffers.h"
00017 #include "plugincommands.h"
00018 #include "pluginserver.inc"
00019 #include "theme.inc"
00020 #include "vframe.h"
00021
00022
00023 extern "C"
00024 {
00025 extern PluginClient* new_plugin(PluginServer *server);
00026 }
00027
00028 class PluginClientAuto
00029 {
00030 public:
00031 float position;
00032 float intercept;
00033 float slope;
00034 };
00035
00036
00037
00038
00039
00040
00041 #define REGISTER_PLUGIN(class_title) \
00042 PluginClient* new_plugin(PluginServer *server) \
00043 { \
00044 return new class_title(server); \
00045 }
00046
00047
00048 #define WINDOW_CLOSE_EVENT(window_class) \
00049 int window_class::close_event() \
00050 { \
00051 \
00052 set_done(1); \
00053 return 1; \
00054 }
00055
00056
00057 #define PLUGIN_THREAD_HEADER(plugin_class, thread_class, window_class) \
00058 class thread_class : public Thread \
00059 { \
00060 public: \
00061 thread_class(plugin_class *plugin); \
00062 ~thread_class(); \
00063 void run(); \
00064 window_class *window; \
00065 plugin_class *plugin; \
00066 };
00067
00068
00069 #define PLUGIN_THREAD_OBJECT(plugin_class, thread_class, window_class) \
00070 thread_class::thread_class(plugin_class *plugin) \
00071 : Thread(0, 0, 1) \
00072 { \
00073 this->plugin = plugin; \
00074 } \
00075 \
00076 thread_class::~thread_class() \
00077 { \
00078 delete window; \
00079 } \
00080 \
00081 void thread_class::run() \
00082 { \
00083 BC_DisplayInfo info; \
00084 window = new window_class(plugin, \
00085 info.get_abs_cursor_x() - 75, \
00086 info.get_abs_cursor_y() - 65); \
00087 window->create_objects(); \
00088 \
00089 \
00090 plugin->thread = this; \
00091 int result = window->run_window(); \
00092 \
00093 if(result) plugin->client_side_close(); \
00094 }
00095
00096
00097
00098
00099 #define PLUGIN_CLASS_MEMBERS(config_name, thread_name) \
00100 int load_configuration(); \
00101 VFrame* new_picon(); \
00102 char* plugin_title(); \
00103 int show_gui(); \
00104 int set_string(); \
00105 void raise_window(); \
00106 BC_Hash *defaults; \
00107 config_name config; \
00108 thread_name *thread;
00109
00110 #define PLUGIN_CONSTRUCTOR_MACRO \
00111 thread = 0; \
00112 defaults = 0; \
00113 load_defaults(); \
00114
00115 #define PLUGIN_DESTRUCTOR_MACRO \
00116 if(thread) \
00117 { \
00118 \
00119 \
00120 \
00121 thread->window->lock_window("PLUGIN_DESTRUCTOR_MACRO"); \
00122 thread->window->set_done(0); \
00123 thread->window->unlock_window(); \
00124 thread->join(); \
00125 } \
00126 \
00127 \
00128 if(defaults) save_defaults(); \
00129 if(defaults) delete defaults;
00130
00131
00132
00133
00134 #define SHOW_GUI_MACRO(plugin_class, thread_class) \
00135 int plugin_class::show_gui() \
00136 { \
00137 load_configuration(); \
00138 thread_class *new_thread = new thread_class(this); \
00139 new_thread->start(); \
00140 return 0; \
00141 }
00142
00143 #define RAISE_WINDOW_MACRO(plugin_class) \
00144 void plugin_class::raise_window() \
00145 { \
00146 if(thread) \
00147 { \
00148 thread->window->lock_window(); \
00149 thread->window->raise_window(); \
00150 thread->window->flush(); \
00151 thread->window->unlock_window(); \
00152 } \
00153 }
00154
00155 #define SET_STRING_MACRO(plugin_class) \
00156 int plugin_class::set_string() \
00157 { \
00158 if(thread) \
00159 { \
00160 thread->window->lock_window(); \
00161 thread->window->set_title(gui_string); \
00162 thread->window->unlock_window(); \
00163 } \
00164 return 0; \
00165 }
00166
00167 #define NEW_PICON_MACRO(plugin_class) \
00168 VFrame* plugin_class::new_picon() \
00169 { \
00170 return new VFrame(picon_png); \
00171 }
00172
00173 #define LOAD_CONFIGURATION_MACRO(plugin_class, config_class) \
00174 int plugin_class::load_configuration() \
00175 { \
00176 KeyFrame *prev_keyframe, *next_keyframe; \
00177 prev_keyframe = get_prev_keyframe(get_source_position()); \
00178 next_keyframe = get_next_keyframe(get_source_position()); \
00179 \
00180 int64_t next_position = edl_to_local(next_keyframe->position); \
00181 int64_t prev_position = edl_to_local(prev_keyframe->position); \
00182 \
00183 config_class old_config, prev_config, next_config; \
00184 old_config.copy_from(config); \
00185 read_data(prev_keyframe); \
00186 prev_config.copy_from(config); \
00187 read_data(next_keyframe); \
00188 next_config.copy_from(config); \
00189 \
00190 config.interpolate(prev_config, \
00191 next_config, \
00192 (next_position == prev_position) ? \
00193 get_source_position() : \
00194 prev_position, \
00195 (next_position == prev_position) ? \
00196 get_source_position() + 1 : \
00197 next_position, \
00198 get_source_position()); \
00199 \
00200 if(!config.equivalent(old_config)) \
00201 return 1; \
00202 else \
00203 return 0; \
00204 }
00205
00206
00207
00208
00209
00210
00211 class PluginClient
00212 {
00213 public:
00214 PluginClient(PluginServer *server);
00215 virtual ~PluginClient();
00216
00217
00218
00219 virtual int is_realtime();
00220 virtual int is_audio();
00221 virtual int is_video();
00222 virtual int is_fileio();
00223 virtual int is_theme();
00224 virtual int uses_gui();
00225 virtual int is_multichannel();
00226 virtual int is_synthesis();
00227 virtual int is_transition();
00228 virtual char* plugin_title();
00229 virtual VFrame* new_picon();
00230 virtual Theme* new_theme();
00231
00232 Theme* get_theme();
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242 virtual int get_samplerate();
00243
00244
00245 virtual double get_framerate();
00246 virtual int delete_nonrealtime_parameters();
00247 virtual int start_plugin();
00248 virtual int get_parameters();
00249 virtual int64_t get_in_buffers(int64_t recommended_size);
00250 virtual int64_t get_out_buffers(int64_t recommended_size);
00251 virtual int start_loop();
00252 virtual int process_loop();
00253 virtual int stop_loop();
00254
00255
00256
00257
00258
00259
00260 virtual int set_string();
00261
00262 virtual int show_gui();
00263
00264 void client_side_close();
00265 void update_display_title();
00266
00267 virtual void raise_window() {};
00268 virtual void update_gui() {};
00269 virtual void save_data(KeyFrame *keyframe) {};
00270 virtual void read_data(KeyFrame *keyframe) {};
00271 int send_hide_gui();
00272
00273 int get_configure_change();
00274
00275
00276 virtual void plugin_render_gui(void *data) {};
00277 virtual void plugin_render_gui(void *data, int size) {};
00278 virtual int plugin_process_loop(VFrame **buffers, int64_t &write_length) { return 1; };
00279 virtual int plugin_process_loop(double **buffers, int64_t &write_length) { return 1; };
00280
00281 virtual int init_realtime_parameters();
00282
00283 virtual void render_stop() {};
00284 int get_gui_status();
00285 char* get_gui_string();
00286
00287
00288
00289 char* get_path();
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299 KeyFrame* get_prev_keyframe(int64_t position, int is_local = 1);
00300 KeyFrame* get_next_keyframe(int64_t position, int is_local = 1);
00301
00302 void get_camera(float *x, float *y, float *z, int64_t position);
00303 void get_projector(float *x, float *y, float *z, int64_t position);
00304
00305
00306
00307 int send_configure_change();
00308
00309
00310
00311
00312
00313 int gui_open();
00314
00315
00316
00317
00318
00319
00320
00321 int64_t get_total_len();
00322
00323
00324
00325 int64_t get_source_start();
00326
00327
00328
00329
00330 virtual int64_t local_to_edl(int64_t position);
00331
00332
00333 virtual int64_t edl_to_local(int64_t position);
00334
00335
00336
00337
00338
00339
00340 int64_t get_source_position();
00341
00342
00343 EDLSession* get_edlsession();
00344
00345
00346
00347 int get_direction();
00348
00349
00350
00351 int get_use_opengl();
00352
00353
00354 int get_total_buffers();
00355
00356
00357 int get_buffer_size();
00358
00359
00360 int get_interpolation_type();
00361
00362
00363 float get_red();
00364 float get_green();
00365 float get_blue();
00366
00367
00368
00369
00370 virtual int open_file() { return 0; };
00371 virtual int get_audio_parameters() { return 0; };
00372 virtual int get_video_parameters() { return 0; };
00373 virtual int check_header(char *path) { return 0; };
00374 virtual int open_file(char *path, int wr, int rd) { return 1; };
00375 virtual int close_file() { return 0; };
00376
00377
00378
00379
00380
00381
00382 virtual int load_defaults();
00383 virtual int save_defaults();
00384
00385
00386
00387
00388
00389 virtual int plugin_start_loop(int64_t start,
00390 int64_t end,
00391 int64_t buffer_size,
00392 int total_buffers);
00393 int plugin_stop_loop();
00394 int plugin_process_loop();
00395 MainProgressBar* start_progress(char *string, int64_t length);
00396
00397 int get_project_samplerate();
00398
00399 double get_project_framerate();
00400
00401 int get_project_smp();
00402 int get_aspect_ratio(float &aspect_w, float &aspect_h);
00403
00404
00405 int write_frames(int64_t total_frames);
00406 int write_samples(int64_t total_samples);
00407 virtual int plugin_get_parameters();
00408 char* get_defaultdir();
00409 void set_interactive();
00410
00411
00412 int reset();
00413 virtual int plugin_command_derived(int plugin_command) {};
00414 int plugin_get_range();
00415 int plugin_init_realtime(int realtime_priority,
00416 int total_in_buffers,
00417 int buffer_size);
00418
00419
00420
00421
00422 virtual int delete_buffer_ptrs();
00423
00424
00425
00426
00427
00428 int stop_gui_client();
00429 int save_data_client();
00430 int load_data_client();
00431 int set_string_client(char *string);
00432 int send_cancelled();
00433
00434
00435
00436
00437 ArrayList<int> double_buffers_in;
00438 ArrayList<int> double_buffers_out;
00439
00440
00441 ArrayList<int64_t> offset_in_render;
00442 ArrayList<int64_t> offset_out_render;
00443 ArrayList<int64_t> double_buffer_in_render;
00444 ArrayList<int64_t> double_buffer_out_render;
00445
00446 ArrayList<int64_t> realtime_in_size;
00447 ArrayList<int64_t> realtime_out_size;
00448
00449
00450
00451 ArrayList<PluginClientAuto> automation;
00452
00453
00454 char gui_string[BCTEXTLEN];
00455 int master_gui_on;
00456 int client_gui_on;
00457
00458 int show_initially;
00459
00460 int64_t start, end;
00461 int interactive;
00462 int success;
00463 int total_out_buffers;
00464 int total_in_buffers;
00465 int wr, rd;
00466
00467
00468
00469 int64_t out_buffer_size;
00470
00471 int64_t in_buffer_size;
00472
00473
00474
00475
00476
00477 int direction;
00478
00479
00480 int realtime_priority;
00481
00482
00483
00484 int64_t source_position;
00485
00486
00487 int64_t source_start;
00488
00489
00490 int64_t total_len;
00491
00492 int smp;
00493 PluginServer *server;
00494
00495 private:
00496
00497
00498
00499 };
00500
00501
00502 #endif