除图片外的其他音频、视频相关样例都增加验证时长的处理逻辑。

Signed-off-by: zhangwei <zhangwei2@iie.ac.cn>
This commit is contained in:
zhangwei
2018-10-17 11:07:44 +08:00
parent e71d14254b
commit aa690069bd

View File

@@ -29,6 +29,7 @@ import com.nis.domain.maat.ToMaatResult;
import com.nis.domain.maat.ToMaatResult.ResponseData;
import com.nis.exceptions.CallExternalProceduresException;
import com.nis.exceptions.MaatConvertException;
import com.nis.exceptions.MultiPartNewException;
import com.nis.util.ConfigServiceUtil;
import com.nis.util.Constants;
import com.nis.util.DictUtils;
@@ -162,10 +163,16 @@ public class AvController extends BaseController {
// entity.setSrcMd5(srcMd5);
// entity.setSampleMd5(sampleMd5);
//验证音视频文件时长
Encoder encoder = new Encoder();
String length = "";
try {
//音频、视频、VoIP、说话人音频、人脸识别视频样例需要验证时长
if(entity.getCfgType().equals(Constants.AV_SAMPLE_AUDIO_REGION)
|| entity.getCfgType().equals(Constants.AV_SAMPLE_VIDEO_REGION)
|| entity.getCfgType().equals(Constants.AV_SAMPLE_VOIP_REGION)
|| entity.getCfgType().equals(Constants.MM_SPEAKER_RECOGNIZATION_REGION)
|| entity.getCfgType().equals(Constants.MM_FACE_RECOGNIZATION_REGION)){
//验证音视频文件时长
Encoder encoder = new Encoder();
String length = "";
MultimediaInfo m = encoder.getInfo(uploadSrcFile);
long ls = m.getDuration()/1000;
int hour = (int) (ls/3600);
@@ -176,13 +183,10 @@ public class AvController extends BaseController {
if(ls>0 && second>Constants.AV_DURATION_LIMIT){
addMessage(redirectAttributes,"exceeds_duration_limit");
logger.error("The duration of uploaded files exceeds the limit("+Constants.AV_DURATION_LIMIT+"s).");
return "redirect:" + adminPath +"/ntc/av/sample/fileSampleList?functionId="+entity.getFunctionId();
throw new MultiPartNewException(this.getMsgProp().getProperty("exceeds_duration_limit"));
}
} catch (Exception e) {
e.printStackTrace();
addMessage(redirectAttributes,"save_failed");
return "redirect:" + adminPath +"/ntc/av/sample/fileSampleList?functionId="+entity.getFunctionId();
}
}
avCfgService.saveOrUpdateAvFileSample(entity, srcFile);
@@ -195,7 +199,7 @@ public class AvController extends BaseController {
if(e instanceof MaatConvertException||e instanceof CallExternalProceduresException) {
addMessage(redirectAttributes,e.getMessage());
}else {
addMessage(redirectAttributes,"save_failed");
addMessage(redirectAttributes,e.getMessage());
}
}