1 /** inline_video.c
2 *
3 * TODO : a lot...
4 *
5 * We need to resive the video frame, and maybe center...
6 *
7 * Consider drawing messages under the video?
8 * Consider do we want to draw buttons on screen?
9 * Consider double click to pop out
10 *
11 * Consider auto selecting inline video
12 */
13
14 #include "inline_video.h"
15
16 #include "debug.h"
17 #include "macros.h"
18 #include "settings.h"
19 #include "ui.h"
20
21 #include "av/video.h"
22
23 #include "native/image.h"
24
25 #include <stdlib.h>
26 #include <string.h>
27
28 static UTOX_FRAME_PKG current_frame = { 0, 0, 0, 0 };
29
inline_set_frame(uint16_t w,uint16_t h,size_t size,void * img)30 bool inline_set_frame(uint16_t w, uint16_t h, size_t size, void *img) {
31 current_frame.w = w;
32 current_frame.h = h;
33 current_frame.size = size;
34
35 uint8_t *tmp = realloc(current_frame.img, size);
36 if (!size || !tmp) {
37 current_frame.w = 0;
38 current_frame.h = 0;
39 current_frame.size = 0;
40 tmp ? free(tmp) : free(current_frame.img);
41
42 return false;
43 }
44
45 current_frame.img = tmp;
46 memcpy(current_frame.img, img, size);
47 return true;
48 }
49
inline_video_draw(INLINE_VID * UNUSED (p),int x,int y,int width,int height)50 void inline_video_draw(INLINE_VID *UNUSED(p), int x, int y, int width, int height) {
51 if (!settings.inline_video) {
52 return;
53 }
54
55 LOG_TRACE("Inline Video", "Drawing new frame." );
56
57 if (current_frame.img && current_frame.size) {
58 draw_inline_image(current_frame.img, current_frame.size,
59 MIN(current_frame.w, width), MIN(current_frame.h, height),
60 x, y + MAIN_TOP_FRAME_THICK);
61 }
62 }
63
inline_video_mmove(INLINE_VID * UNUSED (p),int UNUSED (x),int UNUSED (y),int UNUSED (width),int UNUSED (height),int UNUSED (mx),int UNUSED (my),int UNUSED (dx),int UNUSED (dy))64 bool inline_video_mmove(INLINE_VID *UNUSED(p), int UNUSED(x), int UNUSED(y), int UNUSED(width), int UNUSED(height),
65 int UNUSED(mx), int UNUSED(my), int UNUSED(dx), int UNUSED(dy)) {
66 return 0;
67 }
68
inline_video_mdown(INLINE_VID * UNUSED (p))69 bool inline_video_mdown(INLINE_VID *UNUSED(p)) {
70 return 0;
71 }
72
inline_video_mright(INLINE_VID * UNUSED (p))73 bool inline_video_mright(INLINE_VID *UNUSED(p)) {
74 return 0;
75 }
76
inline_video_mwheel(INLINE_VID * UNUSED (p),int UNUSED (height),double UNUSED (d),bool UNUSED (smooth))77 bool inline_video_mwheel(INLINE_VID *UNUSED(p), int UNUSED(height), double UNUSED(d), bool UNUSED(smooth)) {
78 return 0;
79 }
80
inline_video_mup(INLINE_VID * UNUSED (p))81 bool inline_video_mup(INLINE_VID *UNUSED(p)) {
82 return 0;
83 }
84
inline_video_mleave(INLINE_VID * UNUSED (p))85 bool inline_video_mleave(INLINE_VID *UNUSED(p)) {
86 return 0;
87 }
88