summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core.h3
-rw-r--r--src/srcs.mk1
-rw-r--r--src/video.c38
-rw-r--r--src/vidutil.c52
4 files changed, 56 insertions, 38 deletions
diff --git a/src/core.h b/src/core.h
index a390e0c..3c1ba2b 100644
--- a/src/core.h
+++ b/src/core.h
@@ -35,7 +35,8 @@ enum {
/** Media constants */
enum {
- AUDIO_BANDWIDTH = 128000 /**< Bandwidth for audio in bits/s */
+ AUDIO_BANDWIDTH = 128000, /**< Bandwidth for audio in bits/s */
+ VIDEO_SRATE = 90000, /**< Sampling rate for video */
};
diff --git a/src/srcs.mk b/src/srcs.mk
index a35e0d8..4e9a2a7 100644
--- a/src/srcs.mk
+++ b/src/srcs.mk
@@ -46,6 +46,7 @@ SRCS += vidcodec.c
SRCS += vidfilt.c
SRCS += vidisp.c
SRCS += vidsrc.c
+SRCS += vidutil.c
endif
ifneq ($(STATIC),)
diff --git a/src/video.c b/src/video.c
index f191215..5c1b8bb 100644
--- a/src/video.c
+++ b/src/video.c
@@ -25,7 +25,6 @@
enum {
- SRATE = 90000,
MAX_MUTED_FRAMES = 3,
};
@@ -980,7 +979,7 @@ int video_start(struct video *v, const char *peer)
return err;
}
- stream_set_srate(v->strm, SRATE, SRATE);
+ stream_set_srate(v->strm, VIDEO_SRATE, VIDEO_SRATE);
if (vidisp_find(baresip_vidispl(), NULL)) {
err = set_vidisp(&v->vrx);
@@ -1384,38 +1383,3 @@ void video_set_devicename(struct video *v, const char *src, const char *disp)
str_ncpy(v->vtx.device, src, sizeof(v->vtx.device));
str_ncpy(v->vrx.device, disp, sizeof(v->vrx.device));
}
-
-
-/**
- * Calculate the RTP timestamp from Presentation Time Stamp (PTS)
- * or Decoding Time Stamp (DTS) and framerate.
- *
- * @note The calculated RTP Timestamp may wrap around.
- *
- * @param pts Presentation Time Stamp (PTS)
- * @param fps Framerate in [frames per second]
- *
- * @return RTP Timestamp
- */
-uint32_t video_calc_rtp_timestamp(int64_t pts, unsigned fps)
-{
- uint64_t rtp_ts;
-
- if (!fps)
- return 0;
-
- rtp_ts = ((uint64_t)SRATE * pts) / fps;
-
- return (uint32_t)rtp_ts;
-}
-
-
-double video_calc_seconds(uint32_t rtp_ts)
-{
- double timestamp;
-
- /* convert from RTP clockrate to seconds */
- timestamp = (double)rtp_ts / (double)SRATE;
-
- return timestamp;
-}
diff --git a/src/vidutil.c b/src/vidutil.c
new file mode 100644
index 0000000..b55f216
--- /dev/null
+++ b/src/vidutil.c
@@ -0,0 +1,52 @@
+/**
+ * @file vidutil.c Video utility functions
+ *
+ * Copyright (C) 2017 Creytiv.com
+ */
+
+#include <re.h>
+#include <rem.h>
+#include <baresip.h>
+#include "core.h"
+
+
+/**
+ * Calculate the RTP timestamp from Presentation Time Stamp (PTS)
+ * or Decoding Time Stamp (DTS) and framerate.
+ *
+ * @note The calculated RTP Timestamp may wrap around.
+ *
+ * @param pts Presentation Time Stamp (PTS)
+ * @param fps Framerate in [frames per second]
+ *
+ * @return RTP Timestamp
+ */
+uint32_t video_calc_rtp_timestamp(int64_t pts, unsigned fps)
+{
+ uint64_t rtp_ts;
+
+ if (!fps)
+ return 0;
+
+ rtp_ts = ((uint64_t)VIDEO_SRATE * pts) / fps;
+
+ return (uint32_t)rtp_ts;
+}
+
+
+/**
+ * Calculate the timestamp in seconds from the RTP timestamp.
+ *
+ * @param rtp_ts RTP Timestamp
+ *
+ * @return Timestamp in seconds
+ */
+double video_calc_seconds(uint32_t rtp_ts)
+{
+ double timestamp;
+
+ /* convert from RTP clockrate to seconds */
+ timestamp = (double)rtp_ts / (double)VIDEO_SRATE;
+
+ return timestamp;
+}