rtspdec.c
Go to the documentation of this file.
1 /*
2  * RTSP demuxer
3  * Copyright (c) 2002 Fabrice Bellard
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 #include "libavutil/avstring.h"
23 #include "libavutil/intreadwrite.h"
24 #include "libavutil/mathematics.h"
25 #include "libavutil/random_seed.h"
26 #include "libavutil/time.h"
27 #include "avformat.h"
28 
29 #include "internal.h"
30 #include "network.h"
31 #include "os_support.h"
32 #include "rtsp.h"
33 #include "rdt.h"
34 #include "url.h"
35 
36 static const struct RTSPStatusMessage {
38  const char *message;
39 } status_messages[] = {
40  { RTSP_STATUS_OK, "OK" },
41  { RTSP_STATUS_METHOD, "Method Not Allowed" },
42  { RTSP_STATUS_BANDWIDTH, "Not Enough Bandwidth" },
43  { RTSP_STATUS_SESSION, "Session Not Found" },
44  { RTSP_STATUS_STATE, "Method Not Valid in This State" },
45  { RTSP_STATUS_AGGREGATE, "Aggregate operation not allowed" },
46  { RTSP_STATUS_ONLY_AGGREGATE, "Only aggregate operation allowed" },
47  { RTSP_STATUS_TRANSPORT, "Unsupported transport" },
48  { RTSP_STATUS_INTERNAL, "Internal Server Error" },
49  { RTSP_STATUS_SERVICE, "Service Unavailable" },
50  { RTSP_STATUS_VERSION, "RTSP Version not supported" },
51  { 0, "NULL" }
52 };
53 
55 {
56  RTSPState *rt = s->priv_data;
57 
58  if (!(rt->rtsp_flags & RTSP_FLAG_LISTEN))
59  ff_rtsp_send_cmd_async(s, "TEARDOWN", rt->control_uri, NULL);
60 
64  rt->real_setup = NULL;
66  return 0;
67 }
68 
69 static inline int read_line(AVFormatContext *s, char *rbuf, const int rbufsize,
70  int *rbuflen)
71 {
72  RTSPState *rt = s->priv_data;
73  int idx = 0;
74  int ret = 0;
75  *rbuflen = 0;
76 
77  do {
78  ret = ffurl_read_complete(rt->rtsp_hd, rbuf + idx, 1);
79  if (ret <= 0)
80  return ret ? ret : AVERROR_EOF;
81  if (rbuf[idx] == '\r') {
82  /* Ignore */
83  } else if (rbuf[idx] == '\n') {
84  rbuf[idx] = '\0';
85  *rbuflen = idx;
86  return 0;
87  } else
88  idx++;
89  } while (idx < rbufsize);
90  av_log(s, AV_LOG_ERROR, "Message too long\n");
91  return AVERROR(EIO);
92 }
93 
95  const char *extracontent, uint16_t seq)
96 {
97  RTSPState *rt = s->priv_data;
98  char message[4096];
99  int index = 0;
100  while (status_messages[index].code) {
101  if (status_messages[index].code == code) {
102  snprintf(message, sizeof(message), "RTSP/1.0 %d %s\r\n",
103  code, status_messages[index].message);
104  break;
105  }
106  index++;
107  }
108  if (!status_messages[index].code)
109  return AVERROR(EINVAL);
110  av_strlcatf(message, sizeof(message), "CSeq: %d\r\n", seq);
111  av_strlcatf(message, sizeof(message), "Server: %s\r\n", LIBAVFORMAT_IDENT);
112  if (extracontent)
113  av_strlcat(message, extracontent, sizeof(message));
114  av_strlcat(message, "\r\n", sizeof(message));
115  av_dlog(s, "Sending response:\n%s", message);
116  ffurl_write(rt->rtsp_hd, message, strlen(message));
117 
118  return 0;
119 }
120 
121 static inline int check_sessionid(AVFormatContext *s,
122  RTSPMessageHeader *request)
123 {
124  RTSPState *rt = s->priv_data;
125  unsigned char *session_id = rt->session_id;
126  if (!session_id[0]) {
127  av_log(s, AV_LOG_WARNING, "There is no session-id at the moment\n");
128  return 0;
129  }
130  if (strcmp(session_id, request->session_id)) {
131  av_log(s, AV_LOG_ERROR, "Unexpected session-id %s\n",
132  request->session_id);
135  }
136  return 0;
137 }
138 
140  RTSPMessageHeader *request,
141  const char *method)
142 {
143  RTSPState *rt = s->priv_data;
144  char rbuf[1024];
145  int rbuflen, ret;
146  do {
147  ret = read_line(s, rbuf, sizeof(rbuf), &rbuflen);
148  if (ret)
149  return ret;
150  if (rbuflen > 1) {
151  av_dlog(s, "Parsing[%d]: %s\n", rbuflen, rbuf);
152  ff_rtsp_parse_line(request, rbuf, rt, method);
153  }
154  } while (rbuflen > 0);
155  if (request->seq != rt->seq + 1) {
156  av_log(s, AV_LOG_ERROR, "Unexpected Sequence number %d\n",
157  request->seq);
158  return AVERROR(EINVAL);
159  }
160  if (rt->session_id[0] && strcmp(method, "OPTIONS")) {
161  ret = check_sessionid(s, request);
162  if (ret)
163  return ret;
164  }
165 
166  return 0;
167 }
168 
170 {
171  RTSPState *rt = s->priv_data;
172  RTSPMessageHeader request = { 0 };
173  char sdp[4096];
174  int ret;
175 
176  ret = rtsp_read_request(s, &request, "ANNOUNCE");
177  if (ret)
178  return ret;
179  rt->seq++;
180  if (strcmp(request.content_type, "application/sdp")) {
181  av_log(s, AV_LOG_ERROR, "Unexpected content type %s\n",
182  request.content_type);
185  }
186  if (request.content_length && request.content_length < sizeof(sdp) - 1) {
187  /* Read SDP */
188  if (ffurl_read_complete(rt->rtsp_hd, sdp, request.content_length)
189  < request.content_length) {
190  av_log(s, AV_LOG_ERROR,
191  "Unable to get complete SDP Description in ANNOUNCE\n");
193  return AVERROR(EIO);
194  }
195  sdp[request.content_length] = '\0';
196  av_log(s, AV_LOG_VERBOSE, "SDP: %s\n", sdp);
197  ret = ff_sdp_parse(s, sdp);
198  if (ret)
199  return ret;
200  rtsp_send_reply(s, RTSP_STATUS_OK, NULL, request.seq);
201  return 0;
202  }
203  av_log(s, AV_LOG_ERROR,
204  "Content-Length header value exceeds sdp allocated buffer (4KB)\n");
206  "Content-Length exceeds buffer size", request.seq);
207  return AVERROR(EIO);
208 }
209 
211 {
212  RTSPState *rt = s->priv_data;
213  RTSPMessageHeader request = { 0 };
214  int ret = 0;
215 
216  /* Parsing headers */
217  ret = rtsp_read_request(s, &request, "OPTIONS");
218  if (ret)
219  return ret;
220  rt->seq++;
221  /* Send Reply */
223  "Public: ANNOUNCE, PAUSE, SETUP, TEARDOWN, RECORD\r\n",
224  request.seq);
225  return 0;
226 }
227 
228 static int rtsp_read_setup(AVFormatContext *s, char* host, char *controlurl)
229 {
230  RTSPState *rt = s->priv_data;
231  RTSPMessageHeader request = { 0 };
232  int ret = 0;
233  char url[1024];
234  RTSPStream *rtsp_st;
235  char responseheaders[1024];
236  int localport = -1;
237  int transportidx = 0;
238  int streamid = 0;
239 
240  ret = rtsp_read_request(s, &request, "SETUP");
241  if (ret)
242  return ret;
243  rt->seq++;
244  if (!request.nb_transports) {
245  av_log(s, AV_LOG_ERROR, "No transport defined in SETUP\n");
246  return AVERROR_INVALIDDATA;
247  }
248  for (transportidx = 0; transportidx < request.nb_transports;
249  transportidx++) {
250  if (!request.transports[transportidx].mode_record ||
251  (request.transports[transportidx].lower_transport !=
253  request.transports[transportidx].lower_transport !=
255  av_log(s, AV_LOG_ERROR, "mode=record/receive not set or transport"
256  " protocol not supported (yet)\n");
257  return AVERROR_INVALIDDATA;
258  }
259  }
260  if (request.nb_transports > 1)
261  av_log(s, AV_LOG_WARNING, "More than one transport not supported, "
262  "using first of all\n");
263  for (streamid = 0; streamid < rt->nb_rtsp_streams; streamid++) {
264  if (!strcmp(rt->rtsp_streams[streamid]->control_url,
265  controlurl))
266  break;
267  }
268  if (streamid == rt->nb_rtsp_streams) {
269  av_log(s, AV_LOG_ERROR, "Unable to find requested track\n");
271  }
272  rtsp_st = rt->rtsp_streams[streamid];
273  localport = rt->rtp_port_min;
274 
277  if ((ret = ff_rtsp_open_transport_ctx(s, rtsp_st))) {
279  return ret;
280  }
281  rtsp_st->interleaved_min = request.transports[0].interleaved_min;
282  rtsp_st->interleaved_max = request.transports[0].interleaved_max;
283  snprintf(responseheaders, sizeof(responseheaders), "Transport: "
284  "RTP/AVP/TCP;unicast;mode=receive;interleaved=%d-%d"
285  "\r\n", request.transports[0].interleaved_min,
286  request.transports[0].interleaved_max);
287  } else {
288  do {
289  ff_url_join(url, sizeof(url), "rtp", NULL, host, localport, NULL);
290  av_dlog(s, "Opening: %s", url);
291  ret = ffurl_open(&rtsp_st->rtp_handle, url, AVIO_FLAG_READ_WRITE,
292  &s->interrupt_callback, NULL);
293  if (ret)
294  localport += 2;
295  } while (ret || localport > rt->rtp_port_max);
296  if (localport > rt->rtp_port_max) {
298  return ret;
299  }
300 
301  av_dlog(s, "Listening on: %d",
303  if ((ret = ff_rtsp_open_transport_ctx(s, rtsp_st))) {
305  return ret;
306  }
307 
308  localport = ff_rtp_get_local_rtp_port(rtsp_st->rtp_handle);
309  snprintf(responseheaders, sizeof(responseheaders), "Transport: "
310  "RTP/AVP/UDP;unicast;mode=receive;source=%s;"
311  "client_port=%d-%d;server_port=%d-%d\r\n",
312  host, request.transports[0].client_port_min,
313  request.transports[0].client_port_max, localport,
314  localport + 1);
315  }
316 
317  /* Establish sessionid if not previously set */
318  /* Put this in a function? */
319  /* RFC 2326: session id must be at least 8 digits */
320  while (strlen(rt->session_id) < 8)
321  av_strlcatf(rt->session_id, 512, "%u", av_get_random_seed());
322 
323  av_strlcatf(responseheaders, sizeof(responseheaders), "Session: %s\r\n",
324  rt->session_id);
325  /* Send Reply */
326  rtsp_send_reply(s, RTSP_STATUS_OK, responseheaders, request.seq);
327 
328  rt->state = RTSP_STATE_PAUSED;
329  return 0;
330 }
331 
333 {
334  RTSPState *rt = s->priv_data;
335  RTSPMessageHeader request = { 0 };
336  int ret = 0;
337  char responseheaders[1024];
338 
339  ret = rtsp_read_request(s, &request, "RECORD");
340  if (ret)
341  return ret;
342  ret = check_sessionid(s, &request);
343  if (ret)
344  return ret;
345  rt->seq++;
346  snprintf(responseheaders, sizeof(responseheaders), "Session: %s\r\n",
347  rt->session_id);
348  rtsp_send_reply(s, RTSP_STATUS_OK, responseheaders, request.seq);
349 
351  return 0;
352 }
353 
354 static inline int parse_command_line(AVFormatContext *s, const char *line,
355  int linelen, char *uri, int urisize,
356  char *method, int methodsize,
357  enum RTSPMethod *methodcode)
358 {
359  RTSPState *rt = s->priv_data;
360  const char *linept, *searchlinept;
361  linept = strchr(line, ' ');
362  if (linept - line > methodsize - 1) {
363  av_log(s, AV_LOG_ERROR, "Method string too long\n");
364  return AVERROR(EIO);
365  }
366  memcpy(method, line, linept - line);
367  method[linept - line] = '\0';
368  linept++;
369  if (!strcmp(method, "ANNOUNCE"))
370  *methodcode = ANNOUNCE;
371  else if (!strcmp(method, "OPTIONS"))
372  *methodcode = OPTIONS;
373  else if (!strcmp(method, "RECORD"))
374  *methodcode = RECORD;
375  else if (!strcmp(method, "SETUP"))
376  *methodcode = SETUP;
377  else if (!strcmp(method, "PAUSE"))
378  *methodcode = PAUSE;
379  else if (!strcmp(method, "TEARDOWN"))
380  *methodcode = TEARDOWN;
381  else
382  *methodcode = UNKNOWN;
383  /* Check method with the state */
384  if (rt->state == RTSP_STATE_IDLE) {
385  if ((*methodcode != ANNOUNCE) && (*methodcode != OPTIONS)) {
386  av_log(s, AV_LOG_ERROR, "Unexpected command in Idle State %s\n",
387  line);
389  }
390  } else if (rt->state == RTSP_STATE_PAUSED) {
391  if ((*methodcode != OPTIONS) && (*methodcode != RECORD)
392  && (*methodcode != SETUP)) {
393  av_log(s, AV_LOG_ERROR, "Unexpected command in Paused State %s\n",
394  line);
396  }
397  } else if (rt->state == RTSP_STATE_STREAMING) {
398  if ((*methodcode != PAUSE) && (*methodcode != OPTIONS)
399  && (*methodcode != TEARDOWN)) {
400  av_log(s, AV_LOG_ERROR, "Unexpected command in Streaming State"
401  " %s\n", line);
403  }
404  } else {
405  av_log(s, AV_LOG_ERROR, "Unexpected State [%d]\n", rt->state);
406  return AVERROR_BUG;
407  }
408 
409  searchlinept = strchr(linept, ' ');
410  if (searchlinept == NULL) {
411  av_log(s, AV_LOG_ERROR, "Error parsing message URI\n");
412  return AVERROR_INVALIDDATA;
413  }
414  if (searchlinept - linept > urisize - 1) {
415  av_log(s, AV_LOG_ERROR, "uri string length exceeded buffer size\n");
416  return AVERROR(EIO);
417  }
418  memcpy(uri, linept, searchlinept - linept);
419  uri[searchlinept - linept] = '\0';
420  if (strcmp(rt->control_uri, uri)) {
421  char host[128], path[512], auth[128];
422  int port;
423  char ctl_host[128], ctl_path[512], ctl_auth[128];
424  int ctl_port;
425  av_url_split(NULL, 0, auth, sizeof(auth), host, sizeof(host), &port,
426  path, sizeof(path), uri);
427  av_url_split(NULL, 0, ctl_auth, sizeof(ctl_auth), ctl_host,
428  sizeof(ctl_host), &ctl_port, ctl_path, sizeof(ctl_path),
429  rt->control_uri);
430  if (strcmp(host, ctl_host))
431  av_log(s, AV_LOG_INFO, "Host %s differs from expected %s\n",
432  host, ctl_host);
433  if (strcmp(path, ctl_path) && *methodcode != SETUP)
434  av_log(s, AV_LOG_WARNING, "WARNING: Path %s differs from expected"
435  " %s\n", path, ctl_path);
436  if (*methodcode == ANNOUNCE) {
437  av_log(s, AV_LOG_INFO,
438  "Updating control URI to %s\n", uri);
439  av_strlcpy(rt->control_uri, uri, sizeof(rt->control_uri));
440  }
441  }
442 
443  linept = searchlinept + 1;
444  if (!av_strstart(linept, "RTSP/1.0", NULL)) {
445  av_log(s, AV_LOG_ERROR, "Error parsing protocol or version\n");
447  }
448  return 0;
449 }
450 
452 {
453  RTSPState *rt = s->priv_data;
454  unsigned char rbuf[4096];
455  unsigned char method[10];
456  char uri[500];
457  int ret;
458  int rbuflen = 0;
459  RTSPMessageHeader request = { 0 };
460  enum RTSPMethod methodcode;
461 
462  ret = read_line(s, rbuf, sizeof(rbuf), &rbuflen);
463  if (ret < 0)
464  return ret;
465  ret = parse_command_line(s, rbuf, rbuflen, uri, sizeof(uri), method,
466  sizeof(method), &methodcode);
467  if (ret) {
468  av_log(s, AV_LOG_ERROR, "RTSP: Unexpected Command\n");
469  return ret;
470  }
471 
472  ret = rtsp_read_request(s, &request, method);
473  if (ret)
474  return ret;
475  rt->seq++;
476  if (methodcode == PAUSE) {
477  rt->state = RTSP_STATE_PAUSED;
478  ret = rtsp_send_reply(s, RTSP_STATUS_OK, NULL , request.seq);
479  // TODO: Missing date header in response
480  } else if (methodcode == OPTIONS) {
482  "Public: ANNOUNCE, PAUSE, SETUP, TEARDOWN, "
483  "RECORD\r\n", request.seq);
484  } else if (methodcode == TEARDOWN) {
485  rt->state = RTSP_STATE_IDLE;
486  ret = rtsp_send_reply(s, RTSP_STATUS_OK, NULL , request.seq);
487  return 0;
488  }
489  return ret;
490 }
491 
493 {
494  RTSPState *rt = s->priv_data;
495  RTSPMessageHeader reply1, *reply = &reply1;
496  int i;
497  char cmd[1024];
498 
499  av_log(s, AV_LOG_DEBUG, "hello state=%d\n", rt->state);
500  rt->nb_byes = 0;
501 
502  if (!(rt->server_type == RTSP_SERVER_REAL && rt->need_subscription)) {
503  if (rt->transport == RTSP_TRANSPORT_RTP) {
504  for (i = 0; i < rt->nb_rtsp_streams; i++) {
505  RTSPStream *rtsp_st = rt->rtsp_streams[i];
506  RTPDemuxContext *rtpctx = rtsp_st->transport_priv;
507  if (!rtpctx)
508  continue;
512  rtpctx->base_timestamp = 0;
513  rtpctx->timestamp = 0;
514  rtpctx->unwrapped_timestamp = 0;
515  rtpctx->rtcp_ts_offset = 0;
516  }
517  }
518  if (rt->state == RTSP_STATE_PAUSED) {
519  cmd[0] = 0;
520  } else {
521  snprintf(cmd, sizeof(cmd),
522  "Range: npt=%"PRId64".%03"PRId64"-\r\n",
524  rt->seek_timestamp / (AV_TIME_BASE / 1000) % 1000);
525  }
526  ff_rtsp_send_cmd(s, "PLAY", rt->control_uri, cmd, reply, NULL);
527  if (reply->status_code != RTSP_STATUS_OK) {
528  return -1;
529  }
530  if (rt->transport == RTSP_TRANSPORT_RTP &&
531  reply->range_start != AV_NOPTS_VALUE) {
532  for (i = 0; i < rt->nb_rtsp_streams; i++) {
533  RTSPStream *rtsp_st = rt->rtsp_streams[i];
534  RTPDemuxContext *rtpctx = rtsp_st->transport_priv;
535  AVStream *st = NULL;
536  if (!rtpctx || rtsp_st->stream_index < 0)
537  continue;
538  st = s->streams[rtsp_st->stream_index];
539  rtpctx->range_start_offset =
541  st->time_base);
542  }
543  }
544  }
546  return 0;
547 }
548 
549 /* pause the stream */
551 {
552  RTSPState *rt = s->priv_data;
553  RTSPMessageHeader reply1, *reply = &reply1;
554 
555  if (rt->state != RTSP_STATE_STREAMING)
556  return 0;
557  else if (!(rt->server_type == RTSP_SERVER_REAL && rt->need_subscription)) {
558  ff_rtsp_send_cmd(s, "PAUSE", rt->control_uri, NULL, reply, NULL);
559  if (reply->status_code != RTSP_STATUS_OK) {
560  return -1;
561  }
562  }
563  rt->state = RTSP_STATE_PAUSED;
564  return 0;
565 }
566 
568 {
569  RTSPState *rt = s->priv_data;
570  char cmd[1024];
571  unsigned char *content = NULL;
572  int ret;
573 
574  /* describe the stream */
575  snprintf(cmd, sizeof(cmd),
576  "Accept: application/sdp\r\n");
577  if (rt->server_type == RTSP_SERVER_REAL) {
578  /**
579  * The Require: attribute is needed for proper streaming from
580  * Realmedia servers.
581  */
582  av_strlcat(cmd,
583  "Require: com.real.retain-entity-for-setup\r\n",
584  sizeof(cmd));
585  }
586  ff_rtsp_send_cmd(s, "DESCRIBE", rt->control_uri, cmd, reply, &content);
587  if (!content)
588  return AVERROR_INVALIDDATA;
589  if (reply->status_code != RTSP_STATUS_OK) {
590  av_freep(&content);
591  return AVERROR_INVALIDDATA;
592  }
593 
594  av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", content);
595  /* now we got the SDP description, we parse it */
596  ret = ff_sdp_parse(s, (const char *)content);
597  av_freep(&content);
598  if (ret < 0)
599  return ret;
600 
601  return 0;
602 }
603 
605 {
606  RTSPState *rt = s->priv_data;
607  char host[128], path[512], auth[128];
608  char uri[500];
609  int port;
610  char tcpname[500];
611  unsigned char rbuf[4096];
612  unsigned char method[10];
613  int rbuflen = 0;
614  int ret;
615  enum RTSPMethod methodcode;
616 
617  /* extract hostname and port */
618  av_url_split(NULL, 0, auth, sizeof(auth), host, sizeof(host), &port,
619  path, sizeof(path), s->filename);
620 
621  /* ff_url_join. No authorization by now (NULL) */
622  ff_url_join(rt->control_uri, sizeof(rt->control_uri), "rtsp", NULL, host,
623  port, "%s", path);
624 
625  if (port < 0)
626  port = RTSP_DEFAULT_PORT;
627 
628  /* Create TCP connection */
629  ff_url_join(tcpname, sizeof(tcpname), "tcp", NULL, host, port,
630  "?listen&listen_timeout=%d", rt->initial_timeout * 1000);
631 
632  if (ret = ffurl_open(&rt->rtsp_hd, tcpname, AVIO_FLAG_READ_WRITE,
633  &s->interrupt_callback, NULL)) {
634  av_log(s, AV_LOG_ERROR, "Unable to open RTSP for listening\n");
635  return ret;
636  }
637  rt->state = RTSP_STATE_IDLE;
638  rt->rtsp_hd_out = rt->rtsp_hd;
639  for (;;) { /* Wait for incoming RTSP messages */
640  ret = read_line(s, rbuf, sizeof(rbuf), &rbuflen);
641  if (ret < 0)
642  return ret;
643  ret = parse_command_line(s, rbuf, rbuflen, uri, sizeof(uri), method,
644  sizeof(method), &methodcode);
645  if (ret) {
646  av_log(s, AV_LOG_ERROR, "RTSP: Unexpected Command\n");
647  return ret;
648  }
649 
650  if (methodcode == ANNOUNCE) {
651  ret = rtsp_read_announce(s);
652  rt->state = RTSP_STATE_PAUSED;
653  } else if (methodcode == OPTIONS) {
654  ret = rtsp_read_options(s);
655  } else if (methodcode == RECORD) {
656  ret = rtsp_read_record(s);
657  if (!ret)
658  return 0; // We are ready for streaming
659  } else if (methodcode == SETUP)
660  ret = rtsp_read_setup(s, host, uri);
661  if (ret) {
662  ffurl_close(rt->rtsp_hd);
663  return AVERROR_INVALIDDATA;
664  }
665  }
666  return 0;
667 }
668 
669 static int rtsp_probe(AVProbeData *p)
670 {
671  if (av_strstart(p->filename, "rtsp:", NULL))
672  return AVPROBE_SCORE_MAX;
673  return 0;
674 }
675 
677 {
678  RTSPState *rt = s->priv_data;
679  int ret;
680 
681  if (rt->initial_timeout > 0)
683 
684  if (rt->rtsp_flags & RTSP_FLAG_LISTEN) {
685  ret = rtsp_listen(s);
686  if (ret)
687  return ret;
688  } else {
689  ret = ff_rtsp_connect(s);
690  if (ret)
691  return ret;
692 
693  rt->real_setup_cache = !s->nb_streams ? NULL :
694  av_mallocz(2 * s->nb_streams * sizeof(*rt->real_setup_cache));
695  if (!rt->real_setup_cache && s->nb_streams)
696  return AVERROR(ENOMEM);
697  rt->real_setup = rt->real_setup_cache + s->nb_streams;
698 
699  if (rt->initial_pause) {
700  /* do not start immediately */
701  } else {
702  if (rtsp_read_play(s) < 0) {
705  return AVERROR_INVALIDDATA;
706  }
707  }
708  }
709 
710  return 0;
711 }
712 
714  uint8_t *buf, int buf_size)
715 {
716  RTSPState *rt = s->priv_data;
717  int id, len, i, ret;
718  RTSPStream *rtsp_st;
719 
720  av_dlog(s, "tcp_read_packet:\n");
721 redo:
722  for (;;) {
723  RTSPMessageHeader reply;
724 
725  ret = ff_rtsp_read_reply(s, &reply, NULL, 1, NULL);
726  if (ret < 0)
727  return ret;
728  if (ret == 1) /* received '$' */
729  break;
730  /* XXX: parse message */
731  if (rt->state != RTSP_STATE_STREAMING)
732  return 0;
733  }
734  ret = ffurl_read_complete(rt->rtsp_hd, buf, 3);
735  if (ret != 3)
736  return -1;
737  id = buf[0];
738  len = AV_RB16(buf + 1);
739  av_dlog(s, "id=%d len=%d\n", id, len);
740  if (len > buf_size || len < 8)
741  goto redo;
742  /* get the data */
743  ret = ffurl_read_complete(rt->rtsp_hd, buf, len);
744  if (ret != len)
745  return -1;
746  if (rt->transport == RTSP_TRANSPORT_RDT &&
747  ff_rdt_parse_header(buf, len, &id, NULL, NULL, NULL, NULL) < 0)
748  return -1;
749 
750  /* find the matching stream */
751  for (i = 0; i < rt->nb_rtsp_streams; i++) {
752  rtsp_st = rt->rtsp_streams[i];
753  if (id >= rtsp_st->interleaved_min &&
754  id <= rtsp_st->interleaved_max)
755  goto found;
756  }
757  goto redo;
758 found:
759  *prtsp_st = rtsp_st;
760  return len;
761 }
762 
764 {
765  RTSPState *rt = s->priv_data;
766  char host[1024];
767  int port;
768 
769  av_url_split(NULL, 0, NULL, 0, host, sizeof(host), &port, NULL, 0,
770  s->filename);
773  rt->real_challenge);
774 }
775 
777 {
778  RTSPState *rt = s->priv_data;
779  int ret;
780  RTSPMessageHeader reply1, *reply = &reply1;
781  char cmd[1024];
782 
783 retry:
784  if (rt->server_type == RTSP_SERVER_REAL) {
785  int i;
786 
787  for (i = 0; i < s->nb_streams; i++)
788  rt->real_setup[i] = s->streams[i]->discard;
789 
790  if (!rt->need_subscription) {
791  if (memcmp (rt->real_setup, rt->real_setup_cache,
792  sizeof(enum AVDiscard) * s->nb_streams)) {
793  snprintf(cmd, sizeof(cmd),
794  "Unsubscribe: %s\r\n",
795  rt->last_subscription);
796  ff_rtsp_send_cmd(s, "SET_PARAMETER", rt->control_uri,
797  cmd, reply, NULL);
798  if (reply->status_code != RTSP_STATUS_OK)
799  return AVERROR_INVALIDDATA;
800  rt->need_subscription = 1;
801  }
802  }
803 
804  if (rt->need_subscription) {
805  int r, rule_nr, first = 1;
806 
807  memcpy(rt->real_setup_cache, rt->real_setup,
808  sizeof(enum AVDiscard) * s->nb_streams);
809  rt->last_subscription[0] = 0;
810 
811  snprintf(cmd, sizeof(cmd),
812  "Subscribe: ");
813  for (i = 0; i < rt->nb_rtsp_streams; i++) {
814  rule_nr = 0;
815  for (r = 0; r < s->nb_streams; r++) {
816  if (s->streams[r]->id == i) {
817  if (s->streams[r]->discard != AVDISCARD_ALL) {
818  if (!first)
819  av_strlcat(rt->last_subscription, ",",
820  sizeof(rt->last_subscription));
822  rt->last_subscription,
823  sizeof(rt->last_subscription), i, rule_nr);
824  first = 0;
825  }
826  rule_nr++;
827  }
828  }
829  }
830  av_strlcatf(cmd, sizeof(cmd), "%s\r\n", rt->last_subscription);
831  ff_rtsp_send_cmd(s, "SET_PARAMETER", rt->control_uri,
832  cmd, reply, NULL);
833  if (reply->status_code != RTSP_STATUS_OK)
834  return AVERROR_INVALIDDATA;
835  rt->need_subscription = 0;
836 
837  if (rt->state == RTSP_STATE_STREAMING)
838  rtsp_read_play (s);
839  }
840  }
841 
842  ret = ff_rtsp_fetch_packet(s, pkt);
843  if (ret < 0) {
844  if (ret == AVERROR(ETIMEDOUT) && !rt->packets) {
847  RTSPMessageHeader reply1, *reply = &reply1;
848  av_log(s, AV_LOG_WARNING, "UDP timeout, retrying with TCP\n");
849  if (rtsp_read_pause(s) != 0)
850  return -1;
851  // TEARDOWN is required on Real-RTSP, but might make
852  // other servers close the connection.
853  if (rt->server_type == RTSP_SERVER_REAL)
854  ff_rtsp_send_cmd(s, "TEARDOWN", rt->control_uri, NULL,
855  reply, NULL);
856  rt->session_id[0] = '\0';
857  if (resetup_tcp(s) == 0) {
858  rt->state = RTSP_STATE_IDLE;
859  rt->need_subscription = 1;
860  if (rtsp_read_play(s) != 0)
861  return -1;
862  goto retry;
863  }
864  }
865  }
866  return ret;
867  }
868  rt->packets++;
869 
870  if (!(rt->rtsp_flags & RTSP_FLAG_LISTEN)) {
871  /* send dummy request to keep TCP connection alive */
872  if ((av_gettime() - rt->last_cmd_time) / 1000000 >= rt->timeout / 2 ||
873  rt->auth_state.stale) {
874  if (rt->server_type == RTSP_SERVER_WMS ||
875  (rt->server_type != RTSP_SERVER_REAL &&
877  ff_rtsp_send_cmd_async(s, "GET_PARAMETER", rt->control_uri, NULL);
878  } else {
879  ff_rtsp_send_cmd_async(s, "OPTIONS", "*", NULL);
880  }
881  /* The stale flag should be reset when creating the auth response in
882  * ff_rtsp_send_cmd_async, but reset it here just in case we never
883  * called the auth code (if we didn't have any credentials set). */
884  rt->auth_state.stale = 0;
885  }
886  }
887 
888  return 0;
889 }
890 
891 static int rtsp_read_seek(AVFormatContext *s, int stream_index,
892  int64_t timestamp, int flags)
893 {
894  RTSPState *rt = s->priv_data;
895 
896  rt->seek_timestamp = av_rescale_q(timestamp,
897  s->streams[stream_index]->time_base,
899  switch(rt->state) {
900  default:
901  case RTSP_STATE_IDLE:
902  break;
904  if (rtsp_read_pause(s) != 0)
905  return -1;
907  if (rtsp_read_play(s) != 0)
908  return -1;
909  break;
910  case RTSP_STATE_PAUSED:
911  rt->state = RTSP_STATE_IDLE;
912  break;
913  }
914  return 0;
915 }
916 
917 static const AVClass rtsp_demuxer_class = {
918  .class_name = "RTSP demuxer",
919  .item_name = av_default_item_name,
920  .option = ff_rtsp_options,
921  .version = LIBAVUTIL_VERSION_INT,
922 };
923 
925  .name = "rtsp",
926  .long_name = NULL_IF_CONFIG_SMALL("RTSP input"),
927  .priv_data_size = sizeof(RTSPState),
933  .flags = AVFMT_NOFILE,
934  .read_play = rtsp_read_play,
935  .read_pause = rtsp_read_pause,
936  .priv_class = &rtsp_demuxer_class,
937 };
int interleaved_min
interleave ids, if TCP transport; each TCP/RTSP data packet starts with a &#39;$&#39;, stream length and stre...
Definition: rtsp.h:92
void av_url_split(char *proto, int proto_size, char *authorization, int authorization_size, char *hostname, int hostname_size, int *port_ptr, char *path, int path_size, const char *url)
Split a URL string into components.
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
Definition: mem.c:205
int rtp_port_min
Minimum and maximum local UDP ports.
Definition: rtsp.h:386
const char * s
Definition: avisynth_c.h:668
Realmedia Data Transport.
Definition: rtsp.h:58
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:59
static int rtsp_read_options(AVFormatContext *s)
Definition: rtspdec.c:210
void ff_rtsp_undo_setup(AVFormatContext *s)
Undo the effect of ff_rtsp_make_setup_request, close the transport_priv and rtp_handle fields...
Definition: rtsp.c:569
AVIOInterruptCB interrupt_callback
Custom interrupt callbacks for the I/O layer.
Definition: avformat.h:1125
static const struct RTSPStatusMessage status_messages[]
enum AVCodecID id
Definition: mxfenc.c:89
av_default_item_name
char content_type[64]
Content type header.
Definition: rtsp.h:186
static int rtsp_read_request(AVFormatContext *s, RTSPMessageHeader *request, const char *method)
Definition: rtspdec.c:139
static int rtsp_read_close(AVFormatContext *s)
Definition: rtspdec.c:54
const char * filename
Definition: avformat.h:335
char control_uri[1024]
some MS RTSP streams contain a URL in the SDP that we need to use for all subsequent RTSP requests...
Definition: rtsp.h:316
static int rtsp_read_header(AVFormatContext *s)
Definition: rtspdec.c:676
int ffurl_write(URLContext *h, const unsigned char *buf, int size)
Write size bytes from buf to the resource accessed by h.
Definition: avio.c:317
#define RTSP_DEFAULT_PORT
Definition: rtsp.h:72
Windows Media server.
Definition: rtsp.h:208
int64_t range_start_offset
Definition: rtpdec.h:161
int ff_rtsp_open_transport_ctx(AVFormatContext *s, RTSPStream *rtsp_st)
Open RTSP transport context.
Definition: rtsp.c:629
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:154
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
Definition: libcdio.c:153
static int rtsp_probe(AVProbeData *p)
Definition: rtspdec.c:669
enum AVDiscard * real_setup
current stream setup.
Definition: rtsp.h:295
static int resetup_tcp(AVFormatContext *s)
Definition: rtspdec.c:763
enum AVDiscard * real_setup_cache
stream setup during the last frame read.
Definition: rtsp.h:291
int mode_record
transport set to record data
Definition: rtsp.h:111
int ff_rtsp_setup_input_streams(AVFormatContext *s, RTSPMessageHeader *reply)
Get the description of the stream and set up the RTSPStream child objects.
Definition: rtspdec.c:567
void ff_network_close(void)
Definition: network.c:173
UDP/unicast.
Definition: rtsp.h:38
int seq
sequence number
Definition: rtsp.h:143
initialized and sending/receiving data
Definition: rtsp.h:196
RTSPMethod
Definition: rtspcodes.h:40
char real_challenge[64]
the "RealChallenge1:" field from the server
Definition: rtsp.h:269
static int rtsp_read_pause(AVFormatContext *s)
Definition: rtspdec.c:550
const char * message
Definition: rtspdec.c:38
av_dlog(ac->avr,"%d samples - audio_convert: %s to %s (%s)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt), use_generic?ac->func_descr_generic:ac->func_descr)
int ff_rtsp_tcp_read_packet(AVFormatContext *s, RTSPStream **prtsp_st, uint8_t *buf, int buf_size)
Receive one RTP packet from an TCP interleaved RTSP stream.
Definition: rtspdec.c:713
void ff_rdt_subscribe_rule(char *cmd, int size, int stream_nr, int rule_nr)
Add subscription information to Subscribe parameter string.
Definition: rdt.c:384
#define RTSP_FLAG_LISTEN
Wait for incoming connections.
Definition: rtsp.h:409
char session_id[512]
copy of RTSPMessageHeader->session_id, i.e.
Definition: rtsp.h:244
int64_t seek_timestamp
the seek value requested when calling av_seek_frame().
Definition: rtsp.h:238
static int rtsp_send_reply(AVFormatContext *s, enum RTSPStatusCode code, const char *extracontent, uint16_t seq)
Definition: rtspdec.c:94
static int check_sessionid(AVFormatContext *s, RTSPMessageHeader *request)
Definition: rtspdec.c:121
int ff_rtsp_make_setup_request(AVFormatContext *s, const char *host, int port, int lower_transport, const char *real_challenge)
Do the SETUP requests for each stream for the chosen lower transport mode.
enum RTSPLowerTransport lower_transport
network layer transport protocol; e.g.
Definition: rtsp.h:120
int ff_url_join(char *str, int size, const char *proto, const char *authorization, const char *hostname, int port, const char *fmt,...) av_printf_format(7
Assemble a URL string from components.
This describes the server response to each RTSP command.
Definition: rtsp.h:126
enum RTSPStatusCode code
Definition: rtspdec.c:37
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
Definition: mem.c:198
RTSPTransportField transports[RTSP_MAX_TRANSPORTS]
describes the complete "Transport:" line of the server in response to a SETUP RTSP command by the cli...
Definition: rtsp.h:141
initialize output if(nPeaks >3)%at least 3 peaks in spectrum for trying to find f0 nf0peaks
Format I/O context.
Definition: avformat.h:944
int ff_rtsp_connect(AVFormatContext *s)
Connect to the RTSP server and set up the individual media streams.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:55
static int rtsp_read_packet(AVFormatContext *s, AVPacket *pkt)
Definition: rtspdec.c:776
int get_parameter_supported
Whether the server supports the GET_PARAMETER method.
Definition: rtsp.h:358
Standards-compliant RTP.
Definition: rtsp.h:57
uint8_t
char session_id[512]
the "Session:" field.
Definition: rtsp.h:147
miscellaneous OS support macros and functions.
static AVPacket pkt
Definition: demuxing.c:56
void ff_rtp_reset_packet_queue(RTPDemuxContext *s)
Definition: rtpdec.c:656
int id
Format-specific stream ID.
Definition: avformat.h:650
trying all byte sequences megabyte in length and selecting the best looking sequence will yield cases to try But first
void ff_rtsp_parse_line(RTSPMessageHeader *reply, const char *buf, RTSPState *rt, const char *method)
int initial_timeout
Timeout to wait for incoming connections.
Definition: rtsp.h:391
static int read_line(AVFormatContext *s, char *rbuf, const int rbufsize, int *rbuflen)
Definition: rtspdec.c:69
AVStream ** streams
Definition: avformat.h:992
URLContext * rtsp_hd_out
Additional output handle, used when input and output are done separately, eg for HTTP tunneling...
Definition: rtsp.h:327
Aggregate operation not allowed.
Definition: rtspcodes.h:32
static int rtsp_read_setup(AVFormatContext *s, char *host, char *controlurl)
Definition: rtspdec.c:228
#define AVERROR_PROTOCOL_NOT_FOUND
Protocol not found.
Definition: error.h:63
Service Unavailable.
Definition: rtspcodes.h:36
Describe a single stream, as identified by a single m= line block in the SDP content.
Definition: rtsp.h:418
enum RTSPStatusCode status_code
response code from server
Definition: rtsp.h:130
#define AVERROR_EOF
End of file.
Definition: error.h:55
static av_cold int read_close(AVFormatContext *ctx)
Definition: libcdio.c:145
int ff_rtsp_send_cmd(AVFormatContext *s, const char *method, const char *url, const char *headers, RTSPMessageHeader *reply, unsigned char **content_ptr)
Send a command to the RTSP server and wait for the reply.
static int rtsp_read_play(AVFormatContext *s)
Definition: rtspdec.c:492
int nb_transports
number of items in the &#39;transports&#39; variable below
Definition: rtsp.h:133
Only aggregate operation allowed.
Definition: rtspcodes.h:33
int ff_rtp_get_local_rtp_port(URLContext *h)
Return the local rtp port used by the RTP connection.
Definition: rtpproto.c:292
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
Definition: mathematics.c:130
int ff_sdp_parse(AVFormatContext *s, const char *content)
Parse an SDP description of streams by populating an RTSPState struct within the AVFormatContext; als...
int ff_rtsp_parse_streaming_commands(AVFormatContext *s)
Parse RTSP commands (OPTIONS, PAUSE and TEARDOWN) during streaming in listen mode.
Definition: rtspdec.c:451
Private data for the RTSP demuxer.
Definition: rtsp.h:217
int64_t last_cmd_time
timestamp of the last RTSP command that we sent to the RTSP server.
Definition: rtsp.h:254
int timeout
copy of RTSPMessageHeader->timeout, i.e.
Definition: rtsp.h:249
#define AV_RB16
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
const char * r
Definition: vf_curves.c:94
const AVOption ff_rtsp_options[]
Definition: rtsp.c:81
Definition: graph2dot.c:48
URLContext * rtsp_hd
Definition: rtsp.h:219
void av_log(void *avcl, int level, const char *fmt,...)
Definition: log.c:246
int64_t rtcp_ts_offset
Definition: rtpdec.h:184
size_t av_strlcpy(char *dst, const char *src, size_t size)
Copy the string src to dst, but no more than size - 1 bytes, and null-terminate dst.
Definition: avstring.c:82
static int parse_command_line(AVFormatContext *s, const char *line, int linelen, char *uri, int urisize, char *method, int methodsize, enum RTSPMethod *methodcode)
Definition: rtspdec.c:354
struct RTSPStream ** rtsp_streams
streams in this session
Definition: rtsp.h:224
static int rtsp_read_record(AVFormatContext *s)
Definition: rtspdec.c:332
uint32_t timestamp
Definition: rtpdec.h:157
int stream_index
corresponding stream index, if any.
Definition: rtsp.h:423
int seq
RTSP command sequence number.
Definition: rtsp.h:240
unsigned int nb_streams
A list of all streams in the file.
Definition: avformat.h:991
#define AV_LOG_VERBOSE
Definition: log.h:157
#define LIBAVFORMAT_IDENT
char filename[1024]
input or output filename
Definition: avformat.h:994
int nb_rtsp_streams
number of items in the &#39;rtsp_streams&#39; variable
Definition: rtsp.h:222
int64_t first_rtcp_ntp_time
Definition: rtpdec.h:182
#define AV_TIME_BASE
Internal time base represented as integer.
Definition: avutil.h:196
static int read_probe(AVProbeData *pd)
int content_length
length of the data following this header
Definition: rtsp.h:128
ret
Definition: avfilter.c:821
char last_subscription[1024]
the last value of the "SET_PARAMETER Subscribe:" RTSP command.
Definition: rtsp.h:300
int64_t last_rtcp_ntp_time
Definition: rtpdec.h:180
Method Not Allowed.
Definition: rtspcodes.h:28
LIBAVUTIL_VERSION_INT
Definition: eval.c:55
int stale
Auth ok, but needs to be resent with a new nonce.
Definition: httpauth.h:71
int ff_rdt_parse_header(const uint8_t *buf, int len, int *pset_id, int *pseq_no, int *pstream_id, int *pis_keyframe, uint32_t *ptimestamp)
Actual data handling.
Definition: rdt.c:190
static int read_header(FFV1Context *f)
Definition: ffv1dec.c:517
int64_t av_gettime(void)
Get the current time in microseconds.
Definition: time.c:39
Stream structure.
Definition: avformat.h:643
int nb_byes
Definition: rtsp.h:335
enum RTSPLowerTransport lower_transport
the negotiated network layer transport protocol; e.g.
Definition: rtsp.h:261
NULL
Definition: eval.c:55
int rtp_port_max
Definition: rtsp.h:386
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
Definition: avutil.h:202
int64_t unwrapped_timestamp
Definition: rtpdec.h:160
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:148
enum RTSPTransport transport
the negotiated data/packet transport protocol; e.g.
Definition: rtsp.h:257
void * buf
Definition: avisynth_c.h:594
static int read_packet(AVFormatContext *ctx, AVPacket *pkt)
Definition: libcdio.c:114
#define AVIO_FLAG_READ_WRITE
read-write pseudo flag
Definition: avio.h:334
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
Definition: error.h:50
int rtsp_flags
Various option flags for the RTSP muxer/demuxer.
Definition: rtsp.h:376
int client_port_max
Definition: rtsp.h:100
Describe the class of an AVClass context structure.
Definition: log.h:50
AVInputFormat ff_rtsp_demuxer
Definition: rtspdec.c:924
int index
Definition: gxfenc.c:89
synthesis window for stochastic i
struct RTSPState RTSPState
Private data for the RTSP demuxer.
static int rtsp_listen(AVFormatContext *s)
Definition: rtspdec.c:604
not initialized
Definition: rtsp.h:195
size_t av_strlcatf(char *dst, size_t size, const char *fmt,...)
Definition: avstring.c:100
void ff_rtsp_close_streams(AVFormatContext *s)
Close and free all streams within the RTSP (de)muxer.
Definition: rtsp.c:603
#define snprintf
Definition: snprintf.h:34
This structure contains the data a format has to probe a file.
Definition: avformat.h:334
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFilterBuffer structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later.That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another.Buffer references ownership and permissions
size_t av_strlcat(char *dst, const char *src, size_t size)
Append the string src to the string dst, but to a total length of no more than size - 1 bytes...
Definition: avstring.c:92
int interleaved_max
Definition: rtsp.h:92
enum RTSPServerType server_type
brand of server that we&#39;re talking to; e.g.
Definition: rtsp.h:266
static int flags
Definition: cpu.c:23
int ffurl_close(URLContext *h)
Definition: avio.c:359
RTSPStatusCode
RTSP handling.
Definition: rtspcodes.h:26
int64_t range_start
Time range of the streams that the server will stream.
Definition: rtsp.h:137
enum RTSPClientState state
indicator of whether we are currently receiving data from the server.
Definition: rtsp.h:230
Not Enough Bandwidth.
Definition: rtspcodes.h:29
int ff_rtsp_fetch_packet(AVFormatContext *s, AVPacket *pkt)
Receive one packet from the RTSPStreams set up in the AVFormatContext (which should contain a RTSPSta...
#define AVPROBE_SCORE_MAX
maximum score, half of that is used for file-extension-based detection
Definition: avformat.h:340
int av_strstart(const char *str, const char *pfx, const char **ptr)
Return non-zero if pfx is a prefix of str.
Definition: avstring.c:33
Main libavformat public API header.
static const AVClass rtsp_demuxer_class
Definition: rtspdec.c:917
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:162
initialized, requesting a seek
Definition: rtsp.h:198
#define AVFMT_NOFILE
Demuxer will use avio_open, no opened file should be provided by the caller.
Definition: avformat.h:345
int ffurl_open(URLContext **puc, const char *filename, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options)
Create an URLContext for accessing to the resource indicated by url, and open it. ...
Definition: avio.c:247
int need_subscription
The following are used for Real stream selection.
Definition: rtsp.h:287
int ffurl_read_complete(URLContext *h, unsigned char *buf, int size)
Read as many bytes as possible (up to size), calling the read function multiple times if necessary...
Definition: avio.c:310
static int rtsp_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
Definition: rtspdec.c:891
uint32_t base_timestamp
Definition: rtpdec.h:158
initialized, but not receiving data
Definition: rtsp.h:197
int ff_rtsp_read_reply(AVFormatContext *s, RTSPMessageHeader *reply, unsigned char **content_ptr, int return_on_interleaved_data, const char *method)
Read a RTSP message from the server, or prepare to read data packets if we&#39;re reading data interleave...
int ff_rtsp_send_cmd_async(AVFormatContext *s, const char *method, const char *url, const char *headers)
Send a command to the RTSP server without waiting for the reply.
#define AVERROR_OPTION_NOT_FOUND
Option not found.
Definition: error.h:61
TCP; interleaved in RTSP.
Definition: rtsp.h:39
HTTPAuthState auth_state
authentication state
Definition: rtsp.h:275
int len
Unsupported transport.
Definition: rtspcodes.h:34
char control_url[1024]
url for this stream (from SDP)
Definition: rtsp.h:429
void * priv_data
Format private data.
Definition: avformat.h:964
About Git write you should know how to use GIT properly Luckily Git comes with excellent documentation git help man git shows you the available git< command > help man git< command > shows information about the subcommand< command > The most comprehensive manual is the website Git Reference visit they are quite exhaustive You do not need a special username or password All you need is to provide a ssh public key to the Git server admin What follows now is a basic introduction to Git and some FFmpeg specific guidelines Read it at least if you are granted commit privileges to the FFmpeg project you are expected to be familiar with these rules I if not You can get git from etc no matter how small Every one of them has been saved from looking like a fool by this many times It s very easy for stray debug output or cosmetic modifications to slip please avoid problems through this extra level of scrutiny For cosmetics only commits you should e g by running git config global user name My Name git config global user email my email which is either set in your personal configuration file through git config core editor or set by one of the following environment VISUAL or EDITOR Log messages should be concise but descriptive Explain why you made a what you did will be obvious from the changes themselves most of the time Saying just bug fix or is bad Remember that people of varying skill levels look at and educate themselves while reading through your code Don t include filenames in log Git provides that information Possibly make the commit message have a descriptive first line
Definition: git-howto.txt:153
Method Not Valid in This State.
Definition: rtspcodes.h:31
#define AVERROR_STREAM_NOT_FOUND
Stream not found.
Definition: error.h:65
uint64_t packets
The number of returned packets.
Definition: rtsp.h:348
#define AV_LOG_INFO
Definition: log.h:156
Realmedia-style server.
Definition: rtsp.h:207
int lower_transport_mask
A mask with all requested transport methods.
Definition: rtsp.h:343
static int rtsp_read_announce(AVFormatContext *s)
Definition: rtspdec.c:169
RTSP Version not supported.
Definition: rtspcodes.h:37
const char * name
A comma separated list of short names for the format.
Definition: avformat.h:461
unbuffered private I/O API
uint32_t av_get_random_seed(void)
Get a seed to use in conjunction with random functions.
Definition: random_seed.c:105
Internal Server Error.
Definition: rtspcodes.h:35
Session Not Found.
Definition: rtspcodes.h:30
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
Definition: avformat.h:679
int interleaved_max
Definition: rtsp.h:427
enum AVDiscard discard
Selects which packets can be discarded at will and do not need to be demuxed.
Definition: avformat.h:702
int interleaved_min
interleave IDs; copies of RTSPTransportField->interleaved_min/max for the selected transport...
Definition: rtsp.h:427
This structure stores compressed data.
void ff_rtsp_close_connections(AVFormatContext *s)
Close all connection handles within the RTSP (de)muxer.
URLContext * rtp_handle
RTP stream handle (if UDP)
Definition: rtsp.h:419
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:190
void * transport_priv
RTP/RDT parse context if input, RTP AVFormatContext if output.
Definition: rtsp.h:420
int client_port_min
UDP client ports; these should be the local ports of the UDP RTP (and RTCP) sockets over which we rec...
Definition: rtsp.h:100
int initial_pause
Do not begin to play the stream immediately.
Definition: rtsp.h:363