diff options
author | Martin Storsjö <martin@martin.st> | 2012-08-09 00:05:52 +0400 |
---|---|---|
committer | Martin Storsjö <martin@martin.st> | 2012-08-09 01:25:57 +0400 |
commit | 1243c722510f6cf878039e5edfd912ab25fe66f6 (patch) | |
tree | 26d5c3f082ace6cd5caabc63603eb9a337013d29 /libavformat | |
parent | df8cf076c8627d9240e62187ac98cd88f757353c (diff) |
rtsp: Support mpegts in raw udp packets
This is basically the same way as mpegts packets are parsed in
rtpdec.c.
Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/rtsp.c | 26 | ||||
-rw-r--r-- | libavformat/rtsp.h | 7 | ||||
-rw-r--r-- | libavformat/version.h | 2 |
3 files changed, 33 insertions, 2 deletions
diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c index e03021bdb6..7506d39787 100644 --- a/libavformat/rtsp.c +++ b/libavformat/rtsp.c @@ -46,6 +46,7 @@ #include "rtpenc_chain.h" #include "url.h" #include "rtpenc.h" +#include "mpegts.h" //#define DEBUG @@ -380,6 +381,8 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1, if (!strcmp(ff_rtp_enc_name(rtsp_st->sdp_payload_type), "MP2T")) { /* no corresponding stream */ + if (rt->transport == RTSP_TRANSPORT_RAW && !rt->ts && CONFIG_RTPDEC) + rt->ts = ff_mpegts_parse_open(s); } else if (rt->server_type == RTSP_SERVER_WMS && codec_type == AVMEDIA_TYPE_DATA) { /* RTX stream, a stream that carries all the other actual @@ -596,6 +599,8 @@ void ff_rtsp_close_streams(AVFormatContext *s) if (rt->asf_ctx) { avformat_close_input(&rt->asf_ctx); } + if (rt->ts && CONFIG_RTPDEC) + ff_mpegts_parse_close(rt->ts); av_free(rt->p); av_free(rt->recvbuf); } @@ -1773,8 +1778,15 @@ int ff_rtsp_fetch_packet(AVFormatContext *s, AVPacket *pkt) if (rt->cur_transport_priv) { if (rt->transport == RTSP_TRANSPORT_RDT) { ret = ff_rdt_parse_packet(rt->cur_transport_priv, pkt, NULL, 0); - } else + } else if (rt->transport == RTSP_TRANSPORT_RTP) { ret = ff_rtp_parse_packet(rt->cur_transport_priv, pkt, NULL, 0); + } else if (rt->ts && CONFIG_RTPDEC) { + ret = ff_mpegts_parse_packet(rt->ts, pkt, rt->recvbuf + rt->recvbuf_pos, rt->recvbuf_len - rt->recvbuf_pos); + if (ret >= 0) { + rt->recvbuf_pos += ret; + ret = rt->recvbuf_pos < rt->recvbuf_len; + } + } if (ret == 0) { rt->cur_transport_priv = NULL; return 0; @@ -1876,6 +1888,18 @@ int ff_rtsp_fetch_packet(AVFormatContext *s, AVPacket *pkt) return AVERROR_EOF; } } + } else if (rt->ts && CONFIG_RTPDEC) { + ret = ff_mpegts_parse_packet(rt->ts, pkt, rt->recvbuf, len); + if (ret >= 0) { + if (ret < len) { + rt->recvbuf_len = len; + rt->recvbuf_pos = ret; + rt->cur_transport_priv = rt->ts; + return 1; + } else { + ret = 0; + } + } } else { return AVERROR_INVALIDDATA; } diff --git a/libavformat/rtsp.h b/libavformat/rtsp.h index 704586a94e..d16c98ca8a 100644 --- a/libavformat/rtsp.h +++ b/libavformat/rtsp.h @@ -311,6 +311,13 @@ typedef struct RTSPState { * other cases, this is a copy of AVFormatContext->filename. */ char control_uri[1024]; + /** The following are used for parsing raw mpegts in udp */ + //@{ + struct MpegTSContext *ts; + int recvbuf_pos; + int recvbuf_len; + //@} + /** Additional output handle, used when input and output are done * separately, eg for HTTP tunneling. */ URLContext *rtsp_hd_out; diff --git a/libavformat/version.h b/libavformat/version.h index 55026e809c..e2cd0c7f05 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -31,7 +31,7 @@ #define LIBAVFORMAT_VERSION_MAJOR 54 #define LIBAVFORMAT_VERSION_MINOR 13 -#define LIBAVFORMAT_VERSION_MICRO 1 +#define LIBAVFORMAT_VERSION_MICRO 2 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ LIBAVFORMAT_VERSION_MINOR, \ |