Skip to content

Commit

Permalink
Merge commit 'e72605f80bf5cbe32053a554ccc137e0a99cf3dd'
Browse files Browse the repository at this point in the history
* commit 'e72605f80bf5cbe32053a554ccc137e0a99cf3dd':
  rtpdec: Allow allocating and freeing the private data without explicit functions

Merged-by: Michael Niedermayer <[email protected]>
  • Loading branch information
michaelni committed Feb 24, 2015
2 parents 11fb625 + e72605f commit 48e3cd4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions libavformat/rtpdec.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ struct RTPDynamicProtocolHandler {
int static_payload_id; /* 0 means no payload id is set. 0 is a valid
* payload ID (PCMU), too, but that format doesn't
* require any custom depacketization code. */
int priv_data_size;

/** Initialize dynamic protocol handler, called after the full rtpmap line is parsed, may be null */
int (*init)(AVFormatContext *s, int st_index, PayloadContext *priv_data);
Expand Down
14 changes: 11 additions & 3 deletions libavformat/rtsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,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;
}
}

Expand Down Expand Up @@ -728,9 +732,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_freep(&rtsp_st->include_source_addrs[j]);
av_freep(&rtsp_st->include_source_addrs);
Expand Down

0 comments on commit 48e3cd4

Please sign in to comment.