diff --git a/README.html b/README.html index 963be44..33a3793 100644 --- a/README.html +++ b/README.html @@ -1275,9 +1275,10 @@ to a file to n or less. To change the name audiodump, use -admp [n] filename. Note that (unlike dumped video) the dumped audio is currently only useful for debugging, as it is not containerized to make it playable with standard audio players.

-

-d Enable debug output. Note: this does not show -GStreamer error or debug messages. To see GStreamer error and warning -messages, set the environment variable GST_DEBUG with “export +

-d [n] Enable debug output; optional argument n=1 +suppresses audio/video packet data in debug output. Note: this does not +show GStreamer error or debug messages. To see GStreamer error and +warning messages, set the environment variable GST_DEBUG with “export GST_DEBUG=2” before running uxplay. To see GStreamer information messages, set GST_DEBUG=4; for DEBUG messages, GST_DEBUG=5; increase this to see even more of the GStreamer inner workings.

diff --git a/README.md b/README.md index 30a91da..c871564 100644 --- a/README.md +++ b/README.md @@ -1304,7 +1304,9 @@ that (unlike dumped video) the dumped audio is currently only useful for debugging, as it is not containerized to make it playable with standard audio players.* -**-d** Enable debug output. Note: this does not show GStreamer error or +**-d \[n\]** Enable debug output; optional argument n=1 suppresses audio/video +packet data in debug output. +Note: this does not show GStreamer error or debug messages. To see GStreamer error and warning messages, set the environment variable GST_DEBUG with "export GST_DEBUG=2" before running uxplay. To see GStreamer information messages, set GST_DEBUG=4; for diff --git a/README.txt b/README.txt index 2c9a3f5..a0d5064 100644 --- a/README.txt +++ b/README.txt @@ -1305,12 +1305,13 @@ that (unlike dumped video) the dumped audio is currently only useful for debugging, as it is not containerized to make it playable with standard audio players.* -**-d** Enable debug output. Note: this does not show GStreamer error or -debug messages. To see GStreamer error and warning messages, set the -environment variable GST_DEBUG with "export GST_DEBUG=2" before running -uxplay. To see GStreamer information messages, set GST_DEBUG=4; for -DEBUG messages, GST_DEBUG=5; increase this to see even more of the -GStreamer inner workings. +**-d \[n\]** Enable debug output; optional argument n=1 suppresses +audio/video packet data in debug output. Note: this does not show +GStreamer error or debug messages. To see GStreamer error and warning +messages, set the environment variable GST_DEBUG with "export +GST_DEBUG=2" before running uxplay. To see GStreamer information +messages, set GST_DEBUG=4; for DEBUG messages, GST_DEBUG=5; increase +this to see even more of the GStreamer inner workings. # Troubleshooting diff --git a/lib/logger.h b/lib/logger.h index 970344f..bf2653f 100644 --- a/lib/logger.h +++ b/lib/logger.h @@ -31,6 +31,7 @@ extern "C" { #define LOGGER_NOTICE 5 /* normal but significant condition */ #define LOGGER_INFO 6 /* informational */ #define LOGGER_DEBUG 7 /* debug-level messages */ +#define LOGGER_DEBUG_DATA 8 /* debug-level messages including audio/video packet data */ typedef void (*logger_callback_t)(void *cls, int level, const char *msg); diff --git a/lib/raop_rtp.c b/lib/raop_rtp.c index cfda905..f51eeab 100644 --- a/lib/raop_rtp.c +++ b/lib/raop_rtp.c @@ -421,6 +421,7 @@ raop_rtp_thread_udp(void *arg) assert(raop_rtp); bool logger_debug = (logger_get_level(raop_rtp->logger) >= LOGGER_DEBUG); + bool logger_debug_data = (logger_get_level(raop_rtp->logger) >= LOGGER_DEBUG_DATA); raop_rtp->ntp_start_time = raop_ntp_get_local_time(); raop_rtp->rtp_clock_started = false; @@ -636,7 +637,7 @@ raop_rtp_thread_udp(void *arg) audio_data.ntp_time_remote = rtp_time_to_client_ntp(raop_rtp, rtp_timestamp); audio_data.ntp_time_local = raop_ntp_convert_remote_time(raop_rtp->ntp, audio_data.ntp_time_remote); - if (logger_debug) { + if (logger_debug_data) { uint64_t ntp_now = raop_ntp_get_local_time(); int64_t latency = (audio_data.ntp_time_local ? ((int64_t) ntp_now) - ((int64_t) audio_data.ntp_time_local) : 0); logger_log(raop_rtp->logger, LOGGER_DEBUG, diff --git a/lib/raop_rtp_mirror.c b/lib/raop_rtp_mirror.c index cd38896..de79ed4 100644 --- a/lib/raop_rtp_mirror.c +++ b/lib/raop_rtp_mirror.c @@ -195,6 +195,7 @@ raop_rtp_mirror_thread(void *arg) uint64_t ntp_timestamp_local = 0; unsigned char nal_start_code[4] = { 0x00, 0x00, 0x00, 0x01 }; bool logger_debug = (logger_get_level(raop_rtp_mirror->logger) >= LOGGER_DEBUG); + bool logger_debug_data = (logger_get_level(raop_rtp_mirror->logger) >= LOGGER_DEBUG_DATA); bool h265_video = false; video_codec_t codec = VIDEO_CODEC_UNKNOWN; const char h264[] = "h264"; @@ -396,7 +397,7 @@ raop_rtp_mirror_thread(void *arg) // counting nano seconds since last boot. ntp_timestamp_local = raop_ntp_convert_remote_time(raop_rtp_mirror->ntp, ntp_timestamp_remote); - if (logger_debug) { + if (logger_debug_data) { uint64_t ntp_now = raop_ntp_get_local_time(); int64_t latency = (ntp_timestamp_local ? ((int64_t) ntp_now) - ((int64_t) ntp_timestamp_local) : 0); logger_log(raop_rtp_mirror->logger, LOGGER_DEBUG, diff --git a/uxplay.1 b/uxplay.1 index 35b8b8d..29b1179 100644 --- a/uxplay.1 +++ b/uxplay.1 @@ -165,7 +165,7 @@ UxPlay 1.71: An open\-source AirPlay mirroring (+ audio streaming) server: audio packets are dumped. "aud"= unknown format. .PP .TP -\fB\-d\fR Enable debug logging +\fB\-d [n]\fR Enable debug logging; optional: n=1 to skip normal packet data. .TP \fB\-v\fR Displays version information .TP diff --git a/uxplay.cpp b/uxplay.cpp index 605e737..914c263 100644 --- a/uxplay.cpp +++ b/uxplay.cpp @@ -126,6 +126,7 @@ static bool do_append_hostname = true; static bool use_random_hw_addr = false; static unsigned short display[5] = {0}, tcp[3] = {0}, udp[3] = {0}; static bool debug_log = DEFAULT_DEBUG_LOG; +static bool suppress_packet_debug_data = false; static int log_level = LOGGER_INFO; static bool bt709_fix = false; static bool srgb_fix = DEFAULT_SRGB_FIX; @@ -717,7 +718,7 @@ static void print_info (char *name) { printf(" =1,2,..; fn=\"audiodump\"; change with \"-admp [n] filename\".\n"); printf(" x increases when audio format changes. If n is given, <= n\n"); printf(" audio packets are dumped. \"aud\"= unknown format.\n"); - printf("-d Enable debug logging\n"); + printf("-d [n] Enable debug logging; optional: n=1 to skip normal packet data\n"); printf("-v Displays version information\n"); printf("-h Displays this help\n"); printf("Startup options in $UXPLAYRC, ~/.uxplayrc, or ~/.config/uxplayrc are\n"); @@ -989,7 +990,18 @@ static void parse_arguments (int argc, char *argv[]) { } else if (arg == "-a") { use_audio = false; } else if (arg == "-d") { - debug_log = !debug_log; + if (i < argc - 1 && *argv[i+1] != '-') { + unsigned int n = 1; + if (!get_value(argv[++i], &n)) { + fprintf(stderr, "invalid \"-d %s\"; -d n : max n=1 (suppress packet data in debug output)\n", argv[i]); + exit(1); + } + debug_log = true; + suppress_packet_debug_data = true; + } else { + debug_log = !debug_log; + suppress_packet_debug_data = false; + } } else if (arg == "-h" || arg == "--help" || arg == "-?" || arg == "-help") { print_info(argv[0]); exit(0); @@ -2180,7 +2192,11 @@ int main (int argc, char *argv[]) { } parse_arguments (argc, argv); - log_level = (debug_log ? LOGGER_DEBUG : LOGGER_INFO); + log_level = (debug_log ? LOGGER_DEBUG_DATA : LOGGER_INFO); + if (debug_log && suppress_packet_debug_data) { + log_level = LOGGER_DEBUG; + } + #ifdef _WIN32 /* use utf-8 terminal output; don't buffer stdout in WIN32 when debug_log = false */ SetConsoleOutputCP(CP_UTF8);