From e8b3e7338d0f7b7dc9983b82a8c30255bf52d397 Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Mon, 15 Jul 2024 11:26:44 +0200 Subject: [PATCH] vcomp/rtsp: hide rtp_rx_port DNM refers to GH-400 --- src/video_capture/rtsp.c | 50 ++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/video_capture/rtsp.c b/src/video_capture/rtsp.c index 30701ca4f..50ec3f7ad 100644 --- a/src/video_capture/rtsp.c +++ b/src/video_capture/rtsp.c @@ -65,7 +65,8 @@ #include "rtp/rtp_callback.h" #include "rtp/rtpdec_h264.h" #include "rtsp/rtsp_utils.h" -#include "utils/macros.h" +#include "utils/color_out.h" // for color_printf, TBOLD +#include "utils/macros.h" // for MIN, STR_LEN #include "utils/text.h" // base64_decode #include "video_decompress.h" @@ -150,9 +151,6 @@ init_decompressor(struct video_rtsp_state *sr, struct video_desc desc); static void * vidcap_rtsp_thread(void *args); -static void -show_help(void); - void getNewLine(const char* buffer, int* i, char* line); void @@ -251,13 +249,20 @@ struct rtsp_state { }; static void -show_help() { - printf("[rtsp] usage:\n"); - printf("\t-t rtsp:[:rtp_rx_port=][:decompress]\n"); - printf("\t\t - RTSP server URI\n"); - printf("\t\t - receiver port number \n"); - printf( - "\t\t decompress - decompress the stream (default: disabled)\n\n"); +show_help(bool full) { + color_printf(TBOLD("RTSP client") " usage:\n"); + color_printf("\t" TBOLD(TRED("-t rtsp:") "[:decompress]")); + if (full) { + color_printf(TBOLD("[:rtp_rx_port=]")); + } + color_printf("\n\t" TBOLD("-t rtsp:[full]help") "\n"); + color_printf("\noptions:\n"); + printf("\t - RTSP server URI\n"); + printf("\t decompress - decompress the stream (default: disabled)\n"); + if (full) { + printf("\t - video RTP receiver port number \n"); + } + color_printf("\n"); } static void * @@ -452,17 +457,16 @@ vidcap_rtsp_grab(void *state, struct audio_frame **audio) { } #define INIT_FAIL(msg) log_msg(LOG_LEVEL_ERROR, MOD_NAME msg); \ - free(tmp); \ vidcap_rtsp_done(s); \ - show_help(); \ + show_help(false); \ return VIDCAP_INIT_FAIL static int vidcap_rtsp_init(struct vidcap_params *params, void **state) { - if (vidcap_params_get_fmt(params) - && strcmp(vidcap_params_get_fmt(params), "help") == 0) - { - show_help(); + char fmt[STR_LEN]; + snprintf(fmt, sizeof fmt, "%s", vidcap_params_get_fmt(params)); + if (strcmp(fmt, "help") == 0 || strcmp(fmt, "fullhelp") == 0) { + show_help(strcmp(fmt, "fullhelp") == 0); return VIDCAP_INIT_NOERR; } @@ -501,7 +505,6 @@ vidcap_rtsp_init(struct vidcap_params *params, void **state) { s->vrtsp_state.h264_offset_len = 0; s->curl = NULL; - char *fmt = NULL; pthread_mutex_init(&s->lock, NULL); pthread_cond_init(&s->keepalive_cv, NULL); @@ -509,16 +512,15 @@ vidcap_rtsp_init(struct vidcap_params *params, void **state) { pthread_cond_init(&s->vrtsp_state.boss_cv, NULL); pthread_cond_init(&s->vrtsp_state.worker_cv, NULL); - char *tmp, *item; - fmt = strdup(vidcap_params_get_fmt(params)); - tmp = fmt; + char *tmp = fmt; + char *item = NULL; strcpy(s->uri, "rtsp://"); s->vrtsp_state.desc.tile_count = 1; bool in_uri = true; - while ((item = strtok_r(fmt, ":", &save_ptr))) { - fmt = NULL; + while ((item = strtok_r(tmp, ":", &save_ptr))) { + tmp = NULL; bool option_given = true; if (strstr(item, "rtp_rx_port=") == item) { s->vrtsp_state.port = atoi(strchr(item, '=') + 1); @@ -548,8 +550,6 @@ vidcap_rtsp_init(struct vidcap_params *params, void **state) { in_uri = false; } } - free(tmp); - tmp = NULL; //re-check parameters if (strcmp(s->uri, "rtsp://") == 0) {