annotate ffmpeg/libavformat/rtsp.h @ 13:844d341cf643 tip

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