1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

lavf/rtp: replace linked list with array

This commit is contained in:
Josh de Kock 2018-01-01 23:31:26 +00:00
parent 7e8eba2d87
commit 6197453761
5 changed files with 100 additions and 81 deletions

View File

@ -282,10 +282,6 @@ static void register_all(void)
REGISTER_DEMUXER (SDR2, sdr2);
REGISTER_DEMUXER (SDS, sds);
REGISTER_DEMUXER (SDX, sdx);
#if CONFIG_RTPDEC
ff_register_rtp_dynamic_payload_handlers();
ff_register_rdt_dynamic_payload_handlers();
#endif
REGISTER_DEMUXER (SEGAFILM, segafilm);
REGISTER_MUXER (SEGMENT, segment);
REGISTER_MUXER (SEGMENT, stream_segment);

View File

@ -554,7 +554,7 @@ rdt_close_context (PayloadContext *rdt)
}
#define RDT_HANDLER(n, s, t) \
static RTPDynamicProtocolHandler rdt_ ## n ## _handler = { \
RTPDynamicProtocolHandler ff_rdt_ ## n ## _handler = { \
.enc_name = s, \
.codec_type = t, \
.codec_id = AV_CODEC_ID_NONE, \
@ -570,10 +570,3 @@ RDT_HANDLER(live_audio, "x-pn-multirate-realaudio-live", AVMEDIA_TYPE_AUDIO);
RDT_HANDLER(video, "x-pn-realvideo", AVMEDIA_TYPE_VIDEO);
RDT_HANDLER(audio, "x-pn-realaudio", AVMEDIA_TYPE_AUDIO);
void ff_register_rdt_dynamic_payload_handlers(void)
{
ff_register_dynamic_payload_handler(&rdt_video_handler);
ff_register_dynamic_payload_handler(&rdt_audio_handler);
ff_register_dynamic_payload_handler(&rdt_live_video_handler);
ff_register_dynamic_payload_handler(&rdt_live_audio_handler);
}

View File

