升龙物业 老版本 ocx IPO, 加密狗 转值班电话

DevDsp.cpp 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. #include "StdAfx.h"
  2. #include "DevDsp.h"
  3. #include "DspChannel.h"
  4. #include "MC.h"
  5. CDevDsp::CDevDsp(DEV_RES_NO_TYPE NodeNo, DEV_RES_NO_TYPE BoardNo) : CDevResource(NodeNo, BoardNo), m_CurPos(0), m_MeetingPool(this)
  6. {
  7. }
  8. CDevDsp::~CDevDsp(void)
  9. {
  10. close();
  11. }
  12. /*****************************************************************
  13. **【函数名称】 open
  14. **【函数功能】 DSP设备打开函数
  15. **【参数】
  16. **【返回值】
  17. ****************************************************************/
  18. bool CDevDsp::open( void )
  19. {
  20. if(m_state != STATUS_WORKING || m_DspChList.GetCount() > 0)
  21. return false;
  22. m_CurPos = 0;
  23. for (int i = 0; i < m_Capacity; i++)
  24. {
  25. CDspChannel* pChannel = new CDspChannel(i, m_NodeNo, m_BoardNo);
  26. ASSERT(pChannel != NULL);
  27. if(pChannel != NULL)
  28. {
  29. if(pChannel->open())
  30. {
  31. m_DspChList.Add(pChannel);
  32. CMC::GetInstance().onDevResCreate(pChannel->id());
  33. }
  34. else
  35. delete pChannel;
  36. }
  37. }
  38. LOGGER(LOG_CLASS_DEV, LOG_LEVEL_NORMAL, _T("{DevDsp}: DSP[%d-%d]成功打开%d条通道"), m_NodeNo, m_BoardNo, m_DspChList.GetCount());
  39. if(!m_MeetingPool.open())
  40. LOGGER(LOG_CLASS_DEV, LOG_LEVEL_WARNING, _T("{DevDsp}: DSP[%d-%d]打开会议设备失败"), m_NodeNo, m_BoardNo);
  41. return true;
  42. }
  43. /*****************************************************************
  44. **【函数名称】 close
  45. **【函数功能】 DSP设备关闭函数
  46. **【参数】
  47. **【返回值】
  48. ****************************************************************/
  49. void CDevDsp::close( void )
  50. {
  51. for(int i = 0; i < m_DspChList.GetCount(); ++i)
  52. {
  53. CDspChannel* pChannel = m_DspChList[i];
  54. ASSERT(pChannel != NULL);
  55. CMC::GetInstance().onDevResDestroy(pChannel->id());
  56. pChannel->close();
  57. delete pChannel;
  58. }
  59. m_DspChList.RemoveAll();
  60. m_CurPos = 0;
  61. LOGGER(LOG_CLASS_DEV, LOG_LEVEL_NORMAL, _T("{DevDsp}: DSP[%d-%d]通道全部关闭"), m_NodeNo, m_BoardNo);
  62. m_MeetingPool.close();
  63. }
  64. /*****************************************************************
  65. **【函数名称】 getFreeDspCh
  66. **【函数功能】 获取空闲通道
  67. **【参数】
  68. **【返回值】
  69. ****************************************************************/
  70. CDspChannel* CDevDsp::getFreeDspCh( void )
  71. {
  72. CSingleLock locker(&m_LockSection);
  73. locker.Lock(); // 本操作需锁定
  74. for(int i = 0; i < m_DspChList.GetCount(); ++i) // 保证遍历一轮
  75. {
  76. if(m_CurPos >= m_DspChList.GetCount())
  77. m_CurPos = 0;
  78. CDspChannel* pChannel = m_DspChList[m_CurPos++];
  79. ASSERT(pChannel != NULL);
  80. // 当前是否空闲
  81. if(pChannel->isValid() && pChannel->isFree())
  82. return pChannel;
  83. }
  84. return NULL;
  85. }
  86. /*****************************************************************
  87. **【函数名称】 findChan
  88. **【函数功能】 查找指定资源
  89. **【参数】
  90. **【返回值】
  91. ****************************************************************/
  92. CDspChannel* CDevDsp::findChan( int ResId )
  93. {
  94. if(ResId < 0 || ResId >= m_DspChList.GetCount())
  95. return NULL;
  96. else
  97. return m_DspChList[ResId];
  98. }
  99. /*****************************************************************
  100. **【函数名称】 createMeeting
  101. **【函数功能】 创建会议
  102. **【参数】
  103. **【返回值】
  104. ****************************************************************/
  105. bool CDevDsp::createMeeting( MeetingInfo& MeetInfo )
  106. {
  107. return m_MeetingPool.createMeeting(MeetInfo);
  108. }
  109. /*****************************************************************
  110. **【函数名称】 deleteMeeting
  111. **【函数功能】 删除会议
  112. **【参数】
  113. **【返回值】
  114. ****************************************************************/
  115. void CDevDsp::deleteMeeting( MeetingInfo& MeetInfo )
  116. {
  117. return m_MeetingPool.deleteMeeting(MeetInfo.MeetingId);
  118. }
  119. /*****************************************************************
  120. **【函数名称】 meetingAccept
  121. **【函数功能】 接受与会方
  122. **【参数】
  123. **【返回值】
  124. ****************************************************************/
  125. bool CDevDsp::meetingAccept( int MeetingId, COneLeg* pAttendee, bool IsOneWay )
  126. {
  127. return m_MeetingPool.accept(MeetingId, pAttendee, IsOneWay);
  128. }
  129. /*****************************************************************
  130. **【函数名称】 meetingRemove
  131. **【函数功能】 删除一个与会方
  132. **【参数】
  133. **【返回值】
  134. ****************************************************************/
  135. bool CDevDsp::meetingRemove( int MeetingId, COneLeg* pAttendee )
  136. {
  137. return m_MeetingPool.remove(MeetingId, pAttendee);
  138. }
  139. /*****************************************************************
  140. **【函数名称】 meetingRecord
  141. **【函数功能】 为与会方录音
  142. **【参数】
  143. **【返回值】
  144. ****************************************************************/
  145. bool CDevDsp::meetingRecord( int MeetingId, COneLeg* pAttendee, RecordContent* pContent, bool IsStop )
  146. {
  147. return m_MeetingPool.record(MeetingId, pAttendee, pContent, IsStop);
  148. }
  149. /*****************************************************************
  150. **【函数名称】 meetingMute
  151. **【函数功能】 静音与会方
  152. **【参数】
  153. **【返回值】
  154. ****************************************************************/
  155. bool CDevDsp::meetingMute( int MeetingId, COneLeg* pAttendee, bool IsOff )
  156. {
  157. return m_MeetingPool.mute(MeetingId, pAttendee, IsOff);
  158. }
  159. /*****************************************************************
  160. **【函数名称】 isOk
  161. **【函数功能】 判断设备状态
  162. **【参数】
  163. **【返回值】
  164. ****************************************************************/
  165. bool CDevDsp::isOk( void ) const
  166. {
  167. return (m_state == STATUS_WORKING && m_DspChList.GetCount() == m_Capacity);
  168. }