Commit f525b5572988326c4b73da9f68e7ee7e292a2e46

Authored by 648540858
1 parent 04e7f48f

修复发流复盖的为问题

src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRTPServerFactory.java
@@ -85,7 +85,10 @@ public class ZLMRTPServerFactory { @@ -85,7 +85,10 @@ public class ZLMRTPServerFactory {
85 }else { 85 }else {
86 param.put("port", port); 86 param.put("port", port);
87 } 87 }
88 - param.put("ssrc", ssrc); 88 + if (ssrc != 0) {
  89 + param.put("ssrc", ssrc);
  90 + }
  91 +
89 JSONObject openRtpServerResultJson = zlmresTfulUtils.openRtpServer(mediaServerItem, param); 92 JSONObject openRtpServerResultJson = zlmresTfulUtils.openRtpServer(mediaServerItem, param);
90 logger.info(JSONObject.toJSONString(openRtpServerResultJson)); 93 logger.info(JSONObject.toJSONString(openRtpServerResultJson));
91 if (openRtpServerResultJson != null) { 94 if (openRtpServerResultJson != null) {
src/main/java/com/genersoft/iot/vmp/vmanager/rtp/RtpController.java
@@ -13,6 +13,7 @@ import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForRtpServerTimeout; @@ -13,6 +13,7 @@ import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForRtpServerTimeout;
13 import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForStreamChange; 13 import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForStreamChange;
14 import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; 14 import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
15 import com.genersoft.iot.vmp.service.IMediaServerService; 15 import com.genersoft.iot.vmp.service.IMediaServerService;
  16 +import com.genersoft.iot.vmp.utils.redis.RedisUtil;
16 import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; 17 import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
17 import com.genersoft.iot.vmp.vmanager.bean.OtherRtpSendInfo; 18 import com.genersoft.iot.vmp.vmanager.bean.OtherRtpSendInfo;
18 import io.swagger.v3.oas.annotations.Operation; 19 import io.swagger.v3.oas.annotations.Operation;
@@ -29,6 +30,7 @@ import org.springframework.web.bind.annotation.*; @@ -29,6 +30,7 @@ import org.springframework.web.bind.annotation.*;
29 30
30 import java.io.IOException; 31 import java.io.IOException;
31 import java.util.HashMap; 32 import java.util.HashMap;
  33 +import java.util.List;
32 import java.util.Map; 34 import java.util.Map;
33 import java.util.UUID; 35 import java.util.UUID;
34 import java.util.concurrent.TimeUnit; 36 import java.util.concurrent.TimeUnit;
@@ -98,6 +100,7 @@ public class RtpController { @@ -98,6 +100,7 @@ public class RtpController {
98 } 100 }
99 101
100 } 102 }
  103 + String receiveKey = VideoManagerConstants.WVP_OTHER_RECEIVE_RTP_INFO + userSetting.getServerId() + "_" + callId + "_" + stream;
