Commit 2c5ae577 authored by Michael Niedermayer's avatar Michael Niedermayer

Merge commit '6df9d9b5'

* commit '6df9d9b5':
  lavf: Use av_gettime_relative

Conflicts:
	libavformat/hls.c

See: f78bc96bMerged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents 2896b981 6df9d9b5
...@@ -666,7 +666,7 @@ static int parse_playlist(HLSContext *c, const char *url, ...@@ -666,7 +666,7 @@ static int parse_playlist(HLSContext *c, const char *url,
} }
} }
if (pls) if (pls)
pls->last_load_time = av_gettime(); pls->last_load_time = av_gettime_relative();
fail: fail:
av_free(new_url); av_free(new_url);
...@@ -1035,7 +1035,7 @@ restart: ...@@ -1035,7 +1035,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) {
av_log(v->parent, AV_LOG_WARNING, "Failed to reload playlist %d\n", av_log(v->parent, AV_LOG_WARNING, "Failed to reload playlist %d\n",
v->index); v->index);
...@@ -1055,7 +1055,7 @@ reload: ...@@ -1055,7 +1055,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);
...@@ -1198,7 +1198,7 @@ static int select_cur_seq_no(HLSContext *c, struct playlist *pls) ...@@ -1198,7 +1198,7 @@ static int select_cur_seq_no(HLSContext *c, struct playlist *pls)
int seq_no; int seq_no;
if (!pls->finished && !c->first_packet && if (!pls->finished && !c->first_packet &&
av_gettime() - pls->last_load_time >= default_reload_interval(pls)) av_gettime_relative() - pls->last_load_time >= default_reload_interval(pls))
/* reload the playlist since it was suspended */ /* reload the playlist since it was suspended */
parse_playlist(c, pls->url, pls, NULL); parse_playlist(c, pls->url, pls, NULL);
......
...@@ -169,7 +169,7 @@ static int parse_playlist(URLContext *h, const char *url) ...@@ -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: ...@@ -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: ...@@ -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);
......
...@@ -143,7 +143,7 @@ static int rtcp_parse_packet(RTPDemuxContext *s, const unsigned char *buf, ...@@ -143,7 +143,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) {
...@@ -323,7 +323,7 @@ int ff_rtp_check_and_send_back_rr(RTPDemuxContext *s, URLContext *fd, ...@@ -323,7 +323,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 */
...@@ -448,7 +448,7 @@ int ff_rtp_send_rtcp_feedback(RTPDemuxContext *s, URLContext *fd, ...@@ -448,7 +448,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;
...@@ -691,7 +691,7 @@ static void enqueue_packet(RTPDemuxContext *s, uint8_t *buf, int len) ...@@ -691,7 +691,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;
...@@ -769,7 +769,7 @@ static int rtp_parse_one_packet(RTPDemuxContext *s, AVPacket *pkt, ...@@ -769,7 +769,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);
......
...@@ -1183,7 +1183,7 @@ start: ...@@ -1183,7 +1183,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. */
...@@ -1280,7 +1280,7 @@ static int rtsp_send_cmd_with_content_async(AVFormatContext *s, ...@@ -1280,7 +1280,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;
} }
...@@ -1858,7 +1858,7 @@ static int udp_read_packet(AVFormatContext *s, RTSPStream **prtsp_st, ...@@ -1858,7 +1858,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) {
...@@ -2057,7 +2057,7 @@ redo: ...@@ -2057,7 +2057,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);
......
...@@ -887,7 +887,7 @@ retry: ...@@ -887,7 +887,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 &&
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment