[FFmpeg-cvslog] Merge commit '150e99d694f33ab9ad678834964909aa315d14a1'
James Almer
git at videolan.org
Wed Oct 4 03:58:49 EEST 2017
ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Tue Oct 3 21:34:08 2017 -0300| [c244d4af43a160cfff84e368b5591f2a411eb001] | committer: James Almer
Merge commit '150e99d694f33ab9ad678834964909aa315d14a1'
* commit '150e99d694f33ab9ad678834964909aa315d14a1':
rtsp: Factor out packet reading
Merged-by: James Almer <jamrial at gmail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c244d4af43a160cfff84e368b5591f2a411eb001
---
libavformat/rtsp.c | 66 +++++++++++++++++++++++++++++++++---------------------
1 file changed, 40 insertions(+), 26 deletions(-)
diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index 0bd72dc5ce..736559eab3 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -2054,6 +2054,44 @@ static int pick_stream(AVFormatContext *s, RTSPStream **rtsp_st,
return AVERROR(EAGAIN);
}
+static int read_packet(AVFormatContext *s,
+ RTSPStream **rtsp_st, RTSPStream *first_queue_st,
+ int64_t wait_end)
+{
+ RTSPState *rt = s->priv_data;
+ int len;
+
+ switch(rt->lower_transport) {
+ default:
+#if CONFIG_RTSP_DEMUXER
+ case RTSP_LOWER_TRANSPORT_TCP:
+ len = ff_rtsp_tcp_read_packet(s, rtsp_st, rt->recvbuf, RECVBUF_SIZE);
+ break;
+#endif
+ case RTSP_LOWER_TRANSPORT_UDP:
+ case RTSP_LOWER_TRANSPORT_UDP_MULTICAST:
+ len = udp_read_packet(s, rtsp_st, rt->recvbuf, RECVBUF_SIZE, wait_end);
+ if (len > 0 && (*rtsp_st)->transport_priv && rt->transport == RTSP_TRANSPORT_RTP)
+ ff_rtp_check_and_send_back_rr((*rtsp_st)->transport_priv, (*rtsp_st)->rtp_handle, NULL, len);
+ break;
+ case RTSP_LOWER_TRANSPORT_CUSTOM:
+ if (first_queue_st && rt->transport == RTSP_TRANSPORT_RTP &&
+ wait_end && wait_end < av_gettime_relative())
+ len = AVERROR(EAGAIN);
+ else
+ len = avio_read_partial(s->pb, rt->recvbuf, RECVBUF_SIZE);
+ len = pick_stream(s, rtsp_st, rt->recvbuf, len);
+ if (len > 0 && (*rtsp_st)->transport_priv && rt->transport == RTSP_TRANSPORT_RTP)
+ ff_rtp_check_and_send_back_rr((*rtsp_st)->transport_priv, NULL, s->pb, len);
+ break;
+ }
+
+ if (len == 0)
+ return AVERROR_EOF;
+
+ return len;
+}
+
int ff_rtsp_fetch_packet(AVFormatContext *s, AVPacket *pkt)
{
RTSPState *rt = s->priv_data;
@@ -2118,30 +2156,7 @@ redo:
return AVERROR(ENOMEM);
}
- switch(rt->lower_transport) {
- default:
-#if CONFIG_RTSP_DEMUXER
- case RTSP_LOWER_TRANSPORT_TCP:
- len = ff_rtsp_tcp_read_packet(s, &rtsp_st, rt->recvbuf, RECVBUF_SIZE);
- break;
-#endif
- case RTSP_LOWER_TRANSPORT_UDP:
- case RTSP_LOWER_TRANSPORT_UDP_MULTICAST:
- len = udp_read_packet(s, &rtsp_st, rt->recvbuf, RECVBUF_SIZE, wait_end);
- if (len > 0 && rtsp_st->transport_priv && rt->transport == RTSP_TRANSPORT_RTP)
- ff_rtp_check_and_send_back_rr(rtsp_st->transport_priv, rtsp_st->rtp_handle, NULL, len);
- break;
- case RTSP_LOWER_TRANSPORT_CUSTOM:
- if (first_queue_st && rt->transport == RTSP_TRANSPORT_RTP &&
- wait_end && wait_end < av_gettime_relative())
- len = AVERROR(EAGAIN);
- else
- len = avio_read_partial(s->pb, rt->recvbuf, RECVBUF_SIZE);
- len = pick_stream(s, &rtsp_st, rt->recvbuf, len);
- if (len > 0 && rtsp_st->transport_priv && rt->transport == RTSP_TRANSPORT_RTP)
- ff_rtp_check_and_send_back_rr(rtsp_st->transport_priv, NULL, s->pb, len);
- break;
- }
+ len = read_packet(s, &rtsp_st, first_queue_st, wait_end);
if (len == AVERROR(EAGAIN) && first_queue_st &&
rt->transport == RTSP_TRANSPORT_RTP) {
av_log(s, AV_LOG_WARNING,
@@ -2152,8 +2167,7 @@ redo:
}
if (len < 0)
return len;
- if (len == 0)
- return AVERROR_EOF;
+
if (rt->transport == RTSP_TRANSPORT_RDT) {
ret = ff_rdt_parse_packet(rtsp_st->transport_priv, pkt, &rt->recvbuf, len);
} else if (rt->transport == RTSP_TRANSPORT_RTP) {
======================================================================
diff --cc libavformat/rtsp.c
index 0bd72dc5ce,e75670867a..736559eab3
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@@ -2054,6 -2043,44 +2054,44 @@@ static int pick_stream(AVFormatContext
return AVERROR(EAGAIN);
}
+ static int read_packet(AVFormatContext *s,
+ RTSPStream **rtsp_st, RTSPStream *first_queue_st,
+ int64_t wait_end)
+ {
+ RTSPState *rt = s->priv_data;
+ int len;
+
+ switch(rt->lower_transport) {
+ default:
+ #if CONFIG_RTSP_DEMUXER
+ case RTSP_LOWER_TRANSPORT_TCP:
+ len = ff_rtsp_tcp_read_packet(s, rtsp_st, rt->recvbuf, RECVBUF_SIZE);
+ break;
+ #endif
+ case RTSP_LOWER_TRANSPORT_UDP:
+ case RTSP_LOWER_TRANSPORT_UDP_MULTICAST:
+ len = udp_read_packet(s, rtsp_st, rt->recvbuf, RECVBUF_SIZE, wait_end);
+ if (len > 0 && (*rtsp_st)->transport_priv && rt->transport == RTSP_TRANSPORT_RTP)
+ ff_rtp_check_and_send_back_rr((*rtsp_st)->transport_priv, (*rtsp_st)->rtp_handle, NULL, len);
+ break;
+ case RTSP_LOWER_TRANSPORT_CUSTOM:
+ if (first_queue_st && rt->transport == RTSP_TRANSPORT_RTP &&
+ wait_end && wait_end < av_gettime_relative())
+ len = AVERROR(EAGAIN);
+ else
- len = ffio_read_partial(s->pb, rt->recvbuf, RECVBUF_SIZE);
++ len = avio_read_partial(s->pb, rt->recvbuf, RECVBUF_SIZE);
+ len = pick_stream(s, rtsp_st, rt->recvbuf, len);
+ if (len > 0 && (*rtsp_st)->transport_priv && rt->transport == RTSP_TRANSPORT_RTP)
+ ff_rtp_check_and_send_back_rr((*rtsp_st)->transport_priv, NULL, s->pb, len);
+ break;
+ }
+
+ if (len == 0)
+ return AVERROR_EOF;
+
+ return len;
+ }
+
int ff_rtsp_fetch_packet(AVFormatContext *s, AVPacket *pkt)
{
RTSPState *rt = s->priv_data;
More information about the ffmpeg-cvslog
mailing list