101 int localPort = zlmServerFactory.createRTPServer(mediaServerItem, stream, ssrcInt, null, false, tcpMode); 104 int localPort = zlmServerFactory.createRTPServer(mediaServerItem, stream, ssrcInt, null, false, tcpMode);
102 // 注册回调如果rtp收流超时则通过回调发送通知 105 // 注册回调如果rtp收流超时则通过回调发送通知
103 if (callBack != null) { 106 if (callBack != null) {
@@ -107,6 +110,8 @@ public class RtpController { @@ -107,6 +110,8 @@ public class RtpController {
107 (mediaServerItemInUse, response)->{ 110 (mediaServerItemInUse, response)->{
108 if (stream.equals(response.getString("stream_id"))) { 111 if (stream.equals(response.getString("stream_id"))) {
109 logger.info("[第三方服务对接->开启收流和获取发流信息] 等待收流超时 callId->{}, 发送回调", callId); 112 logger.info("[第三方服务对接->开启收流和获取发流信息] 等待收流超时 callId->{}, 发送回调", callId);
  113 + // 将信息写入redis中,以备后用
  114 + redisTemplate.delete(receiveKey);
110 OkHttpClient.Builder httpClientBuilder = new OkHttpClient.Builder(); 115 OkHttpClient.Builder httpClientBuilder = new OkHttpClient.Builder();
111 OkHttpClient client = httpClientBuilder.build(); 116 OkHttpClient client = httpClientBuilder.build();
112 String url = callBack + "?callId=" + callId; 117 String url = callBack + "?callId=" + callId;
@@ -124,7 +129,7 @@ public class RtpController { @@ -124,7 +129,7 @@ public class RtpController {
124 otherRtpSendInfo.setReceivePort(localPort); 129 otherRtpSendInfo.setReceivePort(localPort);
125 otherRtpSendInfo.setCallId(callId); 130 otherRtpSendInfo.setCallId(callId);
126 otherRtpSendInfo.setStream(stream); 131 otherRtpSendInfo.setStream(stream);
127 - String receiveKey = VideoManagerConstants.WVP_OTHER_RECEIVE_RTP_INFO + userSetting.getServerId() + "_" + stream; 132 +
128 // 将信息写入redis中,以备后用 133 // 将信息写入redis中,以备后用
129 redisTemplate.opsForValue().set(receiveKey, otherRtpSendInfo); 134 redisTemplate.opsForValue().set(receiveKey, otherRtpSendInfo);
130 if (isSend != null && isSend) { 135 if (isSend != null && isSend) {
@@ -148,9 +153,14 @@ public class RtpController { @@ -148,9 +153,14 @@ public class RtpController {
148 logger.info("[第三方服务对接->关闭收流] stream->{}", stream); 153 logger.info("[第三方服务对接->关闭收流] stream->{}", stream);
149 MediaServerItem mediaServerItem = mediaServerService.getDefaultMediaServer(); 154 MediaServerItem mediaServerItem = mediaServerService.getDefaultMediaServer();
150 zlmServerFactory.closeRtpServer(mediaServerItem,stream); 155 zlmServerFactory.closeRtpServer(mediaServerItem,stream);
151 - String receiveKey = VideoManagerConstants.WVP_OTHER_RECEIVE_RTP_INFO + userSetting.getServerId() + "_" + stream;  
152 - // 将信息写入redis中,以备后用  
153 - redisTemplate.delete(receiveKey); 156 + String receiveKey = VideoManagerConstants.WVP_OTHER_RECEIVE_RTP_INFO + userSetting.getServerId() + "_*_" + stream;
  157 + List<Object> scan = RedisUtil.scan(redisTemplate, receiveKey);
  158 + if (scan.size() > 0) {
  159 + for (Object key : scan) {
  160 + // 将信息写入redis中,以备后用
  161 + redisTemplate.delete(key);
  162 + }
  163 + }
154 } 164 }
155 165
156 @GetMapping(value = "/send/start") 166 @GetMapping(value = "/send/start")
@@ -224,7 +234,7 @@ public class RtpController { @@ -224,7 +234,7 @@ public class RtpController {
224 hookSubscribe.addSubscribe(hookSubscribeForStreamChange, 234 hookSubscribe.addSubscribe(hookSubscribeForStreamChange,
225 (mediaServerItemInUse, response)->{ 235 (mediaServerItemInUse, response)->{
226 dynamicTask.stop(uuid); 236 dynamicTask.stop(uuid);
227 - logger.info("[第三方服务对接->发送流] 流上线,开始发流 callId->{}", callId); 237 + logger.info("[第三方服务对接->发送流] 流上线,开始发流 callId->{},param->{}", callId, JSONObject.toJSONString(param));
228 JSONObject jsonObject = zlmServerFactory.startSendRtpStream(mediaServerItem, param); 238 JSONObject jsonObject = zlmServerFactory.startSendRtpStream(mediaServerItem, param);
229 System.out.println("========发流结果=========="); 239 System.out.println("========发流结果==========");
230 System.out.println(jsonObject); 240 System.out.println(jsonObject);