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