1 /**
2  * @file lv_ffmpeg.h
3  *
4  */
5 #ifndef LV_FFMPEG_H
6 #define LV_FFMPEG_H
7 
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11 
12 /*********************
13  *      INCLUDES
14  *********************/
15 #include "../../../lvgl.h"
16 #if LV_USE_FFMPEG != 0
17 
18 /*********************
19  *      DEFINES
20  *********************/
21 
22 /**********************
23  *      TYPEDEFS
24  **********************/
25 struct ffmpeg_context_s;
26 
27 extern const lv_obj_class_t lv_ffmpeg_player_class;
28 
29 typedef struct {
30     lv_img_t img;
31     lv_timer_t * timer;
32     lv_img_dsc_t imgdsc;
33     bool auto_restart;
34     struct ffmpeg_context_s * ffmpeg_ctx;
35 } lv_ffmpeg_player_t;
36 
37 typedef enum {
38     LV_FFMPEG_PLAYER_CMD_START,
39     LV_FFMPEG_PLAYER_CMD_STOP,
40     LV_FFMPEG_PLAYER_CMD_PAUSE,
41     LV_FFMPEG_PLAYER_CMD_RESUME,
42     _LV_FFMPEG_PLAYER_CMD_LAST
43 } lv_ffmpeg_player_cmd_t;
44 
45 /**********************
46  * GLOBAL PROTOTYPES
47  **********************/
48 
49 /**
50  * Register FFMPEG image decoder
51  */
52 void lv_ffmpeg_init(void);
53 
54 /**
55  * Get the number of frames contained in the file
56  * @param path image or video file name
57  * @return Number of frames, less than 0 means failed
58  */
59 int lv_ffmpeg_get_frame_num(const char * path);
60 
61 /**
62  * Create ffmpeg_player object
63  * @param parent pointer to an object, it will be the parent of the new player
64  * @return pointer to the created ffmpeg_player
65  */
66 lv_obj_t * lv_ffmpeg_player_create(lv_obj_t * parent);
67 
68 /**
69  * Set the path of the file to be played
70  * @param obj pointer to a ffmpeg_player object
71  * @param path video file path
72  * @return LV_RES_OK: no error; LV_RES_INV: can't get the info.
73  */
74 lv_res_t lv_ffmpeg_player_set_src(lv_obj_t * obj, const char * path);
75 
76 /**
77  * Set command control video player
78  * @param obj pointer to a ffmpeg_player object
79  * @param cmd control commands
80  */
81 void lv_ffmpeg_player_set_cmd(lv_obj_t * obj, lv_ffmpeg_player_cmd_t cmd);
82 
83 /**
84  * Set the video to automatically replay
85  * @param obj pointer to a ffmpeg_player object
86  * @param en true: enable the auto restart
87  */
88 void lv_ffmpeg_player_set_auto_restart(lv_obj_t * obj, bool en);
89 
90 /*=====================
91  * Other functions
92  *====================*/
93 
94 /**********************
95  *      MACROS
96  **********************/
97 
98 #endif /*LV_USE_FFMPEG*/
99 
100 #ifdef __cplusplus
101 } /*extern "C"*/
102 #endif
103 
104 #endif /*LV_FFMPEG_H*/
105