<refentry id="ortp-RTP-payloads-and-profiles">
<refmeta>
<refentrytitle>RTP payloads and profiles</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>ORTP Library</refmiscinfo>
</refmeta>

<refnamediv>
<refname>RTP payloads and profiles</refname><refpurpose>This section describes the way that the oRTP stack manages RTP profiles and payload types.</refpurpose>
</refnamediv>

<refsynopsisdiv><title>Synopsis</title>

<synopsis>

#include &lt;payloadtype.h&gt;


struct      <link linkend="PayloadType">PayloadType</link>;
struct      <link linkend="RtpProfile">RtpProfile</link>;
extern      RtpProfile <link linkend="av-profile">av_profile</link>;
#define     <link linkend="rtp-profile-clear-all">rtp_profile_clear_all</link>           (profile)
#define     <link linkend="rtp-profile-get-name">rtp_profile_get_name</link>            (profile)
#define     <link linkend="rtp-profile-set-name">rtp_profile_set_name</link>            (profile,nm)
#define     <link linkend="rtp-profile-set-payload">rtp_profile_set_payload</link>         (profile,index,pt)
#define     <link linkend="rtp-profile-get-payload">rtp_profile_get_payload</link>         (profile,index)
#define     <link linkend="rtp-profile-clear-payload">rtp_profile_clear_payload</link>       (profile,index)
#define     <link linkend="rtp-profile-clear-all">rtp_profile_clear_all</link>           (profile)
</synopsis>
</refsynopsisdiv>







<refsect1>
<title>Description</title>
<para>
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 <link linkend="PayloadType">PayloadType</link> 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 <link linkend="RtpProfile">RtpProfile</link> 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 <link linkend="rtp-session-set-profile">rtp_session_set_profile</link>().
</para>
</refsect1>

<refsect1>
<title>Details</title>
<refsect2>
<title><anchor id="PayloadType">struct PayloadType</title>
<programlisting>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;
};
</programlisting>
<para>

</para></refsect2>
<refsect2>
<title><anchor id="RtpProfile">struct RtpProfile</title>
<programlisting>struct RtpProfile {

	char *name;
	PayloadType *payload[127];
};
</programlisting>
<para>

</para></refsect2>
<refsect2>
<title><anchor id="av-profile">av_profile</title>
<programlisting>extern RtpProfile av_profile;
</programlisting>
<para>
This is the Audio Video profile defined in RFC1890.
</para></refsect2>
<refsect2>
<title><anchor id="rtp-profile-clear-all">rtp_profile_clear_all()</title>
<programlisting>#define rtp_profile_clear_all(profile)	memset((void*)(profile),0,sizeof(RtpProfile))
</programlisting>
<para>
Initialize the profile to the empty profile (all payload type are unassigned).</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>profile</parameter>&nbsp;:</term>
<listitem><simpara> an RTP profile (<link linkend="RtpProfile">RtpProfile</link> object)
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="rtp-profile-get-name">rtp_profile_get_name()</title>
<programlisting>#define rtp_profile_get_name(profile) 	(profile)-&gt;name
</programlisting>
<para>
</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>profile</parameter>&nbsp;:</term>
<listitem><simpara>		a rtp profile object (<link linkend="RtpProfile">RtpProfile</link>)
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="rtp-profile-set-name">rtp_profile_set_name()</title>
<programlisting>#define rtp_profile_set_name(profile,nm) 	(profile)-&gt;name=(nm)
</programlisting>
<para>
Set a name to the rtp profile. (This is not required)</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>profile</parameter>&nbsp;:</term>
<listitem><simpara> 	a rtp profile object (<link linkend="RtpProfile">RtpProfile</link>)
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>nm</parameter>&nbsp;:</term>
<listitem><simpara>			a string
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="rtp-profile-set-payload">rtp_profile_set_payload()</title>
<programlisting>#define rtp_profile_set_payload(profile,index,pt)  (profile)-&gt;payload[(index)]=(pt)
</programlisting>
<para>
Assign payload type number <parameter>index</parameter> to payload type desribed in <parameter>pt</parameter> for the RTP profile
<parameter>profile</parameter>.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>profile</parameter>&nbsp;:</term>
<listitem><simpara> an RTP profile (a <link linkend="RtpProfile">RtpProfile</link> object)
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>index</parameter>&nbsp;:</term>
<listitem><simpara>	the payload type number
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>pt</parameter>&nbsp;:</term>
<listitem><simpara>		the payload type description (a <link linkend="PayloadType">PayloadType</link> object )
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="rtp-profile-get-payload">rtp_profile_get_payload()</title>
<programlisting>#define rtp_profile_get_payload(profile,index)	((profile)-&gt;payload[(index)])
</programlisting>
<para>
Gets the payload description of the payload type <parameter>index</parameter> in the profile <parameter>profile</parameter>.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>profile</parameter>&nbsp;:</term>
<listitem><simpara>	an RTP profile (a <link linkend="RtpProfile">RtpProfile</link> object)
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>index</parameter>&nbsp;:</term>
<listitem><simpara>	the payload type number
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="rtp-profile-clear-payload">rtp_profile_clear_payload()</title>
<programlisting>#define rtp_profile_clear_payload(profile,index)	(profile)-&gt;payload[(index)]=NULL
</programlisting>
<para>
Set payload type number <parameter>index</parameter> unassigned in profile <parameter>profile</parameter>.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>profile</parameter>&nbsp;:</term>
<listitem><simpara>	an RTP profile (a <link linkend="RtpProfile">RtpProfile</link> object)
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>index</parameter>&nbsp;:</term>
<listitem><simpara>	the payload type number
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="rtp-profile-clear-all">rtp_profile_clear_all()</title>
<programlisting>#define rtp_profile_clear_all(profile)	memset((void*)(profile),0,sizeof(RtpProfile))
</programlisting>
<para>
Initialize the profile to the empty profile (all payload type are unassigned).</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>profile</parameter>&nbsp;:</term>
<listitem><simpara> an RTP profile (<link linkend="RtpProfile">RtpProfile</link> object)
</simpara></listitem></varlistentry>
</variablelist></refsect2>

</refsect1>



<refsect1>
<title>See Also</title>
<para>
<link linkend="rtp-session-set-profile">rtp_session_set_profile</link>()
</para>
</refsect1>

</refentry>
