CAF: Filling SDP Structures

From TBwiki
(Difference between revisions)
Jump to: navigation, search
Line 1: Line 1:
There are two ways to fill a TBX_SDP_INFO structure.
+
There are two ways to fill a TBX_SDP_INFO structure.  
  
===Filling a TBX_SDP_INFO structure from a text SDP:===
+
=== Filling a TBX_SDP_INFO structure from a text SDP: ===
  
 
   TBX_RESULT CallBridgingSampleLoadConfig_DB
 
   TBX_RESULT CallBridgingSampleLoadConfig_DB
Line 12: Line 12:
 
       CTBCAFOam_sdp_profiles_db_acc      AccessSdpProfiles;
 
       CTBCAFOam_sdp_profiles_db_acc      AccessSdpProfiles;
 
       PITBCAFDb                          pCfgDb;
 
       PITBCAFDb                          pCfgDb;
       std::vector<CTBCAFOam_sdp_profiles> SdpProfiles;
+
       std::vector&lt;CTBCAFOam_sdp_profiles&gt; SdpProfiles;
 
       CTBCAFOam_sdp_profiles              SdpProfile;
 
       CTBCAFOam_sdp_profiles              SdpProfile;
 
       TBX_SDP_INFO                        SdpInfo;
 
       TBX_SDP_INFO                        SdpInfo;
 
       CTBCAFString                        strSdpText;
 
       CTBCAFString                        strSdpText;
 
    
 
    
       pCfgDb = in_pContext->pCppCtx->pCfgDb;
+
       pCfgDb = in_pContext-&gt;pCppCtx-&gt;pCfgDb;
 
    
 
    
 
       Result = AccessSdpProfiles.Init(pCfgDb);
 
       Result = AccessSdpProfiles.Init(pCfgDb);
Line 28: Line 28:
 
       SdpProfile  = SdpProfiles[0];
 
       SdpProfile  = SdpProfiles[0];
 
    
 
    
       '''strSdpText = SdpProfile.str_sdp_text;
+
       '''strSdpText = SdpProfile.str_sdp_text;'''
      '''if( !strSdpText.EndsWith( "\r\n" ) )
+
    '''if(&nbsp;!strSdpText.EndsWith( "\r\n" ) )'''
      '''{
+
    '''{'''
      '''      strSdpText.Append( "\r\n" );
+
    '''      strSdpText.Append( "\r\n" );'''
      '''}
+
    '''}'''
   
+
 
      '''/* Fill media capabilities */
+
    '''/* Fill media capabilities */'''
      '''Result = TBXMediaLibSdpParse
+
    '''Result = TBXMediaLibSdpParse'''
      '''(
+
    '''('''
  '''    (PTBX_CHAR)strSdpText.c_str(),
+
'''    (PTBX_CHAR)strSdpText.c_str(),'''
  '''    &SdpInfo,
+
'''    &amp;SdpInfo,'''
  '''    TBX_MEDIA_SDP_PARSE_OPTION_DEFAULT
+
'''    TBX_MEDIA_SDP_PARSE_OPTION_DEFAULT'''
      ''');
+
    ''');'''
   
+
 
      '''// SdpInfo is now filled with the info from the text SDP
+
    '''// SdpInfo is now filled with the info from the text SDP'''
  }
+
}
  
===Filling a TBX_SDP_INFO structure manually:===
+
=== Filling a TBX_SDP_INFO structure manually: ===
  
 
   TBX_RESULT CTBS2GWSimpleMediaCall::BuildSdpInfo
 
   TBX_RESULT CTBS2GWSimpleMediaCall::BuildSdpInfo
Line 51: Line 51:
 
   IN  PTBX_CHAR in_pszIp,
 
   IN  PTBX_CHAR in_pszIp,
 
   IN  TBX_UINT32 in_un32Port,
 
   IN  TBX_UINT32 in_un32Port,
   OUT TBX_SDP_INFO& out_SdpInfo
