FFmpeg
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 (AVCodecParameters *par, int payload_type)
 Initialize a codec context based on the payload type. More...
 
int ff_rtp_get_payload_type (AVFormatContext *fmt, AVCodecParameters *par, int idx)
 Return the payload type for a given stream used in the given format context. More...
 
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. More...
 
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. More...
 

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

◆ ff_rtp_get_codec_info()

int ff_rtp_get_codec_info ( AVCodecParameters par,
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
parThe codec parameters
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.

◆ ff_rtp_get_payload_type()

int ff_rtp_get_payload_type ( AVFormatContext fmt,
AVCodecParameters par,
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
parThe codec parameters
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().

◆ ff_rtp_enc_name()

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.

◆ ff_rtp_codec_id()

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

◆ pt

int pt

◆ enc_name

const char enc_name[6]
Examples
vaapi_encode.c.

Definition at line 36 of file rtp.c.

Referenced by ff_rtp_codec_id(), and main().

◆ codec_type

enum AVMediaType codec_type

◆ codec_id

enum AVCodecID codec_id

Definition at line 38 of file rtp.c.

Referenced by ff_rtp_get_codec_info(), and ff_rtp_get_payload_type().

◆ clock_rate

int clock_rate

Definition at line 39 of file rtp.c.

Referenced by ff_rtp_get_codec_info().

◆ audio_channels

int audio_channels

Definition at line 40 of file rtp.c.

Referenced by ff_rtp_get_codec_info(), and new_audio_stream().

◆ rtp_payload_types

const { ... } 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().

AV_CODEC_ID_ADPCM_G722
@ AV_CODEC_ID_ADPCM_G722
Definition: avcodec.h:530
AV_CODEC_ID_H261
@ AV_CODEC_ID_H261
Definition: avcodec.h:221
AV_CODEC_ID_PCM_S16BE
@ AV_CODEC_ID_PCM_S16BE
Definition: avcodec.h:464
AV_CODEC_ID_MP3
@ AV_CODEC_ID_MP3
preferred ID for decoding MPEG audio layer 1, 2 or 3
Definition: avcodec.h:565
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
AV_CODEC_ID_MP2
@ AV_CODEC_ID_MP2
Definition: avcodec.h:564
AV_CODEC_ID_PCM_MULAW
@ AV_CODEC_ID_PCM_MULAW
Definition: avcodec.h:469
AVMEDIA_TYPE_DATA
@ AVMEDIA_TYPE_DATA
Opaque data information usually continuous.
Definition: avutil.h:203
AV_CODEC_ID_PCM_ALAW
@ AV_CODEC_ID_PCM_ALAW
Definition: avcodec.h:470
AV_CODEC_ID_G723_1
@ AV_CODEC_ID_G723_1
Definition: avcodec.h:616
AV_CODEC_ID_MPEG2TS
@ AV_CODEC_ID_MPEG2TS
FAKE codec to indicate a raw MPEG-2 TS stream (only used by libavformat)
Definition: avcodec.h:703
AV_CODEC_ID_MPEG1VIDEO
@ AV_CODEC_ID_MPEG1VIDEO
Definition: avcodec.h:219
AV_CODEC_ID_QCELP
@ AV_CODEC_ID_QCELP
Definition: avcodec.h:588
AV_CODEC_ID_H263
@ AV_CODEC_ID_H263
Definition: avcodec.h:222
AVMEDIA_TYPE_UNKNOWN
@ AVMEDIA_TYPE_UNKNOWN
Usually treated as AVMEDIA_TYPE_DATA.
Definition: avutil.h:200
AV_CODEC_ID_MJPEG
@ AV_CODEC_ID_MJPEG
Definition: avcodec.h:225
AV_CODEC_ID_NONE
@ AV_CODEC_ID_NONE
Definition: avcodec.h:216
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AV_CODEC_ID_MPEG2VIDEO
@ AV_CODEC_ID_MPEG2VIDEO
preferred ID for MPEG-1/2 video decoding
Definition: avcodec.h:220