Skip to content

Commit

Permalink
vcap/rtsp: log just setting opts
Browse files Browse the repository at this point in the history
refers to GH-400
  • Loading branch information
MartinPulec committed Jul 18, 2024
1 parent 4bf2808 commit f7dd228
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/video_capture/rtsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,40 @@ enum {
DEFAULT_RTSP_PORT = 554,
};

static const char *int_to_str(int i) {
_Thread_local static char buf[100];
snprintf(buf, sizeof buf, "%d", i);
return buf;
}

static const char *long_to_str(long l) {
_Thread_local static char buf[100];
snprintf(buf, sizeof buf, "%ld", l);
return buf;
}

static const char *pointer_to_str(void *p) {
_Thread_local static char buf[100];
snprintf(buf, sizeof buf, "%p", p);
return buf;
}

static const char *cstr_identity(const char *c) {
return c;
}

#define get_s(X) \
_Generic((X), \
int: int_to_str, \
long: long_to_str, \
const char *: cstr_identity, \
default: pointer_to_str)(X)

/* error handling macros */
#define my_curl_easy_setopt(A, B, C, action_fail) \
{ \
CURLcode res = CURLE_OK; \
MSG(VERBOSE, "Setting " #B " to %s\n", get_s(C)); \
if ((res = curl_easy_setopt((A), (B), (C))) != CURLE_OK){ \
log_msg(LOG_LEVEL_ERROR, MOD_NAME "curl_easy_setopt(%s, %s, %s) failed: %s (%d)\n", #A, #B, #C, curl_easy_strerror(res), res); \
printf("[rtsp error] could not configure rtsp capture properly, \n\t\tplease check your parameters. \nExiting...\n\n"); \
Expand Down

0 comments on commit f7dd228

Please sign in to comment.