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

\begin{DoxyCode}{0}
\DoxyCodeLine{1 \textcolor{preprocessor}{\#ifndef \_OSMO\_RTP\_H\_}}
\DoxyCodeLine{2 \textcolor{preprocessor}{\#define \_OSMO\_RTP\_H\_}}
\DoxyCodeLine{3 }
\DoxyCodeLine{4 \textcolor{preprocessor}{\#include <osmocom/core/endian.h>}}
\DoxyCodeLine{5 }
\DoxyCodeLine{6 \textcolor{comment}{/* RTP header as defined by RFC 3550 */}}
\DoxyCodeLine{7 \textcolor{keyword}{struct }rtp\_hdr \{}
\DoxyCodeLine{8 \textcolor{preprocessor}{\#if OSMO\_IS\_LITTLE\_ENDIAN}}
\DoxyCodeLine{9         uint8\_t  csrc\_count:4,}
\DoxyCodeLine{10                  extension:1,}
\DoxyCodeLine{11                  padding:1,}
\DoxyCodeLine{12                  version:2;}
\DoxyCodeLine{13         uint8\_t  payload\_type:7,}
\DoxyCodeLine{14                  marker:1;}
\DoxyCodeLine{15 \textcolor{preprocessor}{\#elif OSMO\_IS\_BIG\_ENDIAN}}
\DoxyCodeLine{16 \textcolor{comment}{/* auto-\/generated from the little endian part above (libosmocore/contrib/struct\_endianness.py) */}}
\DoxyCodeLine{17         uint8\_t  version:2, padding:1, extension:1, csrc\_count:4;}
\DoxyCodeLine{18         uint8\_t  marker:1, payload\_type:7;}
\DoxyCodeLine{19 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{20         uint16\_t sequence;}
\DoxyCodeLine{21         uint32\_t timestamp;}
\DoxyCodeLine{22         uint32\_t ssrc;}
\DoxyCodeLine{23         uint8\_t data[0];}
\DoxyCodeLine{24 \} \_\_attribute\_\_((packed));}
\DoxyCodeLine{25 }
\DoxyCodeLine{26 \textcolor{preprocessor}{\#define RTP\_VERSION     2}}
\DoxyCodeLine{27 }
\DoxyCodeLine{28 \textcolor{comment}{/* 5.3.1 RTP Header Extension}}
\DoxyCodeLine{29 \textcolor{comment}{ *}}
\DoxyCodeLine{30 \textcolor{comment}{ * If the X bit in the RTP header is one, a variable-\/length header}}
\DoxyCodeLine{31 \textcolor{comment}{ * extension MUST be appended to the RTP header, following the CSRC list}}
\DoxyCodeLine{32 \textcolor{comment}{ * if present. The header extension contains a 16-\/bit length field that}}
\DoxyCodeLine{33 \textcolor{comment}{ * counts the number of 32-\/bit words in the extension, excluding the}}
\DoxyCodeLine{34 \textcolor{comment}{ * four-\/octet extension header (therefore zero is a valid length).  Only}}
\DoxyCodeLine{35 \textcolor{comment}{ * a single extension can be appended to the RTP data header.}}
\DoxyCodeLine{36 \textcolor{comment}{ */}}
\DoxyCodeLine{37 \textcolor{keyword}{struct }rtp\_x\_hdr \{}
\DoxyCodeLine{38         uint16\_t by\_profile;}
\DoxyCodeLine{39         uint16\_t length;}
\DoxyCodeLine{40 \} \_\_attribute\_\_((packed));}
\DoxyCodeLine{41 }
\DoxyCodeLine{42 \textcolor{comment}{/* RTPC header. */}}
\DoxyCodeLine{43 \textcolor{keyword}{struct }rtcp\_hdr \{}
\DoxyCodeLine{44         uint8\_t byte0;}
\DoxyCodeLine{45         uint8\_t type;}
\DoxyCodeLine{46         uint16\_t length;}
\DoxyCodeLine{47 \} \_\_attribute\_\_((packed));}
\DoxyCodeLine{48 }
\DoxyCodeLine{49 \textcolor{comment}{/* XXX: RFC specifies that MTU should used, add generic function to obtain}}
\DoxyCodeLine{50 \textcolor{comment}{        existing MTU. */}}
\DoxyCodeLine{51 \textcolor{preprocessor}{\#define RTP\_MSGB\_SIZE  1500}}
\DoxyCodeLine{52 }
\DoxyCodeLine{53 }
\DoxyCodeLine{54 \textcolor{keyword}{struct }msgb;}
\DoxyCodeLine{55 }
\DoxyCodeLine{56 \textcolor{keyword}{struct }osmo\_rtp\_handle *osmo\_rtp\_handle\_create(\textcolor{keywordtype}{void} *ctx);}
\DoxyCodeLine{57 \textcolor{keywordtype}{void} osmo\_rtp\_handle\_free(\textcolor{keyword}{struct} osmo\_rtp\_handle *h);}
\DoxyCodeLine{58 }
\DoxyCodeLine{59 \textcolor{keywordtype}{int} osmo\_rtp\_handle\_tx\_set\_sequence(\textcolor{keyword}{struct} osmo\_rtp\_handle *h, uint16\_t seq);}
\DoxyCodeLine{60 \textcolor{keywordtype}{int} osmo\_rtp\_handle\_tx\_set\_ssrc(\textcolor{keyword}{struct} osmo\_rtp\_handle *h, uint32\_t ssrc);}
\DoxyCodeLine{61 \textcolor{keywordtype}{int} osmo\_rtp\_handle\_tx\_set\_timestamp(\textcolor{keyword}{struct} osmo\_rtp\_handle *h, uint32\_t timestamp);}
\DoxyCodeLine{62 }
\DoxyCodeLine{63 \textcolor{keyword}{struct }rtp\_hdr *osmo\_rtp\_get\_hdr(\textcolor{keyword}{struct} msgb *msg);}
\DoxyCodeLine{64 \textcolor{keywordtype}{void} *osmo\_rtp\_get\_payload(\textcolor{keyword}{struct} rtp\_hdr *rtph, \textcolor{keyword}{struct} msgb *msg, uint32\_t *plen);}
\DoxyCodeLine{65 }
\DoxyCodeLine{66 \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{67 }
\DoxyCodeLine{68 \textcolor{keywordtype}{int} osmo\_rtp\_snprintf(\textcolor{keywordtype}{char} *buf, \textcolor{keywordtype}{size\_t} size, \textcolor{keyword}{struct} msgb *msg);}
\DoxyCodeLine{69 }
\DoxyCodeLine{70 \textcolor{comment}{/* supported RTP payload types. */}}
\DoxyCodeLine{71 \textcolor{preprocessor}{\#define RTP\_PT\_RTCP                     72      }\textcolor{comment}{/* RFC 3551: 72-\/76 for RTCP */}\textcolor{preprocessor}{}}
\DoxyCodeLine{72 }
\DoxyCodeLine{73 \textcolor{preprocessor}{\#define RTP\_PT\_GSM\_FULL                 3}}
\DoxyCodeLine{74 \textcolor{preprocessor}{\#define RTP\_PT\_GSM\_FULL\_PAYLOAD\_LEN     33}}
\DoxyCodeLine{75 \textcolor{preprocessor}{\#define RTP\_PT\_GSM\_FULL\_DURATION        160     }\textcolor{comment}{/* in samples. */}\textcolor{preprocessor}{}}
\DoxyCodeLine{76 }
\DoxyCodeLine{77 \textcolor{preprocessor}{\#define RTP\_PT\_GSM\_HALF                 96}}
\DoxyCodeLine{78 }
\DoxyCodeLine{79 \textcolor{preprocessor}{\#define RTP\_PT\_GSM\_EFR                  97}}
\DoxyCodeLine{80 \textcolor{preprocessor}{\#define RTP\_PT\_GSM\_EFR\_PAYLOAD\_LEN      31}}
\DoxyCodeLine{81 \textcolor{preprocessor}{\#define RTP\_PT\_GSM\_EFR\_DURATION         160     }\textcolor{comment}{/* in samples. */}\textcolor{preprocessor}{}}
\DoxyCodeLine{82 }
\DoxyCodeLine{83 \textcolor{preprocessor}{\#define RTP\_PT\_AMR                      98}}
\DoxyCodeLine{84 }
\DoxyCodeLine{85 \textcolor{preprocessor}{\#define RTP\_PT\_CSDATA                   120     }\textcolor{comment}{/* 3GPP TS 48.103 table 5.4.2.2.1 */}\textcolor{preprocessor}{}}
\DoxyCodeLine{86 }
\DoxyCodeLine{87 \textcolor{preprocessor}{\#endif}}

\end{DoxyCode}
