LiVES  2.0.3
 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@gmail.com) 2003 - 2013
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 #define PAINTER_CAIRO
56 
57 #ifdef GUI_GTK
58 
59 #include <gtk/gtk.h>
60 #include <gdk/gdkkeysyms.h>
61 
62 #if GTK_CHECK_VERSION(3,0,0)
63 #ifdef ENABLE_GIW
64 #define ENABLE_GIW_3
65 #endif
66 #endif
67 
68 #endif
69 
70 #ifdef IS_MINGW
71 
72 #ifndef WINVER
73 #define WINVER 0x0500
74 #endif
75 
76 #include <windows.h>
77 #include <winbase.h>
78 #include <tlhelp32.h>
79 #include <sddl.h>
80 #include <sys/stat.h>
81 
82 #define O_SYNC (FILE_FLAG_NO_BUFFERING|FILE_FLAG_WRITE_THROUGH)
83 
84 typedef PROCESS_INFORMATION * lives_pid_t;
85 typedef PROCESS_INFORMATION * lives_pgid_t;
86 
87 #ifdef GUI_GTK
88 #ifndef GDK_WINDOWING_WIN32
89 #define GDK_WINDOWING_WIN32
90 #endif
91 #endif
92 
93 #else // IS_MINGW
94 
95 #ifdef GUI_GTK
96 #ifndef GDK_WINDOWING_X11
97 #define GDK_WINDOWING_X11
98 #endif
99 #endif
100 
101 typedef pid_t lives_pid_t;
102 typedef int lives_pgid_t;
103 
104 #endif
105 
106 
107 
108 #ifdef GUI_GTK
109 
110 #ifdef GDK_WINDOWING_WIN32
111 #include <gdk/gdkwin32.h>
112 
113 #ifndef GDK_IS_WIN32_DISPLAY
114 #define GDK_IS_WIN32_DISPLAY(display) (TRUE)
115 #endif
116 
117 #endif //GDK_WINDOWING_WIN32
118 
119 #ifdef GDK_WINDOWING_X11
120 
121 // needed for GDK_WINDOW_XID - for fileselector preview
122 // needed for gdk_x11_screen_get_window_manager_name()
123 
124 #include <gdk/gdkx.h>
125 
126 #ifndef GDK_IS_X11_DISPLAY
127 #define GDK_IS_X11_DISPLAY(display) (TRUE)
128 #endif
129 
130 #ifndef GDK_IS_WIN32_DISPLAY
131 #define GDK_IS_WIN32_DISPLAY(display) (FALSE)
132 #endif
133 
134 
135 #else
136 
137 #ifndef GDK_IS_X11_DISPLAY
138 #define GDK_IS_X11_DISPLAY(display) (FALSE)
139 #endif
140 
141 #endif // GDK_WINDOWING_X11
142 
143 #endif // GUI_GTK
144 
145 
146 #include <stdlib.h>
147 #include <stdio.h>
148 #include <unistd.h>
149 #include <string.h>
150 #include <signal.h>
151 #include <assert.h>
152 #include <errno.h>
153 
154 #define __STDC_CONSTANT_MACROS
155 #include <stdint.h>
156 
157 
158 #define QUOTEME(x) #x
159 
160 
162 #define MAX_FILES 65535
163 
166 #ifndef PREFIX_DEFAULT
167 #ifndef IS_MINGW
168 #define PREFIX_DEFAULT "/usr"
169 #else
170 // TODO - get this from the installer
171 #define PREFIX_DEFAULT "C:\\Program Files\\LiVES"
172 #endif
173 #endif
174 
176 #ifndef PREFIX
177 #define PREFIX PREFIX_DEFAULT
178 #endif
179 
180 
181 
182 #ifndef IS_MINGW
183 #define DOC_DIR "/share/doc/lives-"
184 
185 #define THEME_DIR "/share/lives/themes/"
186 #define PLUGIN_SCRIPTS_DIR "/share/lives/plugins/"
187 #define PLUGIN_COMPOUND_DIR "/share/lives/plugins/"
188 #define PLUGIN_EXEC_DIR "/lives/plugins/"
189 #define ICON_DIR "/share/lives/icons/"
190 #define DESKTOP_ICON_DIR "/share/app-install/icons/"
191 #define DATA_DIR "/share/lives/"
192 #define LIVES_CONFIG_DIR ".lives-dir/"
193 #define LIVES_TMP_NAME "livestmp"
194 
195 #else // IS_MINGW
196 #define DOC_DIR "\\Documents/"
197 
198 #define THEME_DIR "\\Themes/"
199 #define PLUGIN_SCRIPTS_DIR "\\Plugins/"
200 #define PLUGIN_COMPOUND_DIR "\\Plugins/"
201 #define PLUGIN_EXEC_DIR "\\Plugins/"
202 #define ICON_DIR "\\Icons/"
203 #define DATA_DIR "\\Data/"
204 #define LIVES_CONFIG_DIR "\\Config/"
205 #define LIVES_TMP_NAME "livescache"
206 #endif
207 
208 #define LIVES_DEVICE_DIR "/dev/"
209 
210 
211 #define LIVES_MANUAL_URL "http://lives.sourceforge.net/manual/"
212 #define LIVES_MANUAL_FILENAME "LiVES_manual.html"
213 #define LIVES_AUTHOR_EMAIL "mailto:salsaman@gmail.com"
214 #define LIVES_DONATE_URL "https://sourceforge.net/donate/index.php?group_id=64341"
215 #define LIVES_BUG_URL "http://sourceforge.net/tracker/?group_id=64341&atid=507139"
216 #define LIVES_FEATURE_URL "http://sourceforge.net/tracker/?group_id=64341&atid=507142"
217 #define LIVES_TRANSLATE_URL "https://translations.launchpad.net/lives/trunk"
218 
219 #ifdef IS_DARWIN
220 #ifndef off64_t
221 #define off64_t off_t
222 #endif
223 #ifndef lseek64
224 #define lseek64 lseek
225 #endif
226 #endif
227 
228 #define DEF_FILE_PERMS S_IRUSR|S_IWUSR
229 #define DEF_FILE_UMASK (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)^( DEF_FILE_PERMS )
230 
233 #define WARN_FILE_SIZE 500
234 
236 #define FPS_MAX 200.
237 
238 #define MAX_FRAME_WIDTH 100000.
239 #define MAX_FRAME_HEIGHT 100000.
240 
241 #define ENABLE_DVD_GRAB
242 
243 #define FP_BITS 16
244 
245 #ifdef HAVE_MJPEGTOOLS
246 #define HAVE_YUV4MPEG
247 #endif
248 
249 #ifdef ENABLE_OIL
250 #include <liboil/liboil.h>
251 #endif
252 
253 #ifndef IS_SOLARIS
254 #define LIVES_INLINE inline
255 #else
256 #define LIVES_INLINE
257 #endif
258 
259 #include <limits.h>
260 
261 #ifndef PATH_MAX
262 #ifdef MAX_PATH
263 #define PATH_MAX MAX_PATH
264 #else
265 #define PATH_MAX 4096
266 #endif
267 #endif
268 
269 #ifdef __GNUC__
270 # define WARN_UNUSED __attribute__((warn_unused_result))
271 #else
272 # define WARN_UNUSED
273 #endif
274 
275 #ifdef PRODUCE_LOG
276 #define LIVES_LOG "lives.log"
277 #endif
278 
279 #include "widget-helper.h"
280 
281 typedef void *(*fn_ptr) (void *ptr);
282 
283 
286 typedef struct {
287  gint value;
288  gint64 reltime;
289 } event;
290 
291 typedef struct {
292  GtkWidget *processing;
293  GtkWidget *progressbar;
294  GtkWidget *label;
295  GtkWidget *label2;
296  GtkWidget *label3;
297  GtkWidget *stop_button;
298  GtkWidget *pause_button;
299  GtkWidget *preview_button;
300  GtkWidget *cancel_button;
301  GtkWidget *scrolledwindow;
302  guint frames_done;
303 } xprocess;
304 
305 
306 
307 
308 typedef struct {
309  int afile;
310  double seek;
311  double vel;
313 
314 #if HAVE_SYSTEM_WEED
315 #include <weed/weed.h>
316 #include <weed/weed-events.h>
317 #else
318 #include "../libweed/weed.h"
319 #include "../libweed/weed-events.h"
320 #endif
321 
322 
323 
324 // see weed event spec. for more info
325 
327 #include "events.h"
328 
329 
330 typedef enum {
346 
349 
352 
354 
357 
359 } lives_undo_t;
360 
361 
363 typedef enum {
368 
369 
371 typedef enum {
374 
377 
380 
383 
386 
389 
392 
395 
398 
401 
404 
407 
410 
413 
416 
418 
419 
420 typedef enum {
424 
425 
426 
427 
428 typedef enum {
436 
437 
438 typedef enum {
443 
444 
445 
446 #define AFORM_SIGNED 0
447 #define AFORM_LITTLE_ENDIAN 0
448 
449 #define AFORM_UNSIGNED 1
450 #define AFORM_BIG_ENDIAN (1<<1)
451 #define AFORM_UNKNOWN 65536
452 
453 
454 typedef struct {
455  uint16_t red;
456  uint16_t green;
457  uint16_t blue;
459 
460 typedef struct {
461  uint16_t red;
462  uint16_t green;
463  uint16_t blue;
464  uint16_t alpha;
466 
467 
468 typedef enum {
473 
474 
475 #include "pangotext.h"
476 
478 typedef struct {
479  // basic info (saved during backup)
480  gint bpp;
481  gdouble fps;
482  gint hsize;
483  gint vsize;
484  gint arps;
486 
487  gint arate;
488  guint64 unique_id;
489  gint achans;
490  gint asampsize;
491 
493  gint frames;
494  gchar title[256];
495  gchar author[256];
496  gchar comment[256];
497  gchar keywords[256];
499 
501 
502  // extended info (not saved)
504 
505 #define LIVES_CLIP_HEADER_VERSION 100
506 
507  gint rowstride;
508 
511 
512  gchar handle[256];
513  gint ohsize;
514  gint ovsize;
515  int64_t f_size;
516  int64_t afilesize;
517  gint old_frames;
518  gchar file_name[PATH_MAX];
519  gchar info_file[PATH_MAX];
520  gchar name[256];
521  gchar save_file_name[PATH_MAX];
522  gchar type[40];
523  gint start;
524  gint end;
529  boolean changed;
530  GtkWidget *menuentry;
531  boolean orig_file_name;
532  boolean was_renamed;
533  boolean is_untitled;
534  gdouble pb_fps;
535  gdouble freeze_fps;
536  boolean play_paused;
537 
538  //opening/restoring status
539  boolean opening;
540  boolean opening_audio;
542  boolean opening_loc;
543  boolean restoring;
544  boolean is_loaded;
545 
547  boolean nopreview;
548 
550  boolean nokeep;
551 
552  // various times; total time is calculated as the gint64est of video, laudio and raudio
553  gdouble total_time;
554  gdouble video_time;
555  gdouble laudio_time;
556  gdouble raudio_time;
557  gdouble pointer_time;
558 
559  // current and last played index frames for internal player
560  gint frameno;
562 
563 
564 
566  // see resample.c for new events system
567 
568 
569  // events
570  event *events[1];
571 
572  weed_plant_t *event_list;
573  weed_plant_t *event_list_back;
574  weed_plant_t *next_event;
575 
576  GList *layout_map;
578 
581 
583  gint undo_end;
584  gchar undo_text[32];
585  gchar redo_text[32];
586  boolean undoable;
587  boolean redoable;
588 
589  // used for storing undo values
590  gint undo1_int;
591  gint undo2_int;
592  gint undo3_int;
593  gint undo4_int;
594  guint undo1_uint;
595  gdouble undo1_dbl;
596  gdouble undo2_dbl;
597  boolean undo1_boolean;
598  boolean undo2_boolean;
599  boolean undo3_boolean;
600 
601  gint undo_arate;
605  gint undo_arps;
606 
608 
609  void *ext_src;
610 
616 
618 
620 
621 #define FX_FRAME_PUMP_VAL 200
622 
623 #define IMG_BUFF_SIZE 4096
624 
625  boolean ratio_fps;
626 
627  int64_t aseek_pos;
628 
629  // decoder data
630 
631  gchar mime_type[256];
632 
633 
634  boolean deinterlace;
635 
637 
643 
645 
646  gchar *op_dir;
648 
652 
654 
655  lives_painter_surface_t *laudio_drawable;
656  lives_painter_surface_t *raudio_drawable;
657 
658  // TODO - change to lives_clip_t
659 } file;
660 
661 
662 
663 typedef struct {
664  // the following can be assumed TRUE, they are checked on startup
665  boolean has_smogrify;
671 
672  // the following may need checking before use
673  boolean has_dvgrab;
674  boolean has_sox_play;
675  boolean has_sox_sox;
676  boolean has_autolives;
677  boolean has_mplayer;
678  boolean has_convert;
679  boolean has_composite;
680  boolean has_identify;
681  boolean has_cdda2wav;
683  boolean has_jackd;
685  boolean has_xwininfo;
686  boolean has_gdb;
689 
691  gchar home_dir[PATH_MAX];
692 
694  gchar system_tmpdir[PATH_MAX];
695 
696  gchar *rcfile;
697 
699  gchar startup_msg[256];
700 
701  // plugins
703 
704  boolean has_python;
705  guint64 python_version;
706 
707  gshort cpu_bits;
708 
709 
710  gchar *myname_full;
711  gchar *myname;
712 
713  boolean has_stderr;
714 
715  gint nmonitors;
716 
717  gint ncpus;
718 
719 
720 #define LIVES_LITTLE_ENDIAN G_LITTLE_ENDIAN
721 #define LIVES_BIG_ENDIAN G_BIG_ENDIAN
722 
724 
725 } capability;
726 
727 
729 extern capability *capable;
730 
731 #ifdef HAVE_JACK_JACK_H
732 #include "jack.h"
733 #endif
734 
735 #define __STDC_FORMAT_MACROS
736 #include <inttypes.h>
737 
738 #ifndef PRId64
739 
740 #ifndef __WORDSIZE
741 #if defined __x86_64__
742 # define __WORDSIZE 64
743 #ifndef __WORDSIZE_COMPAT32
744 # define __WORDSIZE_COMPAT32 1
745 #endif
746 #else
747 # define __WORDSIZE 32
748 #endif
749 #endif // __WORDSIZE
750 
751 #ifndef __PRI64_PREFIX
752 # if __WORDSIZE == 64
753 # define __PRI64_PREFIX "l"
754 # else
755 # define __PRI64_PREFIX "ll"
756 # endif
757 #endif
758 
759 # define PRId64 __PRI64_PREFIX "d"
760 # define PRIu64 __PRI64_PREFIX "u"
761 #endif // ifndef PRI64d
762 
763 
764 // common defs for mainwindow (retain this order)
765 #include "plugins.h"
766 #include "colourspace.h"
767 #include "paramspecial.h"
768 #include "multitrack.h"
769 #include "mainwindow.h"
770 #include "keyboard.h"
771 #include "preferences.h"
772 
773 extern mainwindow *mainw;
774 
775 
776 // internal player clock
777 #include <sys/time.h>
778 struct timeval tv;
779 
780 
782 extern size_t sizint, sizdbl, sizshrt;
783 
784 
785 
786 typedef enum {
810 
811 
812 // some useful functions
813 
814 // interface.c
815 xprocess* create_processing (const gchar *text);
816 void add_to_winmenu(void);
817 void remove_from_winmenu(void);
818 void make_play_window(void);
819 void resize_play_window (void);
820 void kill_play_window (void);
821 void make_preview_box (void);
822 void play_window_set_title(void);
823 void add_to_playframe (void);
824 GtkWidget* create_cdtrack_dialog (int type, gpointer user_data);
825 GtkTextView *create_output_textview(void);
826 gchar *choose_file(gchar *dir, gchar *fname, gchar **filt, lives_file_chooser_action_t act, const char *title, GtkWidget *extra);
827 void choose_file_with_preview (gchar *dir, const gchar *title, int preview_type);
828 void add_suffix_check(GtkBox *box, const gchar *ext);
829 
830 
831 // dialogs.c
832 boolean do_progress_dialog(boolean visible, boolean cancellable, const gchar *text);
833 boolean do_warning_dialog(const gchar *text);
834 boolean do_warning_dialog_with_check(const gchar *text, int warn_mask_number);
835 boolean do_warning_dialog_with_check_transient(const gchar *text, int warn_mask_number, GtkWindow *transient);
836 boolean do_yesno_dialog(const gchar *text) WARN_UNUSED;
837 int do_abort_cancel_retry_dialog(const gchar *text, GtkWindow *transient) WARN_UNUSED;
838 void do_error_dialog(const gchar *text);
839 void do_info_dialog(const gchar *text);
840 void do_error_dialog_with_check(const gchar *text, int warn_mask_number);
841 void do_blocking_error_dialog(const gchar *text);
842 void do_blocking_info_dialog(const gchar *text);
843 void do_error_dialog_with_check_transient(const gchar *text, boolean is_blocking, int warn_mask_number,
844  GtkWindow *transient);
845 void do_info_dialog_with_transient(const gchar *text, boolean is_blocking, GtkWindow *transient);
846 
847 
848 void do_system_failed_error(const char *com, int retval, const char *addinfo);
849 int do_write_failed_error_s_with_retry(const gchar *fname, const gchar *errtext, GtkWindow *transient) WARN_UNUSED;
850 void do_write_failed_error_s(const char *filename, const char *addinfo);
851 int do_read_failed_error_s_with_retry(const gchar *fname, const gchar *errtext, GtkWindow *transient) WARN_UNUSED;
852 void do_read_failed_error_s(const char *filename, const char *addinfo);
853 boolean do_header_write_error(int clip);
854 int do_header_read_error_with_retry(int clip) WARN_UNUSED;
855 int do_header_missing_detail_error(int clip, lives_clip_details_t detail) WARN_UNUSED;
856 void do_chdir_failed_error(const char *dir);
857 void handle_backend_errors(void);
858 boolean check_backend_return(file *sfile);
859 
861 gchar *ds_critical_msg(const gchar *dir, guint64 dsval);
862 gchar *ds_warning_msg(const gchar *dir, guint64 dsval, guint64 cwarn, guint64 nwarn);
863 boolean check_storage_space(file *sfile, boolean is_processing);
864 
865 gchar *get_upd_msg(void);
866 gchar *get_new_install_msg(void);
867 
868 boolean ask_permission_dialog(int what);
869 boolean do_abort_check(void);
870 void add_warn_check (GtkBox *box, int warn_mask_number);
871 void do_memory_error_dialog (void);
872 void too_many_files(void);
873 void tempdir_warning (void);
874 void do_audio_import_error(void);
875 void do_mt_backup_space_error(lives_mt *, gint memreq_mb);
876 
877 boolean do_clipboard_fps_warning(void);
878 void perf_mem_warning(void);
879 void do_dvgrab_error(void);
880 boolean do_comments_dialog (file *sfile, gchar *filename);
881 boolean do_auto_dialog(const gchar *text, int type);
882 void do_encoder_acodec_error (void);
883 void do_encoder_sox_error(void);
884 boolean rdet_suggest_values (int width, int height, double fps, int fps_num, int fps_denom, int arate,
885  int asigned, boolean swap_endian, boolean anr, boolean ignore_fps);
886 boolean do_encoder_restrict_dialog (int width, int height, double fps, int fps_num, int fps_denom,
887  int arate, int asigned, boolean swap_endian, boolean anr, boolean save_all);
888 void do_keys_window (void);
889 void do_mt_keys_window (void);
890 void do_messages_window (void);
891 void do_firstever_dialog (void);
892 void do_upgrade_error_dialog(void);
893 void do_no_mplayer_sox_error(void);
894 void do_aud_during_play_error(void);
895 void do_rendered_fx_dialog(void);
896 void do_layout_scrap_file_error(void);
897 void do_layout_ascrap_file_error(void);
898 void do_set_load_lmap_error(void);
899 boolean do_set_duplicate_warning (const gchar *new_set);
900 boolean do_set_rename_old_layouts_warning(const gchar *new_set);
901 boolean do_layout_alter_frames_warning(void);
902 boolean do_layout_alter_audio_warning(void);
903 boolean do_yuv4m_open_warning(void);
904 void do_mt_undo_mem_error(void);
905 void do_mt_undo_buf_error(void);
906 void do_mt_set_mem_error(boolean has_mt, boolean trans);
907 void do_mt_audchan_error(int warn_mask);
908 void do_mt_no_audchan_error(void);
909 void do_mt_no_jack_error(int warn_mask);
910 boolean do_mt_rect_prompt(void);
911 void do_audrate_error_dialog(void);
912 boolean do_event_list_warning(void);
913 void do_nojack_rec_error(void);
914 void do_vpp_palette_error (void);
915 void do_vpp_fps_error (void);
916 void do_decoder_palette_error (void);
917 void do_rmem_max_error (gint size);
918 boolean do_original_lost_warning(const gchar *fname);
919 void do_no_decoder_error(const gchar *fname);
920 void do_jack_noopen_warn(void);
921 void do_jack_noopen_warn2(void);
922 void do_jack_noopen_warn3(void);
923 void do_jack_noopen_warn4(void);
924 void do_file_perm_error(const gchar *file_name);
925 void do_dir_perm_error(const gchar *dir_name);
926 void do_dir_perm_access_error(const gchar *dir_name);
928 void do_after_crash_warning (void);
929 void do_bad_layout_error(void);
930 void do_card_in_use_error(void);
931 void do_dev_busy_error(const gchar *devstr);
932 boolean do_existing_subs_warning(void);
933 void do_invalid_subs_error(void);
934 boolean do_erase_subs_warning(void);
935 boolean do_sub_type_warning(const gchar *ext, const gchar *type_ext);
936 boolean do_move_tmpdir_dialog(void);
937 void do_set_locked_warning (const gchar *setname);
938 void do_no_in_vdevs_error(void);
939 void do_locked_in_vdevs_error(void);
940 void do_do_not_close_d (void);
941 void do_set_noclips_error(const char *setname);
942 void do_no_autolives_error(void);
944 void do_pulse_lost_conn_error(void);
945 void do_jack_lost_conn_error(void);
946 
947 boolean process_one (boolean visible);
948 void do_threaded_dialog(gchar *translated_text, boolean has_cancel);
949 void end_threaded_dialog(void);
950 void threaded_dialog_spin (void);
951 void response_ok (GtkButton *button, gpointer user_data);
952 void pump_io_chan(GIOChannel *iochan);
953 
954 void do_splash_progress(void);
955 
956 
957 // d_print shortcuts
958 void d_print_cancelled(void);
959 void d_print_failed(void);
960 void d_print_done(void);
961 void d_print_file_error_failed(void);
962 
963 // general
964 void do_text_window (const gchar *title, const gchar *text);
965 
966 // saveplay.c
967 boolean read_file_details(const gchar *file_name, boolean only_check_for_audio);
968 boolean add_file_info(const gchar *check_handle, boolean aud_only);
969 boolean save_file_comments (int fileno);
970 void reget_afilesize (int fileno);
971 void deduce_file(const gchar *filename, double start_time, int end);
972 void open_file (const gchar *filename);
973 void open_file_sel(const gchar *file_name, double start_time, int frames);
974 void open_fw_device (void);
975 boolean get_new_handle(int index, const gchar *name);
976 boolean get_temp_handle(int index, boolean create);
977 boolean get_handle_from_info_file(int index);
978 void create_cfile(void);
979 void save_file (int clip, int start, int end, const char *filename);
980 void play_file (void);
981 void save_frame (GtkMenuItem *menuitem, gpointer user_data);
982 boolean save_frame_inner(int clip, int frame, const gchar *file_name, int width, int height, boolean from_osc);
983 void wait_for_stop (const gchar *stop_command);
984 boolean save_clip_values(int which_file);
985 void add_to_recovery_file (const gchar *handle);
986 void rewrite_recovery_file(void);
987 boolean check_for_recovery_files (boolean auto_recover);
988 void recover_layout_map(int numclips);
989 const gchar *get_deinterlace_string(void);
990 
991 // saveplay.c backup
992 void backup_file(int clip, int start, int end, const gchar *filename);
993 gint save_event_frames(void);
994 boolean write_headers (file *file);
995 
996 // saveplay.c restore
997 void restore_file(const gchar *filename);
998 boolean read_headers(const gchar *file_name);
999 
1000 // saveplay.c sets
1001 void open_set_file (const gchar *set_name, gint clipnum);
1002 
1003 
1004 // saveplay.c scrap file
1005 boolean open_scrap_file (void);
1006 boolean open_ascrap_file (void);
1007 int save_to_scrap_file (weed_plant_t *layer);
1008 boolean load_from_scrap_file(weed_plant_t *layer, int frame);
1009 void close_ascrap_file (void);
1010 void close_scrap_file (void);
1011 
1012 
1013 // main.c
1014 typedef void (*SignalHandlerPointer)(int);
1015 
1017 void catch_sigint(int signum);
1018 void defer_sigint(int signum);
1019 boolean startup_message_fatal(const gchar *msg);
1020 boolean startup_message_nonfatal(const gchar *msg);
1021 boolean startup_message_info(const gchar *msg);
1022 boolean startup_message_nonfatal_dismissable(const gchar *msg, gint warning_mask);
1024 void get_monitors(void);
1025 void set_ce_frame_from_pixbuf(GtkImage *image, GdkPixbuf *pixbuf, lives_painter_t *);
1026 void load_start_image(gint frame);
1027 void load_end_image(gint frame);
1028 void load_preview_image(boolean update_always);
1029 
1030 boolean pull_frame(weed_plant_t *layer, const gchar *image_ext, weed_timecode_t tc);
1031 boolean pull_frame_at_size (weed_plant_t *layer, const gchar *image_ext, weed_timecode_t tc,
1032  int width, int height, int target_palette);
1033 LiVESPixbuf *pull_lives_pixbuf_at_size(int clip, int frame, const char *image_ext, weed_timecode_t tc,
1034  int width, int height, LiVESInterpType interp);
1035 LiVESPixbuf *pull_lives_pixbuf(int clip, int frame, const char *image_ext, weed_timecode_t tc);
1036 
1037 GError * lives_pixbuf_save(GdkPixbuf *pixbuf, gchar *fname, lives_image_type_t imgtype,
1038  int quality, boolean do_chmod, GError **gerrorptr);
1039 
1040 void load_frame_image(gint frame);
1041 void sensitize(void);
1042 void desensitize(void);
1043 void procw_desensitize(void);
1044 void close_current_file (gint file_to_switch_to);
1045 void get_next_free_file(void);
1046 void switch_to_file(gint old_file, gint new_file);
1047 void do_quick_switch (gint new_file);
1048 void switch_audio_clip(gint new_file, boolean activate);
1049 void resize (gdouble scale);
1050 void do_start_messages(void);
1051 void set_palette_colours (void);
1052 void set_main_title(const gchar *filename, gint or_untitled_number);
1053 void set_record (void);
1054 
1055 //gui.c
1056 void create_LiVES (void);
1057 void enable_record (void);
1058 void toggle_record (void);
1059 void disable_record (void);
1060 void make_custom_submenus(void);
1061 void fade_background(void);
1062 void unfade_background(void);
1063 void block_expose (void);
1064 void unblock_expose (void);
1065 void frame_size_update(void);
1066 void splash_init(void);
1067 void splash_end(void);
1068 void splash_msg(const gchar *msg, double pct);
1069 void add_message_scroller(GtkWidget *conter);
1071 #if GTK_CHECK_VERSION(3,0,0)
1072 void calibrate_sepwin_size(void);
1073 boolean expose_pim (GtkWidget *widget, lives_painter_t *cr, gpointer user_data);
1074 boolean expose_sim (GtkWidget *widget, lives_painter_t *cr, gpointer user_data);
1075 boolean expose_eim (GtkWidget *widget, lives_painter_t *cr, gpointer user_data);
1076 #endif
1077 // system calls in utils.c
1078 int lives_system(const char *com, boolean allow_error);
1079 lives_pid_t lives_fork(const char *com);
1080 ssize_t lives_write(int fd, const void *buf, size_t count, boolean allow_fail);
1081 ssize_t lives_write_le(int fd, const void *buf, size_t count, boolean allow_fail);
1082 ssize_t lives_read(int fd, void *buf, size_t count, boolean allow_less);
1083 ssize_t lives_read_le(int fd, void *buf, size_t count, boolean allow_less);
1084 int lives_chdir(const char *path, boolean allow_fail);
1085 int lives_fputs(const char *s, FILE *stream);
1086 char *lives_fgets(char *s, int size, FILE *stream);
1087 pid_t lives_getpid(void);
1088 int lives_getgid(void);
1089 int lives_getuid(void);
1090 void lives_freep(void **ptr);
1091 void lives_free(gpointer ptr);
1092 void lives_free_with_check(gpointer ptr);
1093 #ifdef IS_MINGW
1094 boolean lives_win32_suspend_resume_process(DWORD pid, boolean suspend);
1095 boolean lives_win32_kill_subprocesses(DWORD pid, boolean kill_parent);
1096 int lives_win32_get_num_logical_cpus(void);
1097 #endif
1098 int lives_kill(lives_pid_t pid, int sig);
1099 int lives_killpg(lives_pgid_t pgrp, int sig);
1100 void lives_srandom(unsigned int seed);
1101 uint64_t lives_random(void);
1102 ssize_t lives_readlink(const char *path, char *buf, size_t bufsiz);
1103 boolean lives_setenv(const char *name, const char *value);
1104 boolean lives_fsync(int fd);
1105 void lives_sync(void);
1106 
1107 char *filename_from_fd(char *val, int fd);
1108 
1109 float LEFloat_to_BEFloat(float f);
1110 uint64_t lives_10pow(int pow);
1111 int get_approx_ln(guint val);
1112 
1113 int64_t lives_get_current_ticks(void);
1114 boolean lives_alarm_get(int alarm_handle);
1115 int lives_alarm_set(int64_t ticks);
1116 void lives_alarm_clear(int alarm_handle);
1117 lives_storage_status_t get_storage_status(const char *dir, guint64 warn_level, guint64 *dsval);
1118 gchar *lives_format_storage_space_string(guint64 space);
1119 
1120 
1121 int myround(double n);
1122 void get_dirname(gchar *filename);
1123 gchar *get_dir(const gchar *filename);
1124 void get_basename(gchar *filename);
1125 void get_filename(gchar *filename, boolean strip_dir);
1126 gchar *get_extension(const gchar *filename);
1127 uint64_t get_version_hash(const gchar *exe, const gchar *sep, int piece);
1128 uint64_t make_version_hash(const char *ver);
1129 void d_print(const gchar *text);
1130 void init_clipboard(void);
1131 boolean cache_file_contents(const gchar *filename);
1132 gchar *get_val_from_cached_list(const gchar *key, size_t maxlen);
1133 
1134 void get_location(const gchar *exe, gchar *val, int maxlen);
1135 
1136 void set_menu_text(GtkWidget *menu, const gchar *text, boolean use_mnemonic);
1137 void get_menu_text(GtkWidget *menu, gchar *text);
1138 void get_menu_text_long(GtkWidget *menuitem, gchar *text);
1139 void reset_clip_menu (void);
1140 void get_play_times(void);
1141 void get_total_time (file *file);
1142 guint get_signed_endian (boolean is_signed, boolean little_endian);
1143 void fullscreen_internal(void);
1144 void colour_equal(GdkColor *c1, const GdkColor *c2);
1145 void switch_to_int_player(void);
1146 void switch_to_mplayer(void);
1147 void switch_aud_to_sox(boolean set_pref);
1148 boolean switch_aud_to_jack(void);
1149 boolean switch_aud_to_pulse(void);
1150 void switch_aud_to_mplayer(boolean set_pref);
1151 boolean prepare_to_play_foreign(void);
1152 boolean after_foreign_play(void);
1153 boolean check_file(const gchar *file_name, boolean check_exists);
1154 boolean check_dir_access (const gchar *dir);
1155 uint64_t get_file_size(int fd);
1156 uint64_t sget_file_size(const gchar *name);
1157 uint64_t get_fs_free(const char *dir);
1158 boolean is_writeable_dir(const char *dir);
1159 boolean ensure_isdir(gchar *fname);
1160 gchar *ensure_extension(const gchar *fname, const gchar *ext) WARN_UNUSED;
1161 boolean check_dev_busy(gchar *devstr);
1162 void activate_url_inner(const gchar *link);
1163 void activate_url (GtkAboutDialog *about, const gchar *link, gpointer data);
1164 void show_manual_section (const gchar *lang, const gchar *section);
1165 
1166 double calc_time_from_frame (int clip, int frame);
1167 gint calc_frame_from_time (int filenum, double time);
1168 gint calc_frame_from_time2 (int filenum, double time);
1169 gint calc_frame_from_time3 (int filenum, double time);
1170 
1171 boolean check_for_ratio_fps (double fps);
1172 double get_ratio_fps(const gchar *string);
1173 void calc_maxspect(gint rwidth, gint rheight, gint *cwidth, gint *cheight);
1174 
1175 gchar *remove_trailing_zeroes(gdouble val);
1176 
1177 void remove_layout_files(GList *lmap);
1178 gboolean add_lmap_error(lives_lmap_error_t lerror, const gchar *name, gpointer user_data,
1179  gint clipno, gint frameno, gdouble atime, gboolean affects_current);
1180 void clear_lmap_errors(void);
1181 gboolean prompt_remove_layout_files(void);
1182 gboolean is_legal_set_name(const gchar *set_name, gboolean allow_dupes);
1183 gchar *repl_tmpdir(const gchar *entry, gboolean fwd);
1184 gchar *clip_detail_to_string(lives_clip_details_t what, size_t *maxlenp);
1185 gboolean get_clip_value(int which, lives_clip_details_t, void *retval, size_t maxlen);
1186 void save_clip_value(int which, lives_clip_details_t, void *val);
1187 gboolean check_frame_count(gint idx);
1188 void get_frame_count(gint idx);
1189 void get_frames_sizes(int fileno, int frame_to_test);
1190 gint count_resampled_frames (gint in_frames, gdouble orig_fps, gdouble resampled_fps);
1191 boolean int_array_contains_value(int *array, int num_elems, int value);
1192 gboolean check_for_lock_file(const gchar *set_name, gint type);
1193 void g_list_free_strings(GList *list);
1194 
1195 gboolean create_event_space(gint length_in_eventsb);
1196 void add_to_recent(const gchar *filename, gdouble start, gint frames, const gchar *file_open_params);
1197 gint verhash (gchar *version);
1198 void set_undoable (const gchar *what, gboolean sensitive);
1199 void set_redoable (const gchar *what, gboolean sensitive);
1200 void zero_spinbuttons (void);
1201 void draw_little_bars (gdouble ptrtime);
1202 void set_sel_label (GtkWidget *label);
1203 void clear_mainw_msg (void);
1204 int get_token_count (const gchar *string, int delim);
1205 LiVESPixbuf *lives_pixbuf_new_blank(int width, int height, int palette);
1206 gchar *g_strappend (gchar *string, gint len, const gchar *newbit);
1207 GList *g_list_append_unique(GList *xlist, const gchar *add);
1208 void find_when_to_stop (void);
1209 int calc_new_playback_position(int fileno, uint64_t otc, uint64_t *ntc);
1210 void calc_aframeno(gint fileno);
1211 void minimise_aspect_delta (gdouble allowed_aspect,gint hblock,gint vblock,gint hsize,gint vsize,gint *width,gint *height);
1212 LiVESInterpType get_interp_value(gshort quality);
1213 
1214 GList *g_list_move_to_first(GList *list, GList *item) WARN_UNUSED;
1215 GList *g_list_delete_string(GList *, char *string) WARN_UNUSED;
1216 GList *g_list_copy_strings(GList *list);
1217 gboolean string_lists_differ(GList *, GList *);
1218 
1219 
1220 GList *get_set_list(const gchar *dir);
1221 
1222 gchar *subst (const gchar *string, const gchar *from, const gchar *to);
1223 gchar *insert_newlines(const gchar *text, int maxwidth);
1224 
1225 gint hextodec (const gchar *string);
1226 gint get_hex_digit (const gchar *c);
1227 
1228 const char *get_image_ext_for_type(lives_image_type_t imgtype);
1229 
1230 guint32 fastrand(void);
1231 void fastsrand(guint32 seed);
1232 
1233 gint lives_list_index (GList *list, const gchar *data);
1234 
1236 
1237 // plugins.c
1239 gboolean check_encoder_restrictions (boolean get_extension, boolean user_audio, boolean save_all);
1240 
1241 //callbacks.c
1242 void lives_exit (void);
1243 void count_opening_frames(void);
1244 void on_fileread_clicked (GtkFileChooser *, gpointer widget);
1245 gboolean dirchange_callback (GtkAccelGroup *, GObject *, guint, GdkModifierType, gpointer user_data);
1246 void on_effects_paused (GtkButton *, gpointer user_data);
1247 void on_cancel_keep_button_clicked (GtkButton *, gpointer user_data);
1248 void on_cleardisk_activate (GtkWidget *, gpointer user_data);
1249 void on_cleardisk_advanced_clicked (GtkWidget *, gpointer user_data);
1250 void popup_lmap_errors(GtkMenuItem *, gpointer);
1251 void on_filesel_button_clicked (GtkButton *button, gpointer user_data);
1252 
1253 
1254 //preferences.c
1255 void get_pref(const gchar *key, gchar *val, int maxlen);
1256 void get_pref_utf8(const gchar *key, gchar *val, int maxlen);
1257 void get_pref_default(const gchar *key, gchar *val, int maxlen);
1258 boolean get_boolean_pref(const gchar *key);
1259 double get_double_pref(const gchar *key);
1260 int get_int_pref(const gchar *key);
1261 GList *get_list_pref(const gchar *key);
1262 void set_pref (const gchar *key, const gchar *value);
1263 void delete_pref (const gchar *key);
1264 void set_boolean_pref(const gchar *key, boolean value);
1265 void set_double_pref(const gchar *key, double value);
1266 void set_int_pref(const gchar *key, int value);
1267 void set_int64_pref(const gchar *key, int64_t value);
1268 void set_list_pref(const char *key, GList *values);
1269 boolean apply_prefs(boolean skip_warnings);
1270 void save_future_prefs(void);
1271 
1272 
1273 // paramspecial.c
1274 LiVESPixbuf *mt_framedraw(lives_mt *, LiVESPixbuf *);
1275 
1276 // rte_window.c
1277 void refresh_rte_window (void);
1278 
1279 // effects-weed.c
1280 void * lives_malloc(size_t size);
1281 void *lives_memcpy(void *dest, const void *src, size_t n);
1282 void *lives_memset(void *s, int c, size_t n);
1283 void lives_free(void *ptr);
1284 void *lives_calloc(size_t nmemb, size_t size);
1285 
1287 void lives_free_normal(void *ptr);
1288 void lives_free_with_check(gpointer ptr);
1289 
1290 // pangotext.c
1291 gboolean subtitles_init(file *sfile, char * fname, lives_subtitle_type_t);
1292 void subtitles_free(file *sfile);
1293 gboolean get_srt_text(file *sfile, double xtime);
1294 gboolean get_sub_text(file *sfile, double xtime);
1295 gboolean save_sub_subtitles(file *sfile, double start_time, double end_time, double offset_time, const char *filename);
1296 gboolean save_srt_subtitles(file *sfile, double start_time, double end_time, double offset_time, const char *filename);
1297 
1298 // osc.c
1299 #ifdef ENABLE_OSC
1300 gboolean lives_osc_init(guint osc_udp_port);
1301 gint lives_osc_poll(gpointer data);
1302 void lives_osc_end(void);
1303 gboolean lives_osc_notify(int msgtype, const char *msgstring);
1304 void lives_osc_notify_success (const gchar *msg);
1305 void lives_osc_notify_failure (void);
1306 void lives_osc_notify_cancel (void);
1307 #include "osc_notify.h"
1308 #endif
1309 
1310 // ldvgrab.c
1311 #ifdef HAVE_LDVGRAB
1312 void on_open_fw_activate (GtkMenuItem *menuitem, gpointer format);
1313 
1314 #define CAM_FORMAT_DV 0
1315 #define CAM_FORMAT_HDV 1
1316 
1317 #endif
1318 
1319 // inlines
1320 #define cfile mainw->files[mainw->current_file]
1321 #define clipboard mainw->files[0]
1322 
1323 #define U82L(String) ( g_locale_from_utf8 (String,-1,NULL,NULL,NULL) )
1324 #define L2U8(String) ( g_locale_to_utf8 (String,-1,NULL,NULL,NULL) )
1325 
1326 
1327 #define PREFS_TIMEOUT 10000000
1328 
1329 #define LIVES_TV_CHANNEL1 "http://www.serverwillprovide.com/sorteal/livestvclips/livestv.ogm"
1330 
1331 
1332 // round (double) a up to next (integer) multiple of (double) b
1333 #define CEIL(a,b) ((int)(((double)a+(double)b-.000000001)/((double)b))*b)
1334 
1335 
1336 gchar *dummychar;
1337 
1338 #define LIVES_NO_DEBUG
1339 #ifndef LIVES_DEBUG
1340 #ifndef LIVES_NO_DEBUG
1341 #define LIVES_DEBUG(x) fprintf(stderr, "LiVES debug: %s\n", x)
1342 #else // LIVES_NO_DEBUG
1343 #define LIVES_DEBUG(x) dummychar = x
1344 #endif // LIVES_NO_DEBUG
1345 #endif // LIVES_DEBUG
1346 
1347 #ifndef LIVES_INFO
1348 #ifndef LIVES_NO_INFO
1349 #define LIVES_INFO(x) fprintf(stderr, "LiVES info: %s\n", x)
1350 #else // LIVES_NO_INFO
1351 #define LIVES_INFO(x) dummychar = x
1352 #endif // LIVES_NO_INFO
1353 #endif // LIVES_INFO
1354 
1355 #ifndef LIVES_WARN
1356 #ifndef LIVES_NO_WARN
1357 #define LIVES_WARN(x) fprintf(stderr, "LiVES warning: %s\n", x)
1358 #else // LIVES_NO_WARN
1359 #define LIVES_WARN(x) dummychar = x
1360 #endif // LIVES_NO_WARN
1361 #endif // LIVES_WARN
1362 
1363 #ifndef LIVES_ERROR
1364 #ifndef LIVES_NO_ERROR
1365 #define LIVES_ERROR(x) fprintf(stderr, "LiVES error: %s\n", x)
1366 #else // LIVES_NO_ERROR
1367 #define LIVES_ERROR(x) dummychar = x
1368 #endif // LIVES_NO_ERROR
1369 #endif // LIVES_ERROR
1370 
1371 #ifndef LIVES_FATAL
1372 #ifndef LIVES_NO_FATAL
1373 #define LIVES_FATAL(x) {fprintf(stderr, "LiVES fatal: %s\n", x); raise (LIVES_SIGSEGV);}
1374 #else // LIVES_NO_FATAL
1375 #define LIVES_FATAL(x) dummychar = x
1376 #endif // LIVES_NO_FATAL
1377 #endif // LIVES_FATAL
1378 
1379 
1380 #endif // #ifndef HAS_LIVES_MAIN_H
1381