From 71cf9852ecc5d77b956d6d3050a7670a46cf3915 Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期四, 16 三月 2023 09:18:27 +0800
Subject: [PATCH] 更新前后端分离部署文档
---
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java | 52 ++++++++++++++++++++++++++++++++++------------------
1 files changed, 34 insertions(+), 18 deletions(-)
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java
index 8817122..fd9e0c6 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java
@@ -5,6 +5,7 @@
import com.genersoft.iot.vmp.conf.UserSetting;
import com.genersoft.iot.vmp.gb28181.bean.*;
import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
+import com.genersoft.iot.vmp.gb28181.session.SsrcConfig;
import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver;
import com.genersoft.iot.vmp.gb28181.transmit.SIPSender;
@@ -45,6 +46,7 @@
import javax.sip.message.Response;
import java.text.ParseException;
import java.time.Instant;
+import java.util.Random;
import java.util.Vector;
/**
@@ -157,11 +159,6 @@
StreamProxyItem proxyByAppAndStream =null;
// 涓嶆槸閫氶亾鍙兘鏄洿鎾祦
if (channel != null && gbStream == null) {
-// if (channel.getStatus() == 0) {
-// logger.info("閫氶亾绂荤嚎锛岃繑鍥�400");
-// responseAck(request, Response.BAD_REQUEST, "channel [" + channel.getChannelId() + "] offline");
-// return;
-// }
// 閫氶亾瀛樺湪锛屽彂100锛孴RYING
try {
responseAck(request, Response.TRYING);
@@ -232,7 +229,7 @@
}
return;
} else {
- logger.info("閫氶亾涓嶅瓨鍦紝杩斿洖404");
+ logger.info("閫氶亾涓嶅瓨鍦紝杩斿洖404: {}", channelId);
try {
// 閫氶亾涓嶅瓨鍦紝鍙�404锛岃祫婧愪笉瀛樺湪
responseAck(request, Response.NOT_FOUND);
@@ -318,7 +315,7 @@
return;
}
String username = sdp.getOrigin().getUsername();
- String addressStr = sdp.getOrigin().getAddress();
+ String addressStr = sdp.getConnection().getAddress();
logger.info("[涓婄骇鐐规挱]鐢ㄦ埛锛歿}锛� 閫氶亾锛歿}, 鍦板潃锛歿}:{}锛� ssrc锛歿}", username, channelId, addressStr, port, ssrc);
Device device = null;
@@ -345,8 +342,7 @@
return;
}
SendRtpItem sendRtpItem = zlmrtpServerFactory.createSendRtpItem(mediaServerItem, addressStr, port, ssrc, requesterId,
- device.getDeviceId(), channelId,
- mediaTransmissionTCP);
+ device.getDeviceId(), channelId, mediaTransmissionTCP, platform.isRtcp());
if (tcpActive != null) {
sendRtpItem.setTcpActive(tcpActive);
@@ -385,7 +381,12 @@
} else {
content.append("t=0 0\r\n");
}
- content.append("m=video " + sendRtpItem.getLocalPort() + " RTP/AVP 96\r\n");
+ int localPort = sendRtpItem.getLocalPort();
+ if (localPort == 0) {
+ // 闈炰弗鏍兼ā寮忕鍙d笉缁熶竴, 澧炲姞鍏煎鎬э紝淇敼涓轰竴涓笉涓�0鐨勭鍙�
+ localPort = new Random().nextInt(65535) + 1;
+ }
+ content.append("m=video " + localPort + " RTP/AVP 96\r\n");
content.append("a=sendonly\r\n");
content.append("a=rtpmap:96 PS/90000\r\n");
content.append("y=" + sendRtpItem.getSsrc() + "\r\n");
@@ -476,6 +477,7 @@
// 鍐欏叆redis锛� 瓒呮椂鏃跺洖澶�
redisCatchStorage.updateSendRTPSever(sendRtpItem);
+ MediaServerItem finalMediaServerItem = mediaServerItem;
playService.play(mediaServerItem, ssrcInfo, device, channelId, hookEvent, errorEvent, (code, msg) -> {
logger.info("[涓婄骇鐐规挱]瓒呮椂, 鐢ㄦ埛锛歿}锛� 閫氶亾锛歿}", username, channelId);
redisCatchStorage.deleteSendRTPServer(platform.getServerGBId(), channelId, callIdHeader.getCallId(), null);
@@ -491,6 +493,15 @@
}
}
} else if (gbStream != null) {
+ if(ssrc.equals(ssrcDefault))
+ {
+ SsrcConfig ssrcConfig = mediaServerItem.getSsrcConfig();
+ if(ssrcConfig != null)
+ {
+ ssrc = ssrcConfig.getPlaySsrc();
+ ssrcConfig.releaseSsrc(ssrc);
+ }
+ }
if("push".equals(gbStream.getStreamType())) {
if (streamPushItem != null && streamPushItem.isPushIng()) {
// 鎺ㄦ祦鐘舵��
@@ -535,8 +546,7 @@
if (streamReady) {
// 鑷钩鍙板唴瀹�
SendRtpItem sendRtpItem = zlmrtpServerFactory.createSendRtpItem(mediaServerItem, addressStr, port, ssrc, requesterId,
- gbStream.getApp(), gbStream.getStream(), channelId,
- mediaTransmissionTCP);
+ gbStream.getApp(), gbStream.getStream(), channelId, mediaTransmissionTCP, platform.isRtcp());
if (sendRtpItem == null) {
logger.warn("鏈嶅姟鍣ㄧ鍙h祫婧愪笉瓒�");
@@ -575,8 +585,7 @@
if (streamReady) {
// 鑷钩鍙板唴瀹�
SendRtpItem sendRtpItem = zlmrtpServerFactory.createSendRtpItem(mediaServerItem, addressStr, port, ssrc, requesterId,
- gbStream.getApp(), gbStream.getStream(), channelId,
- mediaTransmissionTCP);
+ gbStream.getApp(), gbStream.getStream(), channelId, mediaTransmissionTCP, platform.isRtcp());
if (sendRtpItem == null) {
logger.warn("鏈嶅姟鍣ㄧ鍙h祫婧愪笉瓒�");
@@ -656,6 +665,7 @@
if (!platform.isStartOfflinePush()) {
// 骞冲彴璁剧疆涓叧闂簡鎷夎捣绂荤嚎鐨勬帹娴佸垯鐩存帴鍥炲
try {
+ logger.info("[涓婄骇鐐规挱] 澶辫触锛屾帹娴佽澶囨湭鎺ㄦ祦锛宑hannel: {}, app: {}, stream: {}", gbStream.getGbId(), gbStream.getApp(), gbStream.getStream());
responseAck(request, Response.TEMPORARILY_UNAVAILABLE, "channel stream not pushing");
} catch (SipException | InvalidArgumentException | ParseException e) {
logger.error("[鍛戒护鍙戦�佸け璐 invite 閫氶亾鏈帹娴�: {}", e.getMessage());
@@ -692,7 +702,7 @@
dynamicTask.stop(callIdHeader.getCallId());
if (serverId.equals(userSetting.getServerId())) {
SendRtpItem sendRtpItem = zlmrtpServerFactory.createSendRtpItem(mediaServerItem, addressStr, finalPort, ssrc, requesterId,
- app, stream, channelId, mediaTransmissionTCP);
+ app, stream, channelId, mediaTransmissionTCP, platform.isRtcp());
if (sendRtpItem == null) {
logger.warn("涓婄骇鐐规椂鍒涘缓sendRTPItem澶辫触锛屽彲鑳芥槸鏈嶅姟鍣ㄧ鍙h祫婧愪笉瓒�");
@@ -754,7 +764,7 @@
// 鍙戦�乺edis娑堟伅
redisGbPlayMsgListener.sendMsg(streamPushItem.getServerId(), streamPushItem.getMediaServerId(),
streamPushItem.getApp(), streamPushItem.getStream(), addressStr, port, ssrc, requesterId,
- channelId, mediaTransmissionTCP, null, responseSendItemMsg -> {
+ channelId, mediaTransmissionTCP, platform.isRtcp(),null, responseSendItemMsg -> {
SendRtpItem sendRtpItem = responseSendItemMsg.getSendRtpItem();
if (sendRtpItem == null || responseSendItemMsg.getMediaServerItem() == null) {
logger.warn("鏈嶅姟鍣ㄧ鍙h祫婧愪笉瓒�");
@@ -818,7 +828,13 @@
content.append("s=Play\r\n");
content.append("c=IN IP4 " + mediaServerItem.getSdpIp() + "\r\n");
content.append("t=0 0\r\n");
- content.append("m=video " + sendRtpItem.getLocalPort() + " RTP/AVP 96\r\n");
+ // 闈炰弗鏍兼ā寮忕鍙d笉缁熶竴, 澧炲姞鍏煎鎬э紝淇敼涓轰竴涓笉涓�0鐨勭鍙�
+ int localPort = sendRtpItem.getLocalPort();
+ if(localPort == 0)
+ {
+ localPort = new Random().nextInt(65535) + 1;
+ }
+ content.append("m=video " + localPort + " RTP/AVP 96\r\n");
content.append("a=sendonly\r\n");
content.append("a=rtpmap:96 PS/90000\r\n");
if (sendRtpItem.isTcp()) {
@@ -912,7 +928,7 @@
return;
}
String username = sdp.getOrigin().getUsername();
- String addressStr = sdp.getOrigin().getAddress();
+ String addressStr = sdp.getConnection().getAddress();
logger.info("璁惧{}璇锋眰璇煶娴侊紝鍦板潃锛歿}:{}锛宻src锛歿}", username, addressStr, port, ssrc);
} catch (SdpException e) {
logger.error("[SDP瑙f瀽寮傚父]", e);
--
Gitblit v1.8.0