]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/crypto.c
asv1: use av_fast_padded_malloc()
[ffmpeg] / libavformat / crypto.c
index fecc2c961c2434d4239ea0533462eef18d7b7d1e..7095360c85a1947428f3bff1d466671e605d8aba 100644 (file)
@@ -45,20 +45,24 @@ typedef struct {
 } CryptoContext;
 
 #define OFFSET(x) offsetof(CryptoContext, x)
+#define D AV_OPT_FLAG_DECODING_PARAM
 static const AVOption options[] = {
-    {"key", "AES decryption key", OFFSET(key), FF_OPT_TYPE_BINARY },
-    {"iv",  "AES decryption initialization vector", OFFSET(iv),  FF_OPT_TYPE_BINARY },
+    {"key", "AES decryption key", OFFSET(key), AV_OPT_TYPE_BINARY, .flags = D },
+    {"iv",  "AES decryption initialization vector", OFFSET(iv),  AV_OPT_TYPE_BINARY, .flags = D },
     { NULL }
 };
 
 static const AVClass crypto_class = {
-    "crypto", av_default_item_name, options, LIBAVUTIL_VERSION_INT
+    .class_name     = "crypto",
+    .item_name      = av_default_item_name,
+    .option         = options,
+    .version        = LIBAVUTIL_VERSION_INT,
 };
 
 static int crypto_open(URLContext *h, const char *uri, int flags)
 {
     const char *nested_url;
-    int ret;
+    int ret = 0;
     CryptoContext *c = h->priv_data;
 
     if (!av_strstart(uri, "crypto+", &nested_url) &&
@@ -78,7 +82,8 @@ static int crypto_open(URLContext *h, const char *uri, int flags)
         ret = AVERROR(ENOSYS);
         goto err;
     }
-    if ((ret = ffurl_open(&c->hd, nested_url, AVIO_FLAG_READ)) < 0) {
+    if ((ret = ffurl_open(&c->hd, nested_url, AVIO_FLAG_READ,
+                          &h->interrupt_callback, NULL)) < 0) {
         av_log(h, AV_LOG_ERROR, "Unable to open input\n");
         goto err;
     }
@@ -92,10 +97,7 @@ static int crypto_open(URLContext *h, const char *uri, int flags)
 
     h->is_streamed = 1;
 
-    return 0;
 err:
-    av_free(c->key);
-    av_free(c->iv);
     return ret;
 }
 
@@ -154,8 +156,6 @@ static int crypto_close(URLContext *h)
     if (c->hd)
         ffurl_close(c->hd);
     av_freep(&c->aes);
-    av_freep(&c->key);
-    av_freep(&c->iv);
     return 0;
 }