UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
Loading...
Searching...
No Matches
dump.c File Reference
#include "config.h"
#include "config_unix.h"
#include "config_win32.h"
#include <stdint.h>
#include "compat/time.h"
#include "debug.h"
#include "export.h"
#include "host.h"
#include "lib_common.h"
#include "utils/color_out.h"
#include "utils/macros.h"
#include "video.h"
#include "video_display.h"
Include dependency graph for dump.c:

Go to the source code of this file.

Classes

struct  dump_display_state
 

Macros

#define MOD_NAME   "[dump] "
 

Functions

static void display_dump_done (void *state)
 
static bool display_dump_get_property (void *state, int property, void *val, size_t *len)
 
static struct video_frame * display_dump_getf (void *state)
 
static void * display_dump_init (struct module *parent, const char *cfg, unsigned int flags)
 
static void display_dump_probe (struct device_info **available_cards, int *count, void(**deleter)(void *))
 
static bool display_dump_putf (void *state, struct video_frame *frame, long long flags)
 
static bool display_dump_reconfigure (void *state, struct video_desc desc)
 
 REGISTER_MODULE (dump, &display_dump_info, LIBRARY_CLASS_VIDEO_DISPLAY, VIDEO_DISPLAY_ABI_VERSION)
 
static void usage ()
 

Variables

static const struct video_display_info display_dump_info
 

Detailed Description

Author
Martin Pulec pulec.nosp@m.@ces.nosp@m.net.c.nosp@m.z
Todo
Add audio support

Definition in file dump.c.

Macro Definition Documentation

◆ MOD_NAME

#define MOD_NAME   "[dump] "

Definition at line 57 of file dump.c.

Function Documentation

◆ display_dump_done()

static void display_dump_done ( void * state)
static

Definition at line 102 of file dump.c.

103{
104 struct dump_display_state *s = state;
105
106 vf_free(s->f);
107 export_destroy(s->e);
108 free(s);
109}
void ** state
void vf_free(struct video_frame *buf)
Frees video_frame structure.
void export_destroy(struct exporter *s)
Definition export.c:308
struct exporter * e
Definition dump.c:62
struct video_frame * f
Definition dump.c:60

References dump_display_state::e, export_destroy(), dump_display_state::f, state, and vf_free().

Here is the call graph for this function:

◆ display_dump_get_property()

static bool display_dump_get_property ( void * state,
int property,
void * val,
size_t * len )
static

Definition at line 134 of file dump.c.

135{
136 (void) state;
138
139 for (int i = 0; i < VIDEO_CODEC_COUNT - 1; ++i) {
140 codecs[i] = (codec_t) (i + 1); // all codecs (exclude VIDEO_CODEC_NONE)
141 }
142
143 switch (property) {
145 if (sizeof(codecs) <= *len) {
146 memcpy(val, codecs, sizeof(codecs));
147 *len = sizeof(codecs);
148 } else {
149 return FALSE;
150 }
151 break;
154 *len = sizeof(int);
155 break;
156 default:
157 return false;
158 }
159 return true;
160}
int void * val
int void size_t * len
int property
#define FALSE
@ DISPLAY_PROPERTY_VIDEO_MODE
requested video mode - int (one of display_prop_vid_mode)
@ DISPLAY_PROPERTY_CODECS
list of natively supported codecs - codec_t[]
@ DISPLAY_PROPERTY_VIDEO_SEPARATE_TILES
framebuffer consists of separate tiles
codec_t
Definition types.h:65
@ VIDEO_CODEC_COUNT
count of known video codecs (including VIDEO_CODEC_NONE)
Definition types.h:108
static struct @76 codecs[]

References codecs, DISPLAY_PROPERTY_CODECS, DISPLAY_PROPERTY_VIDEO_MODE, DISPLAY_PROPERTY_VIDEO_SEPARATE_TILES, FALSE, len, property, state, val, and VIDEO_CODEC_COUNT.

◆ display_dump_getf()

