bool DumpGui::run() { if ( _fileOutputFPS ) { _fileOutputAdvance = static_cast<int>(1000/_fileOutputFPS); } else { _fileOutputAdvance = _interval; _fileOutputFPS = static_cast<int>(1000/_fileOutputAdvance); } log_debug("DumpGui entering main loop with interval of %d ms", _interval); // heart-beat interval, in milliseconds // TODO: extract this value from the swf's FPS // by default and allow overriding it // unsigned int clockAdvance = _interval; const bool doDisplay = _fileStream.is_open(); terminate_request = false; _startTime = _clock.elapsed(); while (!terminate_request) { _clock.advance(clockAdvance); // advance movie now advanceMovie(doDisplay); if (_started) { writeSamples(); // Dump a video frame if it's time for it or no frame // was dumped yet size_t elapsed = _clock.elapsed(); if (!_framecount || (elapsed - _lastVideoFrameDump) >= _fileOutputAdvance) { writeFrame(); } // check if we've reached a timeout if (_timeout && _clock.elapsed() >= _timeout) { break; } } if (_sleepUS) gnashSleep(_sleepUS); if (!_started && !_startTrigger.empty()) { // Check whether to start std::string path; std::string var; if (parsePath(_startTrigger, path, var)) { movie_root& mr = *getStage(); const as_environment& env = mr.getRootMovie().get_environment(); as_object* o = findObject(env, path); if (o) { as_value val; o->get_member(getURI(mr.getVM(), "_ready"), &val); if (val.equals(true, 8)) { log_debug("Starting dump"); _started = true; _startTime = _clock.elapsed(); _lastVideoFrameDump = _startTime; } } } } } const boost::uint32_t total_time = _clock.elapsed() - _startTime; std::cout << "TIME=" << total_time << std::endl; std::cout << "FPS_ACTUAL=" << _fileOutputFPS << std::endl; // In this Gui, quit() does not exit, but it is necessary to catch the // last frame for screenshots. quit(); return true; }
bool DumpGui::run() { if ( _fileOutputFPS ) { _fileOutputAdvance = static_cast<int>(1000/_fileOutputFPS); } else { _fileOutputAdvance = _interval; _fileOutputFPS = static_cast<int>(1000/_fileOutputAdvance); } log_debug("DumpGui entering main loop with interval of %d ms", _interval); // heart-beat interval, in milliseconds // TODO: extract this value from the swf's FPS // by default and allow overriding it // unsigned int clockAdvance = _interval; VirtualClock& timer = getClock(); const bool doDisplay = _fileStream.is_open(); _terminate_request = false; while (!_terminate_request) { _manualClock.advance(clockAdvance); // advance movie now advanceMovie(doDisplay); writeSamples(); // Dump a video frame if it's time for it or no frame // was dumped yet size_t elapsed = timer.elapsed(); if ( ! _framecount || elapsed - _lastVideoFrameDump >= _fileOutputAdvance ) { writeFrame(); } // check if we've reached a timeout if (_timeout && timer.elapsed() >= _timeout ) { break; } if ( _sleepUS ) gnashSleep(_sleepUS); } boost::uint32_t total_time = timer.elapsed(); std::cout << "TIME=" << total_time << std::endl; std::cout << "FPS_ACTUAL=" << _fileOutputFPS << std::endl; // In this Gui, quit() does not exit, but it is necessary to catch the // last frame for screenshots. quit(); return true; }