aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/rtsp.c
diff options
context:
space:
mode:
authorMartin Storsjö <martin@martin.st>2015-02-23 21:57:33 +0200
committerMartin Storsjö <martin@martin.st>2015-02-24 16:23:37 +0200
commite72605f80bf5cbe32053a554ccc137e0a99cf3dd (patch)
treef9d69244ad2c164cafc60a0ff627fff258ab259b /libavformat/rtsp.c
parent2b982e92f42a6e661d90b12b6592cd13cae496d4 (diff)
downloadffmpeg-e72605f80bf5cbe32053a554ccc137e0a99cf3dd.tar.gz
rtpdec: Allow allocating and freeing the private data without explicit functions
This can reduce the amount of boilerplate in simple depacketizers. Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'libavformat/rtsp.c')
-rw-r--r--libavformat/rtsp.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index 72e5b5b75c..a4527d2c3a 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -190,6 +190,10 @@ static void init_rtp_handler(RTPDynamicProtocolHandler *handler,
rtsp_st->dynamic_protocol_context = handler->alloc();
if (!rtsp_st->dynamic_protocol_context)
rtsp_st->dynamic_handler = NULL;
+ } else if (handler->priv_data_size) {
+ rtsp_st->dynamic_protocol_context = av_mallocz(handler->priv_data_size);
+ if (!rtsp_st->dynamic_protocol_context)
+ rtsp_st->dynamic_handler = NULL;
}
}
@@ -721,9 +725,13 @@ void ff_rtsp_close_streams(AVFormatContext *s)
for (i = 0; i < rt->nb_rtsp_streams; i++) {
rtsp_st = rt->rtsp_streams[i];
if (rtsp_st) {
- if (rtsp_st->dynamic_handler && rtsp_st->dynamic_protocol_context)
- rtsp_st->dynamic_handler->free(
- rtsp_st->dynamic_protocol_context);
+ if (rtsp_st->dynamic_handler && rtsp_st->dynamic_protocol_context) {
+ if (rtsp_st->dynamic_handler->free)
+ rtsp_st->dynamic_handler->free(
+ rtsp_st->dynamic_protocol_context);
+ else
+ av_free(rtsp_st->dynamic_protocol_context);
+ }
for (j = 0; j < rtsp_st->nb_include_source_addrs; j++)
av_free(rtsp_st->include_source_addrs[j]);
av_freep(&rtsp_st->include_source_addrs);