summaryrefslogtreecommitdiff
path: root/libavformat/rtsp.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2015-02-25 00:31:39 +0100
committerMichael Niedermayer <michaelni@gmx.at>2015-02-25 00:32:06 +0100
commit79052cd4ce4a8857cd1088cc69ba59506dfb1b81 (patch)
tree0fd3a32dc325c6eeec6cf17c47d8616b2e59016e /libavformat/rtsp.c
parentfa80b76b110c663809671f7254bc07513710c061 (diff)
parent078d43e23a7a3d64aafee8a58b380d3e139b3020 (diff)
Merge commit '078d43e23a7a3d64aafee8a58b380d3e139b3020'
* commit '078d43e23a7a3d64aafee8a58b380d3e139b3020': rtpdec: Free depacketizers if the init function failed Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/rtsp.c')
-rw-r--r--libavformat/rtsp.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index 32ff18ec03..890b77d866 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -198,6 +198,25 @@ static void init_rtp_handler(RTPDynamicProtocolHandler *handler,
}
}
+static void finalize_rtp_handler_init(AVFormatContext *s, RTSPStream *rtsp_st,
+ AVStream *st)
+{
+ if (rtsp_st->dynamic_handler && rtsp_st->dynamic_handler->init) {
+ int ret = rtsp_st->dynamic_handler->init(s, st ? st->index : -1,
+ rtsp_st->dynamic_protocol_context);
+ if (ret < 0) {
+ if (rtsp_st->dynamic_protocol_context) {
+ if (rtsp_st->dynamic_handler->free)
+ rtsp_st->dynamic_handler->free(
+ rtsp_st->dynamic_protocol_context);
+ av_free(rtsp_st->dynamic_protocol_context);
+ }
+ rtsp_st->dynamic_protocol_context = NULL;
+ rtsp_st->dynamic_handler = NULL;
+ }
+ }
+}
+
/* parse the rtpmap description: <codec_name>/<clock_rate>[/<other params>] */
static int sdp_parse_rtpmap(AVFormatContext *s,
AVStream *st, RTSPStream *rtsp_st,
@@ -266,9 +285,7 @@ static int sdp_parse_rtpmap(AVFormatContext *s,
default:
break;
}
- if (rtsp_st->dynamic_handler && rtsp_st->dynamic_handler->init)
- rtsp_st->dynamic_handler->init(s, st->index,
- rtsp_st->dynamic_protocol_context);
+ finalize_rtp_handler_init(s, rtsp_st, st);
return 0;
}
@@ -451,8 +468,7 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1,
handler = ff_rtp_handler_find_by_id(
rtsp_st->sdp_payload_type, AVMEDIA_TYPE_DATA);
init_rtp_handler(handler, rtsp_st, NULL);
- if (handler && handler->init)
- handler->init(s, -1, rtsp_st->dynamic_protocol_context);
+ finalize_rtp_handler_init(s, rtsp_st, NULL);
}
} else if (rt->server_type == RTSP_SERVER_WMS &&
codec_type == AVMEDIA_TYPE_DATA) {
@@ -476,9 +492,7 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1,
handler = ff_rtp_handler_find_by_id(
rtsp_st->sdp_payload_type, st->codec->codec_type);
init_rtp_handler(handler, rtsp_st, st);
- if (handler && handler->init)
- handler->init(s, st->index,
- rtsp_st->dynamic_protocol_context);
+ finalize_rtp_handler_init(s, rtsp_st, st);
}
if (rt->default_lang[0])
av_dict_set(&st->metadata, "language", rt->default_lang, 0);