|
79 | 79 | #include <curl/curl.h> |
80 | 80 |
|
81 | 81 | #define KEEPALIVE_INTERVAL_S 5 |
| 82 | +#define MAGIC to_fourcc('R', 'T', 'S', 'c') |
82 | 83 | #define MOD_NAME "[rtsp] " |
83 | 84 | #define VERSION_STR "V1.0" |
84 | 85 |
|
@@ -232,6 +233,7 @@ struct audio_rtsp_state { |
232 | 233 | }; |
233 | 234 |
|
234 | 235 | struct rtsp_state { |
| 236 | + uint32_t magic; |
235 | 237 | CURL *curl; |
236 | 238 | char uri[1024]; |
237 | 239 | rtps_types_t avType; |
@@ -485,6 +487,7 @@ vidcap_rtsp_init(struct vidcap_params *params, void **state) { |
485 | 487 |
|
486 | 488 | int len = -1; |
487 | 489 | char *save_ptr = NULL; |
| 490 | + s->magic = MAGIC; |
488 | 491 | s->avType = none; //-1 none, 0 a&v, 1 v, 2 a |
489 | 492 |
|
490 | 493 | s->addr = "127.0.0.1"; |
@@ -663,6 +666,7 @@ static CURL *init_curl() { |
663 | 666 | static size_t print_rtsp_header(char *buffer, size_t size, size_t nitems, void *userdata) { |
664 | 667 | int aggregate_size = size * nitems; |
665 | 668 | struct rtsp_state *s = (struct rtsp_state *) userdata; |
| 669 | + assert(s->magic == MAGIC); |
666 | 670 | if (strncmp(buffer, "RTSP/1.0 ", MIN(strlen("RTSP/1.0 "), (size_t) aggregate_size)) == 0) { |
667 | 671 | int code = atoi(buffer + strlen("RTSP/1.0 ")); |
668 | 672 | s->rtsp_error_occurred = code != 200; |
@@ -711,7 +715,7 @@ init_rtsp(struct rtsp_state *s) { |
711 | 715 | //my_curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, 1); |
712 | 716 | my_curl_easy_setopt(s->curl, CURLOPT_VERBOSE, 0L, goto error); |
713 | 717 | my_curl_easy_setopt(s->curl, CURLOPT_NOPROGRESS, 1L, goto error); |
714 | | - my_curl_easy_setopt(s->curl, CURLOPT_HEADERDATA, &s, goto error); |
| 718 | + my_curl_easy_setopt(s->curl, CURLOPT_HEADERDATA, s, goto error); |
715 | 719 | my_curl_easy_setopt(s->curl, CURLOPT_HEADERFUNCTION, print_rtsp_header, goto error); |
716 | 720 | my_curl_easy_setopt(s->curl, CURLOPT_URL, s->uri, goto error); |
717 | 721 |
|
|
0 commit comments