Пример #1
0
void CAimer39RTSPClient::Run()
{
	if (m_bIsShutDown)	return;
	
	uint64_t nLastRecvBytes = m_nRecvVideoBytes;
	int nNoRecvAnyCnt = 0;

	CClock clock;
	BOOL bIsStartClock = FALSE;
	uint64_t nMs = 0;
	UsageEnvironment & env = m_pRTSPClient->envir();
	// All subsequent activity takes place within the event loop:
	//env.taskScheduler().doEventLoop( &m_eventLoopWatchVariable );

	if (m_nDisConnLimmtMSec < 0) m_nDisConnLimmtMSec = MAX_UNRECV_MS;

	while(1) {
		if (m_eventLoopWatchVariable != 0) break;
		
		if (m_bIsPlay) {
			if (((uint64_t)m_nRecvVideoBytes) == ((uint64_t)nLastRecvBytes)) {
				if (!bIsStartClock) {
					clock.ReInit();
					timeval stTime;
					ZeroMemory(&stTime, sizeof(timeval));
					clock.start(stTime);
					bIsStartClock = TRUE;
					continue;
				}
				
				clock.GetMsSinceStart(nMs);
				if (nMs > (uint64_t)(m_nDisConnLimmtMSec)) {
					bIsStartClock = FALSE;
					if (m_pDisConnCallback) m_pDisConnCallback(m_pDCCallBackParam, this);
				}

			}else {
				bIsStartClock = FALSE;
				nLastRecvBytes = m_nRecvVideoBytes;
			}
		}
		
		((BasicTaskScheduler0*)(&(env.taskScheduler())))->SingleStep();
		CalcBitsRatePerSec();
	}
}