@ -59,11 +59,6 @@ void ff_rdt_parse_close(RDTDemuxContext *s);
void ff_rdt_calc_response_and_checksum(char response[41], char chksum[9],
const char *challenge);
/**
* Register RDT-related dynamic payload handlers with our cache.
*/
void ff_register_rdt_dynamic_payload_handlers(void);
/**
* Add subscription information to Subscribe parameter string.
*

View File

@ -69,88 +69,104 @@ static RTPDynamicProtocolHandler t140_dynamic_handler = { /* RFC 4103 */
.codec_id = AV_CODEC_ID_TEXT,
};
static RTPDynamicProtocolHandler *rtp_first_dynamic_payload_handler = NULL;
extern RTPDynamicProtocolHandler ff_rdt_video_handler;
extern RTPDynamicProtocolHandler ff_rdt_audio_handler;
extern RTPDynamicProtocolHandler ff_rdt_live_video_handler;
extern RTPDynamicProtocolHandler ff_rdt_live_audio_handler;
void ff_register_dynamic_payload_handler(RTPDynamicProtocolHandler *handler)
{
handler->next = rtp_first_dynamic_payload_handler;
rtp_first_dynamic_payload_handler = handler;
}
static const RTPDynamicProtocolHandler *rtp_dynamic_protocol_handler_list[] = {
/* rtp */
&ff_ac3_dynamic_handler,
&ff_amr_nb_dynamic_handler,
&ff_amr_wb_dynamic_handler,
&ff_dv_dynamic_handler,
&ff_g726_16_dynamic_handler,
&ff_g726_24_dynamic_handler,
&ff_g726_32_dynamic_handler,
&ff_g726_40_dynamic_handler,
&ff_g726le_16_dynamic_handler,
&ff_g726le_24_dynamic_handler,
&ff_g726le_32_dynamic_handler,
&ff_g726le_40_dynamic_handler,
&ff_h261_dynamic_handler,
&ff_h263_1998_dynamic_handler,
&ff_h263_2000_dynamic_handler,
&ff_h263_rfc2190_dynamic_handler,
&ff_h264_dynamic_handler,
&ff_hevc_dynamic_handler,
&ff_ilbc_dynamic_handler,
&ff_jpeg_dynamic_handler,
&ff_mp4a_latm_dynamic_handler,
&ff_mp4v_es_dynamic_handler,
&ff_mpeg_audio_dynamic_handler,
&ff_mpeg_audio_robust_dynamic_handler,
&ff_mpeg_video_dynamic_handler,
&ff_mpeg4_generic_dynamic_handler,
&ff_mpegts_dynamic_handler,
&ff_ms_rtp_asf_pfa_handler,
&ff_ms_rtp_asf_pfv_handler,
&ff_qcelp_dynamic_handler,
&ff_qdm2_dynamic_handler,
&ff_qt_rtp_aud_handler,
&ff_qt_rtp_vid_handler,
&ff_quicktime_rtp_aud_handler,
&ff_quicktime_rtp_vid_handler,
&ff_rfc4175_rtp_handler,
&ff_svq3_dynamic_handler,
&ff_theora_dynamic_handler,
&ff_vc2hq_dynamic_handler,
&ff_vorbis_dynamic_handler,
&ff_vp8_dynamic_handler,
&ff_vp9_dynamic_handler,
&gsm_dynamic_handler,
&l24_dynamic_handler,
&opus_dynamic_handler,
&realmedia_mp3_dynamic_handler,
&speex_dynamic_handler,
&t140_dynamic_handler,
/* rdt */
&ff_rdt_video_handler,
&ff_rdt_audio_handler,
&ff_rdt_live_video_handler,
&ff_rdt_live_audio_handler,
NULL,
};
void ff_register_rtp_dynamic_payload_handlers(void)
const RTPDynamicProtocolHandler *ff_rtp_handler_iterate(void **opaque)
{
ff_register_dynamic_payload_handler(&ff_ac3_dynamic_handler);
ff_register_dynamic_payload_handler(&ff_amr_nb_dynamic_handler);
ff_register_dynamic_payload_handler(&ff_amr_wb_dynamic_handler);
ff_register_dynamic_payload_handler(&ff_dv_dynamic_handler);
ff_register_dynamic_payload_handler(&ff_g726_16_dynamic_handler);
ff_register_dynamic_payload_handler(&ff_g726_24_dynamic_handler);
ff_register_dynamic_payload_handler(&ff_g726_32_dynamic_handler);
ff_register_dynamic_payload_handler(&ff_g726_40_dynamic_handler);
ff_register_dynamic_payload_handler(&ff_g726le_16_dynamic_handler);
ff_register_dynamic_payload_handler(&ff_g726le_24_dynamic_handler);
ff_register_dynamic_payload_handler(&ff_g726le_32_dynamic_handler);
ff_register_dynamic_payload_handler(&ff_g726le_40_dynamic_handler);
ff_register_dynamic_payload_handler(&ff_h261_dynamic_handler);
ff_register_dynamic_payload_handler(&ff_h263_1998_dynamic_handler);
ff_register_dynamic_payload_handler(&ff_h263_2000_dynamic_handler);
ff_register_dynamic_payload_handler(&ff_h263_rfc2190_dynamic_handler);
ff_register_dynamic_payload_handler(&ff_h264_dynamic_handler);
ff_register_dynamic_payload_handler(&ff_hevc_dynamic_handler);
ff_register_dynamic_payload_handler(&ff_ilbc_dynamic_handler);
ff_register_dynamic_payload_handler(&ff_jpeg_dynamic_handler);
ff_register_dynamic_payload_handler(&ff_mp4a_latm_dynamic_handler);
ff_register_dynamic_payload_handler(&ff_mp4v_es_dynamic_handler);
ff_register_dynamic_payload_handler(&ff_mpeg_audio_dynamic_handler);
ff_register_dynamic_payload_handler(&ff_mpeg_audio_robust_dynamic_handler);
ff_register_dynamic_payload_handler(&ff_mpeg_video_dynamic_handler);
ff_register_dynamic_payload_handler(&ff_mpeg4_generic_dynamic_handler);
ff_register_dynamic_payload_handler(&ff_mpegts_dynamic_handler);
ff_register_dynamic_payload_handler(&ff_ms_rtp_asf_pfa_handler);
ff_register_dynamic_payload_handler(&ff_ms_rtp_asf_pfv_handler);
ff_register_dynamic_payload_handler(&ff_qcelp_dynamic_handler);
ff_register_dynamic_payload_handler(&ff_qdm2_dynamic_handler);
ff_register_dynamic_payload_handler(&ff_qt_rtp_aud_handler);
ff_register_dynamic_payload_handler(&ff_qt_rtp_vid_handler);
ff_register_dynamic_payload_handler(&ff_quicktime_rtp_aud_handler);
ff_register_dynamic_payload_handler(&ff_quicktime_rtp_vid_handler);
ff_register_dynamic_payload_handler(&ff_rfc4175_rtp_handler);
ff_register_dynamic_payload_handler(&ff_svq3_dynamic_handler);
ff_register_dynamic_payload_handler(&ff_theora_dynamic_handler);
ff_register_dynamic_payload_handler(&ff_vc2hq_dynamic_handler);
ff_register_dynamic_payload_handler(&ff_vorbis_dynamic_handler);
ff_register_dynamic_payload_handler(&ff_vp8_dynamic_handler);
ff_register_dynamic_payload_handler(&ff_vp9_dynamic_handler);
ff_register_dynamic_payload_handler(&gsm_dynamic_handler);
ff_register_dynamic_payload_handler(&l24_dynamic_handler);
ff_register_dynamic_payload_handler(&opus_dynamic_handler);
ff_register_dynamic_payload_handler(&realmedia_mp3_dynamic_handler);
ff_register_dynamic_payload_handler(&speex_dynamic_handler);
ff_register_dynamic_payload_handler(&t140_dynamic_handler);
uintptr_t i = (uintptr_t)*opaque;
const RTPDynamicProtocolHandler *r = rtp_dynamic_protocol_handler_list[i];
if (r)
*opaque = (void*)(i + 1);
return r;
}
RTPDynamicProtocolHandler *ff_rtp_handler_find_by_name(const char *name,
enum AVMediaType codec_type)
{
RTPDynamicProtocolHandler *handler;
for (handler = rtp_first_dynamic_payload_handler;
handler; handler = handler->next)
void *i = 0;
const RTPDynamicProtocolHandler *handler;
while (handler = ff_rtp_handler_iterate(&i)) {
if (handler->enc_name &&
!av_strcasecmp(name, handler->enc_name) &&
codec_type == handler->codec_type)
return handler;
}
return NULL;
}
RTPDynamicProtocolHandler *ff_rtp_handler_find_by_id(int id,
enum AVMediaType codec_type)
{
RTPDynamicProtocolHandler *handler;
for (handler = rtp_first_dynamic_payload_handler;
handler; handler = handler->next)
void *i = 0;
const RTPDynamicProtocolHandler *handler;
while (handler = ff_rtp_handler_iterate(&i)) {
if (handler->static_payload_id && handler->static_payload_id == id &&
codec_type == handler->codec_type)
return handler;
}
return NULL;
}

