78#define DISPLAY_MAGIC 0x01ba7ef1
79#define MOD_NAME "[display] "
102 printf(
"Available display devices:\n");
105 printf(
"(use \"fullhelp\" to show hidden displays)\n");
125 const char *
fmt,
unsigned int flags,
const char *postprocess,
struct display **out)
127 assert (requested_display != NULL &&
fmt != NULL && out != NULL);
129 if (postprocess && (strcmp(postprocess,
"help") == 0 || strcmp(postprocess,
"fullhelp") == 0)) {
139 "was not found.\n", requested_display);
153 if (d->
state == NULL) {
154 debug_msg(
"Unable to start display %s\n",
203#define CHECK(cmd) do { \
258 "being run in a new thread!\n");
283 if (strncasecmp(
msg->text,
"postprocess ", strlen(
"postprocess ")) != 0) {
289 "only an experimental feature! Use with caution!\n");
290 const char *
text =
msg->text + strlen(
"postprocess ");
294 if (strcmp(text,
"flush") != 0) {
348 long long seconds_ns = t - d->
t0;
384 bool display_ret =
true;
424 bool pp_does_change_tiling_mode =
false;
425 size_t len =
sizeof(pp_does_change_tiling_mode);
427 &pp_does_change_tiling_mode, &
len)) {
435 if (!pp_does_change_tiling_mode) {
476 codec_t *display_codecs,
size_t *display_codecs_count,
477 codec_t *pp_codecs,
size_t pp_codecs_count)
480 size_t new_disp_codec_count = 0;
482 for (
unsigned i = 0; i < pp_codecs_count; ++i) {
483 const struct video_desc in_desc = { 1920, 1080,
487 int out_display_mode = 0;
488 int out_frames_count = 0;
495 for (
unsigned j = 0; j < *display_codecs_count; ++j) {
496 if (display_codecs[j] == out_desc.
color_spec) {
497 new_disp_codecs[new_disp_codec_count++] =
502 *display_codecs_count = new_disp_codec_count;
503 memcpy(display_codecs, new_disp_codecs,
504 new_disp_codec_count *
sizeof(
codec_t));
531 size_t display_codecs_count, pp_codecs_count;
534 nlen =
sizeof display_codecs;
540 display_codecs_count = nlen /
sizeof(
codec_t);
541 nlen =
sizeof pp_codecs;
549 pp_codecs_count = nlen /
sizeof(
codec_t);
552 &display_codecs_count, pp_codecs,
555 nlen = display_codecs_count *
sizeof(
codec_t);
558 memcpy(
val, display_codecs, nlen);
638 switch (audio_init_flag) {
struct video_frame * frame
const char unsigned int flags
int vc_get_linesize(unsigned int width, codec_t codec)
struct video_frame * vf_alloc_desc_data(struct video_desc desc)
void log_msg(int level, const char *format,...)
#define LOG_LEVEL_NOTICE
information that may be interesting
#define LOG_LEVEL_INFO
normal reporting
#define LOG_LEVEL_ERROR
general errors
#define debug_msg(...)
#define debug_msg(...) log_msg(LOG_LEVEL_DEBUG, "[pid/%d +%d %s] ", getpid(), LINE,...
#define LOG_LEVEL_FATAL
errors that prevent UG run
#define LOG_LEVEL_WARNING
less severe errors
bool display_reconfigure_audio(struct display *d, int quant_samples, int channels, int sample_rate)
void display_put_audio_frame(struct display *d, const struct audio_frame *frame)
Puts audio data.
#define PITCH_DEFAULT
default pitch, i. e. respective linesize
bool display_put_frame(struct display *d, struct video_frame *frame, long long timeout_ns)
Puts filled video frame. After calling this function, video frame cannot be used.
#define DISPLAY_FLAG_AUDIO_ANALOG
void display_run_mainloop(struct display *d)
Display mainloop function.
bool display_ctl_property(struct display *d, int property, void *val, size_t *len)
Gets property from video display.
void display_run_new_thread(struct display *d)
#define DISPLAY_FLAG_AUDIO_AESEBU
#define VIDEO_DISPLAY_ABI_VERSION
const char * get_audio_conn_flag_name(int audio_init_flag)
#define DISPLAY_FLAG_AUDIO_EMBEDDED
bool display_needs_mainloop(struct display *d)
struct video_frame * get_splashscreen()
void display_done(struct display *d)
This function performs cleanup after done.
void display_join(struct display *d)
int initialize_video_display(struct module *parent, const char *requested_display, const char *fmt, unsigned int flags, const char *postprocess, struct display **out)
Initializes video display.
void list_video_display_devices(bool full)
struct video_frame * display_get_frame(struct display *d)
Returns video framebuffer which will be written to.
@ DISPLAY_PROPERTY_BUF_PITCH
requested framebuffer pitch - int (bytes), may be PITCH_DEFAULT
@ DISPLAY_PROPERTY_CODECS
list of natively supported codecs - codec_t[]
void module_init_default(struct module *module_data)
void module_register(struct module *module_data, struct module *parent)
void module_done(struct module *module_data)
mainloop_t mainloop
mainloop to be run if display mainloop isn't run
void list_modules(enum library_class cls, int abi_version, bool full)
const void * load_library(const char *name, enum library_class cls, int abi_version)
@ LIBRARY_CLASS_VIDEO_DISPLAY
#define UG_ASSERT(cond)
unconditional alternative to assert that is not affected by NDEBUG macro
void free_message(struct message *msg, struct response *r)
struct response * new_response(int status, const char *text)
struct message * check_message(struct module *mod)
#define RESPONSE_BAD_REQUEST
static void display_frame(struct state_sdl *s, struct video_frame *frame)
#define HEADER_PIXEL(data, pixel)
static const char *const splash_data
static const unsigned int splash_width
static const unsigned int splash_height
struct used to comunicate with audio capture/playback device
struct device_option options[64]
This struct represents initialized video display state.
enum video_mode saved_mode
void * state
state of the created video capture driver
struct video_desc saved_desc
const struct video_display_info * funcs
int pp_output_frames_count
struct vo_postprocess_state * postprocess
pthread_t thread_id
thread ID of the display thread (
uint32_t magic
For debugging. Conatins DISPLAY_MAGIC.
char * data
Raw tile data. Pointer must be at least 4B aligned.
unsigned int data_len
length of the data
enum interlacing_t interlacing
unsigned int width
width of every tile (!)
unsigned int height
height of every tile (!)
void(* run)(void *state)
callback to display main event loop; may be NULL
struct video_frame *(* getf)(void *state)
void *(* init)(struct module *parent, const char *fmt, unsigned int flags)
void(* put_audio_frame)(void *state, const struct audio_frame *frame)
may be NULL
bool(* reconfigure_video)(void *state, struct video_desc desc)
bool(* putf)(void *state, struct video_frame *frame, long long timeout_ns)
const char * generic_fps_indicator_prefix
NO_GENERIC_FPS_INDICATOR or pointer to preferred module name.
bool(* reconfigure_audio)(void *state, int quant_samples, int channels, int sample_rate)
bool(* ctl_property)(void *state, int property, void *val, size_t *len)
void(* done)(void *state)
Struct video_frame represents a video frame and contains video description.
struct tile tiles[FLEXIBLE_ARRAY_MEMBER]
void set_thread_name(const char *name)
static time_ns_t get_time_in_ns()
This file contains some common data types.
@ PROGRESSIVE
progressive frame
@ VIDEO_CODEC_COUNT
count of known video codecs (including VIDEO_CODEC_NONE)
@ RGBA
RGBA 8-bit, big-endian.
const char * video_desc_to_string(struct video_desc d)
int get_video_mode_tiles_x(enum video_mode video_mode)
int get_video_mode_tiles_y(enum video_mode video_mode)
This is an umbrella header for video functions.
bool display_reconfigure(struct display *d, struct video_desc desc, enum video_mode video_mode)
Reconfigure display to new video format.
static void restrict_returned_codecs(struct vo_postprocess_state *postprocess, codec_t *display_codecs, size_t *display_codecs_count, codec_t *pp_codecs, size_t pp_codecs_count)
void dev_add_option(struct device_info *dev, const char *name, const char *desc, const char *key, const char *opt_str, bool is_boolean)
static bool display_frame_helper(struct display *d, struct video_frame *frame, long long timeout_ns)
static void * display_run_helper(void *args)
static struct response * process_message(struct display *d, struct msg_universal *msg)
void show_vo_postprocess_help(bool full)
struct vo_postprocess_state * vo_postprocess_init(const char *config_string)
bool vo_postprocess_get_property(struct vo_postprocess_state *s, int property, void *val, size_t *len)
bool vo_postprocess_reconfigure(struct vo_postprocess_state *s, struct video_desc desc)
void vo_postprocess_get_out_desc(struct vo_postprocess_state *s, struct video_desc *out, int *display_mode, int *out_frames_count)
void vo_postprocess_done(struct vo_postprocess_state *s)
bool vo_postprocess(struct vo_postprocess_state *s, struct video_frame *in, struct video_frame *out, int req_pitch)
struct video_frame * vo_postprocess_getf(struct vo_postprocess_state *s)
#define VO_PP_DOES_CHANGE_TILING_MODE
#define VO_PP_PROPERTY_CODECS