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>
This commit is contained in:
parent
2b982e92f4
commit
e72605f80b
@ -120,6 +120,7 @@ struct RTPDynamicProtocolHandler {
|
|||||||
int static_payload_id; /* 0 means no payload id is set. 0 is a valid
|
int static_payload_id; /* 0 means no payload id is set. 0 is a valid
|
||||||
* payload ID (PCMU), too, but that format doesn't
|
* payload ID (PCMU), too, but that format doesn't
|
||||||
* require any custom depacketization code. */
|
* require any custom depacketization code. */
|
||||||
|
int priv_data_size;
|
||||||
|
|
||||||
/** Initialize dynamic protocol handler, called after the full rtpmap line is parsed, may be null */
|
/** 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);
|
int (*init)(AVFormatContext *s, int st_index, PayloadContext *priv_data);
|
||||||
|
@ -190,6 +190,10 @@ static void init_rtp_handler(RTPDynamicProtocolHandler *handler,
|
|||||||
rtsp_st->dynamic_protocol_context = handler->alloc();
|
rtsp_st->dynamic_protocol_context = handler->alloc();
|
||||||
if (!rtsp_st->dynamic_protocol_context)
|
if (!rtsp_st->dynamic_protocol_context)
|
||||||
rtsp_st->dynamic_handler = NULL;
|
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++) {
|
for (i = 0; i < rt->nb_rtsp_streams; i++) {
|
||||||
rtsp_st = rt->rtsp_streams[i];
|
rtsp_st = rt->rtsp_streams[i];
|
||||||
if (rtsp_st) {
|
if (rtsp_st) {
|
||||||
if (rtsp_st->dynamic_handler && rtsp_st->dynamic_protocol_context)
|
if (rtsp_st->dynamic_handler && rtsp_st->dynamic_protocol_context) {
|
||||||
rtsp_st->dynamic_handler->free(
|
if (rtsp_st->dynamic_handler->free)
|
||||||
rtsp_st->dynamic_protocol_context);
|
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++)
|
for (j = 0; j < rtsp_st->nb_include_source_addrs; j++)
|
||||||
av_free(rtsp_st->include_source_addrs[j]);
|
av_free(rtsp_st->include_source_addrs[j]);
|
||||||
av_freep(&rtsp_st->include_source_addrs);
|
av_freep(&rtsp_st->include_source_addrs);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user