LiVES 1.3.11-svn
src/plugins.h
Go to the documentation of this file.
00001 // plugins.h
00002 // LiVES
00003 // (c) G. Finch 2003-2010 <salsaman@xs4all.nl>
00004 // released under the GNU GPL 3 or later
00005 // see file ../COPYING or www.gnu.org for licensing details
00006 
00007 #ifndef _HAS_PLUGINS_H
00008 #define _HAS_PLUGINS_H
00009 
00010 #include <gmodule.h>
00011 #include <unistd.h>
00012 #include <string.h>
00013 #include <fcntl.h>
00014 #include <stdlib.h>
00015 
00016 
00017 // generic plugins
00018 
00019 GList *get_plugin_list (const gchar *plugin_type, gboolean allow_nonex, const gchar *plugdir, const gchar *filter_ext);
00020 #define PLUGIN_ENCODERS "encoders"
00021 #define PLUGIN_DECODERS "decoders"
00022 #define PLUGIN_VID_PLAYBACK "playback/video"
00023 #define PLUGIN_AUDIO_STREAM "playback/audiostream"
00024 
00026 #define PLUGIN_THEMES "themes"
00027 
00029 #define PLUGIN_EFFECTS_WEED "weed"
00030 #define PLUGIN_WEED_FX_BUILTIN "effects/realtime/weed"
00031 
00032 
00033 GList *plugin_request (const gchar *plugin_type, const gchar *plugin_name, const gchar *request);
00034 GList *plugin_request_with_blanks (const gchar *plugin_type, const gchar *plugin_name, const gchar *request);
00035 GList *plugin_request_by_line (const gchar *plugin_type, const gchar *plugin_name, const gchar *request);
00036 GList *plugin_request_by_space (const gchar *plugin_type, const gchar *plugin_name, const gchar *request);
00037 GList *plugin_request_common (const gchar *plugin_type, const gchar *plugin_name, const gchar *request, const gchar *delim, gboolean allow_blanks);
00038 
00039 
00041 typedef gboolean (*plugin_keyfunc) (gboolean down, guint16 unicode, guint16 keymod);
00042 
00043 typedef struct {
00044   // playback
00045   gchar name[64];
00046   void *handle;
00047 
00048   // mandatory
00049   const char *(*module_check_init)(void);
00050   const char *(*version) (void);
00051   const char *(*get_description) (void);
00052   const char *(*get_rfx) (void);
00053   gint *(*get_palette_list) (void);
00054   gboolean (*set_palette) (int palette);
00055   guint64 (*get_capabilities) (int palette);
00056   gboolean (*render_frame) (int hsize, int vsize, int64_t timecode, void *pixel_data, void *return_data);
00057 
00058   // optional
00059   gboolean (*init_screen) (int width, int height, gboolean fullscreen, guint32 window_id, int argc, gchar **argv);
00060   void (*exit_screen) (guint16 mouse_x, guint16 mouse_y);
00061   void (*module_unload) (void);
00062   const gchar *(*get_fps_list) (int palette);
00063   gboolean (*set_fps) (gdouble fps);
00064 
00065   // only for display plugins
00066   gboolean (*send_keycodes) (plugin_keyfunc);
00067 
00068   // optional for YUV palettes
00069   int *(*get_yuv_palette_sampling) (int palette);
00070   int *(*get_yuv_palette_clamping) (int palette);
00071   int *(*get_yuv_palette_subspace) (int palette);
00072   int (*set_yuv_palette_sampling) (int palette);
00073   int (*set_yuv_palette_clamping) (int palette);
00074   int (*set_yuv_palette_subspace) (int palette);
00075 
00076   // audio streaming
00077   int *(*get_audio_fmts)(void);
00078 
00079   guint32 audio_codec;
00080   // must match with the "acodec" GList in interface.c
00081   // and bitmaps in the encder plugins, with this one addition:
00082 
00083   guint64 capabilities;
00084 
00085 #define VPP_CAN_RESIZE    1<<0
00086 #define VPP_CAN_RETURN    1<<1
00087 #define VPP_LOCAL_DISPLAY 1<<2
00088 
00089   gint fwidth,fheight;
00090 
00091   int palette;
00092   int YUV_sampling;
00093   int YUV_clamping;
00094   int YUV_subspace;
00095 
00096   gint fixed_fps_numer;
00097   gint fixed_fps_denom;
00098   gdouble fixed_fpsd;
00099 
00100   int extra_argc;
00101   gchar **extra_argv;
00102 
00103 
00104 } _vid_playback_plugin;
00105 
00106 
00107 #define DEF_VPP_HSIZE 320.
00108 #define DEF_VPP_VSIZE 240.
00109 
00110 _vid_playback_plugin *open_vid_playback_plugin (const gchar *name, gboolean using);
00111 void vid_playback_plugin_exit (void);
00112 void close_vid_playback_plugin(_vid_playback_plugin *);
00113 gint64 get_best_audio(_vid_playback_plugin *);
00114 void save_vpp_defaults(_vid_playback_plugin *, gchar *file);
00115 void load_vpp_defaults(_vid_playback_plugin *, gchar *file);
00116 
00117 
00118 // encoder plugins
00119 
00120 void do_plugin_encoder_error(const gchar *plugin_name_or_null);
00121 
00122 GList *filter_encoders_by_img_ext(GList *encoders, const gchar *img_ext);
00123 
00124 typedef struct {
00125   gchar name[51];
00126   guint32 audio_codec;
00127   // must match with the "acodec" GList in interface.c
00128   // and bitmaps in the encoder plugins
00129 
00130 #define AUDIO_CODEC_MP3 0
00131 #define AUDIO_CODEC_PCM 1
00132 #define AUDIO_CODEC_MP2 2
00133 #define AUDIO_CODEC_VORBIS 3
00134 #define AUDIO_CODEC_AC3 4
00135 #define AUDIO_CODEC_AAC 5
00136 #define AUDIO_CODEC_AMR_NB 6
00137 #define AUDIO_CODEC_RAW 7
00138 
00139 #define AUDIO_CODEC_MAX 31
00140   //
00141 #define AUDIO_CODEC_NONE 32
00142 #define AUDIO_CODEC_UNKNOWN 33
00143 
00144   guint capabilities;
00145 
00146 
00147 #define HAS_RFX 1<<0
00148 
00149 #define CAN_ENCODE_PNG 1<<2
00150 #define ENCODER_NON_NATIVE 1<<3
00151 
00152   // current output format
00153   gchar of_name[51];
00154   gchar of_desc[128];
00155   gint of_allowed_acodecs;
00156   gchar of_restrict[1024];
00157   gchar of_def_ext[16];
00158 }
00159 _encoder;
00160 
00161 
00162 extern const char *anames[AUDIO_CODEC_MAX];
00163 
00164 
00165 // decoder plugins
00166 
00167 // seek_flags is a bitmap
00168 
00170 #define LIVES_SEEK_FAST (1<<0)
00171 
00173 #define LIVES_SEEK_NEEDS_CALCULATION (1<<1)
00174 #define LIVES_SEEK_QUALITY_LOSS (1<<2)
00175 
00176 
00177 typedef struct {
00178   gchar *URI; 
00179 
00180   gint nclips; 
00181   gchar container_name[512]; 
00182 
00184   gint current_clip; 
00185 
00186   // video data
00187   gint width;
00188   gint height;
00189   gint64 nframes;
00190   lives_interlace_t interlace;
00191 
00194   gint offs_x;
00195   gint offs_y;
00196   gint frame_width;
00197   gint frame_height;
00198 
00199   gfloat par; 
00200 
00201   gfloat fps;
00202 
00203   int *palettes;
00204 
00206   int current_palette;  
00207   
00208   int YUV_sampling;
00209   int YUV_clamping;
00210   int YUV_subspace;
00211   gchar video_name[512]; 
00212 
00213   /* audio data */
00214   gint arate;
00215   gint achans;
00216   gint asamps;
00217   gboolean asigned;
00218   gboolean ainterleaf;
00219   gchar audio_name[512]; 
00220 
00221   int seek_flag;
00222 
00223   void *priv; 
00224 
00225 } lives_clip_data_t;
00226 
00227 
00228 
00229 typedef struct {
00230   // playback
00231   gchar *name; 
00232   void *handle; 
00233 
00234   // mandatory
00235   const char *(*version) (void);
00236 
00243   lives_clip_data_t *(*get_clip_data)(char *URI, lives_clip_data_t *cdata);
00244 
00246   gboolean (*get_frame)(const lives_clip_data_t *, int64_t frame, void **pixel_data);
00247 
00249   void (*clip_data_free)(lives_clip_data_t *);
00250 
00251   // optional
00252   const char *(*module_check_init)(void);
00253   int64_t (*rip_audio) (const lives_clip_data_t *, const char *fname, int64_t stframe, int64_t nframes, 
00254                         unsigned char **abuff);
00255   void (*rip_audio_cleanup) (const lives_clip_data_t *cdata);
00256   void (*module_unload)(void);
00257 
00258 } lives_decoder_sys_t;
00259 
00260 
00261 
00262 
00263 typedef struct {
00264   const lives_decoder_sys_t *decoder;
00265   lives_clip_data_t *cdata;
00266 } lives_decoder_t;
00267 
00268 
00269 
00270 
00271 
00272 
00273 const lives_clip_data_t *get_decoder_cdata(file *);
00274 void close_decoder_plugin (lives_decoder_t *);
00275 lives_decoder_sys_t *open_decoder_plugin(const gchar *plname);
00276 void get_mime_type(gchar *text, int maxlen, const lives_clip_data_t *);
00277 void unload_decoder_plugins(void);
00278 
00279 LIVES_INLINE gboolean decplugin_supports_palette (const lives_decoder_t *dplug, int palette);
00280 
00281 
00282 
00283 // RFX plugins
00284 
00285 
00287 #define PLUGIN_RENDERED_EFFECTS_BUILTIN "effects/rendered/"
00288 
00290 #define PLUGIN_RENDERED_EFFECTS_CUSTOM "plugins/effects/rendered/custom/"
00291 #define PLUGIN_RENDERED_EFFECTS_TEST "plugins/effects/rendered/test/"
00292 
00294 #define PLUGIN_RENDERED_EFFECTS_BUILTIN_SCRIPTS "effects/RFXscripts/"
00295 
00297 #define PLUGIN_RENDERED_EFFECTS_CUSTOM_SCRIPTS "plugins/effects/RFXscripts/custom/"
00298 #define PLUGIN_RENDERED_EFFECTS_TEST_SCRIPTS "plugins/effects/RFXscripts/test/"
00299 
00301 #define PLUGIN_RFX_SCRAP ""
00302 
00303 
00305 #define MAX_PARAM_WIDGETS 5
00306 
00308 #define RFX_MAXSTRINGLEN 1024
00309 
00310 
00311 typedef enum {
00312 
00313   LIVES_PARAM_UNKNOWN=0,
00314   LIVES_PARAM_NUM,
00315   LIVES_PARAM_BOOL,
00316   LIVES_PARAM_COLRGB24,
00317   LIVES_PARAM_STRING,
00318   LIVES_PARAM_STRING_LIST,
00319   LIVES_PARAM_COLRGBA32,
00320 
00321   LIVES_PARAM_UNDISPLAYABLE=65536
00322   
00323 } lives_param_type_t;
00324 
00325 
00326 typedef enum {
00327   LIVES_RFX_SOURCE_RFX=0,
00328   LIVES_RFX_SOURCE_WEED
00329 } lives_rfx_source_t;
00330 
00331 
00332 
00333 
00334 
00335 typedef struct {
00336   // weed style part
00337   gchar *name;
00338   gchar *desc;
00339 
00340   gchar *label;
00341   gint flags;
00342   gboolean use_mnemonic;
00343   gpointer interp_func;
00344   gpointer display_func;
00345   gint hidden;
00346 
00347   // reason(s) for hiding [bitmap]
00348 #define HIDDEN_GUI (1<<0)
00349 #define HIDDEN_MULTI (1<<1)
00350 #define HIDDEN_NEEDS_REINIT (1<<2)
00351 
00352   gdouble step_size;
00353   gint copy_to;
00354   gboolean transition;
00355   gboolean reinit;
00356 
00357   gboolean wrap;
00358   gint group;
00359   lives_param_type_t type;
00360 
00361   gint dp;  
00362   void *value;  
00363 
00364   gdouble min;
00365   gdouble max; 
00366 
00367   void *def; 
00368   GList *list; 
00369 
00371   gshort multi;
00372 #define PVAL_MULTI_NONE 0
00373 #define PVAL_MULTI_ANY 1
00374 #define PVAL_MULTI_PER_CHANNEL 2
00375 
00376   //--------------------------------------------------
00377   // extras for LiVES
00378 
00380   GtkWidget *widgets[MAX_PARAM_WIDGETS]; 
00381   gboolean onchange; 
00382 
00383   gboolean changed;
00384 
00385   gboolean change_blocked;
00386 
00387   void *source;
00388 
00389   lives_rfx_source_t source_type;
00390 
00391 } lives_param_t;
00392 
00393 
00394 typedef enum {
00395   RFX_STATUS_BUILTIN=0, 
00396   RFX_STATUS_CUSTOM=1, 
00397   RFX_STATUS_TEST=2, 
00398   RFX_STATUS_ANY=3, 
00399   RFX_STATUS_WEED=4, 
00400   RFX_STATUS_SCRAP=5, 
00401 
00402   // these are only used when prompting for a name
00403   RFX_STATUS_COPY=128, 
00404   RFX_STATUS_RENAME=129 
00405 } lives_rfx_status_t;
00406 
00407 
00408 
00409 
00410 typedef struct {
00411   gchar *name;  
00412   gchar *menu_text; 
00413   gchar *action_desc; 
00414   gint min_frames; 
00415   gint num_in_channels;
00416   lives_rfx_status_t status;
00417 
00418 
00419   guint32 props;
00420 #define RFX_PROPS_SLOW        0x0001  ///< hint to GUI
00421 #define RFX_PROPS_MAY_RESIZE  0x0002 ///< is a tool
00422 #define RFX_PROPS_BATCHG      0x0004 ///< is a batch generator
00423 
00424 
00425 #define RFX_PROPS_RESERVED1   0x1000
00426 #define RFX_PROPS_RESERVED2   0x2000
00427 #define RFX_PROPS_RESERVED3   0x4000
00428 #define RFX_PROPS_AUTO_BUILT  0x8000
00429 
00430   GtkWidget *menuitem;  
00431   gint num_params;
00432   lives_param_t *params;
00433   lives_rfx_source_t source_type;
00434   void *source;  
00435   void *extra;  
00436   gchar delim[2];
00437   gboolean is_template;
00438 
00439 } lives_rfx_t;
00440 
00441 gboolean check_rfx_for_lives (lives_rfx_t *);
00442 
00443 void do_rfx_cleanup(lives_rfx_t *);
00444 
00445 void render_fx_get_params (lives_rfx_t *, const gchar *plugin_name, gshort status);
00446 
00447 void sort_rfx_array (lives_rfx_t *in_array, gint num_elements);
00448 
00449 gint find_rfx_plugin_by_name (const gchar *name, gshort status);
00450 
00451 void rfx_copy (lives_rfx_t *src, lives_rfx_t *dest, gboolean full);
00452 
00453 void rfx_free(lives_rfx_t *rfx);
00454 
00455 void rfx_free_all (void);
00456 
00457 void param_copy (lives_param_t *src, lives_param_t *dest, gboolean full);
00458 
00459 
00460 typedef struct {
00461   GList *list; 
00462   gint delegate; 
00463   gulong func; 
00464   lives_rfx_t *rfx; 
00465 } lives_fx_candidate_t;
00466 
00467 // filter types which can have candidates
00468 #define FX_CANDIDATE_AUDIO_VOL 0
00469 #define FX_CANDIDATE_RESIZER 1
00470 #define FX_CANDIDATE_DEINTERLACE 2
00471 
00472 #define MAX_FX_CANDIDATE_TYPES 3
00473 
00474 gboolean get_bool_param(void *value);
00475 gint get_int_param(void *value);
00476 gdouble get_double_param(void *value);
00477 void get_colRGB24_param(void *value, lives_colRGB24_t *rgb);
00478 void get_colRGBA32_param(void *value, lives_colRGBA32_t *rgba);
00479 
00480 void set_bool_param(void *value, gboolean );
00481 void set_int_param(void *value, gint );
00482 void set_double_param(void *value, gdouble );
00483 void set_colRGB24_param(void *value, gshort red, gshort green, gshort blue);
00484 void set_colRGBA32_param(void *value, gshort red, gshort green, gshort blue, gshort alpha);
00485 
00487 void **store_rfx_params (lives_rfx_t *);
00488 void set_rfx_params_from_store (lives_rfx_t *rfx, void **store);
00489 void rfx_params_store_free (lives_rfx_t *, void **store);
00490 
00491 GList *array_to_string_list (gchar **array, gint offset, gint len);
00492 
00493 lives_rfx_t *weed_to_rfx (weed_plant_t *plant, gboolean show_reinits);
00494 
00495 gchar *plugin_run_param_window(const gchar *get_com, GtkVBox *vbox, lives_rfx_t **ret_rfx);
00496 
00499 typedef struct {
00500   _vid_playback_plugin *plugin;
00501   GtkWidget *dialog;
00502   GtkWidget *spinbuttonh;
00503   GtkWidget *spinbuttonw;
00504   GtkWidget *fps_entry;
00505   GtkWidget *pal_entry;
00506   lives_rfx_t *rfx;
00507 } _vppaw;
00508 
00509 _vppaw *on_vpp_advanced_clicked (GtkButton *, gpointer);
00510 
00511 
00513 
00514 #endif
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines