Skip to content

Commit

Permalink
tools: add ug_stub.c to substitute host.cpp
Browse files Browse the repository at this point in the history
Because host.cpp has extensive dependencies on UG internals, it is a
bit tricky to link-in. Created a replacement instead.
  • Loading branch information
MartinPulec committed Sep 30, 2024
1 parent 9adf7b6 commit bdce8d7
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 13 deletions.
7 changes: 1 addition & 6 deletions src/libavcodec/lavc_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,18 +178,13 @@ static void av_log_ug_callback(void *avcl, int av_level, const char *fmt, va_lis
buf[0] = '\0';
}

#ifdef HAVE_CONFIG_H // built inside UG
ADD_TO_PARAM("lavc-log-level",
"* lavc-log-level=<num>\n"
" Set libavcodec log level (FFmpeg range semantics, bypasses UG logger)\n"
" - 'D' - use FFmpeg default log handler\n");
#endif
/// Sets specified log level either given explicitly or from UG-wide log_level
void ug_set_av_logging() {
const char *param = NULL;
#ifdef HAVE_CONFIG_H // built inside UG
param = get_commandline_param("lavc-log-level");
#endif
const char *param = get_commandline_param("lavc-log-level");
if (param == NULL) {
av_log_set_callback(av_log_ug_callback);
return;
Expand Down
6 changes: 0 additions & 6 deletions src/utils/color_out.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,21 +125,16 @@ static bool isMsysPty(int fd) {
}
#endif // defined _WIN32

// conditional include here (and below) is to allow compilation outside UG
// without the need to link with host.o, which seems to be tricky
#ifdef HAVE_CONFIG_H
ADD_TO_PARAM("log-color", "* log-color[=no]\n"
" Force enable/disable ANSI text formatting.\n");
ADD_TO_PARAM("log-nocolor", "* log-nocolor\n"
" Force disable ANSI text formatting.\n");
#endif
/**
* @returns whether stdout can process ANSI escape sequences
*/
static bool
is_output_color()
{
#ifdef HAVE_CONFIG_H
const char *const param_val = get_commandline_param("log-color");
if (param_val != nullptr) {
return strcmp(param_val, "no") != 0;
Expand All @@ -150,7 +145,6 @@ is_output_color()
"'log-color=no' instead\n");
return false;
}
#endif
const char *env_val = getenv("ULTRAGRID_COLOR_OUT");
if (env_val != nullptr && strlen(env_val) > 0) {
return strcmp(env_val, "0") != 0;
Expand Down
3 changes: 2 additions & 1 deletion tools/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ TARGETS=astat_lib astat_test benchmark_ff_convs convert decklink_temperature \

COMMON_OBJS = src/color.o src/debug.o src/video_codec.o src/pixfmt_conv.o \
src/utils/color_out.o src/utils/misc.o src/video_frame.o \
src/utils/pam.o src/utils/y4m.o
src/utils/pam.o src/utils/y4m.o \
ug_stub.o

OBJS=$(shell find . -name '*.o')

Expand Down
21 changes: 21 additions & 0 deletions tools/ug_stub.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* @file
* replacement for UltraGrid functions/global objects that are not linked-in,
* usually the ones located in host.cpp
*/

#include <stddef.h>

const char *
get_commandline_param(const char *key)
{
(void) key;
return NULL;
}

void
register_param(const char *param, const char *doc)
{
(void) param;
(void) doc;
}

0 comments on commit bdce8d7

Please sign in to comment.