|
|
@ -53,6 +53,9 @@ public class SampleEngineRecordServiceImpl implements ISampleEngineRecordService |
|
|
|
@Autowired |
|
|
|
private XingluoApiConfig xingluoApiConfig; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private IDeviceService deviceService; |
|
|
|
|
|
|
|
@DubboReference |
|
|
|
private RemoteConfigService remoteConfigService; |
|
|
|
|
|
|
@ -81,7 +84,7 @@ public class SampleEngineRecordServiceImpl implements ISampleEngineRecordService |
|
|
|
//{"code":200,"message":"操作成功","data":[{"scene":"可见光","id":2}]}
|
|
|
|
sceneResponseBody = GetRequest(uri, token); |
|
|
|
} catch (URISyntaxException e) { |
|
|
|
throw new RuntimeException(e); |
|
|
|
log.error("星逻算法-场景查询异常",e); |
|
|
|
} |
|
|
|
JSONObject jsonObject1 = new JSONObject(sceneResponseBody); |
|
|
|
// 逐层获取 data -> token
|
|
|
@ -107,7 +110,7 @@ public class SampleEngineRecordServiceImpl implements ISampleEngineRecordService |
|
|
|
break; |
|
|
|
} |
|
|
|
} catch (URISyntaxException | JsonProcessingException e) { |
|
|
|
throw new RuntimeException(e); |
|
|
|
log.error("星逻算法-算法列表查询失败",e); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -133,8 +136,16 @@ public class SampleEngineRecordServiceImpl implements ISampleEngineRecordService |
|
|
|
String taskId = ""; |
|
|
|
String missionBatch = ""; |
|
|
|
String deviceSn = MapUtil.getStr(objectMap, "deviceSn", ""); |
|
|
|
//获取rtmpUrl
|
|
|
|
String rtmpUrl = ""; |
|
|
|
DeviceDTO deviceDTO = deviceService.getDeviceBySn(deviceSn).orElse(null); |
|
|
|
if (deviceDTO != null) { |
|
|
|
String childDeviceRtmpUrl = deviceService.getChildDeviceStreamUrlByDeviceSn(deviceDTO.getChildDeviceSn()); |
|
|
|
rtmpUrl = childDeviceRtmpUrl; |
|
|
|
} |
|
|
|
|
|
|
|
//查询用户开通的场景
|
|
|
|
Object rtmpUrlParam = objectMap.get("rtmpUrl"); |
|
|
|
if (StringUtils.isNotEmpty(token)){ |
|
|
|
JSONObject jsonObj2 = new JSONObject(); |
|
|
|
String type = objectMap.get("type").toString(); |
|
|
@ -144,8 +155,8 @@ public class SampleEngineRecordServiceImpl implements ISampleEngineRecordService |
|
|
|
jsonObj2.put("callback_url", xingluoApiConfig.getEngineCallbackUrl());//"http://121.237.178.63:11100/sample/manage/api/v1/saEngineRecord/some"
|
|
|
|
jsonObj2.put("extra_type_list",new JSONArray(list)); |
|
|
|
// jsonObj2.put("input_url","http://"+ip+":19008/live/livesteam/"+objectMap.get("rtmpUrl")+".flv");
|
|
|
|
jsonObj2.put("input_url", "rtmp://"+ip+"/live/livesteam/"+objectMap.get("rtmpUrl"));//预览接口必须要传rtmp,不能是flv
|
|
|
|
String pushUrl = "rtmp://" + ip + "/live/livesteam/" + objectMap.get("rtmpUrl") + "ai1"; |
|
|
|
jsonObj2.put("input_url", "rtmp://"+ip+"/live/livesteam/"+ rtmpUrl);//预览接口必须要传rtmp,不能是flv
|
|
|
|
String pushUrl = "rtmp://" + ip + "/live/livesteam/" + rtmpUrl + "ai1"; |
|
|
|
jsonObj2.put("push_url", pushUrl); //推流接口有时候不稳定,需要检查SRS服务
|
|
|
|
// jsonObj2.put("play_url", objectMap.get("play_url")); //play_url不必传, play和push是一对, play 其实是冗余的, 方便记录更详细的日志
|
|
|
|
/** |
|
|
@ -160,10 +171,10 @@ public class SampleEngineRecordServiceImpl implements ISampleEngineRecordService |
|
|
|
try { |
|
|
|
response = mapper1.readValue(responseBody2, EngineResponse.class); |
|
|
|
if (response.getCode() != 200){ |
|
|
|
throw new RuntimeException("第三方接口调用失败!"); |
|
|
|
log.error("第三方接口调用失败!"); |
|
|
|
} |
|
|
|
} catch (JsonProcessingException e) { |
|
|
|
throw new RuntimeException(e); |
|
|
|
log.error("星逻算法-引擎启动失败",e); |
|
|
|
} |
|
|
|
taskId = response.getData().getTask_id(); |
|
|
|
missionBatch = response.getData().getMission_batch(); |
|
|
@ -171,7 +182,7 @@ public class SampleEngineRecordServiceImpl implements ISampleEngineRecordService |
|
|
|
objectMap.put("task_id",response.getData().getTask_id()); |
|
|
|
record.setDeviceSn(deviceSn); |
|
|
|
record.setExtraType(objectMap.get("type").toString()); |
|
|
|
record.setPushUrl(objectMap.get("rtmpUrl").toString()); |
|
|
|
record.setPushUrl(rtmpUrl.toString()); |
|
|
|
record.setTaskId(taskId); //MapUtil.getStr(objectMap,"task_id","")
|
|
|
|
record .setMissionBatch(missionBatch); |
|
|
|
record.setPushUrl(pushUrl); |
|
|
@ -183,7 +194,7 @@ public class SampleEngineRecordServiceImpl implements ISampleEngineRecordService |
|
|
|
engineRecordMapper.insert(record); |
|
|
|
|
|
|
|
Map<String, Object> map = new HashMap(); |
|
|
|
map.put("push_url", "http://"+ip+":1985/rtc/v1/whep/?app=live/livesteam&stream="+objectMap.get("rtmpUrl")+"ai1"); |
|
|
|
map.put("push_url", "http://"+ip+":1985/rtc/v1/whep/?app=live/livesteam&stream="+ rtmpUrl +"ai1"); |
|
|
|
map.put("task_id", taskId);//objectMap.get("task_id")
|
|
|
|
|
|
|
|
//添加任务id和jobid关联关系
|
|
|
@ -280,7 +291,7 @@ public class SampleEngineRecordServiceImpl implements ISampleEngineRecordService |
|
|
|
if (response.getStatusLine().getStatusCode() == 200) { |
|
|
|
return responseBody; |
|
|
|
} else { |
|
|
|
throw new RuntimeException("第三方接口调用失败!"); |
|
|
|
log.error("第三方接口调用失败!"); |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
@ -307,7 +318,8 @@ public class SampleEngineRecordServiceImpl implements ISampleEngineRecordService |
|
|
|
if (response.getStatusLine().getStatusCode() == 200){ |
|
|
|
return responseBody; |
|
|
|
}else { |
|
|
|
throw new RuntimeException("第三方接口调用失败!"); |
|
|
|
log.error("星逻算法-第三方接口调用失败"); |
|
|
|
// throw new RuntimeException("第三方接口调用失败!");
|
|
|
|
} |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|