1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-08-10 06:10:52 +02:00

lavf: Use av_gettime_relative

The ones left using av_gettime are NTP timestamps (for RTCP,
which is specified to send the actual current realtime clock
in RTCP SR packets), and the NUT muxer timestamper, which is
documented as using wallclock time.

Signed-off-by: Martin Storsjö <martin@martin.st>
This commit is contained in:
Martin Storsjö
2014-10-22 12:40:46 +03:00
parent d0c0930219
commit 6df9d9b55d
6 changed files with 17 additions and 17 deletions

View File

@@ -320,7 +320,7 @@ static int parse_playlist(HLSContext *c, const char *url,
} }
} }
if (var) if (var)
var->last_load_time = av_gettime(); var->last_load_time = av_gettime_relative();
fail: fail:
av_free(new_url); av_free(new_url);
@@ -392,7 +392,7 @@ restart:
reload: reload:
if (!v->finished && if (!v->finished &&
av_gettime() - v->last_load_time >= reload_interval) { av_gettime_relative() - v->last_load_time >= reload_interval) {
if ((ret = parse_playlist(c, v->url, v, NULL)) < 0) if ((ret = parse_playlist(c, v->url, v, NULL)) < 0)
return ret; return ret;
/* If we need to reload the playlist again below (if /* If we need to reload the playlist again below (if
@@ -409,7 +409,7 @@ reload:
if (v->cur_seq_no >= v->start_seq_no + v->n_segments) { if (v->cur_seq_no >= v->start_seq_no + v->n_segments) {
if (v->finished) if (v->finished)
return AVERROR_EOF; return AVERROR_EOF;
while (av_gettime() - v->last_load_time < reload_interval) { while (av_gettime_relative() - v->last_load_time < reload_interval) {
if (ff_check_interrupt(c->interrupt_callback)) if (ff_check_interrupt(c->interrupt_callback))
return AVERROR_EXIT; return AVERROR_EXIT;
av_usleep(100*1000); av_usleep(100*1000);

View File

@@ -169,7 +169,7 @@ static int parse_playlist(URLContext *h, const char *url)
} }
} }
} }
s->last_load_time = av_gettime(); s->last_load_time = av_gettime_relative();
fail: fail:
avio_close(in); avio_close(in);
@@ -273,7 +273,7 @@ start:
s->target_duration; s->target_duration;
retry: retry:
if (!s->finished) { if (!s->finished) {
int64_t now = av_gettime(); int64_t now = av_gettime_relative();
if (now - s->last_load_time >= reload_interval) { if (now - s->last_load_time >= reload_interval) {
if ((ret = parse_playlist(h, s->playlisturl)) < 0) if ((ret = parse_playlist(h, s->playlisturl)) < 0)
return ret; return ret;
@@ -292,7 +292,7 @@ retry:
if (s->cur_seq_no - s->start_seq_no >= s->n_segments) { if (s->cur_seq_no - s->start_seq_no >= s->n_segments) {
if (s->finished) if (s->finished)
return AVERROR_EOF; return AVERROR_EOF;
while (av_gettime() - s->last_load_time < reload_interval) { while (av_gettime_relative() - s->last_load_time < reload_interval) {
if (ff_check_interrupt(&h->interrupt_callback)) if (ff_check_interrupt(&h->interrupt_callback))
return AVERROR_EXIT; return AVERROR_EXIT;
av_usleep(100*1000); av_usleep(100*1000);

View File

@@ -135,7 +135,7 @@ static int rtcp_parse_packet(RTPDemuxContext *s, const unsigned char *buf,
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
s->last_rtcp_reception_time = av_gettime(); s->last_rtcp_reception_time = av_gettime_relative();
s->last_rtcp_ntp_time = AV_RB64(buf + 8); s->last_rtcp_ntp_time = AV_RB64(buf + 8);
s->last_rtcp_timestamp = AV_RB32(buf + 16); s->last_rtcp_timestamp = AV_RB32(buf + 16);
if (s->first_rtcp_ntp_time == AV_NOPTS_VALUE) { if (s->first_rtcp_ntp_time == AV_NOPTS_VALUE) {
@@ -315,7 +315,7 @@ int ff_rtp_check_and_send_back_rr(RTPDemuxContext *s, URLContext *fd,
avio_wb32(pb, 0); /* delay since last SR */ avio_wb32(pb, 0); /* delay since last SR */
} else { } else {
uint32_t middle_32_bits = s->last_rtcp_ntp_time >> 16; // this is valid, right? do we need to handle 64 bit values special? uint32_t middle_32_bits = s->last_rtcp_ntp_time >> 16; // this is valid, right? do we need to handle 64 bit values special?
uint32_t delay_since_last = av_rescale(av_gettime() - s->last_rtcp_reception_time, uint32_t delay_since_last = av_rescale(av_gettime_relative() - s->last_rtcp_reception_time,
65536, AV_TIME_BASE); 65536, AV_TIME_BASE);
avio_wb32(pb, middle_32_bits); /* last SR timestamp */ avio_wb32(pb, middle_32_bits); /* last SR timestamp */
@@ -440,7 +440,7 @@ int ff_rtp_send_rtcp_feedback(RTPDemuxContext *s, URLContext *fd,
/* Send new feedback if enough time has elapsed since the last /* Send new feedback if enough time has elapsed since the last
* feedback packet. */ * feedback packet. */
now = av_gettime(); now = av_gettime_relative();
if (s->last_feedback_time && if (s->last_feedback_time &&
(now - s->last_feedback_time) < MIN_FEEDBACK_INTERVAL) (now - s->last_feedback_time) < MIN_FEEDBACK_INTERVAL)
return 0; return 0;
@@ -683,7 +683,7 @@ static void enqueue_packet(RTPDemuxContext *s, uint8_t *buf, int len)
packet = av_mallocz(sizeof(*packet)); packet = av_mallocz(sizeof(*packet));
if (!packet) if (!packet)
return; return;
packet->recvtime = av_gettime(); packet->recvtime = av_gettime_relative();
packet->seq = seq; packet->seq = seq;
packet->len = len; packet->len = len;
packet->buf = buf; packet->buf = buf;
@@ -761,7 +761,7 @@ static int rtp_parse_one_packet(RTPDemuxContext *s, AVPacket *pkt,
} }
if (s->st) { if (s->st) {
int64_t received = av_gettime(); int64_t received = av_gettime_relative();
uint32_t arrival_ts = av_rescale_q(received, AV_TIME_BASE_Q, uint32_t arrival_ts = av_rescale_q(received, AV_TIME_BASE_Q,
s->st->time_base); s->st->time_base);
timestamp = AV_RB32(buf + 4); timestamp = AV_RB32(buf + 4);

View File

@@ -1179,7 +1179,7 @@ start:
} }
ffurl_write(rt->rtsp_hd_out, ptr, strlen(ptr)); ffurl_write(rt->rtsp_hd_out, ptr, strlen(ptr));
rt->last_cmd_time = av_gettime(); rt->last_cmd_time = av_gettime_relative();
/* Even if the request from the server had data, it is not the data /* Even if the request from the server had data, it is not the data
* that the caller wants or expects. The memory could also be leaked * that the caller wants or expects. The memory could also be leaked
* if the actual following reply has content data. */ * if the actual following reply has content data. */
@@ -1276,7 +1276,7 @@ static int rtsp_send_cmd_with_content_async(AVFormatContext *s,
} }
ffurl_write(rt->rtsp_hd_out, send_content, send_content_length); ffurl_write(rt->rtsp_hd_out, send_content, send_content_length);
} }
rt->last_cmd_time = av_gettime(); rt->last_cmd_time = av_gettime_relative();
return 0; return 0;
} }
@@ -1851,7 +1851,7 @@ static int udp_read_packet(AVFormatContext *s, RTSPStream **prtsp_st,
for (;;) { for (;;) {
if (ff_check_interrupt(&s->interrupt_callback)) if (ff_check_interrupt(&s->interrupt_callback))
return AVERROR_EXIT; return AVERROR_EXIT;
if (wait_end && wait_end - av_gettime() < 0) if (wait_end && wait_end - av_gettime_relative() < 0)
return AVERROR(EAGAIN); return AVERROR(EAGAIN);
max_p = 0; max_p = 0;
if (rt->rtsp_hd) { if (rt->rtsp_hd) {
@@ -2050,7 +2050,7 @@ redo:
break; break;
case RTSP_LOWER_TRANSPORT_CUSTOM: case RTSP_LOWER_TRANSPORT_CUSTOM:
if (first_queue_st && rt->transport == RTSP_TRANSPORT_RTP && if (first_queue_st && rt->transport == RTSP_TRANSPORT_RTP &&
wait_end && wait_end < av_gettime()) wait_end && wait_end < av_gettime_relative())
len = AVERROR(EAGAIN); len = AVERROR(EAGAIN);
else else
len = ffio_read_partial(s->pb, rt->recvbuf, RECVBUF_SIZE); len = ffio_read_partial(s->pb, rt->recvbuf, RECVBUF_SIZE);

View File

@@ -885,7 +885,7 @@ retry:
if (!(rt->rtsp_flags & RTSP_FLAG_LISTEN)) { if (!(rt->rtsp_flags & RTSP_FLAG_LISTEN)) {
/* send dummy request to keep TCP connection alive */ /* send dummy request to keep TCP connection alive */
if ((av_gettime() - rt->last_cmd_time) / 1000000 >= rt->timeout / 2 || if ((av_gettime_relative() - rt->last_cmd_time) / 1000000 >= rt->timeout / 2 ||
rt->auth_state.stale) { rt->auth_state.stale) {
if (rt->server_type == RTSP_SERVER_WMS || if (rt->server_type == RTSP_SERVER_WMS ||
(rt->server_type != RTSP_SERVER_REAL && (rt->server_type != RTSP_SERVER_REAL &&

View File

@@ -245,7 +245,7 @@ static int sap_write_packet(AVFormatContext *s, AVPacket *pkt)
{ {
AVFormatContext *rtpctx; AVFormatContext *rtpctx;
struct SAPState *sap = s->priv_data; struct SAPState *sap = s->priv_data;
int64_t now = av_gettime(); int64_t now = av_gettime_relative();
if (!sap->last_time || now - sap->last_time > 5000000) { if (!sap->last_time || now - sap->last_time > 5000000) {
int ret = ffurl_write(sap->ann_fd, sap->ann, sap->ann_size); int ret = ffurl_write(sap->ann_fd, sap->ann, sap->ann_size);