rtsp.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644
  1. /*
  2. * RTSP definitions
  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. #ifndef AVFORMAT_RTSP_H
  22. #define AVFORMAT_RTSP_H
  23. #include <stdint.h>
  24. #include "avformat.h"
  25. #include "rtspcodes.h"
  26. #include "rtpdec.h"
  27. #include "network.h"
  28. #include "httpauth.h"
  29. #include "libavutil/log.h"
  30. #include "libavutil/opt.h"
  31. /**
  32. * Network layer over which RTP/etc packet data will be transported.
  33. */
  34. enum RTSPLowerTransport {
  35. RTSP_LOWER_TRANSPORT_UDP = 0, /**< UDP/unicast */
  36. RTSP_LOWER_TRANSPORT_TCP = 1, /**< TCP; interleaved in RTSP */
  37. RTSP_LOWER_TRANSPORT_UDP_MULTICAST = 2, /**< UDP/multicast */
  38. RTSP_LOWER_TRANSPORT_NB,
  39. RTSP_LOWER_TRANSPORT_HTTP = 8, /**< HTTP tunneled - not a proper
  40. transport mode as such,
  41. only for use via AVOptions */
  42. RTSP_LOWER_TRANSPORT_HTTPS, /**< HTTPS tunneled */
  43. RTSP_LOWER_TRANSPORT_CUSTOM = 16, /**< Custom IO - not a public
  44. option for lower_transport_mask,
  45. but set in the SDP demuxer based
  46. on a flag. */
  47. };
  48. /**
  49. * Packet profile of the data that we will be receiving. Real servers
  50. * commonly send RDT (although they can sometimes send RTP as well),
  51. * whereas most others will send RTP.
  52. */
  53. enum RTSPTransport {
  54. RTSP_TRANSPORT_RTP, /**< Standards-compliant RTP */
  55. RTSP_TRANSPORT_RDT, /**< Realmedia Data Transport */
  56. RTSP_TRANSPORT_RAW, /**< Raw data (over UDP) */
  57. RTSP_TRANSPORT_NB
  58. };
  59. /**
  60. * Transport mode for the RTSP data. This may be plain, or
  61. * tunneled, which is done over HTTP.
  62. */
  63. enum RTSPControlTransport {
  64. RTSP_MODE_PLAIN, /**< Normal RTSP */
  65. RTSP_MODE_TUNNEL /**< RTSP over HTTP (tunneling) */
  66. };
  67. #define RTSP_DEFAULT_PORT 554
  68. #define RTSPS_DEFAULT_PORT 322
  69. #define RTSP_MAX_TRANSPORTS 8
  70. #define RTSP_TCP_MAX_PACKET_SIZE 1472
  71. #define RTSP_DEFAULT_NB_AUDIO_CHANNELS 1
  72. #define RTSP_DEFAULT_AUDIO_SAMPLERATE 44100
  73. #define RTSP_RTP_PORT_MIN 5000
  74. #define RTSP_RTP_PORT_MAX 65000
  75. /**
  76. * This describes a single item in the "Transport:" line of one stream as
  77. * negotiated by the SETUP RTSP command. Multiple transports are comma-
  78. * separated ("Transport: x-read-rdt/tcp;interleaved=0-1,rtp/avp/udp;
  79. * client_port=1000-1001;server_port=1800-1801") and described in separate
  80. * RTSPTransportFields.
  81. */
  82. typedef struct RTSPTransportField {
  83. /** interleave ids, if TCP transport; each TCP/RTSP data packet starts
  84. * with a '$', stream length and stream ID. If the stream ID is within
  85. * the range of this interleaved_min-max, then the packet belongs to
  86. * this stream. */
  87. int interleaved_min, interleaved_max;
  88. /** UDP multicast port range; the ports to which we should connect to
  89. * receive multicast UDP data. */
  90. int port_min, port_max;
  91. /** UDP client ports; these should be the local ports of the UDP RTP
  92. * (and RTCP) sockets over which we receive RTP/RTCP data. */
  93. int client_port_min, client_port_max;
  94. /** UDP unicast server port range; the ports to which we should connect
  95. * to receive unicast UDP RTP/RTCP data. */
  96. int server_port_min, server_port_max;
  97. /** time-to-live value (required for multicast); the amount of HOPs that
  98. * packets will be allowed to make before being discarded. */
  99. int ttl;
  100. /** transport set to record data */
  101. int mode_record;
  102. struct sockaddr_storage destination; /**< destination IP address */
  103. char source[INET6_ADDRSTRLEN + 1]; /**< source IP address */
  104. /** data/packet transport protocol; e.g. RTP or RDT */
  105. enum RTSPTransport transport;
  106. /** network layer transport protocol; e.g. TCP or UDP uni-/multicast */
  107. enum RTSPLowerTransport lower_transport;
  108. } RTSPTransportField;
  109. /**
  110. * This describes the server response to each RTSP command.
  111. */
  112. typedef struct RTSPMessageHeader {
  113. /** length of the data following this header */
  114. int content_length;
  115. enum RTSPStatusCode status_code; /**< response code from server */
  116. /** number of items in the 'transports' variable below */
  117. int nb_transports;
  118. /** Time range of the streams that the server will stream. In
  119. * AV_TIME_BASE unit, AV_NOPTS_VALUE if not used */
  120. int64_t range_start, range_end;
  121. /** describes the complete "Transport:" line of the server in response
  122. * to a SETUP RTSP command by the client */
  123. RTSPTransportField transports[RTSP_MAX_TRANSPORTS];
  124. int seq; /**< sequence number */
  125. /** the "Session:" field. This value is initially set by the server and
  126. * should be re-transmitted by the client in every RTSP command. */
  127. char session_id[512];
  128. /** the "Location:" field. This value is used to handle redirection.
  129. */
  130. char location[4096];
  131. /** the "RealChallenge1:" field from the server */
  132. char real_challenge[64];
  133. /** the "Server: field, which can be used to identify some special-case
  134. * servers that are not 100% standards-compliant. We use this to identify
  135. * Windows Media Server, which has a value "WMServer/v.e.r.sion", where
  136. * version is a sequence of digits (e.g. 9.0.0.3372). Helix/Real servers
  137. * use something like "Helix [..] Server Version v.e.r.sion (platform)
  138. * (RealServer compatible)" or "RealServer Version v.e.r.sion (platform)",
  139. * where platform is the output of $uname -msr | sed 's/ /-/g'. */
  140. char server[64];
  141. /** The "timeout" comes as part of the server response to the "SETUP"
  142. * command, in the "Session: <xyz>[;timeout=<value>]" line. It is the
  143. * time, in seconds, that the server will go without traffic over the
  144. * RTSP/TCP connection before it closes the connection. To prevent
  145. * this, sent dummy requests (e.g. OPTIONS) with intervals smaller
  146. * than this value. */
  147. int timeout;
  148. /** The "Notice" or "X-Notice" field value. See
  149. * http://tools.ietf.org/html/draft-stiemerling-rtsp-announce-00
  150. * for a complete list of supported values. */
  151. int notice;
  152. /** The "reason" is meant to specify better the meaning of the error code
  153. * returned
  154. */
  155. char reason[256];
  156. /**
  157. * Content type header
  158. */
  159. char content_type[64];
  160. } RTSPMessageHeader;
  161. /**
  162. * Client state, i.e. whether we are currently receiving data (PLAYING) or
  163. * setup-but-not-receiving (PAUSED). State can be changed in applications
  164. * by calling av_read_play/pause().
  165. */
  166. enum RTSPClientState {
  167. RTSP_STATE_IDLE, /**< not initialized */
  168. RTSP_STATE_STREAMING, /**< initialized and sending/receiving data */
  169. RTSP_STATE_PAUSED, /**< initialized, but not receiving data */
  170. RTSP_STATE_SEEKING, /**< initialized, requesting a seek */
  171. };
  172. /**
  173. * Identify particular servers that require special handling, such as
  174. * standards-incompliant "Transport:" lines in the SETUP request.
  175. */
  176. enum RTSPServerType {
  177. RTSP_SERVER_RTP, /**< Standards-compliant RTP-server */
  178. RTSP_SERVER_REAL, /**< Realmedia-style server */
  179. RTSP_SERVER_WMS, /**< Windows Media server */
  180. RTSP_SERVER_NB
  181. };
  182. /**
  183. * Private data for the RTSP demuxer.
  184. *
  185. * @todo Use AVIOContext instead of URLContext
  186. */
  187. typedef struct RTSPState {
  188. const AVClass *class; /**< Class for private options. */
  189. URLContext *rtsp_hd; /* RTSP TCP connection handle */
  190. /** number of items in the 'rtsp_streams' variable */
  191. int nb_rtsp_streams;
  192. struct RTSPStream **rtsp_streams; /**< streams in this session */
  193. /** indicator of whether we are currently receiving data from the
  194. * server. Basically this isn't more than a simple cache of the
  195. * last PLAY/PAUSE command sent to the server, to make sure we don't
  196. * send 2x the same unexpectedly or commands in the wrong state. */
  197. enum RTSPClientState state;
  198. /** the seek value requested when calling av_seek_frame(). This value
  199. * is subsequently used as part of the "Range" parameter when emitting
  200. * the RTSP PLAY command. If we are currently playing, this command is
  201. * called instantly. If we are currently paused, this command is called
  202. * whenever we resume playback. Either way, the value is only used once,
  203. * see rtsp_read_play() and rtsp_read_seek(). */
  204. int64_t seek_timestamp;
  205. int seq; /**< RTSP command sequence number */
  206. /** copy of RTSPMessageHeader->session_id, i.e. the server-provided session
  207. * identifier that the client should re-transmit in each RTSP command */
  208. char session_id[512];
  209. /** copy of RTSPMessageHeader->timeout, i.e. the time (in seconds) that
  210. * the server will go without traffic on the RTSP/TCP line before it
  211. * closes the connection. */
  212. int timeout;
  213. /** timestamp of the last RTSP command that we sent to the RTSP server.
  214. * This is used to calculate when to send dummy commands to keep the
  215. * connection alive, in conjunction with timeout. */
  216. int64_t last_cmd_time;
  217. /** the negotiated data/packet transport protocol; e.g. RTP or RDT */
  218. enum RTSPTransport transport;
  219. /** the negotiated network layer transport protocol; e.g. TCP or UDP
  220. * uni-/multicast */
  221. enum RTSPLowerTransport lower_transport;
  222. /** brand of server that we're talking to; e.g. WMS, REAL or other.
  223. * Detected based on the value of RTSPMessageHeader->server or the presence
  224. * of RTSPMessageHeader->real_challenge */
  225. enum RTSPServerType server_type;
  226. /** the "RealChallenge1:" field from the server */
  227. char real_challenge[64];
  228. /** plaintext authorization line (username:password) */
  229. char auth[128];
  230. /** authentication state */
  231. HTTPAuthState auth_state;
  232. /** The last reply of the server to a RTSP command */
  233. char last_reply[2048]; /* XXX: allocate ? */
  234. /** RTSPStream->transport_priv of the last stream that we read a
  235. * packet from */
  236. void *cur_transport_priv;
  237. /** The following are used for Real stream selection */
  238. //@{
  239. /** whether we need to send a "SET_PARAMETER Subscribe:" command */
  240. int need_subscription;
  241. /** stream setup during the last frame read. This is used to detect if
  242. * we need to subscribe or unsubscribe to any new streams. */
  243. enum AVDiscard *real_setup_cache;
  244. /** current stream setup. This is a temporary buffer used to compare
  245. * current setup to previous frame setup. */
  246. enum AVDiscard *real_setup;
  247. /** the last value of the "SET_PARAMETER Subscribe:" RTSP command.
  248. * this is used to send the same "Unsubscribe:" if stream setup changed,
  249. * before sending a new "Subscribe:" command. */
  250. char last_subscription[1024];
  251. //@}
  252. /** The following are used for RTP/ASF streams */
  253. //@{
  254. /** ASF demuxer context for the embedded ASF stream from WMS servers */
  255. AVFormatContext *asf_ctx;
  256. /** cache for position of the asf demuxer, since we load a new
  257. * data packet in the bytecontext for each incoming RTSP packet. */
  258. uint64_t asf_pb_pos;
  259. //@}
  260. /** some MS RTSP streams contain a URL in the SDP that we need to use
  261. * for all subsequent RTSP requests, rather than the input URI; in
  262. * other cases, this is a copy of AVFormatContext->filename. */
  263. char control_uri[1024];
  264. /** The following are used for parsing raw mpegts in udp */
  265. //@{
  266. struct MpegTSContext *ts;
  267. int recvbuf_pos;
  268. int recvbuf_len;
  269. //@}
  270. /** Additional output handle, used when input and output are done
  271. * separately, eg for HTTP tunneling. */
  272. URLContext *rtsp_hd_out;
  273. /** RTSP transport mode, such as plain or tunneled. */
  274. enum RTSPControlTransport control_transport;
  275. /* Number of RTCP BYE packets the RTSP session has received.
  276. * An EOF is propagated back if nb_byes == nb_streams.
  277. * This is reset after a seek. */
  278. int nb_byes;
  279. /** Reusable buffer for receiving packets */
  280. uint8_t* recvbuf;
  281. /**
  282. * A mask with all requested transport methods
  283. */
  284. int lower_transport_mask;
  285. /**
  286. * The number of returned packets
  287. */
  288. uint64_t packets;
  289. /**
  290. * Polling array for udp
  291. */
  292. struct pollfd *p;
  293. int max_p;
  294. /**
  295. * Whether the server supports the GET_PARAMETER method.
  296. */
  297. int get_parameter_supported;
  298. /**
  299. * Do not begin to play the stream immediately.
  300. */
  301. int initial_pause;
  302. /**
  303. * Option flags for the chained RTP muxer.
  304. */
  305. int rtp_muxer_flags;
  306. /** Whether the server accepts the x-Dynamic-Rate header */
  307. int accept_dynamic_rate;
  308. /**
  309. * Various option flags for the RTSP muxer/demuxer.
  310. */
  311. int rtsp_flags;
  312. /**
  313. * Mask of all requested media types
  314. */
  315. int media_type_mask;
  316. /**
  317. * Minimum and maximum local UDP ports.
  318. */
  319. int rtp_port_min, rtp_port_max;
  320. /**
  321. * Timeout to wait for incoming connections.
  322. */
  323. int initial_timeout;
  324. /**
  325. * timeout of socket i/o operations.
  326. */
  327. int stimeout;
  328. /**
  329. * Size of RTP packet reordering queue.
  330. */
  331. int reordering_queue_size;
  332. /**
  333. * User-Agent string
  334. */
  335. char *user_agent;
  336. char default_lang[4];
  337. int buffer_size;
  338. int pkt_size;
  339. } RTSPState;
  340. #define RTSP_FLAG_FILTER_SRC 0x1 /**< Filter incoming UDP packets -
  341. receive packets only from the right
  342. source address and port. */
  343. #define RTSP_FLAG_LISTEN 0x2 /**< Wait for incoming connections. */
  344. #define RTSP_FLAG_CUSTOM_IO 0x4 /**< Do all IO via the AVIOContext. */
  345. #define RTSP_FLAG_RTCP_TO_SOURCE 0x8 /**< Send RTCP packets to the source
  346. address of received packets. */
  347. #define RTSP_FLAG_PREFER_TCP 0x10 /**< Try RTP via TCP first if possible. */
  348. typedef struct RTSPSource {
  349. char addr[128]; /**< Source-specific multicast include source IP address (from SDP content) */
  350. } RTSPSource;
  351. /**
  352. * Describe a single stream, as identified by a single m= line block in the
  353. * SDP content. In the case of RDT, one RTSPStream can represent multiple
  354. * AVStreams. In this case, each AVStream in this set has similar content
  355. * (but different codec/bitrate).
  356. */
  357. typedef struct RTSPStream {
  358. URLContext *rtp_handle; /**< RTP stream handle (if UDP) */
  359. void *transport_priv; /**< RTP/RDT parse context if input, RTP AVFormatContext if output */
  360. /** corresponding stream index, if any. -1 if none (MPEG2TS case) */
  361. int stream_index;
  362. /** interleave IDs; copies of RTSPTransportField->interleaved_min/max
  363. * for the selected transport. Only used for TCP. */
  364. int interleaved_min, interleaved_max;
  365. char control_url[1024]; /**< url for this stream (from SDP) */
  366. /** The following are used only in SDP, not RTSP */
  367. //@{
  368. int sdp_port; /**< port (from SDP content) */
  369. struct sockaddr_storage sdp_ip; /**< IP address (from SDP content) */
  370. int nb_include_source_addrs; /**< Number of source-specific multicast include source IP addresses (from SDP content) */
  371. struct RTSPSource **include_source_addrs; /**< Source-specific multicast include source IP addresses (from SDP content) */
  372. int nb_exclude_source_addrs; /**< Number of source-specific multicast exclude source IP addresses (from SDP content) */
  373. struct RTSPSource **exclude_source_addrs; /**< Source-specific multicast exclude source IP addresses (from SDP content) */
  374. int sdp_ttl; /**< IP Time-To-Live (from SDP content) */
  375. int sdp_payload_type; /**< payload type */
  376. //@}
  377. /** The following are used for dynamic protocols (rtpdec_*.c/rdt.c) */
  378. //@{
  379. /** handler structure */
  380. const RTPDynamicProtocolHandler *dynamic_handler;
  381. /** private data associated with the dynamic protocol */
  382. PayloadContext *dynamic_protocol_context;
  383. //@}
  384. /** Enable sending RTCP feedback messages according to RFC 4585 */
  385. int feedback;
  386. /** SSRC for this stream, to allow identifying RTCP packets before the first RTP packet */
  387. uint32_t ssrc;
  388. char crypto_suite[40];
  389. char crypto_params[100];
  390. } RTSPStream;
  391. void ff_rtsp_parse_line(AVFormatContext *s,
  392. RTSPMessageHeader *reply, const char *buf,
  393. RTSPState *rt, const char *method);
  394. /**
  395. * Send a command to the RTSP server without waiting for the reply.
  396. *
  397. * @see rtsp_send_cmd_with_content_async
  398. */
  399. int ff_rtsp_send_cmd_async(AVFormatContext *s, const char *method,
  400. const char *url, const char *headers);
  401. /**
  402. * Send a command to the RTSP server and wait for the reply.
  403. *
  404. * @param s RTSP (de)muxer context
  405. * @param method the method for the request
  406. * @param url the target url for the request
  407. * @param headers extra header lines to include in the request
  408. * @param reply pointer where the RTSP message header will be stored
  409. * @param content_ptr pointer where the RTSP message body, if any, will
  410. * be stored (length is in reply)
  411. * @param send_content if non-null, the data to send as request body content
  412. * @param send_content_length the length of the send_content data, or 0 if
  413. * send_content is null
  414. *
  415. * @return zero if success, nonzero otherwise
  416. */
  417. int ff_rtsp_send_cmd_with_content(AVFormatContext *s,
  418. const char *method, const char *url,
  419. const char *headers,
  420. RTSPMessageHeader *reply,
  421. unsigned char **content_ptr,
  422. const unsigned char *send_content,
  423. int send_content_length);
  424. /**
  425. * Send a command to the RTSP server and wait for the reply.
  426. *
  427. * @see rtsp_send_cmd_with_content
  428. */
  429. int ff_rtsp_send_cmd(AVFormatContext *s, const char *method,
  430. const char *url, const char *headers,
  431. RTSPMessageHeader *reply, unsigned char **content_ptr);
  432. /**
  433. * Read a RTSP message from the server, or prepare to read data
  434. * packets if we're reading data interleaved over the TCP/RTSP
  435. * connection as well.
  436. *
  437. * @param s RTSP (de)muxer context
  438. * @param reply pointer where the RTSP message header will be stored
  439. * @param content_ptr pointer where the RTSP message body, if any, will
  440. * be stored (length is in reply)
  441. * @param return_on_interleaved_data whether the function may return if we
  442. * encounter a data marker ('$'), which precedes data
  443. * packets over interleaved TCP/RTSP connections. If this
  444. * is set, this function will return 1 after encountering
  445. * a '$'. If it is not set, the function will skip any
  446. * data packets (if they are encountered), until a reply
  447. * has been fully parsed. If no more data is available
  448. * without parsing a reply, it will return an error.
  449. * @param method the RTSP method this is a reply to. This affects how
  450. * some response headers are acted upon. May be NULL.
  451. *
  452. * @return 1 if a data packets is ready to be received, -1 on error,
  453. * and 0 on success.
  454. */
  455. int ff_rtsp_read_reply(AVFormatContext *s, RTSPMessageHeader *reply,
  456. unsigned char **content_ptr,
  457. int return_on_interleaved_data, const char *method);
  458. /**
  459. * Skip a RTP/TCP interleaved packet.
  460. */
  461. void ff_rtsp_skip_packet(AVFormatContext *s);
  462. /**
  463. * Connect to the RTSP server and set up the individual media streams.
  464. * This can be used for both muxers and demuxers.
  465. *
  466. * @param s RTSP (de)muxer context
  467. *
  468. * @return 0 on success, < 0 on error. Cleans up all allocations done
  469. * within the function on error.
  470. */
  471. int ff_rtsp_connect(AVFormatContext *s);
  472. /**
  473. * Close and free all streams within the RTSP (de)muxer
  474. *
  475. * @param s RTSP (de)muxer context
  476. */
  477. void ff_rtsp_close_streams(AVFormatContext *s);
  478. /**
  479. * Close all connection handles within the RTSP (de)muxer
  480. *
  481. * @param s RTSP (de)muxer context
  482. */
  483. void ff_rtsp_close_connections(AVFormatContext *s);
  484. /**
  485. * Get the description of the stream and set up the RTSPStream child
  486. * objects.
  487. */
  488. int ff_rtsp_setup_input_streams(AVFormatContext *s, RTSPMessageHeader *reply);
  489. /**
  490. * Announce the stream to the server and set up the RTSPStream child
  491. * objects for each media stream.
  492. */
  493. int ff_rtsp_setup_output_streams(AVFormatContext *s, const char *addr);
  494. /**
  495. * Parse RTSP commands (OPTIONS, PAUSE and TEARDOWN) during streaming in
  496. * listen mode.
  497. */
  498. int ff_rtsp_parse_streaming_commands(AVFormatContext *s);
  499. /**
  500. * Parse an SDP description of streams by populating an RTSPState struct
  501. * within the AVFormatContext; also allocate the RTP streams and the
  502. * pollfd array used for UDP streams.
  503. */
  504. int ff_sdp_parse(AVFormatContext *s, const char *content);
  505. /**
  506. * Receive one RTP packet from an TCP interleaved RTSP stream.
  507. */
  508. int ff_rtsp_tcp_read_packet(AVFormatContext *s, RTSPStream **prtsp_st,
  509. uint8_t *buf, int buf_size);
  510. /**
  511. * Send buffered packets over TCP.
  512. */
  513. int ff_rtsp_tcp_write_packet(AVFormatContext *s, RTSPStream *rtsp_st);
  514. /**
  515. * Receive one packet from the RTSPStreams set up in the AVFormatContext
  516. * (which should contain a RTSPState struct as priv_data).
  517. */
  518. int ff_rtsp_fetch_packet(AVFormatContext *s, AVPacket *pkt);
  519. /**
  520. * Do the SETUP requests for each stream for the chosen
  521. * lower transport mode.
  522. * @return 0 on success, <0 on error, 1 if protocol is unavailable
  523. */
  524. int ff_rtsp_make_setup_request(AVFormatContext *s, const char *host, int port,
  525. int lower_transport, const char *real_challenge);
  526. /**
  527. * Undo the effect of ff_rtsp_make_setup_request, close the
  528. * transport_priv and rtp_handle fields.
  529. */
  530. void ff_rtsp_undo_setup(AVFormatContext *s, int send_packets);
  531. /**
  532. * Open RTSP transport context.
  533. */
  534. int ff_rtsp_open_transport_ctx(AVFormatContext *s, RTSPStream *rtsp_st);
  535. extern const AVOption ff_rtsp_options[];
  536. #endif /* AVFORMAT_RTSP_H */