diff mbox series

[FFmpeg-devel,2/2] avformat/file: Combine all CONFIG_ANDROID_CONTENT_PROTOCOL blocks

Message ID GV1P250MB07374F24E278493C744AF9FB8F302@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM
State Accepted
Commit e95dd6f53e49325f95ac2243acf3667a6ddf40ac
Headers show
Series [FFmpeg-devel,1/2] avformat/file: Constify android content protocol | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished

Commit Message

Andreas Rheinhardt March 23, 2024, 12:20 p.m. UTC
Besides improving readability this also ensures that
a developer who has the android content protocol enabled
and works on the other parts of the file will not
forget to add necessary inclusions just because of
(indirect) inclusions from the files included only
when said protocol is enabled.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavformat/file.c | 36 +++++++++++++++---------------------
 1 file changed, 15 insertions(+), 21 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/file.c b/libavformat/file.c
index 8f3b35c795..182995717a 100644
--- a/libavformat/file.c
+++ b/libavformat/file.c
@@ -40,12 +40,6 @@ 
 #include <stdlib.h>
 #include "os_support.h"
 #include "url.h"
-#if CONFIG_ANDROID_CONTENT_PROTOCOL
-#include <jni.h>
-#include "libavcodec/jni.h"
-#include "libavcodec/ffjni.c"
-#endif
-
 
 /* Some systems may not have S_ISFIFO */
 #ifndef S_ISFIFO
@@ -107,21 +101,6 @@  typedef struct FileContext {
     int64_t initial_pos;
 } FileContext;
 
-
-#if CONFIG_ANDROID_CONTENT_PROTOCOL
-static const AVOption android_content_options[] = {
-    { "blocksize", "set I/O operation maximum block size", offsetof(FileContext, blocksize), AV_OPT_TYPE_INT, { .i64 = INT_MAX }, 1, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM },
-    { NULL }
-};
-
-static const AVClass android_content_class = {
-    .class_name = "android_content",
-    .item_name  = av_default_item_name,
-    .option     = android_content_options,
-    .version    = LIBAVUTIL_VERSION_INT,
-};
-#endif
-
 static const AVOption file_options[] = {
     { "truncate", "truncate existing files on write", offsetof(FileContext, trunc), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, AV_OPT_FLAG_ENCODING_PARAM },
     { "blocksize", "set I/O operation maximum block size", offsetof(FileContext, blocksize), AV_OPT_TYPE_INT, { .i64 = INT_MAX }, 1, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM },
@@ -547,6 +526,9 @@  const URLProtocol ff_fd_protocol = {
 #endif /* CONFIG_FD_PROTOCOL */
 
 #if CONFIG_ANDROID_CONTENT_PROTOCOL
+#include <jni.h>
+#include "libavcodec/jni.h"
+#include "libavcodec/ffjni.c"
 
 typedef struct JFields {
     jclass uri_class;
@@ -670,6 +652,18 @@  done:
     return ret;
 }
 
+static const AVOption android_content_options[] = {
+    { "blocksize", "set I/O operation maximum block size", offsetof(FileContext, blocksize), AV_OPT_TYPE_INT, { .i64 = INT_MAX }, 1, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM },
+    { NULL }
+};
+
+static const AVClass android_content_class = {
+    .class_name = "android_content",
+    .item_name  = av_default_item_name,
+    .option     = android_content_options,
+    .version    = LIBAVUTIL_VERSION_INT,
+};
+
 const URLProtocol ff_android_content_protocol = {
     .name                = "content",
     .url_open            = android_content_open,