void TemplateMatchingTrainer::evaluateBaseline(const std::string &meanForAlign, const std::string &dataPath, const std::string &pcaDepthmapPath) { FaceAligner aligner(Mesh::fromFile(meanForAlign), std::string()); std::vector<std::string> fileNames = Face::LinAlg::Loader::listFiles(dataPath, "*.binz", Face::LinAlg::Loader::Filename); int n = fileNames.size(); std::vector<int> ids = Face::Biometrics::BioDataProcessing::getIds(fileNames, "-"); std::vector<Mesh> meshes(n); std::vector<double> times(n); #pragma omp parallel for for (int i = 0; i < n; i++) { //if (ids[i] >= 1002) break; //if (ids[i] < 5000) continue; Mesh m = Mesh::fromFile(dataPath + Poco::Path::separator() + fileNames[i]); SurfaceProcessor::mdenoising(m, 0.01, 10, 0.01); Poco::Timestamp before; aligner.icpAlign(m, 50, FaceAligner::TemplateMatching); times[i] = before.elapsed()/1000; meshes[i] = m; } std::cout << "mean align time (ms) :" << (std::accumulate(times.begin(), times.end(), 0.0)/n) << std::endl; evaluate(meshes, ids, pcaDepthmapPath); }
void Context::flushSessionCache() { poco_assert (isForServerUse()); Poco::Timestamp now; SSL_CTX_flush_sessions(_pSSLContext, static_cast<long>(now.epochTime())); }
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; } }
void StartupStore(const TCHAR *Str, ...) { TCHAR buf[(MAX_PATH*2)+1]; // 260 chars normally FIX 100205 va_list ap; va_start(ap, Str); _vsntprintf(buf, countof(buf), Str, ap); va_end(ap); LockStartupStore(); FILE *startupStoreFile = NULL; static TCHAR szFileName[MAX_PATH]; static Poco::Timestamp StartTime; static bool initialised = false; if (!initialised) { LocalPath(szFileName, TEXT(LKF_RUNLOG)); initialised = true; } startupStoreFile = _tfopen(szFileName, TEXT("ab+")); if (startupStoreFile != NULL) { char sbuf[(MAX_PATH*2)+1]; // FIX 100205 int i = TCHAR2utf(buf, sbuf, sizeof(sbuf)); if (i > 0) { if (sbuf[i - 1] == 0x0a && (i == 1 || (i > 1 && sbuf[i-2] != 0x0d))) sprintf(sbuf + i - 1, SNEWLINE); fprintf(startupStoreFile, "[%09u] %s", (unsigned int)StartTime.elapsed()/1000, sbuf); } fclose(startupStoreFile); } UnlockStartupStore(); }
int FFmpegTagger::IORead(void *opaque, uint8_t *buf, int buf_size) { URLContext* pUrlContext = (URLContext*)opaque; std::istream* pInputStream = (std::istream*)pUrlContext->priv_data; if (!pInputStream) { LOGNS(Omm::AvStream, avstream, error, "IORead failed, std::istream not set"); return -1; } pInputStream->read((char*)buf, buf_size); Poco::Timestamp::TimeDiff time = _timestamp.elapsed(); _timestamp.update(); Poco::Timestamp::TimeDiff startTime = _startTimestamp.elapsed(); int bytes = pInputStream->gcount(); _totalBytes += bytes; if (!pInputStream->good()) { LOGNS(Omm::AvStream, avstream, error, "IORead failed to read from std::istream"); return -1; } LOGNS(Omm::AvStream, avstream, trace, "IORead() bytes read: " + Poco::NumberFormatter::format(bytes) + " in " + Poco::NumberFormatter::format(time/1000.0, 3) + " msec (" + Poco::NumberFormatter::format(bytes*1000/time) + " kB/s), total : " +\ Poco::NumberFormatter::format(_totalBytes/1000) + "kB in " + Poco::NumberFormatter::format(startTime/(Poco::Timestamp::TimeDiff)1000000) + " sec (" + Poco::NumberFormatter::format((Poco::Timestamp::TimeDiff)(_totalBytes*1000)/startTime) + "kB/s)"); return bytes; }
void ThreadTest::testSleep() { Poco::Timestamp start; Thread::sleep(200); Poco::Timespan elapsed = start.elapsed(); assert (elapsed.totalMilliseconds() >= 190 && elapsed.totalMilliseconds() < 250); }
void ofxTwitter::checkHelpConfigurationFile() { ofFile file(ofToDataPath("ofxTwitter_configuration.json")); bool configFileNeedsUpdate = false; if(file.exists()) { Poco::File &filepoco = file.getPocoFile(); Poco::Timestamp tfile = filepoco.getLastModified(); time_t timer; time(&timer); double seconds; seconds = difftime(timer,tfile.epochTime()); if(seconds < 86400) { configFileNeedsUpdate = false; } else { configFileNeedsUpdate = true; } } else { configFileNeedsUpdate = true; } if(!configFileNeedsUpdate) { ofLogNotice("ofxTwitter::authorize") << "Config up to date."; parseConfigurationFile(); } else { updateHelpConfiguration(); } }
void TileCacheTests::testPerformance() { std::string documentPath, documentURL; getDocumentPathAndURL("hello.odt", documentPath, documentURL); Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, documentURL); auto socket = *loadDocAndGetSocket(_uri, documentURL, "tile-performance "); getResponseMessage(socket, "invalidatetiles:"); Poco::Timestamp timestamp; for (auto x = 0; x < 5; ++x) { sendTextFrame(socket, "tilecombine part=0 width=256 height=256 tileposx=0,3840,7680,11520,0,3840,7680,11520 tileposy=0,0,0,0,3840,3840,3840,3840 tilewidth=3840 tileheight=3840"); for (auto i = 0; i < 8; ++i) { auto tile = getResponseMessage(socket, "tile:", "tile-performance "); CPPUNIT_ASSERT_MESSAGE("did not receive a tile: message as expected", !tile.empty()); } } std::cerr << "Tile rendering roundtrip for 5 x 8 tiles combined: " << timestamp.elapsed() / 1000. << " ms. Per-tilecombine: " << timestamp.elapsed() / (1000. * 5) << " ms. Per-tile: " << timestamp.elapsed() / (1000. * 5 * 8) << "ms." << std::endl; socket.shutdown(); }
bool Debounce(void) { if (fpsTimeLast.isElapsed(debounceTimeout.totalMicroseconds())) { fpsTimeLast.update(); return true; } else { return false; } }
void TrafficDataObject::deleteOld() { Poco::Timestamp achshav; Poco::Timespan days = Poco::Timespan::DAYS * Poco::Util::Application::instance().config().getUInt("ion.trafficage"); achshav -= days; std::time_t age = achshav.epochTime(); _session << "DELETE FROM traffic WHERE time<?", use(age), now; }
bool Debounce(int dtime) { const Poco::Timespan TimeOut(0, 1000*dtime); if (fpsTimeLast.isElapsed(TimeOut.totalMicroseconds())) { fpsTimeLast.update(); return true; } else { return false; } }
void Timer::run() { Poco::Timestamp now; long interval(0); do { long sleep(0); do { now.update(); sleep = static_cast<long>((_nextInvocation - now)/1000); if (sleep < 0) { if (interval == 0) { sleep = 0; break; } _nextInvocation += static_cast<Timestamp::TimeVal>(interval)*1000; ++_skipped; } } while (sleep < 0); if (_wakeUp.tryWait(sleep)) { Poco::FastMutex::ScopedLock lock(_mutex); _nextInvocation.update(); interval = _periodicInterval; } else { try { _pCallback->invoke(*this); } catch (Poco::Exception& exc) { Poco::ErrorHandler::handle(exc); } catch (std::exception& exc) { Poco::ErrorHandler::handle(exc); } catch (...) { Poco::ErrorHandler::handle(); } interval = _periodicInterval; } _nextInvocation += static_cast<Timestamp::TimeVal>(interval)*1000; _skipped = 0; } while (interval > 0); _done.set(); }
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; }
std::time_t UIShader::getLastModified( ofFile& _file ){ if( _file.exists() ){ Poco::File& pocoFile = _file.getPocoFile(); Poco::Timestamp timestamp = pocoFile.getLastModified(); std::time_t fileChangedTime = timestamp.epochTime(); return fileChangedTime; } else { return 0; } }
void ThreadImpl::sleepImpl(long milliseconds) { #if defined(__digital__) // This is specific to DECThreads struct timespec interval; interval.tv_sec = milliseconds / 1000; interval.tv_nsec = (milliseconds % 1000)*1000000; pthread_delay_np(&interval); #elif POCO_OS == POCO_OS_LINUX || POCO_OS == POCO_OS_ANDROID || POCO_OS == POCO_OS_MAC_OS_X || POCO_OS == POCO_OS_QNX || POCO_OS == POCO_OS_VXWORKS Poco::Timespan remainingTime(1000*Poco::Timespan::TimeDiff(milliseconds)); int rc; do { struct timespec ts; ts.tv_sec = (long) remainingTime.totalSeconds(); ts.tv_nsec = (long) remainingTime.useconds()*1000; Poco::Timestamp start; rc = ::nanosleep(&ts, 0); if (rc < 0 && errno == EINTR) { Poco::Timestamp end; Poco::Timespan waited = start.elapsed(); if (waited < remainingTime) remainingTime -= waited; else remainingTime = 0; } } while (remainingTime > 0 && rc < 0 && errno == EINTR); if (rc < 0 && remainingTime > 0) throw Poco::SystemException("Thread::sleep(): nanosleep() failed"); #else Poco::Timespan remainingTime(1000*Poco::Timespan::TimeDiff(milliseconds)); int rc; do { struct timeval tv; tv.tv_sec = (long) remainingTime.totalSeconds(); tv.tv_usec = (long) remainingTime.useconds(); Poco::Timestamp start; rc = ::select(0, NULL, NULL, NULL, &tv); if (rc < 0 && errno == EINTR) { Poco::Timestamp end; Poco::Timespan waited = start.elapsed(); if (waited < remainingTime) remainingTime -= waited; else remainingTime = 0; } } while (remainingTime > 0 && rc < 0 && errno == EINTR); if (rc < 0 && remainingTime > 0) throw Poco::SystemException("Thread::sleep(): select() failed"); #endif }
void MultiBiomertricsAutoTuner::fillEvaluations(const Input &sourceDatabaseTrainData, const Input &targetDatabaseTrainData, const Settings &settings, std::vector<Evaluation> &evaluations) { int allUnitsCount = settings.params.size(); Poco::Timestamp stamp; #pragma omp parallel for for (int i = 0; i < allUnitsCount; i++) { trainUnit(settings.params[i], sourceDatabaseTrainData, targetDatabaseTrainData, evaluations, i); } std::cout << "Training individual classifiers took " << (stamp.elapsed()/1000) << "ms"; }
void TrafficDataObject::checkAuthStatus() { Poco::Timestamp achshav; Poco::Timespan days = Poco::Timespan::MINUTES * Poco::Util::Application::instance().config().getUInt("ion.traffic-interval"); achshav -= days; std::time_t age = achshav.epochTime(); unsigned count = 0; _session << "SELECT sum(count) AS count FROM traffic WHERE time>? AND " "traffic.domain NOT IN (SELECT value FROM authorized_traffic WHERE type='domain') AND " "traffic.ip NOT IN (SELECT value FROM authorized_traffic WHERE type='ip') AND " "traffic.port NOT IN (SELECT value FROM authorized_traffic WHERE type='port') AND " "traffic.process NOT IN (SELECT value FROM authorized_traffic WHERE type='process')", use(age), into(count), now; if (count > 0) { _logger.notice("Non authorized traffic count %u", count); EventNotification::notifyTraffic(count); } }
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 ); } } }
RealSenseSensor::State RealSenseSensorImpl::go() { try { if (brightnessToSet != 0) { Poco::Timestamp now; check(device->SetColorBrightness(brightnessToSet), "Set color brightness failed"); printTimeIfBig(now.elapsed(), "setColorBrightnessTime"); brightnessToSet = 0; } switch (state) { case RealSenseSensor::STATE_OFF: // do nothing break; case RealSenseSensor::STATE_IDLE: // Check for face presence every 5th frame // Start positioning if face is present long enough doIdle(); break; case RealSenseSensor::STATE_POSITIONING: // Navigate user to proper position doPositioning(); break; case RealSenseSensor::STATE_CAPTURING: // Just convert current depth and color buffer to mesh doCapturing(); break; case RealSenseSensor::STATE_CAPTURING_DONE: // do nothing doCapturingDone(); break; default: break; } } catch (std::exception& e) { std::cerr << "go() exception in state " << getState() << ": " << e.what() << std::endl; } return getState(); }
//---------------------------------------- // 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; }
int ICMPSocketImpl::receiveFrom(void*, int, SocketAddress& address, int flags) { int maxPacketSize = _icmpPacket.maxPacketSize(); unsigned char* buffer = new unsigned char[maxPacketSize]; try { Poco::Timestamp ts; do { if (ts.isElapsed(_timeout)) { // This guards against a possible DoS attack, where sending // fake ping responses will cause an endless loop. throw TimeoutException(); } SocketImpl::receiveFrom(buffer, maxPacketSize, address, flags); } while (!_icmpPacket.validReplyID(buffer, maxPacketSize)); } catch (TimeoutException&) { delete [] buffer; throw; } catch (Exception&) { std::string err = _icmpPacket.errorDescription(buffer, maxPacketSize); delete [] buffer; if (!err.empty()) throw ICMPException(err); else throw; } struct timeval then = _icmpPacket.time(buffer, maxPacketSize); struct timeval now = _icmpPacket.time(); int elapsed = (((now.tv_sec * 1000000) + now.tv_usec) - ((then.tv_sec * 1000000) + then.tv_usec))/1000; delete[] buffer; return elapsed; }
//---------------------------------------- // 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(); }
ByteIOContext* FFmpegTagger::initIo(std::istream& istr, bool isSeekable, unsigned char* pIoBuffer) { static char streamName[] = "std::istream"; // FIXME: deallocate URLContext after stream has finished. URLContext* pUrlContext = new URLContext; pUrlContext->is_streamed = 1; // pUrlContext->priv_data = 0; pUrlContext->priv_data = &istr; pUrlContext->filename = streamName; pUrlContext->prot = new URLProtocol; pUrlContext->prot->name = "OMM avio wrapper for std::iostream"; pUrlContext->prot->next = 0; pUrlContext->prot->url_open = 0; // pUrlContext->prot->url_open = (int (*)(URLContext *, const char *, int))IOOpen; pUrlContext->prot->url_read = (int (*) (URLContext *, unsigned char *, int))FFmpegTagger::IORead; pUrlContext->prot->url_write = 0; if (isSeekable) { pUrlContext->prot->url_seek = (int64_t (*) (URLContext *, int64_t, int))FFmpegTagger::IOSeek; } else { pUrlContext->prot->url_seek = 0; } pUrlContext->prot->url_close = 0; // pUrlContext->prot->url_close = (int (*)(URLContext *))IOClose; LOG(ffmpeg, trace, "ffmpeg::av_alloc_put_byte() ..."); ByteIOContext* pIoContext; if (isSeekable) { pIoContext = av_alloc_put_byte(pIoBuffer, _IoBufferSize, 0, pUrlContext, FFmpegTagger::IORead, 0, FFmpegTagger::IOSeek); } else { pIoContext = av_alloc_put_byte(pIoBuffer, _IoBufferSize, 0, pUrlContext, FFmpegTagger::IORead, 0, 0); pIoContext->is_streamed = 1; } pIoContext->max_packet_size = _IoBufferSize; _timestamp.update(); _startTimestamp.update(); return pIoContext; }
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"); } }
Notification* TimedNotificationQueue::waitDequeueNotification(long milliseconds) { while (milliseconds >= 0) { _mutex.lock(); NfQueue::iterator it = _nfQueue.begin(); if (it != _nfQueue.end()) { _mutex.unlock(); Poco::Timestamp now; Timestamp::TimeDiff sleep = it->first - now; if (sleep <= 0) { return dequeueOne(it).duplicate(); } else if (sleep <= 1000*Timestamp::TimeDiff(milliseconds)) { if (!wait(sleep)) { return dequeueOne(it).duplicate(); } else { milliseconds -= static_cast<long>((now.elapsed() + 999)/1000); continue; } } } else { _mutex.unlock(); } if (milliseconds > 0) { Poco::Timestamp now; _nfAvailable.tryWait(milliseconds); milliseconds -= static_cast<long>((now.elapsed() + 999)/1000); } else return 0; } return 0; }
void ChildProcessSession::sendFontRendering(const char* /*buffer*/, int /*length*/, StringTokenizer& tokens) { std::string font, decodedFont; int width, height; unsigned char *pixmap; if (tokens.count() < 2 || !getTokenString(tokens[1], "font", font)) { sendTextFrame("error: cmd=renderfont kind=syntax"); return; } Poco::Mutex::ScopedLock lock(_mutex); _loKitDocument->pClass->setView(_loKitDocument, _viewId); URI::decode(font, decodedFont); std::string response = "renderfont: " + Poco::cat(std::string(" "), tokens.begin() + 1, tokens.end()) + "\n"; std::vector<char> output; output.resize(response.size()); std::memcpy(output.data(), response.data(), response.size()); Poco::Timestamp timestamp; pixmap = _loKitDocument->pClass->renderFont(_loKitDocument, decodedFont.c_str(), &width, &height); Log::trace("renderFont [" + font + "] rendered in " + std::to_string(timestamp.elapsed()/1000.) + "ms"); if (pixmap != nullptr) { if (!Util::encodePNGAndAppendToBuffer(pixmap, width, height, output, LOK_TILEMODE_RGBA)) { sendTextFrame("error: cmd=renderfont kind=failure"); delete[] pixmap; return; } delete[] pixmap; } sendBinaryFrame(output.data(), output.size()); }
void Topology::flushCache() { #ifdef DEBUG_TFC StartupStore(TEXT("---flushCache() starts%s"),NEWLINE); Poco::Timestamp starttick;; #endif switch (cache_mode) { case 0: // Original case 1: // Bounds array in memory for (int i=0; i<shpfile.numshapes; i++) { removeShape(i); } break; case 2: // Shapes in memory for (int i=0; i<shpfile.numshapes; i++) { shpCache[i] = NULL; } break; }//sw shapes_visible_count = 0; #ifdef DEBUG_TFC StartupStore(TEXT(" flushCache() ends (%dms)%s"),Poco::Timespan(starttick.elapsed()).totalMilliseconds(),NEWLINE); #endif }
void run() { Poco::Timestamp lastScan; ItemInfoMap entries; scan(entries); while (!_stopped) { struct timespec timeout; timeout.tv_sec = 0; timeout.tv_nsec = 200000000; unsigned eventFilter = NOTE_WRITE; struct kevent event; struct kevent eventData; EV_SET(&event, _dirFD, EVFILT_VNODE, EV_ADD | EV_CLEAR, eventFilter, 0, 0); int nEvents = kevent(_queueFD, &event, 1, &eventData, 1, &timeout); if (nEvents < 0 || eventData.flags == EV_ERROR) { try { FileImpl::handleLastErrorImpl(owner().directory().path()); } catch (Poco::Exception& exc) { owner().scanError(&owner(), exc); } } else if (nEvents > 0 || ((owner().eventMask() & DirectoryWatcher::DW_ITEM_MODIFIED) && lastScan.isElapsed(owner().scanInterval()*1000000))) { ItemInfoMap newEntries; scan(newEntries); compare(entries, newEntries); std::swap(entries, newEntries); lastScan.update(); } } }