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,
' ');
367 if (linept - line > methodsize - 1) {
371 memcpy(method, line, linept - line);
372 method[linept - line] =
'\0';
374 if (!strcmp(method,
"ANNOUNCE"))
376 else if (!strcmp(method,
"OPTIONS"))
378 else if (!strcmp(method,
"RECORD"))
380 else if (!strcmp(method,
"SETUP"))
382 else if (!strcmp(method,
"PAUSE"))
384 else if (!strcmp(method,
"TEARDOWN"))
397 && (*methodcode !=
SETUP)) {
414 searchlinept = strchr(linept,
' ');
415 if (searchlinept == NULL) {
419 if (searchlinept - linept > urisize - 1) {
423 memcpy(uri, linept, searchlinept - linept);
424 uri[searchlinept - linept] =
'\0';
426 char host[128], path[512], auth[128];
428 char ctl_host[128], ctl_path[512], ctl_auth[128];
430 av_url_split(NULL, 0, auth,
sizeof(auth), host,
sizeof(host), &port,
431 path,
sizeof(path), uri);
432 av_url_split(NULL, 0, ctl_auth,
sizeof(ctl_auth), ctl_host,
433 sizeof(ctl_host), &ctl_port, ctl_path,
sizeof(ctl_path),
435 if (strcmp(host, ctl_host))
438 if (strcmp(path, ctl_path) && *methodcode !=
SETUP)
440 " %s\n", path, ctl_path);
443 "Updating control URI to %s\n", uri);
448 linept = searchlinept + 1;
459 unsigned char rbuf[4096];
460 unsigned char method[10];
467 ret =
read_line(s, rbuf,
sizeof(rbuf), &rbuflen);
471 sizeof(method), &methodcode);
481 if (methodcode ==
PAUSE) {
485 }
else if (methodcode ==
OPTIONS) {
487 "Public: ANNOUNCE, PAUSE, SETUP, TEARDOWN, "
488 "RECORD\r\n", request.
seq);
489 }
else if (methodcode ==
TEARDOWN) {
527 "Range: npt=%"PRId64
".%03"PRId64
"-\r\n",
576 unsigned char *content = NULL;
581 "Accept: application/sdp\r\n");
588 "Require: com.real.retain-entity-for-setup\r\n",
612 char host[128], path[512], auth[128];
616 unsigned char rbuf[4096];
617 unsigned char method[10];
623 av_url_split(NULL, 0, auth,
sizeof(auth), host,
sizeof(host), &port,
634 ff_url_join(tcpname,
sizeof(tcpname),
"tcp", NULL, host, port,
645 ret =
read_line(s, rbuf,
sizeof(rbuf), &rbuflen);
649 sizeof(method), &methodcode);
658 }
else if (methodcode ==
OPTIONS) {
660 }
else if (methodcode ==
RECORD) {
664 }
else if (methodcode ==
SETUP)
725 av_dlog(s,
"tcp_read_packet:\n");
744 av_dlog(s,
"id=%d len=%d\n",
id, len);
745 if (len > buf_size || len < 8)
759 id <= rtsp_st->interleaved_max)
774 av_url_split(NULL, 0, NULL, 0, host,
sizeof(host), &port, NULL, 0,
799 "Unsubscribe: %s\r\n",
810 int r, rule_nr, first = 1;
897 int64_t timestamp,
int flags)
941 .priv_class = &rtsp_demuxer_class,