修改三方通话功能,在发起三方通话时,先保持住主叫,然后再拉回主叫到会议

TrunkAidedAllocator.cpp 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. #include "StdAfx.h"
  2. #include "TrunkAidedAllocator.h"
  3. #include "AidedUnit.h"
  4. #include "Config.h"
  5. #include "OneLeg.h"
  6. SINGLETON_IMPLEMENT(CTrunkAidedAllocator)
  7. CTrunkAidedAllocator::CTrunkAidedAllocator(void)
  8. {
  9. }
  10. CTrunkAidedAllocator::~CTrunkAidedAllocator(void)
  11. {
  12. __free();
  13. }
  14. /*****************************************************************
  15. **【函数名称】 __free
  16. **【函数功能】 释放资源
  17. **【参数】
  18. **【返回值】
  19. ****************************************************************/
  20. void CTrunkAidedAllocator::__free( void )
  21. {
  22. for(int i = 0; i < m_UnitList.GetCount(); ++i)
  23. {
  24. delete m_UnitList[i];
  25. }
  26. m_UnitList.RemoveAll();
  27. }
  28. /*****************************************************************
  29. **【函数名称】 __getAidedUnit
  30. **【函数功能】 获取辅助单元
  31. **【参数】
  32. **【返回值】
  33. ****************************************************************/
  34. CAidedUnit* CTrunkAidedAllocator::__getAidedUnit( LPCTSTR Prefix, bool NewWhenNULL/* = false*/ )
  35. {
  36. for(int i = 0; i < m_UnitList.GetCount(); ++i)
  37. {
  38. if(m_UnitList[i]->prefix() == Prefix)
  39. return m_UnitList[i];
  40. }
  41. if(NewWhenNULL)
  42. {
  43. CAidedUnit* pNewUnit = new CAidedUnit(Prefix);
  44. m_UnitList.Add(pNewUnit);
  45. return pNewUnit;
  46. }
  47. return NULL;
  48. }
  49. /*****************************************************************
  50. **【函数名称】 init
  51. **【函数功能】 初始化
  52. **【参数】
  53. **【返回值】
  54. ****************************************************************/
  55. void CTrunkAidedAllocator::init( void )
  56. {
  57. CCfgTrunkMatch& Match = CConfig::trunkMatch();
  58. POSITION Pos = Match.GetHeadPosition();
  59. while(Pos != NULL)
  60. {
  61. TRUNK_MATCH* pMatch = Match.GetNext(Pos);
  62. ASSERT(pMatch != NULL);
  63. CAidedUnit* pUnit = __getAidedUnit(pMatch->Prefix, true);
  64. ASSERT(pUnit != NULL);
  65. pUnit->add(pMatch);
  66. }
  67. }
  68. /*****************************************************************
  69. **【函数名称】 aidedAlloc
  70. **【函数功能】 辅助分配通道
  71. **【参数】
  72. **【返回值】
  73. ****************************************************************/
  74. COneLeg* CTrunkAidedAllocator::aidedAlloc( CString& CallerNum, CString& CalleeNum, TRUNK_ITEM** pTrunkItem )
  75. {
  76. CAidedUnit* pUnit = NULL;
  77. for(int i = 0; i < m_UnitList.GetCount(); ++i)
  78. {
  79. pUnit = m_UnitList[i];
  80. if(pUnit->match(CalleeNum))
  81. return pUnit->aidedAlloc(CallerNum, CalleeNum, pTrunkItem);
  82. }
  83. return NULL;
  84. }
  85. /*****************************************************************
  86. **【函数名称】 aidedAllocByDefault
  87. **【函数功能】 辅助分配通道若失败则用缺省中继项
  88. **【参数】
  89. **【返回值】
  90. ****************************************************************/
  91. COneLeg* CTrunkAidedAllocator::aidedAllocWithDefault( CString& CallerNum, CString& CalleeNum, TRUNK_ITEM** pTrunkItem )
  92. {
  93. CAidedUnit* pUnit = NULL;
  94. // 匹配出局字冠
  95. for(int i = 0; i < m_UnitList.GetCount(); ++i)
  96. {
  97. pUnit = m_UnitList[i];
  98. if(pUnit->match(CalleeNum))
  99. break;
  100. }
  101. // 未匹配到,则进行无匹配分配
  102. COneLeg* pCallLeg = NULL;
  103. for(int i = 0; i < m_UnitList.GetCount(); ++i)
  104. {
  105. pCallLeg = m_UnitList[i]->aidedAlloc(CallerNum, pTrunkItem);
  106. if(pCallLeg != NULL)
  107. break;
  108. }
  109. return pCallLeg;
  110. }