FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions | Variables
rtp.c File Reference
#include "libavutil/avstring.h"
#include "libavutil/opt.h"
#include "avformat.h"
#include "rtp.h"

Go to the source code of this file.

Functions

int ff_rtp_get_codec_info (AVCodecContext *codec, int payload_type)
 Initialize a codec context based on the payload type.
 
int ff_rtp_get_payload_type (AVFormatContext *fmt, AVCodecContext *codec, int idx)
 Return the payload type for a given stream used in the given format context.
 
const char * ff_rtp_enc_name (int payload_type)
 Return the encoding name (as defined in http://www.iana.org/assignments/rtp-parameters) for a given payload type.
 
enum AVCodecID ff_rtp_codec_id (const char *buf, enum AVMediaType codec_type)
 Return the codec id for the given encoding name and codec type.
 

Variables

struct {
   int   pt
 
   const char   enc_name [6]
 
   enum AVMediaType   codec_type
 
   enum AVCodecID   codec_id
 
   int   clock_rate
 
   int   audio_channels
 
rtp_payload_types []
 

Function Documentation

int ff_rtp_get_codec_info ( AVCodecContext codec,
int  payload_type 
)

Initialize a codec context based on the payload type.

Fill the codec_type and codec_id fields of a codec context with information depending on the payload type; for audio codecs, the channels and sample_rate fields are also filled.

Parameters
codecThe context of the codec
payload_typeThe payload type (the 'PT' field in the RTP header)
Returns
In case of unknown payload type or dynamic payload type, a negative value is returned; otherwise, 0 is returned

Definition at line 71 of file rtp.c.

int ff_rtp_get_payload_type ( AVFormatContext fmt,
AVCodecContext codec,
int  idx 
)

Return the payload type for a given stream used in the given format context.

Static payload types are derived from the codec. Dynamic payload type are derived from the id field in AVStream. The format context private option payload_type overrides both.

Parameters
fmtThe context of the format
codecThe context of the codec
idxThe stream index
Returns
The payload type (the 'PT' field in the RTP header).

Definition at line 90 of file rtp.c.

Referenced by ff_rtp_chain_mux_open(), and rtp_write_header().

const char* ff_rtp_enc_name ( int  payload_type)

Return the encoding name (as defined in http://www.iana.org/assignments/rtp-parameters) for a given payload type.

Parameters
payload_typeThe payload type (the 'PT' field in the RTP header)
Returns
In case of unknown payload type or dynamic payload type, a pointer to an empty string is returned; otherwise, a pointer to a string containing the encoding name is returned

Definition at line 132 of file rtp.c.

enum AVCodecID ff_rtp_codec_id ( const char *  buf,
enum AVMediaType  codec_type 
)

Return the codec id for the given encoding name and codec type.

Parameters
bufA pointer to the string containing the encoding name
codec_typeThe codec type
Returns
In case of unknown encoding name, AV_CODEC_ID_NONE is returned; otherwise, the codec id is returned

Definition at line 143 of file rtp.c.

Variable Documentation

int pt
const char enc_name[6]

Definition at line 36 of file rtp.c.

Referenced by ff_rtp_codec_id().

enum AVMediaType codec_type
enum AVCodecID codec_id

Definition at line 38 of file rtp.c.

int clock_rate

Definition at line 39 of file rtp.c.

Referenced by ff_rtp_get_codec_info().

int audio_channels

Definition at line 40 of file rtp.c.

Referenced by ff_rtp_get_codec_info(), and new_audio_stream().

struct { ... } rtp_payload_types[]
Initial value:
= {
{0, "PCMU", AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_PCM_MULAW, 8000, 1},
{3, "GSM", AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_NONE, 8000, 1},
{4, "G723", AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_G723_1, 8000, 1},
{5, "DVI4", AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_NONE, 8000, 1},
{6, "DVI4", AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_NONE, 16000, 1},
{7, "LPC", AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_NONE, 8000, 1},
{8, "PCMA", AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_PCM_ALAW, 8000, 1},
{10, "L16", AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_PCM_S16BE, 44100, 2},
{11, "L16", AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_PCM_S16BE, 44100, 1},
{12, "QCELP", AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_QCELP, 8000, 1},
{13, "CN", AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_NONE, 8000, 1},
{14, "MPA", AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_MP2, -1, -1},
{14, "MPA", AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_MP3, -1, -1},
{15, "G728", AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_NONE, 8000, 1},
{16, "DVI4", AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_NONE, 11025, 1},
{17, "DVI4", AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_NONE, 22050, 1},
{18, "G729", AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_NONE, 8000, 1},
{25, "CelB", AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_NONE, 90000, -1},
{26, "JPEG", AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_MJPEG, 90000, -1},
{28, "nv", AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_NONE, 90000, -1},
{31, "H261", AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_H261, 90000, -1},
{32, "MPV", AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_MPEG1VIDEO, 90000, -1},
{32, "MPV", AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_MPEG2VIDEO, 90000, -1},
{33, "MP2T", AVMEDIA_TYPE_DATA, AV_CODEC_ID_MPEG2TS, 90000, -1},
{34, "H263", AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_H263, 90000, -1},
}

Referenced by ff_rtp_codec_id(), ff_rtp_enc_name(), ff_rtp_get_codec_info(), and ff_rtp_get_payload_type().