uint32_t MeetingFrameImpl::StartPublishVideo2(uint64_t ulToUserID,uint32_t ulChannelID,IVideoWin*videoWin) { Mutex::ScopedLock lock(m_Mutex); if(ulChannelID <0) return 0; int count = GetVideoCaptureDeviceCount(); if(count == 0) return 0; if(ulChannelID>GetVideoCaptureDeviceCount()-1) ulChannelID = 0; if(m_bHasStartVideo2 == true) return 0; m_bHasStartVideo2 = true; m_bVideoMonitor = true; uint64_t myGuid ; Poco::Timestamp t; uint32_t ulSSRC = unsigned int(t.epochMicroseconds()&0xFFFFFFFF); if(videoWin) { videoWin->SetUserID(0); videoWin->SetUserName(GetUserName(ulToUserID)); m_myUserInfo.ulVideoSSRC = m_pIZYMediaStreamManager->StartVideoSender(ulSSRC,ulChannelID, videoWin, MeetingConnImpl::GetInstance()->GetRoomID()); if(m_myUserInfo.ulVideoSSRC > 0) { return ulSSRC; } } else { return 0; } }
int main(int argc, char**argv) { dsosg::DSOSG *dsosg; Poco::Timestamp time; bool done; osg::ArgumentParser arguments(&argc, argv); arguments.getApplicationUsage()->setApplicationName(arguments.getApplicationName()); arguments.getApplicationUsage()->setDescription("Manual display/camera calibration utility"); arguments.getApplicationUsage()->addCommandLineOption("--config <filename>","Display server config JSON file"); arguments.getApplicationUsage()->addCommandLineOption("--display-mode <name>","Display mode"); osg::ApplicationUsage::Type help = arguments.readHelpType(); if (help != osg::ApplicationUsage::NO_HELP) { arguments.getApplicationUsage()->write(std::cout); exit(0); } std::string config_filename = "~/flyvr-devel/flyvr/flyvr/config/config.json"; while(arguments.read("--config", config_filename)); std::string display_mode = "vr_display"; while(arguments.read("--display-mode", display_mode)); std::string flyvr_basepath = "/home/john/Programming/flyvr.git/flyvr/"; float observer_radius = 0.01; bool two_pass = false; bool show_geom_coords = false; osg::Vec3 observer_position(0,0,0); osg::Quat observer_orientation(0,0,0,1); dsosg = new dsosg::DSOSG( flyvr_basepath, display_mode, observer_radius, config_filename, two_pass, show_geom_coords); dsosg->setup_viewer("display_server","{}"); dsosg->set_stimulus_plugin("Stimulus3DDemo"); done = false; while (!done) { float now; time.update(); now = time.epochMicroseconds() * 1e6; /* microseconds to seconds */ dsosg->update(now, observer_position, observer_orientation); dsosg->frame(); done = dsosg->done(); } return 0; }
void XplDevice::run ( void ) { if ( !m_bInitialised ) { assert ( 0 ); return; } while ( !m_bExitThread ) { // Deal with heartbeats int64_t currentTime; Poco::Timestamp tst; tst.update(); currentTime = tst.epochMicroseconds(); //GetSystemTimeAsFileTime( (FILETIME*)¤tTime ); if ( m_nextHeartbeat <= currentTime ) { poco_debug( devLog, "Sending heartbeat" ); // It is time to send a heartbeat if ( m_bConfigRequired ) { // Send a config heartbeat, then calculate the time of the next one m_pComms->SendConfigHeartbeat ( m_completeId, m_heartbeatInterval, m_version ); } else { // Send a heartbeat, then calculate the time of the next one m_pComms->SendHeartbeat ( m_completeId, m_heartbeatInterval, m_version ); } SetNextHeartbeatTime(); } // Calculate the time (in milliseconds) until the next heartbeat int32 heartbeatTimeout = ( int32 ) ( ( m_nextHeartbeat - currentTime ) ); // Divide by 10000 to convert 100 nanosecond intervals to milliseconds. poco_debug ( devLog, "Sleeping " + NumberFormatter::format ( heartbeatTimeout/1000 ) + " seconds till next hbeat" ); m_hRxInterrupt->tryWait ( heartbeatTimeout ); //Thread::sleep(); poco_debug ( devLog, "Woken up for hbeat or interrupt" ); } // cout << "exiting dev thread (ret)\n"; return; }
void XplDevice::SetNextHeartbeatTime() { // Set the new heartbeat time int64_t currentTime; Poco::Timestamp tst; tst.update(); currentTime = tst.epochMicroseconds(); //GetSystemTimeAsFileTime( (FILETIME*)¤tTime ); // If we're waiting for a hub, we have to send at more // rapid intervals - every 3 seconds for the first two // minutes, then once every 30 seconds after that. if ( m_bWaitingForHub ) { if ( m_rapidHeartbeatCounter ) { // This counter starts at 40 for 2 minutes of // heartbeats at 3 second intervals. --m_rapidHeartbeatCounter; m_nextHeartbeat = currentTime + ( ( int64_t ) c_rapidHeartbeatFastInterval * 1000l ); } else { // one second m_nextHeartbeat = currentTime + ( ( int64_t ) c_rapidHeartbeatSlowInterval * 1000l ); } } else { // It is time to send a heartbeat if ( m_bConfigRequired ) { // one minute m_nextHeartbeat = currentTime + 60*1000l; } else { // 60000000 is one minute in the 100 nanosecond intervals // that the system time is measured in. m_nextHeartbeat = currentTime + ( ( int64_t ) m_heartbeatInterval * 60*1000l ); } } }
//---------------------------------------- // TestSchedule //---------------------------------------- void TestSchedule(ScopedLogMessage& msg, Poco::Util::Timer& timer) { msg.Message("--- schedule ---"); const Poco::Timestamp::TimeDiff kTimeDiff = 500000; // 500msec Poco::Event event; MyTimerTask task(msg, event); Poco::Util::TimerTask::Ptr pTask = new Poco::Util::TimerTaskAdapter<MyTimerTask>(task, &MyTimerTask::onTimer); Poco::Timestamp time; time += kTimeDiff; timer.schedule(pTask, time); event.wait(); msg.Message(Poco::format(" execution delay from scheduled: %Ldusec" , pTask->lastExecution().epochMicroseconds()-time.epochMicroseconds())); }
void MeetingFrameImpl::On_MeetingEvent_Enter_Room_Result(uint32_t status, char* pData) { Mutex::ScopedLock lock(m_Mutex); switch(status) { case 0: { if(m_mapOnlineUser.size()>0){ //断线重新连接成功,清空在线用户 m_mapOnlineUser.clear(); } m_myUserInfo.userRole = MeetingConnImpl::GetInstance()->m_userRole; PROOM_INFO pRoomInfo = (PROOM_INFO)pData; m_pRoomInfo = new ROOM_INFO(); memcpy((void*)(m_pRoomInfo),pData,sizeof(ROOM_INFO)); kAudioMode = pRoomInfo->bMixAudio; m_orgi_user_role = MeetingConnImpl::GetInstance()->m_userRole; m_myUserInfo.userRole = MeetingConnImpl::GetInstance()->m_userRole; //启动音频接收 if(kAudioMode == 1) { Poco::Timestamp t; m_ulMixAudioSSRC = unsigned int(t.epochMicroseconds()&0xFFFFFFFF)+rand(); m_ulAudioPlaySSRC = m_ulMixAudioSSRC; m_pIZYMediaStreamManager->StartAudioRecver(m_ulMixAudioSSRC,m_mainHWND,MeetingConnImpl::GetInstance()->GetRoomID(), kAudioMode,m_pRoomInfo->sampleRate); } if(m_pEvent) { m_pEvent->On_MeetingEvent_UpdateUI(); } } break; case kLoginResult_Meeting_NoRoom: //房间号错误 printf("not find room ! \n"); break; case kLoginResult_Meeting_RoomPwd_NOTCorrent: //密码错误 printf("password not correct! \n"); break; case kLoginResult_Meeting_NotAuth: //没有权限进入 break; }
//---------------------------------------- // TestInterval //---------------------------------------- void TestInterval(ScopedLogMessage& msg, Poco::Util::Timer& timer) { msg.Message("--- schedule interval ---"); Poco::Event event; MyTimerTask task(msg, event); Poco::Util::TimerTask::Ptr pTask = new Poco::Util::TimerTaskAdapter<MyTimerTask>(task, &MyTimerTask::onTimer); Poco::Timestamp time; timer.schedule(pTask, 500, 500); // 500msec Poco::Timestamp::TimeVal val; val = WaitAndShowTime(msg, event, pTask, " delay :", time.epochMicroseconds()); for(int i=0; i<2; ++i) { val = WaitAndShowTime(msg, event, pTask, " interval:", val); } pTask->cancel(); }
void MeetingFrameImpl::StartPublishVideo(uint64_t ulToUserID,uint32_t ulChannelID,IVideoWin*videoWin) { Mutex::ScopedLock lock(m_Mutex); if(ulChannelID <0) return; int count = GetVideoCaptureDeviceCount(); if(count == 0) return; if(ulChannelID>GetVideoCaptureDeviceCount()-1) ulChannelID = 0; if(m_bStartVideo == true) return; m_bStartVideo = true; uint64_t myGuid ; Poco::Timestamp t; uint32_t ulSSRC = unsigned int(t.epochMicroseconds()&0xFFFFFFFF); if(videoWin) { videoWin->SetUserID(0); videoWin->SetUserName(m_myUserInfo.strUserName); m_myUserInfo.ulVideoSSRC = m_pIZYMediaStreamManager->StartVideoSender(ulSSRC,ulChannelID, videoWin, MeetingConnImpl::GetInstance()->GetRoomID()); m_bBroadcast = true; if(m_myUserInfo.ulVideoSSRC > 0) { char pData[64]; myGuid = m_pIZYMediaStreamManager->GetGUID(); memcpy(pData,&myGuid,8); memcpy(pData+8,&m_myUserInfo.ulVideoSSRC,4); char subMsg[512] = {0}; sprintf(subMsg,"{\"cmd\":\"recvMyVideo\",\"ssrc\":%u,\"fromSessionID\":%I64u,\"channelID\":%u}" ,m_myUserInfo.ulVideoSSRC,m_myUserInfo.sessionID,ulChannelID); MeetingConnImpl::GetInstance()->TransParentRoomCommand(0,subMsg); } } else { OutputDebugStringW(L"Get New IVideoWin Failed!\n"); } }
void SHA1EngineExt::update(const Poco::Timestamp &data) { Poco::Timestamp::TimeVal val = data.epochMicroseconds(); SHA1Engine::update(&val, sizeof(val)); }