\doxysection{Themyscira Wireless RTP endpoint implementation}
\label{group__twrtp}\index{Themyscira Wireless RTP endpoint implementation@{Themyscira Wireless RTP endpoint implementation}}


osmo\+\_\+twrtp is a complete RTP endpoint.  


\doxysubsubsection*{Data Structures}
\begin{DoxyCompactItemize}
\item 
struct \textbf{ osmo\+\_\+twrtp\+\_\+stats}
\begin{DoxyCompactList}\small\item\em Stats collected during the lifetime of a twrtp instance. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsubsection*{Typedefs}
\begin{DoxyCompactItemize}
\item 
\label{group__twrtp_ga67d808ff514c37233fdb12fcb4b293be} 
typedef bool($\ast$ {\bfseries osmo\+\_\+twrtp\+\_\+raw\+\_\+rx\+\_\+cb}) (struct osmo\+\_\+twrtp $\ast$endp, void $\ast$user\+\_\+data, struct msgb $\ast$msg)
\end{DoxyCompactItemize}
\doxysubsubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
struct osmo\+\_\+twrtp $\ast$ \textbf{ osmo\+\_\+twrtp\+\_\+create} (void $\ast$ctx, uint16\+\_\+t clock\+\_\+khz, uint16\+\_\+t quantum\+\_\+ms, bool random\+\_\+ts\+\_\+seq, const struct osmo\+\_\+twjit\+\_\+config $\ast$twjit\+\_\+config)
\begin{DoxyCompactList}\small\item\em \textbackslash{}addgroup twrtp \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+twrtp\+\_\+destroy} (struct osmo\+\_\+twrtp $\ast$endp)
\begin{DoxyCompactList}\small\item\em Destroy a twrtp endpoint. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+twrtp\+\_\+supply\+\_\+fds} (struct osmo\+\_\+twrtp $\ast$endp, int rtp\+\_\+fd, int rtcp\+\_\+fd)
\begin{DoxyCompactList}\small\item\em Equip twrtp endpoint with RTP and RTCP sockets (supplied file descriptors) \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+twrtp\+\_\+bind\+\_\+local} (struct osmo\+\_\+twrtp $\ast$endp, const struct osmo\+\_\+sockaddr $\ast$rtp\+\_\+addr, bool bind\+\_\+rtcp)
\begin{DoxyCompactList}\small\item\em Equip twrtp endpoint with locally bound RTP and RTCP sockets. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+twrtp\+\_\+set\+\_\+remote} (struct osmo\+\_\+twrtp $\ast$endp, const struct osmo\+\_\+sockaddr $\ast$rtp\+\_\+addr)
\begin{DoxyCompactList}\small\item\em Set RTP remote address. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+twrtp\+\_\+twjit\+\_\+rx\+\_\+ctrl} (struct osmo\+\_\+twrtp $\ast$endp, bool rx\+\_\+enable)
\begin{DoxyCompactList}\small\item\em Enable or disable Rx via twjit. \end{DoxyCompactList}\item 
struct msgb $\ast$ \textbf{ osmo\+\_\+twrtp\+\_\+twjit\+\_\+rx\+\_\+poll} (struct osmo\+\_\+twrtp $\ast$endp)
\begin{DoxyCompactList}\small\item\em Fixed-\/timing output poll from the twrtp endpoint\textquotesingle{}s twjit buffer. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+twrtp\+\_\+set\+\_\+raw\+\_\+rx\+\_\+cb} (struct osmo\+\_\+twrtp $\ast$endp, osmo\+\_\+twrtp\+\_\+raw\+\_\+rx\+\_\+cb cb, void $\ast$user\+\_\+data)
\begin{DoxyCompactList}\small\item\em Set callback function for unbuffered/non-\/delayed Rx path. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+twrtp\+\_\+tx\+\_\+quantum} (struct osmo\+\_\+twrtp $\ast$endp, const uint8\+\_\+t $\ast$payload, unsigned payload\+\_\+len, uint8\+\_\+t payload\+\_\+type, bool marker, bool auto\+\_\+marker, bool send\+\_\+rtcp)
\begin{DoxyCompactList}\small\item\em Emit RTP packet carrying a locally sourced quantum of speech/data. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+twrtp\+\_\+tx\+\_\+skip} (struct osmo\+\_\+twrtp $\ast$endp)
\begin{DoxyCompactList}\small\item\em Incur an intentional gap in the emitted RTP stream. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+twrtp\+\_\+tx\+\_\+restart} (struct osmo\+\_\+twrtp $\ast$endp)
\begin{DoxyCompactList}\small\item\em Reset output stream cadence. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+twrtp\+\_\+tx\+\_\+forward} (struct osmo\+\_\+twrtp $\ast$endp, struct msgb $\ast$msg)
\begin{DoxyCompactList}\small\item\em Forward RTP packet between endpoints. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+twrtp\+\_\+set\+\_\+sdes} (struct osmo\+\_\+twrtp $\ast$endp, const char $\ast$cname, const char $\ast$name, const char $\ast$email, const char $\ast$phone, const char $\ast$loc, const char $\ast$tool, const char $\ast$note)
\begin{DoxyCompactList}\small\item\em Set SDES strings for RTCP SR and RR packet generation. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+twrtp\+\_\+set\+\_\+auto\+\_\+rtcp\+\_\+interval} (struct osmo\+\_\+twrtp $\ast$endp, uint16\+\_\+t interval)
\begin{DoxyCompactList}\small\item\em Configure automatic emission of periodic RTCP SR packets. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+twrtp\+\_\+send\+\_\+rtcp\+\_\+rr} (struct osmo\+\_\+twrtp $\ast$endp)
\begin{DoxyCompactList}\small\item\em Emit RTCP RR packet. \end{DoxyCompactList}\item 
struct osmo\+\_\+twjit $\ast$ \textbf{ osmo\+\_\+twrtp\+\_\+get\+\_\+twjit} (struct osmo\+\_\+twrtp $\ast$endp)
\begin{DoxyCompactList}\small\item\em Get twjit from twrtp. \end{DoxyCompactList}\item 
const struct \textbf{ osmo\+\_\+twrtp\+\_\+stats} $\ast$ \textbf{ osmo\+\_\+twrtp\+\_\+get\+\_\+stats} (struct osmo\+\_\+twrtp $\ast$endp)
\begin{DoxyCompactList}\small\item\em Retrieve lifetime stats from twrtp instance. \end{DoxyCompactList}\item 
bool \textbf{ osmo\+\_\+twrtp\+\_\+got\+\_\+rtcp\+\_\+rr} (struct osmo\+\_\+twrtp $\ast$endp)
\begin{DoxyCompactList}\small\item\em Have we received any RTCP RR? \end{DoxyCompactList}\item 
uint32\+\_\+t \textbf{ osmo\+\_\+twrtp\+\_\+rr\+\_\+lost\+\_\+word} (struct osmo\+\_\+twrtp $\ast$endp)
\begin{DoxyCompactList}\small\item\em Info from received RTCP RR\+: lost packets word. \end{DoxyCompactList}\item 
int32\+\_\+t \textbf{ osmo\+\_\+twrtp\+\_\+rr\+\_\+lost\+\_\+cumulative} (struct osmo\+\_\+twrtp $\ast$endp)
\begin{DoxyCompactList}\small\item\em Info from received RTCP RR\+: cumulative number of packets lost. \end{DoxyCompactList}\item 
uint32\+\_\+t \textbf{ osmo\+\_\+twrtp\+\_\+rr\+\_\+jitter\+\_\+last} (struct osmo\+\_\+twrtp $\ast$endp)
\begin{DoxyCompactList}\small\item\em Info from received RTCP RR\+: interarrival jitter, most recent. \end{DoxyCompactList}\item 
uint32\+\_\+t \textbf{ osmo\+\_\+twrtp\+\_\+rr\+\_\+jitter\+\_\+max} (struct osmo\+\_\+twrtp $\ast$endp)
\begin{DoxyCompactList}\small\item\em Info from received RTCP RR\+: interarrival jitter, highest received. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+twrtp\+\_\+get\+\_\+rtp\+\_\+fd} (struct osmo\+\_\+twrtp $\ast$endp)
\begin{DoxyCompactList}\small\item\em Retrieve file descriptor for RTP UDP socket. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+twrtp\+\_\+get\+\_\+rtcp\+\_\+fd} (struct osmo\+\_\+twrtp $\ast$endp)
\begin{DoxyCompactList}\small\item\em Retrieve file descriptor for RTCP UDP socket. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+twrtp\+\_\+set\+\_\+dscp} (struct osmo\+\_\+twrtp $\ast$endp, uint8\+\_\+t dscp)
\begin{DoxyCompactList}\small\item\em Set DSCP (Differentiated Services Code Point) for emitted RTP and RTCP packets. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+twrtp\+\_\+set\+\_\+socket\+\_\+prio} (struct osmo\+\_\+twrtp $\ast$endp, int prio)
\begin{DoxyCompactList}\small\item\em Set socket priority for emitted RTP and RTCP packets. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
osmo\+\_\+twrtp is a complete RTP endpoint. 

