diff mbox series

[FFmpeg-devel,v2,3/4] avformat/argo_asf: add name option

Message ID 20200808133717.2311422-3-zane@zanevaniperen.com
State Superseded
Headers show
Series [FFmpeg-devel,v2,1/4] avformat/argo_asf: don't check or probe file version
Related show

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Zane van Iperen Aug. 8, 2020, 1:37 p.m. UTC
Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
---
 libavformat/argo_asf.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/libavformat/argo_asf.c b/libavformat/argo_asf.c
index c693cfd045..7eaf2fec73 100644
--- a/libavformat/argo_asf.c
+++ b/libavformat/argo_asf.c
@@ -74,6 +74,7 @@  typedef struct ArgoASFMuxContext {
     const AVClass *class;
     int            version_major;
     int            version_minor;
+    const char    *name;
 } ArgoASFMuxContext;
 
 #if CONFIG_ARGO_ASF_DEMUXER
@@ -309,7 +310,10 @@  static int argo_asf_write_header(AVFormatContext *s)
     fhdr.version_minor = (uint16_t)ctx->version_minor;
     fhdr.num_chunks    = 1;
     fhdr.chunk_offset  = ASF_FILE_HEADER_SIZE;
-    strncpy(fhdr.name, av_basename(s->url), FF_ARRAY_ELEMS(fhdr.name));
+    if (ctx->name)
+        strncpy(fhdr.name, ctx->name, sizeof(fhdr.name));
+    else
+        strncpy(fhdr.name, av_basename(s->url), sizeof(fhdr.name));
 
     chdr.num_blocks    = 0;
     chdr.num_samples   = ASF_SAMPLE_COUNT;
@@ -370,6 +374,14 @@  static const AVOption argo_asf_options[] = {
         .max         = UINT16_MAX,
         .flags       = AV_OPT_FLAG_ENCODING_PARAM
     },
+    {
+        .name        = "name",
+        .help        = "embedded file name (max 8 characters)",
+        .offset      = offsetof(ArgoASFMuxContext, name),
+        .type        = AV_OPT_TYPE_STRING,
+        .default_val = {.str = NULL},
+        .flags       = AV_OPT_FLAG_ENCODING_PARAM
+    },
     { NULL }
 };