49#include <condition_variable>
59static constexpr const char *
MOD_NAME =
"[multiplier] ";
64using unique_disp = std::unique_ptr<struct display, disp_deleter>;
76 condition_variable
cv;
83 printf(
"Multiplier display\n");
85 printf(
"\t-d multiplier:<display1>[:<display_config1>][#<display2>[:<display_config2>]]...\n");
90 auto s = std::make_unique<state_multiplier>();
92 if(!
fmt || strlen(
fmt) == 0){
97 std::string_view fmt_sv =
fmt;
99 if (fmt_sv ==
"help") {
106 for(
auto tok =
tokenize(fmt_sv,
'#'); !tok.empty(); tok =
tokenize(fmt_sv,
'#')){
109 auto cfg = std::string(tok);
116 unique_disp disp(d_ptr);
121 s->displays.push_back(std::move(disp));
133 *current_desc =
desc;
134 fprintf(stderr,
"RECONFIGURED\n");
149 unique_lock<mutex> lg(s->lock);
150 s->cv.wait(lg, [s]{
return s->incoming_queue.size() > 0;});
151 frame = s->incoming_queue.front();
152 s->incoming_queue.pop();
153 s->in_queue_decremented_cv.notify_one();
157 for (
auto& disp : s->displays) {
171 for (
auto& disp : s->displays) {
193 assert(!s->displays.empty());
195 for (
size_t i = 1; i < s->displays.size(); i++) {
203 s->worker_thread.join();
204 for (
size_t i = 1; i < s->displays.size(); i++) {
229 unique_lock<mutex> lg(s->lock);
231 fprintf(stderr,
"Multiplier: queue full!\n");
238 s->incoming_queue.push(
frame);
260 for (
auto &disp : s->displays) {
284 *available_cards =
nullptr;
struct video_frame * frame
const char unsigned int flags
int void(** deleter)(void *))
void vf_free(struct video_frame *buf)
Frees video_frame structure.
struct video_desc video_desc_from_frame(const struct video_frame *frame)
Returns struct video_desc from video frame.
struct video_frame * vf_alloc_desc_data(struct video_desc desc)
#define LOG_LEVEL_ERROR
general errors
#define LOG_LEVEL_VERBOSE
#define LOG_LEVEL_FATAL
errors that prevent UG run
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.
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.
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 VIDEO_DISPLAY_ABI_VERSION
#define DISPLAY_NO_GENERIC_FPS_INDICATOR
bool display_needs_mainloop(struct display *d)
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.
struct video_frame * display_get_frame(struct display *d)
Returns video framebuffer which will be written to.
@ LIBRARY_CLASS_VIDEO_DISPLAY
#define REGISTER_MODULE(name, info, lclass, abi)
Registers module to global modules' registry.
static constexpr unsigned int IN_QUEUE_MAX_BUFFER_LEN
static void display_multiplier_put_audio_frame(void *state, const struct audio_frame *frame)
static void display_multiplier_worker(void *state)
static void display_multiplier_done(void *state)
static void * display_multiplier_init(struct module *parent, const char *fmt, unsigned int flags)
static bool display_multiplier_reconfigure_audio(void *state, int quant_samples, int channels, int sample_rate)
static bool display_multiplier_get_property(void *state, int property, void *val, size_t *len)
static bool display_multiplier_reconfigure(void *state, struct video_desc desc)
static void display_multiplier_probe(struct device_info **available_cards, int *count, void(**deleter)(void *))
static constexpr int SKIP_FIRST_N_FRAMES_IN_STREAM
static void check_reconf(struct state_multiplier *s, struct video_desc *current_desc, struct video_desc desc)
static const struct video_display_info display_multiplier_info
static void display_multiplier_run(void *state)
static constexpr const char * MOD_NAME
static bool display_multiplier_putf(void *state, struct video_frame *frame, long long flags)
static struct video_frame * display_multiplier_getf(void *state)
std::string_view tokenize(std::string_view &str, char delim, char quot)
Tokenizer for string_view.
struct used to comunicate with audio capture/playback device
This struct represents initialized video display state.
std::vector< unique_disp > displays
queue< struct video_frame * > incoming_queue
condition_variable in_queue_decremented_cv
char * data
Raw tile data. Pointer must be at least 4B aligned.
unsigned int data_len
length of the data
Struct video_frame represents a video frame and contains video description.
struct tile tiles[FLEXIBLE_ARRAY_MEMBER]
@ VIDEO_NORMAL
normal video (one tile)
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.
bool video_desc_eq(struct video_desc a, struct video_desc b)
Compares two video descriptions.