It is primarily designed to be used together with twjit to build a bidirectional interface between an RTP stream and a fixed timing system such as GSM Um TCH or T1/\+E1 Abis, but it also has limited support for endpoints without twjit. A twrtp endpoint without twjit is either an output-\/only endpoint (playout of in-\/band tones and announcements etc), or one side of a pair of endpoints that forward RTP packets to each other without delay.

The basic workflow is\+:


\begin{DoxyEnumerate}
\item Create a twrtp instance with \doxyref{osmo\+\_\+twrtp\+\_\+create()}{p.}{group__twrtp_gacf8121473c5a45b5710a0b95d8e16575}. The decision to use or not use twjit is fixed at this time; if twjit is to be used, struct osmo\+\_\+twjit\+\_\+config needs to be provided.
\item Create and bind a pair of local UDP sockets for RTP and RTCP, or supply osmo\+\_\+twrtp with an already-\/obtained pair of file descriptors for the same. Most users will find the high-\/level API \doxyref{osmo\+\_\+twrtp\+\_\+bind\+\_\+local()}{p.}{group__twrtp_gaaebac4722d129a840d35a3d0c0aa63a7} most suitable, but some applications may prefer to use the low-\/level API \doxyref{osmo\+\_\+twrtp\+\_\+supply\+\_\+fds()}{p.}{group__twrtp_ga1d22a40f737ead143bfca1d75259aba2} instead.
\item Set the IP\+:port address of the remote RTP end with \doxyref{osmo\+\_\+twrtp\+\_\+set\+\_\+remote()}{p.}{group__twrtp_gaa712a64e760d07cc5c22cbf2d5772ce9}.
\item Traffic can now be sent and received as detailed below.
\end{DoxyEnumerate}

Receiving RTP traffic, interworking to a fixed timing system\+:


\begin{DoxyEnumerate}
\item Provide struct osmo\+\_\+twjit\+\_\+config to \doxyref{osmo\+\_\+twrtp\+\_\+create()}{p.}{group__twrtp_gacf8121473c5a45b5710a0b95d8e16575}, so the twrtp instance will be created with twjit included.
\item When you are ready to start receiving traffic, call \doxyref{osmo\+\_\+twrtp\+\_\+twjit\+\_\+rx\+\_\+ctrl()}{p.}{group__twrtp_gaaf8aa5a57b46f846b865cb370b36a52e} with rx\+\_\+enable argument set to true.
\item Once you\textquotesingle{}ve made the above call, commit to calling \doxyref{osmo\+\_\+twrtp\+\_\+twjit\+\_\+rx\+\_\+poll()}{p.}{group__twrtp_gacaa8b25a610a5ed982eba709a516c3e2} every 20 ms (or whatever your quantum duration is) as timed by your GSM Um TCH or TDM system, every tick without fail.
\item You can pause operation by calling \doxyref{osmo\+\_\+twrtp\+\_\+twjit\+\_\+rx\+\_\+ctrl()}{p.}{group__twrtp_gaaf8aa5a57b46f846b865cb370b36a52e} with rx\+\_\+enable argument set to false, and then later restart by returning to step 2 above. When you pause, the Rx jitter buffer will be flushed, and when you restart Rx, twjit will restart from empty state.
\end{DoxyEnumerate}

Sending RTP traffic, coming from a fixed timing system\+:


\begin{DoxyEnumerate}
\item Make the first call to \doxyref{osmo\+\_\+twrtp\+\_\+tx\+\_\+quantum()}{p.}{group__twrtp_gae20168f9074f530ae0d9270697fadaeb} whenever you are ready to send out the first quantum.
\item Once you\textquotesingle{}ve made that first call, commit to sending either another quantum or an intentional gap (\doxyref{osmo\+\_\+twrtp\+\_\+tx\+\_\+skip()}{p.}{group__twrtp_ga971ca670aa852281620c69cbd69a57e8}) every 20 ms without fail, as timed by your GSM Um TCH, T1/\+E1 TDM or other fixed timing system.
\item If you need to pause Tx output and restart later, or if some discontinuity occurs in your fixed timing system where you know that your interval between quantum sends is not the proper 20 ms or whatever your quantum duration is, call \doxyref{osmo\+\_\+twrtp\+\_\+tx\+\_\+restart()}{p.}{group__twrtp_ga2e365e51cc37adb56a77b9c2bfa26683}, telling the library to reset the RTP timescale in its subsequent output.
\end{DoxyEnumerate}

No-\/delay forwarding operation from one twrtp endpoint to another\+:


\begin{DoxyEnumerate}
\item On the receiving side, call \doxyref{osmo\+\_\+twrtp\+\_\+set\+\_\+raw\+\_\+rx\+\_\+cb()}{p.}{group__twrtp_ga98fce03a5a6dd6a58759c43b3ecb536b} to set up an unbuffered/non-\/delayed Rx callback function.
\item In that Rx callback function, forward the packet to the other endpoint with \doxyref{osmo\+\_\+twrtp\+\_\+tx\+\_\+forward()}{p.}{group__twrtp_ga2907d4ec5bdd2bbb32f37d72b3275d94}.
\item If you are building an MGW that mostly does forwarding as described here, but occasionally inserts its own in-\/band tones or announcements, you can switch in real time between just-\/described forwarding and "{}native"{} \doxyref{osmo\+\_\+twrtp\+\_\+tx\+\_\+quantum()}{p.}{group__twrtp_gae20168f9074f530ae0d9270697fadaeb} output. The receiving RTP end will see "{}handover"{} events as SSRC switches between the one emitted by twrtp and the one coming from the other remote party. Actual timing will also switch, as there is no realistic way your own 20 ms timing for announcement playout will exactly match the timing of the RTP stream switched from the other remote party.
\end{DoxyEnumerate}

RTCP handling is mostly internal to the library -\/ as a user, you don\textquotesingle{}t need to concern yourself with it. More precisely, incoming RTCP packets are always handled internally; if you wish to send out RTCP, you have to set SDES and decide if you wish to send out SR or RR packets. Automatic emission of an SR packet after every so many RTP packets, with an RR block included in that SR, is the most common and most useful mode. OTOH, if your RTP application does not use RTCP, you don\textquotesingle{}t need to concern yourself with RTCP at all\+: don\textquotesingle{}t configure or enable RTCP sending, and ignore the existence of the built-\/in RTCP receiver. Any received RTCP packets will still be parsed, but you can ignore the data that result from this parsing.

