LiVES  1.6.4-svn
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
main.h
Go to the documentation of this file.
1 // main.h
2 // LiVES
3 // (c) G. Finch (salsaman@xs4all.nl,salsaman@gmail.com) 2003 - 2012
4 // see file ../COPYING for full licensing details
5 
6 /* This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License version 3 or higher as
8  published by the Free Software Foundation.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  agint64 with this program; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 */
19 
20 
21 // begin legal warning
22 /*
23  NO WARRANTY
24 
25  BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
26  FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
27 OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
28  PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
29  OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
30 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
31 TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
32  PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
33 REPAIR OR CORRECTION.
34 
35  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
36  WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
37  REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
38  INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
39  OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
40 TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
41 YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
42  PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
43 POSSIBILITY OF SUCH DAMAGES.
44 */
45 // end legal warning
46 
47 
48 // Have fun, and let's fight for Free Speech, Open Media and True Creativity !
49 // - Salsaman
50 
51 #ifndef HAS_LIVES_MAIN_H
52 #define HAS_LIVES_MAIN_H
53 
54 #define GUI_GTK
55 
56 #ifdef GUI_GTK
57 
58 #include <gtk/gtk.h>
59 #include <gdk/gdkkeysyms.h>
60 
61 #ifdef IS_MINGW
62 
63 #undef GDK_WINDOWING_X11
64 #ifndef WINVER
65 #define WINVER 0x0500
66 #endif
67 
68 #include <windows.h>
69 #include <winbase.h>
70 #include <tlhelp32.h>
71 #include <sddl.h>
72 #include <sys/stat.h>
73 
74 #define O_SYNC (FILE_FLAG_NO_BUFFERING|FILE_FLAG_WRITE_THROUGH)
75 
76 typedef PROCESS_INFORMATION * lives_pid_t;
77 typedef PROCESS_INFORMATION * lives_pgid_t;
78 
79 #include <gdk/gdkwin32.h>
80 
81 #else
82 
83 typedef pid_t lives_pid_t;
84 typedef int lives_pgid_t;
85 
86 #endif
87 
88 
89 #ifdef GDK_WINDOWING_X11
90 #define USE_X11
91 
92 // needed for GDK_WINDOW_XID - for fileselector preview
93 // needed for gdk_x11_screen_get_window_manager_name()
94 
95 #include <gdk/gdkx.h>
96 #endif
97 
98 #endif // GUI_GTK
99 
100 #include <stdlib.h>
101 #include <stdio.h>
102 #include <unistd.h>
103 #include <string.h>
104 #include <signal.h>
105 #include <assert.h>
106 #include <errno.h>
107 
108 #define __STDC_CONSTANT_MACROS
109 #include <stdint.h>
110 
111 
112 #define QUOTEME(x) #x
113 
114 
116 #define MAX_FILES 65535
117 
120 #ifndef PREFIX_DEFAULT
121 #ifndef IS_MINGW
122 #define PREFIX_DEFAULT "/usr"
123 #else
124 // TODO - get this from the installer
125 #define PREFIX_DEFAULT "C:\\Program Files\\LiVES"
126 #endif
127 #endif
128 
130 #ifndef PREFIX
131 #define PREFIX PREFIX_DEFAULT
132 #endif
133 
134 
135 
136 #ifndef IS_MINGW
137 #define DOC_DIR "/share/doc/lives-"
138 
139 #define THEME_DIR "/share/lives/themes/"
140 #define PLUGIN_SCRIPTS_DIR "/share/lives/plugins/"
141 #define PLUGIN_EXEC_DIR "/lives/plugins/"
142 #define ICON_DIR "/share/lives/icons/"
143 #define DATA_DIR "/share/lives/"
144 #define LIVES_CONFIG_DIR ".lives-dir/"
145 #define LIVES_TMP_NAME "livestmp"
146 
147 #else // IS_MINGW
148 #define DOC_DIR "\\Documents/"
149 
150 #define THEME_DIR "\\Themes/"
151 #define PLUGIN_SCRIPTS_DIR "\\Plugins/"
152 #define PLUGIN_EXEC_DIR "\\Plugins/"
153 #define ICON_DIR "\\Icons/"
154 #define DATA_DIR "\\Data/"
155 #define LIVES_CONFIG_DIR "\\Config/"
156 #define LIVES_TMP_NAME "livescache"
157 #endif
158 
159 #define LIVES_DEVICE_DIR "/dev/"
160 
161 
162 #define LIVES_MANUAL_URL "http://lives.sourceforge.net/manual/"
163 #define LIVES_MANUAL_FILENAME "LiVES_manual.html"
164 #define LIVES_AUTHOR_EMAIL "mailto:salsaman@gmail.com"
165 #define LIVES_DONATE_URL "https://sourceforge.net/donate/index.php?group_id=64341"
166 #define LIVES_BUG_URL "http://sourceforge.net/tracker/?group_id=64341&atid=507139"
167 #define LIVES_FEATURE_URL "http://sourceforge.net/tracker/?group_id=64341&atid=507142"
168 #define LIVES_TRANSLATE_URL "https://translations.launchpad.net/lives/trunk"
169 
170 #ifdef IS_DARWIN
171 #ifndef off64_t
172 #define off64_t off_t
173 #endif
174 #ifndef lseek64
175 #define lseek64 lseek
176 #endif
177 #endif
178 
179 #define DEF_FILE_PERMS S_IRUSR|S_IWUSR
180 #define DEF_FILE_UMASK (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)^( DEF_FILE_PERMS )
181 
184 #define WARN_FILE_SIZE 500
185 
187 #define FPS_MAX 200.
188 
189 #define ENABLE_DVD_GRAB
190 
191 #define FP_BITS 16
192 
193 #ifdef HAVE_MJPEGTOOLS
194 #define HAVE_YUV4MPEG
195 #endif
196 
197 #ifdef ENABLE_OIL
198 #include <liboil/liboil.h>
199 #endif
200 
201 #ifndef IS_SOLARIS
202 #define LIVES_INLINE inline
203 #else
204 #define LIVES_INLINE
205 #endif
206 
207 #include <limits.h>
208 
209 #ifndef PATH_MAX
210 #ifdef MAX_PATH
211 #define PATH_MAX MAX_PATH
212 #else
213 #define PATH_MAX 4096
214 #endif
215 #endif
216 
217 #ifdef __GNUC__
218 # define WARN_UNUSED __attribute__((warn_unused_result))
219 #else
220 # define WARN_UNUSED
221 #endif
222 
223 #ifdef PRODUCE_LOG
224 #define LIVES_LOG "lives.log"
225 #endif
226 
227 #include "widget-helper.h"
228 
229 typedef void *(*fn_ptr) (void *ptr);
230 
231 
234 typedef struct {
235  gint value;
236  gint64 reltime;
237 } event;
238 
239 typedef struct {
240  GtkWidget *processing;
241  GtkWidget *progressbar;
242  GtkWidget *label;
243  GtkWidget *label2;
244  GtkWidget *label3;
245  GtkWidget *stop_button;
246  GtkWidget *pause_button;
247  GtkWidget *preview_button;
248  GtkWidget *cancel_button;
249  GtkWidget *scrolledwindow;
250  guint frames_done;
251 } xprocess;
252 
253 
254 
255 
256 typedef struct {
257  int afile;
258  double seek;
259  double vel;
261 
262 #if HAVE_SYSTEM_WEED
263 #include <weed/weed.h>
264 #include <weed/weed-events.h>
265 #else
266 #include "../libweed/weed.h"
267 #include "../libweed/weed-events.h"
268 #endif
269 
270 
271 
272 // see weed event spec. for more info
273 
275 #include "events.h"
276 
277 
278 typedef enum {
294 
297 
300 
302 
305 
307 } lives_undo_t;
308 
309 
311 typedef enum {
316 
317 
319 typedef enum {
322 
325 
328 
331 
334 
337 
340 
343 
346 
349 
352 
355 
358 
361 
364 
366 
367 
368 typedef enum {
372 
373 
374 
375 
376 typedef enum {
384 
385 
386 typedef enum {
391 
392 
393 
394 #define AFORM_SIGNED 0
395 #define AFORM_LITTLE_ENDIAN 0
396 
397 #define AFORM_UNSIGNED 1
398 #define AFORM_BIG_ENDIAN (1<<1)
399 #define AFORM_UNKNOWN 65536
400 
401 
402 typedef struct {
403  gshort red;
404  gshort green;
405  gshort blue;
407 
408 typedef struct {
409  gshort red;
410  gshort green;
411  gshort blue;
412  gshort alpha;
414 
415 
416 typedef enum {
421 
422 
423 #include "pangotext.h"
424 
426 typedef struct {
427  // basic info (saved during backup)
428  gint bpp;
429  gdouble fps;
430  gint hsize;
431  gint vsize;
432  gint arps;
434 
435  gint arate;
436  guint64 unique_id;
437  gint achans;
438  gint asampsize;
439 
441  gint frames;
442  gchar title[256];
443  gchar author[256];
444  gchar comment[256];
445  gchar keywords[256];
447 
449 
450  // extended info (not saved)
452 
453 #define LIVES_CLIP_HEADER_VERSION 100
454 
455  gint rowstride;
456 
459 
460  gchar handle[256];
461  gint ohsize;
462  gint ovsize;
463  int64_t f_size;
464  int64_t afilesize;
465  gint old_frames;
466  gchar file_name[PATH_MAX];
467  gchar info_file[PATH_MAX];
468  gchar name[256];
469  gchar save_file_name[PATH_MAX];
470  gchar type[40];
471  gint start;
472  gint end;
477  gboolean changed;
478  GtkWidget *menuentry;
479  gboolean orig_file_name;
480  gboolean was_renamed;
481  gboolean is_untitled;
482  gdouble pb_fps;
483  gdouble freeze_fps;
484  gboolean play_paused;
485 
486  //opening/restoring status
487  gboolean opening;
488  gboolean opening_audio;
490  gboolean opening_loc;
491  gboolean restoring;
492  gboolean is_loaded;
493 
495  gboolean nopreview;
496 
498  gboolean nokeep;
499 
500  // various times; total time is calculated as the gint64est of video, laudio and raudio
501  gdouble total_time;
502  gdouble video_time;
503  gdouble laudio_time;
504  gdouble raudio_time;
505  gdouble pointer_time;
506 
507  // current and last played index frames for internal player
508  gint frameno;
510 
511 
512 
514  // see resample.c for new events system
515 
516 
517  // events
518  event *events[1];
519 
520  weed_plant_t *event_list;
521  weed_plant_t *event_list_back;
522  weed_plant_t *next_event;
523 
524  GList *layout_map;
526 
529 
531  gint undo_end;
532  gchar undo_text[32];
533  gchar redo_text[32];
534  gboolean undoable;
535  gboolean redoable;
536 
537  // used for storing undo values
538  gint undo1_int;
539  gint undo2_int;
540  gint undo3_int;
541  gint undo4_int;
542  guint undo1_uint;
543  gdouble undo1_dbl;
544  gdouble undo2_dbl;
545  gboolean undo1_boolean;
546  gboolean undo2_boolean;
547  gboolean undo3_boolean;
548 
549  gint undo_arate;
553  gint undo_arps;
554 
556 
557  void *ext_src;
558 
564 
566 
568 
569 #define FX_FRAME_PUMP_VAL 200
570 
571 #define IMG_BUFF_SIZE 4096
572 
573  gboolean ratio_fps;
574 
575  int64_t aseek_pos;
576 
577  // decoder data
578 
579  gchar mime_type[256];
580 
581 
582  gboolean deinterlace;
583 
585 
591 
593 
594  gchar *op_dir;
596 
600 
602 
603  // TODO - change to lives_clip_t
604 } file;
605 
606 
607 
608 typedef struct {
609  // the following can be assumed TRUE, they are checked on startup
610  gboolean has_smogrify;
616 
617  // the following may need checking before use
618  gboolean has_xmms;
619  gboolean has_dvgrab;
620  gboolean has_sox_play;
621  gboolean has_sox_sox;
622  gboolean has_autolives;
623  gboolean has_mplayer;
624  gboolean has_convert;
625  gboolean has_composite;
626  gboolean has_identify;
627  gboolean has_cdda2wav;
629  gboolean has_jackd;
630  gboolean has_pulse_audio;
631  gboolean has_xwininfo;
632  gboolean has_gdb;
633  gboolean has_gconftool_2;
635 
637  gchar home_dir[PATH_MAX];
638 
640  gchar system_tmpdir[PATH_MAX];
641 
642  gchar *rcfile;
643 
645  gchar startup_msg[256];
646 
647  // plugins
649 
650  gboolean has_python;
651  guint64 python_version;
652 
653  gshort cpu_bits;
654 
655 
656  gchar *myname_full;
657  gchar *myname;
658 
659  gboolean has_stderr;
660 
661  gint nmonitors;
662 
663  gint ncpus;
664 
665 
666 #define LIVES_LITTLE_ENDIAN G_LITTLE_ENDIAN
667 #define LIVES_BIG_ENDIAN G_BIG_ENDIAN
668 
670 
671 } capability;
672 
673 
675 extern capability *capable;
676 
677 #ifdef HAVE_JACK_JACK_H
678 #include "jack.h"
679 #endif
680 
681 #define __STDC_FORMAT_MACROS
682 #include <inttypes.h>
683 
684 #ifndef PRId64
685 
686 #ifndef __WORDSIZE
687 #if defined __x86_64__
688 # define __WORDSIZE 64
689 #ifndef __WORDSIZE_COMPAT32
690 # define __WORDSIZE_COMPAT32 1
691 #endif
692 #else
693 # define __WORDSIZE 32
694 #endif
695 #endif // __WORDSIZE
696 
697 #ifndef __PRI64_PREFIX
698 # if __WORDSIZE == 64
699 # define __PRI64_PREFIX "l"
700 # else
701 # define __PRI64_PREFIX "ll"
702 # endif
703 #endif
704 
705 # define PRId64 __PRI64_PREFIX "d"
706 # define PRIu64 __PRI64_PREFIX "u"
707 #endif // ifndef PRI64d
708 
709 
710 // common defs for mainwindow
711 #include "plugins.h"
712 #include "colourspace.h"
713 #include "paramspecial.h"
714 #include "multitrack.h"
715 #include "mainwindow.h"
716 #include "keyboard.h"
717 #include "preferences.h"
718 
719 extern mainwindow *mainw;
720 
721 
722 // internal player clock
723 #include <sys/time.h>
724 struct timeval tv;
725 
726 
728 extern size_t sizint, sizdbl, sizshrt;
729 
730 
731 
732 typedef enum {
756 
757 
758 // some useful functions
759 
760 // interface.c
761 xprocess* create_processing (const gchar *text);
762 void add_to_winmenu(void);
763 void remove_from_winmenu(void);
764 void make_play_window(void);
765 void resize_play_window (void);
766 void kill_play_window (void);
767 void make_preview_box (void);
768 void add_to_playframe (void);
769 GtkWidget* create_cdtrack_dialog (gint type, gpointer user_data);
770 GtkTextView *create_output_textview(void);
771 gchar *choose_file(gchar *dir, gchar *fname, gchar **filt, GtkFileChooserAction act, const char *title, GtkWidget *extra);
772 void add_suffix_check(GtkBox *box, const gchar *ext);
773 
774 
775 // dialogs.c
776 gboolean do_progress_dialog(gboolean visible, gboolean cancellable, const gchar *text);
777 gboolean do_warning_dialog(const gchar *text);
778 gboolean do_warning_dialog_with_check(const gchar *text, gint warn_mask_number);
779 gboolean do_warning_dialog_with_check_transient(const gchar *text, gint warn_mask_number, GtkWindow *transient);
780 gboolean do_yesno_dialog(const gchar *text) WARN_UNUSED;
781 int do_abort_cancel_retry_dialog(const gchar *text, GtkWindow *transient) WARN_UNUSED;
782 void do_error_dialog(const gchar *text);
783 void do_error_dialog_with_check(const gchar *text, gint warn_mask_number);
784 void do_blocking_error_dialog(const gchar *text);
785 void do_error_dialog_with_check_transient(const gchar *text, gboolean is_blocking,gint warn_mask_number,
786  GtkWindow *transient);
787 
788 
789 void do_system_failed_error(const char *com, int retval, const char *addinfo);
790 int do_write_failed_error_s_with_retry(const gchar *fname, const gchar *errtext, GtkWindow *transient) WARN_UNUSED;
791 void do_write_failed_error_s(const char *filename, const char *addinfo);
792 int do_read_failed_error_s_with_retry(const gchar *fname, const gchar *errtext, GtkWindow *transient) WARN_UNUSED;
793 void do_read_failed_error_s(const char *filename, const char *addinfo);
794 gboolean do_header_write_error(int clip);
795 int do_header_read_error_with_retry(int clip) WARN_UNUSED;
796 int do_header_missing_detail_error(int clip, lives_clip_details_t detail) WARN_UNUSED;
797 void do_chdir_failed_error(const char *dir);
798 void handle_backend_errors(void);
799 gboolean check_backend_return(file *sfile);
800 
802 gchar *ds_critical_msg(const gchar *dir, guint64 dsval);
803 gchar *ds_warning_msg(const gchar *dir, guint64 dsval, guint64 cwarn, guint64 nwarn);
804 gboolean check_storage_space(file *sfile, gboolean is_processing);
805 
806 gchar *get_upd_msg(void);
807 gchar *get_new_install_msg(void);
808 
809 gboolean ask_permission_dialog(int what);
810 gboolean do_abort_check(void);
811 void add_warn_check (GtkBox *box, gint warn_mask_number);
812 void do_memory_error_dialog (void);
813 void too_many_files(void);
814 void tempdir_warning (void);
815 void do_audio_import_error(void);
816 void do_mt_backup_space_error(lives_mt *, gint memreq_mb);
817 
818 gboolean do_clipboard_fps_warning(void);
819 void perf_mem_warning(void);
820 void do_dvgrab_error(void);
821 gboolean do_comments_dialog (file *sfile, gchar *filename);
822 gboolean do_auto_dialog(const gchar *text, gint type);
823 void do_encoder_acodec_error (void);
824 void do_encoder_sox_error(void);
825 gboolean rdet_suggest_values (gint width, gint height, gdouble fps, gint fps_num, gint fps_denom, gint arate,
826  gint asigned, gboolean swap_endian, gboolean anr, gboolean ignore_fps);
827 gboolean do_encoder_restrict_dialog (gint width, gint height, gdouble fps, gint fps_num, gint fps_denom,
828  gint arate, gint asigned, gboolean swap_endian, gboolean anr, gboolean save_all);
829 void do_keys_window (void);
830 void do_mt_keys_window (void);
831 void do_messages_window (void);
832 void do_firstever_dialog (void);
833 void do_upgrade_error_dialog(void);
834 void do_no_mplayer_sox_error(void);
835 void do_aud_during_play_error(void);
836 void do_rendered_fx_dialog(void);
837 void do_layout_scrap_file_error(void);
838 void do_layout_ascrap_file_error(void);
839 void do_set_load_lmap_error(void);
840 gboolean do_set_duplicate_warning (const gchar *new_set);
841 gboolean do_set_rename_old_layouts_warning(const gchar *new_set);
842 gboolean do_layout_alter_frames_warning(void);
843 gboolean do_layout_alter_audio_warning(void);
844 gboolean do_yuv4m_open_warning(void);
845 void do_mt_undo_mem_error(void);
846 void do_mt_undo_buf_error(void);
847 void do_mt_set_mem_error(gboolean has_mt, gboolean trans);
848 void do_mt_audchan_error(gint warn_mask);
849 void do_mt_no_audchan_error(void);
850 void do_mt_no_jack_error(gint warn_mask);
851 gboolean do_mt_rect_prompt(void);
852 void do_audrate_error_dialog(void);
853 gboolean do_event_list_warning(void);
854 void do_nojack_rec_error(void);
855 void do_vpp_palette_error (void);
856 void do_vpp_fps_error (void);
857 void do_decoder_palette_error (void);
858 void do_rmem_max_error (gint size);
859 gboolean do_original_lost_warning(const gchar *fname);
860 void do_no_decoder_error(const gchar *fname);
861 void do_jack_noopen_warn(void);
862 void do_jack_noopen_warn2(void);
863 void do_jack_noopen_warn3(void);
864 void do_jack_noopen_warn4(void);
865 void do_file_perm_error(const gchar *file_name);
866 void do_dir_perm_error(const gchar *dir_name);
868 void do_after_crash_warning (void);
869 void do_bad_layout_error(void);
870 void do_card_in_use_error(void);
871 void do_dev_busy_error(const gchar *devstr);
872 gboolean do_existing_subs_warning(void);
873 void do_invalid_subs_error(void);
874 gboolean do_erase_subs_warning(void);
875 gboolean do_sub_type_warning(const gchar *ext, const gchar *type_ext);
876 gboolean do_move_tmpdir_dialog(void);
877 void do_set_locked_warning (const gchar *setname);
878 void do_no_in_vdevs_error(void);
879 void do_locked_in_vdevs_error(void);
880 void do_do_not_close_d (void);
881 void do_set_noclips_error(const char *setname);
882 void do_no_autolives_error(void);
884 void do_pulse_lost_conn_error(void);
885 void do_jack_lost_conn_error(void);
886 
887 gboolean process_one (gboolean visible);
888 void do_threaded_dialog(gchar *translated_text, gboolean has_cancel);
889 void end_threaded_dialog(void);
890 void threaded_dialog_spin (void);
891 void response_ok (GtkButton *button, gpointer user_data);
892 void response_cancel (GtkButton *button, gpointer user_data);
893 void pump_io_chan(GIOChannel *iochan);
894 
895 void do_splash_progress(void);
896 
897 
898 // d_print shortcuts
899 void d_print_cancelled(void);
900 void d_print_failed(void);
901 void d_print_done(void);
902 void d_print_file_error_failed(void);
903 
904 // general
905 void do_text_window (const gchar *title, const gchar *text);
906 
907 // saveplay.c
908 gboolean add_file_info(const gchar *check_handle, gboolean aud_only);
909 gboolean save_file_comments (int fileno);
910 void reget_afilesize (int fileno);
911 void deduce_file(const gchar *filename, gdouble start_time, gint end);
912 void open_file (const gchar *filename);
913 void open_file_sel(const gchar *file_name,gdouble start_time, gint frames);
914 void open_fw_device (void);
915 gboolean get_new_handle(gint index, const gchar *name);
916 gboolean get_temp_handle(gint index, gboolean create);
917 gboolean get_handle_from_info_file(gint index);
918 void create_cfile(void);
919 void save_file (int clip, int start, int end, const char *filename);
920 void play_file (void);
921 void save_frame (GtkMenuItem *menuitem, gpointer user_data);
922 gboolean save_frame_inner(gint clip, gint frame, const gchar *file_name, gint width, gint height, gboolean auto_overwrite);
923 void wait_for_stop (const gchar *stop_command);
924 gboolean save_clip_values(gint which_file);
925 void add_to_recovery_file (const gchar *handle);
926 void rewrite_recovery_file(void);
927 gboolean check_for_recovery_files (gboolean auto_recover);
928 void recover_layout_map(gint numclips);
929 const gchar *get_deinterlace_string(void);
930 
931 // saveplay.c backup
932 void backup_file(int clip, int start, int end, const gchar *filename);
933 gint save_event_frames(void);
934 gboolean write_headers (file *file);
935 
936 // saveplay.c restore
937 void restore_file(const gchar *filename);
938 gboolean read_headers(const gchar *file_name);
939 
940 // saveplay.c sets
941 void open_set_file (const gchar *set_name, gint clipnum);
942 
943 
944 // saveplay.c scrap file
945 gboolean open_scrap_file (void);
946 gboolean open_ascrap_file (void);
947 gint save_to_scrap_file (weed_plant_t *layer);
948 gboolean load_from_scrap_file(weed_plant_t *layer, int frame);
949 void close_ascrap_file (void);
950 void close_scrap_file (void);
951 
952 
953 // main.c
954 void catch_sigint(int signum);
955 gboolean startup_message_fatal(const gchar *msg);
956 gboolean startup_message_nonfatal(const gchar *msg);
957 gboolean startup_message_nonfatal_dismissable(const gchar *msg, gint warning_mask);
959 void get_monitors(void);
960 void load_start_image(gint frame);
961 void load_end_image(gint frame);
962 void load_preview_image(gboolean update_always);
963 
964 gboolean pull_frame(weed_plant_t *layer, const gchar *image_ext, weed_timecode_t tc);
965 gboolean pull_frame_at_size (weed_plant_t *layer, const gchar *image_ext, weed_timecode_t tc,
966  int width, int height, int target_palette);
967 LiVESPixbuf *pull_lives_pixbuf_at_size(int clip, int frame, const char *image_ext, weed_timecode_t tc,
968  int width, int height, LiVESInterpType interp);
969 GError * lives_pixbuf_save(GdkPixbuf *pixbuf, gchar *fname, lives_image_type_t imgtype,
970  int quality, gboolean do_chmod, GError **gerrorptr);
971 
972 void load_frame_image(gint frame);
973 void sensitize(void);
974 void desensitize(void);
975 void procw_desensitize(void);
976 void close_current_file (gint file_to_switch_to);
977 void get_next_free_file(void);
978 void switch_to_file(gint old_file, gint new_file);
979 void do_quick_switch (gint new_file);
980 void resize (gdouble scale);
981 gboolean read_file_details(const gchar *file_name, gboolean only_check_for_audio);
982 void do_start_messages(void);
983 void set_palette_colours (void);
984 void set_main_title(const gchar *filename, gint or_untitled_number);
985 void set_record (void);
986 
987 //gui.c
988 //gui.c
989 void create_LiVES (void);
990 void enable_record (void);
991 void toggle_record (void);
992 void disable_record (void);
993 void make_custom_submenus(void);
994 void fade_background(void);
995 void unfade_background(void);
996 void block_expose (void);
997 void unblock_expose (void);
998 void frame_size_update(void);
999 void splash_init(void);
1000 void splash_end(void);
1001 void splash_msg(const gchar *msg, gdouble pct);
1002 void add_message_scroller(GtkWidget *conter);
1003 
1004 
1005 // system calls in utils.c
1006 int lives_system(const char *com, gboolean allow_error);
1007 lives_pid_t lives_fork(const char *com);
1008 ssize_t lives_write(int fd, const void *buf, size_t count, gboolean allow_fail);
1009 ssize_t lives_write_le(int fd, const void *buf, size_t count, gboolean allow_fail);
1010 ssize_t lives_read(int fd, void *buf, size_t count, gboolean allow_less);
1011 ssize_t lives_read_le(int fd, void *buf, size_t count, gboolean allow_less);
1012 int lives_chdir(const char *path, gboolean allow_fail);
1013 int lives_fputs(const char *s, FILE *stream);
1014 char *lives_fgets(char *s, int size, FILE *stream);
1015 pid_t lives_getpid(void);
1016 int lives_getgid(void);
1017 int lives_getuid(void);
1018 void lives_freep(void **ptr);
1019 void lives_free(gpointer ptr);
1020 void lives_free_with_check(gpointer ptr);
1021 #ifdef IS_MINGW
1022 gboolean lives_win32_suspend_resume_process(DWORD pid, gboolean suspend);
1023 gboolean lives_win32_kill_subprocesses(DWORD pid, gboolean kill_parent);
1024 int lives_win32_get_num_logical_cpus(void);
1025 #endif
1026 int lives_kill(lives_pid_t pid, int sig);
1027 int lives_killpg(lives_pgid_t pgrp, int sig);
1028 void lives_srandom(unsigned int seed);
1029 uint64_t lives_random(void);
1030 ssize_t lives_readlink(const char *path, char *buf, size_t bufsiz);
1031 boolean lives_setenv(const char *name, const char *value);
1032 boolean lives_fsync(int fd);
1033 void lives_sync(void);
1034 
1035 char *filename_from_fd(char *val, int fd);
1036 
1037 float LEFloat_to_BEFloat(float f);
1038 uint64_t lives_10pow(int pow);
1039 int get_approx_ln(guint val);
1040 
1041 int64_t lives_get_current_ticks(void);
1042 gboolean lives_alarm_get(int alarm_handle);
1043 int lives_alarm_set(int64_t ticks);
1044 void lives_alarm_clear(int alarm_handle);
1045 lives_storage_status_t get_storage_status(const char *dir, guint64 warn_level, guint64 *dsval);
1046 gchar *lives_format_storage_space_string(guint64 space);
1047 
1048 
1049 gint myround(gdouble n);
1050 void get_dirname(gchar *filename);
1051 gchar *get_dir(const gchar *filename);
1052 void get_basename(gchar *filename);
1053 void get_filename(gchar *filename, gboolean strip_dir);
1054 gchar *get_extension(const gchar *filename);
1055 guint64 get_version_hash(const gchar *exe, const gchar *sep, int piece);
1056 void d_print(const gchar *text);
1057 void init_clipboard(void);
1058 gboolean cache_file_contents(const gchar *filename);
1059 gchar *get_val_from_cached_list(const gchar *key, size_t maxlen);
1060 void get_pref(const gchar *key, gchar *val, gint maxlen);
1061 void get_pref_utf8(const gchar *key, gchar *val, gint maxlen);
1062 void get_pref_default(const gchar *key, gchar *val, gint maxlen);
1063 gboolean get_boolean_pref(const gchar *key);
1064 gdouble get_double_pref(const gchar *key);
1065 gint get_int_pref(const gchar *key);
1066 GList *get_list_pref(const gchar *key);
1067 void get_location(const gchar *exe, gchar *val, gint maxlen);
1068 void set_pref (const gchar *key, const gchar *value);
1069 void delete_pref (const gchar *key);
1070 void set_boolean_pref(const gchar *key, gboolean value);
1071 void set_double_pref(const gchar *key, gdouble value);
1072 void set_int_pref(const gchar *key, gint value);
1073 void set_int64_pref(const gchar *key, gint64 value);
1074 void set_list_pref(const char *key, GList *values);
1075 gboolean apply_prefs(gboolean skip_warnings);
1076 void save_future_prefs(void);
1077 void set_menu_text(GtkWidget *menu, const gchar *text, gboolean use_mnemonic);
1078 void get_menu_text(GtkWidget *menu, gchar *text);
1079 void get_menu_text_long(GtkWidget *menuitem, gchar *text);
1080 void reset_clip_menu (void);
1081 void get_play_times(void);
1082 void get_total_time (file *file);
1083 guint get_signed_endian (gboolean is_signed, gboolean little_endian);
1084 void fullscreen_internal(void);
1085 void set_alwaysontop(GtkWidget *window, gboolean ontop);
1086 void colour_equal(GdkColor *c1, const GdkColor *c2);
1087 void switch_to_int_player(void);
1088 void switch_to_mplayer(void);
1089 void switch_aud_to_sox(gboolean set_pref);
1090 gboolean switch_aud_to_jack(void);
1091 gboolean switch_aud_to_pulse(void);
1092 void switch_aud_to_mplayer(gboolean set_pref);
1093 void prepare_to_play_foreign(void);
1094 gboolean after_foreign_play(void);
1095 gboolean check_file(const gchar *file_name, gboolean check_exists);
1096 gboolean check_dir_access (const gchar *dir);
1097 uint64_t get_file_size(int fd);
1098 uint64_t sget_file_size(const gchar *name);
1099 uint64_t get_fs_free(const char *dir);
1100 gboolean is_writeable_dir(const char *dir);
1101 gboolean ensure_isdir(gchar *fname);
1102 gchar *ensure_extension(const gchar *fname, const gchar *ext) WARN_UNUSED;
1103 gboolean check_dev_busy(gchar *devstr);
1104 void activate_url_inner(const gchar *link);
1105 void activate_url (GtkAboutDialog *about, const gchar *link, gpointer data);
1106 void show_manual_section (const gchar *lang, const gchar *section);
1107 
1108 gdouble calc_time_from_frame (gint clip, gint frame);
1109 gint calc_frame_from_time (gint filenum, gdouble time);
1110 gint calc_frame_from_time2 (gint filenum, gdouble time);
1111 gint calc_frame_from_time3 (gint filenum, gdouble time);
1112 
1113 gboolean check_for_ratio_fps (gdouble fps);
1114 gdouble get_ratio_fps(const gchar *string);
1115 void calc_maxspect(gint rwidth, gint rheight, gint *cwidth, gint *cheight);
1116 
1117 gchar *remove_trailing_zeroes(gdouble val);
1118 
1119 void remove_layout_files(GList *lmap);
1120 gboolean add_lmap_error(lives_lmap_error_t lerror, const gchar *name, gpointer user_data,
1121  gint clipno, gint frameno, gdouble atime, gboolean affects_current);
1122 void clear_lmap_errors(void);
1123 gboolean prompt_remove_layout_files(void);
1124 gboolean is_legal_set_name(const gchar *set_name, gboolean allow_dupes);
1125 gchar *repl_tmpdir(const gchar *entry, gboolean fwd);
1126 gchar *clip_detail_to_string(lives_clip_details_t what, size_t *maxlenp);
1127 gboolean get_clip_value(int which, lives_clip_details_t, void *retval, size_t maxlen);
1128 void save_clip_value(int which, lives_clip_details_t, void *val);
1129 gboolean check_frame_count(gint idx);
1130 void get_frame_count(gint idx);
1131 gint count_resampled_frames (gint in_frames, gdouble orig_fps, gdouble resampled_fps);
1132 gboolean int_array_contains_value(int *array, int num_elems, int value);
1133 gboolean check_for_lock_file(const gchar *set_name, gint type);
1134 void g_list_free_strings(GList *list);
1135 
1136 gboolean create_event_space(gint length_in_eventsb);
1137 void add_to_recent(const gchar *filename, gdouble start, gint frames, const gchar *file_open_params);
1138 gint verhash (gchar *version);
1139 void set_undoable (const gchar *what, gboolean sensitive);
1140 void set_redoable (const gchar *what, gboolean sensitive);
1141 void zero_spinbuttons (void);
1142 void draw_little_bars (gdouble ptrtime);
1143 void set_sel_label (GtkWidget *label);
1144 void clear_mainw_msg (void);
1145 gint get_token_count (const gchar *string, int delim);
1146 LiVESPixbuf *lives_pixbuf_new_blank(int width, int height, int palette);
1147 gchar *g_strappend (gchar *string, gint len, const gchar *newbit);
1148 GList *g_list_append_unique(GList *xlist, const gchar *add);
1149 void find_when_to_stop (void);
1150 gint calc_new_playback_position(gint fileno, gint64 otc, gint64 *ntc);
1151 void calc_aframeno(gint fileno);
1152 void minimise_aspect_delta (gdouble allowed_aspect,gint hblock,gint vblock,gint hsize,gint vsize,gint *width,gint *height);
1153 LiVESInterpType get_interp_value(gshort quality);
1154 
1155 GList *g_list_move_to_first(GList *list, GList *item) WARN_UNUSED;
1156 GList *g_list_delete_string(GList *, char *string) WARN_UNUSED;
1157 GList *g_list_copy_strings(GList *list);
1158 gboolean string_lists_differ(GList *, GList *);
1159 
1160 
1161 GList *get_set_list(const gchar *dir);
1162 
1163 gchar *subst (const gchar *string, const gchar *from, const gchar *to);
1164 gchar *insert_newlines(const gchar *text, int maxwidth);
1165 
1166 gint hextodec (const gchar *string);
1167 gint get_hex_digit (const gchar *c);
1168 
1169 guint32 fastrand(void);
1170 void fastsrand(guint32 seed);
1171 
1172 gint lives_list_index (GList *list, const gchar *data);
1173 
1175 
1176 // plugins.c
1178 gboolean check_encoder_restrictions (gboolean get_extension, gboolean user_audio, gboolean save_all);
1179 
1180 //callbacks.c
1181 void lives_exit (void);
1182 void count_opening_frames(void);
1183 void on_fileread_clicked (GtkFileChooser *, gpointer widget);
1184 gboolean dirchange_callback (GtkAccelGroup *, GObject *, guint, GdkModifierType, gpointer user_data);
1185 void on_effects_paused (GtkButton *, gpointer user_data);
1186 void on_cancel_keep_button_clicked (GtkButton *, gpointer user_data);
1187 void on_cleardisk_activate (GtkWidget *, gpointer user_data);
1188 void on_cleardisk_advanced_clicked (GtkWidget *, gpointer user_data);
1189 
1190 // paramspecial.c
1191 gboolean mt_framedraw(lives_mt *, GdkPixbuf *);
1192 
1193 // paramwindow.c
1194 void add_fill_to_box (GtkBox *);
1195 
1196 // rte_window.c
1197 void refresh_rte_window (void);
1198 
1199 // effects-weed.c
1200 void * lives_malloc(size_t size);
1201 void *lives_memcpy(void *dest, const void *src, size_t n);
1202 void *lives_memset(void *s, int c, size_t n);
1203 void lives_free(void *ptr);
1204 
1206 void lives_free_normal(void *ptr);
1207 void lives_free_with_check(gpointer ptr);
1208 
1209 // pangotext.c
1210 gboolean subtitles_init(file *sfile, char * fname, lives_subtitle_type_t);
1211 void subtitles_free(file *sfile);
1212 gboolean get_srt_text(file *sfile, double xtime);
1213 gboolean get_sub_text(file *sfile, double xtime);
1214 gboolean save_sub_subtitles(file *sfile, double start_time, double end_time, double offset_time, const char *filename);
1215 gboolean save_srt_subtitles(file *sfile, double start_time, double end_time, double offset_time, const char *filename);
1216 
1217 // osc.c
1218 #ifdef ENABLE_OSC
1219 gboolean lives_osc_init(guint osc_udp_port);
1220 gint lives_osc_poll(gpointer data);
1221 void lives_osc_end(void);
1222 gboolean lives_osc_notify(int msgtype, const char *msgstring);
1223 void lives_osc_notify_success (const gchar *msg);
1224 void lives_osc_notify_failure (void);
1225 void lives_osc_notify_cancel (void);
1226 #include "osc_notify.h"
1227 #endif
1228 
1229 // ldvgrab.c
1230 #ifdef HAVE_LDVGRAB
1231 void on_open_fw_activate (GtkMenuItem *menuitem, gpointer format);
1232 
1233 #define CAM_FORMAT_DV 0
1234 #define CAM_FORMAT_HDV 1
1235 
1236 #endif
1237 
1238 // inlines
1239 #define cfile mainw->files[mainw->current_file]
1240 #define clipboard mainw->files[0]
1241 
1242 #define U82L(String) ( g_locale_from_utf8 (String,-1,NULL,NULL,NULL) )
1243 #define L2U8(String) ( g_locale_to_utf8 (String,-1,NULL,NULL,NULL) )
1244 
1245 
1246 #define PREFS_TIMEOUT 10000000
1247 
1248 #define LIVES_TV_CHANNEL1 "http://www.serverwillprovide.com/sorteal/livestvclips/livestv.ogm"
1249 
1250 
1251 // round (double) a up to next (integer) multiple of (double) b
1252 #define CEIL(a,b) ((int)(((double)a+(double)b-.000000001)/((double)b))*b)
1253 
1254 
1255 gchar *dummychar;
1256 
1257 #define LIVES_NO_DEBUG
1258 #ifndef LIVES_DEBUG
1259 #ifndef LIVES_NO_DEBUG
1260 #define LIVES_DEBUG(x) fprintf(stderr, "LiVES debug: %s\n", x)
1261 #else // LIVES_NO_DEBUG
1262 #define LIVES_DEBUG(x) dummychar = x
1263 #endif // LIVES_NO_DEBUG
1264 #endif // LIVES_DEBUG
1265 
1266 #ifndef LIVES_INFO
1267 #ifndef LIVES_NO_INFO
1268 #define LIVES_INFO(x) fprintf(stderr, "LiVES info: %s\n", x)
1269 #else // LIVES_NO_INFO
1270 #define LIVES_INFO(x) dummychar = x
1271 #endif // LIVES_NO_INFO
1272 #endif // LIVES_INFO
1273 
1274 #ifndef LIVES_WARN
1275 #ifndef LIVES_NO_WARN
1276 #define LIVES_WARN(x) fprintf(stderr, "LiVES warning: %s\n", x)
1277 #else // LIVES_NO_WARN
1278 #define LIVES_WARN(x) dummychar = x
1279 #endif // LIVES_NO_WARN
1280 #endif // LIVES_WARN
1281 
1282 #ifndef LIVES_ERROR
1283 #ifndef LIVES_NO_ERROR
1284 #define LIVES_ERROR(x) fprintf(stderr, "LiVES error: %s\n", x)
1285 #else // LIVES_NO_ERROR
1286 #define LIVES_ERROR(x) dummychar = x
1287 #endif // LIVES_NO_ERROR
1288 #endif // LIVES_ERROR
1289 
1290 #ifndef LIVES_FATAL
1291 #ifndef LIVES_NO_FATAL
1292 #define LIVES_FATAL(x) {fprintf(stderr, "LiVES fatal: %s\n", x); raise (LIVES_SIGSEGV);}
1293 #else // LIVES_NO_FATAL
1294 #define LIVES_FATAL(x) dummychar = x
1295 #endif // LIVES_NO_FATAL
1296 #endif // LIVES_FATAL
1297 
1298 
1299 #endif // #ifndef HAS_LIVES_MAIN_H
1300