+
   OUT TBX_SDP_INFO&amp; out_SdpInfo
 
   )
 
   )
 
   {
 
   {
   TBCAF_MUTEX_GET_SCOPE_BEGIN( &mMutex )
+
   TBCAF_MUTEX_GET_SCOPE_BEGIN( &amp;mMutex )
 
   PTBX_MEDIA_CAPABILITY pCap;
 
   PTBX_MEDIA_CAPABILITY pCap;
 
   PTBX_SDP_MEDIA_CONNECTION pConn;
 
   PTBX_SDP_MEDIA_CONNECTION pConn;
Line 63: Line 63:
 
   CAFCODE( CTBS2GWSimpleMediaCall::BuildSdpInfo )
 
   CAFCODE( CTBS2GWSimpleMediaCall::BuildSdpInfo )
 
   {
 
   {
   memset(&out_SdpInfo, 0, sizeof(out_SdpInfo));
+
   memset(&amp;out_SdpInfo, 0, sizeof(out_SdpInfo));
 
  
 
  
 
   // Set capabilities
 
   // Set capabilities
   pCap = &( out_SdpInfo.Capabilities.aMediaCap[ out_SdpInfo.Capabilities.un8NbMediaCapabilities ] );
+
   pCap = &amp;( out_SdpInfo.Capabilities.aMediaCap[ out_SdpInfo.Capabilities.un8NbMediaCapabilities ] );
 
   {
 
   {
 
   /* Reserve this capability in aMediaCap */
 
   /* Reserve this capability in aMediaCap */
 
   out_SdpInfo.Capabilities.un8NbMediaCapabilities++;
 
   out_SdpInfo.Capabilities.un8NbMediaCapabilities++;
 
    
 
    
   pCap->Encoding.MediaType = TBX_MEDIA_TYPE_AUDIO_PCMU;
+
   pCap-&gt;Encoding.MediaType = TBX_MEDIA_TYPE_AUDIO_PCMU;
   pCap->Direction = TBX_MEDIA_DIRECTION_RX_TX_SAME;
+
   pCap-&gt;Direction = TBX_MEDIA_DIRECTION_RX_TX_SAME;
     pCap->Transport.Type = TBX_MEDIA_TRANSPORT_TYPE_RTP;
+
     pCap-&gt;Transport.Type = TBX_MEDIA_TRANSPORT_TYPE_RTP;
   pCap->Transport.Rtp.PayloadType = TBX_MEDIA_PAYLOAD_TYPE_PCMU;
+
   pCap-&gt;Transport.Rtp.PayloadType = TBX_MEDIA_PAYLOAD_TYPE_PCMU;
   pCap->Transport.Rtp.un16MaxAudioFramesPerPacket = 160;
+
   pCap-&gt;Transport.Rtp.un16MaxAudioFramesPerPacket = 160;
   pCap->Transport.Rtp.un16PacketDurationMs = 20;
+
   pCap-&gt;Transport.Rtp.un16PacketDurationMs = 20;
 
   }
 
   }
   pCap = &( out_SdpInfo.Capabilities.aMediaCap[ out_SdpInfo.Capabilities.un8NbMediaCapabilities ] );
+
   pCap = &amp;( out_SdpInfo.Capabilities.aMediaCap[ out_SdpInfo.Capabilities.un8NbMediaCapabilities ] );
 
   {
 
   {
 
   /* Reserve this capability in aMediaCap */
 
   /* Reserve this capability in aMediaCap */
 
   out_SdpInfo.Capabilities.un8NbMediaCapabilities++;
 
   out_SdpInfo.Capabilities.un8NbMediaCapabilities++;
 
    
 
    
   pCap->Encoding.MediaType = TBX_MEDIA_TYPE_AUDIO_PCMA;
+
   pCap-&gt;Encoding.MediaType = TBX_MEDIA_TYPE_AUDIO_PCMA;
   pCap->Direction = TBX_MEDIA_DIRECTION_RX_TX_SAME;
+
   pCap-&gt;Direction = TBX_MEDIA_DIRECTION_RX_TX_SAME;
     pCap->Transport.Type = TBX_MEDIA_TRANSPORT_TYPE_RTP;
+
     pCap-&gt;Transport.Type = TBX_MEDIA_TRANSPORT_TYPE_RTP;
   pCap->Transport.Rtp.PayloadType = TBX_MEDIA_PAYLOAD_TYPE_PCMA;
+
   pCap-&gt;Transport.Rtp.PayloadType = TBX_MEDIA_PAYLOAD_TYPE_PCMA;
   pCap->Transport.Rtp.un16MaxAudioFramesPerPacket = 160;
+
   pCap-&gt;Transport.Rtp.un16MaxAudioFramesPerPacket = 160;
   pCap->Transport.Rtp.un16PacketDurationMs = 40;
+
   pCap-&gt;Transport.Rtp.un16PacketDurationMs = 40;
 
   }
 
   }
 
   out_SdpInfo.Capabilities.un8NbCapabilityGroups = 1;
 
   out_SdpInfo.Capabilities.un8NbCapabilityGroups = 1;
 
   out_SdpInfo.Capabilities.aCapGroups[0].un8NbSimultaneousCap = 1;
 
   out_SdpInfo.Capabilities.aCapGroups[0].un8NbSimultaneousCap = 1;
   pMediaDesc = &( out_SdpInfo.Capabilities.aCapGroups[0].aSimultaneousCap[ 0 ] );
+
   pMediaDesc = &amp;( out_SdpInfo.Capabilities.aCapGroups[0].aSimultaneousCap[ 0 ] );
   pMediaDesc->un8NbPorts = in_un32Port ? 1 : 0;
+
   pMediaDesc-&gt;un8NbPorts = in_un32Port&nbsp;? 1&nbsp;: 0;
   pMediaDesc->un16UdpPort = in_un32Port;
+
   pMediaDesc-&gt;un16UdpPort = in_un32Port;
   pMediaDesc->un8ConnectionIdx = 0;
+
   pMediaDesc-&gt;un8ConnectionIdx = 0;
   pMediaDesc->un8NbChoices = 2;
+
   pMediaDesc-&gt;un8NbChoices = 2;
   pMediaDesc->aMediaCapChoices[0] = 0;
+
   pMediaDesc-&gt;aMediaCapChoices[0] = 0;
   pMediaDesc->aMediaCapChoices[1] = 1;
+
   pMediaDesc-&gt;aMediaCapChoices[1] = 1;
 
    
 
    
 
   // Set connection info
 
   // Set connection info
   pConn = &out_SdpInfo.aConnections[out_SdpInfo.un8NbConnections];
+
   pConn = &amp;out_SdpInfo.aConnections[out_SdpInfo.un8NbConnections];
   pConn->un32NumAddr = 0; /* Not used, not multicast */
+
   pConn-&gt;un32NumAddr = 0; /* Not used, not multicast */
   pConn->un16Ttl = 0; /* Not used, not multicast */
+
   pConn-&gt;un16Ttl = 0; /* Not used, not multicast */
   pConn->IPDescriptionType = (TBX_UINT8)TBX_SDP_MEDIA_IP_DESCRIPTION_TYPE_IPV4_ADDRESS;
+
   pConn-&gt;IPDescriptionType = (TBX_UINT8)TBX_SDP_MEDIA_IP_DESCRIPTION_TYPE_IPV4_ADDRESS;
 
   Strncpy
 
   Strncpy
 
   (
 
   (
   pConn->szIp,
+
   pConn-&gt;szIp,
 
   in_pszIp,
 
   in_pszIp,
   sizeof( pConn->szIp )
+
   sizeof( pConn-&gt;szIp )
 
   );
 
   );
 
   out_SdpInfo.un8NbConnections++;
 
   out_SdpInfo.un8NbConnections++;
Line 136: Line 136:
 
    
 
    
 
   RETURN;
 
   RETURN;
   TBCAF_MUTEX_GET_SCOPE_END( &mMutex )
+
   TBCAF_MUTEX_GET_SCOPE_END( &amp;mMutex )
 
   }
 
   }
  
 
+
[[Category:CAF]] [[Category:Needs_revising]]
 
+
[[category:CAF]]
+

Revision as of 13:24, 5 March 2010

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 )
 }
Personal tools