For a more detailed description, please consult the full twrtp guide document that can be found in doc/twrtp directory. This document is required reading for anyone seeking to properly understand twrtp, its domain of application and all of its capabilities, beyond the brief summary given above. Specific section references to this document will be made in subsequent comments. 

\doxysubsection{Function Documentation}
\label{group__twrtp_gaaebac4722d129a840d35a3d0c0aa63a7} 
\index{Themyscira Wireless RTP endpoint implementation@{Themyscira Wireless RTP endpoint implementation}!osmo\_twrtp\_bind\_local@{osmo\_twrtp\_bind\_local}}
\index{osmo\_twrtp\_bind\_local@{osmo\_twrtp\_bind\_local}!Themyscira Wireless RTP endpoint implementation@{Themyscira Wireless RTP endpoint implementation}}
\doxysubsubsection{osmo\_twrtp\_bind\_local()}
{\footnotesize\ttfamily int osmo\+\_\+twrtp\+\_\+bind\+\_\+local (\begin{DoxyParamCaption}\item[{struct osmo\+\_\+twrtp $\ast$}]{endp,  }\item[{const struct osmo\+\_\+sockaddr $\ast$}]{rtp\+\_\+addr,  }\item[{bool}]{bind\+\_\+rtcp }\end{DoxyParamCaption})}



Equip twrtp endpoint with locally bound RTP and RTCP sockets. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em endp} & Endpoint to operate on \\
\hline
\mbox{\texttt{ in}}  & {\em rtp\+\_\+addr} & IP\+:port address to be bound locally for RTP socket; the corresponding address for RTCP (port increment by 1) will be derived internally. \\
\hline
\mbox{\texttt{ in}}  & {\em bind\+\_\+rtcp} & Create and bind sockets for both RTP and RTCP if true, or for RTP only if false. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 if successful, negative on errors
\end{DoxyReturn}
This function creates a pair of UDP sockets of the right address family (IPv4 or IPv6) for RTP and RTCP, binds them locally and installs them in the twrtp endpoint. (Or just one UDP socket for RTP, if bind\+\_\+rtcp is false.) Either the present API or the lower-\/level alternative \doxyref{osmo\+\_\+twrtp\+\_\+supply\+\_\+fds()}{p.}{group__twrtp_ga1d22a40f737ead143bfca1d75259aba2} must be called after \doxyref{osmo\+\_\+twrtp\+\_\+create()}{p.}{group__twrtp_gacf8121473c5a45b5710a0b95d8e16575} in order for the endpoint to become functional, but neither function can be used again once this step is done. 

References \textbf{ osmo\+\_\+twrtp\+\_\+supply\+\_\+fds()}.

\label{group__twrtp_gacf8121473c5a45b5710a0b95d8e16575} 
\index{Themyscira Wireless RTP endpoint implementation@{Themyscira Wireless RTP endpoint implementation}!osmo\_twrtp\_create@{osmo\_twrtp\_create}}
\index{osmo\_twrtp\_create@{osmo\_twrtp\_create}!Themyscira Wireless RTP endpoint implementation@{Themyscira Wireless RTP endpoint implementation}}
\doxysubsubsection{osmo\_twrtp\_create()}
{\footnotesize\ttfamily struct osmo\+\_\+twrtp $\ast$ osmo\+\_\+twrtp\+\_\+create (\begin{DoxyParamCaption}\item[{void $\ast$}]{ctx,  }\item[{uint16\+\_\+t}]{clock\+\_\+khz,  }\item[{uint16\+\_\+t}]{quantum\+\_\+ms,  }\item[{bool}]{random\+\_\+ts\+\_\+seq,  }\item[{const struct osmo\+\_\+twjit\+\_\+config $\ast$}]{twjit\+\_\+config }\end{DoxyParamCaption})}



\textbackslash{}addgroup twrtp 

Create a twrtp endpoint


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em ctx} & Parent talloc context under which struct osmo\+\_\+twrtp should be allocated. \\
\hline
\mbox{\texttt{ in}}  & {\em clock\+\_\+khz} & RTP clock rate in k\+Hz, i.\+e., number of RTP timestamp units per millisecond. The most common value is 8. \\
\hline
\mbox{\texttt{ in}}  & {\em quantum\+\_\+ms} & Duration of a single quantum (unit of speech or data carried in one RTP packet) in milliseconds. The most common value is 20. \\
\hline
\mbox{\texttt{ in}}  & {\em random\+\_\+ts\+\_\+seq} & For RTP packets we generate and emit, randomize not only SSRC for this session, but also the starting timestamp and the starting sequence number. Pass true to satisfy the SHOULD directive in RFC 3550 and for feature parity with ortp, or false for ease of debugging. \\
\hline
\mbox{\texttt{ in}}  & {\em twjit\+\_\+config} & If this RTP endpoint is to be equipped with twjit, pass twjit config structure with tunable parameters here. If a sans-\/twjit RTP endpoint is to be created, pass NULL here. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
pointer to the newly created twrtp instance, or NULL on errors.
\end{DoxyReturn}
Every twrtp endpoint is always capable of sending and receiving RTP and RTCP packets on the IP network, but it may be either twjit-\/equipped or sans-\/twjit. The decision to have or not have a twjit instance as part of a newly created twrtp instance must be made at the time of creation with this function, by passing either a valid twjit config structure or NULL as twjit\+\_\+config.

Parameters clock\+\_\+khz and quantum\+\_\+ms are passed through to twjit if a twjit instance is created inside the new twrtp instance, but they are mandatory even if no twjit instance is to be created. With or without twjit, these parameters are used for locally generated RTP packets, i.\+e., those emitted via \doxyref{osmo\+\_\+twrtp\+\_\+tx\+\_\+quantum()}{p.}{group__twrtp_gae20168f9074f530ae0d9270697fadaeb} as opposed to \doxyref{osmo\+\_\+twrtp\+\_\+tx\+\_\+forward()}{p.}{group__twrtp_ga2907d4ec5bdd2bbb32f37d72b3275d94}. 

References \textbf{ osmo\+\_\+twjit\+\_\+create()}.

\label{group__twrtp_ga5630b784627262f27ca75b524e094a73} 
\index{Themyscira Wireless RTP endpoint implementation@{Themyscira Wireless RTP endpoint implementation}!osmo\_twrtp\_destroy@{osmo\_twrtp\_destroy}}
\index{osmo\_twrtp\_destroy@{osmo\_twrtp\_destroy}!Themyscira Wireless RTP endpoint implementation@{Themyscira Wireless RTP endpoint implementation}}
\doxysubsubsection{osmo\_twrtp\_destroy()}
{\footnotesize\ttfamily void osmo\+\_\+twrtp\+\_\+destroy (\begin{DoxyParamCaption}\item[{struct osmo\+\_\+twrtp $\ast$}]{endp }\end{DoxyParamCaption})}



Destroy a twrtp endpoint. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em endp} & Instance (endpoint) to be freed \\
\hline
\end{DoxyParams}


References \textbf{ osmo\+\_\+twjit\+\_\+destroy()}.

\label{group__twrtp_gadf5ed8a54818f6705d1e036c3ddd9cf5} 
\index{Themyscira Wireless RTP endpoint implementation@{Themyscira Wireless RTP endpoint implementation}!osmo\_twrtp\_get\_rtcp\_fd@{osmo\_twrtp\_get\_rtcp\_fd}}
\index{osmo\_twrtp\_get\_rtcp\_fd@{osmo\_twrtp\_get\_rtcp\_fd}!Themyscira Wireless RTP endpoint implementation@{Themyscira Wireless RTP endpoint implementation}}
\doxysubsubsection{osmo\_twrtp\_get\_rtcp\_fd()}
{\footnotesize\ttfamily int osmo\+\_\+twrtp\+\_\+get\+\_\+rtcp\+\_\+fd (\begin{DoxyParamCaption}\item[{struct osmo\+\_\+twrtp $\ast$}]{endp }\end{DoxyParamCaption})}



