void CConferenceInfo::doAudioProc(void)
{
	bool bGetTempMember = false;
	CLockMap<CConferenceMember*, CMemberData::pointer> toSendMembers;
	CLockList<CMemberData::pointer> memberTemps;

	while (!m_killed)
	{
		CMemberData::pointer memberData;
		if (bGetTempMember)
		{
			if (!memberTemps.front(memberData, true))
			{
				bGetTempMember = false;
				continue;
			}

		}else if (!m_datasa.front(memberData, true))
		{
#ifdef WIN32
			Sleep(20);
#else
			usleep(20000);
#endif
			continue;
		}

		CConferenceMember * pDataConferenceMember = (CConferenceMember*)memberData->getRtpParam();
		if (pDataConferenceMember->getClosed() || pDataConferenceMember->getAudioHandler() == 0 || pDataConferenceMember->getVideoHandler() == 0)
		{
			continue;
		}

		BOOST_ASSERT (pDataConferenceMember->getAudioHandler().get() == memberData->getDoRtpHandler().get());

		if (toSendMembers.exist(pDataConferenceMember))
		{
			if (toSendMembers.size() < (unsigned int)countAudioMember())
			{
				setToMemberFront(memberTemps, memberData);
				bGetTempMember = false;
				continue;
			}

			sendAudioFrame(toSendMembers);
			toSendMembers.clear(false);
		}

		toSendMembers.insert(pDataConferenceMember, memberData);
		bGetTempMember = !memberTemps.empty();
	}

}
Example #2
0
	// OnRtpHandler
	virtual void onReceiveEvent(CRTPData::pointer receiveData, DoRtpHandler::pointer pDoRtpHandler, void * rtpParam)
	{
		BOOST_ASSERT (receiveData.get() != 0);
		if (m_commHandler.get() != NULL)
		{
			// ?
			unsigned long destIp = receiveData->destip();
			unsigned int  destPort = receiveData->destport();
			u_long remoteAddrHash = destIp + destPort;

			cgcRemote::pointer pCgcRemote;
			if (!m_mapCgcRemote.find(remoteAddrHash, pCgcRemote, false))
			{
				pCgcRemote = cgcRemote::pointer(new CcgcRemote(destIp, destPort, (CRemoteHandler*)this, m_pDoRtpHandler));
				m_mapCgcRemote.insert(remoteAddrHash, pCgcRemote);
			}else if (pCgcRemote->isInvalidate())
			{
				m_mapCgcRemote.remove(remoteAddrHash);
				pCgcRemote = cgcRemote::pointer(new CcgcRemote(destIp, destPort, (CRemoteHandler*)this, m_pDoRtpHandler));
				m_mapCgcRemote.insert(remoteAddrHash, pCgcRemote);
			}else
			{
				((CcgcRemote*)pCgcRemote.get())->SetRemote(destIp, destPort);
			}
			CRtpRemoteInfo::pointer pEventData = CRtpRemoteInfo::create(CCommEventData::CET_Recv);
			pEventData->setRemote(pCgcRemote);
			pEventData->setRemoteId(pCgcRemote->getRemoteId());
			pEventData->recvdata(receiveData);
			m_listMgr.add(pEventData);
		}
	}
void CConferenceInfo::setToMemberFront(CLockList<CMemberData::pointer> & destList, CMemberData::pointer memberData) const
{
	BOOST_ASSERT (memberData.get() != 0);

	CLockList<CMemberData::pointer>::iterator iter;
	for (iter=destList.begin(); iter!= destList.end(); iter++)
	{
		//CMemberData::pointer memberDataTemp = *iter;
		if ((*iter)->getRtpParam() == memberData->getRtpParam())
		{
			destList.insert(iter, memberData);
			return;
		}
	}

	destList.add(memberData);
}
Example #4
0
	virtual void onRtpKilledEvent(DoRtpHandler::pointer pDoRtpHandler, void * rtpParam)
	{
		while (true)
		{
			if (m_listMgr.empty())
				break;

#ifdef WIN32
			Sleep(100);
#else
			usleep(100000);
#endif
		}

	}
Example #5
0
	virtual void finalService(void)
	{
		if (!m_bServiceInited) return;

		cgcObject::pointer eventPointer = theAppAttributes->removeAttribute(EVENT_ATTRIBUTE, this);
		CIDEvent * pIDEvent = (CIDEvent*)eventPointer.get();
		if (pIDEvent != NULL)
		{
			for (unsigned int i=pIDEvent->m_nCurIDEvent; i<pIDEvent->m_nCurIDEvent+pIDEvent->m_nCapacity; i++)
				theApplication->KillTimer(i);
		}

		m_mapCgcRemote.clear();
		m_listMgr.clear();

		DoRtpHandler::pointer pDoRtpHandlerTemp = m_pDoRtpHandler;
		m_pDoRtpHandler.reset();
		m_rtpService->stopRtp(pDoRtpHandlerTemp);
		m_bServiceInited = false;
		CGC_LOG((LOG_INFO, _T("**** [%s:%d] Stop succeeded ****\n"), serviceName().c_str(), m_commPort));
	}
Example #6
0
	// cgcOnTimerHandler
	virtual void OnTimeout(unsigned int nIDEvent, const void * pvParam)
	{
		if (++m_nDoCommEventCouter > 120000)
		{
			if (!eraseIsInvalidated())
			{
				m_nDoCommEventCouter = 0;
			}
		}

		if (m_commHandler.get() == NULL) return;
		CRtpRemoteInfo::pointer pCommEventData;
		if (!m_listMgr.front(pCommEventData)) return;
		BOOST_ASSERT (pCommEventData->recvdata() != 0);

		switch (pCommEventData->getCommEventType())
		{
		case CCommEventData::CET_Recv:
			m_commHandler->onRecvData(pCommEventData->getRemote(), pCommEventData->recvdata()->data(), pCommEventData->recvdata()->size());
			break;
		default:
			break;
		}
	}