Commit 3951a95284fb60ce9f625dcd17689d38ec7852dc

Authored by 648540858
2 parents 985082d3 23ce5526

Merge branch '2.6.8' into wvp-28181-2.0

# Conflicts:
#	src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java
@@ -479,55 +479,47 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements @@ -479,55 +479,47 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
479 errorEvent.run(code, msg, data); 479 errorEvent.run(code, msg, data);
480 } 480 }
481 }); 481 });
482 - }else if ("Download".equalsIgnoreCase(sessionName)) {  
483 - // 获取指定的下载速度  
484 - Vector sdpMediaDescriptions = sdp.getMediaDescriptions(true);  
485 - MediaDescription mediaDescription = null;  
486 - String downloadSpeed = "1";  
487 - if (sdpMediaDescriptions.size() > 0) {  
488 - mediaDescription = (MediaDescription)sdpMediaDescriptions.get(0);  
489 - }  
490 - if (mediaDescription != null) {  
491 - downloadSpeed = mediaDescription.getAttribute("downloadspeed"); 482 + } else {
  483 + sendRtpItem.setPlayType(InviteStreamType.PLAY);
  484 + sendRtpItem.setPlayType(InviteStreamType.PLAY);
  485 +// SsrcTransaction playTransaction = sessionManager.getSsrcTransaction(device.getDeviceId(), channelId, "play", null);
  486 + StreamInfo streamInfo = redisCatchStorage.queryPlayByDevice(device.getDeviceId(), channelId);
  487 + if (streamInfo != null) {
  488 + Boolean streamReady = zlmServerFactory.isStreamReady(mediaServerItem, streamInfo.getApp(), streamInfo.getStream());
  489 + if (!streamReady) {
  490 + redisCatchStorage.stopPlay(streamInfo);
  491 + storager.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId());
  492 + streamInfo = null;
  493 + }
492 } 494 }
493 -  
494 - sendRtpItem.setPlayType(InviteStreamType.DOWNLOAD);  
495 - SSRCInfo ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, null, null, device.isSsrcCheck(), true, 0, false, device.getStreamModeForParam());  
496 - sendRtpItem.setStreamId(ssrcInfo.getStream());  
497 - // 写入redis, 超时时回复  
498 - redisCatchStorage.updateSendRTPSever(sendRtpItem);  
499 - playService.download(mediaServerItem, ssrcInfo, device.getDeviceId(), channelId, DateUtil.formatter.format(start),  
500 - DateUtil.formatter.format(end), Integer.parseInt(downloadSpeed),  
501 - (code, msg, data) -> {  
502 - if (code == InviteErrorCode.SUCCESS.getCode()){  
503 - hookEvent.run(code, msg, data);  
504 - }else if (code == InviteErrorCode.ERROR_FOR_SIGNALLING_TIMEOUT.getCode() || code == InviteErrorCode.ERROR_FOR_STREAM_TIMEOUT.getCode()){  
505 - logger.info("[录像下载]超时, 用户:{}, 通道:{}", username, channelId);  
506 - redisCatchStorage.deleteSendRTPServer(platform.getServerGBId(), channelId, callIdHeader.getCallId(), null);  
507 - errorEvent.run(code, msg, data);  
508 - }else {  
509 - errorEvent.run(code, msg, data);  
510 - }  
511 - });  
512 - }else {  
513 -  
514 - SSRCInfo ssrcInfo = playService.play(mediaServerItem, device.getDeviceId(), channelId, ssrc, ((code, msg, data) -> {  
515 - if (code == InviteErrorCode.SUCCESS.getCode()){  
516 - hookEvent.run(code, msg, data);  
517 - }else if (code == InviteErrorCode.ERROR_FOR_SIGNALLING_TIMEOUT.getCode() || code == InviteErrorCode.ERROR_FOR_STREAM_TIMEOUT.getCode()){ 495 + if (streamInfo == null) {
  496 + String streamId = null;
  497 + if (mediaServerItem.isRtpEnable()) {
  498 + streamId = String.format("%s_%s", device.getDeviceId(), channelId);
  499 + }
  500 + SSRCInfo ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, streamId, null, device.isSsrcCheck(), false, 0, false, device.getStreamModeForParam());
  501 + logger.info(JSONObject.toJSONString(ssrcInfo));
  502 + sendRtpItem.setStreamId(ssrcInfo.getStream());
  503 + sendRtpItem.setSsrc(ssrc);
  504 +
  505 + // 写入redis, 超时时回复
  506 + redisCatchStorage.updateSendRTPSever(sendRtpItem);
  507 + MediaServerItem finalMediaServerItem = mediaServerItem;
  508 + playService.play(mediaServerItem, ssrcInfo, device, channelId, hookEvent, errorEvent, (code, msg) -> {
518 logger.info("[上级点播]超时, 用户:{}, 通道:{}", username, channelId); 509 logger.info("[上级点播]超时, 用户:{}, 通道:{}", username, channelId);
519 redisCatchStorage.deleteSendRTPServer(platform.getServerGBId(), channelId, callIdHeader.getCallId(), null); 510 redisCatchStorage.deleteSendRTPServer(platform.getServerGBId(), channelId, callIdHeader.getCallId(), null);
520 - errorEvent.run(code, msg, data);  
521 - }else {  
522 - errorEvent.run(code, msg, data);  
523 - }  
524 - }));  
525 - sendRtpItem.setPlayType(InviteStreamType.PLAY);  
526 - String streamId = String.format("%s_%s", device.getDeviceId(), channelId);  
527 - sendRtpItem.setStreamId(streamId);  
528 - sendRtpItem.setSsrc(ssrcInfo.getSsrc());  
529 - redisCatchStorage.updateSendRTPSever(sendRtpItem);  
530 - 511 + });
  512 + } else {
  513 + // 当前系统作为下级平台使用,当上级平台点播时不携带ssrc时,并且设备在当前系统中已经点播了。这个时候需要重新给生成一个ssrc,不使用默认的"0000000000"。
  514 + sendRtpItem.setSsrc(ssrc);
  515 + sendRtpItem.setStreamId(playTransaction.getStream());
  516 + // 写入redis, 超时时回复
  517 + redisCatchStorage.updateSendRTPSever(sendRtpItem);
  518 + JSONObject jsonObject = new JSONObject();
  519 + jsonObject.put("app", sendRtpItem.getApp());
  520 + jsonObject.put("stream", sendRtpItem.getStreamId());
  521 + hookEvent.response(mediaServerItem, jsonObject);
  522 + }