Retrieve file descriptor for RTCP UDP socket. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em endp} & Endpoint to query \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
OS-\/level file descriptor of the UDP socket used for RTCP.
\end{DoxyReturn}
The file descriptor made accessible via this function is still owned by the parent twrtp instance -\/ closing it, or otherwise manipulating it too heavily (e.\+g., doing kernel-\/level connect on it) will break the library. \label{group__twrtp_ga059c9fdc8016d0e872d226f7980fd872} 
\index{Themyscira Wireless RTP endpoint implementation@{Themyscira Wireless RTP endpoint implementation}!osmo\_twrtp\_get\_rtp\_fd@{osmo\_twrtp\_get\_rtp\_fd}}
\index{osmo\_twrtp\_get\_rtp\_fd@{osmo\_twrtp\_get\_rtp\_fd}!Themyscira Wireless RTP endpoint implementation@{Themyscira Wireless RTP endpoint implementation}}
\doxysubsubsection{osmo\_twrtp\_get\_rtp\_fd()}
{\footnotesize\ttfamily int osmo\+\_\+twrtp\+\_\+get\+\_\+rtp\+\_\+fd (\begin{DoxyParamCaption}\item[{struct osmo\+\_\+twrtp $\ast$}]{endp }\end{DoxyParamCaption})}



Retrieve file descriptor for RTP UDP socket. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em endp} & Endpoint to query \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
OS-\/level file descriptor of the UDP socket used for RTP.
\end{DoxyReturn}
The file descriptor made accessible via this function is still owned by the parent twrtp instance -\/ closing it, or otherwise manipulating it too heavily (e.\+g., doing kernel-\/level connect on it) will break the library. \label{group__twrtp_gaaee07c8c0e31f8551868079a18cb29cf} 
\index{Themyscira Wireless RTP endpoint implementation@{Themyscira Wireless RTP endpoint implementation}!osmo\_twrtp\_get\_stats@{osmo\_twrtp\_get\_stats}}
\index{osmo\_twrtp\_get\_stats@{osmo\_twrtp\_get\_stats}!Themyscira Wireless RTP endpoint implementation@{Themyscira Wireless RTP endpoint implementation}}
\doxysubsubsection{osmo\_twrtp\_get\_stats()}
{\footnotesize\ttfamily const struct \textbf{ osmo\+\_\+twrtp\+\_\+stats} $\ast$ osmo\+\_\+twrtp\+\_\+get\+\_\+stats (\begin{DoxyParamCaption}\item[{struct osmo\+\_\+twrtp $\ast$}]{endp }\end{DoxyParamCaption})}



Retrieve lifetime stats from twrtp instance. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em endp} & Endpoint to query \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
pointer to lifetime stats structure
\end{DoxyReturn}
Note that a twrtp endpoint equipped with twjit has two levels of stats\+: there are stats at twrtp level and at twjit level. The present function retrieves twrtp stats; to get twjit stats, call \doxyref{osmo\+\_\+twrtp\+\_\+get\+\_\+twjit()}{p.}{group__twrtp_gaa2cb81a157a22376b0c51ffc2421760e} followed by \doxyref{osmo\+\_\+twjit\+\_\+get\+\_\+stats()}{p.}{group__twjit_gaeb5d008cacb7d8329c0f0fffb4463504}. \label{group__twrtp_gaa2cb81a157a22376b0c51ffc2421760e} 
\index{Themyscira Wireless RTP endpoint implementation@{Themyscira Wireless RTP endpoint implementation}!osmo\_twrtp\_get\_twjit@{osmo\_twrtp\_get\_twjit}}
\index{osmo\_twrtp\_get\_twjit@{osmo\_twrtp\_get\_twjit}!Themyscira Wireless RTP endpoint implementation@{Themyscira Wireless RTP endpoint implementation}}
\doxysubsubsection{osmo\_twrtp\_get\_twjit()}
{\footnotesize\ttfamily struct osmo\+\_\+twjit $\ast$ osmo\+\_\+twrtp\+\_\+get\+\_\+twjit (\begin{DoxyParamCaption}\item[{struct osmo\+\_\+twrtp $\ast$}]{endp }\end{DoxyParamCaption})}



Get twjit from twrtp. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em endp} & Endpoint to query \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
pointer to twjit instance owned by this twrtp endpoint, or NULL if this twrtp endpoint has no associated twjit.
\end{DoxyReturn}
The twjit instance made accessible via this function is still owned by the parent twrtp instance -\/ calling \doxyref{osmo\+\_\+twjit\+\_\+destroy()}{p.}{group__twjit_ga7c28897aed4b25c3ede1a67fc5e6ae95} on it would cause a crash the next time twrtp tries to use it! Safe twjit APIs are as follows, for dynamic reconfiguration and information retrieval\+:

\doxyref{osmo\+\_\+twjit\+\_\+set\+\_\+config()}{p.}{group__twjit_ga930cda4155d06b50b87fcdc1785e7bec} \doxyref{osmo\+\_\+twjit\+\_\+get\+\_\+stats()}{p.}{group__twjit_gaeb5d008cacb7d8329c0f0fffb4463504} \doxyref{osmo\+\_\+twjit\+\_\+get\+\_\+rr\+\_\+info()}{p.}{group__twjit_ga40f81a7ab7af3942e540a50bb367ae56} \doxyref{osmo\+\_\+twjit\+\_\+rr\+\_\+info\+\_\+valid()}{p.}{group__twjit_ga7a0b80aa4271d55bbb720a73ab4db421} \label{group__twrtp_gab5cb8eab0ff864174338d6e8cab24b2b} 
\index{Themyscira Wireless RTP endpoint implementation@{Themyscira Wireless RTP endpoint implementation}!osmo\_twrtp\_got\_rtcp\_rr@{osmo\_twrtp\_got\_rtcp\_rr}}
\index{osmo\_twrtp\_got\_rtcp\_rr@{osmo\_twrtp\_got\_rtcp\_rr}!Themyscira Wireless RTP endpoint implementation@{Themyscira Wireless RTP endpoint implementation}}
\doxysubsubsection{osmo\_twrtp\_got\_rtcp\_rr()}
{\footnotesize\ttfamily bool osmo\+\_\+twrtp\+\_\+got\+\_\+rtcp\+\_\+rr (\begin{DoxyParamCaption}\item[{struct osmo\+\_\+twrtp $\ast$}]{endp }\end{DoxyParamCaption})}



Have we received any RTCP RR? 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em endp} & Endpoint to query \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
true if at least one reception report block has been received whose SSRC matches that of our locally generated RTP output, false otherwise. 
\end{DoxyReturn}
\label{group__twrtp_gafe2455fdfebeda8f4b810ceae34311b1} 
\index{Themyscira Wireless RTP endpoint implementation@{Themyscira Wireless RTP endpoint implementation}!osmo\_twrtp\_rr\_jitter\_last@{osmo\_twrtp\_rr\_jitter\_last}}
\index{osmo\_twrtp\_rr\_jitter\_last@{osmo\_twrtp\_rr\_jitter\_last}!Themyscira Wireless RTP endpoint implementation@{Themyscira Wireless RTP endpoint implementation}}
\doxysubsubsection{osmo\_twrtp\_rr\_jitter\_last()}
{\footnotesize\ttfamily uint32\+\_\+t osmo\+\_\+twrtp\+\_\+rr\+\_\+jitter\+\_\+last (\begin{DoxyParamCaption}\item[{struct osmo\+\_\+twrtp $\ast$}]{endp }\end{DoxyParamCaption})}



