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,
' ');
363 if (linept - line > methodsize - 1) {
367 memcpy(method, line, linept - line);
368 method[linept - line] =
'\0';
370 if (!strcmp(method,
"ANNOUNCE"))
372 else if (!strcmp(method,
"OPTIONS"))
374 else if (!strcmp(method,
"RECORD"))
376 else if (!strcmp(method,
"SETUP"))
378 else if (!strcmp(method,
"PAUSE"))
380 else if (!strcmp(method,
"TEARDOWN"))
393 && (*methodcode !=
SETUP)) {
410 searchlinept = strchr(linept,
' ');
411 if (searchlinept == NULL) {
415 if (searchlinept - linept > urisize - 1) {
419 memcpy(uri, linept, searchlinept - linept);
420 uri[searchlinept - linept] =
'\0';
422 char host[128], path[512], auth[128];
424 char ctl_host[128], ctl_path[512], ctl_auth[128];
426 av_url_split(NULL, 0, auth,
sizeof(auth), host,
sizeof(host), &port,
427 path,
sizeof(path), uri);
428 av_url_split(NULL, 0, ctl_auth,
sizeof(ctl_auth), ctl_host,
429 sizeof(ctl_host), &ctl_port, ctl_path,
sizeof(ctl_path),
431 if (strcmp(host, ctl_host))
434 if (strcmp(path, ctl_path) && *methodcode !=
SETUP)
436 " %s\n", path, ctl_path);
439 "Updating control URI to %s\n", uri);
444 linept = searchlinept + 1;
455 unsigned char rbuf[4096];
456 unsigned char method[10];
463 ret =
read_line(s, rbuf,
sizeof(rbuf), &rbuflen);
467 sizeof(method), &methodcode);
477 if (methodcode ==
PAUSE) {
481 }
else if (methodcode ==
OPTIONS) {
483 "Public: ANNOUNCE, PAUSE, SETUP, TEARDOWN, "
484 "RECORD\r\n", request.
seq);
485 }
else if (methodcode ==
TEARDOWN) {
523 "Range: npt=%"PRId64
".%03"PRId64
"-\r\n",
572 unsigned char *content = NULL;
577 "Accept: application/sdp\r\n");
584 "Require: com.real.retain-entity-for-setup\r\n",
608 char host[128], path[512], auth[128];
612 unsigned char rbuf[4096];
613 unsigned char method[10];
619 av_url_split(NULL, 0, auth,
sizeof(auth), host,
sizeof(host), &port,
630 ff_url_join(tcpname,
sizeof(tcpname),
"tcp", NULL, host, port,
641 ret =
read_line(s, rbuf,
sizeof(rbuf), &rbuflen);
645 sizeof(method), &methodcode);
654 }
else if (methodcode ==
OPTIONS) {
656 }
else if (methodcode ==
RECORD) {
660 }
else if (methodcode ==
SETUP)
721 av_dlog(s,
"tcp_read_packet:\n");
740 av_dlog(s,
"id=%d len=%d\n",
id, len);
741 if (len > buf_size || len < 8)
755 id <= rtsp_st->interleaved_max)
770 av_url_split(NULL, 0, NULL, 0, host,
sizeof(host), &port, NULL, 0,
795 "Unsubscribe: %s\r\n",
806 int r, rule_nr, first = 1;
893 int64_t timestamp,
int flags)
937 .priv_class = &rtsp_demuxer_class,