# RTP payloads and profiles

## Name

RTP payloads and profiles -- This section describes the way that the oRTP stack manages RTP profiles and payload types.

## Synopsis

    #include <payloadtype.h>

    struct      PayloadType;
    struct      RtpProfile;
    extern      RtpProfile av_profile;
    #define     rtp_profile_clear_all           (profile)
    #define     rtp_profile_get_name            (profile)
    #define     rtp_profile_set_name            (profile,nm)
    #define     rtp_profile_set_payload         (profile,index,pt)
    #define     rtp_profile_get_payload         (profile,index)
    #define     rtp_profile_clear_payload       (profile,index)
    #define     rtp_profile_clear_all           (profile)

## Description

A rtp payload type is a number between 0 and 127 that identifies a particular payload (GSM, PCMU, MPEG,...) within a given rtp profile. The PayloadType object in oRTP describes a payload. An RTP profile is a table that assigns particular payloads (GSM, MPEG...) to a payload type number within the range 0..127. In oRTP, profiles are represented by the RtpProfile object. For example in the AV profile (Audio Video profile, defined in RFC1890), often used by telephony applications, the payload type number 8 is assigned to PCMA (A-law compressed audio) at sampling frequency 8000 Hz, mono. By default, all RTP sessions created by oRTP use the AV profile, but you can change the profile of an RTP session using rtp_session_set_profile().

## Details

### struct PayloadType

    struct PayloadType {

    	gint type;
    	#define PAYLOAD_AUDIO_CONTINUOUS 0
    	#define PAYLOAD_AUDIO_PACKETIZED 1
    	#define	PAYLOAD_VIDEO 2
    	#define PAYLOAD_OTHER 3  /* ?? */
    	gint clock_rate;
    	double bytes_per_sample;		/* in case of continuous audio data */
    	char *zero_pattern;
    	gint pattern_length;
    	/* other usefull information */
    	gint normal_bitrate;	/*in bit/s */
    	char *mime_type;
    	PayloadTypeFlags flags;
    	void *user_data;
    };

### struct RtpProfile

    struct RtpProfile {

    	char *name;
    	PayloadType *payload[127];
    };

### av_profile

    extern RtpProfile av_profile;

This is the Audio Video profile defined in RFC1890.

### rtp_profile_clear_all()

    #define rtp_profile_clear_all(profile)	memset((void*)(profile),0,sizeof(RtpProfile))

Initialize the profile to the empty profile (all payload type are unassigned).

profile : | an RTP profile (RtpProfile object)

### rtp_profile_get_name()

    #define rtp_profile_get_name(profile) 	(profile)->name

profile : | a rtp profile object (RtpProfile)

### rtp_profile_set_name()

    #define rtp_profile_set_name(profile,nm) 	(profile)->name=(nm)

Set a name to the rtp profile. (This is not required)

profile : | a rtp profile object (RtpProfile)
nm : | a string

### rtp_profile_set_payload()

    #define rtp_profile_set_payload(profile,index,pt)  (profile)->payload[(index)]=(pt)

Assign payload type number index to payload type desribed in pt for the RTP profile profile.

profile : | an RTP profile (a RtpProfile object)
index : | the payload type number
pt : | the payload type description (a PayloadType object )

### rtp_profile_get_payload()

    #define rtp_profile_get_payload(profile,index)	((profile)->payload[(index)])

Gets the payload description of the payload type index in the profile profile.

profile : | an RTP profile (a RtpProfile object)
index : | the payload type number

### rtp_profile_clear_payload()

    #define rtp_profile_clear_payload(profile,index)	(profile)->payload[(index)]=NULL

Set payload type number index unassigned in profile profile.

profile : | an RTP profile (a RtpProfile object)
index : | the payload type number

### rtp_profile_clear_all()

    #define rtp_profile_clear_all(profile)	memset((void*)(profile),0,sizeof(RtpProfile))

Initialize the profile to the empty profile (all payload type are unassigned).

profile : | an RTP profile (RtpProfile object)

## See Also

rtp_session_set_profile()