yading@11: /* yading@11: * RTP definitions yading@11: * Copyright (c) 2002 Fabrice Bellard yading@11: * yading@11: * This file is part of FFmpeg. yading@11: * yading@11: * FFmpeg is free software; you can redistribute it and/or yading@11: * modify it under the terms of the GNU Lesser General Public yading@11: * License as published by the Free Software Foundation; either yading@11: * version 2.1 of the License, or (at your option) any later version. yading@11: * yading@11: * FFmpeg is distributed in the hope that it will be useful, yading@11: * but WITHOUT ANY WARRANTY; without even the implied warranty of yading@11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU yading@11: * Lesser General Public License for more details. yading@11: * yading@11: * You should have received a copy of the GNU Lesser General Public yading@11: * License along with FFmpeg; if not, write to the Free Software yading@11: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA yading@11: */ yading@11: #ifndef AVFORMAT_RTP_H yading@11: #define AVFORMAT_RTP_H yading@11: yading@11: #include "libavformat/avformat.h" yading@11: #include "libavcodec/avcodec.h" yading@11: yading@11: /** yading@11: * Return the payload type for a given stream used in the given format context. yading@11: * Static payload types are derived from the codec. yading@11: * Dynamic payload type are derived from the id field in AVStream. yading@11: * The format context private option payload_type overrides both. yading@11: * yading@11: * @param fmt The context of the format yading@11: * @param codec The context of the codec yading@11: * @param idx The stream index yading@11: * @return The payload type (the 'PT' field in the RTP header). yading@11: */ yading@11: int ff_rtp_get_payload_type(AVFormatContext *fmt, AVCodecContext *codec, yading@11: int idx); yading@11: yading@11: /** yading@11: * Initialize a codec context based on the payload type. yading@11: * yading@11: * Fill the codec_type and codec_id fields of a codec context with yading@11: * information depending on the payload type; for audio codecs, the yading@11: * channels and sample_rate fields are also filled. yading@11: * yading@11: * @param codec The context of the codec yading@11: * @param payload_type The payload type (the 'PT' field in the RTP header) yading@11: * @return In case of unknown payload type or dynamic payload type, a yading@11: * negative value is returned; otherwise, 0 is returned yading@11: */ yading@11: int ff_rtp_get_codec_info(AVCodecContext *codec, int payload_type); yading@11: yading@11: /** yading@11: * Return the encoding name (as defined in yading@11: * http://www.iana.org/assignments/rtp-parameters) for a given payload type. yading@11: * yading@11: * @param payload_type The payload type (the 'PT' field in the RTP header) yading@11: * @return In case of unknown payload type or dynamic payload type, a pointer yading@11: * to an empty string is returned; otherwise, a pointer to a string containing yading@11: * the encoding name is returned yading@11: */ yading@11: const char *ff_rtp_enc_name(int payload_type); yading@11: yading@11: /** yading@11: * Return the codec id for the given encoding name and codec type. yading@11: * yading@11: * @param buf A pointer to the string containing the encoding name yading@11: * @param codec_type The codec type yading@11: * @return In case of unknown encoding name, AV_CODEC_ID_NONE is returned; yading@11: * otherwise, the codec id is returned yading@11: */ yading@11: enum AVCodecID ff_rtp_codec_id(const char *buf, enum AVMediaType codec_type); yading@11: yading@11: #define RTP_PT_PRIVATE 96 yading@11: #define RTP_VERSION 2 yading@11: #define RTP_MAX_SDES 256 /**< maximum text length for SDES */ yading@11: yading@11: /* RTCP packets use 0.5% of the bandwidth */ yading@11: #define RTCP_TX_RATIO_NUM 5 yading@11: #define RTCP_TX_RATIO_DEN 1000 yading@11: yading@11: /* An arbitrary id value for RTP Xiph streams - only relevant to indicate yading@11: * that the configuration has changed within a stream (by changing the yading@11: * ident value sent). yading@11: */ yading@11: #define RTP_XIPH_IDENT 0xfecdba yading@11: yading@11: /* RTCP packet types */ yading@11: enum RTCPType { yading@11: RTCP_FIR = 192, yading@11: RTCP_NACK, // 193 yading@11: RTCP_SMPTETC,// 194 yading@11: RTCP_IJ, // 195 yading@11: RTCP_SR = 200, yading@11: RTCP_RR, // 201 yading@11: RTCP_SDES, // 202 yading@11: RTCP_BYE, // 203 yading@11: RTCP_APP, // 204 yading@11: RTCP_RTPFB,// 205 yading@11: RTCP_PSFB, // 206 yading@11: RTCP_XR, // 207 yading@11: RTCP_AVB, // 208 yading@11: RTCP_RSI, // 209 yading@11: RTCP_TOKEN,// 210 yading@11: }; yading@11: yading@11: #define RTP_PT_IS_RTCP(x) (((x) >= RTCP_FIR && (x) <= RTCP_IJ) || \ yading@11: ((x) >= RTCP_SR && (x) <= RTCP_TOKEN)) yading@11: yading@11: #endif /* AVFORMAT_RTP_H */