Libav
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 
49 };
50 
61 };
62 
70 };
71 
72 #define RTSP_DEFAULT_PORT 554
73 #define RTSP_MAX_TRANSPORTS 8
74 #define RTSP_TCP_MAX_PACKET_SIZE 1472
75 #define RTSP_DEFAULT_NB_AUDIO_CHANNELS 1
76 #define RTSP_DEFAULT_AUDIO_SAMPLERATE 44100
77 #define RTSP_RTP_PORT_MIN 5000
78 #define RTSP_RTP_PORT_MAX 10000
79 
87 typedef struct RTSPTransportField {
93 
97 
101 
105 
108  int ttl;
109 
112 
118 
122 
126 typedef struct RTSPMessageHeader {
129 
134 
138 
142 
143  int seq;
147  char session_id[512];
148 
151  char location[4096];
152 
154  char real_challenge[64];
155 
163  char server[64];
164 
171  int timeout;
172 
176  int notice;
177 
181  char reason[256];
182 
186  char content_type[64];
188 
199 };
200 
210 };
211 
217 typedef struct RTSPState {
218  const AVClass *class;
219  URLContext *rtsp_hd; /* RTSP TCP connection handle */
220 
223 
231 
238  int64_t seek_timestamp;
239 
240  int seq;
244  char session_id[512];
245 
249  int timeout;
250 
254  int64_t last_cmd_time;
255 
258 
262 
267 
269  char real_challenge[64];
270 
272  char auth[128];
273 
276 
278  char last_reply[2048]; /* XXX: allocate ? */
279 
283 
288 
292 
296 
300  char last_subscription[1024];
302 
307 
310  uint64_t asf_pb_pos;
312 
316  char control_uri[1024];
317 
320  struct MpegTSContext *ts;
324 
328 
331 
332  /* Number of RTCP BYE packets the RTSP session has received.
333  * An EOF is propagated back if nb_byes == nb_streams.
334  * This is reset after a seek. */
335  int nb_byes;
336 
339 
344 
348  uint64_t packets;
349 
353  struct pollfd *p;
354 
359 
364 
369 
372 
377 
382 
387 
392 
397 } RTSPState;
398 
399 #define RTSP_FLAG_FILTER_SRC 0x1
402 #define RTSP_FLAG_LISTEN 0x2
403 #define RTSP_FLAG_CUSTOM_IO 0x4
404 #define RTSP_FLAG_RTCP_TO_SOURCE 0x8
407 typedef struct RTSPSource {
408  char addr[128];
409 } RTSPSource;
417 typedef struct RTSPStream {
419  void *transport_priv;
423 
427 
428  char control_url[1024];
432  int sdp_port;
433  struct sockaddr_storage sdp_ip;
438  int sdp_ttl;
446 
450 
452  int feedback;
453 
454  char crypto_suite[40];
455  char crypto_params[100];
456 } RTSPStream;
458 void ff_rtsp_parse_line(RTSPMessageHeader *reply, const char *buf,
459  RTSPState *rt, const char *method);
460 
466 int ff_rtsp_send_cmd_async(AVFormatContext *s, const char *method,
467  const char *url, const char *headers);
468 
486  const char *method, const char *url,
487  const char *headers,
488  RTSPMessageHeader *reply,
489  unsigned char **content_ptr,
490  const unsigned char *send_content,
491  int send_content_length);
492 
498 int ff_rtsp_send_cmd(AVFormatContext *s, const char *method,
499  const char *url, const char *headers,
500  RTSPMessageHeader *reply, unsigned char **content_ptr);
501 
526  unsigned char **content_ptr,
527  int return_on_interleaved_data, const char *method);
528 
533 
544 
551 
558 
564 
570 
576 
582 int ff_sdp_parse(AVFormatContext *s, const char *content);
583 
588  uint8_t *buf, int buf_size);
589 
594 
600 
606 int ff_rtsp_make_setup_request(AVFormatContext *s, const char *host, int port,
607  int lower_transport, const char *real_challenge);
608 
613 void ff_rtsp_undo_setup(AVFormatContext *s, int send_packets);
614 
619 
620 extern const AVOption ff_rtsp_options[];
621 
622 #endif /* AVFORMAT_RTSP_H */