static struct video_frame * display_dump_getf ( void * state)
static

Definition at line 111 of file dump.c.

112{
113 struct dump_display_state *s = state;
114 for (unsigned int i = 0; i < s->f->tile_count; ++i) {
115 if (is_codec_opaque(s->f->color_spec)) {
116 s->f->tiles[i].data_len = s->max_tile_data_len;
117 }
118 }
119 return s->f;
120}
size_t max_tile_data_len
Definition dump.c:63
unsigned int data_len
length of the data
Definition types.h:288
struct tile tiles[FLEXIBLE_ARRAY_MEMBER]
Definition types.h:345
unsigned int tile_count
Definition types.h:344
codec_t color_spec
Definition types.h:306
bool is_codec_opaque(codec_t codec)

References video_frame::color_spec, tile::data_len, dump_display_state::f, is_codec_opaque(), dump_display_state::max_tile_data_len, state, video_frame::tile_count, and video_frame::tiles.

Here is the call graph for this function:

◆ display_dump_init()

static void * display_dump_init ( struct module * parent,
const char * cfg,
unsigned int flags )
static

Definition at line 76 of file dump.c.

77{
78 (void) parent, (void) flags;
79 if (strcmp(cfg, "help") == 0) {
80 usage();
81 return INIT_NOERR;
82 }
83 struct dump_display_state *s = calloc(1, sizeof *s);
84 char dirname[128];
85 if (strlen(cfg) == 0) {
86 time_t t = time(NULL);
87 struct tm tm_buf = { 0 };
88 localtime_s(&t, &tm_buf);
89 strftime(dirname, sizeof dirname, "dump.%Y%m%dT%H%M%S",
90 &tm_buf);
91 cfg = dirname;
92 }
93 s->e = export_init(NULL, cfg, true);
94 if (s->e == NULL) {
95 log_msg(LOG_LEVEL_ERROR, "[dump] Failed to create export instance!\n");
96 free(s);
97 return NULL;
98 }
99 return s;
100}
const char unsigned int flags
#define localtime_s
Definition time.h:51
void log_msg(int level, const char *format,...)
Definition debug.cpp:130
#define LOG_LEVEL_ERROR
general errors
Definition debug.h:59
static void usage()
Definition dump.c:67
struct exporter * export_init(struct module *parent, const char *cfg, bool should_export)
Definition export.c:149
#define INIT_NOERR
Definition host.h:73
const char * parent
Definition settings.cpp:198

References dump_display_state::e, export_init(), flags, INIT_NOERR, localtime_s, LOG_LEVEL_ERROR, log_msg(), parent, and usage().

Here is the call graph for this function:

◆ display_dump_probe()

static void display_dump_probe ( struct device_info ** available_cards,
int * count,
void(** deleter )(void *) )
static

Definition at line 180 of file dump.c.

180 {
182 *available_cards = NULL;
183 *count = 0;
184}
#define UNUSED(x)
int void(** deleter)(void *))
int count
Definition hd-rum.c:44

References count, deleter, and UNUSED.

◆ display_dump_putf()

static bool display_dump_putf ( void * state,
struct video_frame * frame,
long long flags )
static

Definition at line 122 of file dump.c.

123{
124 struct dump_display_state *s = state;
125 if (frame == NULL || flags == PUTF_DISCARD) {
126 return true;
127 }
128 assert(frame == s->f);
129 export_video(s->e, frame);
130
131 return true;
132}
struct video_frame * frame
void export_video(struct exporter *s, struct video_frame *frame)
Definition export.c:356
#define PUTF_DISCARD

References dump_display_state::e, export_video(), dump_display_state::f, flags, frame, PUTF_DISCARD, and state.

Here is the call graph for this function:

◆ display_dump_reconfigure()

static bool display_dump_reconfigure ( void * state,
struct video_desc desc )
static

Definition at line 162 of file dump.c.

