Main Page
Related Pages
Modules
Data Structures
Files
Examples
File List
Globals
libavformat
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
37
enum
RTSPLowerTransport
{
38
RTSP_LOWER_TRANSPORT_UDP
= 0,
39
RTSP_LOWER_TRANSPORT_TCP
= 1,
40
RTSP_LOWER_TRANSPORT_UDP_MULTICAST
= 2,
41
RTSP_LOWER_TRANSPORT_NB
,
42
RTSP_LOWER_TRANSPORT_HTTP
= 8,
45
};
46
52
enum
RTSPTransport
{
53
RTSP_TRANSPORT_RTP
,
54
RTSP_TRANSPORT_RDT
,
55
RTSP_TRANSPORT_NB
56
};
57
62
enum
RTSPControlTransport
{
63
RTSP_MODE_PLAIN
,
64
RTSP_MODE_TUNNEL
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
{
87
int
interleaved_min
,
interleaved_max
;
88
91
int
port_min
,
port_max
;
92
95
int
client_port_min
,
client_port_max
;
96
99
int
server_port_min
,
server_port_max
;
100
103
int
ttl
;
104
105
struct
sockaddr_storage
destination
;
106
char
source
[
INET6_ADDRSTRLEN
+ 1];
109
enum
RTSPTransport
transport
;
110
112
enum
RTSPLowerTransport
lower_transport
;
113
}
RTSPTransportField
;
114
118
typedef
struct
RTSPMessageHeader
{
120
int
content_length
;
121
122
enum
RTSPStatusCode
status_code
;
125
int
nb_transports
;
126
129
int64_t
range_start
,
range_end
;
130
133
RTSPTransportField
transports
[
RTSP_MAX_TRANSPORTS
];
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];
174
}
RTSPMessageHeader
;
175
181
enum
RTSPClientState
{
182
RTSP_STATE_IDLE
,
183
RTSP_STATE_STREAMING
,
184
RTSP_STATE_PAUSED
,
185
RTSP_STATE_SEEKING
,
186
};
187
192
enum
RTSPServerType
{
193
RTSP_SERVER_RTP
,
194
RTSP_SERVER_REAL
,
195
RTSP_SERVER_WMS
,
196
RTSP_SERVER_NB
197
};
198
204
typedef
struct
RTSPState
{
205
const
AVClass
*
class
;
206
URLContext
*
rtsp_hd
;
/* RTSP TCP connection handle */
207
209
int
nb_rtsp_streams
;
210
211
struct
RTSPStream
**
rtsp_streams
;
217
enum
RTSPClientState
state
;
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
244
enum
RTSPTransport
transport
;
245
248
enum
RTSPLowerTransport
lower_transport
;
249
253
enum
RTSPServerType
server_type
;
254
256
char
real_challenge
[64];
257
259
char
auth
[128];
260
262
HTTPAuthState
auth_state
;
263
265
char
last_reply
[2048];
/* XXX: allocate ? */
266
269
void
*
cur_transport_priv
;
270
274
int
need_subscription
;
275
278
enum
AVDiscard
*
real_setup_cache
;
279
282
enum
AVDiscard
*
real_setup
;
283
287
char
last_subscription
[1024];
289
293
AVFormatContext
*
asf_ctx
;
294
297
uint64_t
asf_pb_pos
;
299
303
char
control_uri
[1024];
304
307
URLContext
*
rtsp_hd_out
;
308
310
enum
RTSPControlTransport
control_transport
;
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
323
int
lower_transport_mask
;
324
328
uint64_t
packets
;
329
333
struct
pollfd *
p
;
334
338
int
get_parameter_supported
;
339
343
int
initial_pause
;
344
348
int
rtp_muxer_flags
;
349
351
int
accept_dynamic_rate
;
352
356
int
rtsp_flags
;
357
361
int
media_type_mask
;
362
}
RTSPState
;
363
364
#define RTSP_FLAG_FILTER_SRC 0x1
374
typedef struct RTSPStream {
375
URLContext
*
rtp_handle
;
376
void
*
transport_priv
;
379
int
stream_index
;
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
;
392
int
sdp_payload_type
;
394
398
RTPDynamicProtocolHandler
*
dynamic_handler
;
399
401
PayloadContext
*
dynamic_protocol_context
;
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
432
int
ff_rtsp_send_cmd_with_content
(
AVFormatContext
*s,
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
472
int
ff_rtsp_read_reply
(
AVFormatContext
*s,
RTSPMessageHeader
*reply,
473
unsigned
char
**content_ptr,
474
int
return_on_interleaved_data,
const
char
*method);
475
479
void
ff_rtsp_skip_packet
(
AVFormatContext
*s);
480
490
int
ff_rtsp_connect
(
AVFormatContext
*s);
491
497
void
ff_rtsp_close_streams
(
AVFormatContext
*s);
498
504
void
ff_rtsp_close_connections
(
AVFormatContext
*s);
505
510
int
ff_rtsp_setup_input_streams
(
AVFormatContext
*s,
RTSPMessageHeader
*reply);
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
528
int
ff_rtsp_tcp_read_packet
(
AVFormatContext
*s,
RTSPStream
**prtsp_st,
529
uint8_t *buf,
int
buf_size);
530
535
int
ff_rtsp_fetch_packet
(
AVFormatContext
*s,
AVPacket
*pkt);
536
542
int
ff_rtsp_make_setup_request
(
AVFormatContext
*s,
const
char
*host,
int
port,
543
int
lower_transport,
const
char
*real_challenge);
544
549
void
ff_rtsp_undo_setup
(
AVFormatContext
*s);
550
551
extern
const
AVOption
ff_rtsp_options
[];
552
553
#endif
/* AVFORMAT_RTSP_H */