| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- #include "StdAfx.h"
- #include "DevDsp.h"
- #include "DspChannel.h"
- #include "MC.h"
- CDevDsp::CDevDsp(DEV_RES_NO_TYPE NodeNo, DEV_RES_NO_TYPE BoardNo) : CDevResource(NodeNo, BoardNo), m_CurPos(0), m_MeetingPool(this)
- {
- }
- CDevDsp::~CDevDsp(void)
- {
- close();
- }
- /*****************************************************************
- **【函数名称】 open
- **【函数功能】 DSP设备打开函数
- **【参数】
- **【返回值】
- ****************************************************************/
- bool CDevDsp::open( void )
- {
- if(m_state != STATUS_WORKING || m_DspChList.GetCount() > 0)
- return false;
- m_CurPos = 0;
- for (int i = 0; i < m_Capacity; i++)
- {
- CDspChannel* pChannel = new CDspChannel(i, m_NodeNo, m_BoardNo);
- ASSERT(pChannel != NULL);
- if(pChannel != NULL)
- {
- if(pChannel->open())
- {
- m_DspChList.Add(pChannel);
- CMC::GetInstance().onDevResCreate(pChannel->id());
- }
- else
- delete pChannel;
- }
- }
- LOGGER(LOG_CLASS_DEV, LOG_LEVEL_NORMAL, _T("{DevDsp}: DSP[%d-%d]成功打开%d条通道"), m_NodeNo, m_BoardNo, m_DspChList.GetCount());
- if(!m_MeetingPool.open())
- LOGGER(LOG_CLASS_DEV, LOG_LEVEL_WARNING, _T("{DevDsp}: DSP[%d-%d]打开会议设备失败"), m_NodeNo, m_BoardNo);
- return true;
- }
- /*****************************************************************
- **【函数名称】 close
- **【函数功能】 DSP设备关闭函数
- **【参数】
- **【返回值】
- ****************************************************************/
- void CDevDsp::close( void )
- {
- for(int i = 0; i < m_DspChList.GetCount(); ++i)
- {
- CDspChannel* pChannel = m_DspChList[i];
- ASSERT(pChannel != NULL);
- CMC::GetInstance().onDevResDestroy(pChannel->id());
- pChannel->close();
- delete pChannel;
- }
- m_DspChList.RemoveAll();
- m_CurPos = 0;
- LOGGER(LOG_CLASS_DEV, LOG_LEVEL_NORMAL, _T("{DevDsp}: DSP[%d-%d]通道全部关闭"), m_NodeNo, m_BoardNo);
- m_MeetingPool.close();
- }
- /*****************************************************************
- **【函数名称】 getFreeDspCh
- **【函数功能】 获取空闲通道
- **【参数】
- **【返回值】
- ****************************************************************/
- CDspChannel* CDevDsp::getFreeDspCh( void )
- {
- CSingleLock locker(&m_LockSection);
- locker.Lock(); // 本操作需锁定
- for(int i = 0; i < m_DspChList.GetCount(); ++i) // 保证遍历一轮
- {
- if(m_CurPos >= m_DspChList.GetCount())
- m_CurPos = 0;
- CDspChannel* pChannel = m_DspChList[m_CurPos++];
- ASSERT(pChannel != NULL);
- // 当前是否空闲
- if(pChannel->isValid() && pChannel->isFree())
- return pChannel;
- }
-
- return NULL;
- }
- /*****************************************************************
- **【函数名称】 findChan
- **【函数功能】 查找指定资源
- **【参数】
- **【返回值】
- ****************************************************************/
- CDspChannel* CDevDsp::findChan( int ResId )
- {
- if(ResId < 0 || ResId >= m_DspChList.GetCount())
- return NULL;
- else
- return m_DspChList[ResId];
- }
- /*****************************************************************
- **【函数名称】 createMeeting
- **【函数功能】 创建会议
- **【参数】
- **【返回值】
- ****************************************************************/
- bool CDevDsp::createMeeting( MeetingInfo& MeetInfo )
- {
- return m_MeetingPool.createMeeting(MeetInfo);
- }
- /*****************************************************************
- **【函数名称】 deleteMeeting
- **【函数功能】 删除会议
- **【参数】
- **【返回值】
- ****************************************************************/
- void CDevDsp::deleteMeeting( MeetingInfo& MeetInfo )
- {
- return m_MeetingPool.deleteMeeting(MeetInfo.MeetingId);
- }
- /*****************************************************************
- **【函数名称】 meetingAccept
- **【函数功能】 接受与会方
- **【参数】
- **【返回值】
- ****************************************************************/
- bool CDevDsp::meetingAccept( int MeetingId, COneLeg* pAttendee, bool IsOneWay )
- {
- return m_MeetingPool.accept(MeetingId, pAttendee, IsOneWay);
- }
- /*****************************************************************
- **【函数名称】 meetingRemove
- **【函数功能】 删除一个与会方
- **【参数】
- **【返回值】
- ****************************************************************/
- bool CDevDsp::meetingRemove( int MeetingId, COneLeg* pAttendee )
- {
- return m_MeetingPool.remove(MeetingId, pAttendee);
- }
- /*****************************************************************
- **【函数名称】 meetingRecord
- **【函数功能】 为与会方录音
- **【参数】
- **【返回值】
- ****************************************************************/
- bool CDevDsp::meetingRecord( int MeetingId, COneLeg* pAttendee, RecordContent* pContent, bool IsStop )
- {
- return m_MeetingPool.record(MeetingId, pAttendee, pContent, IsStop);
- }
- /*****************************************************************
- **【函数名称】 meetingMute
- **【函数功能】 静音与会方
- **【参数】
- **【返回值】
- ****************************************************************/
- bool CDevDsp::meetingMute( int MeetingId, COneLeg* pAttendee, bool IsOff )
- {
- return m_MeetingPool.mute(MeetingId, pAttendee, IsOff);
- }
- /*****************************************************************
- **【函数名称】 isOk
- **【函数功能】 判断设备状态
- **【参数】
- **【返回值】
- ****************************************************************/
- bool CDevDsp::isOk( void ) const
- {
- return (m_state == STATUS_WORKING && m_DspChList.GetCount() == m_Capacity);
- }
|