163{
164 struct dump_display_state *s = state;
165 vf_free(s->f);
166 s->f = vf_alloc_desc(desc);
168 s->max_tile_data_len = MAX(8 * desc.width * desc.height, 1000000UL);
169 for (unsigned int i = 0; i < s->f->tile_count; ++i) {
171 s->f->tiles[i].data_len = s->max_tile_data_len;
172 }
173 s->f->tiles[i].data = (char *) malloc(s->f->tiles[i].data_len);
174 }
176
177 return true;
178}
struct video_desc desc
void vf_data_deleter(struct video_frame *buf)
struct video_frame * vf_alloc_desc(struct video_desc desc)
Allocates video frame accordig given desc.
#define TRUE
#define MAX(a, b)
Definition macros.h:65
char * data
Raw tile data. Pointer must be at least 4B aligned.
Definition types.h:287
codec_t color_spec
Definition types.h:182
unsigned int width
width of every tile (!)
Definition types.h:179
unsigned int height
height of every tile (!)
Definition types.h:180
void(* data_deleter)(struct video_frame *)
Definition types.h:256
unsigned int decoder_overrides_data_len
Definition types.h:322
struct video_frame_callbacks callbacks
Definition types.h:324

References video_frame::callbacks, video_desc::color_spec, tile::data, video_frame_callbacks::data_deleter, tile::data_len, video_frame::decoder_overrides_data_len, desc, dump_display_state::f, FALSE, video_desc::height, is_codec_opaque(), MAX, dump_display_state::max_tile_data_len, state, video_frame::tile_count, video_frame::tiles, TRUE, vf_alloc_desc(), vf_data_deleter(), vf_free(), and video_desc::width.

Here is the call graph for this function:

◆ REGISTER_MODULE()

REGISTER_MODULE ( dump ,
& display_dump_info,
LIBRARY_CLASS_VIDEO_DISPLAY ,
VIDEO_DISPLAY_ABI_VERSION  )

◆ usage()

static void usage ( void )
static

Definition at line 67 of file dump.c.

68{
69 color_printf("Usage:\n");
70 color_printf(TERM_BOLD TERM_FG_RED "\t-d dump" TERM_FG_RESET "[:<directory>] [--param decoder-use-codec=<c>]\n" TERM_RESET);
71 color_printf("where\n");
72 color_printf(TERM_BOLD "\t<directory>" TERM_RESET " - directory to save the dumped stream\n");
73 color_printf(TERM_BOLD "\t<c>" TERM_RESET " - codec to use instead of the received (default), must be a way to convert\n");
74}
int color_printf(const char *format,...)
#define TERM_BOLD
Definition color_out.h:48
#define TERM_FG_RED
Definition color_out.h:50
#define TERM_RESET
Definition color_out.h:47
#define TERM_FG_RESET
Definition color_out.h:59

References color_printf(), TERM_BOLD, TERM_FG_RED, TERM_FG_RESET, and TERM_RESET.

Referenced by display_dump_init().

Here is the call graph for this function:

Variable Documentation

◆ display_dump_info

const struct video_display_info display_dump_info
static
Initial value:
= {
NULL,
NULL,
NULL,
}
static void display_dump_probe(struct device_info **available_cards, int *count, void(**deleter)(void *))
Definition dump.c:180
static void display_dump_done(void *state)
Definition dump.c:102
static bool display_dump_reconfigure(void *state, struct video_desc desc)
Definition dump.c:162
static bool display_dump_get_property(void *state, int property, void *val, size_t *len)
Definition dump.c:134
static void * display_dump_init(struct module *parent, const char *cfg, unsigned int flags)
Definition dump.c:76
static struct video_frame * display_dump_getf(void *state)
Definition dump.c:111
#define MOD_NAME
Definition dump.c:57
static bool display_dump_putf(void *state, struct video_frame *frame, long long flags)
Definition dump.c:122

Definition at line 186 of file dump.c.

186 {
189 NULL, // _run
195 NULL, // _put_audio_frame
196 NULL, // _reconfigure_audio,
197 MOD_NAME,
198};