mirror of https://git.ffmpeg.org/ffmpeg.git
Split the sdp_read_packet() function out of rtsp_read_packet().
This allows to avoid compiling RTSP code when not needed. Originally committed as revision 20526 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
1ced9da357
commit
987131828c
|
@ -43,6 +43,8 @@
|
|||
//#define DEBUG
|
||||
//#define DEBUG_RTP_TCP
|
||||
|
||||
static int tcp_read_packet(AVFormatContext *s, RTSPStream **prtsp_st,
|
||||
uint8_t *buf, int buf_size);
|
||||
static int rtsp_read_reply(AVFormatContext *s, RTSPMessageHeader *reply,
|
||||
unsigned char **content_ptr,
|
||||
int return_on_interleaved_data);
|
||||
|
@ -609,6 +611,63 @@ static int udp_read_packet(AVFormatContext *s, RTSPStream **prtsp_st,
|
|||
}
|
||||
}
|
||||
|
||||
static int sdp_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
{
|
||||
RTSPState *rt = s->priv_data;
|
||||
int ret, len;
|
||||
uint8_t buf[10 * RTP_MAX_PACKET_LENGTH];
|
||||
RTSPStream *rtsp_st;
|
||||
|
||||
/* get next frames from the same RTP packet */
|
||||
if (rt->cur_transport_priv) {
|
||||
if (rt->transport == RTSP_TRANSPORT_RDT)
|
||||
ret = ff_rdt_parse_packet(rt->cur_transport_priv, pkt, NULL, 0);
|
||||
else
|
||||
ret = rtp_parse_packet(rt->cur_transport_priv, pkt, NULL, 0);
|
||||
if (ret == 0) {
|
||||
rt->cur_transport_priv = NULL;
|
||||
return 0;
|
||||
} else if (ret == 1) {
|
||||
return 0;
|
||||
} else {
|
||||
rt->cur_transport_priv = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* read next RTP packet */
|
||||
redo:
|
||||
switch(rt->lower_transport) {
|
||||
default:
|
||||
#if CONFIG_RTSP_DEMUXER
|
||||
case RTSP_LOWER_TRANSPORT_TCP:
|
||||
len = tcp_read_packet(s, &rtsp_st, buf, sizeof(buf));
|
||||
break;
|
||||
#endif
|
||||
case RTSP_LOWER_TRANSPORT_UDP:
|
||||
case RTSP_LOWER_TRANSPORT_UDP_MULTICAST:
|
||||
len = udp_read_packet(s, &rtsp_st, buf, sizeof(buf));
|
||||
if (len >=0 && rtsp_st->transport_priv && rt->transport == RTSP_TRANSPORT_RTP)
|
||||
rtp_check_and_send_back_rr(rtsp_st->transport_priv, len);
|
||||
break;
|
||||
}
|
||||
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, buf, len);
|
||||
else
|
||||
ret = rtp_parse_packet(rtsp_st->transport_priv, pkt, buf, len);
|
||||
if (ret < 0)
|
||||
goto redo;
|
||||
if (ret == 1) {
|
||||
/* more packets may follow, so we save the RTP context */
|
||||
rt->cur_transport_priv = rtsp_st->transport_priv;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* close and free RTSP streams */
|
||||
static void rtsp_close_streams(RTSPState *rt)
|
||||
{
|
||||
|
@ -1498,9 +1557,7 @@ static int rtsp_read_packet(AVFormatContext *s,
|
|||
AVPacket *pkt)
|
||||
{
|
||||
RTSPState *rt = s->priv_data;
|
||||
RTSPStream *rtsp_st;
|
||||
int ret, len;
|
||||
uint8_t buf[10 * RTP_MAX_PACKET_LENGTH];
|
||||
int ret;
|
||||
RTSPMessageHeader reply1, *reply = &reply1;
|
||||
char cmd[1024];
|
||||
|
||||
|
@ -1564,49 +1621,9 @@ static int rtsp_read_packet(AVFormatContext *s,
|
|||
}
|
||||
}
|
||||
|
||||
/* get next frames from the same RTP packet */
|
||||
if (rt->cur_transport_priv) {
|
||||
if (rt->transport == RTSP_TRANSPORT_RDT)
|
||||
ret = ff_rdt_parse_packet(rt->cur_transport_priv, pkt, NULL, 0);
|
||||
else
|
||||
ret = rtp_parse_packet(rt->cur_transport_priv, pkt, NULL, 0);
|
||||
if (ret == 0) {
|
||||
rt->cur_transport_priv = NULL;
|
||||
return 0;
|
||||
} else if (ret == 1) {
|
||||
return 0;
|
||||
} else {
|
||||
rt->cur_transport_priv = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* read next RTP packet */
|
||||
redo:
|
||||
switch(rt->lower_transport) {
|
||||
default:
|
||||
case RTSP_LOWER_TRANSPORT_TCP:
|
||||
len = tcp_read_packet(s, &rtsp_st, buf, sizeof(buf));
|
||||
break;
|
||||
case RTSP_LOWER_TRANSPORT_UDP:
|
||||
case RTSP_LOWER_TRANSPORT_UDP_MULTICAST:
|
||||
len = udp_read_packet(s, &rtsp_st, buf, sizeof(buf));
|
||||
if (len >=0 && rtsp_st->transport_priv && rt->transport == RTSP_TRANSPORT_RTP)
|
||||
rtp_check_and_send_back_rr(rtsp_st->transport_priv, len);
|
||||
break;
|
||||
}
|
||||
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, buf, len);
|
||||
else
|
||||
ret = rtp_parse_packet(rtsp_st->transport_priv, pkt, buf, len);
|
||||
if (ret < 0)
|
||||
goto redo;
|
||||
if (ret == 1) {
|
||||
/* more packets may follow, so we save the RTP context */
|
||||
rt->cur_transport_priv = rtsp_st->transport_priv;
|
||||
ret = sdp_read_packet(s, pkt);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* send dummy request to keep TCP connection alive */
|
||||
|
@ -1777,12 +1794,6 @@ static int sdp_read_header(AVFormatContext *s,
|
|||
return err;
|
||||
}
|
||||
|
||||
static int sdp_read_packet(AVFormatContext *s,
|
||||
AVPacket *pkt)
|
||||
{
|
||||
return rtsp_read_packet(s, pkt);
|
||||
}
|
||||
|
||||
static int sdp_read_close(AVFormatContext *s)
|
||||
{
|
||||
RTSPState *rt = s->priv_data;
|
||||
|
|
Loading…
Reference in New Issue