3 /*----------------------------------------------------------------------------*/
5 /*----------------------------------------------------------------------------*/
7 #include "npv/c_fixing.h"
8 /* NotoSansSymbols2 is the only one with the play and pause symbols */
9 STATIC u8
*npv_faces
[] = {
10 "/share/fonts/noto/NotoMono-Regular.ttf",
11 "/share/fonts/noto/NotoSansSymbols-Regular.ttf",
12 "/share/fonts/noto/NotoSansSymbols2-Regular.ttf",
13 "/usr/share/fonts/truetype/noto/NotoMono-Regular.ttf",
14 "/usr/share/fonts/truetype/noto/NotoSansSymbols-Regular.ttf",
15 "/usr/share/fonts/truetype/noto/NotoSansSymbols2-Regular.ttf",
18 /* we don't use a xkb state machine, only bear 8bits truncated raw keycodes */
19 /*----------------------------------------------------------------------------*/
20 STATIC
void npv_cmd_quit(void);
21 STATIC
void npv_cmd_rewind(void);
22 STATIC
void npv_cmd_fastforward(void);
23 STATIC
void npv_cmd_rewind_big(void);
24 STATIC
void npv_cmd_fastforward_big(void);
25 STATIC
void npv_cmd_vol_up(void);
26 STATIC
void npv_cmd_vol_down(void);
27 STATIC
void npv_cmd_mute(void);
28 STATIC
void npv_cmd_osd_timer_toggle(void);
29 STATIC
void npv_cmd_pause(void);
30 STATIC
void npv_cmd_fullscreen_toggle(void);
32 STATIC
void npv_cmd_debug_toggle(void);
34 /*----------------------------------------------------------------------------*/
35 /* for documentation and example */
36 #define LINUX_KEY_ESC 0x01
37 #define LINUX_KEY_SPACE 0x39
38 /* x11 keycodes do offset linux keycodes by 8 */
39 #define X11_KEYCODE_ESC (LINUX_KEY_ESC + 8)
40 #define X11_KEYCODE_SPACE (LINUX_KEY_SPACE + 8)
41 /*----------------------------------------------------------------------------*/
42 struct npv_x11_bind_t
{
43 u8 keycode
; /* the 8bits truncated raw keycode */
44 u8
*name
; /* friendly name */
45 void (*cmd
)(void); /* bound cmd */
47 #define X11_BIND(x, y, z) {.keycode = x, .name = y, .cmd = z}
48 struct npv_x11_bind_t npv_x11_binds
[] = {
49 X11_BIND(X11_KEYCODE_ESC
, "escape", npv_cmd_quit
),
50 X11_BIND(X11_KEYCODE_SPACE
, "space", npv_cmd_pause
),
51 X11_BIND(0x71, "arrow left", npv_cmd_rewind
),
52 X11_BIND(0x72, "arrow right", npv_cmd_fastforward
),
53 X11_BIND(0x6e, "home", npv_cmd_rewind_big
),
54 X11_BIND(0x73, "end", npv_cmd_fastforward_big
),
55 X11_BIND(0x6f, "arrow up", npv_cmd_vol_up
),
56 X11_BIND(0x74, "arrow down", npv_cmd_vol_down
),
57 X11_BIND(0x48, "f6", npv_cmd_mute
),
58 X11_BIND(0x43, "f1", npv_cmd_osd_timer_toggle
),
59 X11_BIND(0x5f, "f11", npv_cmd_fullscreen_toggle
),
61 X11_BIND(0x60, "f12", npv_cmd_debug_toggle
)
66 #undef LINUX_KEY_SPACE
67 #undef X11_KEYCODE_ESC
68 #undef X11_KEYCODE_SPACE
69 /*----------------------------------------------------------------------------*/
70 #define VOL_DELTA 0.1 /* from 0.0 to 1.0 */
71 #define SEEK_DELTA INT64_C(10) /* 10 seconds */
72 #define SEEK_DELTA_BIG (INT64_C(4) * INT64_C(60)) /* 4 minutes */
73 /*============================================================================*/
74 /* kinky internal settings, modify with care */
76 * The targeted count of decoded video frames in the array (while not
77 * resyncing). Decoded frames are "memory expensive".
79 #define DEC_FRS_ARRAY_N_MAX 4
81 * video frames are presumed arriving inorder, but once a backward
82 * discontinuity is detected, in order to avoid a full/dead locked array of
83 * predecoded video frames, we unlock the size of array of decoded frames until
84 * we "resynchronize". To decide if we found a resynchronizing frame, we define
85 * a time window based on the following value.
87 #define DISCONT_BACKWARD_RESYNC_MS 500
89 * the rate limiter while resyncing, since it can flood memory. We target 16 ms
92 #define RESYNC_RATE_LIMITER_MS 16