Skip to content

Commit

Permalink
vcomp/rtsp: hide rtp_rx_port
Browse files Browse the repository at this point in the history
DNM refers to CESNETGH-400
  • Loading branch information
MartinPulec committed Jul 15, 2024
1 parent 91bf978 commit e8b3e73
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions src/video_capture/rtsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -251,13 +249,20 @@ struct rtsp_state {
};

static void
show_help() {
printf("[rtsp] usage:\n");
printf("\t-t rtsp:<uri>[:rtp_rx_port=<port>][:decompress]\n");
printf("\t\t <uri> - RTSP server URI\n");
printf("\t\t <port> - 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:<uri>") "[:decompress]"));
if (full) {
color_printf(TBOLD("[:rtp_rx_port=<port>]"));
}
color_printf("\n\t" TBOLD("-t rtsp:[full]help") "\n");
color_printf("\noptions:\n");
printf("\t <uri> - RTSP server URI\n");
printf("\t decompress - decompress the stream (default: disabled)\n");
if (full) {
printf("\t <port> - video RTP receiver port number \n");
}
color_printf("\n");
}

static void *
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -501,24 +505,22 @@ 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);
pthread_mutex_init(&s->vrtsp_state.lock, NULL);
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);
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit e8b3e73

Please sign in to comment.