From e48fa711a3664bece9b3e58840a75fe7c05bc47c Mon Sep 17 00:00:00 2001
From: panlinlin <648540858@qq.com>
Date: 星期六, 08 五月 2021 17:14:05 +0800
Subject: [PATCH] 添加截图(快照)功能

---
 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/InviteRequestProcessor.java |   64 +++++++++++++++++---------------
 1 files changed, 34 insertions(+), 30 deletions(-)

diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/InviteRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/InviteRequestProcessor.java
index 43be89d..a6f0ae7 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/InviteRequestProcessor.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/InviteRequestProcessor.java
@@ -11,7 +11,7 @@
 import javax.sip.message.Request;
 import javax.sip.message.Response;
 
-import com.genersoft.iot.vmp.conf.MediaServerConfig;
+import com.genersoft.iot.vmp.media.zlm.ZLMServerConfig;
 import com.genersoft.iot.vmp.gb28181.bean.*;
 import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
 import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform;
@@ -92,10 +92,18 @@
 				DeviceChannel channel = storager.queryChannelInParentPlatform(requesterId, channelId);
 				GbStream gbStream = storager.queryStreamInParentPlatform(requesterId, channelId);
 				// 涓嶆槸閫氶亾鍙兘鏄洿鎾祦
-				if (channel != null || gbStream != null ) {
+				if (channel != null && gbStream == null ) {
 					if (channel.getStatus() == 0) {
 						logger.info("閫氶亾绂荤嚎锛岃繑鍥�400");
 						responseAck(evt, Response.BAD_REQUEST, "channel [" + channel.getChannelId() + "] offline");
+						return;
+					}
+					responseAck(evt, Response.CALL_IS_BEING_FORWARDED); // 閫氶亾瀛樺湪锛屽彂181锛屽懠鍙浆鎺ヤ腑
+				}else if(channel == null && gbStream != null){
+					Boolean streamReady = zlmrtpServerFactory.isStreamReady(gbStream.getApp(), gbStream.getStream());
+					if (!streamReady) {
+						logger.info("[ app={}, stream={} ]閫氶亾绂荤嚎锛岃繑鍥�400",gbStream.getApp(), gbStream.getStream());
+						responseAck(evt, Response.BAD_REQUEST, "channel [" + gbStream.getGbId() + "] offline");
 						return;
 					}
 					responseAck(evt, Response.CALL_IS_BEING_FORWARDED); // 閫氶亾瀛樺湪锛屽彂181锛屽懠鍙浆鎺ヤ腑
@@ -187,7 +195,7 @@
 						sendRtpItem.setStatus(1);
 						redisCatchStorage.updateSendRTPSever(sendRtpItem);
 						// TODO 娣诲姞瀵箃cp鐨勬敮鎸�
-						MediaServerConfig mediaInfo = redisCatchStorage.getMediaInfo();
+						ZLMServerConfig mediaInfo = redisCatchStorage.getMediaInfo();
 						StringBuffer content = new StringBuffer(200);
 						content.append("v=0\r\n");
 						content.append("o="+"00000"+" 0 0 IN IP4 "+mediaInfo.getWanIp()+"\r\n");
@@ -240,34 +248,30 @@
 					// 鍐欏叆redis锛� 瓒呮椂鏃跺洖澶�
 					redisCatchStorage.updateSendRTPSever(sendRtpItem);
 
-					// 妫�娴嬬洿鎾祦鏄惁鍦ㄧ嚎
-					Boolean streamReady = zlmrtpServerFactory.isStreamReady(gbStream.getApp(), gbStream.getStream());
-					if (streamReady) {
-						sendRtpItem.setStatus(1);
-						redisCatchStorage.updateSendRTPSever(sendRtpItem);
-						// TODO 娣诲姞瀵箃cp鐨勬敮鎸�
-						MediaServerConfig mediaInfo = redisCatchStorage.getMediaInfo();
-						StringBuffer content = new StringBuffer(200);
-						content.append("v=0\r\n");
-						content.append("o="+"00000"+" 0 0 IN IP4 "+mediaInfo.getWanIp()+"\r\n");
-						content.append("s=Play\r\n");
-						content.append("c=IN IP4 "+mediaInfo.getWanIp()+"\r\n");
-						content.append("t=0 0\r\n");
-						content.append("m=video "+ sendRtpItem.getLocalPort()+" RTP/AVP 96\r\n");
-						content.append("a=sendonly\r\n");
-						content.append("a=rtpmap:96 PS/90000\r\n");
-						content.append("y="+ ssrc + "\r\n");
-						content.append("f=\r\n");
+					sendRtpItem.setStatus(1);
+					redisCatchStorage.updateSendRTPSever(sendRtpItem);
+					// TODO 娣诲姞瀵箃cp鐨勬敮鎸�
+					ZLMServerConfig mediaInfo = redisCatchStorage.getMediaInfo();
+					StringBuffer content = new StringBuffer(200);
+					content.append("v=0\r\n");
+					content.append("o="+"00000"+" 0 0 IN IP4 "+mediaInfo.getWanIp()+"\r\n");
+					content.append("s=Play\r\n");
+					content.append("c=IN IP4 "+mediaInfo.getWanIp()+"\r\n");
+					content.append("t=0 0\r\n");
+					content.append("m=video "+ sendRtpItem.getLocalPort()+" RTP/AVP 96\r\n");
+					content.append("a=sendonly\r\n");
+					content.append("a=rtpmap:96 PS/90000\r\n");
+					content.append("y="+ ssrc + "\r\n");
+					content.append("f=\r\n");
 
-						try {
-							responseAck(evt, content.toString());
-						} catch (SipException e) {
-							e.printStackTrace();
-						} catch (InvalidArgumentException e) {
-							e.printStackTrace();
-						} catch (ParseException e) {
-							e.printStackTrace();
-						}
+					try {
+						responseAck(evt, content.toString());
+					} catch (SipException e) {
+						e.printStackTrace();
+					} catch (InvalidArgumentException e) {
+						e.printStackTrace();
+					} catch (ParseException e) {
+						e.printStackTrace();
 					}
 				}
 

--
Gitblit v1.8.0