Merge pull request #673 from 648540858/wvp-28181-2.0-multi-network
Wvp 28181 2.0 multi network
| | |
| | | add sdpIp varchar(50) default null; |
| | | |
| | | alter table device |
| | | add localIp varchar(50) default null; |
| | | |
| | | alter table device |
| | | add password varchar(255) default null; |
| | | |
| | | alter table device |
| | |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | @Schema(description = "流信息") |
| | | public class StreamInfo { |
| | | public class StreamInfo implements Serializable, Cloneable{ |
| | | |
| | | @Schema(description = "应用名") |
| | | private String app; |
| | |
| | | private String deviceID; |
| | | @Schema(description = "通道编号") |
| | | private String channelId; |
| | | @Schema(description = "HTTP-FLV流地址") |
| | | private String flv; |
| | | |
| | | @Schema(description = "IP") |
| | | private String ip; |
| | | |
| | | @Schema(description = "HTTP-FLV流地址") |
| | | private StreamURL flv; |
| | | |
| | | @Schema(description = "HTTPS-FLV流地址") |
| | | private String https_flv; |
| | | private StreamURL https_flv; |
| | | @Schema(description = "Websocket-FLV流地址") |
| | | private String ws_flv; |
| | | private StreamURL ws_flv; |
| | | @Schema(description = "Websockets-FLV流地址") |
| | | private String wss_flv; |
| | | private StreamURL wss_flv; |
| | | @Schema(description = "HTTP-FMP4流地址") |
| | | private String fmp4; |
| | | private StreamURL fmp4; |
| | | @Schema(description = "HTTPS-FMP4流地址") |
| | | private String https_fmp4; |
| | | private StreamURL https_fmp4; |
| | | @Schema(description = "Websocket-FMP4流地址") |
| | | private String ws_fmp4; |
| | | private StreamURL ws_fmp4; |
| | | @Schema(description = "Websockets-FMP4流地址") |
| | | private String wss_fmp4; |
| | | private StreamURL wss_fmp4; |
| | | @Schema(description = "HLS流地址") |
| | | private String hls; |
| | | private StreamURL hls; |
| | | @Schema(description = "HTTPS-HLS流地址") |
| | | private String https_hls; |
| | | private StreamURL https_hls; |
| | | @Schema(description = "Websocket-HLS流地址") |
| | | private String ws_hls; |
| | | private StreamURL ws_hls; |
| | | @Schema(description = "Websockets-HLS流地址") |
| | | private String wss_hls; |
| | | private StreamURL wss_hls; |
| | | @Schema(description = "HTTP-TS流地址") |
| | | private String ts; |
| | | private StreamURL ts; |
| | | @Schema(description = "HTTPS-TS流地址") |
| | | private String https_ts; |
| | | private StreamURL https_ts; |
| | | @Schema(description = "Websocket-TS流地址") |
| | | private String ws_ts; |
| | | private StreamURL ws_ts; |
| | | @Schema(description = "Websockets-TS流地址") |
| | | private String wss_ts; |
| | | private StreamURL wss_ts; |
| | | @Schema(description = "RTMP流地址") |
| | | private String rtmp; |
| | | private StreamURL rtmp; |
| | | @Schema(description = "RTMPS流地址") |
| | | private String rtmps; |
| | | private StreamURL rtmps; |
| | | @Schema(description = "RTSP流地址") |
| | | private String rtsp; |
| | | private StreamURL rtsp; |
| | | @Schema(description = "RTSPS流地址") |
| | | private String rtsps; |
| | | private StreamURL rtsps; |
| | | @Schema(description = "RTC流地址") |
| | | private String rtc; |
| | | private StreamURL rtc; |
| | | |
| | | @Schema(description = "RTCS流地址") |
| | | private String rtcs; |
| | | private StreamURL rtcs; |
| | | @Schema(description = "流媒体ID") |
| | | private String mediaServerId; |
| | | @Schema(description = "流编码信息") |
| | |
| | | |
| | | @Schema(description = "是否暂停(录像回放使用)") |
| | | private boolean pause; |
| | | |
| | | public void setFlv(StreamURL flv) { |
| | | this.flv = flv; |
| | | } |
| | | |
| | | public void setHttps_flv(StreamURL https_flv) { |
| | | this.https_flv = https_flv; |
| | | } |
| | | |
| | | public void setWs_flv(StreamURL ws_flv) { |
| | | this.ws_flv = ws_flv; |
| | | } |
| | | |
| | | public void setWss_flv(StreamURL wss_flv) { |
| | | this.wss_flv = wss_flv; |
| | | } |
| | | |
| | | public void setFmp4(StreamURL fmp4) { |
| | | this.fmp4 = fmp4; |
| | | } |
| | | |
| | | public void setHttps_fmp4(StreamURL https_fmp4) { |
| | | this.https_fmp4 = https_fmp4; |
| | | } |
| | | |
| | | public void setWs_fmp4(StreamURL ws_fmp4) { |
| | | this.ws_fmp4 = ws_fmp4; |
| | | } |
| | | |
| | | public void setWss_fmp4(StreamURL wss_fmp4) { |
| | | this.wss_fmp4 = wss_fmp4; |
| | | } |
| | | |
| | | public void setHls(StreamURL hls) { |
| | | this.hls = hls; |
| | | } |
| | | |
| | | public void setHttps_hls(StreamURL https_hls) { |
| | | this.https_hls = https_hls; |
| | | } |
| | | |
| | | public void setWs_hls(StreamURL ws_hls) { |
| | | this.ws_hls = ws_hls; |
| | | } |
| | | |
| | | public void setWss_hls(StreamURL wss_hls) { |
| | | this.wss_hls = wss_hls; |
| | | } |
| | | |
| | | public void setTs(StreamURL ts) { |
| | | this.ts = ts; |
| | | } |
| | | |
| | | public void setHttps_ts(StreamURL https_ts) { |
| | | this.https_ts = https_ts; |
| | | } |
| | | |
| | | public void setWs_ts(StreamURL ws_ts) { |
| | | this.ws_ts = ws_ts; |
| | | } |
| | | |
| | | public void setWss_ts(StreamURL wss_ts) { |
| | | this.wss_ts = wss_ts; |
| | | } |
| | | |
| | | public void setRtmp(StreamURL rtmp) { |
| | | this.rtmp = rtmp; |
| | | } |
| | | |
| | | public void setRtmps(StreamURL rtmps) { |
| | | this.rtmps = rtmps; |
| | | } |
| | | |
| | | public void setRtsp(StreamURL rtsp) { |
| | | this.rtsp = rtsp; |
| | | } |
| | | |
| | | public void setRtsps(StreamURL rtsps) { |
| | | this.rtsps = rtsps; |
| | | } |
| | | |
| | | public void setRtc(StreamURL rtc) { |
| | | this.rtc = rtc; |
| | | } |
| | | |
| | | public void setRtcs(StreamURL rtcs) { |
| | | this.rtcs = rtcs; |
| | | } |
| | | |
| | | public void setRtmp(String host, int port, int sslPort, String app, String stream, String callIdParam) { |
| | | String file = String.format("%s/%s/%s", app, stream, callIdParam); |
| | | this.rtmp = new StreamURL("rtmp", host, port, file); |
| | | if (sslPort != 0) { |
| | | this.rtmps = new StreamURL("rtmps", host, sslPort, file); |
| | | } |
| | | } |
| | | |
| | | public void setRtsp(String host, int port, int sslPort, String app, String stream, String callIdParam) { |
| | | String file = String.format("%s/%s/%s", app, stream, callIdParam); |
| | | this.rtsp = new StreamURL("rtsp", host, port, file); |
| | | if (sslPort != 0) { |
| | | this.rtsps = new StreamURL("rtsps", host, sslPort, file); |
| | | } |
| | | } |
| | | |
| | | public void setFlv(String host, int port, int sslPort, String app, String stream, String callIdParam) { |
| | | String file = String.format("%s/%s.live.flv%s", app, stream, callIdParam); |
| | | this.flv = new StreamURL("http", host, port, file); |
| | | this.ws_flv = new StreamURL("ws", host, port, file); |
| | | if (sslPort != 0) { |
| | | this.https_flv = new StreamURL("https", host, sslPort, file); |
| | | this.wss_flv = new StreamURL("wss", host, sslPort, file); |
| | | } |
| | | } |
| | | |
| | | public void setFmp4(String host, int port, int sslPort, String app, String stream, String callIdParam) { |
| | | String file = String.format("%s/%s.live.mp4%s", app, stream, callIdParam); |
| | | this.fmp4 = new StreamURL("http", host, port, file); |
| | | this.ws_fmp4 = new StreamURL("ws", host, port, file); |
| | | if (sslPort != 0) { |
| | | this.https_fmp4 = new StreamURL("https", host, sslPort, file); |
| | | this.wss_fmp4 = new StreamURL("wss", host, sslPort, file); |
| | | } |
| | | } |
| | | |
| | | public void setHls(String host, int port, int sslPort, String app, String stream, String callIdParam) { |
| | | String file = String.format("%s/%s/hls.m3u8%s", app, stream, callIdParam); |
| | | this.hls = new StreamURL("http", host, port, file); |
| | | this.ws_hls = new StreamURL("ws", host, port, file); |
| | | if (sslPort != 0) { |
| | | this.https_hls = new StreamURL("https", host, sslPort, file); |
| | | this.wss_hls = new StreamURL("wss", host, sslPort, file); |
| | | } |
| | | } |
| | | |
| | | public void setTs(String host, int port, int sslPort, String app, String stream, String callIdParam) { |
| | | String file = String.format("%s/%s.live.ts%s", app, stream, callIdParam); |
| | | this.ts = new StreamURL("http", host, port, file); |
| | | this.ws_ts = new StreamURL("ws", host, port, file); |
| | | if (sslPort != 0) { |
| | | this.https_ts = new StreamURL("https", host, sslPort, file); |
| | | this.wss_ts = new StreamURL("wss", host, sslPort, file); |
| | | } |
| | | } |
| | | |
| | | public void setRtc(String host, int port, int sslPort, String app, String stream, String callIdParam) { |
| | | String file = String.format("index/api/webrtc?app=%s&stream=%s&type=play%s", app, stream, callIdParam); |
| | | this.rtc = new StreamURL("http", host, port, file); |
| | | if (sslPort != 0) { |
| | | this.rtcs = new StreamURL("https", host, sslPort, file); |
| | | } |
| | | } |
| | | |
| | | public void channgeStreamIp(String localAddr) { |
| | | this.flv.setHost(localAddr); |
| | | this.ws_flv.setHost(localAddr); |
| | | this.hls.setHost(localAddr); |
| | | this.ws_hls.setHost(localAddr); |
| | | this.ts.setHost(localAddr); |
| | | this.ws_ts.setHost(localAddr); |
| | | this.fmp4.setHost(localAddr); |
| | | this.ws_fmp4.setHost(localAddr); |
| | | this.rtc.setHost(localAddr); |
| | | if (this.https_flv != null) { |
| | | this.https_flv.setHost(localAddr); |
| | | this.wss_flv.setHost(localAddr); |
| | | this.https_hls.setHost(localAddr); |
| | | this.wss_hls.setHost(localAddr); |
| | | this.wss_ts.setHost(localAddr); |
| | | this.https_fmp4.setHost(localAddr); |
| | | this.wss_fmp4.setHost(localAddr); |
| | | this.rtcs.setHost(localAddr); |
| | | } |
| | | this.rtsp.setHost(localAddr); |
| | | if (this.rtsps != null) { |
| | | this.rtsps.setHost(localAddr); |
| | | } |
| | | this.rtmp.setHost(localAddr); |
| | | if (this.rtmps != null) { |
| | | this.rtmps.setHost(localAddr); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | public static class TransactionInfo{ |
| | | public String callId; |
| | |
| | | this.channelId = channelId; |
| | | } |
| | | |
| | | public String getFlv() { |
| | | return flv; |
| | | } |
| | | |
| | | public void setFlv(String flv) { |
| | | this.flv = flv; |
| | | } |
| | | |
| | | public String getWs_flv() { |
| | | return ws_flv; |
| | | } |
| | | |
| | | public void setWs_flv(String ws_flv) { |
| | | this.ws_flv = ws_flv; |
| | | } |
| | | |
| | | public String getRtmp() { |
| | | return rtmp; |
| | | } |
| | | |
| | | public void setRtmp(String rtmp) { |
| | | this.rtmp = rtmp; |
| | | } |
| | | |
| | | public String getHls() { |
| | | return hls; |
| | | } |
| | | |
| | | public void setHls(String hls) { |
| | | this.hls = hls; |
| | | } |
| | | |
| | | public String getRtsp() { |
| | | return rtsp; |
| | | } |
| | | |
| | | public void setRtsp(String rtsp) { |
| | | this.rtsp = rtsp; |
| | | } |
| | | |
| | | public Object getTracks() { |
| | | return tracks; |
| | | } |
| | | |
| | | public void setTracks(Object tracks) { |
| | | this.tracks = tracks; |
| | | } |
| | | |
| | | public String getFmp4() { |
| | | return fmp4; |
| | | } |
| | | |
| | | public void setFmp4(String fmp4) { |
| | | this.fmp4 = fmp4; |
| | | } |
| | | |
| | | public String getWs_fmp4() { |
| | | return ws_fmp4; |
| | | } |
| | | |
| | | public void setWs_fmp4(String ws_fmp4) { |
| | | this.ws_fmp4 = ws_fmp4; |
| | | } |
| | | |
| | | public String getWs_hls() { |
| | | return ws_hls; |
| | | } |
| | | |
| | | public void setWs_hls(String ws_hls) { |
| | | this.ws_hls = ws_hls; |
| | | } |
| | | |
| | | public String getTs() { |
| | | return ts; |
| | | } |
| | | |
| | | public void setTs(String ts) { |
| | | this.ts = ts; |
| | | } |
| | | |
| | | public String getWs_ts() { |
| | | return ws_ts; |
| | | } |
| | | |
| | | public void setWs_ts(String ws_ts) { |
| | | this.ws_ts = ws_ts; |
| | | } |
| | | |
| | | public String getStream() { |
| | | return stream; |
| | | } |
| | |
| | | this.stream = stream; |
| | | } |
| | | |
| | | public String getRtc() { |
| | | public String getIp() { |
| | | return ip; |
| | | } |
| | | |
| | | public void setIp(String ip) { |
| | | this.ip = ip; |
| | | } |
| | | |
| | | public StreamURL getFlv() { |
| | | return flv; |
| | | } |
| | | |
| | | public StreamURL getHttps_flv() { |
| | | return https_flv; |
| | | } |
| | | |
| | | public StreamURL getWs_flv() { |
| | | return ws_flv; |
| | | } |
| | | |
| | | |
| | | public StreamURL getWss_flv() { |
| | | return wss_flv; |
| | | } |
| | | |
| | | public StreamURL getFmp4() { |
| | | return fmp4; |
| | | } |
| | | |
| | | |
| | | |
| | | public StreamURL getHttps_fmp4() { |
| | | return https_fmp4; |
| | | } |
| | | |
| | | public StreamURL getWs_fmp4() { |
| | | return ws_fmp4; |
| | | } |
| | | |
| | | public StreamURL getWss_fmp4() { |
| | | return wss_fmp4; |
| | | } |
| | | |
| | | public StreamURL getHls() { |
| | | return hls; |
| | | } |
| | | |
| | | |
| | | public StreamURL getHttps_hls() { |
| | | return https_hls; |
| | | } |
| | | |
| | | public StreamURL getWs_hls() { |
| | | return ws_hls; |
| | | } |
| | | |
| | | public StreamURL getWss_hls() { |
| | | return wss_hls; |
| | | } |
| | | |
| | | public StreamURL getTs() { |
| | | return ts; |
| | | } |
| | | |
| | | |
| | | public StreamURL getHttps_ts() { |
| | | return https_ts; |
| | | } |
| | | |
| | | |
| | | public StreamURL getWs_ts() { |
| | | return ws_ts; |
| | | } |
| | | |
| | | |
| | | public StreamURL getWss_ts() { |
| | | return wss_ts; |
| | | } |
| | | |
| | | |
| | | public StreamURL getRtmp() { |
| | | return rtmp; |
| | | } |
| | | |
| | | public StreamURL getRtmps() { |
| | | return rtmps; |
| | | } |
| | | |
| | | public StreamURL getRtsp() { |
| | | return rtsp; |
| | | } |
| | | |
| | | public StreamURL getRtsps() { |
| | | return rtsps; |
| | | } |
| | | |
| | | public StreamURL getRtc() { |
| | | return rtc; |
| | | } |
| | | |
| | | public void setRtc(String rtc) { |
| | | this.rtc = rtc; |
| | | } |
| | | |
| | | public TransactionInfo getTransactionInfo() { |
| | | return transactionInfo; |
| | | } |
| | | |
| | | public void setTransactionInfo(TransactionInfo transactionInfo) { |
| | | this.transactionInfo = transactionInfo; |
| | | public StreamURL getRtcs() { |
| | | return rtcs; |
| | | } |
| | | |
| | | public String getMediaServerId() { |
| | |
| | | this.mediaServerId = mediaServerId; |
| | | } |
| | | |
| | | public String getHttps_flv() { |
| | | return https_flv; |
| | | public Object getTracks() { |
| | | return tracks; |
| | | } |
| | | |
| | | public void setHttps_flv(String https_flv) { |
| | | this.https_flv = https_flv; |
| | | public void setTracks(Object tracks) { |
| | | this.tracks = tracks; |
| | | } |
| | | |
| | | public String getWss_flv() { |
| | | return wss_flv; |
| | | } |
| | | |
| | | public void setWss_flv(String wss_flv) { |
| | | this.wss_flv = wss_flv; |
| | | } |
| | | |
| | | public String getWss_fmp4() { |
| | | return wss_fmp4; |
| | | } |
| | | |
| | | public void setWss_fmp4(String wss_fmp4) { |
| | | this.wss_fmp4 = wss_fmp4; |
| | | } |
| | | |
| | | public String getWss_hls() { |
| | | return wss_hls; |
| | | } |
| | | |
| | | public void setWss_hls(String wss_hls) { |
| | | this.wss_hls = wss_hls; |
| | | } |
| | | |
| | | public String getWss_ts() { |
| | | return wss_ts; |
| | | } |
| | | |
| | | public void setWss_ts(String wss_ts) { |
| | | this.wss_ts = wss_ts; |
| | | } |
| | | |
| | | public String getRtmps() { |
| | | return rtmps; |
| | | } |
| | | |
| | | public void setRtmps(String rtmps) { |
| | | this.rtmps = rtmps; |
| | | } |
| | | |
| | | public String getRtsps() { |
| | | return rtsps; |
| | | } |
| | | |
| | | public void setRtsps(String rtsps) { |
| | | this.rtsps = rtsps; |
| | | } |
| | | |
| | | public String getHttps_hls() { |
| | | return https_hls; |
| | | } |
| | | |
| | | public void setHttps_hls(String https_hls) { |
| | | this.https_hls = https_hls; |
| | | } |
| | | |
| | | public String getHttps_fmp4() { |
| | | return https_fmp4; |
| | | } |
| | | |
| | | public void setHttps_fmp4(String https_fmp4) { |
| | | this.https_fmp4 = https_fmp4; |
| | | } |
| | | |
| | | public String getHttps_ts() { |
| | | return https_ts; |
| | | } |
| | | |
| | | public void setHttps_ts(String https_ts) { |
| | | this.https_ts = https_ts; |
| | | } |
| | | |
| | | |
| | | public String getStartTime() { |
| | | return startTime; |
| | |
| | | this.progress = progress; |
| | | } |
| | | |
| | | public String getIp() { |
| | | return ip; |
| | | } |
| | | |
| | | public void setIp(String ip) { |
| | | this.ip = ip; |
| | | } |
| | | |
| | | public String getRtcs() { |
| | | return rtcs; |
| | | } |
| | | |
| | | public void setRtcs(String rtcs) { |
| | | this.rtcs = rtcs; |
| | | } |
| | | |
| | | public boolean isPause() { |
| | | return pause; |
| | | } |
| | |
| | | public void setPause(boolean pause) { |
| | | this.pause = pause; |
| | | } |
| | | |
| | | public TransactionInfo getTransactionInfo() { |
| | | return transactionInfo; |
| | | } |
| | | |
| | | public void setTransactionInfo(TransactionInfo transactionInfo) { |
| | | this.transactionInfo = transactionInfo; |
| | | } |
| | | |
| | | @Override |
| | | public StreamInfo clone() { |
| | | StreamInfo instance = null; |
| | | try{ |
| | | instance = (StreamInfo)super.clone(); |
| | | }catch(CloneNotSupportedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return instance; |
| | | } |
| | | } |
New file |
| | |
| | | package com.genersoft.iot.vmp.common; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | |
| | | @Schema(description = "流地址信息") |
| | | public class StreamURL implements Serializable { |
| | | |
| | | @Schema(description = "协议") |
| | | private String protocol; |
| | | |
| | | @Schema(description = "主机地址") |
| | | private String host; |
| | | |
| | | @Schema(description = "端口") |
| | | private int port = -1; |
| | | |
| | | @Schema(description = "定位位置") |
| | | private String file; |
| | | |
| | | @Schema(description = "拼接后的地址") |
| | | private String url; |
| | | |
| | | public StreamURL() { |
| | | } |
| | | |
| | | public StreamURL(String protocol, String host, int port, String file) { |
| | | this.protocol = protocol; |
| | | this.host = host; |
| | | this.port = port; |
| | | this.file = file; |
| | | } |
| | | |
| | | public String getProtocol() { |
| | | return protocol; |
| | | } |
| | | |
| | | public void setProtocol(String protocol) { |
| | | this.protocol = protocol; |
| | | } |
| | | |
| | | public String getHost() { |
| | | return host; |
| | | } |
| | | |
| | | public void setHost(String host) { |
| | | this.host = host; |
| | | } |
| | | |
| | | public int getPort() { |
| | | return port; |
| | | } |
| | | |
| | | public void setPort(int port) { |
| | | this.port = port; |
| | | } |
| | | |
| | | public String getFile() { |
| | | return file; |
| | | } |
| | | |
| | | public void setFile(String file) { |
| | | this.file = file; |
| | | } |
| | | |
| | | public String getUrl() { |
| | | return this.toString(); |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | if (protocol != null && host != null && port != -1 ) { |
| | | return String.format("%s://%s:%s/%s", protocol, host, port, file); |
| | | }else { |
| | | return null; |
| | | } |
| | | } |
| | | } |
| | |
| | | public void execute(){ |
| | | if (futureMap.size() > 0) { |
| | | for (String key : futureMap.keySet()) { |
| | | if (futureMap.get(key).isDone()) { |
| | | if (futureMap.get(key).isDone() || futureMap.get(key).isCancelled()) { |
| | | futureMap.remove(key); |
| | | runnableMap.remove(key); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | public boolean isAlive(String key) { |
| | | return futureMap.get(key) != null && !futureMap.get(key).isDone() && !futureMap.get(key).isCancelled(); |
| | | } |
| | | } |
| | |
| | | @Value("${media.ip}") |
| | | private String ip; |
| | | |
| | | @Value("${media.hook-ip:${sip.ip}}") |
| | | @Value("${media.hook-ip:}") |
| | | private String hookIp; |
| | | |
| | | @Value("${sip.ip}") |
| | |
| | | |
| | | public String getHookIp() { |
| | | if (ObjectUtils.isEmpty(hookIp)){ |
| | | return sipIp; |
| | | return sipIp.split(",")[0]; |
| | | }else { |
| | | return hookIp; |
| | | } |
| | |
| | | |
| | | import org.springframework.boot.context.properties.ConfigurationProperties; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.ObjectUtils; |
| | | |
| | | @Component |
| | | @ConfigurationProperties(prefix = "sip", ignoreInvalidFields = true) |
| | | public class SipConfig { |
| | | |
| | | private String ip; |
| | | |
| | | /** |
| | | * 默认使用 0.0.0.0 |
| | | */ |
| | | private String monitorIp = "0.0.0.0"; |
| | | |
| | | private Integer port; |
| | | |
| | |
| | | |
| | | Integer ptzSpeed = 50; |
| | | |
| | | Integer keepaliveTimeOut = 255; |
| | | |
| | | Integer registerTimeInterval = 120; |
| | | |
| | | private boolean alarm; |
| | | |
| | | public void setIp(String ip) { |
| | | this.ip = ip; |
| | | } |
| | | |
| | | public void setMonitorIp(String monitorIp) { |
| | | this.monitorIp = monitorIp; |
| | | } |
| | | |
| | | public void setPort(Integer port) { |
| | |
| | | this.ptzSpeed = ptzSpeed; |
| | | } |
| | | |
| | | public void setKeepaliveTimeOut(Integer keepaliveTimeOut) { |
| | | this.keepaliveTimeOut = keepaliveTimeOut; |
| | | } |
| | | |
| | | public void setRegisterTimeInterval(Integer registerTimeInterval) { |
| | | this.registerTimeInterval = registerTimeInterval; |
| | | } |
| | | |
| | | public String getMonitorIp() { |
| | | return monitorIp; |
| | | } |
| | | |
| | | public String getIp() { |
| | |
| | | return ptzSpeed; |
| | | } |
| | | |
| | | public Integer getKeepaliveTimeOut() { |
| | | return keepaliveTimeOut; |
| | | } |
| | | |
| | | public Integer getRegisterTimeInterval() { |
| | | return registerTimeInterval; |
| | | } |
| | |
| | | public void setAlarm(boolean alarm) { |
| | | this.alarm = alarm; |
| | | } |
| | | |
| | | public void getLocalIp(String deviceLocalIp) { |
| | | if (ObjectUtils.isEmpty(deviceLocalIp)) { |
| | | |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; |
| | | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatformCatch; |
| | | import com.genersoft.iot.vmp.gb28181.event.EventPublisher; |
| | | import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; |
| | | import com.genersoft.iot.vmp.service.IPlatformService; |
| | | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| | |
| | | parentPlatformCatch.setId(parentPlatform.getServerGBId()); |
| | | redisCatchStorage.updatePlatformCatchInfo(parentPlatformCatch); |
| | | // 设置所有平台离线 |
| | | platformService.offline(parentPlatform); |
| | | platformService.offline(parentPlatform, true); |
| | | // 取消订阅 |
| | | sipCommanderForPlatform.unregister(parentPlatform, null, (eventResult)->{ |
| | | platformService.login(parentPlatform); |
| | |
| | | |
| | | private Boolean usePushingAsStatus = Boolean.TRUE; |
| | | |
| | | private Boolean useSourceIpAsStreamIp = Boolean.FALSE; |
| | | |
| | | private Boolean streamOnDemand = Boolean.TRUE; |
| | | |
| | | private Boolean pushAuthority = Boolean.TRUE; |
| | |
| | | this.streamOnDemand = streamOnDemand; |
| | | } |
| | | |
| | | public Boolean getUseSourceIpAsStreamIp() { |
| | | return useSourceIpAsStreamIp; |
| | | } |
| | | |
| | | public void setUseSourceIpAsStreamIp(Boolean useSourceIpAsStreamIp) { |
| | | this.useSourceIpAsStreamIp = useSourceIpAsStreamIp; |
| | | } |
| | | |
| | | public Boolean getPushAuthority() { |
| | | return pushAuthority; |
| | | } |
| | |
| | | import org.slf4j.Logger;
|
| | | import org.slf4j.LoggerFactory;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.context.annotation.Bean;
|
| | | import org.springframework.context.annotation.Configuration;
|
| | | import org.springframework.context.annotation.DependsOn;
|
| | | import org.springframework.boot.CommandLineRunner;
|
| | | import org.springframework.core.annotation.Order;
|
| | | import org.springframework.stereotype.Component;
|
| | | import org.springframework.util.ObjectUtils;
|
| | |
|
| | | import javax.sip.*;
|
| | | import java.util.Properties;
|
| | | import java.util.TooManyListenersException;
|
| | | import java.util.*;
|
| | | import java.util.concurrent.ConcurrentHashMap;
|
| | |
|
| | | @Configuration
|
| | | public class SipLayer{
|
| | | @Component
|
| | | @Order(value=1)
|
| | | public class SipLayer implements CommandLineRunner {
|
| | |
|
| | | private final static Logger logger = LoggerFactory.getLogger(SipLayer.class);
|
| | |
|
| | |
| | | @Autowired
|
| | | private ISIPProcessorObserver sipProcessorObserver;
|
| | |
|
| | | private SipStackImpl sipStack;
|
| | |
|
| | |
|
| | | private final Map<String, SipProviderImpl> tcpSipProviderMap = new ConcurrentHashMap<>();
|
| | | private final Map<String, SipProviderImpl> udpSipProviderMap = new ConcurrentHashMap<>();
|
| | |
|
| | | private SipFactory sipFactory;
|
| | |
|
| | | @Override
|
| | | public void run(String... args) {
|
| | | List<String> monitorIps = new ArrayList<>();
|
| | | // 使用逗号分割多个ip
|
| | | String separator = ",";
|
| | | if (sipConfig.getIp().indexOf(separator) > 0) {
|
| | | String[] split = sipConfig.getIp().split(separator);
|
| | | monitorIps.addAll(Arrays.asList(split));
|
| | | }else {
|
| | | monitorIps.add(sipConfig.getIp());
|
| | | }
|
| | |
|
| | | @Bean("sipFactory")
|
| | | SipFactory createSipFactory() {
|
| | | sipFactory = SipFactory.getInstance();
|
| | | sipFactory.setPathName("gov.nist");
|
| | | return sipFactory;
|
| | | }
|
| | | |
| | | @Bean("sipStack")
|
| | | @DependsOn({"sipFactory"})
|
| | | SipStackImpl createSipStack() throws PeerUnavailableException {
|
| | | sipStack = ( SipStackImpl )sipFactory.createSipStack(DefaultProperties.getProperties(sipConfig.getMonitorIp(), false));
|
| | | return sipStack;
|
| | | if (monitorIps.size() > 0) {
|
| | | for (String monitorIp : monitorIps) {
|
| | | addListeningPoint(monitorIp, sipConfig.getPort());
|
| | | }
|
| | | if (udpSipProviderMap.size() + tcpSipProviderMap.size() == 0) {
|
| | | System.exit(1);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | @Bean(name = "tcpSipProvider")
|
| | | @DependsOn("sipStack")
|
| | | SipProviderImpl startTcpListener() {
|
| | | ListeningPoint tcpListeningPoint = null;
|
| | | SipProviderImpl tcpSipProvider = null;
|
| | | private void addListeningPoint(String monitorIp, int port){
|
| | | SipStackImpl sipStack;
|
| | | try {
|
| | | tcpListeningPoint = sipStack.createListeningPoint(sipConfig.getMonitorIp(), sipConfig.getPort(), "TCP");
|
| | | tcpSipProvider = (SipProviderImpl)sipStack.createSipProvider(tcpListeningPoint);
|
| | | sipStack = (SipStackImpl)sipFactory.createSipStack(DefaultProperties.getProperties(monitorIp, false));
|
| | | } catch (PeerUnavailableException e) {
|
| | | logger.error("[Sip Server] SIP服务启动失败, 监听地址{}失败,请检查ip是否正确", monitorIp);
|
| | | return;
|
| | | }
|
| | |
|
| | | try {
|
| | | ListeningPoint tcpListeningPoint = sipStack.createListeningPoint(monitorIp, port, "TCP");
|
| | | SipProviderImpl tcpSipProvider = (SipProviderImpl)sipStack.createSipProvider(tcpListeningPoint);
|
| | |
|
| | | tcpSipProvider.setDialogErrorsAutomaticallyHandled();
|
| | | tcpSipProvider.addSipListener(sipProcessorObserver);
|
| | | logger.info("[Sip Server] TCP 启动成功 {}:{}", sipConfig.getMonitorIp(), sipConfig.getPort());
|
| | | } catch (TransportNotSupportedException e) {
|
| | | e.printStackTrace();
|
| | | } catch (InvalidArgumentException e) {
|
| | | logger.error("[Sip Server] 无法使用 [ {}:{} ]作为SIP[ TCP ]服务,可排查: 1. sip.monitor-ip 是否为本机网卡IP; 2. sip.port 是否已被占用"
|
| | | , sipConfig.getMonitorIp(), sipConfig.getPort());
|
| | | } catch (TooManyListenersException e) {
|
| | | e.printStackTrace();
|
| | | } catch (ObjectInUseException e) {
|
| | | e.printStackTrace();
|
| | | tcpSipProviderMap.put(monitorIp, tcpSipProvider);
|
| | |
|
| | | logger.info("[Sip Server] tcp://{}:{} 启动成功", monitorIp, port);
|
| | | } catch (TransportNotSupportedException
|
| | | | TooManyListenersException
|
| | | | ObjectInUseException
|
| | | | InvalidArgumentException e) {
|
| | | logger.error("[Sip Server] tcp://{}:{} SIP服务启动失败,请检查端口是否被占用或者ip是否正确"
|
| | | , monitorIp, port);
|
| | | }
|
| | | return tcpSipProvider;
|
| | | }
|
| | | |
| | | @Bean(name = "udpSipProvider")
|
| | | @DependsOn("sipStack")
|
| | | SipProviderImpl startUdpListener() {
|
| | | ListeningPoint udpListeningPoint = null;
|
| | | SipProviderImpl udpSipProvider = null;
|
| | |
|
| | | try {
|
| | | udpListeningPoint = sipStack.createListeningPoint(sipConfig.getMonitorIp(), sipConfig.getPort(), "UDP");
|
| | | udpSipProvider = (SipProviderImpl)sipStack.createSipProvider(udpListeningPoint);
|
| | | ListeningPoint udpListeningPoint = sipStack.createListeningPoint(monitorIp, port, "UDP");
|
| | |
|
| | | SipProviderImpl udpSipProvider = (SipProviderImpl)sipStack.createSipProvider(udpListeningPoint);
|
| | | udpSipProvider.addSipListener(sipProcessorObserver);
|
| | | } catch (TransportNotSupportedException e) {
|
| | | e.printStackTrace();
|
| | | } catch (InvalidArgumentException e) {
|
| | | logger.error("[Sip Server] 无法使用 [ {}:{} ]作为SIP[ UDP ]服务,可排查: 1. sip.monitor-ip 是否为本机网卡IP; 2. sip.port 是否已被占用"
|
| | | , sipConfig.getMonitorIp(), sipConfig.getPort());
|
| | | } catch (TooManyListenersException e) {
|
| | | e.printStackTrace();
|
| | | } catch (ObjectInUseException e) {
|
| | | e.printStackTrace();
|
| | |
|
| | | udpSipProviderMap.put(monitorIp, udpSipProvider);
|
| | |
|
| | | logger.info("[Sip Server] udp://{}:{} 启动成功", monitorIp, port);
|
| | | } catch (TransportNotSupportedException
|
| | | | TooManyListenersException
|
| | | | ObjectInUseException
|
| | | | InvalidArgumentException e) {
|
| | | logger.error("[Sip Server] udp://{}:{} SIP服务启动失败,请检查端口是否被占用或者ip是否正确"
|
| | | , monitorIp, port);
|
| | | }
|
| | | logger.info("[Sip Server] UDP 启动成功 {}:{}", sipConfig.getMonitorIp(), sipConfig.getPort());
|
| | | return udpSipProvider;
|
| | | }
|
| | |
|
| | | public SipFactory getSipFactory() {
|
| | | return sipFactory;
|
| | | }
|
| | |
|
| | | public SipProviderImpl getUdpSipProvider(String ip) {
|
| | | if (ObjectUtils.isEmpty(ip)) {
|
| | | return null;
|
| | | }
|
| | | return udpSipProviderMap.get(ip);
|
| | | }
|
| | |
|
| | | public SipProviderImpl getUdpSipProvider() {
|
| | | if (udpSipProviderMap.size() != 1) {
|
| | | return null;
|
| | | }
|
| | | return udpSipProviderMap.values().stream().findFirst().get();
|
| | | }
|
| | |
|
| | | public SipProviderImpl getTcpSipProvider() {
|
| | | if (tcpSipProviderMap.size() != 1) {
|
| | | return null;
|
| | | }
|
| | | return tcpSipProviderMap.values().stream().findFirst().get();
|
| | | }
|
| | |
|
| | | public SipProviderImpl getTcpSipProvider(String ip) {
|
| | | if (ObjectUtils.isEmpty(ip)) {
|
| | | return null;
|
| | | }
|
| | | return tcpSipProviderMap.get(ip);
|
| | | }
|
| | |
|
| | | public String getLocalIp(String deviceLocalIp) {
|
| | | if (!ObjectUtils.isEmpty(deviceLocalIp)) {
|
| | | return deviceLocalIp;
|
| | | }
|
| | | return getUdpSipProvider().getListeningPoint().getIPAddress();
|
| | | }
|
| | | }
|
| | |
| | | @Schema(description = "收流IP") |
| | | private String sdpIp; |
| | | |
| | | @Schema(description = "SIP交互IP(设备访问平台的IP)") |
| | | private String localIp; |
| | | |
| | | |
| | | public String getDeviceId() { |
| | | return deviceId; |
| | |
| | | public void setSdpIp(String sdpIp) { |
| | | this.sdpIp = sdpIp; |
| | | } |
| | | |
| | | public String getLocalIp() { |
| | | return localIp; |
| | | } |
| | | |
| | | public void setLocalIp(String localIp) { |
| | | this.localIp = localIp; |
| | | } |
| | | } |
| | |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.context.ApplicationListener; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.web.servlet.mvc.method.annotation.SseEmitter; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Hashtable; |
| | | import java.util.Map; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | |
| | | /** |
| | | * @description: 录像查询结束事件 |
| | |
| | | |
| | | private final static Logger logger = LoggerFactory.getLogger(RecordEndEventListener.class); |
| | | |
| | | private static Map<String, SseEmitter> sseEmitters = new Hashtable<>(); |
| | | |
| | | public interface RecordEndEventHandler{ |
| | | void handler(RecordInfo recordInfo); |
| | | } |
| | | |
| | | private Map<String, RecordEndEventHandler> handlerMap = new HashMap<>(); |
| | | private Map<String, RecordEndEventHandler> handlerMap = new ConcurrentHashMap<>(); |
| | | |
| | | @Override |
| | | public void onApplicationEvent(RecordEndEvent event) { |
| | | logger.info("录像查询完成事件触发,deviceId:{}, channelId: {}, 录像数量{}条", event.getRecordInfo().getDeviceId(), |
| | |
| | | recordEndEventHandler.handler(event.getRecordInfo()); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | public void addEndEventHandler(String device, String channelId, RecordEndEventHandler recordEndEventHandler) { |
| | |
| | | import com.genersoft.iot.vmp.gb28181.transmit.event.request.ISIPRequestProcessor; |
| | | import com.genersoft.iot.vmp.gb28181.transmit.event.response.ISIPResponseProcessor; |
| | | import com.genersoft.iot.vmp.gb28181.transmit.event.timeout.ITimeoutProcessor; |
| | | import gov.nist.javax.sip.message.SIPRequest; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | import javax.sip.header.*; |
| | | import javax.sip.message.Request; |
| | | import javax.sip.message.Response; |
| | | import java.net.InetAddress; |
| | | import java.util.Map; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | |
| | |
| | | ISIPRequestProcessor sipRequestProcessor = requestProcessorMap.get(method); |
| | | if (sipRequestProcessor == null) { |
| | | logger.warn("不支持方法{}的request", method); |
| | | // TODO 回复错误玛 |
| | | return; |
| | | } |
| | | requestProcessorMap.get(method).process(requestEvent); |
| | |
| | | package com.genersoft.iot.vmp.gb28181.transmit; |
| | | |
| | | import com.genersoft.iot.vmp.gb28181.SipLayer; |
| | | import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; |
| | | import com.genersoft.iot.vmp.gb28181.utils.SipUtils; |
| | | import com.genersoft.iot.vmp.utils.GitUtil; |
| | |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Qualifier; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.ObjectUtils; |
| | | |
| | | import javax.sip.SipException; |
| | | import javax.sip.SipFactory; |
| | | import javax.sip.header.CallIdHeader; |
| | | import javax.sip.header.UserAgentHeader; |
| | | import javax.sip.header.ViaHeader; |
| | |
| | | private final Logger logger = LoggerFactory.getLogger(SIPSender.class); |
| | | |
| | | @Autowired |
| | | @Qualifier(value = "tcpSipProvider") |
| | | private SipProviderImpl tcpSipProvider; |
| | | |
| | | @Autowired |
| | | @Qualifier(value = "udpSipProvider") |
| | | private SipProviderImpl udpSipProvider; |
| | | |
| | | @Autowired |
| | | private SipFactory sipFactory; |
| | | private SipLayer sipLayer; |
| | | |
| | | @Autowired |
| | | private GitUtil gitUtil; |
| | |
| | | @Autowired |
| | | private SipSubscribe sipSubscribe; |
| | | |
| | | public void transmitRequest(Message message) throws SipException, ParseException { |
| | | transmitRequest(message, null, null); |
| | | public void transmitRequest(String ip, Message message) throws SipException, ParseException { |
| | | transmitRequest(ip, message, null, null); |
| | | } |
| | | |
| | | public void transmitRequest(Message message, SipSubscribe.Event errorEvent) throws SipException, ParseException { |
| | | transmitRequest(message, errorEvent, null); |
| | | public void transmitRequest(String ip, Message message, SipSubscribe.Event errorEvent) throws SipException, ParseException { |
| | | transmitRequest(ip, message, errorEvent, null); |
| | | } |
| | | |
| | | public void transmitRequest(Message message, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws SipException, ParseException { |
| | | public void transmitRequest(String ip, Message message, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws SipException, ParseException { |
| | | ViaHeader viaHeader = (ViaHeader)message.getHeader(ViaHeader.NAME); |
| | | String transport = "UDP"; |
| | | if (viaHeader == null) { |
| | | logger.warn("[消息头缺失]: ViaHeader"); |
| | | logger.warn("[消息头缺失]: ViaHeader, 使用默认的UDP方式处理数据"); |
| | | }else { |
| | | transport = viaHeader.getTransport(); |
| | | } |
| | | if (message.getHeader(UserAgentHeader.NAME) == null) { |
| | | try { |
| | | message.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil)); |
| | | message.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil)); |
| | | } catch (ParseException e) { |
| | | logger.error("添加UserAgentHeader失败", e); |
| | | } |
| | |
| | | }); |
| | | } |
| | | if ("TCP".equals(transport)) { |
| | | SipProviderImpl tcpSipProvider = sipLayer.getTcpSipProvider(ip); |
| | | if (tcpSipProvider == null) { |
| | | logger.error("[发送信息失败] 未找到tcp://{}的监听信息", ip); |
| | | return; |
| | | } |
| | | if (message instanceof Request) { |
| | | tcpSipProvider.sendRequest((Request)message); |
| | | }else if (message instanceof Response) { |
| | |
| | | } |
| | | |
| | | } else if ("UDP".equals(transport)) { |
| | | SipProviderImpl sipProvider = sipLayer.getUdpSipProvider(ip); |
| | | if (sipProvider == null) { |
| | | logger.error("[发送信息失败] 未找到udp://{}的监听信息", ip); |
| | | return; |
| | | } |
| | | if (message instanceof Request) { |
| | | udpSipProvider.sendRequest((Request)message); |
| | | sipProvider.sendRequest((Request)message); |
| | | }else if (message instanceof Response) { |
| | | udpSipProvider.sendResponse((Response)message); |
| | | sipProvider.sendResponse((Response)message); |
| | | } |
| | | } |
| | | } |
| | | |
| | | public CallIdHeader getNewCallIdHeader(String transport){ |
| | | return transport.equalsIgnoreCase("TCP") ? tcpSipProvider.getNewCallId() |
| | | : udpSipProvider.getNewCallId(); |
| | | public CallIdHeader getNewCallIdHeader(String ip, String transport){ |
| | | if (ObjectUtils.isEmpty(transport)) { |
| | | return sipLayer.getUdpSipProvider().getNewCallId(); |
| | | } |
| | | SipProviderImpl sipProvider; |
| | | if (ObjectUtils.isEmpty(ip)) { |
| | | sipProvider = transport.equalsIgnoreCase("TCP") ? sipLayer.getTcpSipProvider() |
| | | : sipLayer.getUdpSipProvider(); |
| | | }else { |
| | | sipProvider = transport.equalsIgnoreCase("TCP") ? sipLayer.getTcpSipProvider(ip) |
| | | : sipLayer.getUdpSipProvider(ip); |
| | | } |
| | | |
| | | if (sipProvider == null) { |
| | | sipProvider = sipLayer.getUdpSipProvider(); |
| | | } |
| | | |
| | | if (sipProvider != null) { |
| | | return sipProvider.getNewCallId(); |
| | | }else { |
| | | logger.warn("[新建CallIdHeader失败], ip={}, transport={}", ip, transport); |
| | | return null; |
| | | } |
| | | } |
| | | } |
| | |
| | | package com.genersoft.iot.vmp.gb28181.transmit.callback;
|
| | |
|
| | | import java.util.HashMap;
|
| | | import com.genersoft.iot.vmp.vmanager.bean.DeferredResultEx;
|
| | | import org.springframework.stereotype.Component;
|
| | | import org.springframework.util.ObjectUtils;
|
| | | import org.springframework.web.context.request.async.DeferredResult;
|
| | |
|
| | | import java.util.Collection;
|
| | | import java.util.Map;
|
| | | import java.util.Set;
|
| | | import java.util.concurrent.ConcurrentHashMap;
|
| | |
|
| | | import org.springframework.http.HttpStatus;
|
| | | import org.springframework.http.ResponseEntity;
|
| | | import org.springframework.stereotype.Component;
|
| | | import org.springframework.web.context.request.async.DeferredResult;
|
| | |
|
| | | /**
|
| | | * @description: 异步请求处理
|
| | |
| | |
|
| | | public static final String CALLBACK_CMD_BROADCAST = "CALLBACK_BROADCAST";
|
| | |
|
| | | private Map<String, Map<String, DeferredResult>> map = new ConcurrentHashMap<>();
|
| | | private Map<String, Map<String, DeferredResultEx>> map = new ConcurrentHashMap<>();
|
| | |
|
| | |
|
| | | public void put(String key, String id, DeferredResult result) {
|
| | | Map<String, DeferredResult> deferredResultMap = map.get(key);
|
| | | public void put(String key, String id, DeferredResultEx result) {
|
| | | Map<String, DeferredResultEx> deferredResultMap = map.get(key);
|
| | | if (deferredResultMap == null) {
|
| | | deferredResultMap = new ConcurrentHashMap<>();
|
| | | map.put(key, deferredResultMap);
|
| | | }
|
| | | deferredResultMap.put(id, result);
|
| | | }
|
| | | |
| | | public DeferredResult get(String key, String id) {
|
| | | Map<String, DeferredResult> deferredResultMap = map.get(key);
|
| | |
|
| | | public void put(String key, String id, DeferredResult result) {
|
| | | Map<String, DeferredResultEx> deferredResultMap = map.get(key);
|
| | | if (deferredResultMap == null) {
|
| | | deferredResultMap = new ConcurrentHashMap<>();
|
| | | map.put(key, deferredResultMap);
|
| | | }
|
| | | deferredResultMap.put(id, new DeferredResultEx(result));
|
| | | }
|
| | | |
| | | public DeferredResultEx get(String key, String id) {
|
| | | Map<String, DeferredResultEx> deferredResultMap = map.get(key);
|
| | | if (deferredResultMap == null || ObjectUtils.isEmpty(id)) {
|
| | | return null;
|
| | | }
|
| | | return deferredResultMap.get(id);
|
| | | }
|
| | |
|
| | | public Collection<DeferredResultEx> getAllByKey(String key) {
|
| | | Map<String, DeferredResultEx> deferredResultMap = map.get(key);
|
| | | if (deferredResultMap == null) {
|
| | | return null;
|
| | | }
|
| | | return deferredResultMap.values();
|
| | | }
|
| | |
|
| | | public boolean exist(String key, String id){
|
| | | if (key == null) {
|
| | | return false;
|
| | | }
|
| | | Map<String, DeferredResult> deferredResultMap = map.get(key);
|
| | | Map<String, DeferredResultEx> deferredResultMap = map.get(key);
|
| | | if (id == null) {
|
| | | return deferredResultMap != null;
|
| | | }else {
|
| | |
| | | * @param msg
|
| | | */
|
| | | public void invokeResult(RequestMessage msg) {
|
| | | Map<String, DeferredResult> deferredResultMap = map.get(msg.getKey());
|
| | | Map<String, DeferredResultEx> deferredResultMap = map.get(msg.getKey());
|
| | | if (deferredResultMap == null) {
|
| | | return;
|
| | | }
|
| | | DeferredResult result = deferredResultMap.get(msg.getId());
|
| | | DeferredResultEx result = deferredResultMap.get(msg.getId());
|
| | | if (result == null) {
|
| | | return;
|
| | | }
|
| | | result.setResult(msg.getData());
|
| | | result.getDeferredResult().setResult(msg.getData());
|
| | | deferredResultMap.remove(msg.getId());
|
| | | if (deferredResultMap.size() == 0) {
|
| | | map.remove(msg.getKey());
|
| | |
| | | * @param msg
|
| | | */
|
| | | public void invokeAllResult(RequestMessage msg) {
|
| | | Map<String, DeferredResult> deferredResultMap = map.get(msg.getKey());
|
| | | Map<String, DeferredResultEx> deferredResultMap = map.get(msg.getKey());
|
| | | if (deferredResultMap == null) {
|
| | | return;
|
| | | }
|
| | | Set<String> ids = deferredResultMap.keySet();
|
| | | for (String id : ids) {
|
| | | DeferredResult result = deferredResultMap.get(id);
|
| | | if (result == null) {
|
| | | synchronized (this) {
|
| | | deferredResultMap = map.get(msg.getKey());
|
| | | if (deferredResultMap == null) {
|
| | | return;
|
| | | }
|
| | | result.setResult(msg.getData());
|
| | | Set<String> ids = deferredResultMap.keySet();
|
| | | for (String id : ids) {
|
| | | DeferredResultEx result = deferredResultMap.get(id);
|
| | | if (result == null) {
|
| | | return;
|
| | | }
|
| | | if (result.getFilter() != null) {
|
| | | Object handler = result.getFilter().handler(msg.getData());
|
| | | result.getDeferredResult().setResult(handler);
|
| | | }else {
|
| | | result.getDeferredResult().setResult(msg.getData());
|
| | | }
|
| | |
|
| | | }
|
| | | map.remove(msg.getKey());
|
| | | }
|
| | | map.remove(msg.getKey());
|
| | | }
|
| | | }
|
| | |
| | | package com.genersoft.iot.vmp.gb28181.transmit.cmd; |
| | | |
| | | import com.genersoft.iot.vmp.conf.SipConfig; |
| | | import com.genersoft.iot.vmp.gb28181.SipLayer; |
| | | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; |
| | | import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem; |
| | | import com.genersoft.iot.vmp.gb28181.bean.SubscribeInfo; |
| | |
| | | private SipConfig sipConfig; |
| | | |
| | | @Autowired |
| | | private SipFactory sipFactory; |
| | | private SipLayer sipLayer; |
| | | |
| | | @Autowired |
| | | private GitUtil gitUtil; |
| | |
| | | @Autowired |
| | | private IRedisCatchStorage redisCatchStorage; |
| | | |
| | | public Request createRegisterRequest(@NotNull ParentPlatform platform, long CSeq, String fromTag, String viaTag, CallIdHeader callIdHeader, boolean isRegister) throws ParseException, InvalidArgumentException, PeerUnavailableException { |
| | | public Request createRegisterRequest(@NotNull ParentPlatform parentPlatform, long CSeq, String fromTag, String viaTag, CallIdHeader callIdHeader, boolean isRegister) throws ParseException, InvalidArgumentException, PeerUnavailableException { |
| | | Request request = null; |
| | | String sipAddress = sipConfig.getIp() + ":" + sipConfig.getPort(); |
| | | String sipAddress = parentPlatform.getDeviceIp() + ":" + parentPlatform.getDevicePort(); |
| | | //请求行 |
| | | SipURI requestLine = sipFactory.createAddressFactory().createSipURI(platform.getServerGBId(), |
| | | platform.getServerIP() + ":" + platform.getServerPort()); |
| | | SipURI requestLine = sipLayer.getSipFactory().createAddressFactory().createSipURI(parentPlatform.getServerGBId(), |
| | | parentPlatform.getServerIP() + ":" + parentPlatform.getServerPort()); |
| | | //via |
| | | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(); |
| | | ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(platform.getServerIP(), platform.getServerPort(), platform.getTransport(), viaTag); |
| | | ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(parentPlatform.getServerIP(), parentPlatform.getServerPort(), parentPlatform.getTransport(), viaTag); |
| | | viaHeader.setRPort(); |
| | | viaHeaders.add(viaHeader); |
| | | //from |
| | | SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(platform.getDeviceGBId(), sipConfig.getDomain()); |
| | | Address fromAddress = sipFactory.createAddressFactory().createAddress(fromSipURI); |
| | | FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, fromTag); |
| | | SipURI fromSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(parentPlatform.getDeviceGBId(), sipConfig.getDomain()); |
| | | Address fromAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(fromSipURI); |
| | | FromHeader fromHeader = sipLayer.getSipFactory().createHeaderFactory().createFromHeader(fromAddress, fromTag); |
| | | //to |
| | | SipURI toSipURI = sipFactory.createAddressFactory().createSipURI(platform.getDeviceGBId(), sipConfig.getDomain()); |
| | | Address toAddress = sipFactory.createAddressFactory().createAddress(toSipURI); |
| | | ToHeader toHeader = sipFactory.createHeaderFactory().createToHeader(toAddress,null); |
| | | SipURI toSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(parentPlatform.getDeviceGBId(), sipConfig.getDomain()); |
| | | Address toAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(toSipURI); |
| | | ToHeader toHeader = sipLayer.getSipFactory().createHeaderFactory().createToHeader(toAddress,null); |
| | | |
| | | //Forwards |
| | | MaxForwardsHeader maxForwards = sipFactory.createHeaderFactory().createMaxForwardsHeader(70); |
| | | MaxForwardsHeader maxForwards = sipLayer.getSipFactory().createHeaderFactory().createMaxForwardsHeader(70); |
| | | |
| | | //ceq |
| | | CSeqHeader cSeqHeader = sipFactory.createHeaderFactory().createCSeqHeader(CSeq, Request.REGISTER); |
| | | request = sipFactory.createMessageFactory().createRequest(requestLine, Request.REGISTER, callIdHeader, |
| | | CSeqHeader cSeqHeader = sipLayer.getSipFactory().createHeaderFactory().createCSeqHeader(CSeq, Request.REGISTER); |
| | | request = sipLayer.getSipFactory().createMessageFactory().createRequest(requestLine, Request.REGISTER, callIdHeader, |
| | | cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards); |
| | | |
| | | Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory() |
| | | .createSipURI(platform.getDeviceGBId(), sipAddress)); |
| | | request.addHeader(sipFactory.createHeaderFactory().createContactHeader(concatAddress)); |
| | | Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory() |
| | | .createSipURI(parentPlatform.getDeviceGBId(), sipAddress)); |
| | | request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress)); |
| | | |
| | | ExpiresHeader expires = sipFactory.createHeaderFactory().createExpiresHeader(isRegister ? platform.getExpires() : 0); |
| | | ExpiresHeader expires = sipLayer.getSipFactory().createHeaderFactory().createExpiresHeader(isRegister ? parentPlatform.getExpires() : 0); |
| | | request.addHeader(expires); |
| | | |
| | | request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil)); |
| | | request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil)); |
| | | |
| | | return request; |
| | | } |
| | |
| | | |
| | | |
| | | Request registerRequest = createRegisterRequest(parentPlatform, redisCatchStorage.getCSEQ(), fromTag, viaTag, callIdHeader, isRegister); |
| | | SipURI requestURI = sipFactory.createAddressFactory().createSipURI(parentPlatform.getServerGBId(), parentPlatform.getServerIP() + ":" + parentPlatform.getServerPort()); |
| | | SipURI requestURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(parentPlatform.getServerGBId(), parentPlatform.getServerIP() + ":" + parentPlatform.getServerPort()); |
| | | if (www == null) { |
| | | AuthorizationHeader authorizationHeader = sipFactory.createHeaderFactory().createAuthorizationHeader("Digest"); |
| | | AuthorizationHeader authorizationHeader = sipLayer.getSipFactory().createHeaderFactory().createAuthorizationHeader("Digest"); |
| | | authorizationHeader.setUsername(parentPlatform.getDeviceGBId()); |
| | | authorizationHeader.setURI(requestURI); |
| | | authorizationHeader.setAlgorithm("MD5"); |
| | |
| | | |
| | | String RESPONSE = DigestUtils.md5DigestAsHex(reStr.toString().getBytes()); |
| | | |
| | | AuthorizationHeader authorizationHeader = sipFactory.createHeaderFactory().createAuthorizationHeader(scheme); |
| | | AuthorizationHeader authorizationHeader = sipLayer.getSipFactory().createHeaderFactory().createAuthorizationHeader(scheme); |
| | | authorizationHeader.setUsername(parentPlatform.getDeviceGBId()); |
| | | authorizationHeader.setRealm(realm); |
| | | authorizationHeader.setNonce(nonce); |
| | |
| | | } |
| | | |
| | | public Request createMessageRequest(ParentPlatform parentPlatform, String content, SendRtpItem sendRtpItem) throws PeerUnavailableException, ParseException, InvalidArgumentException { |
| | | CallIdHeader callIdHeader = sipFactory.createHeaderFactory().createCallIdHeader(sendRtpItem.getCallId()); |
| | | CallIdHeader callIdHeader = sipLayer.getSipFactory().createHeaderFactory().createCallIdHeader(sendRtpItem.getCallId()); |
| | | return createMessageRequest(parentPlatform, content, sendRtpItem.getToTag(), SipUtils.getNewViaTag(), sendRtpItem.getFromTag(), callIdHeader); |
| | | } |
| | | |
| | |
| | | Request request = null; |
| | | String serverAddress = parentPlatform.getServerIP()+ ":" + parentPlatform.getServerPort(); |
| | | // sipuri |
| | | SipURI requestURI = sipFactory.createAddressFactory().createSipURI(parentPlatform.getServerGBId(), serverAddress); |
| | | SipURI requestURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(parentPlatform.getServerGBId(), serverAddress); |
| | | // via |
| | | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(); |
| | | ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(parentPlatform.getDeviceIp(), Integer.parseInt(parentPlatform.getDevicePort()), |
| | | ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(parentPlatform.getDeviceIp(), Integer.parseInt(parentPlatform.getDevicePort()), |
| | | parentPlatform.getTransport(), viaTag); |
| | | viaHeader.setRPort(); |
| | | viaHeaders.add(viaHeader); |
| | | // from |
| | | // SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(parentPlatform.getDeviceGBId(), parentPlatform.getDeviceIp() + ":" + parentPlatform.getDeviceIp()); |
| | | SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(parentPlatform.getDeviceGBId(), sipConfig.getDomain()); |
| | | Address fromAddress = sipFactory.createAddressFactory().createAddress(fromSipURI); |
| | | FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, fromTag); |
| | | // SipURI fromSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(parentPlatform.getDeviceGBId(), parentPlatform.getDeviceIp() + ":" + parentPlatform.getDeviceIp()); |
| | | SipURI fromSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(parentPlatform.getDeviceGBId(), sipConfig.getDomain()); |
| | | Address fromAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(fromSipURI); |
| | | FromHeader fromHeader = sipLayer.getSipFactory().createHeaderFactory().createFromHeader(fromAddress, fromTag); |
| | | // to |
| | | SipURI toSipURI = sipFactory.createAddressFactory().createSipURI(parentPlatform.getServerGBId(), serverAddress); |
| | | Address toAddress = sipFactory.createAddressFactory().createAddress(toSipURI); |
| | | ToHeader toHeader = sipFactory.createHeaderFactory().createToHeader(toAddress, toTag); |
| | | SipURI toSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(parentPlatform.getServerGBId(), serverAddress); |
| | | Address toAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(toSipURI); |
| | | ToHeader toHeader = sipLayer.getSipFactory().createHeaderFactory().createToHeader(toAddress, toTag); |
| | | |
| | | // Forwards |
| | | MaxForwardsHeader maxForwards = sipFactory.createHeaderFactory().createMaxForwardsHeader(70); |
| | | MaxForwardsHeader maxForwards = sipLayer.getSipFactory().createHeaderFactory().createMaxForwardsHeader(70); |
| | | // ceq |
| | | CSeqHeader cSeqHeader = sipFactory.createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.MESSAGE); |
| | | MessageFactoryImpl messageFactory = (MessageFactoryImpl) sipFactory.createMessageFactory(); |
| | | CSeqHeader cSeqHeader = sipLayer.getSipFactory().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.MESSAGE); |
| | | MessageFactoryImpl messageFactory = (MessageFactoryImpl) sipLayer.getSipFactory().createMessageFactory(); |
| | | // 设置编码, 防止中文乱码 |
| | | messageFactory.setDefaultContentEncodingCharset(parentPlatform.getCharacterSet()); |
| | | request = messageFactory.createRequest(requestURI, Request.MESSAGE, callIdHeader, cSeqHeader, fromHeader, |
| | | toHeader, viaHeaders, maxForwards); |
| | | |
| | | request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil)); |
| | | request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil)); |
| | | |
| | | ContentTypeHeader contentTypeHeader = sipFactory.createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml"); |
| | | ContentTypeHeader contentTypeHeader = sipLayer.getSipFactory().createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml"); |
| | | request.setContent(content, contentTypeHeader); |
| | | return request; |
| | | } |
| | |
| | | public SIPRequest createNotifyRequest(ParentPlatform parentPlatform, String content, SubscribeInfo subscribeInfo) throws PeerUnavailableException, ParseException, InvalidArgumentException { |
| | | SIPRequest request = null; |
| | | // sipuri |
| | | SipURI requestURI = sipFactory.createAddressFactory().createSipURI(parentPlatform.getServerGBId(), parentPlatform.getServerIP()+ ":" + parentPlatform.getServerPort()); |
| | | SipURI requestURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(parentPlatform.getServerGBId(), parentPlatform.getServerIP()+ ":" + parentPlatform.getServerPort()); |
| | | // via |
| | | ArrayList<ViaHeader> viaHeaders = new ArrayList<>(); |
| | | ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(parentPlatform.getDeviceIp(), Integer.parseInt(parentPlatform.getDevicePort()), |
| | | ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(parentPlatform.getDeviceIp(), Integer.parseInt(parentPlatform.getDevicePort()), |
| | | parentPlatform.getTransport(), SipUtils.getNewViaTag()); |
| | | viaHeader.setRPort(); |
| | | viaHeaders.add(viaHeader); |
| | | // from |
| | | SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(parentPlatform.getDeviceGBId(), |
| | | SipURI fromSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(parentPlatform.getDeviceGBId(), |
| | | parentPlatform.getDeviceIp() + ":" + parentPlatform.getDevicePort()); |
| | | Address fromAddress = sipFactory.createAddressFactory().createAddress(fromSipURI); |
| | | FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, subscribeInfo.getResponse().getToTag()); |
| | | Address fromAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(fromSipURI); |
| | | FromHeader fromHeader = sipLayer.getSipFactory().createHeaderFactory().createFromHeader(fromAddress, subscribeInfo.getResponse().getToTag()); |
| | | // to |
| | | SipURI toSipURI = sipFactory.createAddressFactory().createSipURI(parentPlatform.getServerGBId(), parentPlatform.getServerGBDomain()); |
| | | Address toAddress = sipFactory.createAddressFactory().createAddress(toSipURI); |
| | | ToHeader toHeader = sipFactory.createHeaderFactory().createToHeader(toAddress, subscribeInfo.getRequest().getFromTag()); |
| | | SipURI toSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(parentPlatform.getServerGBId(), parentPlatform.getServerGBDomain()); |
| | | Address toAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(toSipURI); |
| | | ToHeader toHeader = sipLayer.getSipFactory().createHeaderFactory().createToHeader(toAddress, subscribeInfo.getRequest().getFromTag()); |
| | | |
| | | // Forwards |
| | | MaxForwardsHeader maxForwards = sipFactory.createHeaderFactory().createMaxForwardsHeader(70); |
| | | MaxForwardsHeader maxForwards = sipLayer.getSipFactory().createHeaderFactory().createMaxForwardsHeader(70); |
| | | // ceq |
| | | CSeqHeader cSeqHeader = sipFactory.createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.NOTIFY); |
| | | MessageFactoryImpl messageFactory = (MessageFactoryImpl) sipFactory.createMessageFactory(); |
| | | CSeqHeader cSeqHeader = sipLayer.getSipFactory().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.NOTIFY); |
| | | MessageFactoryImpl messageFactory = (MessageFactoryImpl) sipLayer.getSipFactory().createMessageFactory(); |
| | | // 设置编码, 防止中文乱码 |
| | | messageFactory.setDefaultContentEncodingCharset("gb2312"); |
| | | |
| | | CallIdHeader callIdHeader = sipFactory.createHeaderFactory().createCallIdHeader(subscribeInfo.getRequest().getCallIdHeader().getCallId()); |
| | | CallIdHeader callIdHeader = sipLayer.getSipFactory().createHeaderFactory().createCallIdHeader(subscribeInfo.getRequest().getCallIdHeader().getCallId()); |
| | | |
| | | request = (SIPRequest) messageFactory.createRequest(requestURI, Request.NOTIFY, callIdHeader, cSeqHeader, fromHeader, |
| | | toHeader, viaHeaders, maxForwards); |
| | | |
| | | request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil)); |
| | | request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil)); |
| | | |
| | | EventHeader event = sipFactory.createHeaderFactory().createEventHeader(subscribeInfo.getEventType()); |
| | | EventHeader event = sipLayer.getSipFactory().createHeaderFactory().createEventHeader(subscribeInfo.getEventType()); |
| | | if (subscribeInfo.getEventId() != null) { |
| | | event.setEventId(subscribeInfo.getEventId()); |
| | | } |
| | | |
| | | request.addHeader(event); |
| | | |
| | | SubscriptionStateHeader active = sipFactory.createHeaderFactory().createSubscriptionStateHeader("active"); |
| | | SubscriptionStateHeader active = sipLayer.getSipFactory().createHeaderFactory().createSubscriptionStateHeader("active"); |
| | | request.setHeader(active); |
| | | |
| | | String sipAddress = sipConfig.getIp() + ":" + sipConfig.getPort(); |
| | | Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory() |
| | | String sipAddress = parentPlatform.getDeviceIp() + ":" + parentPlatform.getDevicePort(); |
| | | Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory() |
| | | .createSipURI(parentPlatform.getDeviceGBId(), sipAddress)); |
| | | request.addHeader(sipFactory.createHeaderFactory().createContactHeader(concatAddress)); |
| | | request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress)); |
| | | |
| | | ContentTypeHeader contentTypeHeader = sipFactory.createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml"); |
| | | ContentTypeHeader contentTypeHeader = sipLayer.getSipFactory().createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml"); |
| | | request.setContent(content, contentTypeHeader); |
| | | return request; |
| | | } |
| | |
| | | |
| | | SIPRequest request = null; |
| | | // sipuri |
| | | SipURI requestURI = sipFactory.createAddressFactory().createSipURI(platform.getServerGBId(), platform.getServerIP()+ ":" + platform.getServerPort()); |
| | | SipURI requestURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(platform.getServerGBId(), platform.getServerIP()+ ":" + platform.getServerPort()); |
| | | // via |
| | | ArrayList<ViaHeader> viaHeaders = new ArrayList<>(); |
| | | ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(platform.getDeviceIp(), Integer.parseInt(platform.getDevicePort()), |
| | | ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(platform.getDeviceIp(), Integer.parseInt(platform.getDevicePort()), |
| | | platform.getTransport(), SipUtils.getNewViaTag()); |
| | | viaHeader.setRPort(); |
| | | viaHeaders.add(viaHeader); |
| | | // from |
| | | SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(platform.getDeviceGBId(), |
| | | SipURI fromSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(platform.getDeviceGBId(), |
| | | platform.getDeviceIp() + ":" + platform.getDevicePort()); |
| | | Address fromAddress = sipFactory.createAddressFactory().createAddress(fromSipURI); |
| | | FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, sendRtpItem.getToTag()); |
| | | Address fromAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(fromSipURI); |
| | | FromHeader fromHeader = sipLayer.getSipFactory().createHeaderFactory().createFromHeader(fromAddress, sendRtpItem.getToTag()); |
| | | // to |
| | | SipURI toSipURI = sipFactory.createAddressFactory().createSipURI(platform.getServerGBId(), platform.getServerGBDomain()); |
| | | Address toAddress = sipFactory.createAddressFactory().createAddress(toSipURI); |
| | | ToHeader toHeader = sipFactory.createHeaderFactory().createToHeader(toAddress, sendRtpItem.getFromTag()); |
| | | SipURI toSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(platform.getServerGBId(), platform.getServerGBDomain()); |
| | | Address toAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(toSipURI); |
| | | ToHeader toHeader = sipLayer.getSipFactory().createHeaderFactory().createToHeader(toAddress, sendRtpItem.getFromTag()); |
| | | |
| | | // Forwards |
| | | MaxForwardsHeader maxForwards = sipFactory.createHeaderFactory().createMaxForwardsHeader(70); |
| | | MaxForwardsHeader maxForwards = sipLayer.getSipFactory().createHeaderFactory().createMaxForwardsHeader(70); |
| | | // ceq |
| | | CSeqHeader cSeqHeader = sipFactory.createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.BYE); |
| | | MessageFactoryImpl messageFactory = (MessageFactoryImpl) sipFactory.createMessageFactory(); |
| | | CSeqHeader cSeqHeader = sipLayer.getSipFactory().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.BYE); |
| | | MessageFactoryImpl messageFactory = (MessageFactoryImpl) sipLayer.getSipFactory().createMessageFactory(); |
| | | // 设置编码, 防止中文乱码 |
| | | messageFactory.setDefaultContentEncodingCharset("gb2312"); |
| | | |
| | | CallIdHeader callIdHeader = sipFactory.createHeaderFactory().createCallIdHeader(sendRtpItem.getCallId()); |
| | | CallIdHeader callIdHeader = sipLayer.getSipFactory().createHeaderFactory().createCallIdHeader(sendRtpItem.getCallId()); |
| | | |
| | | request = (SIPRequest) messageFactory.createRequest(requestURI, Request.BYE, callIdHeader, cSeqHeader, fromHeader, |
| | | toHeader, viaHeaders, maxForwards); |
| | | |
| | | request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil)); |
| | | request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil)); |
| | | |
| | | String sipAddress = sipConfig.getIp() + ":" + sipConfig.getPort(); |
| | | Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory() |
| | | String sipAddress = platform.getDeviceIp() + ":" + platform.getDevicePort(); |
| | | Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory() |
| | | .createSipURI(platform.getDeviceGBId(), sipAddress)); |
| | | request.addHeader(sipFactory.createHeaderFactory().createContactHeader(concatAddress)); |
| | | request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress)); |
| | | |
| | | return request; |
| | | } |
| | |
| | | package com.genersoft.iot.vmp.gb28181.transmit.cmd;
|
| | |
|
| | | import java.text.ParseException;
|
| | | import java.util.ArrayList;
|
| | |
|
| | | import javax.sip.*;
|
| | | import javax.sip.address.Address;
|
| | | import javax.sip.address.SipURI;
|
| | | import javax.sip.header.*;
|
| | | import javax.sip.message.Request;
|
| | |
|
| | | import com.genersoft.iot.vmp.common.StreamInfo;
|
| | | import com.genersoft.iot.vmp.gb28181.bean.SipMsgInfo;
|
| | | import com.genersoft.iot.vmp.conf.SipConfig;
|
| | | import com.genersoft.iot.vmp.gb28181.SipLayer;
|
| | | import com.genersoft.iot.vmp.gb28181.bean.Device;
|
| | | import com.genersoft.iot.vmp.gb28181.bean.SipTransactionInfo;
|
| | | import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction;
|
| | | import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
|
| | | import com.genersoft.iot.vmp.gb28181.utils.SipUtils;
|
| | | import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
| | | import com.genersoft.iot.vmp.utils.GitUtil;
|
| | | import gov.nist.javax.sip.SipProviderImpl;
|
| | | import gov.nist.javax.sip.SipStackImpl;
|
| | | import gov.nist.javax.sip.message.SIPRequest;
|
| | | import gov.nist.javax.sip.message.SIPResponse;
|
| | | import gov.nist.javax.sip.stack.SIPDialog;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.beans.factory.annotation.Qualifier;
|
| | | import org.springframework.stereotype.Component;
|
| | |
|
| | | import com.genersoft.iot.vmp.conf.SipConfig;
|
| | | import com.genersoft.iot.vmp.gb28181.bean.Device;
|
| | | import javax.sip.InvalidArgumentException;
|
| | | import javax.sip.PeerUnavailableException;
|
| | | import javax.sip.SipException;
|
| | | import javax.sip.address.Address;
|
| | | import javax.sip.address.SipURI;
|
| | | import javax.sip.header.*;
|
| | | import javax.sip.message.Request;
|
| | | import java.text.ParseException;
|
| | | import java.util.ArrayList;
|
| | |
|
| | | /**
|
| | | * @description:摄像头命令request创造器 TODO 冗余代码太多待优化
|
| | |
| | | private SipConfig sipConfig;
|
| | |
|
| | | @Autowired
|
| | | private SipFactory sipFactory;
|
| | | private SipLayer sipLayer;
|
| | |
|
| | | @Autowired
|
| | | private GitUtil gitUtil;
|
| | |
| | | public Request createMessageRequest(Device device, String content, String viaTag, String fromTag, String toTag, CallIdHeader callIdHeader) throws ParseException, InvalidArgumentException, PeerUnavailableException {
|
| | | Request request = null;
|
| | | // sipuri
|
| | | SipURI requestURI = sipFactory.createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress());
|
| | | SipURI requestURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress());
|
| | | // via
|
| | | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();
|
| | | ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(sipConfig.getIp(), sipConfig.getPort(), device.getTransport(), viaTag);
|
| | | ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(sipLayer.getLocalIp(device.getLocalIp()), sipConfig.getPort(), device.getTransport(), viaTag);
|
| | | viaHeader.setRPort();
|
| | | viaHeaders.add(viaHeader);
|
| | | // from
|
| | | SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getDomain());
|
| | | Address fromAddress = sipFactory.createAddressFactory().createAddress(fromSipURI);
|
| | | FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, fromTag);
|
| | | SipURI fromSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getDomain());
|
| | | Address fromAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(fromSipURI);
|
| | | FromHeader fromHeader = sipLayer.getSipFactory().createHeaderFactory().createFromHeader(fromAddress, fromTag);
|
| | | // to
|
| | | SipURI toSipURI = sipFactory.createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress());
|
| | | Address toAddress = sipFactory.createAddressFactory().createAddress(toSipURI);
|
| | | ToHeader toHeader = sipFactory.createHeaderFactory().createToHeader(toAddress, toTag);
|
| | | SipURI toSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress());
|
| | | Address toAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(toSipURI);
|
| | | ToHeader toHeader = sipLayer.getSipFactory().createHeaderFactory().createToHeader(toAddress, toTag);
|
| | |
|
| | | // Forwards
|
| | | MaxForwardsHeader maxForwards = sipFactory.createHeaderFactory().createMaxForwardsHeader(70);
|
| | | MaxForwardsHeader maxForwards = sipLayer.getSipFactory().createHeaderFactory().createMaxForwardsHeader(70);
|
| | | // ceq
|
| | | CSeqHeader cSeqHeader = sipFactory.createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.MESSAGE);
|
| | | CSeqHeader cSeqHeader = sipLayer.getSipFactory().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.MESSAGE);
|
| | |
|
| | | request = sipFactory.createMessageFactory().createRequest(requestURI, Request.MESSAGE, callIdHeader, cSeqHeader, fromHeader,
|
| | | request = sipLayer.getSipFactory().createMessageFactory().createRequest(requestURI, Request.MESSAGE, callIdHeader, cSeqHeader, fromHeader,
|
| | | toHeader, viaHeaders, maxForwards);
|
| | |
|
| | | request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil));
|
| | | request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil));
|
| | |
|
| | | ContentTypeHeader contentTypeHeader = sipFactory.createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml");
|
| | | ContentTypeHeader contentTypeHeader = sipLayer.getSipFactory().createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml");
|
| | | request.setContent(content, contentTypeHeader);
|
| | | return request;
|
| | | }
|
| | |
| | | public Request createInviteRequest(Device device, String channelId, String content, String viaTag, String fromTag, String toTag, String ssrc, CallIdHeader callIdHeader) throws ParseException, InvalidArgumentException, PeerUnavailableException {
|
| | | Request request = null;
|
| | | //请求行
|
| | | SipURI requestLine = sipFactory.createAddressFactory().createSipURI(channelId, device.getHostAddress());
|
| | | SipURI requestLine = sipLayer.getSipFactory().createAddressFactory().createSipURI(channelId, device.getHostAddress());
|
| | | //via
|
| | | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();
|
| | | ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(sipConfig.getIp(), sipConfig.getPort(), device.getTransport(), viaTag);
|
| | | HeaderFactory headerFactory = sipLayer.getSipFactory().createHeaderFactory();
|
| | | ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(sipLayer.getLocalIp(device.getLocalIp()), sipConfig.getPort(), device.getTransport(), viaTag);
|
| | | viaHeader.setRPort();
|
| | | viaHeaders.add(viaHeader);
|
| | |
|
| | | //from
|
| | | SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getDomain());
|
| | | Address fromAddress = sipFactory.createAddressFactory().createAddress(fromSipURI);
|
| | | FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, fromTag); //必须要有标记,否则无法创建会话,无法回应ack
|
| | | SipURI fromSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getDomain());
|
| | | Address fromAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(fromSipURI);
|
| | | FromHeader fromHeader = sipLayer.getSipFactory().createHeaderFactory().createFromHeader(fromAddress, fromTag); //必须要有标记,否则无法创建会话,无法回应ack
|
| | | //to
|
| | | SipURI toSipURI = sipFactory.createAddressFactory().createSipURI(channelId, device.getHostAddress());
|
| | | Address toAddress = sipFactory.createAddressFactory().createAddress(toSipURI);
|
| | | ToHeader toHeader = sipFactory.createHeaderFactory().createToHeader(toAddress,null);
|
| | | SipURI toSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(channelId, device.getHostAddress());
|
| | | Address toAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(toSipURI);
|
| | | ToHeader toHeader = sipLayer.getSipFactory().createHeaderFactory().createToHeader(toAddress,null);
|
| | |
|
| | | //Forwards
|
| | | MaxForwardsHeader maxForwards = sipFactory.createHeaderFactory().createMaxForwardsHeader(70);
|
| | | MaxForwardsHeader maxForwards = sipLayer.getSipFactory().createHeaderFactory().createMaxForwardsHeader(70);
|
| | |
|
| | | //ceq
|
| | | CSeqHeader cSeqHeader = sipFactory.createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.INVITE);
|
| | | request = sipFactory.createMessageFactory().createRequest(requestLine, Request.INVITE, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards);
|
| | | CSeqHeader cSeqHeader = sipLayer.getSipFactory().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.INVITE);
|
| | | request = sipLayer.getSipFactory().createMessageFactory().createRequest(requestLine, Request.INVITE, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards);
|
| | |
|
| | | request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil));
|
| | | request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil));
|
| | |
|
| | | Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getIp()+":"+sipConfig.getPort()));
|
| | | // Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), device.getHost().getIp()+":"+device.getHost().getPort()));
|
| | | request.addHeader(sipFactory.createHeaderFactory().createContactHeader(concatAddress));
|
| | | Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), sipLayer.getLocalIp(device.getLocalIp())+":"+sipConfig.getPort()));
|
| | | // Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), device.getHost().getIp()+":"+device.getHost().getPort()));
|
| | | request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress));
|
| | | // Subject
|
| | | SubjectHeader subjectHeader = sipFactory.createHeaderFactory().createSubjectHeader(String.format("%s:%s,%s:%s", channelId, ssrc, sipConfig.getId(), 0));
|
| | | SubjectHeader subjectHeader = sipLayer.getSipFactory().createHeaderFactory().createSubjectHeader(String.format("%s:%s,%s:%s", channelId, ssrc, sipConfig.getId(), 0));
|
| | | request.addHeader(subjectHeader);
|
| | | ContentTypeHeader contentTypeHeader = sipFactory.createHeaderFactory().createContentTypeHeader("APPLICATION", "SDP");
|
| | | ContentTypeHeader contentTypeHeader = sipLayer.getSipFactory().createHeaderFactory().createContentTypeHeader("APPLICATION", "SDP");
|
| | | request.setContent(content, contentTypeHeader);
|
| | | return request;
|
| | | }
|
| | |
| | | public Request createPlaybackInviteRequest(Device device, String channelId, String content, String viaTag, String fromTag, String toTag, CallIdHeader callIdHeader, String ssrc) throws ParseException, InvalidArgumentException, PeerUnavailableException {
|
| | | Request request = null;
|
| | | //请求行
|
| | | SipURI requestLine = sipFactory.createAddressFactory().createSipURI(channelId, device.getHostAddress());
|
| | | SipURI requestLine = sipLayer.getSipFactory().createAddressFactory().createSipURI(channelId, device.getHostAddress());
|
| | | // via
|
| | | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();
|
| | | ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(sipConfig.getIp(), sipConfig.getPort(), device.getTransport(), viaTag);
|
| | | ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(sipLayer.getLocalIp(device.getLocalIp()), sipConfig.getPort(), device.getTransport(), viaTag);
|
| | | viaHeader.setRPort();
|
| | | viaHeaders.add(viaHeader);
|
| | | //from
|
| | | SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getDomain());
|
| | | Address fromAddress = sipFactory.createAddressFactory().createAddress(fromSipURI);
|
| | | FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, fromTag); //必须要有标记,否则无法创建会话,无法回应ack
|
| | | SipURI fromSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getDomain());
|
| | | Address fromAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(fromSipURI);
|
| | | FromHeader fromHeader = sipLayer.getSipFactory().createHeaderFactory().createFromHeader(fromAddress, fromTag); //必须要有标记,否则无法创建会话,无法回应ack
|
| | | //to
|
| | | SipURI toSipURI = sipFactory.createAddressFactory().createSipURI(channelId, device.getHostAddress());
|
| | | Address toAddress = sipFactory.createAddressFactory().createAddress(toSipURI);
|
| | | ToHeader toHeader = sipFactory.createHeaderFactory().createToHeader(toAddress,null);
|
| | | SipURI toSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(channelId, device.getHostAddress());
|
| | | Address toAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(toSipURI);
|
| | | ToHeader toHeader = sipLayer.getSipFactory().createHeaderFactory().createToHeader(toAddress,null);
|
| | |
|
| | | //Forwards
|
| | | MaxForwardsHeader maxForwards = sipFactory.createHeaderFactory().createMaxForwardsHeader(70);
|
| | | MaxForwardsHeader maxForwards = sipLayer.getSipFactory().createHeaderFactory().createMaxForwardsHeader(70);
|
| | |
|
| | | //ceq
|
| | | CSeqHeader cSeqHeader = sipFactory.createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.INVITE);
|
| | | request = sipFactory.createMessageFactory().createRequest(requestLine, Request.INVITE, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards);
|
| | | CSeqHeader cSeqHeader = sipLayer.getSipFactory().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.INVITE);
|
| | | request = sipLayer.getSipFactory().createMessageFactory().createRequest(requestLine, Request.INVITE, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards);
|
| | |
|
| | | Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getIp()+":"+sipConfig.getPort()));
|
| | | // Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), device.getHost().getIp()+":"+device.getHost().getPort()));
|
| | | request.addHeader(sipFactory.createHeaderFactory().createContactHeader(concatAddress));
|
| | | Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), sipLayer.getLocalIp(device.getLocalIp())+":"+sipConfig.getPort()));
|
| | | // Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), device.getHost().getIp()+":"+device.getHost().getPort()));
|
| | | request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress));
|
| | |
|
| | | request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil));
|
| | | request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil));
|
| | |
|
| | | // Subject
|
| | | SubjectHeader subjectHeader = sipFactory.createHeaderFactory().createSubjectHeader(String.format("%s:%s,%s:%s", channelId, ssrc, sipConfig.getId(), 0));
|
| | | SubjectHeader subjectHeader = sipLayer.getSipFactory().createHeaderFactory().createSubjectHeader(String.format("%s:%s,%s:%s", channelId, ssrc, sipConfig.getId(), 0));
|
| | | request.addHeader(subjectHeader);
|
| | |
|
| | | ContentTypeHeader contentTypeHeader = sipFactory.createHeaderFactory().createContentTypeHeader("APPLICATION", "SDP");
|
| | | ContentTypeHeader contentTypeHeader = sipLayer.getSipFactory().createHeaderFactory().createContentTypeHeader("APPLICATION", "SDP");
|
| | | request.setContent(content, contentTypeHeader);
|
| | | return request;
|
| | | }
|
| | |
| | | public Request createByteRequest(Device device, String channelId, SipTransactionInfo transactionInfo) throws ParseException, InvalidArgumentException, PeerUnavailableException {
|
| | | Request request = null;
|
| | | //请求行
|
| | | SipURI requestLine = sipFactory.createAddressFactory().createSipURI(channelId, device.getHostAddress());
|
| | | SipURI requestLine = sipLayer.getSipFactory().createAddressFactory().createSipURI(channelId, device.getHostAddress());
|
| | | // via
|
| | | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();
|
| | | ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(sipConfig.getIp(), sipConfig.getPort(), device.getTransport(), SipUtils.getNewViaTag());
|
| | | ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(sipLayer.getLocalIp(device.getLocalIp()), sipConfig.getPort(), device.getTransport(), SipUtils.getNewViaTag());
|
| | | viaHeaders.add(viaHeader);
|
| | | //from
|
| | | SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(sipConfig.getId(),sipConfig.getDomain());
|
| | | Address fromAddress = sipFactory.createAddressFactory().createAddress(fromSipURI);
|
| | | FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, transactionInfo.getFromTag());
|
| | | SipURI fromSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(),sipConfig.getDomain());
|
| | | Address fromAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(fromSipURI);
|
| | | FromHeader fromHeader = sipLayer.getSipFactory().createHeaderFactory().createFromHeader(fromAddress, transactionInfo.getFromTag());
|
| | | //to
|
| | | SipURI toSipURI = sipFactory.createAddressFactory().createSipURI(channelId,device.getHostAddress());
|
| | | Address toAddress = sipFactory.createAddressFactory().createAddress(toSipURI);
|
| | | ToHeader toHeader = sipFactory.createHeaderFactory().createToHeader(toAddress, transactionInfo.getToTag());
|
| | | SipURI toSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(channelId,device.getHostAddress());
|
| | | Address toAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(toSipURI);
|
| | | ToHeader toHeader = sipLayer.getSipFactory().createHeaderFactory().createToHeader(toAddress, transactionInfo.getToTag());
|
| | |
|
| | | //Forwards
|
| | | MaxForwardsHeader maxForwards = sipFactory.createHeaderFactory().createMaxForwardsHeader(70);
|
| | | MaxForwardsHeader maxForwards = sipLayer.getSipFactory().createHeaderFactory().createMaxForwardsHeader(70);
|
| | |
|
| | | //ceq
|
| | | CSeqHeader cSeqHeader = sipFactory.createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.BYE);
|
| | | CallIdHeader callIdHeader = sipFactory.createHeaderFactory().createCallIdHeader(transactionInfo.getCallId());
|
| | | request = sipFactory.createMessageFactory().createRequest(requestLine, Request.BYE, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards);
|
| | | CSeqHeader cSeqHeader = sipLayer.getSipFactory().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.BYE);
|
| | | CallIdHeader callIdHeader = sipLayer.getSipFactory().createHeaderFactory().createCallIdHeader(transactionInfo.getCallId());
|
| | | request = sipLayer.getSipFactory().createMessageFactory().createRequest(requestLine, Request.BYE, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards);
|
| | |
|
| | | request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil));
|
| | | request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil));
|
| | |
|
| | | Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getIp()+":"+sipConfig.getPort()));
|
| | | request.addHeader(sipFactory.createHeaderFactory().createContactHeader(concatAddress));
|
| | | Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), sipLayer.getLocalIp(device.getLocalIp())+":"+sipConfig.getPort()));
|
| | | request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress));
|
| | |
|
| | | request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil));
|
| | | request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil));
|
| | |
|
| | | return request;
|
| | | }
|
| | |
| | | public Request createSubscribeRequest(Device device, String content, SIPRequest requestOld, Integer expires, String event, CallIdHeader callIdHeader) throws ParseException, InvalidArgumentException, PeerUnavailableException {
|
| | | Request request = null;
|
| | | // sipuri
|
| | | SipURI requestURI = sipFactory.createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress());
|
| | | SipURI requestURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress());
|
| | | // via
|
| | | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();
|
| | | ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(sipConfig.getIp(), sipConfig.getPort(),
|
| | | ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(sipLayer.getLocalIp(device.getLocalIp()), sipConfig.getPort(),
|
| | | device.getTransport(), SipUtils.getNewViaTag());
|
| | | viaHeader.setRPort();
|
| | | viaHeaders.add(viaHeader);
|
| | | // from
|
| | | SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getDomain());
|
| | | Address fromAddress = sipFactory.createAddressFactory().createAddress(fromSipURI);
|
| | | FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, requestOld == null ? SipUtils.getNewFromTag() :requestOld.getFromTag());
|
| | | SipURI fromSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getDomain());
|
| | | Address fromAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(fromSipURI);
|
| | | FromHeader fromHeader = sipLayer.getSipFactory().createHeaderFactory().createFromHeader(fromAddress, requestOld == null ? SipUtils.getNewFromTag() :requestOld.getFromTag());
|
| | | // to
|
| | | SipURI toSipURI = sipFactory.createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress());
|
| | | Address toAddress = sipFactory.createAddressFactory().createAddress(toSipURI);
|
| | | ToHeader toHeader = sipFactory.createHeaderFactory().createToHeader(toAddress, requestOld == null ? null :requestOld.getToTag());
|
| | | SipURI toSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress());
|
| | | Address toAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(toSipURI);
|
| | | ToHeader toHeader = sipLayer.getSipFactory().createHeaderFactory().createToHeader(toAddress, requestOld == null ? null :requestOld.getToTag());
|
| | |
|
| | | // Forwards
|
| | | MaxForwardsHeader maxForwards = sipFactory.createHeaderFactory().createMaxForwardsHeader(70);
|
| | | MaxForwardsHeader maxForwards = sipLayer.getSipFactory().createHeaderFactory().createMaxForwardsHeader(70);
|
| | |
|
| | | // ceq
|
| | | CSeqHeader cSeqHeader = sipFactory.createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.SUBSCRIBE);
|
| | | CSeqHeader cSeqHeader = sipLayer.getSipFactory().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.SUBSCRIBE);
|
| | |
|
| | | request = sipFactory.createMessageFactory().createRequest(requestURI, Request.SUBSCRIBE, callIdHeader, cSeqHeader, fromHeader,
|
| | | request = sipLayer.getSipFactory().createMessageFactory().createRequest(requestURI, Request.SUBSCRIBE, callIdHeader, cSeqHeader, fromHeader,
|
| | | toHeader, viaHeaders, maxForwards);
|
| | |
|
| | |
|
| | | Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getIp()+":"+sipConfig.getPort()));
|
| | | request.addHeader(sipFactory.createHeaderFactory().createContactHeader(concatAddress));
|
| | | Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), sipLayer.getLocalIp(device.getLocalIp())+":"+sipConfig.getPort()));
|
| | | request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress));
|
| | |
|
| | | // Expires
|
| | | ExpiresHeader expireHeader = sipFactory.createHeaderFactory().createExpiresHeader(expires);
|
| | | ExpiresHeader expireHeader = sipLayer.getSipFactory().createHeaderFactory().createExpiresHeader(expires);
|
| | | request.addHeader(expireHeader);
|
| | |
|
| | | // Event
|
| | | EventHeader eventHeader = sipFactory.createHeaderFactory().createEventHeader(event);
|
| | | EventHeader eventHeader = sipLayer.getSipFactory().createHeaderFactory().createEventHeader(event);
|
| | |
|
| | | int random = (int) Math.floor(Math.random() * 10000);
|
| | | eventHeader.setEventId(random + "");
|
| | | request.addHeader(eventHeader);
|
| | |
|
| | | ContentTypeHeader contentTypeHeader = sipFactory.createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml");
|
| | | ContentTypeHeader contentTypeHeader = sipLayer.getSipFactory().createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml");
|
| | | request.setContent(content, contentTypeHeader);
|
| | |
|
| | | request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil));
|
| | | request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil));
|
| | |
|
| | | return request;
|
| | | }
|
| | |
| | | }
|
| | | SIPRequest request = null;
|
| | | //请求行
|
| | | SipURI requestLine = sipFactory.createAddressFactory().createSipURI(channelId, device.getHostAddress());
|
| | | SipURI requestLine = sipLayer.getSipFactory().createAddressFactory().createSipURI(channelId, device.getHostAddress());
|
| | | // via
|
| | | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();
|
| | | ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(sipConfig.getIp(), sipConfig.getPort(), device.getTransport(), SipUtils.getNewViaTag());
|
| | | ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(sipLayer.getLocalIp(device.getLocalIp()), sipConfig.getPort(), device.getTransport(), SipUtils.getNewViaTag());
|
| | | viaHeaders.add(viaHeader);
|
| | | //from
|
| | | SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(sipConfig.getId(),sipConfig.getDomain());
|
| | | Address fromAddress = sipFactory.createAddressFactory().createAddress(fromSipURI);
|
| | | FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, transactionInfo.getFromTag());
|
| | | SipURI fromSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(),sipConfig.getDomain());
|
| | | Address fromAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(fromSipURI);
|
| | | FromHeader fromHeader = sipLayer.getSipFactory().createHeaderFactory().createFromHeader(fromAddress, transactionInfo.getFromTag());
|
| | | //to
|
| | | SipURI toSipURI = sipFactory.createAddressFactory().createSipURI(channelId,device.getHostAddress());
|
| | | Address toAddress = sipFactory.createAddressFactory().createAddress(toSipURI);
|
| | | ToHeader toHeader = sipFactory.createHeaderFactory().createToHeader(toAddress, transactionInfo.getToTag());
|
| | | SipURI toSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(channelId,device.getHostAddress());
|
| | | Address toAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(toSipURI);
|
| | | ToHeader toHeader = sipLayer.getSipFactory().createHeaderFactory().createToHeader(toAddress, transactionInfo.getToTag());
|
| | |
|
| | | //Forwards
|
| | | MaxForwardsHeader maxForwards = sipFactory.createHeaderFactory().createMaxForwardsHeader(70);
|
| | | MaxForwardsHeader maxForwards = sipLayer.getSipFactory().createHeaderFactory().createMaxForwardsHeader(70);
|
| | |
|
| | | //ceq
|
| | | CSeqHeader cSeqHeader = sipFactory.createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.INFO);
|
| | | CallIdHeader callIdHeader = sipFactory.createHeaderFactory().createCallIdHeader(transactionInfo.getCallId());
|
| | | request = (SIPRequest)sipFactory.createMessageFactory().createRequest(requestLine, Request.INFO, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards);
|
| | | CSeqHeader cSeqHeader = sipLayer.getSipFactory().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.INFO);
|
| | | CallIdHeader callIdHeader = sipLayer.getSipFactory().createHeaderFactory().createCallIdHeader(transactionInfo.getCallId());
|
| | | request = (SIPRequest)sipLayer.getSipFactory().createMessageFactory().createRequest(requestLine, Request.INFO, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards);
|
| | |
|
| | | request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil));
|
| | | request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil));
|
| | |
|
| | | Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getIp()+":"+sipConfig.getPort()));
|
| | | request.addHeader(sipFactory.createHeaderFactory().createContactHeader(concatAddress));
|
| | | Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), sipLayer.getLocalIp(device.getLocalIp())+":"+sipConfig.getPort()));
|
| | | request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress));
|
| | |
|
| | | request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil));
|
| | | request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil));
|
| | |
|
| | | if (content != null) {
|
| | | ContentTypeHeader contentTypeHeader = sipFactory.createHeaderFactory().createContentTypeHeader("Application",
|
| | | ContentTypeHeader contentTypeHeader = sipLayer.getSipFactory().createHeaderFactory().createContentTypeHeader("Application",
|
| | | "MANSRTSP");
|
| | | request.setContent(content, contentTypeHeader);
|
| | | }
|
| | | return request;
|
| | | }
|
| | |
|
| | | public Request createAckRequest(SipURI sipURI, SIPResponse sipResponse) throws ParseException, InvalidArgumentException, PeerUnavailableException {
|
| | | public Request createAckRequest(String localIp, SipURI sipURI, SIPResponse sipResponse) throws ParseException, InvalidArgumentException, PeerUnavailableException {
|
| | |
|
| | |
|
| | | // via
|
| | | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();
|
| | | ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(sipConfig.getIp(), sipConfig.getPort(), sipResponse.getTopmostViaHeader().getTransport(), SipUtils.getNewViaTag());
|
| | | ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(localIp, sipConfig.getPort(), sipResponse.getTopmostViaHeader().getTransport(), SipUtils.getNewViaTag());
|
| | | viaHeaders.add(viaHeader);
|
| | |
|
| | | //Forwards
|
| | | MaxForwardsHeader maxForwards = sipFactory.createHeaderFactory().createMaxForwardsHeader(70);
|
| | | MaxForwardsHeader maxForwards = sipLayer.getSipFactory().createHeaderFactory().createMaxForwardsHeader(70);
|
| | |
|
| | | //ceq
|
| | | CSeqHeader cSeqHeader = sipFactory.createHeaderFactory().createCSeqHeader(sipResponse.getCSeqHeader().getSeqNumber(), Request.ACK);
|
| | | CSeqHeader cSeqHeader = sipLayer.getSipFactory().createHeaderFactory().createCSeqHeader(sipResponse.getCSeqHeader().getSeqNumber(), Request.ACK);
|
| | |
|
| | | Request request = sipFactory.createMessageFactory().createRequest(sipURI, Request.ACK, sipResponse.getCallIdHeader(), cSeqHeader, sipResponse.getFromHeader(), sipResponse.getToHeader(), viaHeaders, maxForwards);
|
| | | Request request = sipLayer.getSipFactory().createMessageFactory().createRequest(sipURI, Request.ACK, sipResponse.getCallIdHeader(), cSeqHeader, sipResponse.getFromHeader(), sipResponse.getToHeader(), viaHeaders, maxForwards);
|
| | |
|
| | | request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil));
|
| | | request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil));
|
| | |
|
| | | Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getIp()+":"+sipConfig.getPort()));
|
| | | request.addHeader(sipFactory.createHeaderFactory().createContactHeader(concatAddress));
|
| | | Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), localIp + ":"+sipConfig.getPort()));
|
| | | request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress));
|
| | |
|
| | | request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil));
|
| | | request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil));
|
| | |
|
| | | return request;
|
| | | }
|
| | |
| | | import com.genersoft.iot.vmp.conf.SipConfig;
|
| | | import com.genersoft.iot.vmp.conf.UserSetting;
|
| | | import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException;
|
| | | import com.genersoft.iot.vmp.gb28181.SipLayer;
|
| | | import com.genersoft.iot.vmp.gb28181.bean.*;
|
| | | import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
|
| | | import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
|
| | |
| | | import javax.sip.InvalidArgumentException;
|
| | | import javax.sip.ResponseEvent;
|
| | | import javax.sip.SipException;
|
| | | import javax.sip.SipFactory;
|
| | | import javax.sip.header.CallIdHeader;
|
| | | import javax.sip.message.Request;
|
| | | import java.text.ParseException;
|
| | |
| | | private SipConfig sipConfig;
|
| | |
|
| | | @Autowired
|
| | | private SipFactory sipFactory;
|
| | | private SipLayer sipLayer;
|
| | |
|
| | | @Autowired
|
| | | private SIPSender sipSender;
|
| | |
| | | ptzXml.append("</Info>\r\n");
|
| | | ptzXml.append("</Control>\r\n");
|
| | |
|
| | | Request request = headerProvider.createMessageRequest(device, ptzXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null, sipSender.getNewCallIdHeader(device.getTransport()));
|
| | | Request request = headerProvider.createMessageRequest(device, ptzXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null, sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()));
|
| | |
|
| | | sipSender.transmitRequest( request);
|
| | | sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()),request);
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | |
|
| | |
|
| | |
|
| | | SIPRequest request = (SIPRequest) headerProvider.createMessageRequest(device, ptzXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport()));
|
| | | sipSender.transmitRequest(request);
|
| | | SIPRequest request = (SIPRequest) headerProvider.createMessageRequest(device, ptzXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()));
|
| | | sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()),request);
|
| | |
|
| | | }
|
| | |
|
| | |
| | | ptzXml.append("</Control>\r\n");
|
| | |
|
| | |
|
| | | Request request = headerProvider.createMessageRequest(device, ptzXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport()));
|
| | | sipSender.transmitRequest(request, errorEvent, okEvent);
|
| | | Request request = headerProvider.createMessageRequest(device, ptzXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()));
|
| | | sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()),request, errorEvent, okEvent);
|
| | |
|
| | | }
|
| | |
|
| | |
| | |
|
| | |
|
| | |
|
| | | Request request = headerProvider.createInviteRequest(device, channelId, content.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null, ssrcInfo.getSsrc(),sipSender.getNewCallIdHeader(device.getTransport()));
|
| | | sipSender.transmitRequest( request, (e -> {
|
| | | Request request = headerProvider.createInviteRequest(device, channelId, content.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null, ssrcInfo.getSsrc(),sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()));
|
| | | sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, (e -> {
|
| | | streamSession.remove(device.getDeviceId(), channelId, ssrcInfo.getStream());
|
| | | mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcInfo.getSsrc());
|
| | | errorEvent.response(e);
|
| | |
| | | content.append("a=rtpmap:97 MPEG4/90000\r\n");
|
| | | content.append("a=rtpmap:98 H264/90000\r\n");
|
| | | content.append("a=rtpmap:99 H265/90000\r\n");
|
| | | if ("TCP-PASSIVE".equalsIgnoreCase(streamMode)) { // tcp被动模式
|
| | | if ("TCP-PASSIVE".equalsIgnoreCase(streamMode)) {
|
| | | // tcp被动模式
|
| | | content.append("a=setup:passive\r\n");
|
| | | content.append("a=connection:new\r\n");
|
| | | } else if ("TCP-ACTIVE".equalsIgnoreCase(streamMode)) { // tcp主动模式
|
| | | } else if ("TCP-ACTIVE".equalsIgnoreCase(streamMode)) {
|
| | | // tcp主动模式
|
| | | content.append("a=setup:active\r\n");
|
| | | content.append("a=connection:new\r\n");
|
| | | }
|
| | | }
|
| | |
|
| | | content.append("y=" + ssrcInfo.getSsrc() + "\r\n");//ssrc
|
| | | //ssrc
|
| | | content.append("y=" + ssrcInfo.getSsrc() + "\r\n");
|
| | |
|
| | | HookSubscribeForStreamChange hookSubscribe = HookSubscribeFactory.on_stream_changed("rtp", ssrcInfo.getStream(), true, "rtsp", mediaServerItem.getId());
|
| | | // 添加订阅
|
| | | subscribe.addSubscribe(hookSubscribe, (MediaServerItem mediaServerItemInUse, JSONObject json) -> {
|
| | | if (hookEvent != null) {
|
| | | InviteStreamInfo inviteStreamInfo = new InviteStreamInfo(mediaServerItemInUse, json,sipSender.getNewCallIdHeader(device.getTransport()).getCallId(), "rtp", ssrcInfo.getStream());
|
| | | InviteStreamInfo inviteStreamInfo = new InviteStreamInfo(mediaServerItemInUse, json,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()).getCallId(), "rtp", ssrcInfo.getStream());
|
| | | hookEvent.call(inviteStreamInfo);
|
| | | }
|
| | | subscribe.removeSubscribe(hookSubscribe);
|
| | | });
|
| | | Request request = headerProvider.createPlaybackInviteRequest(device, channelId, content.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport()), ssrcInfo.getSsrc());
|
| | | Request request = headerProvider.createPlaybackInviteRequest(device, channelId, content.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()), ssrcInfo.getSsrc());
|
| | |
|
| | | sipSender.transmitRequest( request, errorEvent, event -> {
|
| | | sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent, event -> {
|
| | | ResponseEvent responseEvent = (ResponseEvent) event.event;
|
| | | SIPResponse response = (SIPResponse) responseEvent.getResponse();
|
| | | streamSession.put(device.getDeviceId(), channelId,sipSender.getNewCallIdHeader(device.getTransport()).getCallId(), ssrcInfo.getStream(), ssrcInfo.getSsrc(), mediaServerItem.getId(), response, VideoStreamSessionManager.SessionType.playback);
|
| | | streamSession.put(device.getDeviceId(), channelId,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()).getCallId(), ssrcInfo.getStream(), ssrcInfo.getSsrc(), mediaServerItem.getId(), response, VideoStreamSessionManager.SessionType.playback);
|
| | | okEvent.response(event);
|
| | | });
|
| | | if (inviteStreamCallback != null) {
|
| | | inviteStreamCallback.call(new InviteStreamInfo(mediaServerItem, null,sipSender.getNewCallIdHeader(device.getTransport()).getCallId(), "rtp", ssrcInfo.getStream()));
|
| | | inviteStreamCallback.call(new InviteStreamInfo(mediaServerItem, null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()).getCallId(), "rtp", ssrcInfo.getStream()));
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | HookSubscribeForStreamChange hookSubscribe = HookSubscribeFactory.on_stream_changed("rtp", ssrcInfo.getStream(), true, null, mediaServerItem.getId());
|
| | | // 添加订阅
|
| | | subscribe.addSubscribe(hookSubscribe, (MediaServerItem mediaServerItemInUse, JSONObject json) -> {
|
| | | hookEvent.call(new InviteStreamInfo(mediaServerItem, json,sipSender.getNewCallIdHeader(device.getTransport()).getCallId(), "rtp", ssrcInfo.getStream()));
|
| | | hookEvent.call(new InviteStreamInfo(mediaServerItem, json,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()).getCallId(), "rtp", ssrcInfo.getStream()));
|
| | | subscribe.removeSubscribe(hookSubscribe);
|
| | | hookSubscribe.getContent().put("regist", false);
|
| | | hookSubscribe.getContent().put("schema", "rtsp");
|
| | |
| | | (MediaServerItem mediaServerItemForEnd, JSONObject jsonForEnd) -> {
|
| | | logger.info("[录像]下载结束, 发送BYE");
|
| | | try {
|
| | | streamByeCmd(device, channelId, ssrcInfo.getStream(),sipSender.getNewCallIdHeader(device.getTransport()).getCallId());
|
| | | streamByeCmd(device, channelId, ssrcInfo.getStream(),sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()).getCallId());
|
| | | } catch (InvalidArgumentException | ParseException | SipException |
|
| | | SsrcTransactionNotFoundException e) {
|
| | | logger.error("[录像]下载结束, 发送BYE失败 {}", e.getMessage());
|
| | |
| | | });
|
| | | });
|
| | |
|
| | | Request request = headerProvider.createPlaybackInviteRequest(device, channelId, content.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport()), ssrcInfo.getSsrc());
|
| | | Request request = headerProvider.createPlaybackInviteRequest(device, channelId, content.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()), ssrcInfo.getSsrc());
|
| | | if (inviteStreamCallback != null) {
|
| | | inviteStreamCallback.call(new InviteStreamInfo(mediaServerItem, null,sipSender.getNewCallIdHeader(device.getTransport()).getCallId(), "rtp", ssrcInfo.getStream()));
|
| | | inviteStreamCallback.call(new InviteStreamInfo(mediaServerItem, null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()).getCallId(), "rtp", ssrcInfo.getStream()));
|
| | | }
|
| | | sipSender.transmitRequest( request, errorEvent, okEvent -> {
|
| | | sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent, okEvent -> {
|
| | | ResponseEvent responseEvent = (ResponseEvent) okEvent.event;
|
| | | SIPResponse response = (SIPResponse) responseEvent.getResponse();
|
| | | streamSession.put(device.getDeviceId(), channelId,sipSender.getNewCallIdHeader(device.getTransport()).getCallId(), ssrcInfo.getStream(), ssrcInfo.getSsrc(), mediaServerItem.getId(), response, VideoStreamSessionManager.SessionType.download);
|
| | | streamSession.put(device.getDeviceId(), channelId,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()).getCallId(), ssrcInfo.getStream(), ssrcInfo.getSsrc(), mediaServerItem.getId(), response, VideoStreamSessionManager.SessionType.download);
|
| | | });
|
| | | }
|
| | |
|
| | |
| | | streamSession.remove(ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId(), ssrcTransaction.getStream());
|
| | |
|
| | | Request byteRequest = headerProvider.createByteRequest(device, channelId, ssrcTransaction.getSipTransactionInfo());
|
| | | sipSender.transmitRequest( byteRequest, null, okEvent);
|
| | | sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), byteRequest, null, okEvent);
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | |
|
| | |
|
| | |
|
| | | Request request = headerProvider.createMessageRequest(device, broadcastXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport()));
|
| | | sipSender.transmitRequest( request);
|
| | | Request request = headerProvider.createMessageRequest(device, broadcastXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()));
|
| | | sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request);
|
| | |
|
| | | }
|
| | |
|
| | |
| | |
|
| | |
|
| | |
|
| | | Request request = headerProvider.createMessageRequest(device, broadcastXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport()));
|
| | | sipSender.transmitRequest( request, errorEvent);
|
| | | Request request = headerProvider.createMessageRequest(device, broadcastXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()));
|
| | | sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent);
|
| | |
|
| | | }
|
| | |
|
| | |
| | |
|
| | |
|
| | |
|
| | | Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport()));
|
| | | sipSender.transmitRequest( request, errorEvent);
|
| | | Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()));
|
| | | sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent);
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | |
|
| | |
|
| | |
|
| | | Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport()));
|
| | | sipSender.transmitRequest( request);
|
| | | Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()));
|
| | | sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request);
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | |
|
| | |
|
| | |
|
| | | Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport()));
|
| | | sipSender.transmitRequest( request, errorEvent);
|
| | | Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()));
|
| | | sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent);
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | |
|
| | |
|
| | |
|
| | | Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport()));
|
| | | sipSender.transmitRequest( request, errorEvent);
|
| | | Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()));
|
| | | sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent);
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | |
|
| | |
|
| | |
|
| | | Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport()));
|
| | | sipSender.transmitRequest( request);
|
| | | Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()));
|
| | | sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request);
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | |
|
| | |
|
| | |
|
| | | Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport()));
|
| | | sipSender.transmitRequest( request, errorEvent);
|
| | | Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()));
|
| | | sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent);
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | |
|
| | |
|
| | |
|
| | | Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport()));
|
| | | sipSender.transmitRequest( request, errorEvent);
|
| | | Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()));
|
| | | sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent);
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | |
|
| | |
|
| | |
|
| | | Request request = headerProvider.createMessageRequest(device, catalogXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport()));
|
| | | Request request = headerProvider.createMessageRequest(device, catalogXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()));
|
| | |
|
| | | sipSender.transmitRequest( request, errorEvent);
|
| | | sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent);
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | |
|
| | |
|
| | |
|
| | | Request request = headerProvider.createMessageRequest(device, catalogXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport()));
|
| | | Request request = headerProvider.createMessageRequest(device, catalogXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()));
|
| | |
|
| | | sipSender.transmitRequest( request);
|
| | | sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request);
|
| | |
|
| | | }
|
| | |
|
| | |
| | |
|
| | |
|
| | |
|
| | | Request request = headerProvider.createMessageRequest(device, catalogXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport()));
|
| | | Request request = headerProvider.createMessageRequest(device, catalogXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()));
|
| | |
|
| | | sipSender.transmitRequest( request, errorEvent);
|
| | | sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent);
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | |
|
| | |
|
| | | Request request = headerProvider.createMessageRequest(device, recordInfoXml.toString(),
|
| | | SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport()));
|
| | | SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()));
|
| | |
|
| | | sipSender.transmitRequest( request, errorEvent, okEvent);
|
| | | sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent, okEvent);
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | |
|
| | |
|
| | |
|
| | | Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport()));
|
| | | sipSender.transmitRequest( request, errorEvent);
|
| | | Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()));
|
| | | sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent);
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | |
|
| | |
|
| | |
|
| | | Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport()));
|
| | | sipSender.transmitRequest( request, errorEvent);
|
| | | Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()));
|
| | | sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent);
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | |
|
| | |
|
| | |
|
| | | Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport()));
|
| | | sipSender.transmitRequest( request, errorEvent);
|
| | | Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()));
|
| | | sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent);
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | |
|
| | |
|
| | |
|
| | | Request request = headerProvider.createMessageRequest(device, mobilePostitionXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport()));
|
| | | Request request = headerProvider.createMessageRequest(device, mobilePostitionXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()));
|
| | |
|
| | | sipSender.transmitRequest( request, errorEvent);
|
| | | sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent);
|
| | |
|
| | | }
|
| | |
|
| | |
| | | CallIdHeader callIdHeader;
|
| | |
|
| | | if (requestOld != null) {
|
| | | callIdHeader = sipFactory.createHeaderFactory().createCallIdHeader(requestOld.getCallIdHeader().getCallId());
|
| | | callIdHeader = sipLayer.getSipFactory().createHeaderFactory().createCallIdHeader(requestOld.getCallIdHeader().getCallId());
|
| | | } else {
|
| | | callIdHeader = sipSender.getNewCallIdHeader(device.getTransport());
|
| | | callIdHeader = sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport());
|
| | | }
|
| | | SIPRequest request = (SIPRequest) headerProvider.createSubscribeRequest(device, subscribePostitionXml.toString(), requestOld, device.getSubscribeCycleForMobilePosition(), "presence",callIdHeader); //Position;id=" + tm.substring(tm.length() - 4));
|
| | |
|
| | | sipSender.transmitRequest( request, errorEvent, okEvent);
|
| | | sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent, okEvent);
|
| | | return request;
|
| | | }
|
| | |
|
| | |
| | |
|
| | |
|
| | |
|
| | | Request request = headerProvider.createSubscribeRequest(device, cmdXml.toString(), null, expires, "presence",sipSender.getNewCallIdHeader(device.getTransport()));
|
| | | sipSender.transmitRequest( request);
|
| | | Request request = headerProvider.createSubscribeRequest(device, cmdXml.toString(), null, expires, "presence",sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()));
|
| | | sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request);
|
| | |
|
| | | }
|
| | |
|
| | |
| | | CallIdHeader callIdHeader;
|
| | |
|
| | | if (requestOld != null) {
|
| | | callIdHeader = sipFactory.createHeaderFactory().createCallIdHeader(requestOld.getCallIdHeader().getCallId());
|
| | | callIdHeader = sipLayer.getSipFactory().createHeaderFactory().createCallIdHeader(requestOld.getCallIdHeader().getCallId());
|
| | | } else {
|
| | | callIdHeader = sipSender.getNewCallIdHeader(device.getTransport());
|
| | | callIdHeader = sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport());
|
| | | }
|
| | |
|
| | | // 有效时间默认为60秒以上
|
| | | SIPRequest request = (SIPRequest) headerProvider.createSubscribeRequest(device, cmdXml.toString(), requestOld, device.getSubscribeCycleForCatalog(), "Catalog",
|
| | | callIdHeader);
|
| | | sipSender.transmitRequest( request, errorEvent, okEvent);
|
| | | sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent, okEvent);
|
| | | return request;
|
| | | }
|
| | |
|
| | |
| | | dragXml.append(cmdString);
|
| | | dragXml.append("</Control>\r\n");
|
| | |
|
| | | Request request = headerProvider.createMessageRequest(device, dragXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport()));
|
| | | Request request = headerProvider.createMessageRequest(device, dragXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()));
|
| | | logger.debug("拉框信令: " + request.toString());
|
| | | sipSender.transmitRequest(request);
|
| | | sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()),request);
|
| | | }
|
| | |
|
| | |
|
| | |
| | | return;
|
| | | }
|
| | |
|
| | | sipSender.transmitRequest( request, errorEvent, okEvent);
|
| | | sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent, okEvent);
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | deviceStatusXml.append("</Notify>\r\n");
|
| | |
|
| | |
|
| | | Request request = headerProvider.createMessageRequest(device, deviceStatusXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport()));
|
| | | sipSender.transmitRequest(request);
|
| | | Request request = headerProvider.createMessageRequest(device, deviceStatusXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()));
|
| | | sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()),request);
|
| | |
|
| | |
|
| | | }
|
| | |
| | | package com.genersoft.iot.vmp.gb28181.transmit.cmd.impl; |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.genersoft.iot.vmp.gb28181.SipLayer; |
| | | import com.genersoft.iot.vmp.gb28181.bean.*; |
| | | import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; |
| | | import com.genersoft.iot.vmp.gb28181.transmit.SIPSender; |
| | |
| | | private ZLMRTPServerFactory zlmrtpServerFactory; |
| | | |
| | | @Autowired |
| | | private SipFactory sipFactory; |
| | | private SipLayer sipLayer; |
| | | |
| | | @Autowired |
| | | private SIPSender sipSender; |
| | |
| | | SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent, boolean registerAgain, boolean isRegister) throws SipException, InvalidArgumentException, ParseException { |
| | | Request request; |
| | | if (!registerAgain ) { |
| | | CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getTransport()); |
| | | CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport()); |
| | | |
| | | request = headerProviderPlatformProvider.createRegisterRequest(parentPlatform, |
| | | redisCatchStorage.getCSEQ(), SipUtils.getNewFromTag(), |
| | |
| | | }); |
| | | |
| | | }else { |
| | | CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getTransport()); |
| | | CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport()); |
| | | request = headerProviderPlatformProvider.createRegisterRequest(parentPlatform, SipUtils.getNewFromTag(), null, callId, www, callIdHeader, isRegister); |
| | | } |
| | | |
| | | sipSender.transmitRequest( request, null, okEvent); |
| | | sipSender.transmitRequest(parentPlatform.getDeviceIp(), request, null, okEvent); |
| | | } |
| | | |
| | | @Override |
| | |
| | | keepaliveXml.append("<Status>OK</Status>\r\n"); |
| | | keepaliveXml.append("</Notify>\r\n"); |
| | | |
| | | CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getTransport()); |
| | | CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport()); |
| | | |
| | | Request request = headerProviderPlatformProvider.createMessageRequest( |
| | | parentPlatform, |
| | |
| | | SipUtils.getNewFromTag(), |
| | | SipUtils.getNewViaTag(), |
| | | callIdHeader); |
| | | sipSender.transmitRequest( request, errorEvent, okEvent); |
| | | sipSender.transmitRequest(parentPlatform.getDeviceIp(), request, errorEvent, okEvent); |
| | | return callIdHeader.getCallId(); |
| | | } |
| | | |
| | |
| | | String catalogXml = getCatalogXml(channels, sn, parentPlatform, size); |
| | | |
| | | // callid |
| | | CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getTransport()); |
| | | CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport()); |
| | | |
| | | Request request = headerProviderPlatformProvider.createMessageRequest(parentPlatform, catalogXml.toString(), fromTag, SipUtils.getNewViaTag(), callIdHeader); |
| | | sipSender.transmitRequest( request); |
| | | sipSender.transmitRequest(parentPlatform.getDeviceIp(), request); |
| | | |
| | | } |
| | | |
| | |
| | | } |
| | | String catalogXml = getCatalogXml(deviceChannels, sn, parentPlatform, channels.size()); |
| | | // callid |
| | | CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getTransport()); |
| | | CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport()); |
| | | |
| | | Request request = headerProviderPlatformProvider.createMessageRequest(parentPlatform, catalogXml, fromTag, SipUtils.getNewViaTag(), callIdHeader); |
| | | sipSender.transmitRequest( request, null, eventResult -> { |
| | | sipSender.transmitRequest(parentPlatform.getDeviceIp(), request, null, eventResult -> { |
| | | int indexNext = index + parentPlatform.getCatalogGroup(); |
| | | try { |
| | | sendCatalogResponse(channels, parentPlatform, sn, fromTag, indexNext); |
| | |
| | | deviceInfoXml.append("<Result>OK</Result>\r\n"); |
| | | deviceInfoXml.append("</Response>\r\n"); |
| | | |
| | | CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getTransport()); |
| | | CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport()); |
| | | |
| | | Request request = headerProviderPlatformProvider.createMessageRequest(parentPlatform, deviceInfoXml.toString(), fromTag, SipUtils.getNewViaTag(), callIdHeader); |
| | | sipSender.transmitRequest( request); |
| | | sipSender.transmitRequest(parentPlatform.getDeviceIp(), request); |
| | | } |
| | | |
| | | /** |
| | |
| | | deviceStatusXml.append("<Status>OK</Status>\r\n"); |
| | | deviceStatusXml.append("</Response>\r\n"); |
| | | |
| | | CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getTransport()); |
| | | CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport()); |
| | | |
| | | Request request = headerProviderPlatformProvider.createMessageRequest(parentPlatform, deviceStatusXml.toString(), fromTag, SipUtils.getNewViaTag(), callIdHeader); |
| | | sipSender.transmitRequest( request); |
| | | sipSender.transmitRequest(parentPlatform.getDeviceIp(), request); |
| | | |
| | | } |
| | | |
| | |
| | | deviceStatusXml.append("</info>\r\n"); |
| | | deviceStatusXml.append("</Notify>\r\n"); |
| | | |
| | | CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getTransport()); |
| | | CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport()); |
| | | |
| | | Request request = headerProviderPlatformProvider.createMessageRequest(parentPlatform, deviceStatusXml.toString(), SipUtils.getNewFromTag(), SipUtils.getNewViaTag(), callIdHeader); |
| | | sipSender.transmitRequest( request); |
| | | sipSender.transmitRequest(parentPlatform.getDeviceIp(), request); |
| | | |
| | | } |
| | | |
| | |
| | | private void sendNotify(ParentPlatform parentPlatform, String catalogXmlContent, |
| | | SubscribeInfo subscribeInfo, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent ) |
| | | throws SipException, ParseException, InvalidArgumentException { |
| | | MessageFactoryImpl messageFactory = (MessageFactoryImpl) sipFactory.createMessageFactory(); |
| | | MessageFactoryImpl messageFactory = (MessageFactoryImpl) sipLayer.getSipFactory().createMessageFactory(); |
| | | String characterSet = parentPlatform.getCharacterSet(); |
| | | // 设置编码, 防止中文乱码 |
| | | messageFactory.setDefaultContentEncodingCharset(characterSet); |
| | | |
| | | SIPRequest notifyRequest = headerProviderPlatformProvider.createNotifyRequest(parentPlatform, catalogXmlContent, subscribeInfo); |
| | | |
| | | sipSender.transmitRequest( notifyRequest); |
| | | sipSender.transmitRequest(parentPlatform.getDeviceIp(), notifyRequest); |
| | | } |
| | | |
| | | private String getCatalogXmlContentForCatalogAddOrUpdate(ParentPlatform parentPlatform, List<DeviceChannel> channels, int sumNum, String type, SubscribeInfo subscribeInfo) { |
| | |
| | | recordXml.append("</Response>\r\n"); |
| | | |
| | | // callid |
| | | CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getTransport()); |
| | | CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport()); |
| | | |
| | | Request request = headerProviderPlatformProvider.createMessageRequest(parentPlatform, recordXml.toString(), fromTag, SipUtils.getNewViaTag(), callIdHeader); |
| | | sipSender.transmitRequest( request); |
| | | sipSender.transmitRequest(parentPlatform.getDeviceIp(), request); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void sendMediaStatusNotify(ParentPlatform platform, SendRtpItem sendRtpItem) throws SipException, InvalidArgumentException, ParseException { |
| | | if (sendRtpItem == null || platform == null) { |
| | | public void sendMediaStatusNotify(ParentPlatform parentPlatform, SendRtpItem sendRtpItem) throws SipException, InvalidArgumentException, ParseException { |
| | | if (sendRtpItem == null || parentPlatform == null) { |
| | | return; |
| | | } |
| | | |
| | | |
| | | String characterSet = platform.getCharacterSet(); |
| | | String characterSet = parentPlatform.getCharacterSet(); |
| | | StringBuffer mediaStatusXml = new StringBuffer(200); |
| | | mediaStatusXml.append("<?xml version=\"1.0\" encoding=\"" + characterSet + "\"?>\r\n"); |
| | | mediaStatusXml.append("<Notify>\r\n"); |
| | |
| | | mediaStatusXml.append("<NotifyType>121</NotifyType>\r\n"); |
| | | mediaStatusXml.append("</Notify>\r\n"); |
| | | |
| | | SIPRequest messageRequest = (SIPRequest)headerProviderPlatformProvider.createMessageRequest(platform, mediaStatusXml.toString(), |
| | | SIPRequest messageRequest = (SIPRequest)headerProviderPlatformProvider.createMessageRequest(parentPlatform, mediaStatusXml.toString(), |
| | | sendRtpItem); |
| | | |
| | | sipSender.transmitRequest(messageRequest); |
| | | sipSender.transmitRequest(parentPlatform.getDeviceIp(),messageRequest); |
| | | |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void streamByeCmd(ParentPlatform platform, SendRtpItem sendRtpItem) throws SipException, InvalidArgumentException, ParseException { |
| | | public void streamByeCmd(ParentPlatform parentPlatform, SendRtpItem sendRtpItem) throws SipException, InvalidArgumentException, ParseException { |
| | | if (sendRtpItem == null ) { |
| | | logger.info("[向上级发送BYE], sendRtpItem 为NULL"); |
| | | return; |
| | | } |
| | | if (platform == null) { |
| | | if (parentPlatform == null) { |
| | | logger.info("[向上级发送BYE], platform 为NULL"); |
| | | return; |
| | | } |
| | | logger.info("[向上级发送BYE], {}/{}", platform.getServerGBId(), sendRtpItem.getChannelId()); |
| | | logger.info("[向上级发送BYE], {}/{}", parentPlatform.getServerGBId(), sendRtpItem.getChannelId()); |
| | | String mediaServerId = sendRtpItem.getMediaServerId(); |
| | | MediaServerItem mediaServerItem = mediaServerService.getOne(mediaServerId); |
| | | if (mediaServerItem != null) { |
| | | mediaServerService.releaseSsrc(mediaServerItem.getId(), sendRtpItem.getSsrc()); |
| | | zlmrtpServerFactory.closeRtpServer(mediaServerItem, sendRtpItem.getStreamId()); |
| | | } |
| | | SIPRequest byeRequest = headerProviderPlatformProvider.createByeRequest(platform, sendRtpItem); |
| | | SIPRequest byeRequest = headerProviderPlatformProvider.createByeRequest(parentPlatform, sendRtpItem); |
| | | if (byeRequest == null) { |
| | | logger.warn("[向上级发送bye]:无法创建 byeRequest"); |
| | | } |
| | | sipSender.transmitRequest(byeRequest); |
| | | sipSender.transmitRequest(parentPlatform.getDeviceIp(),byeRequest); |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | // 发送response |
| | | sipSender.transmitRequest(response); |
| | | sipSender.transmitRequest(sipRequest.getLocalAddress().getHostAddress(), response); |
| | | |
| | | return response; |
| | | } |
| | |
| | | // 未知错误。直接转发设备点播的错误 |
| | | try { |
| | | Response response = getMessageFactory().createResponse(event.statusCode, evt.getRequest()); |
| | | sipSender.transmitRequest(response); |
| | | sipSender.transmitRequest(request.getLocalAddress().getHostAddress(), response); |
| | | } catch (ParseException | SipException e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | playService.play(mediaServerItem, ssrcInfo, device, channelId, hookEvent, errorEvent, (code, msg) -> { |
| | | logger.info("[上级点播]超时, 用户:{}, 通道:{}", username, channelId); |
| | | redisCatchStorage.deleteSendRTPServer(platform.getServerGBId(), channelId, callIdHeader.getCallId(), null); |
| | | zlmrtpServerFactory.releasePort(finalMediaServerItem, sendRtpItem.getSsrc()); |
| | | }, null); |
| | | }); |
| | | } else { |
| | | sendRtpItem.setStreamId(playTransaction.getStream()); |
| | | // 写入redis, 超时时回复 |
| | |
| | | package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl; |
| | | |
| | | import com.genersoft.iot.vmp.conf.SipConfig; |
| | | import com.genersoft.iot.vmp.gb28181.auth.DigestServerAuthenticationHelper; |
| | | import com.genersoft.iot.vmp.gb28181.bean.Device; |
| | | import com.genersoft.iot.vmp.gb28181.bean.WvpSipDate; |
| | | import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver; |
| | | import com.genersoft.iot.vmp.gb28181.transmit.SIPSender; |
| | | import com.genersoft.iot.vmp.gb28181.transmit.event.request.ISIPRequestProcessor; |
| | | import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; |
| | | import com.genersoft.iot.vmp.gb28181.auth.DigestServerAuthenticationHelper; |
| | | import com.genersoft.iot.vmp.service.IDeviceService; |
| | | import com.genersoft.iot.vmp.utils.DateUtil; |
| | | import gov.nist.javax.sip.RequestEventExt; |
| | | import gov.nist.javax.sip.address.AddressImpl; |
| | | import gov.nist.javax.sip.address.SipUri; |
| | | import gov.nist.javax.sip.header.Expires; |
| | | import gov.nist.javax.sip.header.SIPDateHeader; |
| | | import gov.nist.javax.sip.message.SIPRequest; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.InitializingBean; |
| | |
| | | |
| | | import javax.sip.RequestEvent; |
| | | import javax.sip.SipException; |
| | | import javax.sip.header.*; |
| | | import javax.sip.message.Request; |
| | | import javax.sip.header.AuthorizationHeader; |
| | | import javax.sip.header.ContactHeader; |
| | | import javax.sip.header.FromHeader; |
| | | import javax.sip.header.ViaHeader; |
| | | import javax.sip.message.Response; |
| | | import java.security.NoSuchAlgorithmException; |
| | | import java.text.ParseException; |
| | |
| | | RequestEventExt evtExt = (RequestEventExt) evt; |
| | | String requestAddress = evtExt.getRemoteIpAddress() + ":" + evtExt.getRemotePort(); |
| | | logger.info("[注册请求] 开始处理: {}", requestAddress); |
| | | Request request = evt.getRequest(); |
| | | ExpiresHeader expiresHeader = (ExpiresHeader) request.getHeader(Expires.NAME); |
| | | SIPRequest request = (SIPRequest)evt.getRequest(); |
| | | Response response = null; |
| | | boolean passwordCorrect = false; |
| | | // 注册标志 |
| | | boolean registerFlag = false; |
| | | boolean registerFlag; |
| | | FromHeader fromHeader = (FromHeader) request.getHeader(FromHeader.NAME); |
| | | AddressImpl address = (AddressImpl) fromHeader.getAddress(); |
| | | SipUri uri = (SipUri) address.getURI(); |
| | |
| | | logger.info("[注册请求] 回复401: {}", requestAddress); |
| | | response = getMessageFactory().createResponse(Response.UNAUTHORIZED, request); |
| | | new DigestServerAuthenticationHelper().generateChallenge(getHeaderFactory(), response, sipConfig.getDomain()); |
| | | sipSender.transmitRequest(response); |
| | | sipSender.transmitRequest(request.getLocalAddress().getHostAddress(), response); |
| | | return; |
| | | } |
| | | |
| | |
| | | response = getMessageFactory().createResponse(Response.FORBIDDEN, request); |
| | | response.setReasonPhrase("wrong password"); |
| | | logger.info("[注册请求] 密码/SIP服务器ID错误, 回复403: {}", requestAddress); |
| | | sipSender.transmitRequest(response); |
| | | sipSender.transmitRequest(request.getLocalAddress().getHostAddress(), response); |
| | | return; |
| | | } |
| | | |
| | |
| | | dateHeader.setDate(wvpSipDate); |
| | | response.addHeader(dateHeader); |
| | | |
| | | if (expiresHeader == null) { |
| | | if (request.getExpires() == null) { |
| | | response = getMessageFactory().createResponse(Response.BAD_REQUEST, request); |
| | | sipSender.transmitRequest(response); |
| | | sipSender.transmitRequest(request.getLocalAddress().getHostAddress(), response); |
| | | return; |
| | | } |
| | | // 添加Contact头 |
| | |
| | | device.setIp(received); |
| | | device.setPort(rPort); |
| | | device.setHostAddress(received.concat(":").concat(String.valueOf(rPort))); |
| | | if (expiresHeader.getExpires() == 0) { |
| | | device.setLocalIp(request.getLocalAddress().getHostAddress()); |
| | | if (request.getExpires().getExpires() == 0) { |
| | | // 注销成功 |
| | | registerFlag = false; |
| | | } else { |
| | | // 注册成功 |
| | | device.setExpires(expiresHeader.getExpires()); |
| | | device.setExpires(request.getExpires().getExpires()); |
| | | registerFlag = true; |
| | | // 判断TCP还是UDP |
| | | ViaHeader reqViaHeader = (ViaHeader) request.getHeader(ViaHeader.NAME); |
| | |
| | | device.setTransport("TCP".equalsIgnoreCase(transport) ? "TCP" : "UDP"); |
| | | } |
| | | |
| | | sipSender.transmitRequest(response); |
| | | sipSender.transmitRequest(request.getLocalAddress().getHostAddress(), response); |
| | | // 注册成功 |
| | | // 保存到redis |
| | | if (registerFlag) { |
| | |
| | | response.setExpires(expireHeader); |
| | | } |
| | | logger.info("response : " + response); |
| | | sipSender.transmitRequest(response); |
| | | sipSender.transmitRequest(request.getLocalAddress().getHostAddress(), response); |
| | | } |
| | | } catch (ParseException | SipException | InvalidArgumentException | DocumentException e) { |
| | | e.printStackTrace(); |
| | |
| | | import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; |
| | | import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.control.ControlMessageHandler; |
| | | import com.genersoft.iot.vmp.storager.IVideoManagerStorage; |
| | | import com.genersoft.iot.vmp.utils.SpringBeanFactory; |
| | | import gov.nist.javax.sip.SipStackImpl; |
| | | import gov.nist.javax.sip.message.SIPRequest; |
| | | import org.dom4j.Element; |
| | | import org.slf4j.Logger; |
| | |
| | | logger.error("[命令发送失败] 国标级联 注销: {}", e.getMessage()); |
| | | } |
| | | taskExecutor.execute(()->{ |
| | | try { |
| | | Thread.sleep(3000); |
| | | SipProvider up = (SipProvider) SpringBeanFactory.getBean("udpSipProvider"); |
| | | SipStackImpl stack = (SipStackImpl)up.getSipStack(); |
| | | stack.stop(); |
| | | Iterator listener = stack.getListeningPoints(); |
| | | while (listener.hasNext()) { |
| | | stack.deleteListeningPoint((ListeningPoint) listener.next()); |
| | | } |
| | | Iterator providers = stack.getSipProviders(); |
| | | while (providers.hasNext()) { |
| | | stack.deleteSipProvider((SipProvider) providers.next()); |
| | | } |
| | | VManageBootstrap.restart(); |
| | | } catch (InterruptedException | ObjectInUseException e) { |
| | | logger.error("[任务执行失败] 服务重启: {}", e.getMessage()); |
| | | } |
| | | // 远程启动 |
| | | // try { |
| | | // Thread.sleep(3000); |
| | | // SipProvider up = (SipProvider) SpringBeanFactory.getBean("udpSipProvider"); |
| | | // SipStackImpl stack = (SipStackImpl)up.getSipStack(); |
| | | // stack.stop(); |
| | | // Iterator listener = stack.getListeningPoints(); |
| | | // while (listener.hasNext()) { |
| | | // stack.deleteListeningPoint((ListeningPoint) listener.next()); |
| | | // } |
| | | // Iterator providers = stack.getSipProviders(); |
| | | // while (providers.hasNext()) { |
| | | // stack.deleteSipProvider((SipProvider) providers.next()); |
| | | // } |
| | | // VManageBootstrap.restart(); |
| | | // } catch (InterruptedException | ObjectInUseException e) { |
| | | // logger.error("[任务执行失败] 服务重启: {}", e.getMessage()); |
| | | // } |
| | | }); |
| | | } else { |
| | | // 远程启动指定设备 |
| | |
| | | package com.genersoft.iot.vmp.gb28181.transmit.event.response.impl; |
| | | |
| | | import com.genersoft.iot.vmp.conf.SipConfig; |
| | | import com.genersoft.iot.vmp.gb28181.SipLayer; |
| | | import com.genersoft.iot.vmp.gb28181.bean.Device; |
| | | import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction; |
| | | import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; |
| | |
| | | |
| | | |
| | | @Autowired |
| | | private SipFactory sipFactory; |
| | | private SipLayer sipLayer; |
| | | |
| | | @Autowired |
| | | private SIPSender sipSender; |
| | |
| | | } else { |
| | | sdp = SdpFactory.getInstance().createSessionDescription(contentString); |
| | | } |
| | | SipURI requestUri = sipFactory.createAddressFactory().createSipURI(sdp.getOrigin().getUsername(), event.getRemoteIpAddress() + ":" + event.getRemotePort()); |
| | | Request reqAck = headerProvider.createAckRequest(requestUri, response); |
| | | |
| | | SipURI requestUri = sipLayer.getSipFactory().createAddressFactory().createSipURI(sdp.getOrigin().getUsername(), event.getRemoteIpAddress() + ":" + event.getRemotePort()); |
| | | Request reqAck = headerProvider.createAckRequest(response.getLocalAddress().getHostAddress(), requestUri, response); |
| | | |
| | | logger.info("[回复ack] {}-> {}:{} ", sdp.getOrigin().getUsername(), event.getRemoteIpAddress(), event.getRemotePort()); |
| | | sipSender.transmitRequest(reqAck); |
| | | sipSender.transmitRequest( response.getLocalAddress().getHostAddress(), reqAck); |
| | | } |
| | | } catch (InvalidArgumentException | ParseException | SipException | SdpParseException e) { |
| | | logger.info("[点播回复ACK],异常:", e ); |
| | |
| | | if (platformRegisterInfo.isRegister()) { |
| | | platformService.online(parentPlatform); |
| | | }else { |
| | | platformService.offline(parentPlatform); |
| | | platformService.offline(parentPlatform, false); |
| | | } |
| | | |
| | | // 注册/注销成功移除缓存的信息 |
| | |
| | | public JSONObject onServerStarted(HttpServletRequest request, @RequestBody JSONObject jsonObject){
|
| | |
|
| | | jsonObject.put("ip", request.getRemoteAddr());
|
| | | System.out.println(jsonObject.toJSONString()
|
| | | );
|
| | | ZLMServerConfig zlmServerConfig = JSON.to(ZLMServerConfig.class, jsonObject);
|
| | | zlmServerConfig.setIp(request.getRemoteAddr());
|
| | | logger.info("[ZLM HOOK] zlm 启动 " + zlmServerConfig.getGeneralMediaServerId());
|
| | |
| | | @ResponseBody
|
| | | @PostMapping(value = "/on_rtp_server_timeout", produces = "application/json;charset=UTF-8")
|
| | | public JSONObject onRtpServerTimeout(HttpServletRequest request, @RequestBody OnRtpServerTimeoutHookParam param){
|
| | | System.out.println(param);
|
| | | logger.info("[ZLM HOOK] rtpServer收流超时:{}->{}({})", param.getMediaServerId(), param.getStream_id(), param.getSsrc());
|
| | |
|
| | | JSONObject ret = new JSONObject();
|
| | |
| | | .build(); |
| | | Response response = client.newCall(request).execute(); |
| | | if (response.isSuccessful()) { |
| | | logger.info("response body contentType: " + Objects.requireNonNull(response.body()).contentType()); |
| | | if (targetPath != null) { |
| | | File snapFolder = new File(targetPath); |
| | | if (!snapFolder.exists()) { |
| | |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | |
| | | @Component |
| | | @Order(value=1) |
| | | @Order(value=2) |
| | | public class ZLMRunner implements CommandLineRunner { |
| | | |
| | | private final static Logger logger = LoggerFactory.getLogger(ZLMRunner.class); |
| | |
| | | package com.genersoft.iot.vmp.service; |
| | | |
| | | import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; |
| | | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; |
| | | import com.genersoft.iot.vmp.gb28181.bean.SubscribeInfo; |
| | | import com.genersoft.iot.vmp.service.bean.GPSMsgInfo; |
| | | import com.github.pagehelper.PageInfo; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 国标平台的业务类 |
| | |
| | | * 平台离线 |
| | | * @param parentPlatform 平台信息 |
| | | */ |
| | | void offline(ParentPlatform parentPlatform); |
| | | void offline(ParentPlatform parentPlatform, boolean stopRegisterTask); |
| | | |
| | | /** |
| | | * 向上级平台发起注册 |
| | |
| | | import com.genersoft.iot.vmp.service.bean.PlayBackCallback; |
| | | import com.genersoft.iot.vmp.service.bean.SSRCInfo; |
| | | import com.genersoft.iot.vmp.vmanager.bean.WVPResult; |
| | | import com.genersoft.iot.vmp.vmanager.gb28181.play.bean.PlayResult; |
| | | import org.springframework.web.context.request.async.DeferredResult; |
| | | |
| | | import javax.sip.InvalidArgumentException; |
| | |
| | | */ |
| | | public interface IPlayService { |
| | | |
| | | void onPublishHandlerForPlay(MediaServerItem mediaServerItem, JSONObject resonse, String deviceId, String channelId, String uuid); |
| | | void onPublishHandlerForPlay(MediaServerItem mediaServerItem, JSONObject resonse, String deviceId, String channelId); |
| | | |
| | | void play(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, Device device, String channelId, |
| | | ZlmHttpHookSubscribe.Event hookEvent, SipSubscribe.Event errorEvent, |
| | | InviteTimeOutCallback timeoutCallback, String uuid); |
| | | PlayResult play(MediaServerItem mediaServerItem, String deviceId, String channelId, ZlmHttpHookSubscribe.Event event, SipSubscribe.Event errorEvent, Runnable timeoutCallback); |
| | | InviteTimeOutCallback timeoutCallback); |
| | | void play(MediaServerItem mediaServerItem, String deviceId, String channelId, ZlmHttpHookSubscribe.Event event, SipSubscribe.Event errorEvent, Runnable timeoutCallback); |
| | | |
| | | MediaServerItem getNewMediaServerItem(Device device); |
| | | |
| | |
| | | mediaServerItem.setRtspSSLPort(zlmServerConfig.getRtspSSlport()); |
| | | mediaServerItem.setRtpProxyPort(zlmServerConfig.getRtpProxyPort()); |
| | | mediaServerItem.setStreamIp(ip); |
| | | mediaServerItem.setHookIp(sipConfig.getIp()); |
| | | mediaServerItem.setHookIp(sipConfig.getIp().split(",")[0]); |
| | | mediaServerItem.setSdpIp(ip); |
| | | return mediaServerItem; |
| | | } |
| | |
| | | import com.alibaba.fastjson2.JSONArray; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.genersoft.iot.vmp.common.StreamInfo; |
| | | import com.genersoft.iot.vmp.common.StreamURL; |
| | | import com.genersoft.iot.vmp.conf.MediaConfig; |
| | | import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; |
| | | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.ObjectUtils; |
| | | |
| | | import java.net.URL; |
| | | |
| | | @Service |
| | | public class MediaServiceImpl implements IMediaService { |
| | |
| | | if (addr == null) { |
| | | addr = mediaInfo.getStreamIp(); |
| | | } |
| | | |
| | | streamInfoResult.setIp(addr); |
| | | streamInfoResult.setMediaServerId(mediaInfo.getId()); |
| | | String callIdParam = ObjectUtils.isEmpty(callId)?"":"?callId=" + callId; |
| | | streamInfoResult.setRtmp(String.format("rtmp://%s:%s/%s/%s%s", addr, mediaInfo.getRtmpPort(), app, stream, callIdParam)); |
| | | if (mediaInfo.getRtmpSSlPort() != 0) { |
| | | streamInfoResult.setRtmps(String.format("rtmps://%s:%s/%s/%s%s", addr, mediaInfo.getRtmpSSlPort(), app, stream, callIdParam)); |
| | | } |
| | | streamInfoResult.setRtsp(String.format("rtsp://%s:%s/%s/%s%s", addr, mediaInfo.getRtspPort(), app, stream, callIdParam)); |
| | | if (mediaInfo.getRtspSSLPort() != 0) { |
| | | streamInfoResult.setRtsps(String.format("rtsps://%s:%s/%s/%s%s", addr, mediaInfo.getRtspSSLPort(), app, stream, callIdParam)); |
| | | } |
| | | streamInfoResult.setFlv(String.format("http://%s:%s/%s/%s.live.flv%s", addr, mediaInfo.getHttpPort(), app, stream, callIdParam)); |
| | | streamInfoResult.setWs_flv(String.format("ws://%s:%s/%s/%s.live.flv%s", addr, mediaInfo.getHttpPort(), app, stream, callIdParam)); |
| | | streamInfoResult.setHls(String.format("http://%s:%s/%s/%s/hls.m3u8%s", addr, mediaInfo.getHttpPort(), app, stream, callIdParam)); |
| | | streamInfoResult.setWs_hls(String.format("ws://%s:%s/%s/%s/hls.m3u8%s", addr, mediaInfo.getHttpPort(), app, stream, callIdParam)); |
| | | streamInfoResult.setFmp4(String.format("http://%s:%s/%s/%s.live.mp4%s", addr, mediaInfo.getHttpPort(), app, stream, callIdParam)); |
| | | streamInfoResult.setWs_fmp4(String.format("ws://%s:%s/%s/%s.live.mp4%s", addr, mediaInfo.getHttpPort(), app, stream, callIdParam)); |
| | | streamInfoResult.setTs(String.format("http://%s:%s/%s/%s.live.ts%s", addr, mediaInfo.getHttpPort(), app, stream, callIdParam)); |
| | | streamInfoResult.setWs_ts(String.format("ws://%s:%s/%s/%s.live.ts%s", addr, mediaInfo.getHttpPort(), app, stream, callIdParam)); |
| | | streamInfoResult.setRtc(String.format("http://%s:%s/index/api/webrtc?app=%s&stream=%s&type=play%s", mediaInfo.getStreamIp(), mediaInfo.getHttpPort(), app, stream, ObjectUtils.isEmpty(callId)?"":"&callId=" + callId)); |
| | | if (mediaInfo.getHttpSSlPort() != 0) { |
| | | streamInfoResult.setHttps_flv(String.format("https://%s:%s/%s/%s.live.flv%s", addr, mediaInfo.getHttpSSlPort(), app, stream, callIdParam)); |
| | | streamInfoResult.setWss_flv(String.format("wss://%s:%s/%s/%s.live.flv%s", addr, mediaInfo.getHttpSSlPort(), app, stream, callIdParam)); |
| | | streamInfoResult.setHttps_hls(String.format("https://%s:%s/%s/%s/hls.m3u8%s", addr, mediaInfo.getHttpSSlPort(), app, stream, callIdParam)); |
| | | streamInfoResult.setWss_hls(String.format("wss://%s:%s/%s/%s/hls.m3u8%s", addr, mediaInfo.getHttpSSlPort(), app, stream, callIdParam)); |
| | | streamInfoResult.setHttps_fmp4(String.format("https://%s:%s/%s/%s.live.mp4%s", addr, mediaInfo.getHttpSSlPort(), app, stream, callIdParam)); |
| | | streamInfoResult.setWss_fmp4(String.format("wss://%s:%s/%s/%s.live.mp4%s", addr, mediaInfo.getHttpSSlPort(), app, stream, callIdParam)); |
| | | streamInfoResult.setHttps_ts(String.format("https://%s:%s/%s/%s.live.ts%s", addr, mediaInfo.getHttpSSlPort(), app, stream, callIdParam)); |
| | | streamInfoResult.setWss_ts(String.format("wss://%s:%s/%s/%s.live.ts%s", addr, mediaInfo.getHttpSSlPort(), app, stream, callIdParam)); |
| | | streamInfoResult.setWss_ts(String.format("wss://%s:%s/%s/%s.live.ts%s", addr, mediaInfo.getHttpSSlPort(), app, stream, callIdParam)); |
| | | streamInfoResult.setRtcs(String.format("https://%s:%s/index/api/webrtc?app=%s&stream=%s&type=play%s", mediaInfo.getStreamIp(), mediaInfo.getHttpSSlPort(), app, stream, ObjectUtils.isEmpty(callId)?"":"&callId=" + callId)); |
| | | } |
| | | streamInfoResult.setRtmp(addr, mediaInfo.getRtmpPort(),mediaInfo.getRtmpSSlPort(), app, stream, callIdParam); |
| | | streamInfoResult.setRtsp(addr, mediaInfo.getRtspPort(),mediaInfo.getRtspSSLPort(), app, stream, callIdParam); |
| | | streamInfoResult.setFlv(addr, mediaInfo.getHttpPort(),mediaInfo.getHttpSSlPort(), app, stream, callIdParam); |
| | | streamInfoResult.setFmp4(addr, mediaInfo.getHttpPort(),mediaInfo.getHttpSSlPort(), app, stream, callIdParam); |
| | | streamInfoResult.setHls(addr, mediaInfo.getHttpPort(),mediaInfo.getHttpSSlPort(), app, stream, callIdParam); |
| | | streamInfoResult.setTs(addr, mediaInfo.getHttpPort(),mediaInfo.getHttpSSlPort(), app, stream, callIdParam); |
| | | streamInfoResult.setRtc(addr, mediaInfo.getHttpPort(),mediaInfo.getHttpSSlPort(), app, stream, callIdParam); |
| | | |
| | | streamInfoResult.setTracks(tracks); |
| | | return streamInfoResult; |
| | |
| | | |
| | | import javax.sip.InvalidArgumentException; |
| | | import javax.sip.SipException; |
| | | import javax.sip.TimeoutEvent; |
| | | import java.text.ParseException; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | |
| | | } |
| | | |
| | | final String registerTaskKey = REGISTER_KEY_PREFIX + parentPlatform.getServerGBId(); |
| | | if (dynamicTask.contains(registerTaskKey)) { |
| | | dynamicTask.stop(registerTaskKey); |
| | | } |
| | | // 添加注册任务 |
| | | dynamicTask.startDelay(registerTaskKey, |
| | | if (!dynamicTask.isAlive(registerTaskKey)) { |
| | | // 添加注册任务 |
| | | dynamicTask.startCron(registerTaskKey, |
| | | // 注册失败(注册成功时由程序直接调用了online方法) |
| | | ()-> { |
| | | try { |
| | | commanderForPlatform.register(parentPlatform, eventResult -> offline(parentPlatform),null); |
| | | logger.info("[国标级联] 平台:{}注册即将到期,重新注册", parentPlatform.getServerGBId()); |
| | | commanderForPlatform.register(parentPlatform, eventResult -> { |
| | | offline(parentPlatform, false); |
| | | },null); |
| | | } catch (InvalidArgumentException | ParseException | SipException e) { |
| | | logger.error("[命令发送失败] 国标级联定时注册: {}", e.getMessage()); |
| | | } |
| | | }, |
| | | (parentPlatform.getExpires() - 10) *1000); |
| | | } |
| | | |
| | | |
| | | final String keepaliveTaskKey = KEEPALIVE_KEY_PREFIX + parentPlatform.getServerGBId(); |
| | | if (!dynamicTask.contains(keepaliveTaskKey)) { |
| | |
| | | // 此时是第三次心跳超时, 平台离线 |
| | | if (platformCatch.getKeepAliveReply() == 2) { |
| | | // 设置平台离线,并重新注册 |
| | | offline(parentPlatform); |
| | | logger.info("[国标级联] {},三次心跳超时后再次发起注册", parentPlatform.getServerGBId()); |
| | | try { |
| | | commanderForPlatform.register(parentPlatform, eventResult1 -> { |
| | | logger.info("[国标级联] {},三次心跳超时后再次发起注册仍然失败,开始定时发起注册,间隔为1分钟", parentPlatform.getServerGBId()); |
| | | // 添加注册任务 |
| | | dynamicTask.startCron(registerTaskKey, |
| | | // 注册失败(注册成功时由程序直接调用了online方法) |
| | | ()->logger.info("[国标级联] {},平台离线后持续发起注册,失败", parentPlatform.getServerGBId()), |
| | | 60*1000); |
| | | offline(parentPlatform, false); |
| | | }, null); |
| | | } catch (InvalidArgumentException | ParseException | SipException e) { |
| | | logger.error("[命令发送失败] 国标级联 注册: {}", e.getMessage()); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void offline(ParentPlatform parentPlatform) { |
| | | public void offline(ParentPlatform parentPlatform, boolean stopRegister) { |
| | | logger.info("[平台离线]:{}", parentPlatform.getServerGBId()); |
| | | ParentPlatformCatch parentPlatformCatch = redisCatchStorage.queryPlatformCatchInfo(parentPlatform.getServerGBId()); |
| | | parentPlatformCatch.setKeepAliveReply(0); |
| | |
| | | // 停止所有推流 |
| | | logger.info("[平台离线] {}, 停止所有推流", parentPlatform.getServerGBId()); |
| | | stopAllPush(parentPlatform.getServerGBId()); |
| | | // 清除注册定时 |
| | | logger.info("[平台离线] {}, 停止定时注册任务", parentPlatform.getServerGBId()); |
| | | final String registerTaskKey = REGISTER_KEY_PREFIX + parentPlatform.getServerGBId(); |
| | | if (dynamicTask.contains(registerTaskKey)) { |
| | | dynamicTask.stop(registerTaskKey); |
| | | if (stopRegister) { |
| | | // 清除注册定时 |
| | | logger.info("[平台离线] {}, 停止定时注册任务", parentPlatform.getServerGBId()); |
| | | final String registerTaskKey = REGISTER_KEY_PREFIX + parentPlatform.getServerGBId(); |
| | | if (dynamicTask.contains(registerTaskKey)) { |
| | | dynamicTask.stop(registerTaskKey); |
| | | } |
| | | } |
| | | // 清除心跳定时 |
| | | logger.info("[平台离线] {}, 停止定时发送心跳任务", parentPlatform.getServerGBId()); |
| | |
| | | import com.genersoft.iot.vmp.utils.redis.RedisUtil; |
| | | import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; |
| | | import com.genersoft.iot.vmp.vmanager.bean.WVPResult; |
| | | import com.genersoft.iot.vmp.vmanager.gb28181.play.bean.PlayResult; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | import java.math.RoundingMode; |
| | | import java.text.ParseException; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.UUID; |
| | | |
| | | @SuppressWarnings(value = {"rawtypes", "unchecked"}) |
| | |
| | | private ThreadPoolTaskExecutor taskExecutor; |
| | | |
| | | @Override |
| | | public PlayResult play(MediaServerItem mediaServerItem, String deviceId, String channelId, |
| | | ZlmHttpHookSubscribe.Event hookEvent, SipSubscribe.Event errorEvent, |
| | | Runnable timeoutCallback) { |
| | | public void play(MediaServerItem mediaServerItem, String deviceId, String channelId, |
| | | ZlmHttpHookSubscribe.Event hookEvent, SipSubscribe.Event errorEvent, |
| | | Runnable timeoutCallback) { |
| | | if (mediaServerItem == null) { |
| | | throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到可用的zlm"); |
| | | } |
| | | PlayResult playResult = new PlayResult(); |
| | | RequestMessage msg = new RequestMessage(); |
| | | String key = DeferredResultHolder.CALLBACK_CMD_PLAY + deviceId + channelId; |
| | | |
| | | RequestMessage msg = new RequestMessage(); |
| | | msg.setKey(key); |
| | | String uuid = UUID.randomUUID().toString(); |
| | | msg.setId(uuid); |
| | | playResult.setUuid(uuid); |
| | | DeferredResult<WVPResult<StreamInfo>> result = new DeferredResult<>(userSetting.getPlayTimeout().longValue()); |
| | | playResult.setResult(result); |
| | | // 录像查询以channelId作为deviceId查询 |
| | | resultHolder.put(key, uuid, result); |
| | | |
| | | Device device = redisCatchStorage.getDevice(deviceId); |
| | | StreamInfo streamInfo = redisCatchStorage.queryPlayByDevice(deviceId, channelId); |
| | | playResult.setDevice(device); |
| | | |
| | | result.onCompletion(() -> { |
| | | // 点播结束时调用截图接口 |
| | | taskExecutor.execute(() -> { |
| | | // TODO 应该在上流时调用更好,结束也可能是错误结束 |
| | | String path = "snap"; |
| | | String fileName = deviceId + "_" + channelId + ".jpg"; |
| | | WVPResult wvpResult = (WVPResult) result.getResult(); |
| | | if (Objects.requireNonNull(wvpResult).getCode() == 0) { |
| | | StreamInfo streamInfoForSuccess = (StreamInfo) wvpResult.getData(); |
| | | MediaServerItem mediaInfo = mediaServerService.getOne(streamInfoForSuccess.getMediaServerId()); |
| | | String streamUrl = streamInfoForSuccess.getFmp4(); |
| | | |
| | | // 请求截图 |
| | | logger.info("[请求截图]: " + fileName); |
| | | zlmresTfulUtils.getSnap(mediaInfo, streamUrl, 15, 1, path, fileName); |
| | | } |
| | | }); |
| | | }); |
| | | |
| | | if (streamInfo != null) { |
| | | String streamId = streamInfo.getStream(); |
| | |
| | | wvpResult.setMsg("点播失败, redis缓存streamId等于null"); |
| | | msg.setData(wvpResult); |
| | | resultHolder.invokeAllResult(msg); |
| | | return playResult; |
| | | return; |
| | | } |
| | | String mediaServerId = streamInfo.getMediaServerId(); |
| | | MediaServerItem mediaInfo = mediaServerService.getOne(mediaServerId); |
| | |
| | | msg.setData(wvpResult); |
| | | |
| | | resultHolder.invokeAllResult(msg); |
| | | return playResult; |
| | | return; |
| | | } else { |
| | | WVPResult wvpResult = new WVPResult(); |
| | | wvpResult.setCode(ErrorCode.SUCCESS.getCode()); |
| | | wvpResult.setMsg(ErrorCode.SUCCESS.getMsg()); |
| | | wvpResult.setData(streamInfo); |
| | | msg.setData(wvpResult); |
| | | |
| | | resultHolder.invokeAllResult(msg); |
| | | if (hookEvent != null) { |
| | | hookEvent.response(mediaServerItem, JSON.parseObject(JSON.toJSONString(streamInfo))); |
| | |
| | | streamId = String.format("%s_%s", device.getDeviceId(), channelId); |
| | | } |
| | | SSRCInfo ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, streamId, device.isSsrcCheck(), false); |
| | | logger.info(JSONObject.toJSONString(ssrcInfo)); |
| | | if (ssrcInfo == null) { |
| | | WVPResult wvpResult = new WVPResult(); |
| | | wvpResult.setCode(ErrorCode.ERROR100.getCode()); |
| | |
| | | msg.setData(wvpResult); |
| | | |
| | | resultHolder.invokeAllResult(msg); |
| | | return playResult; |
| | | return; |
| | | } |
| | | play(mediaServerItem, ssrcInfo, device, channelId, (mediaServerItemInUse, response) -> { |
| | | if (hookEvent != null) { |
| | |
| | | msg.setData(wvpResult); |
| | | // 回复之前所有的点播请求 |
| | | resultHolder.invokeAllResult(msg); |
| | | }, uuid); |
| | | }); |
| | | } |
| | | return playResult; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void play(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, Device device, String channelId, |
| | | ZlmHttpHookSubscribe.Event hookEvent, SipSubscribe.Event errorEvent, |
| | | InviteTimeOutCallback timeoutCallback, String uuid) { |
| | | InviteTimeOutCallback timeoutCallback) { |
| | | |
| | | logger.info("[点播开始] deviceId: {}, channelId: {},收流端口: {}, 收流模式:{}, SSRC: {}, SSRC校验:{}", device.getDeviceId(), channelId, ssrcInfo.getPort(), device.getStreamMode(), ssrcInfo.getSsrc(), device.isSsrcCheck()); |
| | | // 超时处理 |
| | |
| | | } |
| | | } |
| | | }, userSetting.getPlayTimeout()); |
| | | //端口获取失败的ssrcInfo 没有必要发送点播指令 |
| | | if (ssrcInfo.getPort() <= 0) { |
| | | logger.info("[点播端口分配异常],deviceId={},channelId={},ssrcInfo={}", device.getDeviceId(), channelId, ssrcInfo); |
| | | dynamicTask.stop(timeOutTaskKey); |
| | | // 释放ssrc |
| | | mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcInfo.getSsrc()); |
| | | |
| | | streamSession.remove(device.getDeviceId(), channelId, ssrcInfo.getStream()); |
| | | |
| | | RequestMessage msg = new RequestMessage(); |
| | | msg.setKey(DeferredResultHolder.CALLBACK_CMD_PLAY + device.getDeviceId() + channelId); |
| | | msg.setData(WVPResult.fail(ErrorCode.ERROR100.getCode(), "点播端口分配异常")); |
| | | resultHolder.invokeAllResult(msg); |
| | | return; |
| | | } |
| | | try { |
| | | cmder.playStreamCmd(mediaServerItem, ssrcInfo, device, channelId, (MediaServerItem mediaServerItemInuse, JSONObject response) -> { |
| | | logger.info("收到订阅消息: " + response.toJSONString()); |
| | | dynamicTask.stop(timeOutTaskKey); |
| | | |
| | | // hook响应 |
| | | onPublishHandlerForPlay(mediaServerItemInuse, response, device.getDeviceId(), channelId, uuid); |
| | | onPublishHandlerForPlay(mediaServerItemInuse, response, device.getDeviceId(), channelId); |
| | | hookEvent.response(mediaServerItemInuse, response); |
| | | logger.info("[点播成功] deviceId: {}, channelId: {}", device.getDeviceId(), channelId); |
| | | String streamUrl = String.format("rtsp://127.0.0.1:%s/%s/%s", mediaServerItemInuse.getRtspPort(), "rtp", ssrcInfo.getStream()); |
| | | String path = "snap"; |
| | | String fileName = device.getDeviceId() + "_" + channelId + ".jpg"; |
| | | // 请求截图 |
| | | logger.info("[请求截图]: " + fileName); |
| | | zlmresTfulUtils.getSnap(mediaServerItemInuse, streamUrl, 15, 1, path, fileName); |
| | | |
| | | }, (event) -> { |
| | | ResponseEvent responseEvent = (ResponseEvent) event.event; |
| | |
| | | logger.info("[ZLM HOOK] ssrc修正后收到订阅消息: " + response.toJSONString()); |
| | | dynamicTask.stop(timeOutTaskKey); |
| | | // hook响应 |
| | | onPublishHandlerForPlay(mediaServerItemInUse, response, device.getDeviceId(), channelId, uuid); |
| | | onPublishHandlerForPlay(mediaServerItemInUse, response, device.getDeviceId(), channelId); |
| | | hookEvent.response(mediaServerItemInUse, response); |
| | | }); |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void onPublishHandlerForPlay(MediaServerItem mediaServerItem, JSONObject response, String deviceId, String channelId, String uuid) { |
| | | public void onPublishHandlerForPlay(MediaServerItem mediaServerItem, JSONObject response, String deviceId, String channelId) { |
| | | StreamInfo streamInfo = onPublishHandler(mediaServerItem, response, deviceId, channelId); |
| | | RequestMessage msg = new RequestMessage(); |
| | | if (uuid != null) { |
| | | msg.setKey(DeferredResultHolder.CALLBACK_CMD_PLAY + deviceId + channelId); |
| | | if (streamInfo != null) { |
| | | DeviceChannel deviceChannel = storager.queryChannel(deviceId, channelId); |
| | | if (deviceChannel != null) { |
| | | deviceChannel.setStreamId(streamInfo.getStream()); |
| | | storager.startPlay(deviceId, channelId, streamInfo.getStream()); |
| | | } |
| | | redisCatchStorage.startPlay(streamInfo); |
| | | |
| | | WVPResult wvpResult = new WVPResult(); |
| | | wvpResult.setCode(ErrorCode.SUCCESS.getCode()); |
| | | wvpResult.setMsg(ErrorCode.SUCCESS.getMsg()); |
| | | wvpResult.setData(streamInfo); |
| | | |
| | | msg.setData(wvpResult); |
| | | resultHolder.invokeAllResult(msg); |
| | | |
| | | } else { |
| | | logger.warn("设备预览API调用失败!"); |
| | | msg.setData(WVPResult.fail(ErrorCode.ERROR100.getCode(), "设备预览API调用失败!")); |
| | | resultHolder.invokeAllResult(msg); |
| | | } |
| | | } |
| | | |
| | | private void onPublishHandlerForPlayback(MediaServerItem mediaServerItem, JSONObject response, String deviceId, String channelId, String uuid) { |
| | | RequestMessage msg = new RequestMessage(); |
| | | msg.setKey(DeferredResultHolder.CALLBACK_CMD_PLAY + deviceId + channelId); |
| | | if (!ObjectUtils.isEmpty(uuid)) { |
| | | msg.setId(uuid); |
| | | } |
| | | msg.setKey(DeferredResultHolder.CALLBACK_CMD_PLAY + deviceId + channelId); |
| | | StreamInfo streamInfo = onPublishHandler(mediaServerItem, response, deviceId, channelId); |
| | | |
| | | if (streamInfo != null) { |
| | | DeviceChannel deviceChannel = storager.queryChannel(deviceId, channelId); |
| | | if (deviceChannel != null) { |
| | |
| | | |
| | | resultHolder.invokeAllResult(msg); |
| | | } else { |
| | | logger.warn("设备预览API调用失败!"); |
| | | msg.setData(WVPResult.fail(ErrorCode.ERROR100.getCode(), "设备预览API调用失败!")); |
| | | logger.warn("录像回放调用失败!"); |
| | | msg.setData(WVPResult.fail(ErrorCode.ERROR100.getCode(), "录像回放调用失败!")); |
| | | resultHolder.invokeAllResult(msg); |
| | | } |
| | | } |
| | |
| | | logger.info("[ZLM HOOK] ssrc修正后收到订阅消息: " + response.toJSONString()); |
| | | dynamicTask.stop(playBackTimeOutTaskKey); |
| | | // hook响应 |
| | | onPublishHandlerForPlay(mediaServerItemInUse, response, device.getDeviceId(), channelId, uuid); |
| | | onPublishHandlerForPlayback(mediaServerItemInUse, response, device.getDeviceId(), channelId, uuid); |
| | | hookEvent.call(new InviteStreamInfo(mediaServerItem, null, eventResult.callId, "rtp", ssrcInfo.getStream())); |
| | | }); |
| | | } |
| | |
| | | return result; |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public DeferredResult<WVPResult<StreamInfo>> download(String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack) { |
| | | Device device = storager.queryVideoDevice(deviceId); |
| | |
| | | streamInfoPushItemMap.put(onStreamChangedHookParam.getApp() + onStreamChangedHookParam.getStream(), onStreamChangedHookParam); |
| | | } |
| | | } |
| | | // 获取所有推流鉴权信息,清理过期的 |
| | | List<StreamAuthorityInfo> allStreamAuthorityInfo = redisCatchStorage.getAllStreamAuthorityInfo(); |
| | | Map<String, StreamAuthorityInfo> streamAuthorityInfoInfoMap = new HashMap<>(); |
| | | for (StreamAuthorityInfo streamAuthorityInfo : allStreamAuthorityInfo) { |
| | | streamAuthorityInfoInfoMap.put(streamAuthorityInfo.getApp() + streamAuthorityInfo.getStream(), streamAuthorityInfo); |
| | | } |
| | | zlmresTfulUtils.getMediaList(mediaServerItem, (mediaList ->{ |
| | | if (mediaList == null) { |
| | | return; |
| | |
| | | for (StreamPushItem streamPushItem : streamPushItems) { |
| | | pushItemMap.remove(streamPushItem.getApp() + streamPushItem.getStream()); |
| | | streamInfoPushItemMap.remove(streamPushItem.getApp() + streamPushItem.getStream()); |
| | | streamAuthorityInfoInfoMap.remove(streamPushItem.getApp() + streamPushItem.getStream()); |
| | | } |
| | | } |
| | | List<StreamPushItem> offlinePushItems = new ArrayList<>(pushItemMap.values()); |
| | |
| | | redisCatchStorage.removeStream(mediaServerItem.getId(), "PUSH", offlineOnStreamChangedHookParam.getApp(), offlineOnStreamChangedHookParam.getStream()); |
| | | } |
| | | } |
| | | |
| | | Collection<StreamAuthorityInfo> streamAuthorityInfos = streamAuthorityInfoInfoMap.values(); |
| | | if (streamAuthorityInfos.size() > 0) { |
| | | for (StreamAuthorityInfo streamAuthorityInfo : streamAuthorityInfos) { |
| | | // 移除redis内流的信息 |
| | | redisCatchStorage.removeStreamAuthorityInfo(streamAuthorityInfo.getApp(), streamAuthorityInfo.getStream()); |
| | | } |
| | | } |
| | | })); |
| | | } |
| | | |
| | |
| | | */ |
| | | StreamAuthorityInfo getStreamAuthorityInfo(String app, String stream); |
| | | |
| | | List<StreamAuthorityInfo> getAllStreamAuthorityInfo(); |
| | | |
| | | /** |
| | | * 发送redis消息 查询所有推流设备的状态 |
| | | */ |
| | |
| | | "streamMode," + |
| | | "ip," + |
| | | "sdpIp," + |
| | | "localIp," + |
| | | "port," + |
| | | "hostAddress," + |
| | | "expires," + |
| | |
| | | "streamMode," + |
| | | "ip," + |
| | | "sdpIp," + |
| | | "localIp," + |
| | | "port," + |
| | | "hostAddress," + |
| | | "expires," + |
| | |
| | | "#{streamMode}," + |
| | | "#{ip}," + |
| | | "#{sdpIp}," + |
| | | "#{localIp}," + |
| | | "#{port}," + |
| | | "#{hostAddress}," + |
| | | "#{expires}," + |
| | |
| | | "<if test=\"firmware != null\">, firmware='${firmware}'</if>" + |
| | | "<if test=\"transport != null\">, transport='${transport}'</if>" + |
| | | "<if test=\"ip != null\">, ip='${ip}'</if>" + |
| | | "<if test=\"localIp != null\">, localIp='${localIp}'</if>" + |
| | | "<if test=\"port != null\">, port=${port}</if>" + |
| | | "<if test=\"hostAddress != null\">, hostAddress='${hostAddress}'</if>" + |
| | | "<if test=\"online != null\">, online=${online}</if>" + |
| | |
| | | "streamMode," + |
| | | "ip," + |
| | | "sdpIp," + |
| | | "localIp," + |
| | | "port," + |
| | | "hostAddress," + |
| | | "expires," + |
| | |
| | | "streamMode," + |
| | | "ip," + |
| | | "sdpIp," + |
| | | "localIp," + |
| | | "port," + |
| | | "hostAddress," + |
| | | "expires," + |
| | |
| | | "streamMode," + |
| | | "ip," + |
| | | "sdpIp," + |
| | | "localIp," + |
| | | "port," + |
| | | "hostAddress," + |
| | | "expires," + |
| | |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public List<StreamAuthorityInfo> getAllStreamAuthorityInfo() { |
| | | String scanKey = VideoManagerConstants.MEDIA_STREAM_AUTHORITY + userSetting.getServerId() + "_*_*" ; |
| | | List<StreamAuthorityInfo> result = new ArrayList<>(); |
| | | List<Object> keys = RedisUtil.scan(scanKey); |
| | | for (Object o : keys) { |
| | | String key = (String) o; |
| | | result.add((StreamAuthorityInfo) RedisUtil.get(key)); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public OnStreamChangedHookParam getStreamInfo(String app, String streamId, String mediaServerId) { |
| | |
| | | package com.genersoft.iot.vmp.utils.redis;
|
| | |
|
| | | import java.nio.charset.Charset;
|
| | |
|
| | | import com.alibaba.fastjson2.JSON;
|
| | | import com.alibaba.fastjson2.JSONReader;
|
| | | import com.alibaba.fastjson2.JSONWriter;
|
| | | import org.springframework.data.redis.serializer.RedisSerializer;
|
| | | import org.springframework.data.redis.serializer.SerializationException;
|
| | |
|
| | | import com.alibaba.fastjson2.JSON;
|
| | | import com.alibaba.fastjson2.JSONWriter.Feature;
|
| | | import java.nio.charset.Charset;
|
| | |
|
| | | /**
|
| | | * @description:使用fastjson实现redis的序列化
|
| | |
| | | if (t == null) {
|
| | | return new byte[0];
|
| | | }
|
| | | return JSON.toJSONString(t, JSONWriter.Feature.WriteClassName).getBytes(DEFAULT_CHARSET);
|
| | | return JSON.toJSONString(t, JSONWriter.Feature.WriteClassName, JSONWriter.Feature.WritePairAsJavaBean).getBytes(DEFAULT_CHARSET);
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | String str = new String(bytes, DEFAULT_CHARSET);
|
| | | return JSON.parseObject(str, clazz, JSONReader.Feature.SupportAutoType);
|
| | | }
|
| | |
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.genersoft.iot.vmp.vmanager.bean; |
| | | |
| | | import org.springframework.web.context.request.async.DeferredResult; |
| | | |
| | | public class DeferredResultEx<T> { |
| | | |
| | | private DeferredResult<T> deferredResult; |
| | | |
| | | private DeferredResultFilter filter; |
| | | |
| | | public DeferredResultEx(DeferredResult<T> result) { |
| | | this.deferredResult = result; |
| | | } |
| | | |
| | | |
| | | public DeferredResult<T> getDeferredResult() { |
| | | return deferredResult; |
| | | } |
| | | |
| | | public void setDeferredResult(DeferredResult<T> deferredResult) { |
| | | this.deferredResult = deferredResult; |
| | | } |
| | | |
| | | public DeferredResultFilter getFilter() { |
| | | return filter; |
| | | } |
| | | |
| | | public void setFilter(DeferredResultFilter filter) { |
| | | this.filter = filter; |
| | | } |
| | | } |
New file |
| | |
| | | package com.genersoft.iot.vmp.vmanager.bean; |
| | | |
| | | public interface DeferredResultFilter { |
| | | |
| | | Object handler(Object o); |
| | | } |
| | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | |
| | | @Schema(description = "统一返回结果") |
| | | public class WVPResult<T> { |
| | | public class WVPResult<T> implements Cloneable{ |
| | | |
| | | public WVPResult() { |
| | | } |
| | |
| | | public void setData(T data) { |
| | | this.data = data; |
| | | } |
| | | |
| | | @Override |
| | | public Object clone() throws CloneNotSupportedException { |
| | | return super.clone(); |
| | | } |
| | | } |
| | |
| | | package com.genersoft.iot.vmp.vmanager.gb28181.play; |
| | | |
| | | import com.alibaba.fastjson2.JSONArray; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.genersoft.iot.vmp.common.StreamInfo; |
| | | import com.genersoft.iot.vmp.conf.UserSetting; |
| | | import com.genersoft.iot.vmp.conf.exception.ControllerException; |
| | | import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException; |
| | | import com.genersoft.iot.vmp.gb28181.bean.Device; |
| | | import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction; |
| | | import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; |
| | | import com.genersoft.iot.vmp.gb28181.bean.Device; |
| | | import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; |
| | | import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; |
| | | import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; |
| | | import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; |
| | | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| | | import com.genersoft.iot.vmp.service.IMediaServerService; |
| | | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| | | import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; |
| | | import com.genersoft.iot.vmp.vmanager.bean.WVPResult; |
| | | import com.genersoft.iot.vmp.vmanager.gb28181.play.bean.PlayResult; |
| | | import com.genersoft.iot.vmp.service.IMediaService; |
| | | import com.genersoft.iot.vmp.service.IPlayService; |
| | | |
| | | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| | | import com.genersoft.iot.vmp.storager.IVideoManagerStorage; |
| | | import com.genersoft.iot.vmp.vmanager.bean.DeferredResultEx; |
| | | import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; |
| | | import com.genersoft.iot.vmp.vmanager.bean.WVPResult; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.CrossOrigin; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; |
| | | import com.genersoft.iot.vmp.storager.IVideoManagerStorage; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.context.request.async.DeferredResult; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.sip.InvalidArgumentException; |
| | | import javax.sip.SipException; |
| | | import java.text.ParseException; |
| | |
| | | @Autowired |
| | | private IMediaServerService mediaServerService; |
| | | |
| | | @Autowired |
| | | private UserSetting userSetting; |
| | | |
| | | @Operation(summary = "开始点播") |
| | | @Parameter(name = "deviceId", description = "设备国标编号", required = true) |
| | | @Parameter(name = "channelId", description = "通道国标编号", required = true) |
| | | @GetMapping("/start/{deviceId}/{channelId}") |
| | | public DeferredResult<WVPResult<StreamInfo>> play(@PathVariable String deviceId, |
| | | @PathVariable String channelId) { |
| | | public DeferredResult<WVPResult<StreamInfo>> play(HttpServletRequest request, @PathVariable String deviceId, |
| | | @PathVariable String channelId) { |
| | | |
| | | // 获取可用的zlm |
| | | Device device = storager.queryVideoDevice(deviceId); |
| | | MediaServerItem newMediaServerItem = playService.getNewMediaServerItem(device); |
| | | PlayResult playResult = playService.play(newMediaServerItem, deviceId, channelId, null, null, null); |
| | | |
| | | return playResult.getResult(); |
| | | RequestMessage msg = new RequestMessage(); |
| | | String key = DeferredResultHolder.CALLBACK_CMD_PLAY + deviceId + channelId; |
| | | boolean exist = resultHolder.exist(key, null); |
| | | msg.setKey(key); |
| | | String uuid = UUID.randomUUID().toString(); |
| | | msg.setId(uuid); |
| | | DeferredResult<WVPResult<StreamInfo>> result = new DeferredResult<>(userSetting.getPlayTimeout().longValue()); |
| | | DeferredResultEx<WVPResult<StreamInfo>> deferredResultEx = new DeferredResultEx<>(result); |
| | | |
| | | result.onTimeout(()->{ |
| | | logger.info("点播接口等待超时"); |
| | | // 释放rtpserver |
| | | WVPResult<StreamInfo> wvpResult = new WVPResult<>(); |
| | | wvpResult.setCode(ErrorCode.ERROR100.getCode()); |
| | | wvpResult.setMsg("点播超时"); |
| | | msg.setData(wvpResult); |
| | | resultHolder.invokeResult(msg); |
| | | }); |
| | | |
| | | // TODO 在点播未成功的情况下在此调用接口点播会导致返回的流地址ip错误 |
| | | deferredResultEx.setFilter(result1 -> { |
| | | WVPResult<StreamInfo> wvpResult1 = (WVPResult<StreamInfo>)result1; |
| | | WVPResult<StreamInfo> clone = null; |
| | | try { |
| | | clone = (WVPResult<StreamInfo>)wvpResult1.clone(); |
| | | } catch (CloneNotSupportedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | if (clone.getCode() == ErrorCode.SUCCESS.getCode()) { |
| | | StreamInfo data = clone.getData().clone(); |
| | | data.channgeStreamIp(request.getLocalName()); |
| | | clone.setData(data); |
| | | } |
| | | return clone; |
| | | }); |
| | | |
| | | // 录像查询以channelId作为deviceId查询 |
| | | resultHolder.put(key, uuid, deferredResultEx); |
| | | |
| | | if (!exist) { |
| | | playService.play(newMediaServerItem, deviceId, channelId, null, null, null); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | |
| | |
| | | @GetMapping(value = "/restart") |
| | | @ResponseBody |
| | | public void restart() { |
| | | taskExecutor.execute(()-> { |
| | | try { |
| | | Thread.sleep(3000); |
| | | SipProvider up = (SipProvider) SpringBeanFactory.getBean("udpSipProvider"); |
| | | SipStackImpl stack = (SipStackImpl) up.getSipStack(); |
| | | stack.stop(); |
| | | Iterator listener = stack.getListeningPoints(); |
| | | while (listener.hasNext()) { |
| | | stack.deleteListeningPoint((ListeningPoint) listener.next()); |
| | | } |
| | | Iterator providers = stack.getSipProviders(); |
| | | while (providers.hasNext()) { |
| | | stack.deleteSipProvider((SipProvider) providers.next()); |
| | | } |
| | | VManageBootstrap.restart(); |
| | | } catch (InterruptedException | ObjectInUseException e) { |
| | | throw new ControllerException(ErrorCode.ERROR100.getCode(), e.getMessage()); |
| | | } |
| | | }); |
| | | // taskExecutor.execute(()-> { |
| | | // try { |
| | | // Thread.sleep(3000); |
| | | // SipProvider up = (SipProvider) SpringBeanFactory.getBean("udpSipProvider"); |
| | | // SipStackImpl stack = (SipStackImpl) up.getSipStack(); |
| | | // stack.stop(); |
| | | // Iterator listener = stack.getListeningPoints(); |
| | | // while (listener.hasNext()) { |
| | | // stack.deleteListeningPoint((ListeningPoint) listener.next()); |
| | | // } |
| | | // Iterator providers = stack.getSipProviders(); |
| | | // while (providers.hasNext()) { |
| | | // stack.deleteSipProvider((SipProvider) providers.next()); |
| | | // } |
| | | // VManageBootstrap.restart(); |
| | | // } catch (InterruptedException | ObjectInUseException e) { |
| | | // throw new ControllerException(ErrorCode.ERROR100.getCode(), e.getMessage()); |
| | | // } |
| | | // }); |
| | | }; |
| | | |
| | | @Operation(summary = "获取系统信息信息") |
| | |
| | | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| | | import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; |
| | | import com.genersoft.iot.vmp.service.IMediaServerService; |
| | | import com.genersoft.iot.vmp.service.IMediaService; |
| | | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| | | import com.genersoft.iot.vmp.service.IStreamProxyService; |
| | | import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; |
| | | import com.genersoft.iot.vmp.vmanager.bean.WVPResult; |
| | | import com.github.pagehelper.PageInfo; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.Parameters; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.util.ObjectUtils; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | @SuppressWarnings("rawtypes") |
| | |
| | | }) |
| | | @PostMapping(value = "/save") |
| | | @ResponseBody |
| | | public StreamInfo save(@RequestBody StreamProxyItem param){ |
| | | public StreamInfo save(@RequestBody StreamProxyItem param){ |
| | | logger.info("添加代理: " + JSONObject.toJSONString(param)); |
| | | if (ObjectUtils.isEmpty(param.getMediaServerId())) { |
| | | param.setMediaServerId("auto"); |
| | |
| | | return resultDeferredResult; |
| | | } |
| | | MediaServerItem newMediaServerItem = playService.getNewMediaServerItem(device); |
| | | PlayResult play = playService.play(newMediaServerItem, serial, code, (mediaServerItem, response)->{ |
| | | playService.play(newMediaServerItem, serial, code, (mediaServerItem, response)->{ |
| | | StreamInfo streamInfo = redisCatchStorage.queryPlayByDevice(serial, code); |
| | | JSONObject result = new JSONObject(); |
| | | result.put("StreamID", streamInfo.getStream()); |
| | |
| | | id: 44010200492000000001 |
| | | # [可选] 默认设备认证密码,后续扩展使用设备单独密码, 移除密码将不进行校验 |
| | | password: admin123 |
| | | # [可选] 心跳超时时间, 建议设置为心跳周期的三倍 |
| | | keepalive-timeout: 255 |
| | | # [可选] 国标级联注册失败,再次发起注册的时间间隔。 默认60秒 |
| | | register-time-interval: 60 |
| | | # [可选] 云台控制速度 |
| | |
| | | logInDatebase: true |
| | | # 使用推流状态作为推流通道状态 |
| | | use-pushing-as-status: true |
| | | # 使用来源请求ip作为streamIp |
| | | use-source-ip-as-stream-ip: true |
| | | # 按需拉流, true:有人观看拉流,无人观看释放, false:拉起后不自动释放 |
| | | stream-on-demand: true |
| | | # 推流鉴权, 默认开启 |
| | |
| | | 更多地址<i class="el-icon-arrow-down el-icon--right"></i> |
| | | </el-button> |
| | | <el-dropdown-menu slot="dropdown" > |
| | | <el-dropdown-item :command="streamInfo.flv"> |
| | | <el-dropdown-item :command="streamInfo.flv.url"> |
| | | <el-tag >FLV:</el-tag> |
| | | <span>{{ streamInfo.flv }}</span> |
| | | <span>{{ streamInfo.flv.url }}</span> |
| | | </el-dropdown-item> |
| | | <el-dropdown-item :command="streamInfo.https_flv"> |
| | | <el-dropdown-item :command="streamInfo.https_flv.url"> |
| | | <el-tag >FLV(https):</el-tag> |
| | | <span>{{ streamInfo.https_flv }}</span> |
| | | <span>{{ streamInfo.https_flv.url }}</span> |
| | | </el-dropdown-item> |
| | | <el-dropdown-item :command="streamInfo.ws_flv"> |
| | | <el-dropdown-item :command="streamInfo.ws_flv.url"> |
| | | <el-tag >FLV(ws):</el-tag> |
| | | <span >{{ streamInfo.ws_flv }}</span> |
| | | <span >{{ streamInfo.ws_flv.url }}</span> |
| | | </el-dropdown-item> |
| | | <el-dropdown-item :command="streamInfo.wss_flv"> |
| | | <el-dropdown-item :command="streamInfo.wss_flv.url"> |
| | | <el-tag >FLV(wss):</el-tag> |
| | | <span>{{ streamInfo.wss_flv }}</span> |
| | | <span>{{ streamInfo.wss_flv.url }}</span> |
| | | </el-dropdown-item> |
| | | <el-dropdown-item :command="streamInfo.fmp4"> |
| | | <el-dropdown-item :command="streamInfo.fmp4.url"> |
| | | <el-tag >FMP4:</el-tag> |
| | | <span>{{ streamInfo.fmp4 }}</span> |
| | | <span>{{ streamInfo.fmp4.url }}</span> |
| | | </el-dropdown-item> |
| | | <el-dropdown-item :command="streamInfo.https_fmp4"> |
| | | <el-dropdown-item :command="streamInfo.https_fmp4.url"> |
| | | <el-tag >FMP4(https):</el-tag> |
| | | <span>{{ streamInfo.https_fmp4 }}</span> |
| | | <span>{{ streamInfo.https_fmp4.url }}</span> |
| | | </el-dropdown-item> |
| | | <el-dropdown-item :command="streamInfo.ws_fmp4"> |
| | | <el-dropdown-item :command="streamInfo.ws_fmp4.url"> |
| | | <el-tag >FMP4(ws):</el-tag> |
| | | <span>{{ streamInfo.ws_fmp4 }}</span> |
| | | <span>{{ streamInfo.ws_fmp4.url }}</span> |
| | | </el-dropdown-item> |
| | | <el-dropdown-item :command="streamInfo.wss_fmp4"> |
| | | <el-dropdown-item :command="streamInfo.wss_fmp4.url"> |
| | | <el-tag >FMP4(wss):</el-tag> |
| | | <span>{{ streamInfo.wss_fmp4 }}</span> |
| | | <span>{{ streamInfo.wss_fmp4.url }}</span> |
| | | </el-dropdown-item> |
| | | <el-dropdown-item :command="streamInfo.hls"> |
| | | <el-dropdown-item :command="streamInfo.hls.url"> |
| | | <el-tag>HLS:</el-tag> |
| | | <span>{{ streamInfo.hls }}</span> |
| | | <span>{{ streamInfo.hls.url }}</span> |
| | | </el-dropdown-item> |
| | | <el-dropdown-item :command="streamInfo.https_hls"> |
| | | <el-dropdown-item :command="streamInfo.https_hls.url"> |
| | | <el-tag >HLS(https):</el-tag> |
| | | <span>{{ streamInfo.https_hls }}</span> |
| | | <span>{{ streamInfo.https_hls.url }}</span> |
| | | </el-dropdown-item> |
| | | <el-dropdown-item :command="streamInfo.ws_hls"> |
| | | <el-dropdown-item :command="streamInfo.ws_hls.url"> |
| | | <el-tag >HLS(ws):</el-tag> |
| | | <span>{{ streamInfo.ws_hls }}</span> |
| | | <span>{{ streamInfo.ws_hls.url }}</span> |
| | | </el-dropdown-item> |
| | | <el-dropdown-item :command="streamInfo.wss_hls"> |
| | | <el-dropdown-item :command="streamInfo.wss_hls.url"> |
| | | <el-tag >HLS(wss):</el-tag> |
| | | <span>{{ streamInfo.wss_hls }}</span> |
| | | <span>{{ streamInfo.wss_hls.url }}</span> |
| | | </el-dropdown-item> |
| | | <el-dropdown-item :command="streamInfo.ts"> |
| | | <el-dropdown-item :command="streamInfo.ts.url"> |
| | | <el-tag>TS:</el-tag> |
| | | <span>{{ streamInfo.ts }}</span> |
| | | <span>{{ streamInfo.ts.url }}</span> |
| | | </el-dropdown-item> |
| | | <el-dropdown-item :command="streamInfo.https_ts"> |
| | | <el-dropdown-item :command="streamInfo.https_ts.url"> |
| | | <el-tag>TS(https):</el-tag> |
| | | <span>{{ streamInfo.https_ts }}</span> |
| | | <span>{{ streamInfo.https_ts.url }}</span> |
| | | </el-dropdown-item> |
| | | <el-dropdown-item :command="streamInfo.ws_ts"> |
| | | <el-dropdown-item :command="streamInfo.ws_ts.url"> |
| | | <el-tag>TS(ws):</el-tag> |
| | | <span>{{ streamInfo.ws_ts }}</span> |
| | | <span>{{ streamInfo.ws_ts.url }}</span> |
| | | </el-dropdown-item> |
| | | <el-dropdown-item :command="streamInfo.wss_ts"> |
| | | <el-dropdown-item :command="streamInfo.wss_ts.url"> |
| | | <el-tag>TS(wss):</el-tag> |
| | | <span>{{ streamInfo.wss_ts }}</span> |
| | | <span>{{ streamInfo.wss_ts.url }}</span> |
| | | </el-dropdown-item> |
| | | <el-dropdown-item :command="streamInfo.rtc"> |
| | | <el-dropdown-item :command="streamInfo.rtc.url"> |
| | | <el-tag >RTC:</el-tag> |
| | | <span>{{ streamInfo.rtc }}</span> |
| | | <span>{{ streamInfo.rtc.url }}</span> |
| | | </el-dropdown-item> |
| | | <el-dropdown-item :command="streamInfo.rtcs"> |
| | | <el-dropdown-item :command="streamInfo.rtcs.url"> |
| | | <el-tag >RTCS:</el-tag> |
| | | <span>{{ streamInfo.rtcs }}</span> |
| | | </el-dropdown-item> |
| | | <el-dropdown-item :command="streamInfo.rtmp"> |
| | | <el-dropdown-item :command="streamInfo.rtmp.url"> |
| | | <el-tag >RTMP:</el-tag> |
| | | <span>{{ streamInfo.rtmp }}</span> |
| | | <span>{{ streamInfo.rtmp.url }}</span> |
| | | </el-dropdown-item> |
| | | <el-dropdown-item :command="streamInfo.rtmps"> |
| | | <el-dropdown-item :command="streamInfo.rtmps.url"> |
| | | <el-tag >RTMPS:</el-tag> |
| | | <span>{{ streamInfo.rtmps }}</span> |
| | | <span>{{ streamInfo.rtmps.url }}</span> |
| | | </el-dropdown-item> |
| | | <el-dropdown-item :command="streamInfo.rtsp"> |
| | | <el-dropdown-item :command="streamInfo.rtsp.url"> |
| | | <el-tag >RTSP:</el-tag> |
| | | <span>{{ streamInfo.rtsp }}</span> |
| | | <span>{{ streamInfo.rtsp.url }}</span> |
| | | </el-dropdown-item> |
| | | <el-dropdown-item :command="streamInfo.rtsps"> |
| | | <el-dropdown-item :command="streamInfo.rtsps.url"> |
| | | <el-tag >RTSPS:</el-tag> |
| | | <span>{{ streamInfo.rtsps }}</span> |
| | | <span>{{ streamInfo.rtsps.url }}</span> |
| | | </el-dropdown-item> |
| | | </el-dropdown-menu> |
| | | </el-dropdown> |
| | |
| | | getUrlByStreamInfo(){ |
| | | console.log(this.streamInfo) |
| | | if (location.protocol === "https:") { |
| | | this.videoUrl = this.streamInfo[this.player[this.activePlayer][1]] |
| | | this.videoUrl = this.streamInfo[this.player[this.activePlayer][1]].url |
| | | }else { |
| | | this.videoUrl = this.streamInfo[this.player[this.activePlayer][0]] |
| | | this.videoUrl = this.streamInfo[this.player[this.activePlayer][0]].url |
| | | } |
| | | return this.videoUrl; |
| | | |
| | |
| | | if (res.data.code === 0 && res.data.data) { |
| | | let videoUrl; |
| | | if (location.protocol === "https:") { |
| | | videoUrl = res.data.data.wss_flv; |
| | | videoUrl = res.data.data.wss_flv.url; |
| | | } else { |
| | | videoUrl = res.data.data.ws_flv; |
| | | videoUrl = res.data.data.ws_flv.url; |
| | | } |
| | | itemData.playUrl = videoUrl; |
| | | that.setPlayUrl(videoUrl, idxTmp); |