LCOV - code coverage report
Current view: top level - libavformat - rtspdec.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 4 563 0.7 %
Date: 2017-12-16 21:16:39 Functions: 1 21 4.8 %

          Line data    Source code
       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 "rtpproto.h"
      33             : #include "rtsp.h"
      34             : #include "rdt.h"
      35             : #include "tls.h"
      36             : #include "url.h"
      37             : 
      38             : static const struct RTSPStatusMessage {
      39             :     enum RTSPStatusCode code;
      40             :     const char *message;
      41             : } status_messages[] = {
      42             :     { RTSP_STATUS_OK,             "OK"                               },
      43             :     { RTSP_STATUS_METHOD,         "Method Not Allowed"               },
      44             :     { RTSP_STATUS_BANDWIDTH,      "Not Enough Bandwidth"             },
      45             :     { RTSP_STATUS_SESSION,        "Session Not Found"                },
      46             :     { RTSP_STATUS_STATE,          "Method Not Valid in This State"   },
      47             :     { RTSP_STATUS_AGGREGATE,      "Aggregate operation not allowed"  },
      48             :     { RTSP_STATUS_ONLY_AGGREGATE, "Only aggregate operation allowed" },
      49             :     { RTSP_STATUS_TRANSPORT,      "Unsupported transport"            },
      50             :     { RTSP_STATUS_INTERNAL,       "Internal Server Error"            },
      51             :     { RTSP_STATUS_SERVICE,        "Service Unavailable"              },
      52             :     { RTSP_STATUS_VERSION,        "RTSP Version not supported"       },
      53             :     { 0,                          "NULL"                             }
      54             : };
      55             : 
      56           0 : static int rtsp_read_close(AVFormatContext *s)
      57             : {
      58           0 :     RTSPState *rt = s->priv_data;
      59             : 
      60           0 :     if (!(rt->rtsp_flags & RTSP_FLAG_LISTEN))
      61           0 :         ff_rtsp_send_cmd_async(s, "TEARDOWN", rt->control_uri, NULL);
      62             : 
      63           0 :     ff_rtsp_close_streams(s);
      64           0 :     ff_rtsp_close_connections(s);
      65           0 :     ff_network_close();
      66           0 :     rt->real_setup = NULL;
      67           0 :     av_freep(&rt->real_setup_cache);
      68           0 :     return 0;
      69             : }
      70             : 
      71           0 : static inline int read_line(AVFormatContext *s, char *rbuf, const int rbufsize,
      72             :                             int *rbuflen)
      73             : {
      74           0 :     RTSPState *rt = s->priv_data;
      75           0 :     int idx       = 0;
      76           0 :     int ret       = 0;
      77           0 :     *rbuflen      = 0;
      78             : 
      79             :     do {
      80           0 :         ret = ffurl_read_complete(rt->rtsp_hd, rbuf + idx, 1);
      81           0 :         if (ret <= 0)
      82           0 :             return ret ? ret : AVERROR_EOF;
      83           0 :         if (rbuf[idx] == '\r') {
      84             :             /* Ignore */
      85           0 :         } else if (rbuf[idx] == '\n') {
      86           0 :             rbuf[idx] = '\0';
      87           0 :             *rbuflen  = idx;
      88           0 :             return 0;
      89             :         } else
      90           0 :             idx++;
      91           0 :     } while (idx < rbufsize);
      92           0 :     av_log(s, AV_LOG_ERROR, "Message too long\n");
      93           0 :     return AVERROR(EIO);
      94             : }
      95             : 
      96           0 : static int rtsp_send_reply(AVFormatContext *s, enum RTSPStatusCode code,
      97             :                            const char *extracontent, uint16_t seq)
      98             : {
      99           0 :     RTSPState *rt = s->priv_data;
     100             :     char message[4096];
     101           0 :     int index = 0;
     102           0 :     while (status_messages[index].code) {
     103           0 :         if (status_messages[index].code == code) {
     104           0 :             snprintf(message, sizeof(message), "RTSP/1.0 %d %s\r\n",
     105             :                      code, status_messages[index].message);
     106           0 :             break;
     107             :         }
     108           0 :         index++;
     109             :     }
     110           0 :     if (!status_messages[index].code)
     111           0 :         return AVERROR(EINVAL);
     112           0 :     av_strlcatf(message, sizeof(message), "CSeq: %d\r\n", seq);
     113           0 :     av_strlcatf(message, sizeof(message), "Server: %s\r\n", LIBAVFORMAT_IDENT);
     114           0 :     if (extracontent)
     115           0 :         av_strlcat(message, extracontent, sizeof(message));
     116           0 :     av_strlcat(message, "\r\n", sizeof(message));
     117           0 :     av_log(s, AV_LOG_TRACE, "Sending response:\n%s", message);
     118           0 :     ffurl_write(rt->rtsp_hd_out, message, strlen(message));
     119             : 
     120           0 :     return 0;
     121             : }
     122             : 
     123           0 : static inline int check_sessionid(AVFormatContext *s,
     124             :                                   RTSPMessageHeader *request)
     125             : {
     126           0 :     RTSPState *rt = s->priv_data;
     127           0 :     unsigned char *session_id = rt->session_id;
     128           0 :     if (!session_id[0]) {
     129           0 :         av_log(s, AV_LOG_WARNING, "There is no session-id at the moment\n");
     130           0 :         return 0;
     131             :     }
     132           0 :     if (strcmp(session_id, request->session_id)) {
     133           0 :         av_log(s, AV_LOG_ERROR, "Unexpected session-id %s\n",
     134           0 :                request->session_id);
     135           0 :         rtsp_send_reply(s, RTSP_STATUS_SESSION, NULL, request->seq);
     136           0 :         return AVERROR_STREAM_NOT_FOUND;
     137             :     }
     138           0 :     return 0;
     139             : }
     140             : 
     141           0 : static inline int rtsp_read_request(AVFormatContext *s,
     142             :                                     RTSPMessageHeader *request,
     143             :                                     const char *method)
     144             : {
     145           0 :     RTSPState *rt = s->priv_data;
     146             :     char rbuf[1024];
     147             :     int rbuflen, ret;
     148             :     do {
     149           0 :         ret = read_line(s, rbuf, sizeof(rbuf), &rbuflen);
     150           0 :         if (ret)
     151           0 :             return ret;
     152           0 :         if (rbuflen > 1) {
     153           0 :             av_log(s, AV_LOG_TRACE, "Parsing[%d]: %s\n", rbuflen, rbuf);
     154           0 :             ff_rtsp_parse_line(s, request, rbuf, rt, method);
     155             :         }
     156           0 :     } while (rbuflen > 0);
     157           0 :     if (request->seq != rt->seq + 1) {
     158           0 :         av_log(s, AV_LOG_ERROR, "Unexpected Sequence number %d\n",
     159             :                request->seq);
     160           0 :         return AVERROR(EINVAL);
     161             :     }
     162           0 :     if (rt->session_id[0] && strcmp(method, "OPTIONS")) {
     163           0 :         ret = check_sessionid(s, request);
     164           0 :         if (ret)
     165           0 :             return ret;
     166             :     }
     167             : 
     168           0 :     return 0;
     169             : }
     170             : 
     171           0 : static int rtsp_read_announce(AVFormatContext *s)
     172             : {
     173           0 :     RTSPState *rt             = s->priv_data;
     174           0 :     RTSPMessageHeader request = { 0 };
     175             :     char sdp[4096];
     176             :     int  ret;
     177             : 
     178           0 :     ret = rtsp_read_request(s, &request, "ANNOUNCE");
     179           0 :     if (ret)
     180           0 :         return ret;
     181           0 :     rt->seq++;
     182           0 :     if (strcmp(request.content_type, "application/sdp")) {
     183           0 :         av_log(s, AV_LOG_ERROR, "Unexpected content type %s\n",
     184             :                request.content_type);
     185           0 :         rtsp_send_reply(s, RTSP_STATUS_SERVICE, NULL, request.seq);
     186           0 :         return AVERROR_OPTION_NOT_FOUND;
     187             :     }
     188           0 :     if (request.content_length && request.content_length < sizeof(sdp) - 1) {
     189             :         /* Read SDP */
     190           0 :         if (ffurl_read_complete(rt->rtsp_hd, sdp, request.content_length)
     191           0 :             < request.content_length) {
     192           0 :             av_log(s, AV_LOG_ERROR,
     193             :                    "Unable to get complete SDP Description in ANNOUNCE\n");
     194           0 :             rtsp_send_reply(s, RTSP_STATUS_INTERNAL, NULL, request.seq);
     195           0 :             return AVERROR(EIO);
     196             :         }
     197           0 :         sdp[request.content_length] = '\0';
     198           0 :         av_log(s, AV_LOG_VERBOSE, "SDP: %s\n", sdp);
     199           0 :         ret = ff_sdp_parse(s, sdp);
     200           0 :         if (ret)
     201           0 :             return ret;
     202           0 :         rtsp_send_reply(s, RTSP_STATUS_OK, NULL, request.seq);
     203           0 :         return 0;
     204             :     }
     205           0 :     av_log(s, AV_LOG_ERROR,
     206             :            "Content-Length header value exceeds sdp allocated buffer (4KB)\n");
     207           0 :     rtsp_send_reply(s, RTSP_STATUS_INTERNAL,
     208           0 :                     "Content-Length exceeds buffer size", request.seq);
     209           0 :     return AVERROR(EIO);
     210             : }
     211             : 
     212           0 : static int rtsp_read_options(AVFormatContext *s)
     213             : {
     214           0 :     RTSPState *rt             = s->priv_data;
     215           0 :     RTSPMessageHeader request = { 0 };
     216           0 :     int ret                   = 0;
     217             : 
     218             :     /* Parsing headers */
     219           0 :     ret = rtsp_read_request(s, &request, "OPTIONS");
     220           0 :     if (ret)
     221           0 :         return ret;
     222           0 :     rt->seq++;
     223             :     /* Send Reply */
     224           0 :     rtsp_send_reply(s, RTSP_STATUS_OK,
     225             :                     "Public: ANNOUNCE, PAUSE, SETUP, TEARDOWN, RECORD\r\n",
     226           0 :                     request.seq);
     227           0 :     return 0;
     228             : }
     229             : 
     230           0 : static int rtsp_read_setup(AVFormatContext *s, char* host, char *controlurl)
     231             : {
     232           0 :     RTSPState *rt             = s->priv_data;
     233           0 :     RTSPMessageHeader request = { 0 };
     234           0 :     int ret                   = 0;
     235             :     char url[1024];
     236             :     RTSPStream *rtsp_st;
     237             :     char responseheaders[1024];
     238           0 :     int localport    = -1;
     239           0 :     int transportidx = 0;
     240           0 :     int streamid     = 0;
     241             : 
     242           0 :     ret = rtsp_read_request(s, &request, "SETUP");
     243           0 :     if (ret)
     244           0 :         return ret;
     245           0 :     rt->seq++;
     246           0 :     if (!request.nb_transports) {
     247           0 :         av_log(s, AV_LOG_ERROR, "No transport defined in SETUP\n");
     248           0 :         return AVERROR_INVALIDDATA;
     249             :     }
     250           0 :     for (transportidx = 0; transportidx < request.nb_transports;
     251           0 :          transportidx++) {
     252           0 :         if (!request.transports[transportidx].mode_record ||
     253           0 :             (request.transports[transportidx].lower_transport !=
     254           0 :              RTSP_LOWER_TRANSPORT_UDP &&
     255           0 :              request.transports[transportidx].lower_transport !=
     256             :              RTSP_LOWER_TRANSPORT_TCP)) {
     257           0 :             av_log(s, AV_LOG_ERROR, "mode=record/receive not set or transport"
     258             :                    " protocol not supported (yet)\n");
     259           0 :             return AVERROR_INVALIDDATA;
     260             :         }
     261             :     }
     262           0 :     if (request.nb_transports > 1)
     263           0 :         av_log(s, AV_LOG_WARNING, "More than one transport not supported, "
     264             :                "using first of all\n");
     265           0 :     for (streamid = 0; streamid < rt->nb_rtsp_streams; streamid++) {
     266           0 :         if (!strcmp(rt->rtsp_streams[streamid]->control_url,
     267             :                     controlurl))
     268           0 :             break;
     269             :     }
     270           0 :     if (streamid == rt->nb_rtsp_streams) {
     271           0 :         av_log(s, AV_LOG_ERROR, "Unable to find requested track\n");
     272           0 :         return AVERROR_STREAM_NOT_FOUND;
     273             :     }
     274           0 :     rtsp_st   = rt->rtsp_streams[streamid];
     275           0 :     localport = rt->rtp_port_min;
     276             : 
     277           0 :     if (request.transports[0].lower_transport == RTSP_LOWER_TRANSPORT_TCP) {
     278           0 :         rt->lower_transport = RTSP_LOWER_TRANSPORT_TCP;
     279           0 :         if ((ret = ff_rtsp_open_transport_ctx(s, rtsp_st))) {
     280           0 :             rtsp_send_reply(s, RTSP_STATUS_TRANSPORT, NULL, request.seq);
     281           0 :             return ret;
     282             :         }
     283           0 :         rtsp_st->interleaved_min = request.transports[0].interleaved_min;
     284           0 :         rtsp_st->interleaved_max = request.transports[0].interleaved_max;
     285           0 :         snprintf(responseheaders, sizeof(responseheaders), "Transport: "
     286             :                  "RTP/AVP/TCP;unicast;mode=receive;interleaved=%d-%d"
     287             :                  "\r\n", request.transports[0].interleaved_min,
     288             :                  request.transports[0].interleaved_max);
     289             :     } else {
     290             :         do {
     291           0 :             AVDictionary *opts = NULL;
     292             :             char buf[256];
     293           0 :             snprintf(buf, sizeof(buf), "%d", rt->buffer_size);
     294           0 :             av_dict_set(&opts, "buffer_size", buf, 0);
     295           0 :             ff_url_join(url, sizeof(url), "rtp", NULL, host, localport, NULL);
     296           0 :             av_log(s, AV_LOG_TRACE, "Opening: %s", url);
     297           0 :             ret = ffurl_open_whitelist(&rtsp_st->rtp_handle, url, AVIO_FLAG_READ_WRITE,
     298           0 :                                        &s->interrupt_callback, &opts,
     299           0 :                                        s->protocol_whitelist, s->protocol_blacklist, NULL);
     300           0 :             av_dict_free(&opts);
     301           0 :             if (ret)
     302           0 :                 localport += 2;
     303           0 :         } while (ret || localport > rt->rtp_port_max);
     304           0 :         if (localport > rt->rtp_port_max) {
     305           0 :             rtsp_send_reply(s, RTSP_STATUS_TRANSPORT, NULL, request.seq);
     306           0 :             return ret;
     307             :         }
     308             : 
     309           0 :         av_log(s, AV_LOG_TRACE, "Listening on: %d",
     310             :                 ff_rtp_get_local_rtp_port(rtsp_st->rtp_handle));
     311           0 :         if ((ret = ff_rtsp_open_transport_ctx(s, rtsp_st))) {
     312           0 :             rtsp_send_reply(s, RTSP_STATUS_TRANSPORT, NULL, request.seq);
     313           0 :             return ret;
     314             :         }
     315             : 
     316           0 :         localport = ff_rtp_get_local_rtp_port(rtsp_st->rtp_handle);
     317           0 :         snprintf(responseheaders, sizeof(responseheaders), "Transport: "
     318             :                  "RTP/AVP/UDP;unicast;mode=receive;source=%s;"
     319             :                  "client_port=%d-%d;server_port=%d-%d\r\n",
     320             :                  host, request.transports[0].client_port_min,
     321             :                  request.transports[0].client_port_max, localport,
     322             :                  localport + 1);
     323             :     }
     324             : 
     325             :     /* Establish sessionid if not previously set */
     326             :     /* Put this in a function? */
     327             :     /* RFC 2326: session id must be at least 8 digits */
     328           0 :     while (strlen(rt->session_id) < 8)
     329           0 :         av_strlcatf(rt->session_id, 512, "%u", av_get_random_seed());
     330             : 
     331           0 :     av_strlcatf(responseheaders, sizeof(responseheaders), "Session: %s\r\n",
     332           0 :                 rt->session_id);
     333             :     /* Send Reply */
     334           0 :     rtsp_send_reply(s, RTSP_STATUS_OK, responseheaders, request.seq);
     335             : 
     336           0 :     rt->state = RTSP_STATE_PAUSED;
     337           0 :     return 0;
     338             : }
     339             : 
     340           0 : static int rtsp_read_record(AVFormatContext *s)
     341             : {
     342           0 :     RTSPState *rt             = s->priv_data;
     343           0 :     RTSPMessageHeader request = { 0 };
     344           0 :     int ret                   = 0;
     345             :     char responseheaders[1024];
     346             : 
     347           0 :     ret = rtsp_read_request(s, &request, "RECORD");
     348           0 :     if (ret)
     349           0 :         return ret;
     350           0 :     ret = check_sessionid(s, &request);
     351           0 :     if (ret)
     352           0 :         return ret;
     353           0 :     rt->seq++;
     354           0 :     snprintf(responseheaders, sizeof(responseheaders), "Session: %s\r\n",
     355           0 :              rt->session_id);
     356           0 :     rtsp_send_reply(s, RTSP_STATUS_OK, responseheaders, request.seq);
     357             : 
     358           0 :     rt->state = RTSP_STATE_STREAMING;
     359           0 :     return 0;
     360             : }
     361             : 
     362           0 : static inline int parse_command_line(AVFormatContext *s, const char *line,
     363             :                                      int linelen, char *uri, int urisize,
     364             :                                      char *method, int methodsize,
     365             :                                      enum RTSPMethod *methodcode)
     366             : {
     367           0 :     RTSPState *rt = s->priv_data;
     368             :     const char *linept, *searchlinept;
     369           0 :     linept = strchr(line, ' ');
     370             : 
     371           0 :     if (!linept) {
     372           0 :         av_log(s, AV_LOG_ERROR, "Error parsing method string\n");
     373           0 :         return AVERROR_INVALIDDATA;
     374             :     }
     375             : 
     376           0 :     if (linept - line > methodsize - 1) {
     377           0 :         av_log(s, AV_LOG_ERROR, "Method string too long\n");
     378           0 :         return AVERROR(EIO);
     379             :     }
     380           0 :     memcpy(method, line, linept - line);
     381           0 :     method[linept - line] = '\0';
     382           0 :     linept++;
     383           0 :     if (!strcmp(method, "ANNOUNCE"))
     384           0 :         *methodcode = ANNOUNCE;
     385           0 :     else if (!strcmp(method, "OPTIONS"))
     386           0 :         *methodcode = OPTIONS;
     387           0 :     else if (!strcmp(method, "RECORD"))
     388           0 :         *methodcode = RECORD;
     389           0 :     else if (!strcmp(method, "SETUP"))
     390           0 :         *methodcode = SETUP;
     391           0 :     else if (!strcmp(method, "PAUSE"))
     392           0 :         *methodcode = PAUSE;
     393           0 :     else if (!strcmp(method, "TEARDOWN"))
     394           0 :         *methodcode = TEARDOWN;
     395             :     else
     396           0 :         *methodcode = UNKNOWN;
     397             :     /* Check method with the state  */
     398           0 :     if (rt->state == RTSP_STATE_IDLE) {
     399           0 :         if ((*methodcode != ANNOUNCE) && (*methodcode != OPTIONS)) {
     400           0 :             av_log(s, AV_LOG_ERROR, "Unexpected command in Idle State %s\n",
     401             :                    line);
     402           0 :             return AVERROR_PROTOCOL_NOT_FOUND;
     403             :         }
     404           0 :     } else if (rt->state == RTSP_STATE_PAUSED) {
     405           0 :         if ((*methodcode != OPTIONS) && (*methodcode != RECORD)
     406           0 :             && (*methodcode != SETUP)) {
     407           0 :             av_log(s, AV_LOG_ERROR, "Unexpected command in Paused State %s\n",
     408             :                    line);
     409           0 :             return AVERROR_PROTOCOL_NOT_FOUND;
     410             :         }
     411           0 :     } else if (rt->state == RTSP_STATE_STREAMING) {
     412           0 :         if ((*methodcode != PAUSE) && (*methodcode != OPTIONS)
     413           0 :             && (*methodcode != TEARDOWN)) {
     414           0 :             av_log(s, AV_LOG_ERROR, "Unexpected command in Streaming State"
     415             :                    " %s\n", line);
     416           0 :             return AVERROR_PROTOCOL_NOT_FOUND;
     417             :         }
     418             :     } else {
     419           0 :         av_log(s, AV_LOG_ERROR, "Unexpected State [%d]\n", rt->state);
     420           0 :         return AVERROR_BUG;
     421             :     }
     422             : 
     423           0 :     searchlinept = strchr(linept, ' ');
     424           0 :     if (!searchlinept) {
     425           0 :         av_log(s, AV_LOG_ERROR, "Error parsing message URI\n");
     426           0 :         return AVERROR_INVALIDDATA;
     427             :     }
     428           0 :     if (searchlinept - linept > urisize - 1) {
     429           0 :         av_log(s, AV_LOG_ERROR, "uri string length exceeded buffer size\n");
     430           0 :         return AVERROR(EIO);
     431             :     }
     432           0 :     memcpy(uri, linept, searchlinept - linept);
     433           0 :     uri[searchlinept - linept] = '\0';
     434           0 :     if (strcmp(rt->control_uri, uri)) {
     435             :         char host[128], path[512], auth[128];
     436             :         int port;
     437             :         char ctl_host[128], ctl_path[512], ctl_auth[128];
     438             :         int ctl_port;
     439           0 :         av_url_split(NULL, 0, auth, sizeof(auth), host, sizeof(host), &port,
     440             :                      path, sizeof(path), uri);
     441           0 :         av_url_split(NULL, 0, ctl_auth, sizeof(ctl_auth), ctl_host,
     442             :                      sizeof(ctl_host), &ctl_port, ctl_path, sizeof(ctl_path),
     443           0 :                      rt->control_uri);
     444           0 :         if (strcmp(host, ctl_host))
     445           0 :             av_log(s, AV_LOG_INFO, "Host %s differs from expected %s\n",
     446             :                    host, ctl_host);
     447           0 :         if (strcmp(path, ctl_path) && *methodcode != SETUP)
     448           0 :             av_log(s, AV_LOG_WARNING, "WARNING: Path %s differs from expected"
     449             :                    " %s\n", path, ctl_path);
     450           0 :         if (*methodcode == ANNOUNCE) {
     451           0 :             av_log(s, AV_LOG_INFO,
     452             :                    "Updating control URI to %s\n", uri);
     453           0 :             av_strlcpy(rt->control_uri, uri, sizeof(rt->control_uri));
     454             :         }
     455             :     }
     456             : 
     457           0 :     linept = searchlinept + 1;
     458           0 :     if (!av_strstart(linept, "RTSP/1.0", NULL)) {
     459           0 :         av_log(s, AV_LOG_ERROR, "Error parsing protocol or version\n");
     460           0 :         return AVERROR_PROTOCOL_NOT_FOUND;
     461             :     }
     462           0 :     return 0;
     463             : }
     464             : 
     465           0 : int ff_rtsp_parse_streaming_commands(AVFormatContext *s)
     466             : {
     467           0 :     RTSPState *rt = s->priv_data;
     468             :     unsigned char rbuf[4096];
     469             :     unsigned char method[10];
     470             :     char uri[500];
     471             :     int ret;
     472           0 :     int rbuflen               = 0;
     473           0 :     RTSPMessageHeader request = { 0 };
     474             :     enum RTSPMethod methodcode;
     475             : 
     476           0 :     ret = read_line(s, rbuf, sizeof(rbuf), &rbuflen);
     477           0 :     if (ret < 0)
     478           0 :         return ret;
     479           0 :     ret = parse_command_line(s, rbuf, rbuflen, uri, sizeof(uri), method,
     480             :                              sizeof(method), &methodcode);
     481           0 :     if (ret) {
     482           0 :         av_log(s, AV_LOG_ERROR, "RTSP: Unexpected Command\n");
     483           0 :         return ret;
     484             :     }
     485             : 
     486           0 :     ret = rtsp_read_request(s, &request, method);
     487           0 :     if (ret)
     488           0 :         return ret;
     489           0 :     rt->seq++;
     490           0 :     if (methodcode == PAUSE) {
     491           0 :         rt->state = RTSP_STATE_PAUSED;
     492           0 :         ret       = rtsp_send_reply(s, RTSP_STATUS_OK, NULL , request.seq);
     493             :         // TODO: Missing date header in response
     494           0 :     } else if (methodcode == OPTIONS) {
     495           0 :         ret = rtsp_send_reply(s, RTSP_STATUS_OK,
     496             :                               "Public: ANNOUNCE, PAUSE, SETUP, TEARDOWN, "
     497           0 :                               "RECORD\r\n", request.seq);
     498           0 :     } else if (methodcode == TEARDOWN) {
     499           0 :         rt->state = RTSP_STATE_IDLE;
     500           0 :         ret       = rtsp_send_reply(s, RTSP_STATUS_OK, NULL , request.seq);
     501             :     }
     502           0 :     return ret;
     503             : }
     504             : 
     505           0 : static int rtsp_read_play(AVFormatContext *s)
     506             : {
     507           0 :     RTSPState *rt = s->priv_data;
     508           0 :     RTSPMessageHeader reply1, *reply = &reply1;
     509             :     int i;
     510             :     char cmd[1024];
     511             : 
     512           0 :     av_log(s, AV_LOG_DEBUG, "hello state=%d\n", rt->state);
     513           0 :     rt->nb_byes = 0;
     514             : 
     515           0 :     if (rt->lower_transport == RTSP_LOWER_TRANSPORT_UDP) {
     516           0 :         for (i = 0; i < rt->nb_rtsp_streams; i++) {
     517           0 :             RTSPStream *rtsp_st = rt->rtsp_streams[i];
     518             :             /* Try to initialize the connection state in a
     519             :              * potential NAT router by sending dummy packets.
     520             :              * RTP/RTCP dummy packets are used for RDT, too.
     521             :              */
     522           0 :             if (rtsp_st->rtp_handle &&
     523           0 :                 !(rt->server_type == RTSP_SERVER_WMS && i > 1))
     524           0 :                 ff_rtp_send_punch_packets(rtsp_st->rtp_handle);
     525             :         }
     526             :     }
     527           0 :     if (!(rt->server_type == RTSP_SERVER_REAL && rt->need_subscription)) {
     528           0 :         if (rt->transport == RTSP_TRANSPORT_RTP) {
     529           0 :             for (i = 0; i < rt->nb_rtsp_streams; i++) {
     530           0 :                 RTSPStream *rtsp_st = rt->rtsp_streams[i];
     531           0 :                 RTPDemuxContext *rtpctx = rtsp_st->transport_priv;
     532           0 :                 if (!rtpctx)
     533           0 :                     continue;
     534           0 :                 ff_rtp_reset_packet_queue(rtpctx);
     535           0 :                 rtpctx->last_rtcp_ntp_time  = AV_NOPTS_VALUE;
     536           0 :                 rtpctx->first_rtcp_ntp_time = AV_NOPTS_VALUE;
     537           0 :                 rtpctx->base_timestamp      = 0;
     538           0 :                 rtpctx->timestamp           = 0;
     539           0 :                 rtpctx->unwrapped_timestamp = 0;
     540           0 :                 rtpctx->rtcp_ts_offset      = 0;
     541             :             }
     542             :         }
     543           0 :         if (rt->state == RTSP_STATE_PAUSED) {
     544           0 :             cmd[0] = 0;
     545             :         } else {
     546           0 :             snprintf(cmd, sizeof(cmd),
     547             :                      "Range: npt=%"PRId64".%03"PRId64"-\r\n",
     548           0 :                      rt->seek_timestamp / AV_TIME_BASE,
     549           0 :                      rt->seek_timestamp / (AV_TIME_BASE / 1000) % 1000);
     550             :         }
     551           0 :         ff_rtsp_send_cmd(s, "PLAY", rt->control_uri, cmd, reply, NULL);
     552           0 :         if (reply->status_code != RTSP_STATUS_OK) {
     553           0 :             return ff_rtsp_averror(reply->status_code, -1);
     554             :         }
     555           0 :         if (rt->transport == RTSP_TRANSPORT_RTP &&
     556           0 :             reply->range_start != AV_NOPTS_VALUE) {
     557           0 :             for (i = 0; i < rt->nb_rtsp_streams; i++) {
     558           0 :                 RTSPStream *rtsp_st = rt->rtsp_streams[i];
     559           0 :                 RTPDemuxContext *rtpctx = rtsp_st->transport_priv;
     560           0 :                 AVStream *st = NULL;
     561           0 :                 if (!rtpctx || rtsp_st->stream_index < 0)
     562           0 :                     continue;
     563             : 
     564           0 :                 st = s->streams[rtsp_st->stream_index];
     565           0 :                 rtpctx->range_start_offset =
     566           0 :                     av_rescale_q(reply->range_start, AV_TIME_BASE_Q,
     567             :                                  st->time_base);
     568             :             }
     569             :         }
     570             :     }
     571           0 :     rt->state = RTSP_STATE_STREAMING;
     572           0 :     return 0;
     573             : }
     574             : 
     575             : /* pause the stream */
     576           0 : static int rtsp_read_pause(AVFormatContext *s)
     577             : {
     578           0 :     RTSPState *rt = s->priv_data;
     579           0 :     RTSPMessageHeader reply1, *reply = &reply1;
     580             : 
     581           0 :     if (rt->state != RTSP_STATE_STREAMING)
     582           0 :         return 0;
     583           0 :     else if (!(rt->server_type == RTSP_SERVER_REAL && rt->need_subscription)) {
     584           0 :         ff_rtsp_send_cmd(s, "PAUSE", rt->control_uri, NULL, reply, NULL);
     585           0 :         if (reply->status_code != RTSP_STATUS_OK) {
     586           0 :             return ff_rtsp_averror(reply->status_code, -1);
     587             :         }
     588             :     }
     589           0 :     rt->state = RTSP_STATE_PAUSED;
     590           0 :     return 0;
     591             : }
     592             : 
     593           0 : int ff_rtsp_setup_input_streams(AVFormatContext *s, RTSPMessageHeader *reply)
     594             : {
     595           0 :     RTSPState *rt = s->priv_data;
     596             :     char cmd[1024];
     597           0 :     unsigned char *content = NULL;
     598             :     int ret;
     599             : 
     600             :     /* describe the stream */
     601           0 :     snprintf(cmd, sizeof(cmd),
     602             :              "Accept: application/sdp\r\n");
     603           0 :     if (rt->server_type == RTSP_SERVER_REAL) {
     604             :         /**
     605             :          * The Require: attribute is needed for proper streaming from
     606             :          * Realmedia servers.
     607             :          */
     608           0 :         av_strlcat(cmd,
     609             :                    "Require: com.real.retain-entity-for-setup\r\n",
     610             :                    sizeof(cmd));
     611             :     }
     612           0 :     ff_rtsp_send_cmd(s, "DESCRIBE", rt->control_uri, cmd, reply, &content);
     613           0 :     if (reply->status_code != RTSP_STATUS_OK) {
     614           0 :         av_freep(&content);
     615           0 :         return ff_rtsp_averror(reply->status_code, AVERROR_INVALIDDATA);
     616             :     }
     617           0 :     if (!content)
     618           0 :         return AVERROR_INVALIDDATA;
     619             : 
     620           0 :     av_log(s, AV_LOG_VERBOSE, "SDP:\n%s\n", content);
     621             :     /* now we got the SDP description, we parse it */
     622           0 :     ret = ff_sdp_parse(s, (const char *)content);
     623           0 :     av_freep(&content);
     624           0 :     if (ret < 0)
     625           0 :         return ret;
     626             : 
     627           0 :     return 0;
     628             : }
     629             : 
     630           0 : static int rtsp_listen(AVFormatContext *s)
     631             : {
     632           0 :     RTSPState *rt = s->priv_data;
     633             :     char proto[128], host[128], path[512], auth[128];
     634             :     char uri[500];
     635             :     int port;
     636           0 :     int default_port = RTSP_DEFAULT_PORT;
     637             :     char tcpname[500];
     638           0 :     const char *lower_proto = "tcp";
     639             :     unsigned char rbuf[4096];
     640             :     unsigned char method[10];
     641           0 :     int rbuflen = 0;
     642             :     int ret;
     643             :     enum RTSPMethod methodcode;
     644             : 
     645             :     /* extract hostname and port */
     646           0 :     av_url_split(proto, sizeof(proto), auth, sizeof(auth), host, sizeof(host),
     647           0 :                  &port, path, sizeof(path), s->filename);
     648             : 
     649             :     /* ff_url_join. No authorization by now (NULL) */
     650           0 :     ff_url_join(rt->control_uri, sizeof(rt->control_uri), proto, NULL, host,
     651             :                 port, "%s", path);
     652             : 
     653           0 :     if (!strcmp(proto, "rtsps")) {
     654           0 :         lower_proto  = "tls";
     655           0 :         default_port = RTSPS_DEFAULT_PORT;
     656             :     }
     657             : 
     658           0 :     if (port < 0)
     659           0 :         port = default_port;
     660             : 
     661             :     /* Create TCP connection */
     662           0 :     ff_url_join(tcpname, sizeof(tcpname), lower_proto, NULL, host, port,
     663           0 :                 "?listen&listen_timeout=%d", rt->initial_timeout * 1000);
     664             : 
     665           0 :     if (ret = ffurl_open_whitelist(&rt->rtsp_hd, tcpname, AVIO_FLAG_READ_WRITE,
     666           0 :                                    &s->interrupt_callback, NULL,
     667           0 :                                    s->protocol_whitelist, s->protocol_blacklist, NULL)) {
     668           0 :         av_log(s, AV_LOG_ERROR, "Unable to open RTSP for listening\n");
     669           0 :         return ret;
     670             :     }
     671           0 :     rt->state       = RTSP_STATE_IDLE;
     672           0 :     rt->rtsp_hd_out = rt->rtsp_hd;
     673             :     for (;;) { /* Wait for incoming RTSP messages */
     674           0 :         ret = read_line(s, rbuf, sizeof(rbuf), &rbuflen);
     675           0 :         if (ret < 0)
     676           0 :             return ret;
     677           0 :         ret = parse_command_line(s, rbuf, rbuflen, uri, sizeof(uri), method,
     678             :                                  sizeof(method), &methodcode);
     679           0 :         if (ret) {
     680           0 :             av_log(s, AV_LOG_ERROR, "RTSP: Unexpected Command\n");
     681           0 :             return ret;
     682             :         }
     683             : 
     684           0 :         if (methodcode == ANNOUNCE) {
     685           0 :             ret       = rtsp_read_announce(s);
     686           0 :             rt->state = RTSP_STATE_PAUSED;
     687           0 :         } else if (methodcode == OPTIONS) {
     688           0 :             ret = rtsp_read_options(s);
     689           0 :         } else if (methodcode == RECORD) {
     690           0 :             ret = rtsp_read_record(s);
     691           0 :             if (!ret)
     692           0 :                 return 0; // We are ready for streaming
     693           0 :         } else if (methodcode == SETUP)
     694           0 :             ret = rtsp_read_setup(s, host, uri);
     695           0 :         if (ret) {
     696           0 :             ffurl_close(rt->rtsp_hd);
     697           0 :             return AVERROR_INVALIDDATA;
     698             :         }
     699             :     }
     700             : }
     701             : 
     702        3209 : static int rtsp_probe(AVProbeData *p)
     703             : {
     704        3209 :     if (
     705             : #if CONFIG_TLS_PROTOCOL
     706             :         av_strstart(p->filename, "rtsps:", NULL) ||
     707             : #endif
     708        3209 :         av_strstart(p->filename, "rtsp:", NULL))
     709           0 :         return AVPROBE_SCORE_MAX;
     710        3209 :     return 0;
     711             : }
     712             : 
     713           0 : static int rtsp_read_header(AVFormatContext *s)
     714             : {
     715           0 :     RTSPState *rt = s->priv_data;
     716             :     int ret;
     717             : 
     718           0 :     if (rt->initial_timeout > 0)
     719           0 :         rt->rtsp_flags |= RTSP_FLAG_LISTEN;
     720             : 
     721           0 :     if (rt->rtsp_flags & RTSP_FLAG_LISTEN) {
     722           0 :         ret = rtsp_listen(s);
     723           0 :         if (ret)
     724           0 :             return ret;
     725             :     } else {
     726           0 :         ret = ff_rtsp_connect(s);
     727           0 :         if (ret)
     728           0 :             return ret;
     729             : 
     730           0 :         rt->real_setup_cache = !s->nb_streams ? NULL :
     731           0 :             av_mallocz_array(s->nb_streams, 2 * sizeof(*rt->real_setup_cache));
     732           0 :         if (!rt->real_setup_cache && s->nb_streams)
     733           0 :             return AVERROR(ENOMEM);
     734           0 :         rt->real_setup = rt->real_setup_cache + s->nb_streams;
     735             : 
     736           0 :         if (rt->initial_pause) {
     737             :             /* do not start immediately */
     738             :         } else {
     739           0 :             if ((ret = rtsp_read_play(s)) < 0) {
     740           0 :                 ff_rtsp_close_streams(s);
     741           0 :                 ff_rtsp_close_connections(s);
     742           0 :                 return ret;
     743             :             }
     744             :         }
     745             :     }
     746             : 
     747           0 :     return 0;
     748             : }
     749             : 
     750           0 : int ff_rtsp_tcp_read_packet(AVFormatContext *s, RTSPStream **prtsp_st,
     751             :                             uint8_t *buf, int buf_size)
     752             : {
     753           0 :     RTSPState *rt = s->priv_data;
     754             :     int id, len, i, ret;
     755             :     RTSPStream *rtsp_st;
     756             : 
     757           0 :     av_log(s, AV_LOG_TRACE, "tcp_read_packet:\n");
     758           0 : redo:
     759           0 :     for (;;) {
     760             :         RTSPMessageHeader reply;
     761             : 
     762           0 :         ret = ff_rtsp_read_reply(s, &reply, NULL, 1, NULL);
     763           0 :         if (ret < 0)
     764           0 :             return ret;
     765           0 :         if (ret == 1) /* received '$' */
     766           0 :             break;
     767             :         /* XXX: parse message */
     768           0 :         if (rt->state != RTSP_STATE_STREAMING)
     769           0 :             return 0;
     770             :     }
     771           0 :     ret = ffurl_read_complete(rt->rtsp_hd, buf, 3);
     772           0 :     if (ret != 3)
     773           0 :         return -1;
     774           0 :     id  = buf[0];
     775           0 :     len = AV_RB16(buf + 1);
     776           0 :     av_log(s, AV_LOG_TRACE, "id=%d len=%d\n", id, len);
     777           0 :     if (len > buf_size || len < 8)
     778             :         goto redo;
     779             :     /* get the data */
     780           0 :     ret = ffurl_read_complete(rt->rtsp_hd, buf, len);
     781           0 :     if (ret != len)
     782           0 :         return -1;
     783           0 :     if (rt->transport == RTSP_TRANSPORT_RDT &&
     784           0 :         ff_rdt_parse_header(buf, len, &id, NULL, NULL, NULL, NULL) < 0)
     785           0 :         return -1;
     786             : 
     787             :     /* find the matching stream */
     788           0 :     for (i = 0; i < rt->nb_rtsp_streams; i++) {
     789           0 :         rtsp_st = rt->rtsp_streams[i];
     790           0 :         if (id >= rtsp_st->interleaved_min &&
     791           0 :             id <= rtsp_st->interleaved_max)
     792           0 :             goto found;
     793             :     }
     794           0 :     goto redo;
     795           0 : found:
     796           0 :     *prtsp_st = rtsp_st;
     797           0 :     return len;
     798             : }
     799             : 
     800           0 : static int resetup_tcp(AVFormatContext *s)
     801             : {
     802           0 :     RTSPState *rt = s->priv_data;
     803             :     char host[1024];
     804             :     int port;
     805             : 
     806           0 :     av_url_split(NULL, 0, NULL, 0, host, sizeof(host), &port, NULL, 0,
     807           0 :                  s->filename);
     808           0 :     ff_rtsp_undo_setup(s, 0);
     809           0 :     return ff_rtsp_make_setup_request(s, host, port, RTSP_LOWER_TRANSPORT_TCP,
     810           0 :                                       rt->real_challenge);
     811             : }
     812             : 
     813           0 : static int rtsp_read_packet(AVFormatContext *s, AVPacket *pkt)
     814             : {
     815           0 :     RTSPState *rt = s->priv_data;
     816             :     int ret;
     817           0 :     RTSPMessageHeader reply1, *reply = &reply1;
     818             :     char cmd[1024];
     819             : 
     820           0 : retry:
     821           0 :     if (rt->server_type == RTSP_SERVER_REAL) {
     822             :         int i;
     823             : 
     824           0 :         for (i = 0; i < s->nb_streams; i++)
     825           0 :             rt->real_setup[i] = s->streams[i]->discard;
     826             : 
     827           0 :         if (!rt->need_subscription) {
     828           0 :             if (memcmp (rt->real_setup, rt->real_setup_cache,
     829           0 :                         sizeof(enum AVDiscard) * s->nb_streams)) {
     830           0 :                 snprintf(cmd, sizeof(cmd),
     831             :                          "Unsubscribe: %s\r\n",
     832           0 :                          rt->last_subscription);
     833           0 :                 ff_rtsp_send_cmd(s, "SET_PARAMETER", rt->control_uri,
     834             :                                  cmd, reply, NULL);
     835           0 :                 if (reply->status_code != RTSP_STATUS_OK)
     836           0 :                     return ff_rtsp_averror(reply->status_code, AVERROR_INVALIDDATA);
     837           0 :                 rt->need_subscription = 1;
     838             :             }
     839             :         }
     840             : 
     841           0 :         if (rt->need_subscription) {
     842           0 :             int r, rule_nr, first = 1;
     843             : 
     844           0 :             memcpy(rt->real_setup_cache, rt->real_setup,
     845           0 :                    sizeof(enum AVDiscard) * s->nb_streams);
     846           0 :             rt->last_subscription[0] = 0;
     847             : 
     848           0 :             snprintf(cmd, sizeof(cmd),
     849             :                      "Subscribe: ");
     850           0 :             for (i = 0; i < rt->nb_rtsp_streams; i++) {
     851           0 :                 rule_nr = 0;
     852           0 :                 for (r = 0; r < s->nb_streams; r++) {
     853           0 :                     if (s->streams[r]->id == i) {
     854           0 :                         if (s->streams[r]->discard != AVDISCARD_ALL) {
     855           0 :                             if (!first)
     856           0 :                                 av_strlcat(rt->last_subscription, ",",
     857             :                                            sizeof(rt->last_subscription));
     858           0 :                             ff_rdt_subscribe_rule(
     859           0 :                                 rt->last_subscription,
     860             :                                 sizeof(rt->last_subscription), i, rule_nr);
     861           0 :                             first = 0;
     862             :                         }
     863           0 :                         rule_nr++;
     864             :                     }
     865             :                 }
     866             :             }
     867           0 :             av_strlcatf(cmd, sizeof(cmd), "%s\r\n", rt->last_subscription);
     868           0 :             ff_rtsp_send_cmd(s, "SET_PARAMETER", rt->control_uri,
     869             :                              cmd, reply, NULL);
     870           0 :             if (reply->status_code != RTSP_STATUS_OK)
     871           0 :                 return ff_rtsp_averror(reply->status_code, AVERROR_INVALIDDATA);
     872           0 :             rt->need_subscription = 0;
     873             : 
     874           0 :             if (rt->state == RTSP_STATE_STREAMING)
     875           0 :                 rtsp_read_play (s);
     876             :         }
     877             :     }
     878             : 
     879           0 :     ret = ff_rtsp_fetch_packet(s, pkt);
     880           0 :     if (ret < 0) {
     881           0 :         if (ret == AVERROR(ETIMEDOUT) && !rt->packets) {
     882           0 :             if (rt->lower_transport == RTSP_LOWER_TRANSPORT_UDP &&
     883           0 :                 rt->lower_transport_mask & (1 << RTSP_LOWER_TRANSPORT_TCP)) {
     884           0 :                 RTSPMessageHeader reply1, *reply = &reply1;
     885           0 :                 av_log(s, AV_LOG_WARNING, "UDP timeout, retrying with TCP\n");
     886           0 :                 if (rtsp_read_pause(s) != 0)
     887           0 :                     return -1;
     888             :                 // TEARDOWN is required on Real-RTSP, but might make
     889             :                 // other servers close the connection.
     890           0 :                 if (rt->server_type == RTSP_SERVER_REAL)
     891           0 :                     ff_rtsp_send_cmd(s, "TEARDOWN", rt->control_uri, NULL,
     892             :                                      reply, NULL);
     893           0 :                 rt->session_id[0] = '\0';
     894           0 :                 if (resetup_tcp(s) == 0) {
     895           0 :                     rt->state = RTSP_STATE_IDLE;
     896           0 :                     rt->need_subscription = 1;
     897           0 :                     if (rtsp_read_play(s) != 0)
     898           0 :                         return -1;
     899           0 :                     goto retry;
     900             :                 }
     901             :             }
     902             :         }
     903           0 :         return ret;
     904             :     }
     905           0 :     rt->packets++;
     906             : 
     907           0 :     if (!(rt->rtsp_flags & RTSP_FLAG_LISTEN)) {
     908             :         /* send dummy request to keep TCP connection alive */
     909           0 :         if ((av_gettime_relative() - rt->last_cmd_time) / 1000000 >= rt->timeout / 2 ||
     910           0 :             rt->auth_state.stale) {
     911           0 :             if (rt->server_type == RTSP_SERVER_WMS ||
     912           0 :                 (rt->server_type != RTSP_SERVER_REAL &&
     913           0 :                  rt->get_parameter_supported)) {
     914           0 :                 ff_rtsp_send_cmd_async(s, "GET_PARAMETER", rt->control_uri, NULL);
     915             :             } else {
     916           0 :                 ff_rtsp_send_cmd_async(s, "OPTIONS", rt->control_uri, NULL);
     917             :             }
     918             :             /* The stale flag should be reset when creating the auth response in
     919             :              * ff_rtsp_send_cmd_async, but reset it here just in case we never
     920             :              * called the auth code (if we didn't have any credentials set). */
     921           0 :             rt->auth_state.stale = 0;
     922             :         }
     923             :     }
     924             : 
     925           0 :     return 0;
     926             : }
     927             : 
     928           0 : static int rtsp_read_seek(AVFormatContext *s, int stream_index,
     929             :                           int64_t timestamp, int flags)
     930             : {
     931           0 :     RTSPState *rt = s->priv_data;
     932             :     int ret;
     933             : 
     934           0 :     rt->seek_timestamp = av_rescale_q(timestamp,
     935           0 :                                       s->streams[stream_index]->time_base,
     936           0 :                                       AV_TIME_BASE_Q);
     937           0 :     switch(rt->state) {
     938           0 :     default:
     939             :     case RTSP_STATE_IDLE:
     940           0 :         break;
     941           0 :     case RTSP_STATE_STREAMING:
     942           0 :         if ((ret = rtsp_read_pause(s)) != 0)
     943           0 :             return ret;
     944           0 :         rt->state = RTSP_STATE_SEEKING;
     945           0 :         if ((ret = rtsp_read_play(s)) != 0)
     946           0 :             return ret;
     947           0 :         break;
     948           0 :     case RTSP_STATE_PAUSED:
     949           0 :         rt->state = RTSP_STATE_IDLE;
     950           0 :         break;
     951             :     }
     952           0 :     return 0;
     953             : }
     954             : 
     955             : static const AVClass rtsp_demuxer_class = {
     956             :     .class_name     = "RTSP demuxer",
     957             :     .item_name      = av_default_item_name,
     958             :     .option         = ff_rtsp_options,
     959             :     .version        = LIBAVUTIL_VERSION_INT,
     960             : };
     961             : 
     962             : AVInputFormat ff_rtsp_demuxer = {
     963             :     .name           = "rtsp",
     964             :     .long_name      = NULL_IF_CONFIG_SMALL("RTSP input"),
     965             :     .priv_data_size = sizeof(RTSPState),
     966             :     .read_probe     = rtsp_probe,
     967             :     .read_header    = rtsp_read_header,
     968             :     .read_packet    = rtsp_read_packet,
     969             :     .read_close     = rtsp_read_close,
     970             :     .read_seek      = rtsp_read_seek,
     971             :     .flags          = AVFMT_NOFILE,
     972             :     .read_play      = rtsp_read_play,
     973             :     .read_pause     = rtsp_read_pause,
     974             :     .priv_class     = &rtsp_demuxer_class,
     975             : };

Generated by: LCOV version 1.13