Info from received RTCP RR\+: interarrival jitter, most recent. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em endp} & Endpoint to query \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
"{}interarrival jitter"{} value from the most recently received RR block. 
\end{DoxyReturn}
\label{group__twrtp_gacd7e9922bc1682c51befe67e8fccbbd0} 
\index{Themyscira Wireless RTP endpoint implementation@{Themyscira Wireless RTP endpoint implementation}!osmo\_twrtp\_rr\_jitter\_max@{osmo\_twrtp\_rr\_jitter\_max}}
\index{osmo\_twrtp\_rr\_jitter\_max@{osmo\_twrtp\_rr\_jitter\_max}!Themyscira Wireless RTP endpoint implementation@{Themyscira Wireless RTP endpoint implementation}}
\doxysubsubsection{osmo\_twrtp\_rr\_jitter\_max()}
{\footnotesize\ttfamily uint32\+\_\+t osmo\+\_\+twrtp\+\_\+rr\+\_\+jitter\+\_\+max (\begin{DoxyParamCaption}\item[{struct osmo\+\_\+twrtp $\ast$}]{endp }\end{DoxyParamCaption})}



Info from received RTCP RR\+: interarrival jitter, highest received. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em endp} & Endpoint to query \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
"{}interarrival jitter"{} value from received RR blocks, the highest value that was received in this session. 
\end{DoxyReturn}
\label{group__twrtp_ga0cb9e5f4ea6238a051d3fc51cb39e6fa} 
\index{Themyscira Wireless RTP endpoint implementation@{Themyscira Wireless RTP endpoint implementation}!osmo\_twrtp\_rr\_lost\_cumulative@{osmo\_twrtp\_rr\_lost\_cumulative}}
\index{osmo\_twrtp\_rr\_lost\_cumulative@{osmo\_twrtp\_rr\_lost\_cumulative}!Themyscira Wireless RTP endpoint implementation@{Themyscira Wireless RTP endpoint implementation}}
\doxysubsubsection{osmo\_twrtp\_rr\_lost\_cumulative()}
{\footnotesize\ttfamily int32\+\_\+t osmo\+\_\+twrtp\+\_\+rr\+\_\+lost\+\_\+cumulative (\begin{DoxyParamCaption}\item[{struct osmo\+\_\+twrtp $\ast$}]{endp }\end{DoxyParamCaption})}



Info from received RTCP RR\+: cumulative number of packets lost. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em endp} & Endpoint to query \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
"{}cumulative number of packets lost"{} value from the most recently received RR block, extracted and converted to a proper signed type. This number can be negative because of the way it is defined in RFC 3550.
\end{DoxyReturn}
If no RTCP RR has been received, this function returns 0. \label{group__twrtp_ga1476c1b31757949bbc7777bee60e5666} 
\index{Themyscira Wireless RTP endpoint implementation@{Themyscira Wireless RTP endpoint implementation}!osmo\_twrtp\_rr\_lost\_word@{osmo\_twrtp\_rr\_lost\_word}}
\index{osmo\_twrtp\_rr\_lost\_word@{osmo\_twrtp\_rr\_lost\_word}!Themyscira Wireless RTP endpoint implementation@{Themyscira Wireless RTP endpoint implementation}}
\doxysubsubsection{osmo\_twrtp\_rr\_lost\_word()}
{\footnotesize\ttfamily uint32\+\_\+t osmo\+\_\+twrtp\+\_\+rr\+\_\+lost\+\_\+word (\begin{DoxyParamCaption}\item[{struct osmo\+\_\+twrtp $\ast$}]{endp }\end{DoxyParamCaption})}



Info from received RTCP RR\+: lost packets word. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em endp} & Endpoint to query \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
lost packets word from the most recently received RR block.
\end{DoxyReturn}
This API returns the 32-\/bit word from received RTCP RR in its raw form, exactly as it appears in RFC 3550 section 6.\+4.\+1\+: fraction lost in the upper 8 bits, cumulative number of packets lost in the lower 24 bits.

If no RTCP RR has been received, this function returns 0. \label{group__twrtp_gab331b2461929cbfd4f26b34b11060fd9} 
\index{Themyscira Wireless RTP endpoint implementation@{Themyscira Wireless RTP endpoint implementation}!osmo\_twrtp\_send\_rtcp\_rr@{osmo\_twrtp\_send\_rtcp\_rr}}
\index{osmo\_twrtp\_send\_rtcp\_rr@{osmo\_twrtp\_send\_rtcp\_rr}!Themyscira Wireless RTP endpoint implementation@{Themyscira Wireless RTP endpoint implementation}}
\doxysubsubsection{osmo\_twrtp\_send\_rtcp\_rr()}
{\footnotesize\ttfamily int osmo\+\_\+twrtp\+\_\+send\+\_\+rtcp\+\_\+rr (\begin{DoxyParamCaption}\item[{struct osmo\+\_\+twrtp $\ast$}]{endp }\end{DoxyParamCaption})}



Emit RTCP RR packet. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em endp} & Endpoint to operate on \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 if successful, negative on errors
\end{DoxyReturn}
This function is safe to call on any twrtp endpoint, but it will actually result in an RTCP RR packet being emitted only if (1) the twrtp endpoint is equipped with twjit and (2) some RTP data packets have been successfully received and header-\/decoded. If these conditions aren\textquotesingle{}t met, no RTCP packet will be emitted and the function will return -\/ENODATA.

This API is rarely needed\+: in most RTCP-\/enabled RTP applications, it is more useful to enable automatic SR generation with \doxyref{osmo\+\_\+twrtp\+\_\+set\+\_\+auto\+\_\+rtcp\+\_\+interval()}{p.}{group__twrtp_ga6b1118cac2c6362a7de38d4aba7eb2c6}, in which case the library will emit RTCP SR packets that also include the same reception report block as those standalone RR packets that are emitted by the present function. However, the present API is provided in case an application receives RTP traffic via twrtp+twjit, but does not emit any RTP traffic of its own -\/ in this case only RTCP RR can be generated, not SR. \label{group__twrtp_ga6b1118cac2c6362a7de38d4aba7eb2c6} 
\index{Themyscira Wireless RTP endpoint implementation@{Themyscira Wireless RTP endpoint implementation}!osmo\_twrtp\_set\_auto\_rtcp\_interval@{osmo\_twrtp\_set\_auto\_rtcp\_interval}}
\index{osmo\_twrtp\_set\_auto\_rtcp\_interval@{osmo\_twrtp\_set\_auto\_rtcp\_interval}!Themyscira Wireless RTP endpoint implementation@{Themyscira Wireless RTP endpoint implementation}}
\doxysubsubsection{osmo\_twrtp\_set\_auto\_rtcp\_interval()}
{\footnotesize\ttfamily void osmo\+\_\+twrtp\+\_\+set\+\_\+auto\+\_\+rtcp\+\_\+interval (\begin{DoxyParamCaption}\item[{struct osmo\+\_\+twrtp $\ast$}]{endp,  }\item[{uint16\+\_\+t}]{interval }\end{DoxyParamCaption})}



Configure automatic emission of periodic RTCP SR packets. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em endp} & Endpoint to operate on \\
\hline
\mbox{\texttt{ in}}  & {\em interval} & Automatically emit RTCP SR after this many RTP data packets, or 0 to turn off this mechanism. \\
\hline
\end{DoxyParams}
\label{group__twrtp_ga4fb17a2a0eb8d531c934d6e129e45265} 
\index{Themyscira Wireless RTP endpoint implementation@{Themyscira Wireless RTP endpoint implementation}!osmo\_twrtp\_set\_dscp@{osmo\_twrtp\_set\_dscp}}
\index{osmo\_twrtp\_set\_dscp@{osmo\_twrtp\_set\_dscp}!Themyscira Wireless RTP endpoint implementation@{Themyscira Wireless RTP endpoint implementation}}
\doxysubsubsection{osmo\_twrtp\_set\_dscp()}
{\footnotesize\ttfamily int osmo\+\_\+twrtp\+\_\+set\+\_\+dscp (\begin{DoxyParamCaption}\item[{struct osmo\+\_\+twrtp $\ast$}]{endp,  }\item[{uint8\+\_\+t}]{dscp }\end{DoxyParamCaption})}



