[FFmpeg-devel] [PATCH 1/7] avformat/ip: factorize some IP filtering and resolving functions to a new file

Marton Balint cus at passwd.hu
Mon Sep 24 02:07:30 EEST 2018



On Sun, 23 Sep 2018, James Almer wrote:

> On 9/23/2018 7:04 PM, Marton Balint wrote:
>> 
>> 
>> On Sun, 23 Sep 2018, Michael Niedermayer wrote:
>> 
>>> On Sat, Sep 22, 2018 at 11:53:22PM +0200, Marton Balint wrote:
>>>> These are based on the very similar UDP and RTP protocol functions.
>>>>
>>>> Signed-off-by: Marton Balint <cus at passwd.hu>
>>>> ---
>>>>  libavformat/ip.c | 165
>>>> +++++++++++++++++++++++++++++++++++++++++++++++++++++++
>>>>  libavformat/ip.h |  74 +++++++++++++++++++++++++
>>>>  2 files changed, 239 insertions(+)
>>>>  create mode 100644 libavformat/ip.c
>>>>  create mode 100644 libavformat/ip.h
>>> [...]
>>>> +/**
>>>> + * Parses the address[,address] source list in buf and adds it to
>>>> the filters
>>>> + * in the IPSourceFilters structure.
>>>> + * @param buf is the source list, which is not changed, but must be
>>>> writable
>>>> + * @return 0 on success, < 0 AVERROR code on error.
>>>> + */
>>>> +int ff_ip_parse_sources(void *log_ctx, char *buf, IPSourceFilters
>>>> *filters);
>>>> +
>>>> +/**
>>>> + * Parses the address[,address] source block list in buf and adds it
>>>> to the
>>>> + * filters in the IPSourceFilters structure.
>>>> + * @param buf is the source list, which is not changed, but must be
>>>> writable
>>>
>>> if its not changed, why does it need to be writable ?
>> 
>> Becasue the during the parsing the ',' is replaced with '\0' temporarily.
>
> Why not use av_get_token() or similar instead, to split it into separate
> strings? That way the buffer passed to the function can be const.

That would cause some unnecesary mallocs/frees because we don't store the 
parsed address strings. Also this patch is mostly factorization, I 
tried to keep functional changes to the mimnium...

Can be changed if any of you still prefer that.

Regards,
Marton


More information about the ffmpeg-devel mailing list