CAF: Leg Creation Samples

From TBwiki
(Difference between revisions)
Jump to: navigation, search
(Creating a Standalone Outgoing Call)
(Creating a Media-only Leg)
Line 14: Line 14:
 
   TODO ADD SAMPLE CODE
 
   TODO ADD SAMPLE CODE
 
==== Creating a Media-only Leg ====
 
==== Creating a Media-only Leg ====
You must first create a media only leg attribute:
+
If you are using the NAP_MEDIA_TDM:
 +
   
 
     PTRCTBCMC_MEDIA_ONLY_LEG_ATTRIBUTE ptrLegAttribute;
 
     PTRCTBCMC_MEDIA_ONLY_LEG_ATTRIBUTE ptrLegAttribute;
 
 
 
     ptrLegAttribute = tbnew CTBCMC_MEDIA_ONLY_LEG_ATTRIBUTE();
 
     ptrLegAttribute = tbnew CTBCMC_MEDIA_ONLY_LEG_ATTRIBUTE();
 +
 
 
     ptrLegAttribute->GetNetworkAccessPoint()      = "NAP_SS7_MONTREAL";
 
     ptrLegAttribute->GetNetworkAccessPoint()      = "NAP_SS7_MONTREAL";
 
      
 
      
 
     pMediaDesc = ptrLegAttribute->GetProfile()->MediaDescription;
 
     pMediaDesc = ptrLegAttribute->GetProfile()->MediaDescription;
 
     pMediaDesc->Type                              = TBCMC_MEDIA_TYPE_AUDIO;
 
     pMediaDesc->Type                              = TBCMC_MEDIA_TYPE_AUDIO;
     pMediaDesc->Transport                        = TBCMC_MEDIA_TRANSPORT_TDM or TBCMC_MEDIA_TRANSPORT_IP;
+
     pMediaDesc->Transport                        = TBCMC_MEDIA_TRANSPORT_TDM;
 
+
Depending on which type of NAP your using, some parameters must be set. If you are using the NAP_MEDIA_TDM:
+
 
+
 
     pMediaDesc->Settings.TdmAudio.Type            = TBCMC_MEDIA_SETTINGS_TYPE_TDM_AUDIO;
 
     pMediaDesc->Settings.TdmAudio.Type            = TBCMC_MEDIA_SETTINGS_TYPE_TDM_AUDIO;
 
     pMediaDesc->Settings.TdmAudio.un8Timeslot    = 5;
 
     pMediaDesc->Settings.TdmAudio.un8Timeslot    = 5;
Line 34: Line 32:
 
         sizeof(pMediaDesc->Settings.TdmAudio.szTrunkName)
 
         sizeof(pMediaDesc->Settings.TdmAudio.szTrunkName)
 
     );
 
     );
 +
 
 +
    PCTBCMCLeg pCallLeg = tbnew CTBCMCLeg( ++mun32LegId, ptrLegAttribute, this, 0, &mLegMutex );
 +
    pCallLeg->CreateCall();
  
 
If you are using the NAP_MEDIA_VOIP:
 
If you are using the NAP_MEDIA_VOIP:
  
     TBX_RESULT               Result;
+
     TBX_RESULT                         Result;
     TBX_SDP_INFO             SdpInfo;
+
     TBX_SDP_INFO                       SdpInfo;
 +
    PTRCTBCMC_MEDIA_ONLY_LEG_ATTRIBUTE ptrLegAttribute;
 +
    ptrLegAttribute = tbnew CTBCMC_MEDIA_ONLY_LEG_ATTRIBUTE();
 +
 
 +
    ptrLegAttribute->GetNetworkAccessPoint()      = "NAP_SS7_MONTREAL";
 
      
 
      
 +
    pMediaDesc = ptrLegAttribute->GetProfile()->MediaDescription;
 +
    pMediaDesc->Type                              = TBCMC_MEDIA_TYPE_AUDIO;
 +
    pMediaDesc->Transport                        = TBCMC_MEDIA_TRANSPORT_IP;
 
     pMediaDesc->Settings.PacketAudio.Type        = TBCMC_MEDIA_SETTINGS_TYPE_PACKET_AUDIO;
 
     pMediaDesc->Settings.PacketAudio.Type        = TBCMC_MEDIA_SETTINGS_TYPE_PACKET_AUDIO;
 
    
 
    
Line 51: Line 59:
 
     TBCAF_EXIT_ON_ERROR( Result, "BuildSdpInfo failed." );
 
     TBCAF_EXIT_ON_ERROR( Result, "BuildSdpInfo failed." );
 
     ptrLegAttribute->SetPeerSDP(&SdpInfo);
 
     ptrLegAttribute->SetPeerSDP(&SdpInfo);
 +
 
 +
    PCTBCMCLeg pCallLeg = tbnew CTBCMCLeg( ++mun32LegId, ptrLegAttribute, this, 0, &mLegMutex );
 +
    pCallLeg->CreateCall();
  
 
