@@ -96,6 +96,7 @@ const AVOption ff_rtsp_options[] = {
{ "min_port", "set minimum local UDP port", OFFSET(rtp_port_min), AV_OPT_TYPE_INT, {.i64 = RTSP_RTP_PORT_MIN}, 0, 65535, DEC|ENC },
{ "max_port", "set maximum local UDP port", OFFSET(rtp_port_max), AV_OPT_TYPE_INT, {.i64 = RTSP_RTP_PORT_MAX}, 0, 65535, DEC|ENC },
{ "listen_timeout", "set maximum timeout (in seconds) to wait for incoming connections (-1 is infinite, imply flag listen)", OFFSET(initial_timeout), AV_OPT_TYPE_INT, {.i64 = -1}, INT_MIN, INT_MAX, DEC },
+ { "first_rtcp_ntp_time_path", "path to write first NTP time (in microseconds) received in RTCP packet", OFFSET(first_rtcp_ntp_time_path), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC },
#if FF_API_OLD_RTSP_OPTIONS
{ "timeout", "set maximum timeout (in seconds) to wait for incoming connections (-1 is infinite, imply flag listen) (deprecated, use listen_timeout)", OFFSET(initial_timeout), AV_OPT_TYPE_INT, {.i64 = -1}, INT_MIN, INT_MAX, DEC },
{ "stimeout", "set timeout (in microseconds) of socket TCP I/O operations", OFFSET(stimeout), AV_OPT_TYPE_INT, {.i64 = 0}, INT_MIN, INT_MAX, DEC },
@@ -2256,6 +2257,21 @@ redo:
(uint64_t) rtpctx->st->time_base.num * 1000000,
rtpctx->st->time_base.den);
}
+
+ // Write the NTP start time
+ if (rt->first_rtcp_ntp_time_path) {
+ AVIOContext *ioctx = NULL;
+ int ret;
+ ret = avio_open(&ioctx, rt->first_rtcp_ntp_time_path, AVIO_FLAG_WRITE);
+ if (ret < 0) {
+ av_log(s, AV_LOG_WARNING, "unable to open %s to write first rtcp ntp time\n", rt->first_rtcp_ntp_time_path);
+ } else {
+ char buf[21] = "";
+ av_strlcatf(buf, sizeof(buf), "%"PRIi64, s->start_time_realtime);
+ avio_write(ioctx, buf, strlen(buf));
+ avio_closep(&ioctx);
+ }
+ }
}
}
if (ret == -RTCP_BYE) {
@@ -408,6 +408,12 @@ typedef struct RTSPState {
*/
char *user_agent;
+ /**
+ * Path to write the first RTCP unix time in microseconds, if
+ * it is received as part of the stream.
+ */
+ char *first_rtcp_ntp_time_path;
+
char default_lang[4];
int buffer_size;
int pkt_size;