648540858
2021-11-03 b445128fb5bdc24f6703e7a40e9fd9f40919baf2
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java
@@ -361,7 +361,7 @@
         //
         StringBuffer content = new StringBuffer(200);
         content.append("v=0\r\n");
         content.append("o="+"00000"+" 0 0 IN IP4 "+ mediaServerItem.getSdpIp() +"\r\n");
         content.append("o="+ sipConfig.getId()+" 0 0 IN IP4 "+ mediaServerItem.getSdpIp() +"\r\n");
         content.append("s=Play\r\n");
         content.append("c=IN IP4 "+ mediaServerItem.getSdpIp() +"\r\n");
         content.append("t=0 0\r\n");
@@ -427,8 +427,8 @@
            mediaServerService.releaseSsrc(mediaServerItem, ssrcInfo.getSsrc());
            errorEvent.response(e);
         }), e ->{
            streamSession.put(device.getDeviceId(), channelId ,ssrcInfo.getSsrc(), finalStreamId, mediaServerItem.getId(),e.getClientTransaction());
            streamSession.put(device.getDeviceId(), channelId , e.getDialog());
            streamSession.put(device.getDeviceId(), channelId ,ssrcInfo.getSsrc(), finalStreamId, mediaServerItem.getId(), ((ResponseEvent)e.event).getClientTransaction());
            streamSession.put(device.getDeviceId(), channelId , e.dialog);
         });
         
@@ -468,7 +468,7 @@
         StringBuffer content = new StringBuffer(200);
           content.append("v=0\r\n");
           content.append("o="+sipConfig.getId()+" 0 0 IN IP4 "+sipConfig.getIp()+"\r\n");
           content.append("o="+sipConfig.getId()+" 0 0 IN IP4 " + mediaServerItem.getSdpIp() + "\r\n");
           content.append("s=Playback\r\n");
           content.append("u="+channelId+":0\r\n");
           content.append("c=IN IP4 "+mediaServerItem.getSdpIp()+"\r\n");
@@ -532,12 +532,12 @@
         CallIdHeader callIdHeader = device.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId()
               : udpSipProvider.getNewCallId();
           Request request = headerProvider.createPlaybackInviteRequest(device, channelId, content.toString(), null, "fromplybck" + tm, null, callIdHeader);
           Request request = headerProvider.createPlaybackInviteRequest(device, channelId, content.toString(), null, "fromplybck" + tm, null, callIdHeader, ssrcInfo.getSsrc());
           transmitRequest(device, request, errorEvent, okEvent -> {
            Dialog dialog = okEvent.getClientTransaction().getDialog();
              streamSession.put(device.getDeviceId(), channelId, ssrcInfo.getSsrc(), ssrcInfo.getStreamId(), mediaServerItem.getId(), okEvent.getClientTransaction());
            streamSession.put(device.getDeviceId(), channelId, dialog);
            ResponseEvent responseEvent = (ResponseEvent) okEvent.event;
              streamSession.put(device.getDeviceId(), channelId, ssrcInfo.getSsrc(), ssrcInfo.getStreamId(), mediaServerItem.getId(), responseEvent.getClientTransaction());
            streamSession.put(device.getDeviceId(), channelId, okEvent.dialog);
         });
      } catch ( SipException | ParseException | InvalidArgumentException e) {
         e.printStackTrace();
@@ -575,7 +575,7 @@
         StringBuffer content = new StringBuffer(200);
           content.append("v=0\r\n");
           content.append("o="+sipConfig.getId()+" 0 0 IN IP4 "+sipConfig.getIp()+"\r\n");
           content.append("o="+sipConfig.getId()+" 0 0 IN IP4 " + mediaServerItem.getSdpIp() + "\r\n");
           content.append("s=Download\r\n");
           content.append("u="+channelId+":0\r\n");
           content.append("c=IN IP4 "+mediaServerItem.getSdpIp()+"\r\n");
@@ -640,7 +640,7 @@
         CallIdHeader callIdHeader = device.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId()
               : udpSipProvider.getNewCallId();
           Request request = headerProvider.createPlaybackInviteRequest(device, channelId, content.toString(), null, "fromplybck" + tm, null, callIdHeader);
           Request request = headerProvider.createPlaybackInviteRequest(device, channelId, content.toString(), null, "fromplybck" + tm, null, callIdHeader, ssrcInfo.getSsrc());
           ClientTransaction transaction = transmitRequest(device, request, errorEvent);
           streamSession.put(device.getDeviceId(), channelId, ssrcInfo.getSsrc(), ssrcInfo.getStreamId(), mediaServerItem.getId(), transaction);
@@ -667,6 +667,10 @@
         ClientTransaction transaction = streamSession.getTransaction(deviceId, channelId);
         if (transaction == null) {
            logger.warn("[ {} -> {}]停止视频流的时候发现事务已丢失", deviceId, channelId);
            SipSubscribe.EventResult<Object> eventResult = new SipSubscribe.EventResult<>();
            if (okEvent != null) {
               okEvent.response(eventResult);
            }
            return;
         }
         SIPDialog dialog = streamSession.getDialog(deviceId, channelId);
@@ -1506,11 +1510,17 @@
      CallIdHeader callIdHeader = (CallIdHeader)request.getHeader(CallIdHeader.NAME);
      // 添加错误订阅
      if (errorEvent != null) {
         sipSubscribe.addErrorSubscribe(callIdHeader.getCallId(), errorEvent);
         sipSubscribe.addErrorSubscribe(callIdHeader.getCallId(), (eventResult -> {
            errorEvent.response(eventResult);
            sipSubscribe.removeErrorSubscribe(eventResult.callId);
         }));
      }
      // 添加订阅
      if (okEvent != null) {
         sipSubscribe.addOkSubscribe(callIdHeader.getCallId(), okEvent);
         sipSubscribe.addOkSubscribe(callIdHeader.getCallId(), eventResult ->{
            okEvent.response(eventResult);
            sipSubscribe.removeOkSubscribe(eventResult.callId);
         });
      }
      clientTransaction.sendRequest();