Set DSCP (Differentiated Services Code Point) for emitted RTP and RTCP packets. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em endp} & Endpoint to operate on \\
\hline
\mbox{\texttt{ in}}  & {\em dscp} & DSCP value \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 if successful, negative on errors
\end{DoxyReturn}
This function exists for feature parity with osmo\+\_\+ortp\+: when migrating from osmo\+\_\+ortp to osmo\+\_\+twrtp, use this function in the place of osmo\+\_\+rtp\+\_\+socket\+\_\+set\+\_\+dscp(). \label{group__twrtp_ga98fce03a5a6dd6a58759c43b3ecb536b} 
\index{Themyscira Wireless RTP endpoint implementation@{Themyscira Wireless RTP endpoint implementation}!osmo\_twrtp\_set\_raw\_rx\_cb@{osmo\_twrtp\_set\_raw\_rx\_cb}}
\index{osmo\_twrtp\_set\_raw\_rx\_cb@{osmo\_twrtp\_set\_raw\_rx\_cb}!Themyscira Wireless RTP endpoint implementation@{Themyscira Wireless RTP endpoint implementation}}
\doxysubsubsection{osmo\_twrtp\_set\_raw\_rx\_cb()}
{\footnotesize\ttfamily void osmo\+\_\+twrtp\+\_\+set\+\_\+raw\+\_\+rx\+\_\+cb (\begin{DoxyParamCaption}\item[{struct osmo\+\_\+twrtp $\ast$}]{endp,  }\item[{osmo\+\_\+twrtp\+\_\+raw\+\_\+rx\+\_\+cb}]{cb,  }\item[{void $\ast$}]{user\+\_\+data }\end{DoxyParamCaption})}



Set callback function for unbuffered/non-\/delayed Rx path. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em endp} & Endpoint to operate on \\
\hline
\mbox{\texttt{ in}}  & {\em cb} & The callback function, or NULL to cancel this callback mechanism. \\
\hline
\mbox{\texttt{ in}}  & {\em user\+\_\+data} & Opaque user data for cb function\\
\hline
\end{DoxyParams}
The callback function set with this API will be called from osmo\+\_\+io Rx callback path whenever an RTP packet is received. If the callback function consumes (takes ownership of) the msgb passed to it, it must return true, otherwise it must return false. If the callback function returns true, osmo\+\_\+io Rx processing ends there; if it returns false, twrtp\textquotesingle{}s regular osmo\+\_\+io Rx callback path passes the msgb to twjit if this endpoint is equipped with such and twjit Rx is enabled, or frees the msgb otherwise.

It is possible to use twjit and this unbuffered/non-\/delayed Rx path at the same time. Consider a speech transcoder that supports AMR codec on the RAN side\+: such TC will use twjit to feed the incoming RTP stream to the speech decoder function that runs on fixed timing, but the non-\/delayed Rx path can also be used to "{}peek"{} at received RTP packets as they come in and extract the CMR field -\/ to be fed to the speech encoder element, which is separate from the speech decoder fed via twjit. \label{group__twrtp_gaa712a64e760d07cc5c22cbf2d5772ce9} 
\index{Themyscira Wireless RTP endpoint implementation@{Themyscira Wireless RTP endpoint implementation}!osmo\_twrtp\_set\_remote@{osmo\_twrtp\_set\_remote}}
\index{osmo\_twrtp\_set\_remote@{osmo\_twrtp\_set\_remote}!Themyscira Wireless RTP endpoint implementation@{Themyscira Wireless RTP endpoint implementation}}
\doxysubsubsection{osmo\_twrtp\_set\_remote()}
{\footnotesize\ttfamily int osmo\+\_\+twrtp\+\_\+set\+\_\+remote (\begin{DoxyParamCaption}\item[{struct osmo\+\_\+twrtp $\ast$}]{endp,  }\item[{const struct osmo\+\_\+sockaddr $\ast$}]{rtp\+\_\+addr }\end{DoxyParamCaption})}



Set RTP remote address. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em endp} & Endpoint to operate on \\
\hline
\mbox{\texttt{ in}}  & {\em rtp\+\_\+addr} & IP\+:port address to be set as the remote for RTP socket; the corresponding address for RTCP (port increment by 1) will be derived internally. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 if successful, negative on errors
\end{DoxyReturn}
This function needs to be called at some point in order for the endpoint to become functional, but unlike \doxyref{osmo\+\_\+twrtp\+\_\+bind\+\_\+local()}{p.}{group__twrtp_gaaebac4722d129a840d35a3d0c0aa63a7}, it can be called again to change the remote address as needed. \label{group__twrtp_ga8072fe44546bcfe663a06ae56efa4db8} 
\index{Themyscira Wireless RTP endpoint implementation@{Themyscira Wireless RTP endpoint implementation}!osmo\_twrtp\_set\_sdes@{osmo\_twrtp\_set\_sdes}}
\index{osmo\_twrtp\_set\_sdes@{osmo\_twrtp\_set\_sdes}!Themyscira Wireless RTP endpoint implementation@{Themyscira Wireless RTP endpoint implementation}}
\doxysubsubsection{osmo\_twrtp\_set\_sdes()}
{\footnotesize\ttfamily int osmo\+\_\+twrtp\+\_\+set\+\_\+sdes (\begin{DoxyParamCaption}\item[{struct osmo\+\_\+twrtp $\ast$}]{endp,  }\item[{const char $\ast$}]{cname,  }\item[{const char $\ast$}]{name,  }\item[{const char $\ast$}]{email,  }\item[{const char $\ast$}]{phone,  }\item[{const char $\ast$}]{loc,  }\item[{const char $\ast$}]{tool,  }\item[{const char $\ast$}]{note }\end{DoxyParamCaption})}



Set SDES strings for RTCP SR and RR packet generation. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em endp} & Endpoint to operate on \\
\hline
\mbox{\texttt{ in}}  & {\em cname} & Per RFC 3550 section 6.\+5.\+1 \\
\hline
\mbox{\texttt{ in}}  & {\em name} & Per RFC 3550 section 6.\+5.\+2 \\
\hline
\mbox{\texttt{ in}}  & {\em email} & Per RFC 3550 section 6.\+5.\+3 \\
\hline
\mbox{\texttt{ in}}  & {\em phone} & Per RFC 3550 section 6.\+5.\+4 \\
\hline
\mbox{\texttt{ in}}  & {\em loc} & Per RFC 3550 section 6.\+5.\+5 \\
\hline
\mbox{\texttt{ in}}  & {\em tool} & Per RFC 3550 section 6.\+5.\+6 \\
\hline
\mbox{\texttt{ in}}  & {\em note} & Per RFC 3550 section 6.\+5.\+7 \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 if successful, negative on errors
\end{DoxyReturn}
RFC 3550 section 6.\+1 stipulates that every RTCP SR or RR packet also needs to include an SDES block, containing at least a CNAME string. The present function sets the full complement of SDES strings\+: the mandatory CNAME string and 6 optional ones per RFC 3550. This function must be called successfully before any RTCP SR or RR packets will be emitted. \label{group__twrtp_ga85635115eb97f0400ca9698dc1e6fb41} 
\index{Themyscira Wireless RTP endpoint implementation@{Themyscira Wireless RTP endpoint implementation}!osmo\_twrtp\_set\_socket\_prio@{osmo\_twrtp\_set\_socket\_prio}}
\index{osmo\_twrtp\_set\_socket\_prio@{osmo\_twrtp\_set\_socket\_prio}!Themyscira Wireless RTP endpoint implementation@{Themyscira Wireless RTP endpoint implementation}}
\doxysubsubsection{osmo\_twrtp\_set\_socket\_prio()}
{\footnotesize\ttfamily int osmo\+\_\+twrtp\+\_\+set\+\_\+socket\+\_\+prio (\begin{DoxyParamCaption}\item[{struct osmo\+\_\+twrtp $\ast$}]{endp,  }\item[{int}]{prio }\end{DoxyParamCaption})}



