Example #1
0
	virtual void invalidate(bool bClose)
	{
		if (m_pDoRtpHandler.get() != NULL)
		{
			if (bClose)
				m_handler->onInvalidate(m_pDoRtpHandler);
			m_pDoRtpHandler.reset();
		}
	}
Example #2
0
void CRtp::stopRtp(DoRtpHandler::pointer handler)
{
	CRtpProxy::pointer rtpProxy;
	if (m_rtpProxy.find(handler.get(), rtpProxy, true))
	{
		//handler->doSetRtpHandler(0);
		rtpProxy->DestroySession();
		handler->doSetRtpHandler(0);
	}
}
Example #3
0
	virtual bool initService(cgcValueInfo::pointer parameter)
	{
		if (m_commHandler.get() == NULL) return false;
		if (m_bServiceInited) return true;

		if (parameter.get() != NULL && parameter->getType() == cgcValueInfo::TYPE_VECTOR)
		{
			const std::vector<cgcValueInfo::pointer>& lists = parameter->getVector();
			if (lists.size() > 2)
				m_protocol = lists[2]->getInt();
			if (lists.size() > 1)
				m_capacity = lists[1]->getInt();
			if (lists.size() > 0)
				m_commPort = lists[0]->getInt();
			else
				return false;
		}

		if (m_pDoRtpHandler.get() == 0)
		{
			m_pDoRtpHandler = m_rtpService->startRtp(m_commPort);
			if (m_pDoRtpHandler.get() == 0)
				return false;
			m_pDoRtpHandler->doSetMediaType(1);
			m_pDoRtpHandler->doSetRtpHandler(this);
		}

		m_capacity = m_capacity < 1 ? 1 : m_capacity;
		CIDEvent * pIDEvent = new CIDEvent();
		pIDEvent->m_nCurIDEvent = theCurrentIdEvent+1;
		pIDEvent->m_nCapacity = m_capacity;
		theAppAttributes->setAttribute(EVENT_ATTRIBUTE, this, cgcObject::pointer(pIDEvent));

		for (int i=0; i<m_capacity; i++)
		{
			theApplication->SetTimer(++theCurrentIdEvent, m_capacity, shared_from_this());
		}

		m_bServiceInited = true;
		CGC_LOG((LOG_INFO, _T("**** [%s:%d] Start succeeded ****\n"), serviceName().c_str(), m_commPort));
		return true;
	}
Example #4
0
	virtual bool isInvalidate(void) const {return m_pDoRtpHandler.get() == 0;}
Example #5
0
	virtual unsigned long getIpAddress(void) const {return m_pDoRtpHandler.get()==NULL?0:m_destIp;}
Example #6
0
	virtual unsigned long getRemoteId(void) const {return m_pDoRtpHandler.get() == 0 ? 0 : m_destIp+m_destPort;}
void CConferenceInfo::onReceiveEvent(CRTPData::pointer receiveData, DoRtpHandler::pointer pDoRtpHandler, void * rtpParam)
{
	BOOST_ASSERT (receiveData.get() != NULL);
	BOOST_ASSERT (pDoRtpHandler.get() != NULL);
	BOOST_ASSERT (rtpParam != NULL);

	CConferenceMember * pDataConferenceMember = (CConferenceMember*)rtpParam;
	if (pDataConferenceMember->getClosed() || pDataConferenceMember->getAudioHandler() == 0 || pDataConferenceMember->getVideoHandler() == 0)
		return;

	if (receiveData->size() == 4)
	{
		if (pDataConferenceMember->getAudioHandler().get() == pDoRtpHandler.get())
		{
			pDataConferenceMember->getAudioHandler()->doClearDest();
			pDataConferenceMember->getAudioHandler()->doAddDest(receiveData->destip(), receiveData->destport());
		}else if (pDataConferenceMember->getVideoHandler().get() == pDoRtpHandler.get())
		{
			pDataConferenceMember->getVideoHandler()->doClearDest();
			pDataConferenceMember->getVideoHandler()->doAddDest(receiveData->destip(), receiveData->destport());
		}
		return;
	}

	if (!pDataConferenceMember->getAudioSend() && pDataConferenceMember->getAudioHandler() == pDoRtpHandler)
	{
		// member audio closed
		return;
	}else if (!pDataConferenceMember->getVideoSend() && pDataConferenceMember->getVideoHandler() == pDoRtpHandler)
	{
		// member video closed
		return;
	}

	bool is_audioData = pDataConferenceMember->getAudioHandler() == pDoRtpHandler;
	if (is_audioData)
	{
		// decode PCM audio

		short v1 = 0;
		short v2 = 0;
		bool has_voice = false;
		switch (receiveData->payloadtype())
		{
		case 8:
			{
				long size = receiveData->size();
				unsigned char * tempBuffer = new unsigned char[size * 2];
				G711Coder::DecodeA((short*)tempBuffer, receiveData->data(), size);
				receiveData->data(tempBuffer, size * 2);

				has_voice = v1 > Default_Silence_Value1 || v2 < Default_Silence_Value2;
			}break;
		case 0:
			{
				long size = receiveData->size();
				unsigned char * tempBuffer = new unsigned char[size * 2];
				G711Coder::DecodeU((short*)tempBuffer, receiveData->data(), size, &v1, &v2);
				receiveData->data(tempBuffer, size * 2);

				has_voice = v1 > Default_Silence_Value1 || v2 < Default_Silence_Value2;
				//if (v1 > Default_Silence_Value1 || v2 < Default_Silence_Value2)
				//{
				//	int i = 0;
				//}
			}break;
		case 18:
			{
				long size = receiveData->size();
				unsigned char * tempBuffer = new unsigned char[(int)(size * (80.0/10.0)*2)];
				m_g729a.g729a_decoder(receiveData->data(), size, (short*)tempBuffer, &v1, &v2);
				receiveData->data(tempBuffer, (long)(size*(80.0/10.0)*2));

				has_voice = v1 > Default_Silence_Value1 || v2 < Default_Silence_Value2;
			}break;
		default:
			break;
		}
		pDataConferenceMember->setRecvDataTime();
		m_datasa.add(CMemberData::create(receiveData, pDoRtpHandler, rtpParam, !has_voice));
	}else
	{
		m_datasv.add(CMemberData::create(receiveData, pDoRtpHandler, rtpParam));
	}

}