]> git.sesse.net Git - ffmpeg/blobdiff - libavdevice/lavfi.c
wtvdec: display warning for encrypted wtv files (instead of 'unsupported chunk' messages)
[ffmpeg] / libavdevice / lavfi.c
index 944794fb87451261998337e068edc54d777915a5..82c5844fab41f76a19e6d4de8dbf815baea99d94 100644 (file)
@@ -27,6 +27,7 @@
 
 #include "float.h"              /* DBL_MIN, DBL_MAX */
 
+#include "libavutil/bprint.h"
 #include "libavutil/log.h"
 #include "libavutil/mem.h"
 #include "libavutil/opt.h"
@@ -339,6 +340,28 @@ static int lavfi_read_packet(AVFormatContext *avctx, AVPacket *pkt)
         memcpy(pkt->data, ref->data[0], size);
     }
 
+    if (ref->metadata) {
+        uint8_t *metadata;
+        AVDictionaryEntry *e = NULL;
+        AVBPrint meta_buf;
+
+        av_bprint_init(&meta_buf, 0, AV_BPRINT_SIZE_UNLIMITED);
+        while ((e = av_dict_get(ref->metadata, "", e, AV_DICT_IGNORE_SUFFIX))) {
+            av_bprintf(&meta_buf, "%s", e->key);
+            av_bprint_chars(&meta_buf, '\0', 1);
+            av_bprintf(&meta_buf, "%s", e->value);
+            av_bprint_chars(&meta_buf, '\0', 1);
+        }
+        if (!av_bprint_is_complete(&meta_buf) ||
+            !(metadata = av_packet_new_side_data(pkt, AV_PKT_DATA_STRINGS_METADATA,
+                                                 meta_buf.len))) {
+            av_bprint_finalize(&meta_buf, NULL);
+            return AVERROR(ENOMEM);
+        }
+        memcpy(metadata, meta_buf.str, meta_buf.len);
+        av_bprint_finalize(&meta_buf, NULL);
+    }
+
     pkt->stream_index = stream_idx;
     pkt->pts = ref->pts;
     pkt->pos = ref->pos;