summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlfred E. Heggestad <alfred.heggestad@gmail.com>2018-02-25 13:45:13 +0100
committerAlfred E. Heggestad <alfred.heggestad@gmail.com>2018-02-25 13:45:13 +0100
commit9780a6260a226f2c19673284730c25d381db074d (patch)
treeda0d6e3031cc6f697060b4c06d43e2860f456619 /src
parent59d29c0254b9240a00ac9236cc8e92c0ae65ec8a (diff)
video: change video_fps from int to double float
Diffstat (limited to 'src')
-rw-r--r--src/conf.c18
-rw-r--r--src/config.c6
-rw-r--r--src/core.h1
-rw-r--r--src/video.c12
-rw-r--r--src/vidutil.c2
5 files changed, 28 insertions, 11 deletions
diff --git a/src/conf.c b/src/conf.c
index 2046216..2bb7d5a 100644
--- a/src/conf.c
+++ b/src/conf.c
@@ -289,6 +289,24 @@ int conf_get_sa(const struct conf *conf, const char *name, struct sa *sa)
}
+int conf_get_float(const struct conf *conf, const char *name, double *val)
+{
+ struct pl opt;
+ int err;
+
+ if (!conf || !name || !val)
+ return EINVAL;
+
+ err = conf_get(conf, name, &opt);
+ if (err)
+ return err;
+
+ *val = pl_float(&opt);
+
+ return 0;
+}
+
+
/**
* Configure the system with default settings
*
diff --git a/src/config.c b/src/config.c
index 1e8b595..14bf651 100644
--- a/src/config.c
+++ b/src/config.c
@@ -319,7 +319,7 @@ int config_parse_conf(struct config *cfg, const struct conf *conf)
cfg->video.height = size.h;
}
(void)conf_get_u32(conf, "video_bitrate", &cfg->video.bitrate);
- (void)conf_get_u32(conf, "video_fps", &cfg->video.fps);
+ (void)conf_get_float(conf, "video_fps", &cfg->video.fps);
(void)conf_get_bool(conf, "video_fullscreen", &cfg->video.fullscreen);
conf_get_vidfmt(conf, "videnc_format", &cfg->video.enc_fmt);
@@ -410,7 +410,7 @@ int config_print(struct re_printf *pf, const struct config *cfg)
"video_display\t\t%s,%s\n"
"video_size\t\t\"%ux%u\"\n"
"video_bitrate\t\t%u\n"
- "video_fps\t\t%u\n"
+ "video_fps\t\t%.2f\n"
"\n"
#endif
"# AVT\n"
@@ -600,7 +600,7 @@ static int core_config_template(struct re_printf *pf, const struct config *cfg)
"#video_display\t\t%s\n"
"video_size\t\t%dx%d\n"
"video_bitrate\t\t%u\n"
- "video_fps\t\t%u\n"
+ "video_fps\t\t%.2f\n"
"video_fullscreen\tyes\n"
"videnc_format\t\t%s\n"
,
diff --git a/src/core.h b/src/core.h
index 4fdc509..c66dffc 100644
--- a/src/core.h
+++ b/src/core.h
@@ -201,6 +201,7 @@ int conf_get_range(const struct conf *conf, const char *name,
struct range *rng);
int conf_get_csv(const struct conf *conf, const char *name,
char *str1, size_t sz1, char *str2, size_t sz2);
+int conf_get_float(const struct conf *conf, const char *name, double *val);
/*
diff --git a/src/video.c b/src/video.c
index 4be9925..699fd01 100644
--- a/src/video.c
+++ b/src/video.c
@@ -329,16 +329,14 @@ static void video_destructor(void *arg)
}
-static int get_fps(const struct video *v)
+static double get_fps(const struct video *v)
{
const char *attr;
/* RFC4566 */
attr = sdp_media_rattr(stream_sdpmedia(v->strm), "framerate");
if (attr) {
- /* NOTE: fractional values are ignored */
- const double fps = atof(attr);
- return (int)fps;
+ return atof(attr);
}
else
return v->cfg.fps;
@@ -834,7 +832,7 @@ int video_alloc(struct video **vp, const struct stream_param *stream_prm,
}
err |= sdp_media_set_lattr(stream_sdpmedia(v->strm), true,
- "framerate", "%d", v->cfg.fps);
+ "framerate", "%.2f", v->cfg.fps);
/* RFC 4585 */
err |= sdp_media_set_lattr(stream_sdpmedia(v->strm), true,
@@ -1156,7 +1154,7 @@ int video_encoder_set(struct video *v, struct vidcodec *vc,
prm.fps = get_fps(v);
prm.max_fs = -1;
- info("Set video encoder: %s %s (%u bit/s, %u fps)\n",
+ info("Set video encoder: %s %s (%u bit/s, %.2f fps)\n",
vc->name, vc->variant, prm.bitrate, prm.fps);
vtx->enc = mem_deref(vtx->enc);
@@ -1318,7 +1316,7 @@ static int vtx_debug(struct re_printf *pf, const struct vtx *vtx)
err |= re_hprintf(pf, " tx: encode: %s %s\n",
vtx->vc ? vtx->vc->name : "none",
vtx->frame ? vidfmt_name(vtx->frame->fmt) : "?");
- err |= re_hprintf(pf, " source: %s %u x %u, fps=%d"
+ err |= re_hprintf(pf, " source: %s %u x %u, fps=%.2f"
" frames=%llu\n",
vtx->vsrc ? vidsrc_get(vtx->vsrc)->name : "none",
vtx->vsrc_size.w,
diff --git a/src/vidutil.c b/src/vidutil.c
index 26d17eb..abdddf7 100644
--- a/src/vidutil.c
+++ b/src/vidutil.c
@@ -21,7 +21,7 @@
*
* @return Extended RTP Timestamp
*/
-uint64_t video_calc_rtp_timestamp(int64_t pts, unsigned fps)
+uint64_t video_calc_rtp_timestamp(int64_t pts, double fps)
{
uint64_t rtp_ts;