Commit 7055c53192aadf6af9444c81373ab256e760b808

Authored by hexq
1 parent dd4e0d0d

BUGFIX:回放时,优先从SDP中提取channelId,兼容从Subject无法提取到channelId的问题

src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java
... ... @@ -30,8 +30,10 @@ import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
30 30 import com.genersoft.iot.vmp.utils.DateUtil;
31 31 import gov.nist.javax.sdp.TimeDescriptionImpl;
32 32 import gov.nist.javax.sdp.fields.TimeField;
  33 +import gov.nist.javax.sdp.fields.URIField;
33 34 import gov.nist.javax.sip.message.SIPRequest;
34 35 import gov.nist.javax.sip.message.SIPResponse;
  36 +import org.apache.commons.lang3.StringUtils;
35 37 import org.slf4j.Logger;
36 38 import org.slf4j.LoggerFactory;
37 39 import org.springframework.beans.factory.InitializingBean;
... ... @@ -133,7 +135,20 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
133 135 // Invite Request消息实现,此消息一般为级联消息,上级给下级发送请求视频指令
134 136 try {
135 137 SIPRequest request = (SIPRequest)evt.getRequest();
136   - String channelId = SipUtils.getChannelIdFromRequest(request);
  138 + String channelIdFromSub = SipUtils.getChannelIdFromRequest(request);
  139 +
  140 + // 解析sdp消息, 使用jainsip 自带的sdp解析方式
  141 + String contentString = new String(request.getRawContent());
  142 + Gb28181Sdp gb28181Sdp = SipUtils.parseSDP(contentString);
  143 + SessionDescription sdp = gb28181Sdp.getBaseSdb();
  144 + String sessionName = sdp.getSessionName().getValue();
  145 + String channelIdFromSdp = null;
  146 + if(StringUtils.equalsIgnoreCase("Playback", sessionName)){
  147 + URIField uriField = (URIField)sdp.getURI();
  148 + channelIdFromSdp = uriField.getURI().split(":")[0];
  149 + }
  150 + final String channelId = StringUtils.isNotBlank(channelIdFromSdp) ? channelIdFromSdp : channelIdFromSub;
  151 +
137 152 String requesterId = SipUtils.getUserIdFromFromHeader(request);
138 153 CallIdHeader callIdHeader = (CallIdHeader) request.getHeader(CallIdHeader.NAME);
139 154 if (requesterId == null || channelId == null) {
... ... @@ -242,12 +257,6 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
242 257 }
243 258 return;
244 259 }
245   - // 解析sdp消息, 使用jainsip 自带的sdp解析方式
246   - String contentString = new String(request.getRawContent());
247   -
248   - Gb28181Sdp gb28181Sdp = SipUtils.parseSDP(contentString);
249   - SessionDescription sdp = gb28181Sdp.getBaseSdb();
250   - String sessionName = sdp.getSessionName().getValue();
251 260  
252 261 Long startTime = null;
253 262 Long stopTime = null;
... ...