LiVES  2.4.1-svn
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
liblives.hpp
Go to the documentation of this file.
1 // liblives.hpp
2 // LiVES (lives-exe)
3 // (c) G. Finch <salsaman@gmail.com> 2015
4 // Released under the GPL 3 or later
5 // see file ../COPYING for licensing details
6 
11 #ifndef HAS_LIBLIVES_H
12 #define HAS_LIBLIVES_H
13 
17 #define LIVES_VERSION_MAJOR 2
18 
22 #define LIVES_VERSION_MINOR 4
23 
27 #define LIVES_VERSION_MICRO 1
28 
32 #define LIVES_CHECK_VERSION(major, minor, micro) (major > LIVES_VERSION_MAJOR || (major == LIVES_VERSION_MAJOR && (minor > LIVES_VERSION_MINOR || (minor == LIVES_VERSION_MINOR && micro >= LIVES_VERSION_MICRO))))
33 
34 
35 // defs shared with lbindings.c
36 
40 typedef enum {
43  // LIVES_FILE_CHOOSER_VIDEO_AUDIO_MULTI, ///< file chooser options for multiple video or audio files
44  //LIVES_FILE_CHOOSER_VIDEO_RANGE ///< file chooser options for video range (start time/number of frames)
46 
50 typedef enum {
55 
56 
60 typedef enum {
68 
69 
73 typedef enum {
77 
78 
82 typedef enum {
89 
92 
94 
97 
98 
101 
103 
105 
106 #ifndef DOXYGEN_SKIP
108 #endif
110 
111 
112 
116 typedef enum {
120  //LIVES_CHAR_ENCODING_UTF16, ///< UTF-16 char encoding
122 
126 #define LIVES_CHAR_ENCODING_DEFAULT LIVES_CHAR_ENCODING_UTF8
127 
131 typedef enum {
132 // positive values for custom responses
145 
146 
150 typedef enum {
155 
156 
160 typedef enum {
168 
169 
170 
174 typedef enum {
177 
178 
179 
183 typedef enum {
188 
189 
190 
194 typedef enum {
199 
200 
202 
203 #ifdef __cplusplus
204 
205 #include <vector>
206 #include <list>
207 #include <map>
208 
209 #include <inttypes.h>
210 
211 #include <string>
212 
216 typedef unsigned long ulong;
217 
218 
219 #ifndef DOXYGEN_SKIP
220 extern "C" {
221  void binding_cb (lives_callback_t cb_type, const char *msgstring, uint64_t id);
222 }
223 #endif
224 
225 using namespace std;
226 
228 
229 
230 
231 
232 
236 namespace lives {
237 
239 
243  typedef class livesApp livesApp;
244 
248  typedef class set set;
249 
253  typedef class clip clip;
254 
258  typedef class effectKey effectKey;
259 
263  typedef class effectKeyMap effectKeyMap;
264 
268  typedef class effect effect;
269 
270 
274  typedef class player player;
275 
276 
280  typedef class multitrack multitrack;
281 
282 
286  typedef class block block;
287 
288 
292  typedef class livesString livesString;
293 
294 
295  typedef list<livesString> livesStringList;
296 
297 
299 
300 
305  class livesString : public std::string {
306  public:
307  livesString(const string& str="", lives_char_encoding_t e=LIVES_CHAR_ENCODING_DEFAULT) : m_encoding(e), std::string(str) {}
308  livesString(const string& str, size_t pos, size_t len = npos, lives_char_encoding_t e=LIVES_CHAR_ENCODING_DEFAULT) : m_encoding(e),
309  std::string(str, pos, len) {}
310  livesString(const char* s, lives_char_encoding_t e=LIVES_CHAR_ENCODING_DEFAULT) : m_encoding(e), std::string(s) {}
311  livesString(const char* s, size_t n, lives_char_encoding_t e=LIVES_CHAR_ENCODING_DEFAULT) : m_encoding(e), std::string(s, n) {}
312  livesString(size_t n, char c, lives_char_encoding_t e=LIVES_CHAR_ENCODING_DEFAULT) : m_encoding(e), std::string(n, c) {}
313  template <class InputIterator>
314  livesString (InputIterator first, InputIterator last,
315  lives_char_encoding_t e=LIVES_CHAR_ENCODING_DEFAULT) : m_encoding(e), std::string(first, last) {}
316 
322  livesString toEncoding(lives_char_encoding_t enc);
323 
328  void setEncoding(lives_char_encoding_t enc);
329 
334  lives_char_encoding_t encoding();
335 
336  private:
337  lives_char_encoding_t m_encoding;
338  };
339 
340 #ifndef DOXYGEN_SKIP
341  typedef void *(*callback_f)(void *);
342 
343  typedef struct {
344  ulong id;
345  livesApp *object;
346  lives_callback_t cb_type;
347  callback_f func;
348  void *data;
349  } closure;
350 
351  typedef list<closure *> closureList;
352  typedef list<closure *>::iterator closureListIterator;
353 #endif
354 
358  typedef struct {
360  } modeChangedInfo;
361 
362 
366  typedef struct {
367  int signum;
368  } appQuitInfo;
369 
370 
371 #ifndef DOXYGEN_SKIP
372  typedef struct {
373  ulong id;
374  char *response;
375  } _privateInfo;
376 
377 
378  typedef bool (*private_callback_f)(_privateInfo *, void *);
379 #endif
380 
386  typedef bool (*modeChanged_callback_f)(livesApp *, modeChangedInfo *, void *);
387 
393  typedef bool (*appQuit_callback_f)(livesApp *, appQuitInfo *, void *);
394 
395 
401  typedef bool (*objectDestroyed_callback_f)(livesApp *, void *);
402 
403 
404 
410  class livesApp {
411  friend set;
412  friend clip;
413  friend effectKeyMap;
414  friend effectKey;
415  friend player;
416  friend multitrack;
417  friend block;
418 
419  public:
423  livesApp();
424 
431  livesApp(int argc, char *argv[]);
432 
437  ~livesApp();
438 
444  bool isValid() const;
445 
450  bool isReady() const;
451 
457  bool isPlaying() const;
458 
462  const set& getSet();
463 
467  const effectKeyMap& getEffectKeyMap();
468 
472  const player& getPlayer();
473 
477  const multitrack& getMultitrack();
478 
484  bool removeCallback(ulong id) const;
485 
495  ulong addCallback(lives_callback_t cb_type, modeChanged_callback_f func, void *data) const;
496 
506  ulong addCallback(lives_callback_t cb_type, appQuit_callback_f func, void *data) const;
507 
517  ulong addCallback(lives_callback_t cb_type, objectDestroyed_callback_f func, void *data) const;
518 
526  lives_dialog_response_t showInfo(livesString text, bool blocking=true);
527 
541  livesString chooseFileWithPreview(livesString dirname, lives_filechooser_t chooser_type, livesString title=livesString(""));
542 
557  clip openFile(livesString fname, bool with_audio=true, double stime=0., int frames=0, bool deinterlace=false);
558 
567  livesStringList availableSets();
568 
579  livesString chooseSet();
580 
591  bool reloadSet(livesString setname);
592 
600  bool setInteractive(bool);
601 
607  bool interactive();
608 
615  bool deinterlaceOption();
616 
623  lives_interface_mode_t mode();
624 
633  lives_interface_mode_t setMode(lives_interface_mode_t);//, livesMultitrackSettings settings=NULL);
634 
641  lives_status_t status() const;
642 
647  bool cancel();
648 
649 
650 
651 #ifndef DOXYGEN_SKIP
652  // For internal use only.
653  closureList& closures();
654  void invalidate();
655  void setClosures(closureList cl);
656 
657  bool setPref(int prefidx, bool val) const;
658  bool setPref(int prefidx, int val) const;
659  bool setPref(int prefidx, int bitfield, bool val) const;
660 
661 #endif
662 
663  protected:
664  ulong addCallback(lives_callback_t cb_type, private_callback_f func, void *data) const;
665 
666  private:
667  ulong m_id;
668  closureList m_closures;
669  set * m_set;
670  player *m_player;
671  effectKeyMap * m_effectKeyMap;
672  multitrack *m_multitrack;
673 
674  pthread_t *m_thread;
675 
676  bool m_deinterlace;
677 
678  ulong appendClosure(lives_callback_t cb_type, callback_f func, void *data) const;
679  void init(int argc, char *argv[]);
680 
681  void operator=(livesApp const&); // Don't implement
682  livesApp(const livesApp &other); // Don't implement
683 
684  };
685 
686 
687 
688 
697  class clip {
698  friend livesApp;
699  friend set;
700  friend block;
701  friend multitrack;
702  friend player;
703 
704  public:
705 
709  clip();
710 
717  bool isValid() const;
718 
725  int frames();
726 
733  int width();
734 
741  int height();
742 
749  double FPS();
750 
760  double playbackFPS();
761 
767  livesString name();
768 
777  int audioRate();
778 
788  int playbackAudioRate();
789 
796  int audioChannels();
797 
804  int audioSampleSize();
805 
811  bool audioSigned();
812 
818  lives_endian_t audioEndian();
819 
820 
826  double audioLength();
827 
834  int selectionStart();
835 
842  int selectionEnd();
843 
844 
850  bool selectAll();
851 
859  bool setSelectionStart(unsigned int start);
860 
868  bool setSelectionEnd(unsigned int end);
869 
878  bool switchTo();
879 
887  bool setIsBackground();
888 
892  inline bool operator==(const clip& other) {
893  return other.m_uid == m_uid && m_lives == other.m_lives;
894  }
895 
896  protected:
897  clip(ulong uid, livesApp *lives=NULL);
898  ulong m_uid;
899 
900  private:
901  livesApp *m_lives;
902 
903  };
904 
905 
906 
907 #ifndef DOXYGEN_SKIP
908  typedef vector<ulong> clipList;
909  typedef vector<ulong>::iterator clipListIterator;
910 #endif
911 
913 
914 
920  class set {
921  friend livesApp;
922 
923  public:
924 
930  bool isValid() const;
931 
937  livesString name() const;
938 
949  bool setName(livesString name=livesString()) const;
950 
962  bool save(livesString name, bool force_append=false) const;
963 
969  bool save() const;
970 
977  unsigned int numClips() const;
978 
985  clip nthClip(unsigned int n) const;
986 
994  int indexOf(clip c) const;
995 
1001  livesStringList layoutNames(unsigned int n) const;
1002 
1006  inline bool operator==(const set& other) const {
1007  return other.m_lives == m_lives;
1008  }
1009 
1010 
1011  protected:
1012  set(livesApp *lives=NULL);
1013 
1014  private:
1015  livesApp *m_lives;
1016  clipList m_clips;
1017 
1018  void update_clip_list(void);
1019 
1020 
1021  };
1022 
1023 
1024 
1025 
1026 
1032  class player {
1033  friend livesApp;
1034 
1035  public:
1036 
1042  bool isValid() const;
1043 
1047  bool isPlaying() const;
1048 
1049 
1053  bool isRecording() const;
1054 
1063  void setSepWin(bool) const;
1064 
1069  bool sepWin() const;
1070 
1077  void setFullScreen(bool) const;
1078 
1083  bool fullScreen() const;
1084 
1093  void setFS(bool) const;
1094 
1100  bool play() const;
1101 
1107  bool stop() const;
1108 
1118  bool setForegroundClip(clip c) const;
1119 
1127  clip foregroundClip() const;
1128 
1138  bool setBackgroundClip(clip c) const;
1139 
1147  clip backgroundClip() const;
1148 
1163  double setPlaybackStartTime(double time) const;
1164 
1177  int setVideoPlaybackFrame(int frame, bool background=false) const;
1178 
1194  double videoPlaybackTime(bool background=false) const;
1195 
1207  double setAudioPlaybackTime(double time) const;
1208 
1222  double audioPlaybackTime() const;
1223 
1232  double elapsedTime() const;
1233 
1245  double setCurrentFPS(double fps) const;
1246 
1255  double currentFPS() const;
1256 
1265  int currentAudioRate() const;
1266 
1275  lives_loop_mode_t setLoopMode(lives_loop_mode_t) const;
1276 
1283  lives_loop_mode_t loopMode() const;
1284 
1294  bool setPingPong(bool) const;
1295 
1305  bool pingPong() const;
1306 
1314  bool resyncFPS() const;
1315 
1316 
1320  inline bool operator==(const player& other) const {
1321  return other.m_lives == m_lives;
1322  }
1323 
1324 
1325  protected:
1326  player(livesApp *lives=NULL);
1327 
1328  private:
1329  livesApp *m_lives;
1330 
1331  };
1332 
1334 
1341  class effectKey {
1342  friend effectKeyMap;
1343  public:
1347  effectKey();
1348 
1355  bool isValid() const;
1356 
1364  int key();
1365 
1372  int numModes();
1373 
1380  int numMappedModes();
1381 
1391  int setCurrentMode(int mode);
1392 
1399  int currentMode();
1400 
1409  bool setEnabled(bool);
1410 
1417  bool enabled();
1418 
1427  int appendMapping(effect e);
1428 
1440  bool removeMapping(int mode);
1441 
1448  effect at(int mode);
1449 
1453  inline bool operator==(const effectKey& other) {
1454  return other.m_key == m_key && m_lives == other.m_lives;
1455  }
1456 
1457  protected:
1458  effectKey(livesApp *lives, int key);
1459 
1460  private:
1461  int m_key;
1462  livesApp *m_lives;
1463 
1464  };
1465 
1466 
1467 
1474  class effectKeyMap {
1475  friend livesApp;
1476  public:
1483  bool isValid() const;
1484 
1490  bool clear() const;
1491 
1500  effectKey at(int i) const;
1501 
1509  size_t size() const;
1510 
1514  inline bool operator==(const effectKeyMap& other) const {
1515  return other.m_lives == m_lives;
1516  }
1517 
1524  inline effectKey operator [] (int i) const {
1525  return effectKey(m_lives, i);
1526  }
1527 
1528 
1529  protected:
1530  effectKeyMap(livesApp *lives);
1531 
1532  private:
1533  livesApp *m_lives;
1534  };
1535 
1536 
1537 
1542  class effect {
1543  friend effectKey;
1544  friend multitrack;
1545  public:
1560  effect(const livesApp &lives, livesString hashname, bool match_full=false);
1561 
1577  effect(const livesApp &lives, livesString package, livesString fxname, livesString author=livesString(), int version=0);
1578 
1585  bool isValid() const;
1586 
1590  inline bool operator==(const effect& other) {
1591  return other.m_idx == m_idx && m_lives == other.m_lives;
1592  }
1593 
1594  protected:
1595  effect();
1596  effect(livesApp *m_lives, int idx);
1597  livesApp *m_lives;
1598  int m_idx;
1599 
1600  private:
1601 
1602  };
1603 
1604 
1605 
1611  class block {
1612  friend multitrack;
1613 
1614  public:
1615 
1622  bool isValid() const;
1623 
1631  block(multitrack m, int track, double time);
1632 
1638  double startTime();
1639 
1645  double length();
1646 
1652  clip clipSource();
1653 
1660  int track();
1661 
1671  bool remove();
1672 
1686  bool moveTo(int track, double time);
1687 
1688 
1689 
1690  protected:
1691  block(multitrack *m=NULL, ulong uid=0l);
1692 
1693 
1694  private:
1695  ulong m_uid;
1696  livesApp *m_lives;
1697 
1698  void invalidate();
1699  };
1700 
1701 
1702 
1707  class multitrack {
1708  friend livesApp;
1709  friend block;
1710 
1711  public:
1712 
1718  bool isValid() const;
1719 
1724  bool isActive() const;
1725 
1733  bool setCurrentTrack(int track) const;
1734 
1743  int currentTrack() const;
1744 
1755  double setCurrentTime(double time) const;
1756 
1767  double currentTime() const;
1768 
1775  livesString trackLabel(int track) const;
1776 
1786  bool setTrackLabel(int track, livesString label=livesString()) const;
1787 
1795  lives_gravity_t gravity() const;
1796 
1804  lives_gravity_t setGravity(lives_gravity_t) const;
1805 
1813  lives_insert_mode_t insertMode() const;
1814 
1822  lives_insert_mode_t setInsertMode(lives_insert_mode_t) const;
1823 
1824 
1830  int addVideoTrack(bool in_front) const;
1831 
1832 
1838  int numVideoTracks() const;
1839 
1840 
1845  int numAudioTracks() const;
1846 
1847 
1853  double FPS() const;
1854 
1879  block insertBlock(clip c, bool ignore_selection_limits=false, bool without_audio=false) const;
1880 
1890  livesString wipeLayout(bool force=false) const;
1891 
1899  livesString chooseLayout() const;
1900 
1907  livesStringList availableLayouts() const;
1908 
1921  bool reloadLayout(livesString filename) const;
1922 
1938  livesString saveLayout(livesString name) const;
1939 
1955  livesString saveLayout() const;
1956 
1967  clip render(bool render_audio=true, bool normalise_audio=true) const;
1968 
1977  effect autoTransition() const;
1978 
1986  bool disableAutoTransition() const;
1987 
1998  bool setAutoTransition(effect autotrans) const;
1999 
2003  inline bool operator==(const multitrack& other) const {
2004  return m_lives == other.m_lives;
2005  }
2006 
2007 
2008  protected:
2009  multitrack(livesApp *lives=NULL);
2010  livesApp *m_lives;
2011 
2012 
2013  };
2014 
2015 
2016 
2017 
2018 
2019 
2025  namespace prefs {
2030  livesString currentVideoLoadDir(const livesApp &lives);
2031 
2036  livesString currentAudioDir(const livesApp &lives);
2037 
2052  livesString tmpDir(const livesApp &lives);
2053 
2059  lives_audio_source_t audioSource(const livesApp &lives);
2060 
2067  bool setAudioSource(const livesApp &lives, lives_audio_source_t);
2068 
2073  lives_audio_player_t audioPlayer(const livesApp &lives);
2074 
2082  int audioPlayerRate(const livesApp &lives);
2083 
2089 
2094  int rteKeysVirtual(const livesApp &lives);
2095 
2100  double maxFPS(const livesApp &lives);
2101 
2107  bool audioFollowsVideoClipChanges(const livesApp &lives);
2108 
2114  bool audioFollowsVideoFPSChanges(const livesApp &lives);
2115 
2122  bool setAudioFollowsVideoFPSChanges(const livesApp &lives, bool);
2123 
2130  bool setAudioFollowsVideoClipChanges(const livesApp &lives, bool);
2131 
2138  bool sepWinSticky(const livesApp &lives);
2139 
2147  bool setSepWinSticky(const livesApp &lives, bool);
2148 
2155  bool mtExitRender(const livesApp &lives);
2156 
2164  bool setMtExitRender(const livesApp &lives, bool);
2165 
2166 
2167  }
2168 
2169 
2170 }
2171 
2172 #endif // __cplusplus
2173 
2174 #endif //HAS_LIBLIVES_H
livesString currentAudioDir(const livesApp &lives)
Definition: liblives.cpp:2241
Definition: liblives.hpp:175
application is processing, commands will be ignored
Definition: liblives.hpp:65
Abort button clicked.
Definition: liblives.hpp:137
livesString tmpDir(const livesApp &lives)
Definition: liblives.cpp:2246
lives_audio_source_t
Definition: liblives.hpp:150
Reset button clicked.
Definition: liblives.hpp:138
8 bit locale file encoding
Definition: liblives.hpp:118
bool sepWinSticky(const livesApp &lives)
Definition: liblives.cpp:2322
No button clicked.
Definition: liblives.hpp:143
application is playing, only player commands will be responded to
Definition: liblives.hpp:64
sent when interface mode changes
Definition: liblives.hpp:102
sent when livesApp object is deleted
Definition: liblives.hpp:104
multitrack mode
Definition: liblives.hpp:53
file chooser options for single video or audio file
Definition: liblives.hpp:41
bool setMtExitRender(const livesApp &lives, bool setting)
Definition: liblives.cpp:2337
lives_filechooser_t
Definition: liblives.hpp:40
Audio source is external to LiVES.
Definition: liblives.hpp:153
bool setSepWinSticky(const livesApp &lives, bool setting)
Definition: liblives.cpp:2327
sent when app quits
Definition: liblives.hpp:93
clip editor mode
Definition: liblives.hpp:52
Unknown / invalid.
Definition: liblives.hpp:161
lives_endian_t
Definition: liblives.hpp:73
Audio playback is through PulseAudio.
Definition: liblives.hpp:162
lives_insert_mode_t
Definition: liblives.hpp:174
livesString currentVideoLoadDir(const livesApp &lives)
Definition: liblives.cpp:2236
livesApp instance is invalid
Definition: liblives.hpp:61
Definition: liblives.hpp:74
double maxFPS(const livesApp &lives)
Definition: liblives.cpp:2297
file system encoding (UTF-8 on windows, local8bit on others)
Definition: liblives.hpp:119
int audioPlayerRate(const livesApp &lives)
Definition: liblives.cpp:2271
Audio source is internal to LiVES.
Definition: liblives.hpp:152
sent when a frame is displayed
Definition: liblives.hpp:83
lives_loop_mode_t
Definition: liblives.hpp:194
lives_audio_player_t
Definition: liblives.hpp:160
Audio playback is through mplayer2.
Definition: liblives.hpp:166
sent after a clip is opened
Definition: liblives.hpp:95
Audio playback is through mplayer.
Definition: liblives.hpp:165
const char * version(void)
Yes button clicked.
Definition: liblives.hpp:142
application is ready for commands
Definition: liblives.hpp:63
inserted blocks gravitate to the left
Definition: liblives.hpp:185
sent after a clip set is opened
Definition: liblives.hpp:99
UTF-8 char encoding.
Definition: liblives.hpp:117
Definition: liblives.hpp:88
lives_dialog_response_t
Definition: liblives.hpp:131
#define LIVES_CHAR_ENCODING_DEFAULT
Definition: liblives.hpp:126
no looping
Definition: liblives.hpp:195
user is previewing an operation, commands will be ignored
Definition: liblives.hpp:66
Unknown / invalid.
Definition: liblives.hpp:151
OK button clicked.
Definition: liblives.hpp:135
both video and audio loop continuously
Definition: liblives.hpp:196
_prefs * prefs
Definition: preferences.h:592
Accept button clicked.
Definition: liblives.hpp:141
lives_callback_t
Definition: liblives.hpp:82
sent after a clip is closed
Definition: liblives.hpp:96
sent after a clip set is closed
Definition: liblives.hpp:100
Definition: liblives.hpp:75
file chooser options for single audio file
Definition: liblives.hpp:42
lives_char_encoding_t
Definition: liblives.hpp:116
lives_mt * multitrack(weed_plant_t *event_list, int orig_file, double fps)
create and return lives_mt struct
Definition: multitrack.c:5811
livesApp instance is invalid
Definition: liblives.hpp:51
video keeps looping until audio playback finishes
Definition: liblives.hpp:197
sent when record starts (TODO)
Definition: liblives.hpp:90
int rteKeysVirtual(const livesApp &lives)
Definition: liblives.cpp:2292
sent when a/v playback starts or clip is switched
Definition: liblives.hpp:84
lives_interface_mode_t
Definition: liblives.hpp:50
Retry button clicked.
Definition: liblives.hpp:136
bool mtExitRender(const livesApp &lives)
Definition: liblives.cpp:2332
sent when record stops (TODO)
Definition: liblives.hpp:91
lives_status_t
Definition: liblives.hpp:60
Audio playback is through Sox.
Definition: liblives.hpp:164
for internal use
Definition: liblives.hpp:107
lives_audio_source_t audioSource(const livesApp &lives)
Definition: liblives.cpp:2251
application is starting up; not ready
Definition: liblives.hpp:62
Definition: liblives.hpp:85
bool setAudioSource(const livesApp &lives, lives_audio_source_t asrc)
Definition: liblives.cpp:2257
Cancel button clicked.
Definition: liblives.hpp:140
void binding_cb(lives_callback_t cb_type, const char *msgstring, ulong id)
Definition: liblives.cpp:2355
Response not obtained.
Definition: liblives.hpp:134
Audio playback is thorugh Jack.
Definition: liblives.hpp:163
inserted blocks gravitate to the right
Definition: liblives.hpp:186
lives_audio_player_t audioPlayer(const livesApp &lives)
Definition: liblives.cpp:2262
Show details button clicked.
Definition: liblives.hpp:139
lives_gravity_t
Definition: liblives.hpp:183
bool isRealtimeAudioPlayer(lives_audio_player_t player_type)
Definition: liblives.cpp:2282
no gravity
Definition: liblives.hpp:184
INVALID response.
Definition: liblives.hpp:133