\doxysection{include/osmocom/codec/codec.h File Reference} \label{codec_8h}\index{include/osmocom/codec/codec.h@{include/osmocom/codec/codec.h}} {\ttfamily \#include $<$stdint.\+h$>$}\newline {\ttfamily \#include $<$stdbool.\+h$>$}\newline {\ttfamily \#include $<$osmocom/core/utils.\+h$>$}\newline {\ttfamily \#include $<$osmocom/core/bits.\+h$>$}\newline \doxysubsection*{Macros} \begin{DoxyCompactItemize} \item \#define \textbf{ GSM\+\_\+\+FR\+\_\+\+BYTES}~33 \item \#define \textbf{ GSM\+\_\+\+HR\+\_\+\+BYTES}~14 \item \#define \textbf{ GSM\+\_\+\+EFR\+\_\+\+BYTES}~31 \item \#define \textbf{ GSM\+\_\+\+HR\+\_\+\+BYTES\+\_\+\+RTP\+\_\+\+RFC5993}~(\textbf{ GSM\+\_\+\+HR\+\_\+\+BYTES} + 1) \item \#define \textbf{ GSM\+\_\+\+HR\+\_\+\+BYTES\+\_\+\+RTP\+\_\+\+TS101318}~(\textbf{ GSM\+\_\+\+HR\+\_\+\+BYTES}) \end{DoxyCompactItemize} \doxysubsection*{Enumerations} \begin{DoxyCompactItemize} \item enum \textbf{ osmo\+\_\+amr\+\_\+type} \{ \newline \textbf{ AMR\+\_\+4\+\_\+75} = 0 , \newline \textbf{ AMR\+\_\+5\+\_\+15} = 1 , \newline \textbf{ AMR\+\_\+5\+\_\+90} = 2 , \newline \textbf{ AMR\+\_\+6\+\_\+70} = 3 , \newline \textbf{ AMR\+\_\+7\+\_\+40} = 4 , \newline \textbf{ AMR\+\_\+7\+\_\+95} = 5 , \newline \textbf{ AMR\+\_\+10\+\_\+2} = 6 , \newline \textbf{ AMR\+\_\+12\+\_\+2} = 7 , \newline \textbf{ AMR\+\_\+\+SID} = 8 , \newline \textbf{ AMR\+\_\+\+GSM\+\_\+\+EFR\+\_\+\+SID} = 9 , \newline \textbf{ AMR\+\_\+\+TDMA\+\_\+\+EFR\+\_\+\+SID} = 10 , \newline \textbf{ AMR\+\_\+\+PDC\+\_\+\+EFR\+\_\+\+SID} = 11 , \newline \textbf{ AMR\+\_\+\+NO\+\_\+\+DATA} = 15 \} \item enum \textbf{ osmo\+\_\+amr\+\_\+quality} \{ \newline \textbf{ AMR\+\_\+\+BAD} = 0 , \newline \textbf{ AMR\+\_\+\+GOOD} = 1 \} \item enum \textbf{ osmo\+\_\+gsm631\+\_\+sid\+\_\+class} \{ \newline \textbf{ OSMO\+\_\+\+GSM631\+\_\+\+SID\+\_\+\+CLASS\+\_\+\+SPEECH} = 0 , \newline \textbf{ OSMO\+\_\+\+GSM631\+\_\+\+SID\+\_\+\+CLASS\+\_\+\+INVALID} = 1 , \newline \textbf{ OSMO\+\_\+\+GSM631\+\_\+\+SID\+\_\+\+CLASS\+\_\+\+VALID} = 2 \} \end{DoxyCompactItemize} \doxysubsection*{Functions} \begin{DoxyCompactItemize} \item static const char $\ast$ \textbf{ osmo\+\_\+amr\+\_\+type\+\_\+name} (enum \textbf{ osmo\+\_\+amr\+\_\+type} \textbf{ type}) \item int \textbf{ osmo\+\_\+amr\+\_\+s\+\_\+to\+\_\+d} (\textbf{ ubit\+\_\+t} $\ast$out, const \textbf{ ubit\+\_\+t} $\ast$in, uint16\+\_\+t n\+\_\+bits, enum \textbf{ osmo\+\_\+amr\+\_\+type} amr\+\_\+mode) \begin{DoxyCompactList}\small\item\em Convert from S-\/bits (codec output) to d-\/bits. \end{DoxyCompactList}\item int \textbf{ osmo\+\_\+amr\+\_\+d\+\_\+to\+\_\+s} (\textbf{ ubit\+\_\+t} $\ast$out, const \textbf{ ubit\+\_\+t} $\ast$in, uint16\+\_\+t n\+\_\+bits, enum \textbf{ osmo\+\_\+amr\+\_\+type} amr\+\_\+mode) \begin{DoxyCompactList}\small\item\em Convert from d-\/bits to s-\/bits (codec input). \end{DoxyCompactList}\item static bool \textbf{ osmo\+\_\+amr\+\_\+is\+\_\+speech} (enum \textbf{ osmo\+\_\+amr\+\_\+type} ft) \begin{DoxyCompactList}\small\item\em Check if given AMR Frame Type is a speech frame. \end{DoxyCompactList}\item bool \textbf{ osmo\+\_\+fr\+\_\+check\+\_\+sid} (const uint8\+\_\+t $\ast$rtp\+\_\+payload, size\+\_\+t payload\+\_\+len) \begin{DoxyCompactList}\small\item\em Check whether RTP frame contains FR SID code word according to TS 101 318 §5.1.\+2. \end{DoxyCompactList}\item bool \textbf{ osmo\+\_\+hr\+\_\+check\+\_\+sid} (const uint8\+\_\+t $\ast$rtp\+\_\+payload, size\+\_\+t payload\+\_\+len) \begin{DoxyCompactList}\small\item\em Check whether RTP frame contains HR SID code word according to TS 101 318 §5.2.\+2. \end{DoxyCompactList}\item bool \textbf{ osmo\+\_\+efr\+\_\+check\+\_\+sid} (const uint8\+\_\+t $\ast$rtp\+\_\+payload, size\+\_\+t payload\+\_\+len) \begin{DoxyCompactList}\small\item\em Check whether RTP frame contains EFR SID code word according to TS 101 318 §5.3.\+2. \end{DoxyCompactList}\item enum \textbf{ osmo\+\_\+gsm631\+\_\+sid\+\_\+class} \textbf{ osmo\+\_\+fr\+\_\+sid\+\_\+classify} (const uint8\+\_\+t $\ast$rtp\+\_\+payload) \begin{DoxyCompactList}\small\item\em Classify potentially-\/\+SID FR codec frame in RTP format according to the rules of GSM 06.\+31 §6.1.\+1. \end{DoxyCompactList}\item enum \textbf{ osmo\+\_\+gsm631\+\_\+sid\+\_\+class} \textbf{ osmo\+\_\+efr\+\_\+sid\+\_\+classify} (const uint8\+\_\+t $\ast$rtp\+\_\+payload) \begin{DoxyCompactList}\small\item\em Classify potentially-\/\+SID EFR codec frame in RTP format according to the rules of GSM 06.\+81 §6.1.\+1. \end{DoxyCompactList}\item static bool \textbf{ osmo\+\_\+fr\+\_\+is\+\_\+any\+\_\+sid} (const uint8\+\_\+t $\ast$rtp\+\_\+payload) \begin{DoxyCompactList}\small\item\em Check if given FR codec frame is any kind of SID, valid or invalid. \end{DoxyCompactList}\item static bool \textbf{ osmo\+\_\+efr\+\_\+is\+\_\+any\+\_\+sid} (const uint8\+\_\+t $\ast$rtp\+\_\+payload) \begin{DoxyCompactList}\small\item\em Check if given EFR codec frame is any kind of SID, valid or invalid. \end{DoxyCompactList}\item bool \textbf{ osmo\+\_\+fr\+\_\+sid\+\_\+preen} (uint8\+\_\+t $\ast$rtp\+\_\+payload) \begin{DoxyCompactList}\small\item\em Preen potentially-\/\+SID FR codec frame in RTP format, ensuring that it is either a speech frame or a valid SID, and if the latter, making it a perfect, error-\/free SID frame. \end{DoxyCompactList}\item bool \textbf{ osmo\+\_\+efr\+\_\+sid\+\_\+preen} (uint8\+\_\+t $\ast$rtp\+\_\+payload) \begin{DoxyCompactList}\small\item\em Preen potentially-\/\+SID EFR codec frame in RTP format, ensuring that it is either a speech frame or a valid SID, and if the latter, making it a perfect, error-\/free SID frame. \end{DoxyCompactList}\item void \textbf{ osmo\+\_\+fr\+\_\+sid\+\_\+reset} (uint8\+\_\+t $\ast$rtp\+\_\+payload) \begin{DoxyCompactList}\small\item\em Reset the SID field and the unused bits of a potentially corrupted, but still valid GSM-\/\+FR SID frame in RTP encoding to their pristine state. \end{DoxyCompactList}\item void \textbf{ osmo\+\_\+hr\+\_\+sid\+\_\+reset} (uint8\+\_\+t $\ast$rtp\+\_\+payload) \begin{DoxyCompactList}\small\item\em Reset the SID field of a potentially corrupted, but still valid GSM-\/\+HR SID frame in TS 101 318 format to its pristine state (full SID codeword). \end{DoxyCompactList}\item void \textbf{ osmo\+\_\+efr\+\_\+sid\+\_\+reset} (uint8\+\_\+t $\ast$rtp\+\_\+payload) \begin{DoxyCompactList}\small\item\em Reset the SID field of a potentially corrupted, but still valid GSM-\/\+EFR SID frame in RTP encoding to its pristine state (full SID code word). \end{DoxyCompactList}\item int \textbf{ osmo\+\_\+amr\+\_\+rtp\+\_\+enc} (uint8\+\_\+t $\ast$payload, uint8\+\_\+t cmr, enum \textbf{ osmo\+\_\+amr\+\_\+type} ft, enum \textbf{ osmo\+\_\+amr\+\_\+quality} bfi) \begin{DoxyCompactList}\small\item\em Encode various AMR parameters from RTP payload (RFC 4867) \end{DoxyCompactList}\item int \textbf{ osmo\+\_\+amr\+\_\+rtp\+\_\+dec} (const uint8\+\_\+t $\ast$payload, int payload\+\_\+len, uint8\+\_\+t $\ast$cmr, int8\+\_\+t $\ast$cmi, enum \textbf{ osmo\+\_\+amr\+\_\+type} $\ast$ft, enum \textbf{ osmo\+\_\+amr\+\_\+quality} $\ast$bfi, int8\+\_\+t $\ast$sti) \begin{DoxyCompactList}\small\item\em Decode various AMR parameters from RTP payload (RFC 4867) acording to 3GPP TS 26.\+101. \end{DoxyCompactList}\end{DoxyCompactItemize} \doxysubsection*{Variables} \begin{DoxyCompactItemize} \item const uint16\+\_\+t \textbf{ gsm610\+\_\+bitorder} [$\,$] \item const uint16\+\_\+t \textbf{ gsm620\+\_\+unvoiced\+\_\+bitorder} [$\,$] \item const uint16\+\_\+t \textbf{ gsm620\+\_\+voiced\+\_\+bitorder} [$\,$] \item const uint16\+\_\+t \textbf{ gsm660\+\_\+bitorder} [$\,$] \item const uint16\+\_\+t \textbf{ gsm690\+\_\+12\+\_\+2\+\_\+bitorder} [$\,$] \item const uint16\+\_\+t \textbf{ gsm690\+\_\+10\+\_\+2\+\_\+bitorder} [$\,$] \item const uint16\+\_\+t \textbf{ gsm690\+\_\+7\+\_\+95\+\_\+bitorder} [$\,$] \item const uint16\+\_\+t \textbf{ gsm690\+\_\+7\+\_\+4\+\_\+bitorder} [$\,$] \item const uint16\+\_\+t \textbf{ gsm690\+\_\+6\+\_\+7\+\_\+bitorder} [$\,$] \item const uint16\+\_\+t \textbf{ gsm690\+\_\+5\+\_\+9\+\_\+bitorder} [$\,$] \item const uint16\+\_\+t \textbf{ gsm690\+\_\+5\+\_\+15\+\_\+bitorder} [$\,$] \item const uint16\+\_\+t \textbf{ gsm690\+\_\+4\+\_\+75\+\_\+bitorder} [$\,$] \item const uint8\+\_\+t \textbf{ osmo\+\_\+gsm611\+\_\+silence\+\_\+frame} [\textbf{ GSM\+\_\+\+FR\+\_\+\+BYTES}] \item const struct \textbf{ value\+\_\+string} \textbf{ osmo\+\_\+amr\+\_\+type\+\_\+names} [$\,$] \item const uint8\+\_\+t \textbf{ gsm690\+\_\+bitlength} [\textbf{ AMR\+\_\+\+NO\+\_\+\+DATA}+1] \begin{DoxyCompactList}\small\item\em These constants refer to the length of one \char`\"{}\+AMR core frame\char`\"{} as per TS 26.\+101 Section 4.\+2.\+2 / Table 2. \end{DoxyCompactList}\end{DoxyCompactItemize} \doxysubsection{Macro Definition Documentation} \mbox{\label{codec_8h_a1408201e76008d9e45eb7d9662bcbadb}} \index{codec.h@{codec.h}!GSM\_EFR\_BYTES@{GSM\_EFR\_BYTES}} \index{GSM\_EFR\_BYTES@{GSM\_EFR\_BYTES}!codec.h@{codec.h}} \doxysubsubsection{GSM\_EFR\_BYTES} {\footnotesize\ttfamily \#define GSM\+\_\+\+EFR\+\_\+\+BYTES~31} \mbox{\label{codec_8h_a8142bfeed988eaca0bd616928348a601}} \index{codec.h@{codec.h}!GSM\_FR\_BYTES@{GSM\_FR\_BYTES}} \index{GSM\_FR\_BYTES@{GSM\_FR\_BYTES}!codec.h@{codec.h}} \doxysubsubsection{GSM\_FR\_BYTES} {\footnotesize\ttfamily \#define GSM\+\_\+\+FR\+\_\+\+BYTES~33} \mbox{\label{codec_8h_a609c2f68d173e81830bd5ada4684fdf1}} \index{codec.h@{codec.h}!GSM\_HR\_BYTES@{GSM\_HR\_BYTES}} \index{GSM\_HR\_BYTES@{GSM\_HR\_BYTES}!codec.h@{codec.h}} \doxysubsubsection{GSM\_HR\_BYTES} {\footnotesize\ttfamily \#define GSM\+\_\+\+HR\+\_\+\+BYTES~14} \mbox{\label{codec_8h_ad1ff0a586dbd42c6615bcb0ceabfd10e}} \index{codec.h@{codec.h}!GSM\_HR\_BYTES\_RTP\_RFC5993@{GSM\_HR\_BYTES\_RTP\_RFC5993}} \index{GSM\_HR\_BYTES\_RTP\_RFC5993@{GSM\_HR\_BYTES\_RTP\_RFC5993}!codec.h@{codec.h}} \doxysubsubsection{GSM\_HR\_BYTES\_RTP\_RFC5993} {\footnotesize\ttfamily \#define GSM\+\_\+\+HR\+\_\+\+BYTES\+\_\+\+RTP\+\_\+\+RFC5993~(\textbf{ GSM\+\_\+\+HR\+\_\+\+BYTES} + 1)} \mbox{\label{codec_8h_a1397a446c4f0b373c474811d81e69609}} \index{codec.h@{codec.h}!GSM\_HR\_BYTES\_RTP\_TS101318@{GSM\_HR\_BYTES\_RTP\_TS101318}} \index{GSM\_HR\_BYTES\_RTP\_TS101318@{GSM\_HR\_BYTES\_RTP\_TS101318}!codec.h@{codec.h}} \doxysubsubsection{GSM\_HR\_BYTES\_RTP\_TS101318} {\footnotesize\ttfamily \#define GSM\+\_\+\+HR\+\_\+\+BYTES\+\_\+\+RTP\+\_\+\+TS101318~(\textbf{ GSM\+\_\+\+HR\+\_\+\+BYTES})} \doxysubsection{Enumeration Type Documentation} \mbox{\label{codec_8h_ad8fe0f6cdeeb90780bc5d5457234cfa6}} \index{codec.h@{codec.h}!osmo\_amr\_quality@{osmo\_amr\_quality}} \index{osmo\_amr\_quality@{osmo\_amr\_quality}!codec.h@{codec.h}} \doxysubsubsection{osmo\_amr\_quality} {\footnotesize\ttfamily enum \textbf{ osmo\+\_\+amr\+\_\+quality}} \begin{DoxyEnumFields}{Enumerator} \raisebox{\heightof{T}}[0pt][0pt]{\index{AMR\_BAD@{AMR\_BAD}!codec.h@{codec.h}}\index{codec.h@{codec.h}!AMR\_BAD@{AMR\_BAD}}}\mbox{\label{codec_8h_ad8fe0f6cdeeb90780bc5d5457234cfa6a6707d26771cc8327db67af28d8e74451}} AMR\+\_\+\+BAD&\\ \hline \raisebox{\heightof{T}}[0pt][0pt]{\index{AMR\_GOOD@{AMR\_GOOD}!codec.h@{codec.h}}\index{codec.h@{codec.h}!AMR\_GOOD@{AMR\_GOOD}}}\mbox{\label{codec_8h_ad8fe0f6cdeeb90780bc5d5457234cfa6a6ed387877388c0c01c7819a13f5f68ac}} AMR\+\_\+\+GOOD&\\ \hline \end{DoxyEnumFields} \mbox{\label{codec_8h_aa3bfef13bd38e839f85fdcd2a11c8802}} \index{codec.h@{codec.h}!osmo\_amr\_type@{osmo\_amr\_type}} \index{osmo\_amr\_type@{osmo\_amr\_type}!codec.h@{codec.h}} \doxysubsubsection{osmo\_amr\_type} {\footnotesize\ttfamily enum \textbf{ osmo\+\_\+amr\+\_\+type}} \begin{DoxyEnumFields}{Enumerator} \raisebox{\heightof{T}}[0pt][0pt]{\index{AMR\_4\_75@{AMR\_4\_75}!codec.h@{codec.h}}\index{codec.h@{codec.h}!AMR\_4\_75@{AMR\_4\_75}}}\mbox{\label{codec_8h_aa3bfef13bd38e839f85fdcd2a11c8802a0b1f2017de8f7f61a91b94d1416cb589}} AMR\+\_\+4\+\_\+75&\\ \hline \raisebox{\heightof{T}}[0pt][0pt]{\index{AMR\_5\_15@{AMR\_5\_15}!codec.h@{codec.h}}\index{codec.h@{codec.h}!AMR\_5\_15@{AMR\_5\_15}}}\mbox{\label{codec_8h_aa3bfef13bd38e839f85fdcd2a11c8802ae683245a4d66e84d4faa660026cd10b5}} AMR\+\_\+5\+\_\+15&\\ \hline \raisebox{\heightof{T}}[0pt][0pt]{\index{AMR\_5\_90@{AMR\_5\_90}!codec.h@{codec.h}}\index{codec.h@{codec.h}!AMR\_5\_90@{AMR\_5\_90}}}\mbox{\label{codec_8h_aa3bfef13bd38e839f85fdcd2a11c8802ad15c62abdb1f24538497ac1b66fc7084}} AMR\+\_\+5\+\_\+90&\\ \hline \raisebox{\heightof{T}}[0pt][0pt]{\index{AMR\_6\_70@{AMR\_6\_70}!codec.h@{codec.h}}\index{codec.h@{codec.h}!AMR\_6\_70@{AMR\_6\_70}}}\mbox{\label{codec_8h_aa3bfef13bd38e839f85fdcd2a11c8802aae17c5669ff3a19c3f1658f54a81392f}} AMR\+\_\+6\+\_\+70&\\ \hline \raisebox{\heightof{T}}[0pt][0pt]{\index{AMR\_7\_40@{AMR\_7\_40}!codec.h@{codec.h}}\index{codec.h@{codec.h}!AMR\_7\_40@{AMR\_7\_40}}}\mbox{\label{codec_8h_aa3bfef13bd38e839f85fdcd2a11c8802a88cc0dc18ca13740ae24d0db4b1cfe8b}} AMR\+\_\+7\+\_\+40&\\ \hline \raisebox{\heightof{T}}[0pt][0pt]{\index{AMR\_7\_95@{AMR\_7\_95}!codec.h@{codec.h}}\index{codec.h@{codec.h}!AMR\_7\_95@{AMR\_7\_95}}}\mbox{\label{codec_8h_aa3bfef13bd38e839f85fdcd2a11c8802af72dbc8b33dd396b7094f15ec293aed0}} AMR\+\_\+7\+\_\+95&\\ \hline \raisebox{\heightof{T}}[0pt][0pt]{\index{AMR\_10\_2@{AMR\_10\_2}!codec.h@{codec.h}}\index{codec.h@{codec.h}!AMR\_10\_2@{AMR\_10\_2}}}\mbox{\label{codec_8h_aa3bfef13bd38e839f85fdcd2a11c8802a9099ffcdfa8f63214f8778eccff996f6}} AMR\+\_\+10\+\_\+2&\\ \hline \raisebox{\heightof{T}}[0pt][0pt]{\index{AMR\_12\_2@{AMR\_12\_2}!codec.h@{codec.h}}\index{codec.h@{codec.h}!AMR\_12\_2@{AMR\_12\_2}}}\mbox{\label{codec_8h_aa3bfef13bd38e839f85fdcd2a11c8802a2823f5ffd0553b9e8b3de24de07081d1}} AMR\+\_\+12\+\_\+2&\\ \hline \raisebox{\heightof{T}}[0pt][0pt]{\index{AMR\_SID@{AMR\_SID}!codec.h@{codec.h}}\index{codec.h@{codec.h}!AMR\_SID@{AMR\_SID}}}\mbox{\label{codec_8h_aa3bfef13bd38e839f85fdcd2a11c8802ac141867c27854f5a1ced1b809faed2f7}} AMR\+\_\+\+SID&\\ \hline \raisebox{\heightof{T}}[0pt][0pt]{\index{AMR\_GSM\_EFR\_SID@{AMR\_GSM\_EFR\_SID}!codec.h@{codec.h}}\index{codec.h@{codec.h}!AMR\_GSM\_EFR\_SID@{AMR\_GSM\_EFR\_SID}}}\mbox{\label{codec_8h_aa3bfef13bd38e839f85fdcd2a11c8802abf434964f2363b746e93bb986ee869d8}} AMR\+\_\+\+GSM\+\_\+\+EFR\+\_\+\+SID&\\ \hline \raisebox{\heightof{T}}[0pt][0pt]{\index{AMR\_TDMA\_EFR\_SID@{AMR\_TDMA\_EFR\_SID}!codec.h@{codec.h}}\index{codec.h@{codec.h}!AMR\_TDMA\_EFR\_SID@{AMR\_TDMA\_EFR\_SID}}}\mbox{\label{codec_8h_aa3bfef13bd38e839f85fdcd2a11c8802aff538b6244088e5d64381ccf90d155f9}} AMR\+\_\+\+TDMA\+\_\+\+EFR\+\_\+\+SID&\\ \hline \raisebox{\heightof{T}}[0pt][0pt]{\index{AMR\_PDC\_EFR\_SID@{AMR\_PDC\_EFR\_SID}!codec.h@{codec.h}}\index{codec.h@{codec.h}!AMR\_PDC\_EFR\_SID@{AMR\_PDC\_EFR\_SID}}}\mbox{\label{codec_8h_aa3bfef13bd38e839f85fdcd2a11c8802abfd9cd1a65cdfe99ded3d5c48618b9da}} AMR\+\_\+\+PDC\+\_\+\+EFR\+\_\+\+SID&\\ \hline \raisebox{\heightof{T}}[0pt][0pt]{\index{AMR\_NO\_DATA@{AMR\_NO\_DATA}!codec.h@{codec.h}}\index{codec.h@{codec.h}!AMR\_NO\_DATA@{AMR\_NO\_DATA}}}\mbox{\label{codec_8h_aa3bfef13bd38e839f85fdcd2a11c8802a009720fb877b08458a901d3b1ff38104}} AMR\+\_\+\+NO\+\_\+\+DATA&\\ \hline \end{DoxyEnumFields} \mbox{\label{codec_8h_aac2ddb7abf585e62ac811d5812cbd4bb}} \index{codec.h@{codec.h}!osmo\_gsm631\_sid\_class@{osmo\_gsm631\_sid\_class}} \index{osmo\_gsm631\_sid\_class@{osmo\_gsm631\_sid\_class}!codec.h@{codec.h}} \doxysubsubsection{osmo\_gsm631\_sid\_class} {\footnotesize\ttfamily enum \textbf{ osmo\+\_\+gsm631\+\_\+sid\+\_\+class}} \begin{DoxyEnumFields}{Enumerator} \raisebox{\heightof{T}}[0pt][0pt]{\index{OSMO\_GSM631\_SID\_CLASS\_SPEECH@{OSMO\_GSM631\_SID\_CLASS\_SPEECH}!codec.h@{codec.h}}\index{codec.h@{codec.h}!OSMO\_GSM631\_SID\_CLASS\_SPEECH@{OSMO\_GSM631\_SID\_CLASS\_SPEECH}}}\mbox{\label{codec_8h_aac2ddb7abf585e62ac811d5812cbd4bba4cbe25e70357d2ed958b90b0fb8cd1e0}} OSMO\+\_\+\+GSM631\+\_\+\+SID\+\_\+\+CLASS\+\_\+\+SPEECH&\\ \hline \raisebox{\heightof{T}}[0pt][0pt]{\index{OSMO\_GSM631\_SID\_CLASS\_INVALID@{OSMO\_GSM631\_SID\_CLASS\_INVALID}!codec.h@{codec.h}}\index{codec.h@{codec.h}!OSMO\_GSM631\_SID\_CLASS\_INVALID@{OSMO\_GSM631\_SID\_CLASS\_INVALID}}}\mbox{\label{codec_8h_aac2ddb7abf585e62ac811d5812cbd4bba9654cf2d4005dbf30136665120494543}} OSMO\+\_\+\+GSM631\+\_\+\+SID\+\_\+\+CLASS\+\_\+\+INVALID&\\ \hline \raisebox{\heightof{T}}[0pt][0pt]{\index{OSMO\_GSM631\_SID\_CLASS\_VALID@{OSMO\_GSM631\_SID\_CLASS\_VALID}!codec.h@{codec.h}}\index{codec.h@{codec.h}!OSMO\_GSM631\_SID\_CLASS\_VALID@{OSMO\_GSM631\_SID\_CLASS\_VALID}}}\mbox{\label{codec_8h_aac2ddb7abf585e62ac811d5812cbd4bba88b53a83aeed926d901cf093ebdfe54a}} OSMO\+\_\+\+GSM631\+\_\+\+SID\+\_\+\+CLASS\+\_\+\+VALID&\\ \hline \end{DoxyEnumFields} \doxysubsection{Function Documentation} \mbox{\label{codec_8h_a899b52a70d03f8f4a8d79a9ed1a0103d}} \index{codec.h@{codec.h}!osmo\_amr\_d\_to\_s@{osmo\_amr\_d\_to\_s}} \index{osmo\_amr\_d\_to\_s@{osmo\_amr\_d\_to\_s}!codec.h@{codec.h}} \doxysubsubsection{osmo\_amr\_d\_to\_s()} {\footnotesize\ttfamily int osmo\+\_\+amr\+\_\+d\+\_\+to\+\_\+s (\begin{DoxyParamCaption}\item[{\textbf{ ubit\+\_\+t} $\ast$}]{out, }\item[{const \textbf{ ubit\+\_\+t} $\ast$}]{in, }\item[{uint16\+\_\+t}]{n\+\_\+bits, }\item[{enum \textbf{ osmo\+\_\+amr\+\_\+type}}]{amr\+\_\+mode }\end{DoxyParamCaption})} Convert from d-\/bits to s-\/bits (codec input). \begin{DoxyParams}[1]{Parameters} \mbox{\texttt{ out}} & {\em out} & user-\/provided output buffer for generated unpacked s-\/bits \\ \hline \mbox{\texttt{ in}} & {\em in} & input buffer for unpacked d-\/bits \\ \hline \mbox{\texttt{ in}} & {\em n\+\_\+bits} & number of bits (in both in and out) \\ \hline \mbox{\texttt{ in}} & {\em AMR} & mode (0..7) \\ \hline \end{DoxyParams} References \textbf{ ARRAY\+\_\+\+SIZE}, \textbf{ ts26101\+\_\+reorder\+\_\+table\+::len}, \textbf{ n}, \textbf{ ts26101\+\_\+reorder\+\_\+table\+::s\+\_\+to\+\_\+d}, and \textbf{ ts26101\+\_\+reorder\+\_\+tables}. \mbox{\label{codec_8h_aa68a81a724f0ffe8489217f459459b2a}} \index{codec.h@{codec.h}!osmo\_amr\_is\_speech@{osmo\_amr\_is\_speech}} \index{osmo\_amr\_is\_speech@{osmo\_amr\_is\_speech}!codec.h@{codec.h}} \doxysubsubsection{osmo\_amr\_is\_speech()} {\footnotesize\ttfamily static bool osmo\+\_\+amr\+\_\+is\+\_\+speech (\begin{DoxyParamCaption}\item[{enum \textbf{ osmo\+\_\+amr\+\_\+type}}]{ft }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}, {\ttfamily [static]}} Check if given AMR Frame Type is a speech frame. \begin{DoxyParams}[1]{Parameters} \mbox{\texttt{ in}} & {\em ft} & AMR Frame Type \\ \hline \end{DoxyParams} \begin{DoxyReturn}{Returns} true if AMR with given Frame Type contains voice, false otherwise \end{DoxyReturn} References \textbf{ AMR\+\_\+10\+\_\+2}, \textbf{ AMR\+\_\+12\+\_\+2}, \textbf{ AMR\+\_\+4\+\_\+75}, \textbf{ AMR\+\_\+5\+\_\+15}, \textbf{ AMR\+\_\+5\+\_\+90}, \textbf{ AMR\+\_\+6\+\_\+70}, \textbf{ AMR\+\_\+7\+\_\+40}, and \textbf{ AMR\+\_\+7\+\_\+95}. \mbox{\label{codec_8h_aaab21df7f423c43adbfd5ef3ccfb6316}} \index{codec.h@{codec.h}!osmo\_amr\_rtp\_dec@{osmo\_amr\_rtp\_dec}} \index{osmo\_amr\_rtp\_dec@{osmo\_amr\_rtp\_dec}!codec.h@{codec.h}} \doxysubsubsection{osmo\_amr\_rtp\_dec()} {\footnotesize\ttfamily int osmo\+\_\+amr\+\_\+rtp\+\_\+dec (\begin{DoxyParamCaption}\item[{const uint8\+\_\+t $\ast$}]{rtppayload, }\item[{int}]{payload\+\_\+len, }\item[{uint8\+\_\+t $\ast$}]{cmr, }\item[{int8\+\_\+t $\ast$}]{cmi, }\item[{enum \textbf{ osmo\+\_\+amr\+\_\+type} $\ast$}]{ft, }\item[{enum \textbf{ osmo\+\_\+amr\+\_\+quality} $\ast$}]{bfi, }\item[{int8\+\_\+t $\ast$}]{sti }\end{DoxyParamCaption})} Decode various AMR parameters from RTP payload (RFC 4867) acording to 3GPP TS 26.\+101. \begin{DoxyParams}[1]{Parameters} \mbox{\texttt{ in}} & {\em rtppayload} & Payload from RTP packet \\ \hline \mbox{\texttt{ in}} & {\em payload\+\_\+len} & length of rtppayload \\ \hline \mbox{\texttt{ out}} & {\em cmr} & AMR Codec Mode Request, not filled if NULL \\ \hline \mbox{\texttt{ out}} & {\em cmi} & AMR Codec Mode Indicator, -\/1 if not applicable for this type, not filled if NULL \\ \hline \mbox{\texttt{ out}} & {\em ft} & AMR Frame Type, not filled if NULL \\ \hline \mbox{\texttt{ out}} & {\em bfi} & AMR Bad Frame Indicator, not filled if NULL \\ \hline \mbox{\texttt{ out}} & {\em sti} & AMR SID Type Indicator, -\/1 if not applicable for this type, not filled if NULL \\ \hline \end{DoxyParams} \begin{DoxyReturn}{Returns} length of AMR data or negative value on error \end{DoxyReturn} References \textbf{ amr\+\_\+len\+\_\+by\+\_\+ft}, \textbf{ AMR\+\_\+\+SID}, \textbf{ ENOTSUP}, and \textbf{ type}. \mbox{\label{codec_8h_a9a65632c3a42a46bb5b1145750a80c77}} \index{codec.h@{codec.h}!osmo\_amr\_rtp\_enc@{osmo\_amr\_rtp\_enc}} \index{osmo\_amr\_rtp\_enc@{osmo\_amr\_rtp\_enc}!codec.h@{codec.h}} \doxysubsubsection{osmo\_amr\_rtp\_enc()} {\footnotesize\ttfamily int osmo\+\_\+amr\+\_\+rtp\+\_\+enc (\begin{DoxyParamCaption}\item[{uint8\+\_\+t $\ast$}]{payload, }\item[{uint8\+\_\+t}]{cmr, }\item[{enum \textbf{ osmo\+\_\+amr\+\_\+type}}]{ft, }\item[{enum \textbf{ osmo\+\_\+amr\+\_\+quality}}]{bfi }\end{DoxyParamCaption})} Encode various AMR parameters from RTP payload (RFC 4867) \begin{DoxyParams}[1]{Parameters} \mbox{\texttt{ out}} & {\em payload} & Payload for RTP packet, contains speech data (if any) except for have 2 first bytes where header will be built \\ \hline \mbox{\texttt{ in}} & {\em cmr} & AMR codec Mode Request \\ \hline \mbox{\texttt{ in}} & {\em ft} & AMR Frame Type \\ \hline \mbox{\texttt{ in}} & {\em bfi} & AMR Bad Frame Indicator \\ \hline \end{DoxyParams} \begin{DoxyReturn}{Returns} length of AMR data (header + ToC + speech data) or negative value on error \end{DoxyReturn} Note\+: only octet-\/aligned mode is supported so the header occupies 2 full bytes. Optional interleaving header is not supported. References \textbf{ amr\+\_\+len\+\_\+by\+\_\+ft}, and \textbf{ ENOTSUP}. \mbox{\label{codec_8h_aba0ae5e40e01a1d075d952fbd15c320c}} \index{codec.h@{codec.h}!osmo\_amr\_s\_to\_d@{osmo\_amr\_s\_to\_d}} \index{osmo\_amr\_s\_to\_d@{osmo\_amr\_s\_to\_d}!codec.h@{codec.h}} \doxysubsubsection{osmo\_amr\_s\_to\_d()} {\footnotesize\ttfamily int osmo\+\_\+amr\+\_\+s\+\_\+to\+\_\+d (\begin{DoxyParamCaption}\item[{\textbf{ ubit\+\_\+t} $\ast$}]{out, }\item[{const \textbf{ ubit\+\_\+t} $\ast$}]{in, }\item[{uint16\+\_\+t}]{n\+\_\+bits, }\item[{enum \textbf{ osmo\+\_\+amr\+\_\+type}}]{amr\+\_\+mode }\end{DoxyParamCaption})} Convert from S-\/bits (codec output) to d-\/bits. \begin{DoxyParams}[1]{Parameters} \mbox{\texttt{ out}} & {\em out} & user-\/provided output buffer for generated unpacked d-\/bits \\ \hline \mbox{\texttt{ in}} & {\em in} & input buffer for unpacked s-\/bits \\ \hline \mbox{\texttt{ in}} & {\em n\+\_\+bits} & number of bits (in both in and out) \\ \hline \mbox{\texttt{ in}} & {\em AMR} & mode (0..7) \\ \hline \end{DoxyParams} References \textbf{ ARRAY\+\_\+\+SIZE}, \textbf{ ts26101\+\_\+reorder\+\_\+table\+::len}, \textbf{ n}, \textbf{ ts26101\+\_\+reorder\+\_\+table\+::s\+\_\+to\+\_\+d}, and \textbf{ ts26101\+\_\+reorder\+\_\+tables}. \mbox{\label{codec_8h_a898ddbb819c7cd8adfdc5b690d3623f1}} \index{codec.h@{codec.h}!osmo\_amr\_type\_name@{osmo\_amr\_type\_name}} \index{osmo\_amr\_type\_name@{osmo\_amr\_type\_name}!codec.h@{codec.h}} \doxysubsubsection{osmo\_amr\_type\_name()} {\footnotesize\ttfamily static const char $\ast$ osmo\+\_\+amr\+\_\+type\+\_\+name (\begin{DoxyParamCaption}\item[{enum \textbf{ osmo\+\_\+amr\+\_\+type}}]{type }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}, {\ttfamily [static]}} References \textbf{ get\+\_\+value\+\_\+string()}, \textbf{ osmo\+\_\+amr\+\_\+type\+\_\+names}, and \textbf{ type}. \mbox{\label{codec_8h_adc6010383adb5b47724576ac1ae07ae4}} \index{codec.h@{codec.h}!osmo\_efr\_check\_sid@{osmo\_efr\_check\_sid}} \index{osmo\_efr\_check\_sid@{osmo\_efr\_check\_sid}!codec.h@{codec.h}} \doxysubsubsection{osmo\_efr\_check\_sid()} {\footnotesize\ttfamily bool osmo\+\_\+efr\+\_\+check\+\_\+sid (\begin{DoxyParamCaption}\item[{const uint8\+\_\+t $\ast$}]{rtp\+\_\+payload, }\item[{size\+\_\+t}]{payload\+\_\+len }\end{DoxyParamCaption})} Check whether RTP frame contains EFR SID code word according to TS 101 318 §5.3.\+2. \begin{DoxyParams}[1]{Parameters} \mbox{\texttt{ in}} & {\em rtp\+\_\+payload} & Buffer with RTP payload \\ \hline \mbox{\texttt{ in}} & {\em payload\+\_\+len} & Length of payload \\ \hline \end{DoxyParams} \begin{DoxyReturn}{Returns} true if code word is found, false otherwise \end{DoxyReturn} References \textbf{ ARRAY\+\_\+\+SIZE}, \textbf{ bitvec\+\_\+get\+\_\+bit\+\_\+pos()}, \textbf{ bitvec\+::data}, \textbf{ bitvec\+::data\+\_\+len}, \textbf{ ONE}, and \textbf{ sid\+\_\+code\+\_\+word\+\_\+bits}. \mbox{\label{codec_8h_acace463308f5ecdd7cb74b6602e61167}} \index{codec.h@{codec.h}!osmo\_efr\_is\_any\_sid@{osmo\_efr\_is\_any\_sid}} \index{osmo\_efr\_is\_any\_sid@{osmo\_efr\_is\_any\_sid}!codec.h@{codec.h}} \doxysubsubsection{osmo\_efr\_is\_any\_sid()} {\footnotesize\ttfamily static bool osmo\+\_\+efr\+\_\+is\+\_\+any\+\_\+sid (\begin{DoxyParamCaption}\item[{const uint8\+\_\+t $\ast$}]{rtp\+\_\+payload }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}, {\ttfamily [static]}} Check if given EFR codec frame is any kind of SID, valid or invalid. \begin{DoxyParams}[1]{Parameters} \mbox{\texttt{ in}} & {\em rtp\+\_\+payload} & Buffer with RTP payload \\ \hline \end{DoxyParams} \begin{DoxyReturn}{Returns} true if the frame is an \char`\"{}accepted SID frame\char`\"{} in GSM 06.\+81 definition, false otherwise. \end{DoxyReturn} References \textbf{ osmo\+\_\+efr\+\_\+sid\+\_\+classify()}, and \textbf{ OSMO\+\_\+\+GSM631\+\_\+\+SID\+\_\+\+CLASS\+\_\+\+SPEECH}. \mbox{\label{codec_8h_a625616d18bff243c177ab5e388786858}} \index{codec.h@{codec.h}!osmo\_efr\_sid\_classify@{osmo\_efr\_sid\_classify}} \index{osmo\_efr\_sid\_classify@{osmo\_efr\_sid\_classify}!codec.h@{codec.h}} \doxysubsubsection{osmo\_efr\_sid\_classify()} {\footnotesize\ttfamily enum \textbf{ osmo\+\_\+gsm631\+\_\+sid\+\_\+class} osmo\+\_\+efr\+\_\+sid\+\_\+classify (\begin{DoxyParamCaption}\item[{const uint8\+\_\+t $\ast$}]{rtp\+\_\+payload }\end{DoxyParamCaption})} Classify potentially-\/\+SID EFR codec frame in RTP format according to the rules of GSM 06.\+81 §6.1.\+1. \begin{DoxyParams}[1]{Parameters} \mbox{\texttt{ in}} & {\em rtp\+\_\+payload} & Buffer with RTP payload \\ \hline \end{DoxyParams} \begin{DoxyReturn}{Returns} enum osmo\+\_\+gsm631\+\_\+sid\+\_\+class, with symbolic values OSMO\+\_\+\+GSM631\+\_\+\+SID\+\_\+\+CLASS\+\_\+\+SPEECH, OSMO\+\_\+\+GSM631\+\_\+\+SID\+\_\+\+CLASS\+\_\+\+INVALID or OSMO\+\_\+\+GSM631\+\_\+\+SID\+\_\+\+CLASS\+\_\+\+VALID corresponding to the 3 possible bit-\/counting classifications prescribed by the spec. \end{DoxyReturn} Differences between the more familiar \doxyref{osmo\+\_\+efr\+\_\+check\+\_\+sid()}{p.}{gsm660_8c_adc6010383adb5b47724576ac1ae07ae4} and the present function are\+: \begin{DoxyEnumerate} \item \doxyref{osmo\+\_\+efr\+\_\+check\+\_\+sid()}{p.}{gsm660_8c_adc6010383adb5b47724576ac1ae07ae4} returns true only if the SID frame is absolutely perfect, with all 95 bits of the SID code word set. However, the rules of GSM 06.\+81 §6.1.\+1 allow up to one bit to be in error, and the frame is still accepted as valid SID. \item The third possible state of invalid SID is not handled at all by the simpler \doxyref{osmo\+\_\+efr\+\_\+check\+\_\+sid()}{p.}{gsm660_8c_adc6010383adb5b47724576ac1ae07ae4} function. \item \doxyref{osmo\+\_\+efr\+\_\+check\+\_\+sid()}{p.}{gsm660_8c_adc6010383adb5b47724576ac1ae07ae4} includes a check for 0xC RTP signature, and returns false if that signature nibble is wrong. That check is not included in the present version because there is no place for it in the ETSI-\/prescribed classification, it is neither speech nor SID. The assumption is that this function is used to classify the bit content of received codec frames, not their RTP encoding -\/ the latter needs to be validated beforehand. \end{DoxyEnumerate} Which function should one use? The answer depends on the specific circumstances, and needs to be addressed on a case-\/by-\/case basis. References \textbf{ ARRAY\+\_\+\+SIZE}, \textbf{ bitvec\+\_\+get\+\_\+bit\+\_\+pos()}, \textbf{ bitvec\+::data}, \textbf{ bitvec\+::data\+\_\+len}, \textbf{ GSM\+\_\+\+EFR\+\_\+\+BYTES}, \textbf{ n}, \textbf{ ONE}, \textbf{ OSMO\+\_\+\+GSM631\+\_\+\+SID\+\_\+\+CLASS\+\_\+\+INVALID}, \textbf{ OSMO\+\_\+\+GSM631\+\_\+\+SID\+\_\+\+CLASS\+\_\+\+SPEECH}, \textbf{ OSMO\+\_\+\+GSM631\+\_\+\+SID\+\_\+\+CLASS\+\_\+\+VALID}, and \textbf{ sid\+\_\+code\+\_\+word\+\_\+bits}. Referenced by \textbf{ osmo\+\_\+efr\+\_\+is\+\_\+any\+\_\+sid()}, and \textbf{ osmo\+\_\+efr\+\_\+sid\+\_\+preen()}. \mbox{\label{codec_8h_a6824b93700b9514c4c796826cf0b3904}} \index{codec.h@{codec.h}!osmo\_efr\_sid\_preen@{osmo\_efr\_sid\_preen}} \index{osmo\_efr\_sid\_preen@{osmo\_efr\_sid\_preen}!codec.h@{codec.h}} \doxysubsubsection{osmo\_efr\_sid\_preen()} {\footnotesize\ttfamily bool osmo\+\_\+efr\+\_\+sid\+\_\+preen (\begin{DoxyParamCaption}\item[{uint8\+\_\+t $\ast$}]{rtp\+\_\+payload }\end{DoxyParamCaption})} Preen potentially-\/\+SID EFR codec frame in RTP format, ensuring that it is either a speech frame or a valid SID, and if the latter, making it a perfect, error-\/free SID frame. \begin{DoxyParams}[1]{Parameters} \mbox{\texttt{ in}} & {\em rtp\+\_\+payload} & Buffer with RTP payload -\/ must be writable! \\ \hline \end{DoxyParams} \begin{DoxyReturn}{Returns} true if the frame is good, false otherwise \end{DoxyReturn} References \textbf{ OSMO\+\_\+\+ASSERT}, \textbf{ osmo\+\_\+efr\+\_\+sid\+\_\+classify()}, \textbf{ osmo\+\_\+efr\+\_\+sid\+\_\+reset()}, \textbf{ OSMO\+\_\+\+GSM631\+\_\+\+SID\+\_\+\+CLASS\+\_\+\+INVALID}, \textbf{ OSMO\+\_\+\+GSM631\+\_\+\+SID\+\_\+\+CLASS\+\_\+\+SPEECH}, and \textbf{ OSMO\+\_\+\+GSM631\+\_\+\+SID\+\_\+\+CLASS\+\_\+\+VALID}. \mbox{\label{codec_8h_a53ea5bc297fc25818f414ab2c0672603}} \index{codec.h@{codec.h}!osmo\_efr\_sid\_reset@{osmo\_efr\_sid\_reset}} \index{osmo\_efr\_sid\_reset@{osmo\_efr\_sid\_reset}!codec.h@{codec.h}} \doxysubsubsection{osmo\_efr\_sid\_reset()} {\footnotesize\ttfamily void osmo\+\_\+efr\+\_\+sid\+\_\+reset (\begin{DoxyParamCaption}\item[{uint8\+\_\+t $\ast$}]{rtp\+\_\+payload }\end{DoxyParamCaption})} Reset the SID field of a potentially corrupted, but still valid GSM-\/\+EFR SID frame in RTP encoding to its pristine state (full SID code word). \begin{DoxyParams}[1]{Parameters} \mbox{\texttt{ in}} & {\em rtp\+\_\+payload} & Buffer with RTP payload -\/ must be writable!\\ \hline \end{DoxyParams} Per GSM 06.\+62 section 5.\+3, a freshly minted SID frame consists of 58 bits of comfort noise parameters (LSF and 4 times fixed codebook gain), 95 bits of SID code word (all 1s) and 91 unused bits (all 0s). Network elements that receive SID frames from call leg A uplink and need to retransmit them on leg B downlink should \char`\"{}rejuvenate\char`\"{} received SID frames prior to retransmission by resetting the SID field to its pristine state of all 1s; this function does the job. Potential TODO\+: it would be nice to also zero out the remaining 91 bits which the spec leaves as reserved, clearing out leg A radio bit errors -\/ but do we really need to? Referenced by \textbf{ osmo\+\_\+efr\+\_\+sid\+\_\+preen()}. \mbox{\label{codec_8h_a20ec1df6610a428b6faadac2ccff0faf}} \index{codec.h@{codec.h}!osmo\_fr\_check\_sid@{osmo\_fr\_check\_sid}} \index{osmo\_fr\_check\_sid@{osmo\_fr\_check\_sid}!codec.h@{codec.h}} \doxysubsubsection{osmo\_fr\_check\_sid()} {\footnotesize\ttfamily bool osmo\+\_\+fr\+\_\+check\+\_\+sid (\begin{DoxyParamCaption}\item[{const uint8\+\_\+t $\ast$}]{rtp\+\_\+payload, }\item[{size\+\_\+t}]{payload\+\_\+len }\end{DoxyParamCaption})} Check whether RTP frame contains FR SID code word according to TS 101 318 §5.1.\+2. \begin{DoxyParams}[1]{Parameters} \mbox{\texttt{ in}} & {\em rtp\+\_\+payload} & Buffer with RTP payload \\ \hline \mbox{\texttt{ in}} & {\em payload\+\_\+len} & Length of payload \\ \hline \end{DoxyParams} \begin{DoxyReturn}{Returns} true if code word is found, false otherwise \end{DoxyReturn} References \textbf{ ARRAY\+\_\+\+SIZE}, \textbf{ bitvec\+\_\+get\+\_\+bit\+\_\+pos()}, \textbf{ bitvec\+::data}, \textbf{ bitvec\+::data\+\_\+len}, \textbf{ sid\+\_\+code\+\_\+word\+\_\+bits}, and \textbf{ ZERO}. Referenced by \textbf{ conceal\+\_\+frame()}. \mbox{\label{codec_8h_a04eb006d11b88ec9b45ebbdd3d49d54f}} \index{codec.h@{codec.h}!osmo\_fr\_is\_any\_sid@{osmo\_fr\_is\_any\_sid}} \index{osmo\_fr\_is\_any\_sid@{osmo\_fr\_is\_any\_sid}!codec.h@{codec.h}} \doxysubsubsection{osmo\_fr\_is\_any\_sid()} {\footnotesize\ttfamily static bool osmo\+\_\+fr\+\_\+is\+\_\+any\+\_\+sid (\begin{DoxyParamCaption}\item[{const uint8\+\_\+t $\ast$}]{rtp\+\_\+payload }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}, {\ttfamily [static]}} Check if given FR codec frame is any kind of SID, valid or invalid. \begin{DoxyParams}[1]{Parameters} \mbox{\texttt{ in}} & {\em rtp\+\_\+payload} & Buffer with RTP payload \\ \hline \end{DoxyParams} \begin{DoxyReturn}{Returns} true if the frame is an \char`\"{}accepted SID frame\char`\"{} in GSM 06.\+31 definition, false otherwise. \end{DoxyReturn} References \textbf{ osmo\+\_\+fr\+\_\+sid\+\_\+classify()}, and \textbf{ OSMO\+\_\+\+GSM631\+\_\+\+SID\+\_\+\+CLASS\+\_\+\+SPEECH}. \mbox{\label{codec_8h_a7d88af998487b2b71d10ea0a6fa6fe07}} \index{codec.h@{codec.h}!osmo\_fr\_sid\_classify@{osmo\_fr\_sid\_classify}} \index{osmo\_fr\_sid\_classify@{osmo\_fr\_sid\_classify}!codec.h@{codec.h}} \doxysubsubsection{osmo\_fr\_sid\_classify()} {\footnotesize\ttfamily enum \textbf{ osmo\+\_\+gsm631\+\_\+sid\+\_\+class} osmo\+\_\+fr\+\_\+sid\+\_\+classify (\begin{DoxyParamCaption}\item[{const uint8\+\_\+t $\ast$}]{rtp\+\_\+payload }\end{DoxyParamCaption})} Classify potentially-\/\+SID FR codec frame in RTP format according to the rules of GSM 06.\+31 §6.1.\+1. \begin{DoxyParams}[1]{Parameters} \mbox{\texttt{ in}} & {\em rtp\+\_\+payload} & Buffer with RTP payload \\ \hline \end{DoxyParams} \begin{DoxyReturn}{Returns} enum osmo\+\_\+gsm631\+\_\+sid\+\_\+class, with symbolic values OSMO\+\_\+\+GSM631\+\_\+\+SID\+\_\+\+CLASS\+\_\+\+SPEECH, OSMO\+\_\+\+GSM631\+\_\+\+SID\+\_\+\+CLASS\+\_\+\+INVALID or OSMO\+\_\+\+GSM631\+\_\+\+SID\+\_\+\+CLASS\+\_\+\+VALID corresponding to the 3 possible bit-\/counting classifications prescribed by the spec. \end{DoxyReturn} Differences between the more familiar \doxyref{osmo\+\_\+fr\+\_\+check\+\_\+sid()}{p.}{gsm610_8c_a20ec1df6610a428b6faadac2ccff0faf} and the present function are\+: \begin{DoxyEnumerate} \item \doxyref{osmo\+\_\+fr\+\_\+check\+\_\+sid()}{p.}{gsm610_8c_a20ec1df6610a428b6faadac2ccff0faf} returns true only if the SID frame is absolutely perfect, with all 95 bits of the SID code word zeroed. However, the rules of GSM 06.\+31 §6.1.\+1 allow up to one bit to be in error, and the frame is still accepted as valid SID. \item The third possible state of invalid SID is not handled at all by the simpler \doxyref{osmo\+\_\+fr\+\_\+check\+\_\+sid()}{p.}{gsm610_8c_a20ec1df6610a428b6faadac2ccff0faf} function. \item \doxyref{osmo\+\_\+fr\+\_\+check\+\_\+sid()}{p.}{gsm610_8c_a20ec1df6610a428b6faadac2ccff0faf} includes a check for 0xD RTP signature, and returns false if that signature nibble is wrong. That check is not included in the present version because there is no place for it in the ETSI-\/prescribed classification, it is neither speech nor SID. The assumption is that this function is used to classify the bit content of received codec frames, not their RTP encoding -\/ the latter needs to be validated beforehand. \end{DoxyEnumerate} Which function should one use? The answer depends on the specific circumstances, and needs to be addressed on a case-\/by-\/case basis. References \textbf{ ARRAY\+\_\+\+SIZE}, \textbf{ bitvec\+\_\+get\+\_\+bit\+\_\+pos()}, \textbf{ bitvec\+::data}, \textbf{ bitvec\+::data\+\_\+len}, \textbf{ GSM\+\_\+\+FR\+\_\+\+BYTES}, \textbf{ n}, \textbf{ OSMO\+\_\+\+GSM631\+\_\+\+SID\+\_\+\+CLASS\+\_\+\+INVALID}, \textbf{ OSMO\+\_\+\+GSM631\+\_\+\+SID\+\_\+\+CLASS\+\_\+\+SPEECH}, \textbf{ OSMO\+\_\+\+GSM631\+\_\+\+SID\+\_\+\+CLASS\+\_\+\+VALID}, \textbf{ sid\+\_\+code\+\_\+word\+\_\+bits}, and \textbf{ ZERO}. Referenced by \textbf{ fr\+\_\+ecu\+\_\+input()}, \textbf{ osmo\+\_\+fr\+\_\+is\+\_\+any\+\_\+sid()}, and \textbf{ osmo\+\_\+fr\+\_\+sid\+\_\+preen()}. \mbox{\label{codec_8h_a22c81d44e6b5ebeec19fb33aace3f214}} \index{codec.h@{codec.h}!osmo\_fr\_sid\_preen@{osmo\_fr\_sid\_preen}} \index{osmo\_fr\_sid\_preen@{osmo\_fr\_sid\_preen}!codec.h@{codec.h}} \doxysubsubsection{osmo\_fr\_sid\_preen()} {\footnotesize\ttfamily bool osmo\+\_\+fr\+\_\+sid\+\_\+preen (\begin{DoxyParamCaption}\item[{uint8\+\_\+t $\ast$}]{rtp\+\_\+payload }\end{DoxyParamCaption})} Preen potentially-\/\+SID FR codec frame in RTP format, ensuring that it is either a speech frame or a valid SID, and if the latter, making it a perfect, error-\/free SID frame. \begin{DoxyParams}[1]{Parameters} \mbox{\texttt{ in}} & {\em rtp\+\_\+payload} & Buffer with RTP payload -\/ must be writable! \\ \hline \end{DoxyParams} \begin{DoxyReturn}{Returns} true if the frame is good, false otherwise \end{DoxyReturn} References \textbf{ OSMO\+\_\+\+ASSERT}, \textbf{ osmo\+\_\+fr\+\_\+sid\+\_\+classify()}, \textbf{ osmo\+\_\+fr\+\_\+sid\+\_\+reset()}, \textbf{ OSMO\+\_\+\+GSM631\+\_\+\+SID\+\_\+\+CLASS\+\_\+\+INVALID}, \textbf{ OSMO\+\_\+\+GSM631\+\_\+\+SID\+\_\+\+CLASS\+\_\+\+SPEECH}, and \textbf{ OSMO\+\_\+\+GSM631\+\_\+\+SID\+\_\+\+CLASS\+\_\+\+VALID}. \mbox{\label{codec_8h_a9a5cdba9e2924cdb1613a4ed8aa2a6a3}} \index{codec.h@{codec.h}!osmo\_fr\_sid\_reset@{osmo\_fr\_sid\_reset}} \index{osmo\_fr\_sid\_reset@{osmo\_fr\_sid\_reset}!codec.h@{codec.h}} \doxysubsubsection{osmo\_fr\_sid\_reset()} {\footnotesize\ttfamily void osmo\+\_\+fr\+\_\+sid\+\_\+reset (\begin{DoxyParamCaption}\item[{uint8\+\_\+t $\ast$}]{rtp\+\_\+payload }\end{DoxyParamCaption})} Reset the SID field and the unused bits of a potentially corrupted, but still valid GSM-\/\+FR SID frame in RTP encoding to their pristine state. \begin{DoxyParams}[1]{Parameters} \mbox{\texttt{ in}} & {\em rtp\+\_\+payload} & Buffer with RTP payload -\/ must be writable!\\ \hline \end{DoxyParams} Per GSM 06.\+12 section 5.\+2, a freshly minted SID frame carries 60 bits of comfort noise parameters (LARc and 4 times Xmaxc), while the remaining 200 bits are all zeros; the latter 200 all-\/0 bits further break down into 95 bits of SID field (checked by receivers to detect SID) and 105 unused bits which receivers are told to ignore. Network elements that receive SID frames from call leg A uplink and need to retransmit them on leg B downlink should \char`\"{}rejuvenate\char`\"{} received SID frames prior to retransmission; this function does the job. Referenced by \textbf{ osmo\+\_\+fr\+\_\+sid\+\_\+preen()}. \mbox{\label{codec_8h_ad9b2ad0ca9540027568e398ca070f645}} \index{codec.h@{codec.h}!osmo\_hr\_check\_sid@{osmo\_hr\_check\_sid}} \index{osmo\_hr\_check\_sid@{osmo\_hr\_check\_sid}!codec.h@{codec.h}} \doxysubsubsection{osmo\_hr\_check\_sid()} {\footnotesize\ttfamily bool osmo\+\_\+hr\+\_\+check\+\_\+sid (\begin{DoxyParamCaption}\item[{const uint8\+\_\+t $\ast$}]{rtp\+\_\+payload, }\item[{size\+\_\+t}]{payload\+\_\+len }\end{DoxyParamCaption})} Check whether RTP frame contains HR SID code word according to TS 101 318 §5.2.\+2. \begin{DoxyParams}[1]{Parameters} \mbox{\texttt{ in}} & {\em rtp\+\_\+payload} & Buffer with RTP payload \\ \hline \mbox{\texttt{ in}} & {\em payload\+\_\+len} & Length of payload \\ \hline \end{DoxyParams} \begin{DoxyReturn}{Returns} true if code word is found, false otherwise \end{DoxyReturn} Note that this function checks only for a perfect, error-\/free SID. Unlike GSM 06.\+31 for FR or GSM 06.\+81 for EFR, GSM 06.\+41 spec for HR does not prescribe exact bit counting rules, hence detection of partially corrupted SID frames in downstream network elements without out-\/of-\/band indication is not possible. References \textbf{ GSM\+\_\+\+HR\+\_\+\+BYTES}. \mbox{\label{codec_8h_aa688d31df81d12d01065c55b8d1b788a}} \index{codec.h@{codec.h}!osmo\_hr\_sid\_reset@{osmo\_hr\_sid\_reset}} \index{osmo\_hr\_sid\_reset@{osmo\_hr\_sid\_reset}!codec.h@{codec.h}} \doxysubsubsection{osmo\_hr\_sid\_reset()} {\footnotesize\ttfamily void osmo\+\_\+hr\+\_\+sid\+\_\+reset (\begin{DoxyParamCaption}\item[{uint8\+\_\+t $\ast$}]{rtp\+\_\+payload }\end{DoxyParamCaption})} Reset the SID field of a potentially corrupted, but still valid GSM-\/\+HR SID frame in TS 101 318 format to its pristine state (full SID codeword). \begin{DoxyParams}[1]{Parameters} \mbox{\texttt{ in}} & {\em rtp\+\_\+payload} & Buffer with RTP payload -\/ must be writable!\\ \hline \end{DoxyParams} Per GSM 06.\+22 section 5.\+3, a freshly minted SID frame consists of 33 bits of comfort noise parameters and 79 bits of SID codeword (all 1s). Network elements that receive SID frames from call leg A uplink and need to retransmit them on leg B downlink should \char`\"{}rejuvenate\char`\"{} received SID frames prior to retransmission by resetting the SID field to its pristine state of all 1s; this function does the job. Important note\+: because of HR-\/specific quirks (lack of exact bit counting rules in GSM 06.\+41 spec compared to 06.\+31 \& 06.\+81, plus the fact that such bit counting can only be done efficiently in the GSM 05.\+03 channel decoder prior to bit reordering based on voiced or unvoiced mode), a generic (usable from any network element) SID classification function similar to osmo\+\_\+\{fr,efr\}\+\_\+sid\+\_\+classify() unfortunately cannot exist for HR. Therefore, the triggering condition for invoking this SID rejuvenation/reset function can only be an out-\/of-\/band SID indication, as in GSM 08.\+61 TRAU frames or RFC 5993 ToC octet. \doxysubsection{Variable Documentation} \mbox{\label{codec_8h_acac81b0b75d15e191f7348d9910a8a1c}} \index{codec.h@{codec.h}!gsm610\_bitorder@{gsm610\_bitorder}} \index{gsm610\_bitorder@{gsm610\_bitorder}!codec.h@{codec.h}} \doxysubsubsection{gsm610\_bitorder} {\footnotesize\ttfamily const uint16\+\_\+t gsm610\+\_\+bitorder[$\,$]\hspace{0.3cm}{\ttfamily [extern]}} \mbox{\label{codec_8h_ac228d9385960cf497b278847a6ca7a50}} \index{codec.h@{codec.h}!gsm620\_unvoiced\_bitorder@{gsm620\_unvoiced\_bitorder}} \index{gsm620\_unvoiced\_bitorder@{gsm620\_unvoiced\_bitorder}!codec.h@{codec.h}} \doxysubsubsection{gsm620\_unvoiced\_bitorder} {\footnotesize\ttfamily const uint16\+\_\+t gsm620\+\_\+unvoiced\+\_\+bitorder[$\,$]\hspace{0.3cm}{\ttfamily [extern]}} \mbox{\label{codec_8h_aea8557d473750507daabb082b7f6438a}} \index{codec.h@{codec.h}!gsm620\_voiced\_bitorder@{gsm620\_voiced\_bitorder}} \index{gsm620\_voiced\_bitorder@{gsm620\_voiced\_bitorder}!codec.h@{codec.h}} \doxysubsubsection{gsm620\_voiced\_bitorder} {\footnotesize\ttfamily const uint16\+\_\+t gsm620\+\_\+voiced\+\_\+bitorder[$\,$]\hspace{0.3cm}{\ttfamily [extern]}} \mbox{\label{codec_8h_af8e11414a72cc4bb5bb6d0df38220fe6}} \index{codec.h@{codec.h}!gsm660\_bitorder@{gsm660\_bitorder}} \index{gsm660\_bitorder@{gsm660\_bitorder}!codec.h@{codec.h}} \doxysubsubsection{gsm660\_bitorder} {\footnotesize\ttfamily const uint16\+\_\+t gsm660\+\_\+bitorder[$\,$]\hspace{0.3cm}{\ttfamily [extern]}} \mbox{\label{codec_8h_a0b2edc5112330587525471bf22b888aa}} \index{codec.h@{codec.h}!gsm690\_10\_2\_bitorder@{gsm690\_10\_2\_bitorder}} \index{gsm690\_10\_2\_bitorder@{gsm690\_10\_2\_bitorder}!codec.h@{codec.h}} \doxysubsubsection{gsm690\_10\_2\_bitorder} {\footnotesize\ttfamily const uint16\+\_\+t gsm690\+\_\+10\+\_\+2\+\_\+bitorder[$\,$]\hspace{0.3cm}{\ttfamily [extern]}} \mbox{\label{codec_8h_acbdaf9399acb152f7f5d411eb2c8d4b4}} \index{codec.h@{codec.h}!gsm690\_12\_2\_bitorder@{gsm690\_12\_2\_bitorder}} \index{gsm690\_12\_2\_bitorder@{gsm690\_12\_2\_bitorder}!codec.h@{codec.h}} \doxysubsubsection{gsm690\_12\_2\_bitorder} {\footnotesize\ttfamily const uint16\+\_\+t gsm690\+\_\+12\+\_\+2\+\_\+bitorder[$\,$]\hspace{0.3cm}{\ttfamily [extern]}} \mbox{\label{codec_8h_a7c32bcc6270a05837382caf0c734e517}} \index{codec.h@{codec.h}!gsm690\_4\_75\_bitorder@{gsm690\_4\_75\_bitorder}} \index{gsm690\_4\_75\_bitorder@{gsm690\_4\_75\_bitorder}!codec.h@{codec.h}} \doxysubsubsection{gsm690\_4\_75\_bitorder} {\footnotesize\ttfamily const uint16\+\_\+t gsm690\+\_\+4\+\_\+75\+\_\+bitorder[$\,$]\hspace{0.3cm}{\ttfamily [extern]}} \mbox{\label{codec_8h_a8778216477a7533a494a6d4b2304e7f1}} \index{codec.h@{codec.h}!gsm690\_5\_15\_bitorder@{gsm690\_5\_15\_bitorder}} \index{gsm690\_5\_15\_bitorder@{gsm690\_5\_15\_bitorder}!codec.h@{codec.h}} \doxysubsubsection{gsm690\_5\_15\_bitorder} {\footnotesize\ttfamily const uint16\+\_\+t gsm690\+\_\+5\+\_\+15\+\_\+bitorder[$\,$]\hspace{0.3cm}{\ttfamily [extern]}} \mbox{\label{codec_8h_a7889158d7ed497f235624b8249d17f09}} \index{codec.h@{codec.h}!gsm690\_5\_9\_bitorder@{gsm690\_5\_9\_bitorder}} \index{gsm690\_5\_9\_bitorder@{gsm690\_5\_9\_bitorder}!codec.h@{codec.h}} \doxysubsubsection{gsm690\_5\_9\_bitorder} {\footnotesize\ttfamily const uint16\+\_\+t gsm690\+\_\+5\+\_\+9\+\_\+bitorder[$\,$]\hspace{0.3cm}{\ttfamily [extern]}} \mbox{\label{codec_8h_ad57f9e4bdb5239d0f335562e9bd50e53}} \index{codec.h@{codec.h}!gsm690\_6\_7\_bitorder@{gsm690\_6\_7\_bitorder}} \index{gsm690\_6\_7\_bitorder@{gsm690\_6\_7\_bitorder}!codec.h@{codec.h}} \doxysubsubsection{gsm690\_6\_7\_bitorder} {\footnotesize\ttfamily const uint16\+\_\+t gsm690\+\_\+6\+\_\+7\+\_\+bitorder[$\,$]\hspace{0.3cm}{\ttfamily [extern]}} \mbox{\label{codec_8h_a6682403306e0626dc678c4fece2c4753}} \index{codec.h@{codec.h}!gsm690\_7\_4\_bitorder@{gsm690\_7\_4\_bitorder}} \index{gsm690\_7\_4\_bitorder@{gsm690\_7\_4\_bitorder}!codec.h@{codec.h}} \doxysubsubsection{gsm690\_7\_4\_bitorder} {\footnotesize\ttfamily const uint16\+\_\+t gsm690\+\_\+7\+\_\+4\+\_\+bitorder[$\,$]\hspace{0.3cm}{\ttfamily [extern]}} \mbox{\label{codec_8h_ab87635afd295b36a0ba728ff44b8c298}} \index{codec.h@{codec.h}!gsm690\_7\_95\_bitorder@{gsm690\_7\_95\_bitorder}} \index{gsm690\_7\_95\_bitorder@{gsm690\_7\_95\_bitorder}!codec.h@{codec.h}} \doxysubsubsection{gsm690\_7\_95\_bitorder} {\footnotesize\ttfamily const uint16\+\_\+t gsm690\+\_\+7\+\_\+95\+\_\+bitorder[$\,$]\hspace{0.3cm}{\ttfamily [extern]}} \mbox{\label{codec_8h_a5a49793e7754e061231c628446330bf9}} \index{codec.h@{codec.h}!gsm690\_bitlength@{gsm690\_bitlength}} \index{gsm690\_bitlength@{gsm690\_bitlength}!codec.h@{codec.h}} \doxysubsubsection{gsm690\_bitlength} {\footnotesize\ttfamily const uint8\+\_\+t gsm690\+\_\+bitlength[\textbf{ AMR\+\_\+\+NO\+\_\+\+DATA}+1]\hspace{0.3cm}{\ttfamily [extern]}} These constants refer to the length of one \char`\"{}\+AMR core frame\char`\"{} as per TS 26.\+101 Section 4.\+2.\+2 / Table 2. \mbox{\label{codec_8h_ab84c9b2bc757b3902acd04009593fd0c}} \index{codec.h@{codec.h}!osmo\_amr\_type\_names@{osmo\_amr\_type\_names}} \index{osmo\_amr\_type\_names@{osmo\_amr\_type\_names}!codec.h@{codec.h}} \doxysubsubsection{osmo\_amr\_type\_names} {\footnotesize\ttfamily const struct \textbf{ value\+\_\+string} osmo\+\_\+amr\+\_\+type\+\_\+names[$\,$]\hspace{0.3cm}{\ttfamily [extern]}} Referenced by \textbf{ osmo\+\_\+amr\+\_\+type\+\_\+name()}. \mbox{\label{codec_8h_a66bd8670d5a45cc42022e58024f8aa3d}} \index{codec.h@{codec.h}!osmo\_gsm611\_silence\_frame@{osmo\_gsm611\_silence\_frame}} \index{osmo\_gsm611\_silence\_frame@{osmo\_gsm611\_silence\_frame}!codec.h@{codec.h}} \doxysubsubsection{osmo\_gsm611\_silence\_frame} {\footnotesize\ttfamily const uint8\+\_\+t osmo\+\_\+gsm611\+\_\+silence\+\_\+frame[\textbf{ GSM\+\_\+\+FR\+\_\+\+BYTES}]\hspace{0.3cm}{\ttfamily [extern]}} Referenced by \textbf{ fr\+\_\+ecu\+\_\+output()}.