\doxysection{rtp.\+h}
\label{rtp_8h_source}\index{include/osmocom/netif/rtp.h@{include/osmocom/netif/rtp.h}}

\begin{DoxyCode}{0}
\DoxyCodeLine{00001\ \textcolor{preprocessor}{\#ifndef\ \_OSMO\_RTP\_H\_}}
\DoxyCodeLine{00002\ \textcolor{preprocessor}{\#define\ \_OSMO\_RTP\_H\_}}
\DoxyCodeLine{00003\ }
\DoxyCodeLine{00004\ \textcolor{preprocessor}{\#include\ <osmocom/core/endian.h>}}
\DoxyCodeLine{00005\ }
\DoxyCodeLine{00006\ \textcolor{comment}{/*\ RTP\ header\ as\ defined\ by\ RFC\ 3550\ */}}
\DoxyCodeLine{00007\ \textcolor{keyword}{struct\ }rtp\_hdr\ \{}
\DoxyCodeLine{00008\ \textcolor{preprocessor}{\#if\ OSMO\_IS\_LITTLE\_ENDIAN}}
\DoxyCodeLine{00009\ \ \ \ \ \ \ \ \ uint8\_t\ \ csrc\_count:4,}
\DoxyCodeLine{00010\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ extension:1,}
\DoxyCodeLine{00011\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ padding:1,}
\DoxyCodeLine{00012\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ version:2;}
\DoxyCodeLine{00013\ \ \ \ \ \ \ \ \ uint8\_t\ \ payload\_type:7,}
\DoxyCodeLine{00014\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ marker:1;}
\DoxyCodeLine{00015\ \textcolor{preprocessor}{\#elif\ OSMO\_IS\_BIG\_ENDIAN}}
\DoxyCodeLine{00016\ \textcolor{comment}{/*\ auto-\/generated\ from\ the\ little\ endian\ part\ above\ (libosmocore/contrib/struct\_endianness.py)\ */}}
\DoxyCodeLine{00017\ \ \ \ \ \ \ \ \ uint8\_t\ \ version:2,\ padding:1,\ extension:1,\ csrc\_count:4;}
\DoxyCodeLine{00018\ \ \ \ \ \ \ \ \ uint8\_t\ \ marker:1,\ payload\_type:7;}
\DoxyCodeLine{00019\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{00020\ \ \ \ \ \ \ \ \ uint16\_t\ sequence;}
\DoxyCodeLine{00021\ \ \ \ \ \ \ \ \ uint32\_t\ timestamp;}
\DoxyCodeLine{00022\ \ \ \ \ \ \ \ \ uint32\_t\ ssrc;}
\DoxyCodeLine{00023\ \ \ \ \ \ \ \ \ uint8\_t\ data[0];}
\DoxyCodeLine{00024\ \}\ \_\_attribute\_\_((packed));}
\DoxyCodeLine{00025\ }
\DoxyCodeLine{00026\ \textcolor{preprocessor}{\#define\ RTP\_VERSION\ \ \ \ \ 2}}
\DoxyCodeLine{00027\ }
\DoxyCodeLine{00028\ \textcolor{comment}{/*\ 5.3.1\ RTP\ Header\ Extension}}
\DoxyCodeLine{00029\ \textcolor{comment}{\ *}}
\DoxyCodeLine{00030\ \textcolor{comment}{\ *\ If\ the\ X\ bit\ in\ the\ RTP\ header\ is\ one,\ a\ variable-\/length\ header}}
\DoxyCodeLine{00031\ \textcolor{comment}{\ *\ extension\ MUST\ be\ appended\ to\ the\ RTP\ header,\ following\ the\ CSRC\ list}}
\DoxyCodeLine{00032\ \textcolor{comment}{\ *\ if\ present.\ The\ header\ extension\ contains\ a\ 16-\/bit\ length\ field\ that}}
\DoxyCodeLine{00033\ \textcolor{comment}{\ *\ counts\ the\ number\ of\ 32-\/bit\ words\ in\ the\ extension,\ excluding\ the}}
\DoxyCodeLine{00034\ \textcolor{comment}{\ *\ four-\/octet\ extension\ header\ (therefore\ zero\ is\ a\ valid\ length).\ \ Only}}
\DoxyCodeLine{00035\ \textcolor{comment}{\ *\ a\ single\ extension\ can\ be\ appended\ to\ the\ RTP\ data\ header.}}
\DoxyCodeLine{00036\ \textcolor{comment}{\ */}}
\DoxyCodeLine{00037\ \textcolor{keyword}{struct\ }rtp\_x\_hdr\ \{}
\DoxyCodeLine{00038\ \ \ \ \ \ \ \ \ uint16\_t\ by\_profile;}
\DoxyCodeLine{00039\ \ \ \ \ \ \ \ \ uint16\_t\ length;}
\DoxyCodeLine{00040\ \}\ \_\_attribute\_\_((packed));}
\DoxyCodeLine{00041\ }
\DoxyCodeLine{00042\ \textcolor{comment}{/*\ RTPC\ header.\ */}}
\DoxyCodeLine{00043\ \textcolor{keyword}{struct\ }rtcp\_hdr\ \{}
\DoxyCodeLine{00044\ \ \ \ \ \ \ \ \ uint8\_t\ byte0;}
\DoxyCodeLine{00045\ \ \ \ \ \ \ \ \ uint8\_t\ type;}
\DoxyCodeLine{00046\ \ \ \ \ \ \ \ \ uint16\_t\ length;}
\DoxyCodeLine{00047\ \}\ \_\_attribute\_\_((packed));}
\DoxyCodeLine{00048\ }
\DoxyCodeLine{00049\ \textcolor{comment}{/*\ XXX:\ RFC\ specifies\ that\ MTU\ should\ used,\ add\ generic\ function\ to\ obtain}}
\DoxyCodeLine{00050\ \textcolor{comment}{\ \ \ \ \ \ \ \ existing\ MTU.\ */}}
\DoxyCodeLine{00051\ \textcolor{preprocessor}{\#define\ RTP\_MSGB\_SIZE\ \ 1500}}
\DoxyCodeLine{00052\ }
\DoxyCodeLine{00053\ }
\DoxyCodeLine{00054\ \textcolor{keyword}{struct\ }msgb;}
\DoxyCodeLine{00055\ }
\DoxyCodeLine{00056\ \textcolor{keyword}{struct\ }osmo\_rtp\_handle\ *osmo\_rtp\_handle\_create(\textcolor{keywordtype}{void}\ *ctx);}
\DoxyCodeLine{00057\ \textcolor{keywordtype}{void}\ osmo\_rtp\_handle\_free(\textcolor{keyword}{struct}\ osmo\_rtp\_handle\ *h);}
\DoxyCodeLine{00058\ }
\DoxyCodeLine{00059\ \textcolor{keywordtype}{int}\ osmo\_rtp\_handle\_tx\_set\_sequence(\textcolor{keyword}{struct}\ osmo\_rtp\_handle\ *h,\ uint16\_t\ seq);}
\DoxyCodeLine{00060\ \textcolor{keywordtype}{int}\ osmo\_rtp\_handle\_tx\_set\_ssrc(\textcolor{keyword}{struct}\ osmo\_rtp\_handle\ *h,\ uint32\_t\ ssrc);}
\DoxyCodeLine{00061\ \textcolor{keywordtype}{int}\ osmo\_rtp\_handle\_tx\_set\_timestamp(\textcolor{keyword}{struct}\ osmo\_rtp\_handle\ *h,\ uint32\_t\ timestamp);}
\DoxyCodeLine{00062\ }
\DoxyCodeLine{00063\ \textcolor{keyword}{struct\ }rtp\_hdr\ *osmo\_rtp\_get\_hdr(\textcolor{keyword}{struct}\ msgb\ *msg);}
\DoxyCodeLine{00064\ \textcolor{keywordtype}{void}\ *osmo\_rtp\_get\_payload(\textcolor{keyword}{struct}\ rtp\_hdr\ *rtph,\ \textcolor{keyword}{struct}\ msgb\ *msg,\ uint32\_t\ *plen);}
\DoxyCodeLine{00065\ }
\DoxyCodeLine{00066\ \textcolor{keyword}{struct\ }msgb\ *osmo\_rtp\_build(\textcolor{keyword}{struct}\ osmo\_rtp\_handle\ *h,\ uint8\_t\ payload\_type,\ uint32\_t\ payload\_len,\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{void}\ *data,\ uint32\_t\ duration);}
\DoxyCodeLine{00067\ }
\DoxyCodeLine{00068\ \textcolor{keywordtype}{int}\ osmo\_rtp\_snprintf(\textcolor{keywordtype}{char}\ *buf,\ \textcolor{keywordtype}{size\_t}\ size,\ \textcolor{keyword}{struct}\ msgb\ *msg);}
\DoxyCodeLine{00069\ }
\DoxyCodeLine{00070\ \textcolor{comment}{/*\ supported\ RTP\ payload\ types.\ */}}
\DoxyCodeLine{00071\ \textcolor{preprocessor}{\#define\ RTP\_PT\_RTCP\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 72\ \ \ \ \ \ }\textcolor{comment}{/*\ RFC\ 3551:\ 72-\/76\ for\ RTCP\ */}\textcolor{preprocessor}{}}
\DoxyCodeLine{00072\ }
\DoxyCodeLine{00073\ \textcolor{preprocessor}{\#define\ RTP\_PT\_GSM\_FULL\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 3}}
\DoxyCodeLine{00074\ \textcolor{preprocessor}{\#define\ RTP\_PT\_GSM\_FULL\_PAYLOAD\_LEN\ \ \ \ \ 33}}
\DoxyCodeLine{00075\ \textcolor{preprocessor}{\#define\ RTP\_PT\_GSM\_FULL\_DURATION\ \ \ \ \ \ \ \ 160\ \ \ \ \ }\textcolor{comment}{/*\ in\ samples.\ */}\textcolor{preprocessor}{}}
\DoxyCodeLine{00076\ }
\DoxyCodeLine{00077\ \textcolor{preprocessor}{\#define\ RTP\_PT\_GSM\_HALF\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 96}}
\DoxyCodeLine{00078\ }
\DoxyCodeLine{00079\ \textcolor{preprocessor}{\#define\ RTP\_PT\_GSM\_EFR\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 97}}
\DoxyCodeLine{00080\ \textcolor{preprocessor}{\#define\ RTP\_PT\_GSM\_EFR\_PAYLOAD\_LEN\ \ \ \ \ \ 31}}
\DoxyCodeLine{00081\ \textcolor{preprocessor}{\#define\ RTP\_PT\_GSM\_EFR\_DURATION\ \ \ \ \ \ \ \ \ 160\ \ \ \ \ }\textcolor{comment}{/*\ in\ samples.\ */}\textcolor{preprocessor}{}}
\DoxyCodeLine{00082\ }
\DoxyCodeLine{00083\ \textcolor{preprocessor}{\#define\ RTP\_PT\_AMR\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 98}}
\DoxyCodeLine{00084\ }
\DoxyCodeLine{00085\ \textcolor{preprocessor}{\#define\ RTP\_PT\_CSDATA\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 120\ \ \ \ \ }\textcolor{comment}{/*\ 3GPP\ TS\ 48.103\ table\ 5.4.2.2.1\ */}\textcolor{preprocessor}{}}
\DoxyCodeLine{00086\ }
\DoxyCodeLine{00087\ \textcolor{preprocessor}{\#endif}}

\end{DoxyCode}
