rtsp.h
Go to the documentation of this file.
1 /*
2  * RTSP definitions
3  * Copyright (c) 2002 Fabrice Bellard
4  *
5  * This file is part of Libav.
6  *
7  * Libav 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  * Libav 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 Libav; 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 
24 #include <stdint.h>
25 #include "avformat.h"
26 #include "rtspcodes.h"
27 #include "rtpdec.h"
28 #include "network.h"
29 #include "httpauth.h"
30 
31 #include "libavutil/log.h"
32 #include "libavutil/opt.h"
33 
45 };
46 
56 };
57 
65 };
66 
67 #define RTSP_DEFAULT_PORT 554
68 #define RTSP_MAX_TRANSPORTS 8
69 #define RTSP_TCP_MAX_PACKET_SIZE 1472
70 #define RTSP_DEFAULT_NB_AUDIO_CHANNELS 1
71 #define RTSP_DEFAULT_AUDIO_SAMPLERATE 44100
72 #define RTSP_RTP_PORT_MIN 5000
73 #define RTSP_RTP_PORT_MAX 10000
74 
82 typedef struct RTSPTransportField {
88 
92 
96 
100 
103  int ttl;
104 
110 
114 
118 typedef struct RTSPMessageHeader {
121 
126 
130 
134 
135  int seq;
139  char session_id[512];
140 
143  char location[4096];
144 
146  char real_challenge[64];
147 
155  char server[64];
156 
163  int timeout;
164 
168  int notice;
169 
173  char reason[256];
175 
186 };
187 
197 };
198 
204 typedef struct RTSPState {
205  const AVClass *class;
206  URLContext *rtsp_hd; /* RTSP TCP connection handle */
207 
210 
218 
225  int64_t seek_timestamp;
226 
227  int seq;
231  char session_id[512];
232 
236  int timeout;
237 
241  int64_t last_cmd_time;
242 
245 
249 
254 
256  char real_challenge[64];
257 
259  char auth[128];
260 
263 
265  char last_reply[2048]; /* XXX: allocate ? */
266 
270 
275 
279 
283 
287  char last_subscription[1024];
289 
294 
297  uint64_t asf_pb_pos;
299 
303  char control_uri[1024];
304 
308 
311 
312  /* Number of RTCP BYE packets the RTSP session has received.
313  * An EOF is propagated back if nb_byes == nb_streams.
314  * This is reset after a seek. */
315  int nb_byes;
316 
318  uint8_t* recvbuf;
319 
324 
328  uint64_t packets;
329 
333  struct pollfd *p;
334 
339 
344 
349 
352 
357 
362 } RTSPState;
363 
364 #define RTSP_FLAG_FILTER_SRC 0x1
374 typedef struct RTSPStream {
380 
383  int interleaved_min, interleaved_max;
384 
385  char control_url[1024];
389  int sdp_port;
390  struct sockaddr_storage sdp_ip;
391  int sdp_ttl;
394 
399 
403 } RTSPStream;
404 
405 void ff_rtsp_parse_line(RTSPMessageHeader *reply, const char *buf,
406  RTSPState *rt, const char *method);
407 
413 int ff_rtsp_send_cmd_async(AVFormatContext *s, const char *method,
414  const char *url, const char *headers);
415 
433  const char *method, const char *url,
434  const char *headers,
435  RTSPMessageHeader *reply,
436  unsigned char **content_ptr,
437  const unsigned char *send_content,
438  int send_content_length);
439 
445 int ff_rtsp_send_cmd(AVFormatContext *s, const char *method,
446  const char *url, const char *headers,
447  RTSPMessageHeader *reply, unsigned char **content_ptr);
448 
473  unsigned char **content_ptr,
474  int return_on_interleaved_data, const char *method);
475 
480 
491 
498 
505 
511 
516 int ff_rtsp_setup_output_streams(AVFormatContext *s, const char *addr);
517 
523 int ff_sdp_parse(AVFormatContext *s, const char *content);
524 
529  uint8_t *buf, int buf_size);
530 
536 
542 int ff_rtsp_make_setup_request(AVFormatContext *s, const char *host, int port,
543  int lower_transport, const char *real_challenge);
544 
550 
551 extern const AVOption ff_rtsp_options[];
552 
553 #endif /* AVFORMAT_RTSP_H */