3 /*----------------------------------------------------------------------------*/
5 /*----------------------------------------------------------------------------*/
7 #include "npv/c_fixing.h"
8 /* some trash at google did hide noto fonts behind a web javascript app */
9 STATIC u8
*npv_faces
[] = {
10 "/share/fonts/dejavu/DejaVuSansMono-Bold.ttf",
11 "/usr/share/fonts/dejavu/DejaVuSansMono-Bold.ttf",
14 /* for missing play/pause glyphs */
15 #define NPV_FACES_ASCII_ONLY 1
16 /* we don't use a xkb state machine, only bear 8bits truncated raw keycodes */
17 /*----------------------------------------------------------------------------*/
18 STATIC
void npv_cmd_quit(void);
19 STATIC
void npv_cmd_rewind(void);
20 STATIC
void npv_cmd_fastforward(void);
21 STATIC
void npv_cmd_rewind_big(void);
22 STATIC
void npv_cmd_fastforward_big(void);
23 STATIC
void npv_cmd_vol_up(void);
24 STATIC
void npv_cmd_vol_down(void);
25 STATIC
void npv_cmd_mute(void);
26 STATIC
void npv_cmd_osd_timer_toggle(void);
27 STATIC
void npv_cmd_pause(void);
28 STATIC
void npv_cmd_fullscreen_toggle(void);
30 STATIC
void npv_cmd_debug_toggle(void);
31 STATIC
void npv_cmd_debug_stats(void);
33 /*----------------------------------------------------------------------------*/
34 /* for documentation and example */
35 #define LINUX_KEY_ESC 0x01
36 #define LINUX_KEY_SPACE 0x39
37 /* x11 keycodes do offset linux keycodes by 8 */
38 #define X11_KEYCODE_ESC (LINUX_KEY_ESC + 8)
39 #define X11_KEYCODE_SPACE (LINUX_KEY_SPACE + 8)
40 /*----------------------------------------------------------------------------*/
41 struct npv_x11_bind_t
{
42 u8 keycode
; /* the 8bits truncated raw keycode */
43 u8
*name
; /* friendly name */
44 void (*cmd
)(void); /* bound cmd */
46 #define X11_BIND(x, y, z) {.keycode = x, .name = y, .cmd = z}
47 struct npv_x11_bind_t npv_x11_binds
[] = {
48 X11_BIND(X11_KEYCODE_ESC
, "escape", npv_cmd_quit
),
49 X11_BIND(X11_KEYCODE_SPACE
, "space", npv_cmd_pause
),
50 X11_BIND(0x71, "arrow left", npv_cmd_rewind
),
51 X11_BIND(0x72, "arrow right", npv_cmd_fastforward
),
52 X11_BIND(0x6e, "home", npv_cmd_rewind_big
),
53 X11_BIND(0x73, "end", npv_cmd_fastforward_big
),
54 X11_BIND(0x6f, "arrow up", npv_cmd_vol_up
),
55 X11_BIND(0x74, "arrow down", npv_cmd_vol_down
),
56 X11_BIND(0x48, "f6", npv_cmd_mute
),
57 X11_BIND(0x43, "f1", npv_cmd_osd_timer_toggle
),
58 X11_BIND(0x5f, "f11", npv_cmd_fullscreen_toggle
),
60 X11_BIND(0x4c, "f10", npv_cmd_debug_stats
),
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