[vlc-devel] [PATCH 1/1] avformat: replace deprecated field in AVFormatContext

Marvin Scholz epirat07 at gmail.com
Thu Oct 17 13:14:40 CEST 2019



On 17 Oct 2019, at 9:24, Mehdi Sabwat wrote:

> Hi,
>
> Sorry I didn't provide enough context. The patch fixes a warning (saying
> the field is deprecated).
> In the version we currently pull from the contribs, the change is already
> included.
>
> Regards,

We need to support versions older than what is in contribs, as far as I know.

This specific change (introduction of the url field) was done in commit
ea3672b7d67c432724bdbc8de0221f869b6a04c6 roughly two years ago, and the
first avformat version to have it is 58.7.100.

>
> On Wed, Oct 16, 2019 at 9:19 AM Steve Lhomme <robux4 at ycbcr.xyz> wrote:
>
>> In which libavformat version was this "url" field introduced ? You may
>> need to support both ways if we support an older lavf version than that.
>>
>> On 2019-10-15 19:53, Mehdi Sabwat wrote:
>>> From: Mehdi Sabwat <mehdisabwat at gmail.com>
>>>
>>>      Since Jan 21, 2018 (ea3672b7d67c432724bdbc8de0221f869b6a04c6)
>>>      filename field was deprecated in favor of `url` which now has
>>>      no length restrictions.
>>> ---
>>>   modules/demux/avformat/mux.c | 12 ++++++------
>>>   1 file changed, 6 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/modules/demux/avformat/mux.c b/modules/demux/avformat/mux.c
>>> index b9d9c378c8..b8aa73000b 100644
>>> --- a/modules/demux/avformat/mux.c
>>> +++ b/modules/demux/avformat/mux.c
>>> @@ -90,10 +90,6 @@ int avformat_OpenMux( vlc_object_t *p_this )
>>>       sout_mux_t *p_mux = (sout_mux_t*)p_this;
>>>       bool dummy = !strcmp( p_mux->p_access->psz_access, "dummy");
>>>
>>> -    if( dummy && strlen(p_mux->p_access->psz_path)
>>> -                              >= sizeof (((AVFormatContext
>> *)NULL)->filename) )
>>> -        return VLC_EGENERIC;
>>> -
>>>       msg_Dbg( p_mux, "using %s %s", AVPROVIDER(LIBAVFORMAT),
>> LIBAVFORMAT_IDENT );
>>>
>>>       vlc_init_avformat(p_this);
>>> @@ -127,8 +123,12 @@ int avformat_OpenMux( vlc_object_t *p_this )
>>>       p_sys->oc->oformat = file_oformat;
>>>       /* If we use dummy access, let avformat write output */
>>>       if( dummy )
>>> -        strcpy( p_sys->oc->filename, p_mux->p_access->psz_path );
>>> -
>>> +    {
>>> +        size_t size = strlen(p_mux->p_access->psz_path);
>>> +        // Freed by libavformat in avformat_free_context()
>>> +        p_sys->oc->url = av_malloc( size + 1 );
>>> +        memcpy( p_sys->oc->url, p_mux->p_access->psz_path , size + 1 );

It might be easier to use ff_format_set_url() here, which will set the old
filename field too.
Additionally it can be simplified by using av_strdup(), i.e.:

  char *psz_url_tmp = av_strdup(p_mux->p_access->psz_path);
  // […] TODO: Error handling for av_strdup failure
  ff_format_set_url(p_sys->oc, psz_url_tmp); // Freed by avformat

>>> +    }
>>>       /* Create I/O wrapper */
>>>       p_sys->io_buffer_size = 10 * 1024 * 1024;  /* FIXME */
>>>       p_sys->io_buffer = malloc( p_sys->io_buffer_size );
>>> --
>>> 2.23.0
>>>
>>> _______________________________________________
>>> vlc-devel mailing list
>>> To unsubscribe or modify your subscription options:
>>> https://mailman.videolan.org/listinfo/vlc-devel
>>>
>> _______________________________________________
>> vlc-devel mailing list
>> To unsubscribe or modify your subscription options:
>> https://mailman.videolan.org/listinfo/vlc-devel
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel


More information about the vlc-devel mailing list