|
@ -442,7 +442,7 @@ public class VideoController extends BaseController { |
|
|
*/ |
|
|
*/ |
|
|
@ApiOperation("获取视频流信息") |
|
|
@ApiOperation("获取视频流信息") |
|
|
@GetMapping(value = "/externalVideoStreaming") |
|
|
@GetMapping(value = "/externalVideoStreaming") |
|
|
public JSONObject externalVideoStreaming(@ApiParam(value = "摄像头标识", name = "camId", required = true) String camId) throws HttpException, IOException { |
|
|
public JSONObject externalVideoStreaming(@ApiParam(value = "摄像头标识", name = "camId", required = true) String camId) { |
|
|
JSONObject cameraInfo = JSONObject.parseObject(configService.selectConfigByKey("dc.cameraInfo")); |
|
|
JSONObject cameraInfo = JSONObject.parseObject(configService.selectConfigByKey("dc.cameraInfo")); |
|
|
|
|
|
|
|
|
JSONObject jsonResult = null; |
|
|
JSONObject jsonResult = null; |
|
@ -453,48 +453,56 @@ public class VideoController extends BaseController { |
|
|
requestParams.put("type", UniversalEnum.ONE.getValue()); |
|
|
requestParams.put("type", UniversalEnum.ONE.getValue()); |
|
|
requestParams.put("camId", camId); |
|
|
requestParams.put("camId", camId); |
|
|
|
|
|
|
|
|
Map<String, String> header = new HashMap<>(); |
|
|
try { |
|
|
|
|
|
Map<String, String> header = new HashMap<>(); |
|
|
if (VideoController.TOKEN == null) { |
|
|
|
|
|
getToken(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
header.put("Authorization", TOKEN); |
|
|
|
|
|
|
|
|
|
|
|
Response response // 请求响应
|
|
|
|
|
|
= okHttp |
|
|
|
|
|
.headers(header) |
|
|
|
|
|
.url(cameraInfo.getString("URL") + UniversalEnum.GET_VIDEO_STREAM_INFORMATION.getValue()) // 请求地址
|
|
|
|
|
|
.data(requestParams) // 请求参数
|
|
|
|
|
|
.post(); // 请求方法
|
|
|
|
|
|
|
|
|
|
|
|
if (response.body() != null) { |
|
|
if (VideoController.TOKEN == null) { |
|
|
jsonResult = JSONObject.parseObject(response.body().string()); |
|
|
getToken(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (jsonResult.containsKey("code")) { |
|
|
header.put("Authorization", TOKEN); |
|
|
if (HttpStatus.SUCCESS == jsonResult.getInteger("code")) { |
|
|
|
|
|
Map<String,Object> data = jsonResult.getJSONObject("data"); |
|
|
Response response // 请求响应
|
|
|
String liveUrl = data.get("liveUrl").toString(); |
|
|
= okHttp |
|
|
liveUrl = configService.selectConfigByKey("dc.cameraUrl") + liveUrl.substring(UniversalEnum.SEVEN.getNumber()); |
|
|
.headers(header) |
|
|
data.put("liveUrl",liveUrl); |
|
|
.url(cameraInfo.getString("URL") + UniversalEnum.GET_VIDEO_STREAM_INFORMATION.getValue()) // 请求地址
|
|
|
jsonResult.put("data",data); |
|
|
.data(requestParams) // 请求参数
|
|
|
} else if (UNAUTHORIZED.equals(jsonResult.getInteger("code"))) { |
|
|
.post(); // 请求方法
|
|
|
getToken(); |
|
|
|
|
|
okHttp.post(); |
|
|
if (response.body() != null) { |
|
|
if (response.body() != null) { |
|
|
jsonResult = JSONObject.parseObject(response.body().string()); |
|
|
jsonResult = JSONObject.parseObject(response.body().string()); |
|
|
|
|
|
if (HttpStatus.SUCCESS == jsonResult.getInteger("code")) { |
|
|
if (jsonResult.containsKey("code")) { |
|
|
Map<String,Object> data = jsonResult.getJSONObject("data"); |
|
|
if (HttpStatus.SUCCESS == jsonResult.getInteger("code")) { |
|
|
String liveUrl = data.get("liveUrl").toString(); |
|
|
Map<String,Object> data = jsonResult.getJSONObject("data"); |
|
|
liveUrl = configService.selectConfigByKey("cameraUrl") + liveUrl.substring(UniversalEnum.SEVEN.getNumber()); |
|
|
String liveUrl = data.get("liveUrl").toString(); |
|
|
data.put("liveUrl",liveUrl); |
|
|
liveUrl = configService.selectConfigByKey("dc.cameraUrl") + liveUrl.substring(UniversalEnum.SEVEN.getNumber()); |
|
|
jsonResult.put("data",data); |
|
|
data.put("liveUrl",liveUrl); |
|
|
|
|
|
jsonResult.put("data",data); |
|
|
|
|
|
} else if (UNAUTHORIZED.equals(jsonResult.getInteger("code"))) { |
|
|
|
|
|
getToken(); |
|
|
|
|
|
okHttp.post(); |
|
|
|
|
|
if (response.body() != null) { |
|
|
|
|
|
jsonResult = JSONObject.parseObject(response.body().string()); |
|
|
|
|
|
if (HttpStatus.SUCCESS == jsonResult.getInteger("code")) { |
|
|
|
|
|
Map<String,Object> data = jsonResult.getJSONObject("data"); |
|
|
|
|
|
String liveUrl = data.get("liveUrl").toString(); |
|
|
|
|
|
liveUrl = configService.selectConfigByKey("cameraUrl") + liveUrl.substring(UniversalEnum.SEVEN.getNumber()); |
|
|
|
|
|
data.put("liveUrl",liveUrl); |
|
|
|
|
|
jsonResult.put("data",data); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
}catch (Exception e) { |
|
|
|
|
|
jsonResult = new JSONObject(); |
|
|
|
|
|
jsonResult.put("code",200); |
|
|
|
|
|
jsonResult.put("data", new JSONObject()); |
|
|
|
|
|
jsonResult.put("msg","摄像机连接失败"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return jsonResult; |
|
|
return jsonResult; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|