82 if (rbuf[idx] ==
'\r') {
84 }
else if (rbuf[idx] ==
'\n') {
90 }
while (idx < rbufsize);
96 const char *extracontent, uint16_t seq)
103 snprintf(message,
sizeof(message),
"RTSP/1.0 %d %s\r\n",
111 av_strlcatf(message,
sizeof(message),
"CSeq: %d\r\n", seq);
114 av_strlcat(message, extracontent,
sizeof(message));
116 av_dlog(s,
"Sending response:\n%s", message);
127 if (!session_id[0]) {
131 if (strcmp(session_id, request->
session_id)) {
148 ret =
read_line(s, rbuf,
sizeof(rbuf), &rbuflen);
152 av_dlog(s,
"Parsing[%d]: %s\n", rbuflen, rbuf);
155 }
while (rbuflen > 0);
156 if (request->
seq != rt->
seq + 1) {
161 if (rt->
session_id[0] && strcmp(method,
"OPTIONS")) {
192 "Unable to get complete SDP Description in ANNOUNCE\n");
205 "Content-Length header value exceeds sdp allocated buffer (4KB)\n");
207 "Content-Length exceeds buffer size", request.
seq);
224 "Public: ANNOUNCE, PAUSE, SETUP, TEARDOWN, RECORD\r\n",
236 char responseheaders[1024];
238 int transportidx = 0;
257 " protocol not supported (yet)\n");
263 "using first of all\n");
284 snprintf(responseheaders,
sizeof(responseheaders),
"Transport: "
285 "RTP/AVP/TCP;unicast;mode=receive;interleaved=%d-%d"
290 ff_url_join(url,
sizeof(url),
"rtp", NULL, host, localport, NULL);
291 av_dlog(s,
"Opening: %s", url);
310 snprintf(responseheaders,
sizeof(responseheaders),
"Transport: "
311 "RTP/AVP/UDP;unicast;mode=receive;source=%s;"
312 "client_port=%d-%d;server_port=%d-%d\r\n",
324 av_strlcatf(responseheaders,
sizeof(responseheaders),
"Session: %s\r\n",
338 char responseheaders[1024];
347 snprintf(responseheaders,
sizeof(responseheaders),
"Session: %s\r\n",
356 int linelen,
char *uri,
int urisize,
357 char *method,
int methodsize,
361 const char *linept, *searchlinept;
362 linept = strchr(line,
' ');
369 if (linept - line > methodsize - 1) {
373 memcpy(method, line, linept - line);
374 method[linept - line] =
'\0';
376 if (!strcmp(method,
"ANNOUNCE"))
378 else if (!strcmp(method,
"OPTIONS"))
380 else if (!strcmp(method,
"RECORD"))
382 else if (!strcmp(method,
"SETUP"))
384 else if (!strcmp(method,
"PAUSE"))
386 else if (!strcmp(method,
"TEARDOWN"))
399 && (*methodcode !=
SETUP)) {
416 searchlinept = strchr(linept,
' ');
421 if (searchlinept - linept > urisize - 1) {
425 memcpy(uri, linept, searchlinept - linept);
426 uri[searchlinept - linept] =
'\0';
428 char host[128], path[512], auth[128];
430 char ctl_host[128], ctl_path[512], ctl_auth[128];
432 av_url_split(NULL, 0, auth,
sizeof(auth), host,
sizeof(host), &port,
433 path,
sizeof(path), uri);
434 av_url_split(NULL, 0, ctl_auth,
sizeof(ctl_auth), ctl_host,
435 sizeof(ctl_host), &ctl_port, ctl_path,
sizeof(ctl_path),
437 if (strcmp(host, ctl_host))
440 if (strcmp(path, ctl_path) && *methodcode !=
SETUP)
442 " %s\n", path, ctl_path);
445 "Updating control URI to %s\n", uri);
450 linept = searchlinept + 1;
461 unsigned char rbuf[4096];
462 unsigned char method[10];
469 ret =
read_line(s, rbuf,
sizeof(rbuf), &rbuflen);
473 sizeof(method), &methodcode);
483 if (methodcode ==
PAUSE) {
487 }
else if (methodcode ==
OPTIONS) {
489 "Public: ANNOUNCE, PAUSE, SETUP, TEARDOWN, "
490 "RECORD\r\n", request.
seq);
491 }
else if (methodcode ==
TEARDOWN) {
529 "Range: npt=%"PRId64
".%03"PRId64
"-\r\n",
578 unsigned char *content = NULL;
583 "Accept: application/sdp\r\n");
590 "Require: com.real.retain-entity-for-setup\r\n",
614 char proto[128], host[128], path[512], auth[128];
619 const char *lower_proto =
"tcp";
620 unsigned char rbuf[4096];
621 unsigned char method[10];
627 av_url_split(proto,
sizeof(proto), auth,
sizeof(auth), host,
sizeof(host),
628 &port, path,
sizeof(path), s->
filename);
634 if (!strcmp(proto,
"rtsps")) {
643 ff_url_join(tcpname,
sizeof(tcpname), lower_proto, NULL, host, port,
654 ret =
read_line(s, rbuf,
sizeof(rbuf), &rbuflen);
658 sizeof(method), &methodcode);
667 }
else if (methodcode ==
OPTIONS) {
669 }
else if (methodcode ==
RECORD) {
673 }
else if (methodcode ==
SETUP)
686 #
if CONFIG_TLS_PROTOCOL
738 av_dlog(s,
"tcp_read_packet:\n");
757 av_dlog(s,
"id=%d len=%d\n",
id, len);
758 if (len > buf_size || len < 8)
772 id <= rtsp_st->interleaved_max)
787 av_url_split(NULL, 0, NULL, 0, host,
sizeof(host), &port, NULL, 0,
812 "Unsubscribe: %s\r\n",
823 int r, rule_nr, first = 1;
910 int64_t timestamp,
int flags)
955 .priv_class = &rtsp_demuxer_class,