Ejemplo n.º 1
0
void CMyPhoneEndPoint::OnRTPStatistics(const H323Connection & connection,
									   const RTP_Session & session) const
{
	// Lock mutex
	if(!(((CMyPhoneEndPoint *)this)->m_StatLock.Lock(10))) return;
	// Reset statistic 
	m_stat.ibSent = m_stat.ibRcvd =0;
    // Getting Audio statistic part
	RTP_Session * asession = connection.GetSession(RTP_Session::DefaultAudioSessionID);
	if (asession != NULL)
	{
		int abSent=0, abRcvd=0;
		// If not sending or receiving Audio, memory read error happens.
		try{	abSent = asession->GetOctetsSent();	} catch(...) {abSent = 0;}
		try{	abRcvd = asession->GetOctetsReceived(); } catch(...) {abRcvd = 0;}
		m_stat.ibSent = abSent;
		m_stat.ibRcvd = abRcvd;
	}
	
	// Getting Video statistic part
	RTP_Session * vsession = connection.GetSession(RTP_Session::DefaultVideoSessionID);
	if (vsession != NULL)
	{
		int vbSent=0, vbRcvd=0;
		// If not sending or receiving Vidio 
		// mamory read error happends.
		try{	vbSent = vsession->GetOctetsSent();	} catch(...) {vbSent = 0;}
		try{	vbRcvd = vsession->GetOctetsReceived(); } catch(...) {vbRcvd = 0;}
		m_stat.ibSent += vbSent;
		m_stat.ibRcvd += vbRcvd;
	}
	
	m_stat.iDelay = connection.GetRoundTripDelay().GetInterval();
	
	m_stat.iSecs = (PTime() - connection.GetConnectionStartTime()).GetSeconds();
	//
	// Release mutex
	((CMyPhoneEndPoint *)this)->m_StatLock.Unlock();
}