rtsp.h 2.92 KB
Newer Older
1 2 3 4
/*
 * RTSP definitions
 * Copyright (c) 2002 Fabrice Bellard.
 *
5 6 7
 * This file is part of FFmpeg.
 *
 * FFmpeg is free software; you can redistribute it and/or
8 9
 * modify it under the terms of the GNU Lesser General Public
 * 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 14 15 16 17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * 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 22
#ifndef FFMPEG_RTSP_H
#define FFMPEG_RTSP_H
23

24 25
#include <stdint.h>
#include "avformat.h"
26 27 28 29 30 31 32 33 34 35
#include "rtspcodes.h"

enum RTSPProtocol {
    RTSP_PROTOCOL_RTP_UDP = 0,
    RTSP_PROTOCOL_RTP_TCP = 1,
    RTSP_PROTOCOL_RTP_UDP_MULTICAST = 2,
};

#define RTSP_DEFAULT_PORT   554
#define RTSP_MAX_TRANSPORTS 8
36
#define RTSP_TCP_MAX_PACKET_SIZE 1472
37 38 39 40
#define RTSP_DEFAULT_NB_AUDIO_CHANNELS 2
#define RTSP_DEFAULT_AUDIO_SAMPLERATE 44100
#define RTSP_RTP_PORT_MIN 5000
#define RTSP_RTP_PORT_MAX 10000
41 42

typedef struct RTSPTransportField {
43 44 45 46 47 48
    int interleaved_min, interleaved_max;  /**< interleave ids, if TCP transport */
    int port_min, port_max; /**< RTP ports */
    int client_port_min, client_port_max; /**< RTP ports */
    int server_port_min, server_port_max; /**< RTP ports */
    int ttl; /**< ttl value */
    uint32_t destination; /**< destination IP address */
49 50 51 52 53
    enum RTSPProtocol protocol;
} RTSPTransportField;

typedef struct RTSPHeader {
    int content_length;
54
    enum RTSPStatusCode status_code; /**< response code from server */
55
    int nb_transports;
56
    /** in AV_TIME_BASE unit, AV_NOPTS_VALUE if not used */
57
    int64_t range_start, range_end;
58
    RTSPTransportField transports[RTSP_MAX_TRANSPORTS];
59
    int seq; /**< sequence number */
60 61 62
    char session_id[512];
} RTSPHeader;

63
/** the callback can be used to extend the connection setup/teardown step */
64 65 66 67 68 69 70 71
enum RTSPCallbackAction {
    RTSP_ACTION_SERVER_SETUP,
    RTSP_ACTION_SERVER_TEARDOWN,
    RTSP_ACTION_CLIENT_SETUP,
    RTSP_ACTION_CLIENT_TEARDOWN,
};

typedef struct RTSPActionServerSetup {
72
    uint32_t ipaddr;
73 74 75
    char transport_option[512];
} RTSPActionServerSetup;

76
typedef int FFRTSPCallback(enum RTSPCallbackAction action,
77 78 79 80 81 82 83
                           const char *session_id,
                           char *buf, int buf_size,
                           void *arg);

int rtsp_init(void);
void rtsp_parse_line(RTSPHeader *reply, const char *buf);

84
#if LIBAVFORMAT_VERSION_INT < (53 << 16)
85
extern int rtsp_default_protocols;
86
#endif
87 88
extern int rtsp_rtp_port_min;
extern int rtsp_rtp_port_max;
89 90 91

int rtsp_pause(AVFormatContext *s);
int rtsp_resume(AVFormatContext *s);
92

93
#endif /* FFMPEG_RTSP_H */