Waave
An audio video engine
 All Data Structures Functions Variables Groups Pages
WAAVE.h
1 #ifndef WAAVE_LIBRARY_H
2 #define WAAVE_LIBRARY_H
3 
4 
5 #include <libavutil/pixfmt.h>
6 #include <stdint.h>
7 #include <SDL.h>
8 
9 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
21 
22 /*||||||||||||||||||||||||||||||||||||*/
23 /* */
24 /* THE STREAMING OBJECT */
25 /* */
26 /*||||||||||||||||||||||||||||||||||||*/
27 
28 
29 /* the get buffer method */
30 //the buffers doesn't change, get is used one time per slot
31 #define WV_STATIC_GET 0
32 //we need to get buffer each time we decode a frame
33 #define WV_DYNAMIC_GET 1
34 
35 /* the Get/Lock/Release method */
36 //just after the frame was displayed we reload the slot
37 #define WV_SYNC_GLR 0
38 //we load the slot just before the next slot was displayed
39 #define WV_ASYNC_GLR 1
40 
41 /* Get/Lock/Release thread safety */
42 //the function is thread safe
43 #define WV_THREAD_SAFE 1
44 //the function is not thread safe
45 #define WV_NO_THREAD_SAFE 0
46 
47 
56 typedef struct WVStreamingBuffer{
57 
58  int width;
59  int height;
60  enum PixelFormat format;
66  uint8_t* data[4];
67 
72  int linesize[4];
73 
75 
76 
77 
88 typedef struct WVStreamingObject{
89 
98  int srcWidth;
99 
109 
118  enum PixelFormat srcFormat; //ffmpeg src format
119 
120 
131  int nbSlots;
132 
133 
151  int getBufferMethod; //STATIC or DYNAMIC
152 
153 
168  int GLRMethod; //SYNC or ASYNC get/lock/release
169 
183  int getThreadSafety; //get thread safety
184 
185 
186 
200  int LRThreadSafety; //Lock and release thread safety
201 
202 
214  int (*init)(struct WVStreamingObject* streamObj);
215 
227  WVStreamingBuffer (*getBuffer)(struct WVStreamingObject* streamObj, int slotIdx);
228 
238  int (*lockBuffer)(struct WVStreamingObject* streamObj, int slotIdx);
239 
240 
241 
254  int (*filterBuffer)(struct WVStreamingObject* streamObj, int slotIdx, WVStreamingBuffer* buffer);
255 
256 
257 
268  int (*releaseBuffer)(struct WVStreamingObject* streamObj, int slotIdx);
269 
280  int (*refreshFrame)(struct WVStreamingObject* streamObj, int slotIdx);
281 
282 
283 
291  int (*close)(struct WVStreamingObject* streamObj);
292 
293 
294  /****************/
295  /* private data */
296  /****************/
297 
304  void* objPrivate;
305 
307 
308 
309 
310 
311 
312 
313 
314 
315 
316 
317 
318 /*|||||||||||||||||||||||||||||||||*/
319 /* */
320 /* THE SYNC OBJECT */
321 /* */
322 /*|||||||||||||||||||||||||||||||||*/
323 
324 
325 /*****************************/
326 /* the clock data structure */
327 /*****************************/
328 
337 typedef struct WVReferenceClock{
338 
346  uint32_t clock;
347 
355  int pauseFlag;
356 
366  int modIdx;
367 
369 
370 
371 
372 
373 /* we have two way for seeking */
374 //if the clock is paused, seek cause restart playing
375 #define WV_PLAYING_SEEK 0
376 //if the clock is paused, it stay paused after the seek
377 #define WV_BLOCKING_SEEK 1
378 
379 /* we have two way for thread EOF */
380 // if clock reach stream end, pause */
381 #define WV_BLOCKING_STREAM 0
382 // if clock reach stream end, loop */
383 #define WV_LOOPING_STREAM 1
384 
385 
386 
387 
388 
389 /*******************/
390 /* the sync object */
391 /*******************/
392 
401 typedef struct WVSyncObject{
402 
403  /************/
404  /* EOF FLAG */
405  /************/
406 
421 
422 
423  /*************/
424  /* SLAVE DEF */
425  /*************/
426 
438  void (*signalStateChange)(struct WVSyncObject* sync);
439 
440  /**************/
441  /* MASTER DEF */
442  /**************/
443 
444  /* !!! getRefClock and play are mandatory !!! */
445  /* !!! signalStateChange for play and seek but not for pause !!! */
446 
447  /* GETREFCLOCK */
448 
465  void (*getRefClock)(struct WVSyncObject* sync, WVReferenceClock* refClock);
466 
467 
468  /* PLAY */
469 
481  int (*play)(struct WVSyncObject* sync);
482 
483 
484  /* PAUSE */
485 
497  int (*pause)(struct WVSyncObject* sync);
498 
499 
500  /* SEEK */
501 
520  int (*seek)(struct WVSyncObject* sync, uint32_t clock, int seekFlag);
521 
522 
523  /***********/
524  /* PRIVATE */
525  /***********/
526 
533  void* objPrivate; //private vars for the methods
534 
542  void* wvStdPrivate;
543 
544 
545 }WVSyncObject;
546 
547 
548 
549 
550 
551 /*|||||||||||||||||||||||||||||||||||||||||||*/
552 /* */
553 /* THE STREAM PARAMETERS */
554 /* */
555 /*|||||||||||||||||||||||||||||||||||||||||||*/
556 
557 /* the stream type */
558 #define WV_STREAM_TYPE_NONE 0
559 #define WV_STREAM_TYPE_AUDIO 1
560 #define WV_STREAM_TYPE_VIDEO 2
561 #define WV_STREAM_TYPE_AUDIOVIDEO 3
562 
563 /* the play method */
564 #define WV_NEUTRAL_PLAY 0
565 #define WV_LOOPING_PLAY 1
566 
567 /* the seek method */
568 #define WV_SEEK_BACKWARD -1
569 #define WV_SEEK_FORWARD 1
570 
571 
572 /* the stream struct */
573 struct WVStream;
574 typedef struct WVStream WVStream;
575 
576 /* to signal eof */
577 typedef int (*WVEOFSignalCall)(struct WVStream* stream, void* param);
578 
579 
580 #define WAAVE_INIT_NONE 0
581 #define WAAVE_INIT_AUDIO 1
582 #define WAAVE_INIT_VIDEO 2
583 
584 
585 
586 /*|||||||||||||||||||||||||||||||||||||||||||*/
587 /* */
588 /* THE WAAVE API */
589 /* */
590 /*|||||||||||||||||||||||||||||||||||||||||||*/
591 
592 
593 
594 /***********************************/
595 /* Start and stop the Waave engine */
596 /***********************************/
597 
629 int WV_waaveInit(int flag);
630 
631 
639 int WV_waaveClose(void);
640 
641 
649 /***********************/
650 /* Stream manipulation */
651 /***********************/
652 
674 WVStream* WV_getStream(const char* filename);
675 
676 
687 WVStream* WV_closeStream(WVStream* stream);
688 
689 
705 int WV_getStreamType(WVStream* stream);
706 
715 int WV_getStreamWidth(WVStream* stream);
716 
725 int WV_getStreamHeight(WVStream* stream);
726 
727 
736 int WV_loadStream(WVStream* stream);
737 
738 
744 /************************/
745 /* Display video frames */
746 /************************/
747 
759 /* the default WV_REFRESH_EVENT value */
760 #if SDL_VERSION_ATLEAST(2,0,0)
761 
762 extern int dynamic_wv_refresh_event; //dynamic, see waave_engine_flags.c
763 #define WV_REFRESH_EVENT dynamic_wv_refresh_event
764 
765 #else
766 
767 #define WV_REFRESH_EVENT SDL_NUMEVENTS - 1
768 
769 #endif
770 
771 
794 void WV_refreshVideoFrame(SDL_Event* refreshEvent);
795 
800 /*************************/
801 /* Set stream parameters */
802 /*************************/
803 
804 
825 int WV_disableAudio(WVStream* stream);
826 
836 int WV_disableVideo(WVStream* stream);
837 
855 int WV_setPlayMethod(WVStream* stream, int playFlag);
856 
857 
858 
874 int WV_setSeekMethod(WVStream* stream, int seekFlag);
875 
876 
877 /* the eof signal */
878 #if SDL_VERSION_ATLEAST(2,0,0)
879 
880 extern int dynamic_wv_eof_event; //dynamic, see waave_engine_flags.c
881 #define WV_EOF_EVENT dynamic_wv_eof_event
882 
883 #else
884 
885 #define WV_EOF_EVENT SDL_NUMEVENTS - 2
886 
887 #endif
888 
889 
905 int WV_setEOFMethod(WVStream* stream, int loopingFlag);
906 
907 
908 
922 int WV_setStreamingMethod(WVStream* stream, WVStreamingObject* streamObj);
923 
924 
925 
935  WVStreamingObject* WV_getStreamingMethod(WVStream* stream);
936 
937 
947 int WV_setSyncMethod(WVStream* stream, WVSyncObject* syncObj);
948 
949 
959  WVSyncObject* WV_getSyncMethod(WVStream* stream);
960 
961 
975 int WV_setEOFSignalParam(WVStream* stream, void* param);
976 
977 
998 int WV_setEOFSignalCall(WVStream* stream, WVEOFSignalCall eofCall);
999 
1000 
1013 int WV_setVolumeDBPitche(WVStream* stream, double DBPitche);
1014 
1015 
1024 double WV_getVolumeDBPitche(WVStream* stream);
1025 
1033 /***************************/
1034 /* Stream playback control */
1035 /***************************/
1036 
1056 int WV_playStream(WVStream* stream);
1057 
1058 
1069 int WV_pauseStream(WVStream* stream);
1070 
1071 
1081 int WV_stopStream(WVStream* stream);
1082 
1083 
1092 int WV_rewindStream(WVStream* stream);
1093 
1094 
1115 int WV_rseekStream(WVStream* stream, uint32_t seekShift, int seekDirection);
1116 
1117 
1130 int WV_seekStream(WVStream* stream, uint32_t clock);
1131 
1132 
1141 uint32_t WV_getStreamDuration(WVStream* stream);
1142 
1143 
1154 uint32_t WV_getStreamClock(WVStream* stream);
1155 
1156 
1164 /*************************/
1165 /* Stream volume control */
1166 /*************************/
1167 
1189 int WV_setVolume(WVStream* stream, double volume);
1190 
1191 
1200  double WV_getVolume(WVStream* stream);
1201 
1202 
1217 int WV_setDBVolume(WVStream* stream, int DBVolume);
1218 
1219 
1228 int WV_getDBVolume(WVStream* stream);
1229 
1230 
1240 int WV_shiftDBVolume(WVStream* stream, int shift);
1241 
1242 
1251 /**************************************/
1252 /* Standard SDL 1.2 streaming objects */
1253 /**************************************/
1254 
1264 //#if !SDL_VERSION_ATLEAST(2,0,0)
1265 
1266  /****************/
1267  /* overlays */
1268  /****************/
1269 
1281 WVStreamingObject* WV_getStreamOverlayObj(SDL_Surface* targetSurface, SDL_Rect* destRect);
1282 
1294 void WV_resetStreamOverlayOutput(WVStreamingObject* streamObj, SDL_Surface* targetSurface, SDL_Rect* destRect);
1295 
1296 
1297 
1308 
1309 
1310 
1311  /****************/
1312  /* surface */
1313  /****************/
1314 
1327 WVStreamingObject* WV_getStreamSurfaceObj(SDL_Surface* targetSurface, SDL_Rect* destRect, int updateFlag);
1328 
1340 void WV_resetStreamSurfaceOutput(WVStreamingObject* streamObj, SDL_Surface* targetSurface, SDL_Rect* destRect);
1341 
1342 
1353 
1354 
1355 
1356 
1357 
1358  //#endif
1359 
1365 /**************************************/
1366 /* Standard SDL 2.0 streaming objects */
1367 /**************************************/
1368 
1386 //#if SDL_VERSION_ATLEAST(2,0,0)
1387 
1388 
1400  WVStreamingObject* WV_getStreamRendererObj(SDL_Renderer* targetRenderer, SDL_Rect* destRect, int updateFlag);
1401 
1402 
1415 void WV_resetStreamRendererOutput(WVStreamingObject* streamObj, SDL_Renderer* targetRenderer, SDL_Rect* destRect);
1416 
1417 
1418 
1429 
1430  //#endif
1431 
1436 #ifdef __cplusplus
1437 }
1438 #endif
1439 
1440 
1441 #endif