[FFmpeg-cvslog] rtsp: Split out a function undoing the setup made by ff_rtsp_make_setup_request
Martin Storsjo
git
Wed Jan 26 04:01:15 CET 2011
ffmpeg | branch: master | Martin Storsjo <martin at martin.st> | Mon Jan 24 09:49:02 2011 +0000| [abbc1d272ee382b47d8736368588040c5dd2d90b] | committer: Michael Niedermayer
rtsp: Split out a function undoing the setup made by ff_rtsp_make_setup_request
Signed-off-by: Janne Grunau <janne-ffmpeg at jannau.net>
(cherry picked from commit 93e7490ee0c456d7e0fa43e3bf2cb4a8eed19194)
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=abbc1d272ee382b47d8736368588040c5dd2d90b
---
libavformat/rtsp.c | 59 ++++++++++++++++++++++++++++++++-------------------
libavformat/rtsp.h | 6 +++++
2 files changed, 43 insertions(+), 22 deletions(-)
diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index feb6193..dcceb68 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -474,6 +474,42 @@ int ff_sdp_parse(AVFormatContext *s, const char *content)
}
#endif /* CONFIG_RTPDEC */
+void ff_rtsp_undo_setup(AVFormatContext *s)
+{
+ RTSPState *rt = s->priv_data;
+ int i;
+
+ for (i = 0; i < rt->nb_rtsp_streams; i++) {
+ RTSPStream *rtsp_st = rt->rtsp_streams[i];
+ if (!rtsp_st)
+ continue;
+ if (rtsp_st->transport_priv) {
+ if (s->oformat) {
+ AVFormatContext *rtpctx = rtsp_st->transport_priv;
+ av_write_trailer(rtpctx);
+ if (rt->lower_transport == RTSP_LOWER_TRANSPORT_TCP) {
+ uint8_t *ptr;
+ url_close_dyn_buf(rtpctx->pb, &ptr);
+ av_free(ptr);
+ } else {
+ url_fclose(rtpctx->pb);
+ }
+ av_metadata_free(&rtpctx->streams[0]->metadata);
+ av_metadata_free(&rtpctx->metadata);
+ av_free(rtpctx->streams[0]);
+ av_free(rtpctx);
+ } else if (rt->transport == RTSP_TRANSPORT_RDT && CONFIG_RTPDEC)
+ ff_rdt_parse_close(rtsp_st->transport_priv);
+ else if (CONFIG_RTPDEC)
+ rtp_parse_close(rtsp_st->transport_priv);
+ }
+ rtsp_st->transport_priv = NULL;
+ if (rtsp_st->rtp_handle)
+ url_close(rtsp_st->rtp_handle);
+ rtsp_st->rtp_handle = NULL;
+ }
+}
+
/* close and free RTSP streams */
void ff_rtsp_close_streams(AVFormatContext *s)
{
@@ -481,31 +517,10 @@ void ff_rtsp_close_streams(AVFormatContext *s)
int i;
RTSPStream *rtsp_st;
+ ff_rtsp_undo_setup(s);
for (i = 0; i < rt->nb_rtsp_streams; i++) {
rtsp_st = rt->rtsp_streams[i];
if (rtsp_st) {
- if (rtsp_st->transport_priv) {
- if (s->oformat) {
- AVFormatContext *rtpctx = rtsp_st->transport_priv;
- av_write_trailer(rtpctx);
- if (rt->lower_transport == RTSP_LOWER_TRANSPORT_TCP) {
- uint8_t *ptr;
- url_close_dyn_buf(rtpctx->pb, &ptr);
- av_free(ptr);
- } else {
- url_fclose(rtpctx->pb);
- }
- av_metadata_free(&rtpctx->streams[0]->metadata);
- av_metadata_free(&rtpctx->metadata);
- av_free(rtpctx->streams[0]);
- av_free(rtpctx);
- } else if (rt->transport == RTSP_TRANSPORT_RDT && CONFIG_RTPDEC)
- ff_rdt_parse_close(rtsp_st->transport_priv);
- else if (CONFIG_RTPDEC)
- rtp_parse_close(rtsp_st->transport_priv);
- }
- if (rtsp_st->rtp_handle)
- url_close(rtsp_st->rtp_handle);
if (rtsp_st->dynamic_handler && rtsp_st->dynamic_protocol_context)
rtsp_st->dynamic_handler->close(
rtsp_st->dynamic_protocol_context);
diff --git a/libavformat/rtsp.h b/libavformat/rtsp.h
index 2ef68db..6dc64b1 100644
--- a/libavformat/rtsp.h
+++ b/libavformat/rtsp.h
@@ -511,4 +511,10 @@ int ff_rtsp_fetch_packet(AVFormatContext *s, AVPacket *pkt);
int ff_rtsp_make_setup_request(AVFormatContext *s, const char *host, int port,
int lower_transport, const char *real_challenge);
+/**
+ * Undo the effect of ff_rtsp_make_setup_request, close the
+ * transport_priv and rtp_handle fields.
+ */
+void ff_rtsp_undo_setup(AVFormatContext *s);
+
#endif /* AVFORMAT_RTSP_H */
More information about the ffmpeg-cvslog
mailing list