To see how to fill a TBX_SDP_INFO structure (implementation of BuildSdpInfo()), refer to [[Customer_Application_Framework_:_Filling_SDP_Structure|Filling an SDP Structure]].
 
To see how to fill a TBX_SDP_INFO structure (implementation of BuildSdpInfo()), refer to [[Customer_Application_Framework_:_Filling_SDP_Structure|Filling an SDP Structure]].
 
After that, all you have to do is create a TBCMCLeg and call CreateCall(), like this:
 
 
  PCTBCMCLeg pCallLeg = tbnew CTBCMCLeg( ++mun32LegId, ptrLegAttribute, this, 0, &mLegMutex );
 
  pCallLeg->CreateCall();
 

Revision as of 09:09, 21 October 2009

Contents

Creating a Standalone Outgoing Call

   PTRCTBCMC_CALL_LEG_ATTRIBUTE ptrOutgoingLegAttribute;
     ptrOutgoingLegAttribute = tbnew CTBCMC_CALL_LEG_ATTRIBUTE();
 
   ptrOutgoingLegAttribute->GetCalledNumber()         = "123-4567";
   ptrOutgoingLegAttribute->GetCallingNumber()        = "987-6543";
   ptrOutgoingLegAttribute->GetNetworkAccessPoint()   = "NAP_SS7_MONTREAL";
 
   PTRCTBCAFCallLeg ptrOutgoingCallLeg = CreateOutgoingCallLeg(ptrOutgoingLegAttribute);

Bridging an Incoming Call (manual method)

 TODO ADD SAMPLE CODE

Bridging an Incoming Call (using CTBCAFBridge )

 TODO ADD SAMPLE CODE

Creating a Media-only Leg

If you are using the NAP_MEDIA_TDM:

   PTRCTBCMC_MEDIA_ONLY_LEG_ATTRIBUTE ptrLegAttribute;
   ptrLegAttribute = tbnew CTBCMC_MEDIA_ONLY_LEG_ATTRIBUTE();
 
   ptrLegAttribute->GetNetworkAccessPoint()      = "NAP_SS7_MONTREAL";
   
   pMediaDesc = ptrLegAttribute->GetProfile()->MediaDescription;
   pMediaDesc->Type                              = TBCMC_MEDIA_TYPE_AUDIO;
   pMediaDesc->Transport                         = TBCMC_MEDIA_TRANSPORT_TDM;
   pMediaDesc->Settings.TdmAudio.Type            = TBCMC_MEDIA_SETTINGS_TYPE_TDM_AUDIO;
   pMediaDesc->Settings.TdmAudio.un8Timeslot     = 5;
   Strncpy
   (
       pMediaDesc->Settings.TdmAudio.szTrunkName, 
       "TRUNK_TORONTO_1", 
       sizeof(pMediaDesc->Settings.TdmAudio.szTrunkName)
   );
 
   PCTBCMCLeg pCallLeg = tbnew CTBCMCLeg( ++mun32LegId, ptrLegAttribute, this, 0, &mLegMutex );
   pCallLeg->CreateCall();

If you are using the NAP_MEDIA_VOIP:

   TBX_RESULT                         Result;
   TBX_SDP_INFO                       SdpInfo;
   PTRCTBCMC_MEDIA_ONLY_LEG_ATTRIBUTE ptrLegAttribute;
   ptrLegAttribute = tbnew CTBCMC_MEDIA_ONLY_LEG_ATTRIBUTE();
 
   ptrLegAttribute->GetNetworkAccessPoint()      = "NAP_SS7_MONTREAL";
   
   pMediaDesc = ptrLegAttribute->GetProfile()->MediaDescription;
   pMediaDesc->Type                              = TBCMC_MEDIA_TYPE_AUDIO;
   pMediaDesc->Transport                         = TBCMC_MEDIA_TRANSPORT_IP;
   pMediaDesc->Settings.PacketAudio.Type         = TBCMC_MEDIA_SETTINGS_TYPE_PACKET_AUDIO;
  
   // Set Local SDP
   Result = BuildSdpInfo("", 0, SdpInfo);                 // No IP specified, Toolpack will choose one
   TBCAF_EXIT_ON_ERROR( Result, "BuildSdpInfo failed." );
   ptrLegAttribute->SetLocalSDP(&SdpInfo);
   
   // Set Peer SDP
   Result = BuildSdpInfo("10.0.0.15", 5000, SdpInfo);     // Using peer IP address and port
   TBCAF_EXIT_ON_ERROR( Result, "BuildSdpInfo failed." );
   ptrLegAttribute->SetPeerSDP(&SdpInfo);
 
   PCTBCMCLeg pCallLeg = tbnew CTBCMCLeg( ++mun32LegId, ptrLegAttribute, this, 0, &mLegMutex );
   pCallLeg->CreateCall();

To see how to fill a TBX_SDP_INFO structure (implementation of BuildSdpInfo()), refer to Filling an SDP Structure.

Personal tools