# 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>

                PayloadType;
                RtpProfile;
    void        rtp_profile_clear_all           (RtpProfile *prof);
    #define     rtp_profile_get_name            (profile)
    void        rtp_profile_set_name            (RtpProfile *prof,
                                                 const char *name);
    void        rtp_profile_set_payload         (RtpProfile *prof,
                                                 int index,
                                                 PayloadType *pt);
    #define     rtp_profile_clear_payload       (profile,index)

## 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

### PayloadType

    typedef struct {
    	int type;
    	#define PAYLOAD_AUDIO_CONTINUOUS 0
    	#define PAYLOAD_AUDIO_PACKETIZED 1
    	#define	PAYLOAD_VIDEO 2
    	#define PAYLOAD_OTHER 3  /* ?? */
    	int clock_rate;
    	char bits_per_sample;		/* in case of continuous audio data */
    	char *zero_pattern;
    	int pattern_length;
    	/* other useful information for the application*/
    	int normal_bitrate;	/*in bit/s */
    	char *mime_type;
    	char *recv_fmtp; /* various format parameters for the incoming stream */
    	char *send_fmtp; /* various format parameters for the outgoing stream */
    	int flags;
    	void *user_data;
    } PayloadType;

### RtpProfile

    typedef struct {
    	char *name;
    	PayloadType *payload[RTP_PROFILE_MAX_PAYLOADS];
    } RtpProfile;

### rtp_profile_clear_all ()

    void        rtp_profile_clear_all           (RtpProfile *prof);

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

`prof` : |

### rtp_profile_get_name()

    #define rtp_profile_get_name(profile) 	(const char*)((profile)->name)

`profile` : | a rtp profile object (RtpProfile)

### rtp_profile_set_name ()

    void        rtp_profile_set_name            (RtpProfile *prof,
                                                 const char *name);

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

`prof` : |
`name` : |

### rtp_profile_set_payload ()

    void        rtp_profile_set_payload         (RtpProfile *prof,
                                                 int index,
                                                 PayloadType *pt);

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

`prof` : |
`index` : | the payload type number
`pt` : | the payload type description (a PayloadType object )

### rtp_profile_clear_payload()

    #define rtp_profile_clear_payload(profile,index)	rtp_profile_set_payload(profile,index,NULL)

Set payload type number `index` unassigned in profile `profile`.

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

## See Also

`rtp_session_set_profile()`