|
65 | 65 | #include "rtp/rtp_callback.h"
|
66 | 66 | #include "rtp/rtpdec_h264.h"
|
67 | 67 | #include "rtsp/rtsp_utils.h"
|
68 |
| -#include "utils/macros.h" |
| 68 | +#include "utils/color_out.h" // for color_printf, TBOLD |
| 69 | +#include "utils/macros.h" // for MIN, STR_LEN |
69 | 70 | #include "utils/text.h" // base64_decode
|
70 | 71 | #include "video_decompress.h"
|
71 | 72 |
|
@@ -150,9 +151,6 @@ init_decompressor(struct video_rtsp_state *sr, struct video_desc desc);
|
150 | 151 | static void *
|
151 | 152 | vidcap_rtsp_thread(void *args);
|
152 | 153 |
|
153 |
| -static void |
154 |
| -show_help(void); |
155 |
| - |
156 | 154 | void getNewLine(const char* buffer, int* i, char* line);
|
157 | 155 |
|
158 | 156 | void
|
@@ -251,13 +249,21 @@ struct rtsp_state {
|
251 | 249 | };
|
252 | 250 |
|
253 | 251 | static void
|
254 |
| -show_help() { |
255 |
| - printf("[rtsp] usage:\n"); |
256 |
| - printf("\t-t rtsp:<uri>[:rtp_rx_port=<port>][:decompress]\n"); |
257 |
| - printf("\t\t <uri> - RTSP server URI\n"); |
258 |
| - printf("\t\t <port> - receiver port number \n"); |
259 |
| - printf( |
260 |
| - "\t\t decompress - decompress the stream (default: disabled)\n\n"); |
| 252 | +show_help(bool full) { |
| 253 | + color_printf(TBOLD("RTSP client") " usage:\n"); |
| 254 | + color_printf("\t" TBOLD(TRED("-t rtsp:<uri>") "[:decompress]")); |
| 255 | + if (full) { |
| 256 | + color_printf(TBOLD("[:rtp_rx_port=<port>]")); |
| 257 | + } |
| 258 | + color_printf("\n\t" TBOLD("-t rtsp:[full]help") "\n"); |
| 259 | + color_printf("\noptions:\n"); |
| 260 | + color_printf("\t " TBOLD("<uri>") " - RTSP server URI\n"); |
| 261 | + printf("\t " TBOLD("decompress") " - decompress the stream " |
| 262 | + "(default: disabled)\n"); |
| 263 | + if (full) { |
| 264 | + printf("\t " TBOLD("<port>") " - video RTP receiver port number\n"); |
| 265 | + } |
| 266 | + color_printf("\n"); |
261 | 267 | }
|
262 | 268 |
|
263 | 269 | static void *
|
@@ -452,17 +458,16 @@ vidcap_rtsp_grab(void *state, struct audio_frame **audio) {
|
452 | 458 | }
|
453 | 459 |
|
454 | 460 | #define INIT_FAIL(msg) log_msg(LOG_LEVEL_ERROR, MOD_NAME msg); \
|
455 |
| - free(tmp); \ |
456 | 461 | vidcap_rtsp_done(s); \
|
457 |
| - show_help(); \ |
| 462 | + show_help(false); \ |
458 | 463 | return VIDCAP_INIT_FAIL
|
459 | 464 |
|
460 | 465 | static int
|
461 | 466 | vidcap_rtsp_init(struct vidcap_params *params, void **state) {
|
462 |
| - if (vidcap_params_get_fmt(params) |
463 |
| - && strcmp(vidcap_params_get_fmt(params), "help") == 0) |
464 |
| - { |
465 |
| - show_help(); |
| 467 | + char fmt[STR_LEN]; |
| 468 | + snprintf(fmt, sizeof fmt, "%s", vidcap_params_get_fmt(params)); |
| 469 | + if (strcmp(fmt, "help") == 0 || strcmp(fmt, "fullhelp") == 0) { |
| 470 | + show_help(strcmp(fmt, "fullhelp") == 0); |
466 | 471 | return VIDCAP_INIT_NOERR;
|
467 | 472 | }
|
468 | 473 |
|
@@ -501,24 +506,22 @@ vidcap_rtsp_init(struct vidcap_params *params, void **state) {
|
501 | 506 | s->vrtsp_state.h264_offset_len = 0;
|
502 | 507 |
|
503 | 508 | s->curl = NULL;
|
504 |
| - char *fmt = NULL; |
505 | 509 |
|
506 | 510 | pthread_mutex_init(&s->lock, NULL);
|
507 | 511 | pthread_cond_init(&s->keepalive_cv, NULL);
|
508 | 512 | pthread_mutex_init(&s->vrtsp_state.lock, NULL);
|
509 | 513 | pthread_cond_init(&s->vrtsp_state.boss_cv, NULL);
|
510 | 514 | pthread_cond_init(&s->vrtsp_state.worker_cv, NULL);
|
511 | 515 |
|
512 |
| - char *tmp, *item; |
513 |
| - fmt = strdup(vidcap_params_get_fmt(params)); |
514 |
| - tmp = fmt; |
| 516 | + char *tmp = fmt; |
| 517 | + char *item = NULL; |
515 | 518 | strcpy(s->uri, "rtsp://");
|
516 | 519 |
|
517 | 520 | s->vrtsp_state.desc.tile_count = 1;
|
518 | 521 |
|
519 | 522 | bool in_uri = true;
|
520 |
| - while ((item = strtok_r(fmt, ":", &save_ptr))) { |
521 |
| - fmt = NULL; |
| 523 | + while ((item = strtok_r(tmp, ":", &save_ptr))) { |
| 524 | + tmp = NULL; |
522 | 525 | bool option_given = true;
|
523 | 526 | if (strstr(item, "rtp_rx_port=") == item) {
|
524 | 527 | s->vrtsp_state.port = atoi(strchr(item, '=') + 1);
|
@@ -548,8 +551,6 @@ vidcap_rtsp_init(struct vidcap_params *params, void **state) {
|
548 | 551 | in_uri = false;
|
549 | 552 | }
|
550 | 553 | }
|
551 |
| - free(tmp); |
552 |
| - tmp = NULL; |
553 | 554 |
|
554 | 555 | //re-check parameters
|
555 | 556 | if (strcmp(s->uri, "rtsp://") == 0) {
|
|
0 commit comments