[vlc-commits] avformat: add support for url field in AvFormatContext

Mehdi Sabwat git at videolan.org
Sat Apr 11 11:04:46 CEST 2020


vlc | branch: master | Mehdi Sabwat <mehdisabwat at gmail.com> | Thu Apr  9 21:59:56 2020 +0200| [869ff2d10ef3eb97723356973dac93e02b2d1225] | committer: Alexandre Janniaux

avformat: add support for url field in AvFormatContext

Since Jan 21, 2018 filename field was deprecated in favor
of `url` which now has no length restrictions.

>From doc/APIChanges:
```
2018-01-28 - ea3672b7d6 - lavf 58.7.100 - avformat.h
  Deprecate AVFormatContext filename field which had limited length, use the
  new dynamically allocated url field instead.
```

The URL field is freed by libavformat in avformat_free_context() in
avformat_CloseMux().

Signed-off-by: Alexandre Janniaux <ajanni at videolabs.io>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=869ff2d10ef3eb97723356973dac93e02b2d1225
---

 modules/demux/avformat/mux.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/modules/demux/avformat/mux.c b/modules/demux/avformat/mux.c
index 9179daf592..258ad283f8 100644
--- a/modules/demux/avformat/mux.c
+++ b/modules/demux/avformat/mux.c
@@ -90,9 +90,12 @@ 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 ( (LIBAVFORMAT_VERSION_MICRO >= 100) \
+      && (LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(58, 7, 100)) )
     if( dummy && strlen(p_mux->p_access->psz_path)
                               >= sizeof (((AVFormatContext *)NULL)->filename) )
         return VLC_EGENERIC;
+#endif
 
     msg_Dbg( p_mux, "using %s %s", AVPROVIDER(LIBAVFORMAT), LIBAVFORMAT_IDENT );
 
@@ -127,7 +130,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 )
+#if ( (LIBAVFORMAT_VERSION_MICRO >= 100) \
+      && (LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(58, 7, 100)) )
+        p_sys->oc->url = av_strdup(p_mux->p_access->psz_path);
+#else
         strcpy( p_sys->oc->filename, p_mux->p_access->psz_path );
+#endif
 
     /* Create I/O wrapper */
     p_sys->io_buffer_size = 10 * 1024 * 1024;  /* FIXME */



More information about the vlc-commits mailing list