From bb49f1f0d622e2a4380a80eff93f779409b36b30 Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期五, 10 二月 2023 15:33:00 +0800
Subject: [PATCH] 添加文档
---
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java | 75 +++++++++++++++++++++++++------------
1 files changed, 50 insertions(+), 25 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 8a1e486..c9b979f 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
@@ -1,6 +1,7 @@
package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl;
import com.alibaba.fastjson2.JSONObject;
+import com.genersoft.iot.vmp.common.VideoManagerConstants;
import com.genersoft.iot.vmp.conf.DynamicTask;
import com.genersoft.iot.vmp.conf.SipConfig;
import com.genersoft.iot.vmp.conf.UserSetting;
@@ -386,8 +387,7 @@
return;
}
SendRtpItem sendRtpItem = zlmrtpServerFactory.createSendRtpItem(mediaServerItem, addressStr, port, ssrc, requesterId,
- device.getDeviceId(), channelId,
- mediaTransmissionTCP, platform.isRtcp());
+ device.getDeviceId(), channelId, mediaTransmissionTCP, platform.isRtcp());
if (tcpActive != null) {
sendRtpItem.setTcpActive(tcpActive);
@@ -440,18 +440,23 @@
try {
// 瓒呮椂鏈敹鍒癆ck搴旇鍥炲bye,褰撳墠绛夊緟鏃堕棿涓�10绉�
- dynamicTask.startDelay(callIdHeader.getCallId(), () -> {
- logger.info("Ack 绛夊緟瓒呮椂");
- mediaServerService.releaseSsrc(mediaServerItemInUSe.getId(), sendRtpItem.getSsrc());
- // 鍥炲bye
- try {
- cmderFroPlatform.streamByeCmd(platform, callIdHeader.getCallId());
- } catch (SipException | InvalidArgumentException | ParseException e) {
- logger.error("[鍛戒护鍙戦�佸け璐 鍥芥爣绾ц仈 鍙戦�丅YE: {}", e.getMessage());
- }
- }, 60 * 1000);
- responseSdpAck(request, content.toString(), platform);
+ if (userSetting.getPushStreamAfterAck()) {
+ dynamicTask.startDelay(callIdHeader.getCallId(), () -> {
+ logger.info("Ack 绛夊緟瓒呮椂");
+ mediaServerService.releaseSsrc(mediaServerItemInUSe.getId(), sendRtpItem.getSsrc());
+ // 鍥炲bye
+ try {
+ cmderFroPlatform.streamByeCmd(platform, callIdHeader.getCallId());
+ } catch (SipException | InvalidArgumentException | ParseException e) {
+ logger.error("[鍛戒护鍙戦�佸け璐 鍥芥爣绾ц仈 鍙戦�丅YE: {}", e.getMessage());
+ }
+ }, 60 * 1000);
+ }
+ SIPResponse sipResponse = responseSdpAck(request, content.toString(), platform);
+ if (!userSetting.getPushStreamAfterAck()) {
+ playService.startPushStream(sendRtpItem, sipResponse, platform, request.getCallIdHeader());
+ }
} catch (SipException e) {
e.printStackTrace();
} catch (InvalidArgumentException e) {
@@ -582,8 +587,7 @@
if (streamReady) {
// 鑷钩鍙板唴瀹�
SendRtpItem sendRtpItem = zlmrtpServerFactory.createSendRtpItem(mediaServerItem, addressStr, port, ssrc, requesterId,
- gbStream.getApp(), gbStream.getStream(), channelId,
- mediaTransmissionTCP, platform.isRtcp());
+ gbStream.getApp(), gbStream.getStream(), channelId, mediaTransmissionTCP, platform.isRtcp());
if (sendRtpItem == null) {
logger.warn("鏈嶅姟鍣ㄧ鍙h祫婧愪笉瓒�");
@@ -622,8 +626,7 @@
if (streamReady) {
// 鑷钩鍙板唴瀹�
SendRtpItem sendRtpItem = zlmrtpServerFactory.createSendRtpItem(mediaServerItem, addressStr, port, ssrc, requesterId,
- gbStream.getApp(), gbStream.getStream(), channelId,
- mediaTransmissionTCP, platform.isRtcp());
+ gbStream.getApp(), gbStream.getStream(), channelId, mediaTransmissionTCP, platform.isRtcp());
if (sendRtpItem == null) {
logger.warn("鏈嶅姟鍣ㄧ鍙h祫婧愪笉瓒�");
@@ -802,7 +805,7 @@
// 鍙戦�乺edis娑堟伅
redisGbPlayMsgListener.sendMsg(streamPushItem.getServerId(), streamPushItem.getMediaServerId(),
streamPushItem.getApp(), streamPushItem.getStream(), addressStr, port, ssrc, requesterId,
- channelId, mediaTransmissionTCP, platform.isRtcp(), null, responseSendItemMsg -> {
+ channelId, mediaTransmissionTCP, platform.isRtcp(),null, responseSendItemMsg -> {
SendRtpItem sendRtpItem = responseSendItemMsg.getSendRtpItem();
if (sendRtpItem == null || responseSendItemMsg.getMediaServerItem() == null) {
logger.warn("鏈嶅姟鍣ㄧ鍙h祫婧愪笉瓒�");
@@ -881,7 +884,11 @@
content.append("f=\r\n");
try {
- return responseSdpAck(request, content.toString(), platform);
+ SIPResponse sipResponse = responseSdpAck(request, content.toString(), platform);
+ if (!userSetting.getPushStreamAfterAck()) {
+ playService.startPushStream(sendRtpItem, sipResponse, platform, request.getCallIdHeader());
+ }
+ return sipResponse;
} catch (SipException e) {
e.printStackTrace();
} catch (InvalidArgumentException e) {
@@ -908,11 +915,14 @@
}
if (device != null) {
logger.info("鏀跺埌璁惧" + requesterId + "鐨勮闊冲箍鎾璉nvite璇锋眰");
-
+ String key = VideoManagerConstants.BROADCAST_WAITE_INVITE + device.getDeviceId() + audioBroadcastCatch.getChannelId();
+ dynamicTask.stop(key);
try {
responseAck(request, Response.TRYING);
} catch (SipException | InvalidArgumentException | ParseException e) {
logger.error("[鍛戒护鍙戦�佸け璐 invite BAD_REQUEST: {}", e.getMessage());
+ playService.stopAudioBroadcast(device.getDeviceId(), audioBroadcastCatch.getChannelId());
+ return;
}
String contentString = new String(request.getRawContent());
// jainSip涓嶆敮鎸亂=瀛楁锛� 绉婚櫎绉婚櫎浠ヨВ鏋愩��
@@ -967,11 +977,14 @@
responseAck(request, Response.UNSUPPORTED_MEDIA_TYPE); // 涓嶆敮鎸佺殑鏍煎紡锛屽彂415
} catch (SipException | InvalidArgumentException | ParseException e) {
logger.error("[鍛戒护鍙戦�佸け璐 invite 涓嶆敮鎸佺殑濯掍綋鏍煎紡: {}", e.getMessage());
+ playService.stopAudioBroadcast(device.getDeviceId(), audioBroadcastCatch.getChannelId());
+ return;
}
return;
}
String addressStr = sdp.getOrigin().getAddress();
- logger.info("璁惧{}璇锋眰璇煶娴侊紝鍦板潃锛歿}:{}锛宻src锛歿}", requesterId, addressStr, port, ssrc);
+ logger.info("璁惧{}璇锋眰璇煶娴侊紝鍦板潃锛歿}:{}锛宻src锛歿}, {}", requesterId, addressStr, port, ssrc,
+ mediaTransmissionTCP ? (tcpActive? "TCP涓诲姩":"TCP琚姩") : "UDP");
MediaServerItem mediaServerItem = playService.getNewMediaServerItem(device);
if (mediaServerItem == null) {
@@ -980,6 +993,7 @@
responseAck(request, Response.BUSY_HERE);
} catch (SipException | InvalidArgumentException | ParseException e) {
logger.error("[鍛戒护鍙戦�佸け璐 invite 鏈壘鍒板彲鐢ㄧ殑zlm: {}", e.getMessage());
+ playService.stopAudioBroadcast(device.getDeviceId(), audioBroadcastCatch.getChannelId());
}
return;
}
@@ -993,13 +1007,12 @@
responseAck(request, Response.BUSY_HERE);
} catch (SipException | InvalidArgumentException | ParseException e) {
logger.error("[鍛戒护鍙戦�佸け璐 invite 鏈嶅姟鍣ㄧ鍙h祫婧愪笉瓒�: {}", e.getMessage());
+ playService.stopAudioBroadcast(device.getDeviceId(), audioBroadcastCatch.getChannelId());
+ return;
}
return;
}
- sendRtpItem.setTcp(mediaTransmissionTCP);
- if (tcpActive != null) {
- sendRtpItem.setTcpActive(tcpActive);
- }
+
String app = "broadcast";
String stream = device.getDeviceId() + "_" + audioBroadcastCatch.getChannelId();
@@ -1014,6 +1027,11 @@
sendRtpItem.setUsePs(false);
sendRtpItem.setRtcp(false);
sendRtpItem.setOnlyAudio(true);
+ sendRtpItem.setTcp(mediaTransmissionTCP);
+ if (tcpActive != null) {
+ sendRtpItem.setTcpActive(tcpActive);
+ }
+
redisCatchStorage.updateSendRTPSever(sendRtpItem);
Boolean streamReady = zlmrtpServerFactory.isStreamReady(mediaServerItem, app, stream);
@@ -1025,11 +1043,13 @@
responseAck(request, Response.GONE);
} catch (SipException | InvalidArgumentException | ParseException e) {
logger.error("[鍛戒护鍙戦�佸け璐 璇煶閫氳瘽 鍥炲410澶辫触锛� {}", e.getMessage());
+ return;
}
playService.stopAudioBroadcast(device.getDeviceId(), audioBroadcastCatch.getChannelId());
}
} catch (SdpException e) {
logger.error("[SDP瑙f瀽寮傚父]", e);
+ playService.stopAudioBroadcast(device.getDeviceId(), audioBroadcastCatch.getChannelId());
}
} else {
logger.warn("鏉ヨ嚜鏃犳晥璁惧/骞冲彴鐨勮姹�");
@@ -1086,6 +1106,11 @@
audioBroadcastCatch.setSipTransactionInfoByRequset(sipResponse);
audioBroadcastManager.update(audioBroadcastCatch);
+ // 寮�鍚彂娴侊紝澶у崕鍦ㄦ敹鍒�200OK鍚庡氨浼氬紑濮嬪缓绔嬭繛鎺�
+ if (!userSetting.getPushStreamAfterAck()) {
+ playService.startPushStream(sendRtpItem, sipResponse, parentPlatform, request.getCallIdHeader());
+ }
+
} catch (SipException | InvalidArgumentException | ParseException | SdpParseException e) {
logger.error("[鍛戒护鍙戦�佸け璐 璇煶瀵硅 鍥炲200OK锛圫DP锛�: {}", e.getMessage());
}
--
Gitblit v1.8.0