Created
July 29, 2024 04:34
-
-
Save pellucide/a7073e6cd1bc8ecad30b896e97236166 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void ffmpeg_av_log_callback(void* ptr, int level, const char* fmt, va_list vl_arg) { | |
if (level > av_log_get_level()) | |
return; | |
static char const* tag = "AMP_FFMPEG_CALLBACK"; | |
static std::mutex log_mutex; | |
static int print_prefix = 1; | |
static int LINE_SZ = 1024; | |
char line[LINE_SZ]; | |
va_list vl; | |
std::lock_guard<std::mutex> guard(log_mutex); | |
va_copy(vl, vl_arg); | |
av_log_format_line(ptr, level, fmt, vl, line, LINE_SZ, &print_prefix); | |
va_end(vl); | |
switch(level) { | |
case AV_LOG_PANIC: | |
LOG(ANDROID_LOG_FATAL, tag, "%s", line); | |
break; | |
case AV_LOG_ERROR: | |
LOG(ANDROID_LOG_ERROR, tag, "%s", line); | |
break; | |
case AV_LOG_WARNING: | |
LOG(ANDROID_LOG_WARN, tag, "%s", line); | |
break; | |
case AV_LOG_INFO: | |
LOG(ANDROID_LOG_INFO, tag, "%s", line); | |
break; | |
case AV_LOG_VERBOSE: // libav's verbose is not particularly verbose | |
case AV_LOG_DEBUG: | |
LOG(ANDROID_LOG_DEBUG, tag, "%s", line); | |
break; | |
case AV_LOG_TRACE: | |
LOG(ANDROID_LOG_VERBOSE, tag, "%s", line); | |
break; | |
default: | |
LOG(ANDROID_LOG_DEFAULT, tag, "%s", line); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment