1923acbbc80181802bd119379932ff0170272f85
[libav.git] / libavformat / rtsp.h
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 FFMPEG_RTSP_H
22 #define FFMPEG_RTSP_H
23
24 #include <stdint.h>
25 #include "avformat.h"
26 #include "rtspcodes.h"
27
28 enum RTSPProtocol {
29 RTSP_PROTOCOL_RTP_UDP = 0,
30 RTSP_PROTOCOL_RTP_TCP = 1,
31 RTSP_PROTOCOL_RTP_UDP_MULTICAST = 2,
32 /**
33 * This is not part of public API and shouldn't be used outside of ffmpeg.
34 */
35 RTSP_PROTOCOL_RTP_LAST
36 };
37
38 #define RTSP_DEFAULT_PORT 554
39 #define RTSP_MAX_TRANSPORTS 8
40 #define RTSP_TCP_MAX_PACKET_SIZE 1472
41 #define RTSP_DEFAULT_NB_AUDIO_CHANNELS 2
42 #define RTSP_DEFAULT_AUDIO_SAMPLERATE 44100
43 #define RTSP_RTP_PORT_MIN 5000
44 #define RTSP_RTP_PORT_MAX 10000
45
46 typedef struct RTSPTransportField {
47 int interleaved_min, interleaved_max; /**< interleave ids, if TCP transport */
48 int port_min, port_max; /**< RTP ports */
49 int client_port_min, client_port_max; /**< RTP ports */
50 int server_port_min, server_port_max; /**< RTP ports */
51 int ttl; /**< ttl value */
52 uint32_t destination; /**< destination IP address */
53 enum RTSPProtocol protocol;
54 } RTSPTransportField;
55
56 typedef struct RTSPHeader {
57 int content_length;
58 enum RTSPStatusCode status_code; /**< response code from server */
59 int nb_transports;
60 /** in AV_TIME_BASE unit, AV_NOPTS_VALUE if not used */
61 int64_t range_start, range_end;
62 RTSPTransportField transports[RTSP_MAX_TRANSPORTS];
63 int seq; /**< sequence number */
64 char session_id[512];
65 char real_challenge[64]; /**< the RealChallenge1 field from the server */
66 } RTSPHeader;
67
68 /** the callback can be used to extend the connection setup/teardown step */
69 enum RTSPCallbackAction {
70 RTSP_ACTION_SERVER_SETUP,
71 RTSP_ACTION_SERVER_TEARDOWN,
72 RTSP_ACTION_CLIENT_SETUP,
73 RTSP_ACTION_CLIENT_TEARDOWN,
74 };
75
76 typedef struct RTSPActionServerSetup {
77 uint32_t ipaddr;
78 char transport_option[512];
79 } RTSPActionServerSetup;
80
81 typedef int FFRTSPCallback(enum RTSPCallbackAction action,
82 const char *session_id,
83 char *buf, int buf_size,
84 void *arg);
85
86 int rtsp_init(void);
87 void rtsp_parse_line(RTSPHeader *reply, const char *buf);
88
89 #if LIBAVFORMAT_VERSION_INT < (53 << 16)
90 extern int rtsp_default_protocols;
91 #endif
92 extern int rtsp_rtp_port_min;
93 extern int rtsp_rtp_port_max;
94
95 int rtsp_pause(AVFormatContext *s);
96 int rtsp_resume(AVFormatContext *s);
97
98 #endif /* FFMPEG_RTSP_H */