Set socket priority for emitted RTP and RTCP packets. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em endp} & Endpoint to operate on \\
\hline
\mbox{\texttt{ in}}  & {\em prio} & Socket priority \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 if successful, negative on errors
\end{DoxyReturn}
This function exists for feature parity with osmo\+\_\+ortp\+: when migrating from osmo\+\_\+ortp to osmo\+\_\+twrtp, use this function in the place of osmo\+\_\+rtp\+\_\+socket\+\_\+set\+\_\+priority(). \label{group__twrtp_ga1d22a40f737ead143bfca1d75259aba2} 
\index{Themyscira Wireless RTP endpoint implementation@{Themyscira Wireless RTP endpoint implementation}!osmo\_twrtp\_supply\_fds@{osmo\_twrtp\_supply\_fds}}
\index{osmo\_twrtp\_supply\_fds@{osmo\_twrtp\_supply\_fds}!Themyscira Wireless RTP endpoint implementation@{Themyscira Wireless RTP endpoint implementation}}
\doxysubsubsection{osmo\_twrtp\_supply\_fds()}
{\footnotesize\ttfamily int osmo\+\_\+twrtp\+\_\+supply\+\_\+fds (\begin{DoxyParamCaption}\item[{struct osmo\+\_\+twrtp $\ast$}]{endp,  }\item[{int}]{rtp\+\_\+fd,  }\item[{int}]{rtcp\+\_\+fd }\end{DoxyParamCaption})}



Equip twrtp endpoint with RTP and RTCP sockets (supplied file descriptors) 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em endp} & Endpoint to operate on \\
\hline
\mbox{\texttt{ in}}  & {\em rtp\+\_\+fd} & OS file descriptor for UDP socket for RTP \\
\hline
\mbox{\texttt{ in}}  & {\em rtcp\+\_\+fd} & OS file descriptor for UDP socket for RTCP \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 if successful, negative on errors
\end{DoxyReturn}
This function equips a newly created twrtp endpoint with file descriptors for RTP and RTCP sockets. Most applications will use the high-\/level API \doxyref{osmo\+\_\+twrtp\+\_\+bind\+\_\+local()}{p.}{group__twrtp_gaaebac4722d129a840d35a3d0c0aa63a7} that creates and binds the right type of sockets, then calls the present function -\/ however, some applications may call this function directly. In Themyscira Wireless CN environment, there is a separate daemon process that manages the pool of local UDP ports for RTP+\+RTCP pairs, and that daemon passes allocated sockets to its clients via UNIX domain socket file descriptor passing mechanism -\/ hence twrtp layer must have a public API that takes in already-\/bound file descriptor pairs.

This function always "{}consumes"{} the two file descriptors that are passed to it. If the operation succeeds, each of these fds becomes wrapped in an osmo\+\_\+io\+\_\+fd subordinate to struct osmo\+\_\+twrtp, and both will eventually be closed upon \doxyref{osmo\+\_\+twrtp\+\_\+destroy()}{p.}{group__twrtp_ga5630b784627262f27ca75b524e094a73}. OTOH, if the present function fails, it closes both fds before returning its error indication. The latter behavior may seem wrong, but it is more convenient for all current users, and consistent with twrtp-\/native and twrtp-\/proto versions. If we get a user application that prefers the other alternative (keeping the fds intact on EBUSY or if osmo\+\_\+iofd\+\_\+setup() or osmo\+\_\+iofd\+\_\+register() operations fail), we can create another variant of this API with that alternative behavior.

It is also possible to pass -\/1 as rtcp\+\_\+fd -\/ in this case the twrtp endpoint will operate with only an RTP socket, and no ability to send or receive RTCP. 

Referenced by \textbf{ osmo\+\_\+twrtp\+\_\+bind\+\_\+local()}.

\label{group__twrtp_gaaf8aa5a57b46f846b865cb370b36a52e} 
\index{Themyscira Wireless RTP endpoint implementation@{Themyscira Wireless RTP endpoint implementation}!osmo\_twrtp\_twjit\_rx\_ctrl@{osmo\_twrtp\_twjit\_rx\_ctrl}}
\index{osmo\_twrtp\_twjit\_rx\_ctrl@{osmo\_twrtp\_twjit\_rx\_ctrl}!Themyscira Wireless RTP endpoint implementation@{Themyscira Wireless RTP endpoint implementation}}
\doxysubsubsection{osmo\_twrtp\_twjit\_rx\_ctrl()}
{\footnotesize\ttfamily void osmo\+\_\+twrtp\+\_\+twjit\+\_\+rx\+\_\+ctrl (\begin{DoxyParamCaption}\item[{struct osmo\+\_\+twrtp $\ast$}]{endp,  }\item[{bool}]{rx\+\_\+enable }\end{DoxyParamCaption})}



Enable or disable Rx via twjit. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em endp} & Endpoint to operate on \\
\hline
\mbox{\texttt{ in}}  & {\em rx\+\_\+enable} & Self-\/explanatory Boolean flag\\
\hline
\end{DoxyParams}
This API is valid only for twrtp endpoints that were equipped with twjit at the time of creation. 

References \textbf{ osmo\+\_\+twjit\+\_\+reset()}.

\label{group__twrtp_gacaa8b25a610a5ed982eba709a516c3e2} 
\index{Themyscira Wireless RTP endpoint implementation@{Themyscira Wireless RTP endpoint implementation}!osmo\_twrtp\_twjit\_rx\_poll@{osmo\_twrtp\_twjit\_rx\_poll}}
\index{osmo\_twrtp\_twjit\_rx\_poll@{osmo\_twrtp\_twjit\_rx\_poll}!Themyscira Wireless RTP endpoint implementation@{Themyscira Wireless RTP endpoint implementation}}
\doxysubsubsection{osmo\_twrtp\_twjit\_rx\_poll()}
{\footnotesize\ttfamily struct msgb $\ast$ osmo\+\_\+twrtp\+\_\+twjit\+\_\+rx\+\_\+poll (\begin{DoxyParamCaption}\item[{struct osmo\+\_\+twrtp $\ast$}]{endp }\end{DoxyParamCaption})}



Fixed-\/timing output poll from the twrtp endpoint\textquotesingle{}s twjit buffer. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em endp} & Endpoint to poll \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
pointer to msgb holding a previously received RTP packet that was successfully mapped to the present quantum in the fixed-\/timing output, or NULL if no such packet is available.
\end{DoxyReturn}
This API is valid only for twrtp endpoints that were equipped with twjit at the time of creation. 

References \textbf{ osmo\+\_\+twjit\+\_\+output()}.

\label{group__twrtp_ga2907d4ec5bdd2bbb32f37d72b3275d94} 
\index{Themyscira Wireless RTP endpoint implementation@{Themyscira Wireless RTP endpoint implementation}!osmo\_twrtp\_tx\_forward@{osmo\_twrtp\_tx\_forward}}
\index{osmo\_twrtp\_tx\_forward@{osmo\_twrtp\_tx\_forward}!Themyscira Wireless RTP endpoint implementation@{Themyscira Wireless RTP endpoint implementation}}
\doxysubsubsection{osmo\_twrtp\_tx\_forward()}
{\footnotesize\ttfamily int osmo\+\_\+twrtp\+\_\+tx\+\_\+forward (\begin{DoxyParamCaption}\item[{struct osmo\+\_\+twrtp $\ast$}]{endp,  }\item[{struct msgb $\ast$}]{msg }\end{DoxyParamCaption})}



