diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..1bffd18 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,44 @@ +cmake_minimum_required(VERSION 3.22) + +project(simple-whep-client VERSION 1.0 LANGUAGES C) + +find_package(PkgConfig REQUIRED) + +pkg_check_modules( + GSTREAMER + REQUIRED + IMPORTED_TARGET + gstreamer-1.0>=1.16 + gstreamer-webrtc-1.0>=1.16 + gstreamer-sdp-1.0>=1.16 + gstreamer-video-1.0 +) + +pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) +pkg_check_modules(SOUP REQUIRED IMPORTED_TARGET libsoup-3.0) + +add_executable(whep-client src/whep-client.c) + +target_compile_features(whep-client PRIVATE c_std_99) +target_compile_options( + whep-client + PRIVATE + -Wall + -Wstrict-prototypes + -Wmissing-prototypes + -Wmissing-declarations + -Wunused +) + +target_link_libraries( + whep-client + PRIVATE PkgConfig::GSTREAMER PkgConfig::GLIB PkgConfig::SOUP +) + +if(WIN32) + target_compile_definitions(whep-client PRIVATE _WIN32_WINNT=0x0601) + target_link_libraries(whep-client PRIVATE ws2_32) +endif() + +include(GNUInstallDirs) +install(TARGETS whep-client RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/src/debug.h b/src/debug.h index d67cbad..3259abb 100644 --- a/src/debug.h +++ b/src/debug.h @@ -68,6 +68,14 @@ static const char *whep_name_prefix[] = { ANSI_COLOR_CYAN"[WHEP]"ANSI_COLOR_RESET" " }; +#if defined(_WIN32) +static inline struct tm * +localtime_r(const time_t *restrict t, struct tm *restrict r) +{ + return (localtime_s(r, t) == 0) ? r : NULL; +} +#endif + /* Simple wrapper to g_print/printf */ #define WHEP_PRINT g_print /* Logger based on different levels, which can either be displayed