79#define MAGIC_SAGE 0x3e960c47
105 struct timeval t,
t0;
140 switch (
msg.getCode()) {
142 sage::printLog(
"Ultragrid: QUIT message");
159 gettimeofday(&s->t, NULL);
162 float fps = s->
frames / seconds;
184 if(strcmp(
fmt,
"help") == 0) {
185 printf(
"SAGE usage:\n");
186 printf(
"\tuv -t sage[:config=<config_file>|:fs=<fsIP>][:codec=<fcc>][:d]\n");
187 printf(
"\t <config_file> - SAGE app config file, default \"ultragrid.conf\"\n");
188 printf(
"\t <fsIP> - FS manager IP address\n");
189 printf(
"\t <fcc> - FourCC of codec that will be used to transmit to SAGE\n");
190 printf(
"\t Supported options are UYVY, RGBA, RGB or DXT1\n");
191 printf(
"\t d - deinterlace output\n");
194 char *tmp, *parse_str;
195 tmp = parse_str = strdup(
fmt);
196 char *save_ptr = NULL;
199 while((
item = strtok_r(parse_str,
":", &save_ptr))) {
201 if(strncmp(
item,
"config=", strlen(
"config=")) == 0) {
203 }
else if(strncmp(
item,
"codec=", strlen(
"codec=")) == 0) {
205 if(strlen(
item + strlen(
"codec=")) !=
sizeof(fourcc)) {
206 fprintf(stderr,
"Malformed FourCC code (wrong length).\n");
207 free(s);
return NULL;
209 memcpy((
void *) &fourcc,
item + strlen(
"codec="),
sizeof(fourcc));
212 fprintf(stderr,
"Codec not found according to FourCC.\n");
213 free(s);
return NULL;
219#ifdef SAGE_NATIVE_DXT5YCOCG
223 fprintf(stderr,
"Entered codec is not nativelly supported by SAGE.\n");
224 free(s);
return NULL;
226 }
else if(strcmp(
item,
"tx") == 0) {
228 }
else if(strncmp(
item,
"fs=", strlen(
"fs=")) == 0) {
230 }
else if(strcmp(
item,
"d") == 0) {
233 fprintf(stderr,
"[SAGE] unrecognized configuration: %s\n",
248 perror(
"Unable to use SAGE config file");
252 }
else if(stat(
"ultragrid.conf", &sb) == 0) {
256 printf(
"[SAGE] Using config file %s.\n", s->
confName);
261 fprintf(stderr,
"[SAGE] Unable to locate FS manager address. "
262 "Set either in config file or from command line.\n");
269 gettimeofday(&s->
t0, NULL);
359 printf(
"frame drop!\n");
377 strncpy(sailCfg.fsIP,
fsIP, SAGE_IP_LEN - 1);
379 sailCfg.fsPort = 20002;
380 strncpy(sailCfg.masterIP,
"127.0.0.1", SAGE_IP_LEN - 1);
382 sailCfg.msgPort = 23010;
383 sailCfg.syncPort = 13010;
384 sailCfg.blockSize = 64;
385 sailCfg.winX = sailCfg.winY = 0;
386 sailCfg.winWidth = width;
387 sailCfg.winHeight = height;
388 sailCfg.streamType = SAGE_BLOCK_NO_SYNC;
389 sailCfg.protocol = SAGE_UDP;
390 sailCfg.asyncUpdate =
false;
395 char appName[] =
"ultragrid";
396 sailCfg.setAppName(appName);
398 sailCfg.appID =
appID;
399 sailCfg.resX = width;
400 sailCfg.resY = height;
402 sageRect renderImageMap;
403 renderImageMap.left = 0.0;
404 renderImageMap.right = 1.0;
405 renderImageMap.bottom = 0.0;
406 renderImageMap.top = 1.0;
408 sailCfg.imageMap = renderImageMap;
411 sailCfg.pixFmt = PIXFMT_DXT;
413#ifdef SAGE_NATIVE_DXT5YCOCG
415 sailCfg.pixFmt = PIXFMT_DXT5YCOCG
419 sailCfg.pixFmt = PIXFMT_8888;
422 sailCfg.pixFmt = PIXFMT_YUV;
425 sailCfg.pixFmt = PIXFMT_888;
432 sailCfg.rowOrd = BOTTOM_TO_TOP;
433#ifdef SAGE_NATIVE_DXT5YCOCG
435 sailCfg.rowOrd = BOTTOM_TO_TOP;
438 sailCfg.rowOrd = TOP_TO_BOTTOM;
440 sailCfg.master =
true;
442 sageInf->init(sailCfg);
454#ifdef SAGE_NATIVE_DXT5YCOCG
467 sigset_t mask, old_mask;
469 sigaddset(&mask, SIGINT);
470 sigaddset(&mask, SIGTERM);
471 sigaddset(&mask, SIGHUP);
472 pthread_sigmask(SIG_BLOCK, &mask, &old_mask);
483 pthread_sigmask(SIG_UNBLOCK, &old_mask, NULL);
496#ifdef SAGE_NATIVE_DXT5YCOCG
500 int rgb_shift[] = {0, 8, 16};
521 if(
sizeof(rgb_shift) > *
len) {
524 memcpy(
val, rgb_shift,
sizeof(rgb_shift));
525 *
len =
sizeof(rgb_shift);
558 strcpy((*available_cards)[0].
dev,
"");
559 strcpy((*available_cards)[0].
name,
"SAGE display wall");
560 (*available_cards)[0].repeatable =
true;
struct video_frame long long nonblock
struct video_frame * frame
const char unsigned int flags
int void(** deleter)(void *))
struct video_frame * vf_alloc(int count)
Allocates blank video frame.
void vf_free(struct video_frame *buf)
Frees video_frame structure.
int vc_get_linesize(unsigned int width, codec_t codec)
void log_msg(int level, const char *format,...)
#define LOG_LEVEL_INFO
normal reporting
#define debug_msg(...)
#define debug_msg(...) log_msg(LOG_LEVEL_DEBUG, "[pid/%d +%d %s] ", getpid(), LINE,...
#define PITCH_DEFAULT
default pitch, i. e. respective linesize
#define VIDEO_DISPLAY_ABI_VERSION
#define DISPLAY_NO_GENERIC_FPS_INDICATOR
@ DISPLAY_PROPERTY_BUF_PITCH
requested framebuffer pitch - int (bytes), may be PITCH_DEFAULT
@ DISPLAY_PROPERTY_RGB_SHIFT
red,green,blue shift - int[3] (bits)
@ DISPLAY_PROPERTY_CODECS
list of natively supported codecs - codec_t[]
@ LIBRARY_CLASS_VIDEO_DISPLAY
#define REGISTER_MODULE(name, info, lclass, abi)
Registers module to global modules' registry.
struct used to comunicate with audio capture/playback device
struct video_frame * frame
codec_t requestedDisplayCodec
pthread_cond_t buffer_writable_cond
volatile unsigned int grab_waiting
pthread_mutex_t buffer_writable_lock
volatile bool should_exit
volatile unsigned int buffer_writable
Struct tile is an area of video_frame.
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 (!)
Struct video_frame represents a video frame and contains video description.
enum interlacing_t interlacing
double tv_diff(struct timeval curr_time, struct timeval prev_time)
@ DXT1
S3 Texture Compression DXT1.
@ RGB
RGB 8-bit (packed into 24-bit word)
@ UYVY
YCbCr 422 8-bit - Cb Y0 Cr Y1.
@ VIDEO_CODEC_NONE
dummy color spec
@ DXT5
S3 Texture Compression DXT5.
@ RGBA
RGBA 8-bit, big-endian.
This is an umbrella header for video functions.
void vc_deinterlace(unsigned char *src, long src_linesize, int lines)
Deinterlaces framebuffer.
codec_t get_codec_from_fcc(uint32_t fourcc)
static struct video_frame * display_sage_getf(void *state)
static int display_sage_handle_events(void)
static void display_sage_probe(struct device_info **available_cards, int *count, void(**deleter)(void *))
static void display_sage_put_audio_frame(void *state, const struct audio_frame *frame)
static void * display_sage_init(struct module *parent, const char *fmt, unsigned int flags)
static void display_sage_run(void *arg)
static void display_sage_done(void *state)
static bool display_sage_reconfigure(void *state, struct video_desc desc)
static bool display_sage_putf(void *state, struct video_frame *frame, long long nonblock)
static bool display_sage_reconfigure_audio(void *state, int quant_samples, int channels, int sample_rate)
static const struct video_display_info display_sage_info
static sail * initSage(const char *confName, const char *fsIP, int appID, int nodeID, int width, int height, codec_t codec)
static bool display_sage_get_property(void *state, int property, void *val, size_t *len)
struct tile * vf_get_tile(struct video_frame *buf, int pos)
Returns pointer to n-th tile from video frame Equivalent to &video_frame::tiles[pos].