diff --git a/src/audio/audio.cpp b/src/audio/audio.cpp index c115ba2e3..b8800a5b1 100644 --- a/src/audio/audio.cpp +++ b/src/audio/audio.cpp @@ -70,6 +70,7 @@ #include "audio/playback/sdi.h" #include "audio/resampler.hpp" #include "audio/utils.h" +#include "config.h" // for HAVE_SPEEXDSP #include "debug.h" #include "host.h" #include "module.h" diff --git a/src/audio/playback/jack.c b/src/audio/playback/jack.c index f722b267d..812bd9c23 100644 --- a/src/audio/playback/jack.c +++ b/src/audio/playback/jack.c @@ -43,6 +43,7 @@ #include "audio/audio_playback.h" #include "audio/types.h" #include "audio/utils.h" +#include "config.h" // for PACKAGE_NAME #include "debug.h" #include "host.h" #include "jack_common.h" diff --git a/src/blackmagic_common.cpp b/src/blackmagic_common.cpp index 06d25a416..2a91341fd 100644 --- a/src/blackmagic_common.cpp +++ b/src/blackmagic_common.cpp @@ -65,6 +65,7 @@ #include "host.h" #include "tv.h" #include "utils/color_out.h" +#include "utils/debug.h" // for DEBUG_TIMER_* #include "utils/macros.h" #include "utils/windows.h" #include "utils/worker.h" diff --git a/src/capture_filter/resize_utils.cpp b/src/capture_filter/resize_utils.cpp index dbcca8b5c..f941a5097 100644 --- a/src/capture_filter/resize_utils.cpp +++ b/src/capture_filter/resize_utils.cpp @@ -64,6 +64,7 @@ #include "capture_filter/resize_utils.h" #include "debug.h" #include "utils/color_out.h" +#include "utils/debug.h" // for DEBUG_TIMER_* #include "video.h" #define DEFAULT_ALGO INTER_LINEAR diff --git a/src/debug.cpp b/src/debug.cpp index b787855c5..079e040a2 100644 --- a/src/debug.cpp +++ b/src/debug.cpp @@ -39,6 +39,9 @@ * SUCH DAMAGE. */ +#include "debug.h" +#include "utils/debug.h" + #ifdef HAVE_CONFIG_H #include "config.h" #endif // defined HAVE_CONFIG_H @@ -52,7 +55,6 @@ #include #include -#include "debug.h" #include "host.h" #include "utils/color_out.h" #include "utils/string_view_utils.hpp" diff --git a/src/debug.h b/src/debug.h index e847df926..1f27e2bf1 100644 --- a/src/debug.h +++ b/src/debug.h @@ -47,9 +47,6 @@ #include // FILE #endif // defined __cplusplus -#ifdef HAVE_CONFIG_H -#include "config.h" // DEBUG -#endif // defined HAVE_CONFIG_H #include "tv.h" #define UNUSED(x) (x=x) @@ -80,11 +77,6 @@ extern "C" { #endif void debug_dump(const void*lp, int len); -#ifdef DEBUG -void debug_file_dump(const char *key, void (*serialize)(const void *data, FILE *), void *data); -#else -#define debug_file_dump(key, serialize, data) (void) (key), (void) (serialize), (void) (data) -#endif #define error_msg(...) log_msg(LOG_LEVEL_ERROR, __VA_ARGS__) #define verbose_msg(...) log_msg(LOG_LEVEL_VERBOSE, __VA_ARGS__) @@ -323,13 +315,4 @@ if ((level) <= log_level) Logger(level).Get() #endif -#ifdef DEBUG -#define DEBUG_TIMER_EVENT(name) time_ns_t name = get_time_in_ns() -#define DEBUG_TIMER_START(name) DEBUG_TIMER_EVENT(name##_start); -#define DEBUG_TIMER_STOP(name) DEBUG_TIMER_EVENT(name##_stop); log_msg(LOG_LEVEL_DEBUG2, "%s duration: %lf s\n", #name, (name##_stop - name##_start) / NS_IN_SEC_DBL) // NOLINT(cppcoreguidelines-pro-type-vararg, hicpp-vararg) -#else -#define DEBUG_TIMER_START(name) -#define DEBUG_TIMER_STOP(name) -#endif - #endif diff --git a/src/hwaccel_vdpau.h b/src/hwaccel_vdpau.h index 96448ce53..d7514fa96 100644 --- a/src/hwaccel_vdpau.h +++ b/src/hwaccel_vdpau.h @@ -45,6 +45,8 @@ #ifndef HWACCEL_VDPAU_H #define HWACCEL_VDPAU_H +#include "config.h" // for HWACC_VDPAU + #ifdef HWACC_VDPAU #include "hwaccel_libav_common.h" diff --git a/src/libavcodec/from_lavc_vid_conv.c b/src/libavcodec/from_lavc_vid_conv.c index f6c3310c0..1b6596ad2 100644 --- a/src/libavcodec/from_lavc_vid_conv.c +++ b/src/libavcodec/from_lavc_vid_conv.c @@ -55,6 +55,7 @@ #include "color.h" #include "compat/qsort_s.h" +#include "config.h" // for HWACC_VDPAU #include "debug.h" #include "host.h" #include "hwaccel_vdpau.h" @@ -64,6 +65,7 @@ #include "libavcodec/lavc_common.h" #include "pixfmt_conv.h" #include "types.h" +#include "utils/debug.h" // for DEBUG_TIMER_* #include "utils/macros.h" // OPTIMIZED_FOR #include "utils/misc.h" // get_cpu_core_count #include "utils/worker.h" // task_run_parallel diff --git a/src/libavcodec/lavc_video.c b/src/libavcodec/lavc_video.c index 0e3ec7785..d87e86492 100644 --- a/src/libavcodec/lavc_video.c +++ b/src/libavcodec/lavc_video.c @@ -44,6 +44,7 @@ * Some conversions to RGBA ignore RGB-shifts - either fix that or deprecate RGB-shifts */ +#include "config.h" // for HAVE_SWSCALE #include "debug.h" #include "lib_common.h" #include "libavcodec/lavc_common.h" diff --git a/src/libavcodec/lavc_video.h b/src/libavcodec/lavc_video.h index 98fb128c0..c5585052e 100644 --- a/src/libavcodec/lavc_video.h +++ b/src/libavcodec/lavc_video.h @@ -44,6 +44,7 @@ #include #endif +#include "config.h" // for HAVE_SWSCALE #include "libavcodec/lavc_common.h" #ifdef __cplusplus diff --git a/src/rtp/audio_decoders.cpp b/src/rtp/audio_decoders.cpp index a329f8ab2..2b62b9fc1 100644 --- a/src/rtp/audio_decoders.cpp +++ b/src/rtp/audio_decoders.cpp @@ -76,6 +76,7 @@ #include "types.h" // for fec_desc, fec_type #include "ug_runtime_error.hpp" #include "utils/color_out.h" +#include "utils/debug.h" // for DEBUG_TIMER_* #include "utils/macros.h" #include "utils/packet_counter.h" #include "utils/worker.h" diff --git a/src/utils/debug.h b/src/utils/debug.h new file mode 100644 index 000000000..2814686d8 --- /dev/null +++ b/src/utils/debug.h @@ -0,0 +1,78 @@ +/** + * @file debug.h + * @author Martin Pulec + */ +/* + * Copyright (c) 2021-2024 CESNET + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, is permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. Neither the name of CESNET nor the names of its contributors may be + * used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef UTILS_DEBUG_H_36CF2E79_AF28_4308_BA8D_56D403BDCC44 +#define UTILS_DEBUG_H_36CF2E79_AF28_4308_BA8D_56D403BDCC44 + +#ifdef HAVE_CONFIG_H +#include "config.h" // for DEBUG +#endif + +#include "../debug.h" // for log_msg +#include "tv.h" // for get_time_in_ns + +#ifdef __cplusplus +#include // for FILE +#define EXTERNC extern "C" +#else +#include +#define EXTERNC // for FILE +#endif + +#ifdef DEBUG + +EXTERNC void debug_file_dump(const char *key, + void (*serialize)(const void *data, FILE *), + void *data); +#define DEBUG_TIMER_EVENT(name) time_ns_t name = get_time_in_ns() +#define DEBUG_TIMER_START(name) DEBUG_TIMER_EVENT(name##_start); +#define DEBUG_TIMER_STOP(name) \ + DEBUG_TIMER_EVENT(name##_stop); \ + log_msg(LOG_LEVEL_DEBUG2, "%s duration: %lf s\n", #name, \ + (name##_stop - name##_start) / NS_IN_SEC_DBL) \ + // NOLINT(cppcoreguidelines-pro-type-vararg, hicpp-vararg) + +#else + +#define debug_file_dump(key, serialize, data) \ + (void) (key), (void) (serialize), (void) (data) +#define DEBUG_TIMER_START(name) +#define DEBUG_TIMER_STOP(name) + +#endif // ! defined DEBUG + +#endif // ! defined UTILS_DEBUG_H_36CF2E79_AF28_4308_BA8D_56D403BDCC44 diff --git a/src/video_codec.c b/src/video_codec.c index ca6eae67a..c7fea2111 100644 --- a/src/video_codec.c +++ b/src/video_codec.c @@ -53,7 +53,7 @@ #define __STDC_WANT_LIB_EXT1__ 1 #ifdef HAVE_CONFIG_H -#include "config.h" +#include "config.h" // for HWACC_VDPAU #endif // HAVE_CONFIG_H #include "config_unix.h" #include "config_win32.h" @@ -70,6 +70,7 @@ #include "host.h" #include "hwaccel_vdpau.h" #include "hwaccel_drm.h" +#include "utils/debug.h" // for DEBUG_TIMER_* #include "utils/macros.h" // to_fourcc, OPTIMEZED_FOR #include "video_codec.h" diff --git a/src/video_compress/libavcodec.cpp b/src/video_compress/libavcodec.cpp index 0489b29df..26d038e97 100644 --- a/src/video_compress/libavcodec.cpp +++ b/src/video_compress/libavcodec.cpp @@ -67,6 +67,7 @@ #include "tv.h" #include "ug_runtime_error.hpp" #include "utils/color_out.h" +#include "utils/debug.h" // for debug_file_dump #include "utils/macros.h" #include "utils/misc.h" #include "utils/string.h" // replace_all diff --git a/src/video_decompress/libavcodec.c b/src/video_decompress/libavcodec.c index 916d7f572..134985a92 100644 --- a/src/video_decompress/libavcodec.c +++ b/src/video_decompress/libavcodec.c @@ -57,6 +57,7 @@ #include "rtp/rtpdec_h264.h" #include "rtp/rtpenc_h264.h" #include "tv.h" +#include "utils/debug.h" // for debug_file_dump #include "utils/macros.h" #include "video.h" #include "video_codec.h" diff --git a/src/video_display/conference.cpp b/src/video_display/conference.cpp index d5801da0b..d820f6ffb 100644 --- a/src/video_display/conference.cpp +++ b/src/video_display/conference.cpp @@ -46,6 +46,7 @@ #include #include +#include "config.h" // for HAVE_OPENCV2_OPENCV_HPP #include "debug.h" #include "host.h" #include "lib_common.h" diff --git a/src/video_display/gl.cpp b/src/video_display/gl.cpp index 54fc7f5ac..7b913ed88 100644 --- a/src/video_display/gl.cpp +++ b/src/video_display/gl.cpp @@ -77,6 +77,7 @@ #include "module.h" #include "types.h" #include "utils/color_out.h" +#include "utils/debug.h" // for DEBUG_TIMER_* #include "utils/macros.h" // OPTIMIZED_FOR #include "utils/ref_count.hpp" #include "video.h" diff --git a/src/video_display/gl_vdpau.hpp b/src/video_display/gl_vdpau.hpp index d46bf20f5..69f7f3f29 100644 --- a/src/video_display/gl_vdpau.hpp +++ b/src/video_display/gl_vdpau.hpp @@ -1,6 +1,8 @@ #ifndef GL_VDPAU_HPP_667244de5757 #define GL_VDPAU_HPP_667244de5757 +#include "config.h" // for HWACC_VDPAU + #ifdef HWACC_VDPAU #ifdef __APPLE__ diff --git a/src/video_display/opengl_conversions.cpp b/src/video_display/opengl_conversions.cpp index 594f4c5ce..04083fc48 100644 --- a/src/video_display/opengl_conversions.cpp +++ b/src/video_display/opengl_conversions.cpp @@ -36,6 +36,7 @@ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include "config.h" // for HWACC_VDPAU #include "color.h" #include "debug.h" #include "host.h" diff --git a/src/video_rxtx/rtp.cpp b/src/video_rxtx/rtp.cpp index d2043f11c..7bb49faa9 100644 --- a/src/video_rxtx/rtp.cpp +++ b/src/video_rxtx/rtp.cpp @@ -41,6 +41,7 @@ #include #include +#include "config.h" // for PACKAGE_STRING #include "debug.h" #include "host.h" #include "messaging.h"