Forward RTP packet between endpoints. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em endp} & Endpoint on which the packet should be sent out \\
\hline
\mbox{\texttt{ in}}  & {\em msg} & RTP packet received from another endpoint \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 if successful, negative on errors
\end{DoxyReturn}
If an application needs to forward RTP packets from one endpoint to another without buffering delay, it should call the present function from the callback registered on the other endpoint with \doxyref{osmo\+\_\+twrtp\+\_\+set\+\_\+raw\+\_\+rx\+\_\+cb()}{p.}{group__twrtp_ga98fce03a5a6dd6a58759c43b3ecb536b}.

This function always consumes the msgb passed to it -\/ if the sending operation fails, the msgb is freed here. \label{group__twrtp_gae20168f9074f530ae0d9270697fadaeb} 
\index{Themyscira Wireless RTP endpoint implementation@{Themyscira Wireless RTP endpoint implementation}!osmo\_twrtp\_tx\_quantum@{osmo\_twrtp\_tx\_quantum}}
\index{osmo\_twrtp\_tx\_quantum@{osmo\_twrtp\_tx\_quantum}!Themyscira Wireless RTP endpoint implementation@{Themyscira Wireless RTP endpoint implementation}}
\doxysubsubsection{osmo\_twrtp\_tx\_quantum()}
{\footnotesize\ttfamily int osmo\+\_\+twrtp\+\_\+tx\+\_\+quantum (\begin{DoxyParamCaption}\item[{struct osmo\+\_\+twrtp $\ast$}]{endp,  }\item[{const uint8\+\_\+t $\ast$}]{payload,  }\item[{unsigned}]{payload\+\_\+len,  }\item[{uint8\+\_\+t}]{payload\+\_\+type,  }\item[{bool}]{marker,  }\item[{bool}]{auto\+\_\+marker,  }\item[{bool}]{send\+\_\+rtcp }\end{DoxyParamCaption})}



Emit RTP packet carrying a locally sourced quantum of speech/data. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em endp} & Endpoint to operate on \\
\hline
\mbox{\texttt{ in}}  & {\em payload} & The payload to emit in RTP, can be NULL iff payload\+\_\+len == 0. \\
\hline
\mbox{\texttt{ in}}  & {\em payload\+\_\+len} & The length of payload in bytes. \\
\hline
\mbox{\texttt{ in}}  & {\em payload\+\_\+type} & The payload type number to be emitted in the generated RTP packet. \\
\hline
\mbox{\texttt{ in}}  & {\em marker} & Value of the M bit to be emitted. \\
\hline
\mbox{\texttt{ in}}  & {\em auto\+\_\+marker} & Automatically set the M bit if the packet we are emitting is our very first or follows \doxyref{osmo\+\_\+twrtp\+\_\+tx\+\_\+restart()}{p.}{group__twrtp_ga2e365e51cc37adb56a77b9c2bfa26683}. \\
\hline
\mbox{\texttt{ in}}  & {\em send\+\_\+rtcp} & Emit RTCP SR along with this RTP data packet. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 if successful, negative on errors.
\end{DoxyReturn}
The design of the library assumes that RTP payloads sent out via this API originate from a fixed timing system such as GSM Um TCH, T1/\+E1 TDM or a software application driven by a CLOCK\+\_\+\+MONOTONIC timerfd, such that once the application calls the present function, subsequent calls to the same will follow every 20 ms (or whatever other quantum duration is set at the time of \doxyref{osmo\+\_\+twrtp\+\_\+create()}{p.}{group__twrtp_gacf8121473c5a45b5710a0b95d8e16575}) without fail.

The M bit will be set in the generated RTP packet if marker argument is true OR if auto\+\_\+marker is true and the conditions for automatic marker setting are met.

RTCP SR packets are emitted by the endpoint only as a result of this function being called, and not along any other path. An RTCP SR will be emitted if send\+\_\+rtcp argument is true OR if automatic RTCP SR generation was enabled with \doxyref{osmo\+\_\+twrtp\+\_\+set\+\_\+auto\+\_\+rtcp\+\_\+interval()}{p.}{group__twrtp_ga6b1118cac2c6362a7de38d4aba7eb2c6} and it is time to emit RTCP SR per the count of emitted RTP data packets. 

References \textbf{ osmo\+\_\+twrtp\+\_\+tx\+\_\+skip()}.

\label{group__twrtp_ga2e365e51cc37adb56a77b9c2bfa26683} 
\index{Themyscira Wireless RTP endpoint implementation@{Themyscira Wireless RTP endpoint implementation}!osmo\_twrtp\_tx\_restart@{osmo\_twrtp\_tx\_restart}}
\index{osmo\_twrtp\_tx\_restart@{osmo\_twrtp\_tx\_restart}!Themyscira Wireless RTP endpoint implementation@{Themyscira Wireless RTP endpoint implementation}}
\doxysubsubsection{osmo\_twrtp\_tx\_restart()}
{\footnotesize\ttfamily void osmo\+\_\+twrtp\+\_\+tx\+\_\+restart (\begin{DoxyParamCaption}\item[{struct osmo\+\_\+twrtp $\ast$}]{endp }\end{DoxyParamCaption})}



Reset output stream cadence. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em endp} & Endpoint to operate on\\
\hline
\end{DoxyParams}
This function needs to be called if the application wishes to restart or resume output after it previously stopped calling \doxyref{osmo\+\_\+twrtp\+\_\+tx\+\_\+quantum()}{p.}{group__twrtp_gae20168f9074f530ae0d9270697fadaeb} or \doxyref{osmo\+\_\+twrtp\+\_\+tx\+\_\+skip()}{p.}{group__twrtp_ga971ca670aa852281620c69cbd69a57e8} every 20 ms, and it should also be called if the cadence of quantum-\/sized timestamp increments needs to be broken for some reason. \label{group__twrtp_ga971ca670aa852281620c69cbd69a57e8} 
\index{Themyscira Wireless RTP endpoint implementation@{Themyscira Wireless RTP endpoint implementation}!osmo\_twrtp\_tx\_skip@{osmo\_twrtp\_tx\_skip}}
\index{osmo\_twrtp\_tx\_skip@{osmo\_twrtp\_tx\_skip}!Themyscira Wireless RTP endpoint implementation@{Themyscira Wireless RTP endpoint implementation}}
\doxysubsubsection{osmo\_twrtp\_tx\_skip()}
{\footnotesize\ttfamily void osmo\+\_\+twrtp\+\_\+tx\+\_\+skip (\begin{DoxyParamCaption}\item[{struct osmo\+\_\+twrtp $\ast$}]{endp }\end{DoxyParamCaption})}



Incur an intentional gap in the emitted RTP stream. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em endp} & Endpoint to operate on\\
\hline
\end{DoxyParams}
Many RTP profiles call for behavior where a stream sender incurs an intentional gap in its output (does not emit the otherwise-\/expected RTP packet for a given timestamp in the expected cadence of timestamp quantum increments) if the corresponding quantum carries speech silence, or if the data source has errors. Such operation is non-\/native to twrtp and generally recommended against (it creates an adverse condition for twjit on the receiving end), but the library provides mechanism rather than policy, hence the ability to incur intentional gaps is supported. This function advances the output timestamp by one quantum, thereby creating the requested intentional gap. 

Referenced by \textbf{ osmo\+\_\+twrtp\+\_\+tx\+\_\+quantum()}.

