> For the complete documentation index, see [llms.txt](https://prosbcdocs.telcobridges.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://prosbcdocs.telcobridges.com/telecom-references/sip-and-voip/caf-filling-sdp-structures.md).

# CAF: Filling SDP Structures

There are two ways to fill a TBX\_SDP\_INFO structure.

#### Filling a TBX\_SDP\_INFO structure from a text SDP:

```
TBX_RESULT CallBridgingSampleLoadConfig_DB
(
IN  PCALL_BRIDGING_SAMPLE_CONTEXT		in_pContext,
OUT PCALL_BRIDGING_SAMPLE_DYNAMIC_CONFIG	out_pDynamicConfig,
OUT TBX_CHAR				out_szResult[ TBCAF_DB_FULL_PATH_NAME_MAX ]
)
{
CTBCAFOam_sdp_profiles_db_acc       AccessSdpProfiles;
PITBCAFDb                           pCfgDb;
std::vector<CTBCAFOam_sdp_profiles> SdpProfiles;
CTBCAFOam_sdp_profiles              SdpProfile;
TBX_SDP_INFO                        SdpInfo;
CTBCAFString                        strSdpText;

pCfgDb = in_pContext->pCppCtx->pCfgDb;

Result = AccessSdpProfiles.Init(pCfgDb);
if (TBX_RESULT_FAILURE(Result))
{
TBX_EXIT_ERROR (Result, 0, "Cannot init AccessSdpProfiles" );
}

SdpProfiles = AccessSdpProfiles.GetAllBy_profile_id( 1 );
SdpProfile  = SdpProfiles[0];

'''strSdpText = SdpProfile.str_sdp_text;'''
'''if( !strSdpText.EndsWith( "\r\n" ) )'''
'''{'''
'''      strSdpText.Append( "\r\n" );'''
'''}'''

'''/* Fill media capabilities */'''
'''Result = TBXMediaLibSdpParse'''
'''('''
'''    (PTBX_CHAR)strSdpText.c_str(),'''
'''    &SdpInfo,'''
'''    TBX_MEDIA_SDP_PARSE_OPTION_DEFAULT'''
''');'''

'''// SdpInfo is now filled with the info from the text SDP'''
}
```

#### Filling a TBX\_SDP\_INFO structure manually:

```
TBX_RESULT CTBS2GWSimpleMediaCall::BuildSdpInfo
(
IN  PTBX_CHAR		in_pszIp,
IN  TBX_UINT32		in_un32Port,
OUT TBX_SDP_INFO&	out_SdpInfo
)
{
TBCAF_MUTEX_GET_SCOPE_BEGIN( &mMutex )
PTBX_MEDIA_CAPABILITY			pCap;
PTBX_SDP_MEDIA_CONNECTION		pConn;
PTBX_MEDIA_CAPABILITY_DESCRIPTION	pMediaDesc;
/*---------------------------------------------------------------------------------------------------------------------------
|  Code section
```

* \--------------------------------------------------------------------------------------------------------------------------\*/ CAFCODE( CTBS2GWSimpleMediaCall::BuildSdpInfo ) { memset(\&out\_SdpInfo, 0, sizeof(out\_SdpInfo));

  // Set capabilities pCap = &( out\_SdpInfo.Capabilities.aMediaCap\[ out\_SdpInfo.Capabilities.un8NbMediaCapabilities ] ); { /\* Reserve this capability in aMediaCap \*/ out\_SdpInfo.Capabilities.un8NbMediaCapabilities++;

  pCap->Encoding.MediaType = TBX\_MEDIA\_TYPE\_AUDIO\_PCMU; pCap->Direction = TBX\_MEDIA\_DIRECTION\_RX\_TX\_SAME; pCap->Transport.Type = TBX\_MEDIA\_TRANSPORT\_TYPE\_RTP; pCap->Transport.Rtp.PayloadType = TBX\_MEDIA\_PAYLOAD\_TYPE\_PCMU; pCap->Transport.Rtp.un16MaxAudioFramesPerPacket = 160; pCap->Transport.Rtp.un16PacketDurationMs = 20; } pCap = &( out\_SdpInfo.Capabilities.aMediaCap\[ out\_SdpInfo.Capabilities.un8NbMediaCapabilities ] ); { /\* Reserve this capability in aMediaCap \*/ out\_SdpInfo.Capabilities.un8NbMediaCapabilities++;

  pCap->Encoding.MediaType = TBX\_MEDIA\_TYPE\_AUDIO\_PCMA; pCap->Direction = TBX\_MEDIA\_DIRECTION\_RX\_TX\_SAME; pCap->Transport.Type = TBX\_MEDIA\_TRANSPORT\_TYPE\_RTP; pCap->Transport.Rtp.PayloadType = TBX\_MEDIA\_PAYLOAD\_TYPE\_PCMA; pCap->Transport.Rtp.un16MaxAudioFramesPerPacket = 160; pCap->Transport.Rtp.un16PacketDurationMs = 40; } out\_SdpInfo.Capabilities.un8NbCapabilityGroups = 1; out\_SdpInfo.Capabilities.aCapGroups\[0].un8NbSimultaneousCap = 1; pMediaDesc = &( out\_SdpInfo.Capabilities.aCapGroups\[0].aSimultaneousCap\[ 0 ] ); pMediaDesc->un8NbPorts = in\_un32Port ? 1 : 0; pMediaDesc->un16UdpPort = in\_un32Port; pMediaDesc->un8ConnectionIdx = 0; pMediaDesc->un8NbChoices = 2; pMediaDesc->aMediaCapChoices\[0] = 0; pMediaDesc->aMediaCapChoices\[1] = 1;

  // Set connection info pConn = \&out\_SdpInfo.aConnections\[out\_SdpInfo.un8NbConnections]; pConn->un32NumAddr = 0; /\* Not used, not multicast */ pConn->un16Ttl = 0; /* Not used, not multicast \*/ pConn->IPDescriptionType = (TBX\_UINT8)TBX\_SDP\_MEDIA\_IP\_DESCRIPTION\_TYPE\_IPV4\_ADDRESS; Strncpy ( pConn->szIp, in\_pszIp, sizeof( pConn->szIp ) ); out\_SdpInfo.un8NbConnections++;

  TBX\_EXIT\_SUCCESS( TBX\_RESULT\_OK ); }

  /\*--------------------------------------------------------------------------------------------------------------------------- | Exception handling section
* \--------------------------------------------------------------------------------------------------------------------------\*/ CAF\_EXCEPTION\_HANDLING

  /\*--------------------------------------------------------------------------------------------------------------------------- | Error handling section
* \--------------------------------------------------------------------------------------------------------------------------\*/ CAF\_ERROR\_HANDLING( CAF\_VERBOSE ) { }

  /\*--------------------------------------------------------------------------------------------------------------------------- | Cleanup section
* \--------------------------------------------------------------------------------------------------------------------------\*/ CAF\_CLEANUP { }

  RETURN; TBCAF\_MUTEX\_GET\_SCOPE\_END( \&mMutex ) }


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://prosbcdocs.telcobridges.com/telecom-references/sip-and-voip/caf-filling-sdp-structures.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
