]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/crypto.c
rtpproto: Allow specifying a separate rtcp port in ff_rtp_set_remote_url
[ffmpeg] / libavformat / crypto.c
index ea6012ad09fc9eff5c542c954a5575f91435f3f2..3bc33f2bb9dd980d5b976431f724a475f46b2d70 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,11 +82,12 @@ 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;
     }
-    c->aes = av_mallocz(av_aes_size);
+    c->aes = av_aes_alloc();
     if (!c->aes) {
         ret = AVERROR(ENOMEM);
         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;
 }
 
@@ -153,9 +155,7 @@ static int crypto_close(URLContext *h)
     CryptoContext *c = h->priv_data;
     if (c->hd)
         ffurl_close(c->hd);
-    av_free(c->aes);
-    av_free(c->key);
-    av_free(c->iv);
+    av_freep(&c->aes);
     return 0;
 }