diff --git a/ultragrid/src/rtp/decoders.c b/ultragrid/src/rtp/decoders.c index 5d40aa4f5..28d91bec8 100644 --- a/ultragrid/src/rtp/decoders.c +++ b/ultragrid/src/rtp/decoders.c @@ -64,6 +64,7 @@ void decode_frame(struct coded_data *cdata, struct video_frame *frame) payload_hdr_t *hdr; uint32_t data_pos; int prints=0; + double fps; while (cdata != NULL) { pckt = cdata->data; @@ -73,15 +74,17 @@ void decode_frame(struct coded_data *cdata, struct video_frame *frame) color_spec = hdr->colorspc; len = ntohs(hdr->length); data_pos = ntohl(hdr->offset); + fps = ntohl(hdr->fps)/65536.0; /* Critical section * each thread *MUST* wait here if this condition is true */ if (!(frame->width == width && frame->height == height && - frame->color_spec == color_spec)) { + frame->color_spec == color_spec && + frame->fps == fps)) { frame->reconfigure(frame->state, width, height, - color_spec); + color_spec, fps); frame->src_linesize = vc_getsrc_linesize(width, color_spec); } diff --git a/ultragrid/src/rtp/rtp_callback.h b/ultragrid/src/rtp/rtp_callback.h index d02c28cbf..01efdea9b 100644 --- a/ultragrid/src/rtp/rtp_callback.h +++ b/ultragrid/src/rtp/rtp_callback.h @@ -57,6 +57,7 @@ typedef struct { uint16_t length; /* octets */ uint8_t colorspc; uint8_t flags; + uint32_t fps; /* fixed point fps. take care! */ } payload_hdr_t; /* FIXME: this is only needed because fdisplay() takes "struct display" as a parameter */ diff --git a/ultragrid/src/transmit.c b/ultragrid/src/transmit.c index a7d0f4829..67748fb4e 100644 --- a/ultragrid/src/transmit.c +++ b/ultragrid/src/transmit.c @@ -127,6 +127,7 @@ tx_send(struct video_tx *tx, struct video_frame *frame, struct rtp *rtp_session) payload_hdr.width = htons(frame->width); payload_hdr.height = htons(frame->height); payload_hdr.colorspc = frame->color_spec; + payload_hdr.fps = htonl((int)(frame->fps * 65536)); do { payload_hdr.offset = htonl(pos); diff --git a/ultragrid/src/video_codec.h b/ultragrid/src/video_codec.h index 3b6dd4edd..d7696c0e8 100644 --- a/ultragrid/src/video_codec.h +++ b/ultragrid/src/video_codec.h @@ -59,7 +59,7 @@ typedef enum { } codec_t; typedef void (*decoder_t)(unsigned char *dst, unsigned char *src, int dst_len, int rshift, int gshift, int bshift); -typedef void (*reconfigure_t)(void *state, int width, int height, codec_t color_spec); +typedef void (*reconfigure_t)(void *state, int width, int height, codec_t color_spec, double fps); struct video_frame { @@ -83,6 +83,7 @@ struct video_frame { decoder_t decoder; reconfigure_t reconfigure; void *state; + double fps; }; diff --git a/ultragrid/src/video_display/hdstation.c b/ultragrid/src/video_display/hdstation.c index 67715d724..d287ce597 100644 --- a/ultragrid/src/video_display/hdstation.c +++ b/ultragrid/src/video_display/hdstation.c @@ -70,15 +70,6 @@ #define HDSP_MAGIC 0x12345678 -typedef struct { - char *name; - int mode; - double fps; - unsigned int width; - unsigned int height; - char interlaced; -} hdsp_mode_table_t; - const hdsp_mode_table_t hdsp_mode_table[] = { {"SMPTE274", SV_MODE_SMPTE274_25P, 25, 1920, 1080, 0}, {"SMPTE274", SV_MODE_SMPTE274_29I, 29, 1920, 1080, 1}, @@ -105,7 +96,6 @@ volatile int worker_waiting; struct video_frame frame; const hdsp_mode_table_t *mode; unsigned interlaced:1; - double fps; }; static void *display_thread_hd(void *arg) @@ -197,7 +187,7 @@ int display_hdstation_putf(void *state, char *frame) static void reconfigure_screen(void *state, unsigned int width, unsigned int height, - codec_t color_spec) + codec_t color_spec, double fps) { struct state_hdsp *s = (struct state_hdsp *)state; int i, res; @@ -210,7 +200,7 @@ reconfigure_screen(void *state, unsigned int width, unsigned int height, if(hdsp_mode_table[i].width == width && hdsp_mode_table[i].height == height && s->interlaced == hdsp_mode_table[i].interlaced && - s->fps == hdsp_mode_table[i].fps) { + fps == hdsp_mode_table[i].fps) { s->mode = &hdsp_mode_table[i]; break; } @@ -219,7 +209,7 @@ reconfigure_screen(void *state, unsigned int width, unsigned int height, if(s->mode == NULL) { fprintf(stderr, "Reconfigure failed. Expect troubles pretty soon..\n" "\tRequested: %dx%d, color space %d, fps %f, interlaced: %d\n", - width, height, color_spec, s->fps, s->interlaced); + width, height, color_spec, fps, s->interlaced); return; } @@ -227,6 +217,7 @@ reconfigure_screen(void *state, unsigned int width, unsigned int height, s->frame.width = width; s->frame.height = height; s->frame.dst_bpp = get_bpp(color_spec); + s->frame.fps = fps; s->hd_video_mode = SV_MODE_COLOR_YUV422 | SV_MODE_ACTIVE_STREAMER; @@ -290,7 +281,7 @@ void *display_hdstation_init(char *fmt) if (fmt != NULL) { if (strcmp(fmt, "help") == 0) { printf("hdstation options:\n"); - printf("\tfps:[mode:[codec:[i|p]]]\n"); + printf("\t[fps:[mode:[codec:[i|p]]]]\n"); return 0; } @@ -359,7 +350,7 @@ void *display_hdstation_init(char *fmt) } if(s->mode) { - reconfigure_screen(s, s->mode->width, s->mode->height, s->frame.color_spec); + reconfigure_screen(s, s->mode->width, s->mode->height, s->frame.color_spec, s->mode->fps); } pthread_mutex_init(&s->lock, NULL); @@ -377,7 +368,7 @@ void *display_hdstation_init(char *fmt) } s->frame.state = s; s->frame.reconfigure = (reconfigure_t)reconfigure_screen; - s->frame.decoder = (decoder_t)memcpy; + s->frame.decoder = (decoder_t)memcpy; return (void *)s; } diff --git a/ultragrid/src/video_display/hdstation.h b/ultragrid/src/video_display/hdstation.h index 7f74b41f1..b28792d0e 100644 --- a/ultragrid/src/video_display/hdstation.h +++ b/ultragrid/src/video_display/hdstation.h @@ -42,6 +42,7 @@ * $Date: 2010/01/28 18:17:28 $ * */ +#include #define DISPLAY_HDSTATION_ID 0x74ac3e0f diff --git a/ultragrid/src/video_display/sdl.c b/ultragrid/src/video_display/sdl.c index cc79eaa72..07fcfdc83 100644 --- a/ultragrid/src/video_display/sdl.c +++ b/ultragrid/src/video_display/sdl.c @@ -114,7 +114,7 @@ struct state_sdl { void show_help(void); void cleanup_screen(struct state_sdl *s); void reconfigure_screen(void *s, unsigned int width, unsigned int height, - codec_t codec); + codec_t codec, double fps); extern int should_exit; @@ -211,7 +211,7 @@ void cleanup_screen(struct state_sdl *s) void reconfigure_screen(void *state, unsigned int width, unsigned int height, - codec_t color_spec) + codec_t color_spec, double fps) { struct state_sdl *s = (struct state_sdl *)state; int itemp; @@ -229,6 +229,7 @@ reconfigure_screen(void *state, unsigned int width, unsigned int height, s->frame.width = width; s->frame.height = height; + s->frame.fps = fps; ret = XGetGeometry(s->display, DefaultRootWindow(s->display), &wtemp, @@ -463,7 +464,7 @@ void *display_sdl_init(char *fmt) } if (fmt != NULL) { - reconfigure_screen(s, s->frame.width, s->frame.height, s->codec_info->codec); + reconfigure_screen(s, s->frame.width, s->frame.height, s->codec_info->codec, s->frame.fps); temp = SDL_LoadBMP("/usr/share/uv-0.3.1/uv_startup.bmp"); if (temp == NULL) { temp =