22 lines
723 B
C++
22 lines
723 B
C++
#include "fgc/CameraStall.h"
|
|
|
|
#include <algorithm>
|
|
|
|
namespace fgc {
|
|
|
|
long long firstFrameLimitMs(double exposure_us) {
|
|
const long long exposure_ms = exposure_us > 0 ? static_cast<long long>(exposure_us / 1000) : 0;
|
|
return std::max<long long>(30000, 3 * exposure_ms + 5000);
|
|
}
|
|
|
|
StallAction onNoFirstFrame(long long waited_ms, double exposure_us, int failed_restarts) {
|
|
if (waited_ms < firstFrameLimitMs(exposure_us)) return StallAction::Wait;
|
|
return failed_restarts >= kRestartsBeforeReset ? StallAction::Reset : StallAction::Restart;
|
|
}
|
|
|
|
StallAction onRestartFailed(int failed_restarts) {
|
|
return failed_restarts >= kRestartsBeforeReset ? StallAction::Reset : StallAction::Restart;
|
|
}
|
|
|
|
} // namespace fgc
|