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"
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];
433 path,
sizeof(path), uri);
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) {
541 "Range: npt=%"PRId64
".%03"PRId64
"-\r\n",
591 unsigned char *content =
NULL;
596 "Accept: application/sdp\r\n");
603 "Require: com.real.retain-entity-for-setup\r\n",
627 char proto[128], host[128], path[512], auth[128];
632 const char *lower_proto =
"tcp";
633 unsigned char rbuf[4096];
634 unsigned char method[10];
640 av_url_split(proto,
sizeof(proto), auth,
sizeof(auth), host,
sizeof(host),
641 &port, path,
sizeof(path), s->
filename);
647 if (!strcmp(proto,
"rtsps")) {
667 ret =
read_line(s, rbuf,
sizeof(rbuf), &rbuflen);
671 sizeof(method), &methodcode);
680 }
else if (methodcode ==
OPTIONS) {
682 }
else if (methodcode ==
RECORD) {
686 }
else if (methodcode ==
SETUP)
699 #
if CONFIG_TLS_PROTOCOL
751 av_dlog(s,
"tcp_read_packet:\n");
770 av_dlog(s,
"id=%d len=%d\n",
id, len);
771 if (len > buf_size || len < 8)
785 id <= rtsp_st->interleaved_max)
825 "Unsubscribe: %s\r\n",
836 int r, rule_nr, first = 1;
923 int64_t timestamp,
int flags)
968 .priv_class = &rtsp_demuxer_class,