/** * @brief * * @param ssrc * @param localHost * @param localPortBase * @param remoteHost * @param remotePortBase */ RtpSession::RtpSession( uint32_t ssrc, const std::string &localHost, int localPortBase, const std::string &remoteHost, int remotePortBase ) : mSsrc( ssrc ), mLocalHost( localHost ), mRemoteHost( remoteHost ), mRtpClock( 0 ), mFrameCount( 0 ) { int seq = 0; char hostname[256] = ""; gethostname( hostname, sizeof(hostname) ); mCname = stringtf( "CaMeRa@%s", hostname ); Debug( 3, "RTP CName = %s", mCname.c_str() ); init( seq ); mMaxSeq = seq - 1; mProbation = MIN_SEQUENTIAL; mLocalPortChans[0] = localPortBase; mLocalPortChans[1] = localPortBase+1; mRemotePortChans[0] = remotePortBase; mRemotePortChans[1] = remotePortBase+1; mBaseTimeReal = tvNow(); mBaseTimeNtp = tvZero(); mBaseTimeRtp = 0; // These are for RTP Sender Reports, not currently implemented mLastSrTimeReal = tvZero(); mLastSrTimeNtp = tvZero(); mLastSrTimeRtp = 0; }
bool CMessageService::SaveThreadInfoData() { //这里进行线程自检 ACE_Time_Value tvNow(ACE_OS::gettimeofday()); ACE_Date_Time dt(m_ThreadInfo.m_tvUpdateTime); //开始查看线程是否超时 //OUR_DEBUG((LM_INFO, "[CMessageService::SaveThreadInfoData]ID=%d,m_u4State=%d,m_u2ThreadTimeOut=%d,cost=%d.\n", m_ThreadInfo.m_u4ThreadID, m_ThreadInfo.m_u4State, m_u2ThreadTimeOut, tvNow.sec() - m_ThreadInfo.m_tvUpdateTime.sec())); if(m_ThreadInfo.m_u4State == THREAD_RUNBEGIN && tvNow.sec() - m_ThreadInfo.m_tvUpdateTime.sec() > m_u2ThreadTimeOut) { AppLogManager::instance()->WriteLog(LOG_SYSTEM_WORKTHREAD, "[CMessageService::handle_timeout] pThreadInfo = [%d] State = [%d] Time = [%04d-%02d-%02d %02d:%02d:%02d] PacketCount = [%d] LastCommand = [0x%x] PacketTime = [%d] TimeOut > %d[%d] CurrPacketCount = [%d] QueueCount = [%d] BuffPacketUsed = [%d] BuffPacketFree = [%d].", m_ThreadInfo.m_u4ThreadID, m_ThreadInfo.m_u4State, dt.year(), dt.month(), dt.day(), dt.hour(), dt.minute(), dt.second(), m_ThreadInfo.m_u4RecvPacketCount, m_ThreadInfo.m_u2CommandID, m_ThreadInfo.m_u2PacketTime, m_u2ThreadTimeOut, tvNow.sec() - m_ThreadInfo.m_tvUpdateTime.sec(), m_ThreadInfo.m_u4CurrPacketCount, (int)msg_queue()->message_count(), App_BuffPacketManager::instance()->GetBuffPacketUsedCount(), App_BuffPacketManager::instance()->GetBuffPacketFreeCount()); //发现阻塞线程,需要重启相应的线程 AppLogManager::instance()->WriteLog(LOG_SYSTEM_WORKTHREAD, "[CMessageService::handle_timeout] ThreadID = [%d] Thread is reset.", m_u4ThreadID); return false; } else { AppLogManager::instance()->WriteLog(LOG_SYSTEM_WORKTHREAD, "[CMessageService::handle_timeout] pThreadInfo = [%d] State = [%d] Time = [%04d-%02d-%02d %02d:%02d:%02d] PacketCount = [%d] LastCommand = [0x%x] PacketTime = [%d] CurrPacketCount = [%d] QueueCount = [%d] BuffPacketUsed = [%d] BuffPacketFree = [%d].", m_ThreadInfo.m_u4ThreadID, m_ThreadInfo.m_u4State, dt.year(), dt.month(), dt.day(), dt.hour(), dt.minute(), dt.second(), m_ThreadInfo.m_u4RecvPacketCount, m_ThreadInfo.m_u2CommandID, m_ThreadInfo.m_u2PacketTime, m_ThreadInfo.m_u4CurrPacketCount, (int)msg_queue()->message_count(), App_BuffPacketManager::instance()->GetBuffPacketUsedCount(), App_BuffPacketManager::instance()->GetBuffPacketFreeCount()); m_ThreadInfo.m_u4CurrPacketCount = 0; return true; } return true; }
RtpSource::RtpSource( int id, const std::string &localHost, int localPortBase, const std::string &remoteHost, int remotePortBase, uint32_t ssrc, uint16_t seq, uint32_t rtpClock, uint32_t rtpTime, _AVCODECID codecId ) : mId( id ), mSsrc( ssrc ), mLocalHost( localHost ), mRemoteHost( remoteHost ), mRtpClock( rtpClock ), mCodecId( codecId ), mFrame( 65536 ), mFrameCount( 0 ), mFrameGood( true ), mFrameReady( false ), mFrameProcessed( false ) { char hostname[256] = ""; gethostname( hostname, sizeof(hostname) ); mCname = stringtf( "zm-%d@%s", mId, hostname ); Debug( 3, "RTP CName = %s", mCname.c_str() ); init( seq ); mMaxSeq = seq - 1; mProbation = MIN_SEQUENTIAL; mLocalPortChans[0] = localPortBase; mLocalPortChans[1] = localPortBase+1; mRemotePortChans[0] = remotePortBase; mRemotePortChans[1] = remotePortBase+1; mRtpFactor = mRtpClock; mBaseTimeReal = tvNow(); mBaseTimeNtp = tvZero(); mBaseTimeRtp = rtpTime; mLastSrTimeReal = tvZero(); mLastSrTimeNtp = tvZero(); mLastSrTimeRtp = 0; if(mCodecId != AV_CODEC_ID_H264 && mCodecId != AV_CODEC_ID_MPEG4) Warning( "The device is using a codec that may not be supported. Do not be surprised if things don't work." ); }