View File

@ -192,9 +192,30 @@ struct RTPDemuxContext {
PayloadContext *dynamic_protocol_context;
};
void ff_register_dynamic_payload_handler(RTPDynamicProtocolHandler *handler);
/**
* Iterate over all registered rtp dynamic protocol handlers.
*
* @param opaque a pointer where libavformat will store the iteration state. Must
* point to NULL to start the iteration.
*
* @return the next registered rtp dynamic protocol handler or NULL when the iteration is
* finished
*/
const RTPDynamicProtocolHandler *ff_rtp_handler_iterate(void **opaque);
/**
* Find a registered rtp dynamic protocol handler with the specified name.
*
* @param name name of the requested rtp dynamic protocol handler
* @return A rtp dynamic protocol handler if one was found, NULL otherwise.
*/
RTPDynamicProtocolHandler *ff_rtp_handler_find_by_name(const char *name,
enum AVMediaType codec_type);
/**
* Find a registered rtp dynamic protocol handler with a matching codec ID.
*
* @param id AVCodecID of the requested rtp dynamic protocol handler.
* @return A rtp dynamic protocol handler if one was found, NULL otherwise.
*/
RTPDynamicProtocolHandler *ff_rtp_handler_find_by_id(int id,
enum AVMediaType codec_type);
@ -209,8 +230,6 @@ int ff_parse_fmtp(AVFormatContext *s,
PayloadContext *data,
const char *attr, const char *value));
void ff_register_rtp_dynamic_payload_handlers(void);
/**
* Close the dynamic buffer and make a packet from it.
*/