yading@11
|
1 /*
|
yading@11
|
2 * RTP definitions
|
yading@11
|
3 * Copyright (c) 2002 Fabrice Bellard
|
yading@11
|
4 *
|
yading@11
|
5 * This file is part of FFmpeg.
|
yading@11
|
6 *
|
yading@11
|
7 * FFmpeg is free software; you can redistribute it and/or
|
yading@11
|
8 * modify it under the terms of the GNU Lesser General Public
|
yading@11
|
9 * License as published by the Free Software Foundation; either
|
yading@11
|
10 * version 2.1 of the License, or (at your option) any later version.
|
yading@11
|
11 *
|
yading@11
|
12 * FFmpeg is distributed in the hope that it will be useful,
|
yading@11
|
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
yading@11
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
yading@11
|
15 * Lesser General Public License for more details.
|
yading@11
|
16 *
|
yading@11
|
17 * You should have received a copy of the GNU Lesser General Public
|
yading@11
|
18 * License along with FFmpeg; if not, write to the Free Software
|
yading@11
|
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
yading@11
|
20 */
|
yading@11
|
21 #ifndef AVFORMAT_RTP_H
|
yading@11
|
22 #define AVFORMAT_RTP_H
|
yading@11
|
23
|
yading@11
|
24 #include "libavformat/avformat.h"
|
yading@11
|
25 #include "libavcodec/avcodec.h"
|
yading@11
|
26
|
yading@11
|
27 /**
|
yading@11
|
28 * Return the payload type for a given stream used in the given format context.
|
yading@11
|
29 * Static payload types are derived from the codec.
|
yading@11
|
30 * Dynamic payload type are derived from the id field in AVStream.
|
yading@11
|
31 * The format context private option payload_type overrides both.
|
yading@11
|
32 *
|
yading@11
|
33 * @param fmt The context of the format
|
yading@11
|
34 * @param codec The context of the codec
|
yading@11
|
35 * @param idx The stream index
|
yading@11
|
36 * @return The payload type (the 'PT' field in the RTP header).
|
yading@11
|
37 */
|
yading@11
|
38 int ff_rtp_get_payload_type(AVFormatContext *fmt, AVCodecContext *codec,
|
yading@11
|
39 int idx);
|
yading@11
|
40
|
yading@11
|
41 /**
|
yading@11
|
42 * Initialize a codec context based on the payload type.
|
yading@11
|
43 *
|
yading@11
|
44 * Fill the codec_type and codec_id fields of a codec context with
|
yading@11
|
45 * information depending on the payload type; for audio codecs, the
|
yading@11
|
46 * channels and sample_rate fields are also filled.
|
yading@11
|
47 *
|
yading@11
|
48 * @param codec The context of the codec
|
yading@11
|
49 * @param payload_type The payload type (the 'PT' field in the RTP header)
|
yading@11
|
50 * @return In case of unknown payload type or dynamic payload type, a
|
yading@11
|
51 * negative value is returned; otherwise, 0 is returned
|
yading@11
|
52 */
|
yading@11
|
53 int ff_rtp_get_codec_info(AVCodecContext *codec, int payload_type);
|
yading@11
|
54
|
yading@11
|
55 /**
|
yading@11
|
56 * Return the encoding name (as defined in
|
yading@11
|
57 * http://www.iana.org/assignments/rtp-parameters) for a given payload type.
|
yading@11
|
58 *
|
yading@11
|
59 * @param payload_type The payload type (the 'PT' field in the RTP header)
|
yading@11
|
60 * @return In case of unknown payload type or dynamic payload type, a pointer
|
yading@11
|
61 * to an empty string is returned; otherwise, a pointer to a string containing
|
yading@11
|
62 * the encoding name is returned
|
yading@11
|
63 */
|
yading@11
|
64 const char *ff_rtp_enc_name(int payload_type);
|
yading@11
|
65
|
yading@11
|
66 /**
|
yading@11
|
67 * Return the codec id for the given encoding name and codec type.
|
yading@11
|
68 *
|
yading@11
|
69 * @param buf A pointer to the string containing the encoding name
|
yading@11
|
70 * @param codec_type The codec type
|
yading@11
|
71 * @return In case of unknown encoding name, AV_CODEC_ID_NONE is returned;
|
yading@11
|
72 * otherwise, the codec id is returned
|
yading@11
|
73 */
|
yading@11
|
74 enum AVCodecID ff_rtp_codec_id(const char *buf, enum AVMediaType codec_type);
|
yading@11
|
75
|
yading@11
|
76 #define RTP_PT_PRIVATE 96
|
yading@11
|
77 #define RTP_VERSION 2
|
yading@11
|
78 #define RTP_MAX_SDES 256 /**< maximum text length for SDES */
|
yading@11
|
79
|
yading@11
|
80 /* RTCP packets use 0.5% of the bandwidth */
|
yading@11
|
81 #define RTCP_TX_RATIO_NUM 5
|
yading@11
|
82 #define RTCP_TX_RATIO_DEN 1000
|
yading@11
|
83
|
yading@11
|
84 /* An arbitrary id value for RTP Xiph streams - only relevant to indicate
|
yading@11
|
85 * that the configuration has changed within a stream (by changing the
|
yading@11
|
86 * ident value sent).
|
yading@11
|
87 */
|
yading@11
|
88 #define RTP_XIPH_IDENT 0xfecdba
|
yading@11
|
89
|
yading@11
|
90 /* RTCP packet types */
|
yading@11
|
91 enum RTCPType {
|
yading@11
|
92 RTCP_FIR = 192,
|
yading@11
|
93 RTCP_NACK, // 193
|
yading@11
|
94 RTCP_SMPTETC,// 194
|
yading@11
|
95 RTCP_IJ, // 195
|
yading@11
|
96 RTCP_SR = 200,
|
yading@11
|
97 RTCP_RR, // 201
|
yading@11
|
98 RTCP_SDES, // 202
|
yading@11
|
99 RTCP_BYE, // 203
|
yading@11
|
100 RTCP_APP, // 204
|
yading@11
|
101 RTCP_RTPFB,// 205
|
yading@11
|
102 RTCP_PSFB, // 206
|
yading@11
|
103 RTCP_XR, // 207
|
yading@11
|
104 RTCP_AVB, // 208
|
yading@11
|
105 RTCP_RSI, // 209
|
yading@11
|
106 RTCP_TOKEN,// 210
|
yading@11
|
107 };
|
yading@11
|
108
|
yading@11
|
109 #define RTP_PT_IS_RTCP(x) (((x) >= RTCP_FIR && (x) <= RTCP_IJ) || \
|
yading@11
|
110 ((x) >= RTCP_SR && (x) <= RTCP_TOKEN))
|
yading@11
|
111
|
yading@11
|
112 #endif /* AVFORMAT_RTP_H */
|