From: Not Zed Date: Thu, 25 Nov 2021 00:07:31 +0000 (+1030) Subject: Add log level get/set functions. X-Git-Url: https://code.zedzone.au/cvs?a=commitdiff_plain;h=5edb28d816923c900480aa6d31dafc54b033443f;p=jjmpeg Add log level get/set functions. --- diff --git a/src/notzed.jjmpeg/classes/au/notzed/jjmpeg/AVUtil.java b/src/notzed.jjmpeg/classes/au/notzed/jjmpeg/AVUtil.java index dce3c7d..727d838 100644 --- a/src/notzed.jjmpeg/classes/au/notzed/jjmpeg/AVUtil.java +++ b/src/notzed.jjmpeg/classes/au/notzed/jjmpeg/AVUtil.java @@ -40,6 +40,20 @@ public class AVUtil { */ public native static void setLogger(AVLogger logger); + /** + * Set log level. + * + * @param level AVLogger.AV_LOG* constants. + */ + public native static void setLogLevel(int level); + + /** + * Get log level. + * + * @return AVLogger.AV_LOG* constants. + */ + public native static int getLogLevel(); + private static final int levels[] = { AVLogger.AV_LOG_QUIET, AVLogger.AV_LOG_PANIC, diff --git a/src/notzed.jjmpeg/jni/jj-avutil.c b/src/notzed.jjmpeg/jni/jj-avutil.c index 8de4a15..19063f9 100644 --- a/src/notzed.jjmpeg/jni/jj-avutil.c +++ b/src/notzed.jjmpeg/jni/jj-avutil.c @@ -36,7 +36,7 @@ static void log_callback(void*ptr, int level, const char*fmt, va_list vl) { char log[1024]; int prefix = 1; int res; - + res = DLCALL(av_log_format_line2)(ptr, level, fmt, vl, log, sizeof(log), &prefix); if (res > 1) { jvalue args[2]; @@ -49,7 +49,7 @@ static void log_callback(void*ptr, int level, const char*fmt, va_list vl) { args[0].i = level; args[1].l = nativez_NewString(env, log); - + (*env)->CallVoidMethodA(env, jlogger_ref, AVLogger_log_il, args); } } @@ -69,3 +69,13 @@ JNIEXPORT void JNICALL Java_au_notzed_jjmpeg_AVUtil_setLogger DLCALL(av_log_set_callback)(DLCALL(av_log_default_callback)); } } + +JNIEXPORT void JNICALL Java_au_notzed_jjmpeg_AVUtil_setLogLevel +(JNIEnv *env, jclass jc, jint level) { + DLCALL(av_log_set_level(level)); +} + +JNIEXPORT jint JNICALL Java_au_notzed_jjmpeg_AVUtil_getLogLevel +(JNIEnv *env, jclass jc) { + return DLCALL(av_log_get_level()); +} diff --git a/src/notzed.jjmpeg/jni/jj-avutil.def b/src/notzed.jjmpeg/jni/jj-avutil.def index 55f3458..cff24e5 100644 --- a/src/notzed.jjmpeg/jni/jj-avutil.def +++ b/src/notzed.jjmpeg/jni/jj-avutil.def @@ -3,6 +3,8 @@ header avutil libavutil/log.h { av_log_default_callback av_log_format_line2 av_default_item_name + av_log_get_level + av_log_set_level } java AVLogger au/notzed/jjmpeg/AVLogger {