支持公网部署
This commit is contained in:
parent
ce1aa6137b
commit
81f9119da6
@ -31,9 +31,10 @@ public class MediaServerConfig {
|
||||
@JSONField(name = "general.streamNoneReaderDelayMS")
|
||||
private String generalStreamNoneReaderDelayMS;
|
||||
|
||||
@JSONField(name = "general.localIP")
|
||||
private String localIP;
|
||||
|
||||
private String wanIp;
|
||||
|
||||
@JSONField(name = "hls.fileBufSize")
|
||||
private String hlsFileBufSize;
|
||||
|
||||
@ -719,4 +720,12 @@ public class MediaServerConfig {
|
||||
public void setShellPhell(String shellPhell) {
|
||||
this.shellPhell = shellPhell;
|
||||
}
|
||||
|
||||
public String getWanIp() {
|
||||
return wanIp;
|
||||
}
|
||||
|
||||
public void setWanIp(String wanIp) {
|
||||
this.wanIp = wanIp;
|
||||
}
|
||||
}
|
||||
|
@ -285,9 +285,9 @@ public class SIPCommander implements ISIPCommander {
|
||||
//
|
||||
StringBuffer content = new StringBuffer(200);
|
||||
content.append("v=0\r\n");
|
||||
content.append("o="+channelId+" 0 0 IN IP4 "+mediaInfo.getLocalIP()+"\r\n");
|
||||
content.append("o="+channelId+" 0 0 IN IP4 "+mediaInfo.getWanIp()+"\r\n");
|
||||
content.append("s=Play\r\n");
|
||||
content.append("c=IN IP4 "+mediaInfo.getLocalIP()+"\r\n");
|
||||
content.append("c=IN IP4 "+mediaInfo.getWanIp()+"\r\n");
|
||||
content.append("t=0 0\r\n");
|
||||
if("TCP-PASSIVE".equals(streamMode)) {
|
||||
content.append("m=video "+ mediaPort +" TCP/RTP/AVP 96 98 97\r\n");
|
||||
|
@ -134,22 +134,22 @@ public class ZLMHttpHookListener {
|
||||
StreamInfo streamInfoForPlay = storager.queryPlayBySSRC(ssrc);
|
||||
if ("rtp".equals(app) && streamInfoForPlay != null ) {
|
||||
MediaServerConfig mediaInfo = storager.getMediaInfo();
|
||||
streamInfoForPlay.setFlv(String.format("http://%s:%s/rtp/%s.flv", mediaInfo.getLocalIP(), mediaInfo.getHttpPort(), streamId));
|
||||
streamInfoForPlay.setWs_flv(String.format("ws://%s:%s/rtp/%s.flv", mediaInfo.getLocalIP(), mediaInfo.getHttpPort(), streamId));
|
||||
streamInfoForPlay.setRtmp(String.format("rtmp://%s:%s/rtp/%s", mediaInfo.getLocalIP(), mediaInfo.getRtmpPort(), streamId));
|
||||
streamInfoForPlay.setHls(String.format("http://%s:%s/rtp/%s/hls.m3u8", mediaInfo.getLocalIP(), mediaInfo.getHttpPort(), streamId));
|
||||
streamInfoForPlay.setRtsp(String.format("rtsp://%s:%s/rtp/%s", mediaInfo.getLocalIP(), mediaInfo.getRtspPort(), streamId));
|
||||
streamInfoForPlay.setFlv(String.format("http://%s:%s/rtp/%s.flv", mediaInfo.getWanIp(), mediaInfo.getHttpPort(), streamId));
|
||||
streamInfoForPlay.setWs_flv(String.format("ws://%s:%s/rtp/%s.flv", mediaInfo.getWanIp(), mediaInfo.getHttpPort(), streamId));
|
||||
streamInfoForPlay.setRtmp(String.format("rtmp://%s:%s/rtp/%s", mediaInfo.getWanIp(), mediaInfo.getRtmpPort(), streamId));
|
||||
streamInfoForPlay.setHls(String.format("http://%s:%s/rtp/%s/hls.m3u8", mediaInfo.getWanIp(), mediaInfo.getHttpPort(), streamId));
|
||||
streamInfoForPlay.setRtsp(String.format("rtsp://%s:%s/rtp/%s", mediaInfo.getWanIp(), mediaInfo.getRtspPort(), streamId));
|
||||
storager.startPlay(streamInfoForPlay);
|
||||
}
|
||||
|
||||
StreamInfo streamInfoForPlayBack = storager.queryPlaybackBySSRC(ssrc);
|
||||
if ("rtp".equals(app) && streamInfoForPlayBack != null ) {
|
||||
MediaServerConfig mediaInfo = storager.getMediaInfo();
|
||||
streamInfoForPlayBack.setFlv(String.format("http://%s:%s/rtp/%s.flv", mediaInfo.getLocalIP(), mediaInfo.getHttpPort(), streamId));
|
||||
streamInfoForPlayBack.setWs_flv(String.format("ws://%s:%s/rtp/%s.flv", mediaInfo.getLocalIP(), mediaInfo.getHttpPort(), streamId));
|
||||
streamInfoForPlayBack.setRtmp(String.format("rtmp://%s:%s/rtp/%s", mediaInfo.getLocalIP(), mediaInfo.getRtmpPort(), streamId));
|
||||
streamInfoForPlayBack.setHls(String.format("http://%s:%s/rtp/%s/hls.m3u8", mediaInfo.getLocalIP(), mediaInfo.getHttpPort(), streamId));
|
||||
streamInfoForPlayBack.setRtsp(String.format("rtsp://%s:%s/rtp/%s", mediaInfo.getLocalIP(), mediaInfo.getRtspPort(), streamId));
|
||||
streamInfoForPlayBack.setFlv(String.format("http://%s:%s/rtp/%s.flv", mediaInfo.getWanIp(), mediaInfo.getHttpPort(), streamId));
|
||||
streamInfoForPlayBack.setWs_flv(String.format("ws://%s:%s/rtp/%s.flv", mediaInfo.getWanIp(), mediaInfo.getHttpPort(), streamId));
|
||||
streamInfoForPlayBack.setRtmp(String.format("rtmp://%s:%s/rtp/%s", mediaInfo.getWanIp(), mediaInfo.getRtmpPort(), streamId));
|
||||
streamInfoForPlayBack.setHls(String.format("http://%s:%s/rtp/%s/hls.m3u8", mediaInfo.getWanIp(), mediaInfo.getHttpPort(), streamId));
|
||||
streamInfoForPlayBack.setRtsp(String.format("rtsp://%s:%s/rtp/%s", mediaInfo.getWanIp(), mediaInfo.getRtspPort(), streamId));
|
||||
storager.startPlayback(streamInfoForPlayBack);
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,7 @@ import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
@ -32,6 +33,9 @@ public class ZLMRunner implements CommandLineRunner {
|
||||
@Value("${media.ip}")
|
||||
private String mediaIp;
|
||||
|
||||
@Value("${media.wanIp}")
|
||||
private String mediaWanIp;
|
||||
|
||||
@Value("${media.port}")
|
||||
private int mediaPort;
|
||||
|
||||
@ -75,6 +79,7 @@ public class ZLMRunner implements CommandLineRunner {
|
||||
if (data != null && data.size() > 0) {
|
||||
mediaServerConfig = JSON.parseObject(JSON.toJSONString(data.get(0)), MediaServerConfig.class);
|
||||
mediaServerConfig.setLocalIP(mediaIp);
|
||||
mediaServerConfig.setWanIp(StringUtils.isEmpty(mediaWanIp)? mediaIp: mediaWanIp);
|
||||
}
|
||||
} else {
|
||||
logger.error("getMediaServerConfig失败, 1s后重试");
|
||||
|
@ -42,6 +42,7 @@ public class PlayController {
|
||||
public ResponseEntity<String> play(@PathVariable String deviceId, @PathVariable String channelId,
|
||||
Integer getEncoding) {
|
||||
|
||||
if (getEncoding == null) getEncoding = 0;
|
||||
Device device = storager.queryVideoDevice(deviceId);
|
||||
StreamInfo streamInfo = storager.queryPlayByDevice(deviceId, channelId);
|
||||
|
||||
@ -146,3 +147,4 @@ public class PlayController {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -41,6 +41,7 @@ auth: #32位小写md5加密(默认密码为admin)
|
||||
|
||||
media: #zlm服务器的ip与http端口, 重点: 这是http端口
|
||||
ip: 192.168.1.44
|
||||
wanIp:
|
||||
port: 80
|
||||
secret: 035c73f7-bb6b-4889-a715-d9eb2d1925cc
|
||||
streamNoneReaderDelayMS: 1800000 # 无人观看多久自动关闭流
|
||||
|
Loading…
Reference in New Issue
Block a user