1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
#pragma once
#include <al/array.h>
#include <al/atomic.h>
#ifdef CAMU_SCREEN_THREADED
#include <nnwt/thread.h>
#endif
#include <stl/window.h>
#include "../buffer/video.h"
#include "../render/renderer.h"
#include "view.h"
#define CAMU_SCREEN_DEBUG_KEY
// Interpret click and drag as seeking. Mainly a seek performance test.
//#define CAMU_SCREEN_DRAG_SEEK
#define CAMU_SCREEN_WIDTH 700
#define CAMU_SCREEN_HEIGHT 700
enum {
CAMU_SCREEN_MOD_SHIFT = 1,
CAMU_SCREEN_MOD_CONTROL = 1 << 1,
CAMU_SCREEN_DRAGGING = 1 << 2,
CAMU_SCREEN_MOUSE_MOD = 1 << 3,
CAMU_SCREEN_ZOOMING = 1 << 4,
CAMU_SCREEN_ZOOM_PAN_SIMPLE = 1 << 5,
CAMU_SCREEN_ZOOM_FOV = 1 << 6
};
enum {
CAMU_SCREEN_PAUSED = 0,
CAMU_SCREEN_PLAYING
};
enum {
CAMU_SCREEN_SET_VOLUME = 0, // f32
CAMU_SCREEN_OFFSET_VOLUME, // f32
CAMU_SCREEN_SKIP, // s32
CAMU_SCREEN_TOGGLE_PAUSE,
CAMU_SCREEN_PERCENT_SEEK, // f64
CAMU_SCREEN_RELATIVE_SEEK, // f64
CAMU_SCREEN_RESEEK,
CAMU_SCREEN_SHUFFLE,
CAMU_SCREEN_STATUS,
#ifdef CAMU_SCREEN_DEBUG_KEY
CAMU_SCREEN_DEBUG,
#endif
CAMU_SCREEN_CLOSE
};
struct camu_screen_video {
struct camu_view view;
struct camu_video_buffer *buf;
};
struct camu_screen {
atomic(s32) state;
struct stl_window *window;
#ifdef STELA_EVENT_BUFFER
struct nn_thread thread;
#endif
struct camu_renderer *renderer;
atomic(u32) force_refresh;
u32 flags;
u32 width;
u32 height;
bool fullscreen;
bool scaling_disabled;
bool transparent_background;
#ifdef CAMU_HAVE_SUBTITLES
bool subtitles_enabled;
#endif
u64 last_click_ts;
f64 last_pointer_y;
f64 last_pointer_x;
#ifdef CAMU_SCREEN_DRAG_SEEK
u64 last_seek_ts;
#endif
u8 vr_emulation;
bool vr_left_eye;
f64 vr_calibrate_x;
f64 vr_calibrate_y;
array(struct camu_screen_video) videos;
#ifdef CAMU_SCREEN_THREADED
array(struct camu_video_buffer *) add_queue;
array(struct camu_video_buffer *) rem_queue;
atomic(bool) queued;
struct nn_mutex mutex;
#endif
void (*callback)(void *, u8, void *);
void *userdata;
};
bool camu_screen_init(struct camu_screen *scr);
bool camu_screen_create_window(struct camu_screen *scr, const char *name);
bool camu_screen_create_renderer(struct camu_screen *scr, struct camu_renderer *renderer);
void camu_screen_add_buffer(struct camu_screen *scr, struct camu_video_buffer *buf);
void camu_screen_remove_buffer(struct camu_screen *scr, struct camu_video_buffer *buf);
#ifdef CAMU_SCREEN_THREADED
void camu_screen_run_queue(struct camu_screen *scr);
void camu_screen_clear(struct camu_screen *scr);
#endif
void camu_screen_set_state(struct camu_screen *scr, s32 state);
void camu_screen_force_refresh(struct camu_screen *scr);
bool camu_screen_poll(struct camu_screen *scr, bool block);
bool camu_screen_tick(struct camu_screen *scr, bool *force);
void camu_screen_wake(struct camu_screen *scr);
void camu_screen_close(struct camu_screen *scr);
|