diff --git a/src/rtsp.c b/src/rtsp.c index 54ec0386..c453b7e9 100644 --- a/src/rtsp.c +++ b/src/rtsp.c @@ -33,8 +33,11 @@ rtsp_send( http_client_t *hc, http_cmd_t cmd, http_arg_list_t *hdr ) { http_arg_list_t h; - size_t blen = 7 + strlen(hc->hc_host) + (path ? strlen(path) : 1) + 1; + size_t blen = 7 + strlen(hc->hc_host) + + (hc->hc_port != 554 ? 7 : 0) + + (path ? strlen(path) : 1) + 1; char *buf = alloca(blen); + char buf2[7]; if (hc->hc_rtsp_session) { if (hdr == NULL) { @@ -43,7 +46,11 @@ rtsp_send( http_client_t *hc, http_cmd_t cmd, } http_arg_set(hdr, "Session", hc->hc_rtsp_session); } - snprintf(buf, blen, "rtsp://%s%s", hc->hc_host, path ? path : "/"); + if (hc->hc_port != 554) + snprintf(buf2, sizeof(buf2), ":%d", hc->hc_port); + else + buf2[0] = '\0'; + snprintf(buf, blen, "rtsp://%s%s%s", hc->hc_host, buf2, path ? path : "/"); return http_client_send(hc, cmd, buf, query, hdr, NULL, 0); }