531 } 523 }
532 } else if (gbStream != null) { 524 } else if (gbStream != null) {
533 525
src/main/java/com/genersoft/iot/vmp/vmanager/ps/PsController.java
@@ -223,8 +223,6 @@ public class PsController { @@ -223,8 +223,6 @@ public class PsController {
223 String is_Udp = isUdp ? "1" : "0"; 223 String is_Udp = isUdp ? "1" : "0";
224 param.put("is_udp", is_Udp); 224 param.put("is_udp", is_Udp);
225 param.put("src_port", sendInfo.getSendLocalPort()); 225 param.put("src_port", sendInfo.getSendLocalPort());
226 - param.put("use_ps", "0");  
227 - param.put("only_audio", "1");  
228 226
229 227
230 Boolean streamReady = zlmServerFactory.isStreamReady(mediaServerItem, app, stream); 228 Boolean streamReady = zlmServerFactory.isStreamReady(mediaServerItem, app, stream);
src/main/java/com/genersoft/iot/vmp/vmanager/rtp/RtpController.java
@@ -247,7 +247,6 @@ public class RtpController { @@ -247,7 +247,6 @@ public class RtpController {
247 String is_Udp = isUdp ? "1" : "0"; 247 String is_Udp = isUdp ? "1" : "0";
248 paramForAudio.put("is_udp", is_Udp); 248 paramForAudio.put("is_udp", is_Udp);
249 paramForAudio.put("src_port", sendInfo.getSendLocalPortForAudio()); 249 paramForAudio.put("src_port", sendInfo.getSendLocalPortForAudio());
250 - paramForAudio.put("use_ps", "0");  
251 paramForAudio.put("only_audio", "1"); 250 paramForAudio.put("only_audio", "1");
252 if (ptForAudio != null) { 251 if (ptForAudio != null) {
253 paramForAudio.put("pt", ptForAudio); 252 paramForAudio.put("pt", ptForAudio);
@@ -268,7 +267,6 @@ public class RtpController { @@ -268,7 +267,6 @@ public class RtpController {
268 String is_Udp = isUdp ? "1" : "0"; 267 String is_Udp = isUdp ? "1" : "0";
269 paramForVideo.put("is_udp", is_Udp); 268 paramForVideo.put("is_udp", is_Udp);
270 paramForVideo.put("src_port", sendInfo.getSendLocalPortForVideo()); 269 paramForVideo.put("src_port", sendInfo.getSendLocalPortForVideo());
271 - paramForVideo.put("use_ps", "0");  
272 paramForVideo.put("only_audio", "0"); 270 paramForVideo.put("only_audio", "0");
273 if (ptForVideo != null) { 271 if (ptForVideo != null) {
274 paramForVideo.put("pt", ptForVideo); 272 paramForVideo.put("pt", ptForVideo);