收到告警之后开始录像,恢复正常超过5s之后,停止录像。正常异常来回切换在5s之内,继续录像。
void WidgetGeneral::warnRecord(qint64 time_data, const XKT_SDKServer_EmotionDataNotify& info) { int int_degree = (int)(info.degree); if (int_degree <= 0) { int_degree = -int_degree; int_degree = 50 - int_degree; } else { int_degree += 50; } if (int_degree > 50) { if (m_firstWarn == 0) { m_firstWarn = time_data; m_bBackToNormal = false; //截图,并且录制视频 streamMediaToFile("", "", time_data); } } if (m_firstWarn != 0) { //出现异常之后,恢复成正常 if (int_degree < 51) { m_bBackToNormal = true; //异常时间超过5秒钟,结束视频录制 if ((time_data- m_firstWarn) >= 5000) { m_bBackToNormal = false; m_firstWarn = 0; this->stopMakeFile(); } } //对长视频进行切分,暂定最长时长为30分钟,超过30分钟就重新录视频 if (int_degree > 50) { if ((time_data - m_firstWarn) >= 1800000) { m_firstWarn = time_data; m_bBackToNormal = false; this->stopMakeFile(); //截图,并且录制视频 streamMediaToFile("", "", time_data); } } } //有正常转变成了异常,跟新m_firstWarn的时间戳 if (m_bBackToNormal && int_degree>50) { m_firstWarn = time_data; } }