20260209:从http更换成https,监控拉流失败(跨域问题)
This commit is contained in:
parent
121d0b41d8
commit
ba3eb91485
@ -394,10 +394,28 @@ public class ZmlHookServiceImpl implements IZmlHookService {
|
||||
return streamUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建 HTTP 主机地址(ip:port),当端口为标准端口(80)时省略端口号
|
||||
*/
|
||||
private String buildHttpHost(MediaServer mediaInfo) {
|
||||
if (mediaInfo.getPortHttp() != null && mediaInfo.getPortHttp() == 80) {
|
||||
return mediaInfo.getIp();
|
||||
}
|
||||
return String.format("%s:%s", mediaInfo.getIp(), mediaInfo.getPortHttp());
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建 HTTPS 主机地址。使用 HTTPS 协议时,流媒体请求通过 Nginx 反向代理(443端口)转发,
|
||||
* 因此 HTTPS URL 只使用域名,不拼接 ZLMediaKit 的 portHttps,避免跨域问题。
|
||||
*/
|
||||
private String buildHttpsHost(MediaServer mediaInfo) {
|
||||
return mediaInfo.getDomain();
|
||||
}
|
||||
|
||||
public void setFlv(String app, Stream streamUrl, MediaServer mediaInfo, String streamId, String secret) {
|
||||
String file = String.format("%s/%s.live.flv", app, streamId);
|
||||
String host = String.format("%s:%s", mediaInfo.getIp(), mediaInfo.getPortHttp());
|
||||
String hosts = String.format("%s:%s", mediaInfo.getDomain(), mediaInfo.getPortHttps());
|
||||
String host = buildHttpHost(mediaInfo);
|
||||
String hosts = buildHttpsHost(mediaInfo);
|
||||
streamUrl.setFlv(String.format("http://%s/%s?secret=%s", host, file, secret));
|
||||
streamUrl.setWs_flv(String.format("ws://%s/%s?secret=%s", host, file, secret));
|
||||
streamUrl.setHttps_flv(String.format("https://%s/%s?secret=%s", hosts, file, secret));
|
||||
@ -406,8 +424,8 @@ public class ZmlHookServiceImpl implements IZmlHookService {
|
||||
|
||||
public void setFmp4(String app, Stream streamUrl, MediaServer mediaInfo, String streamId, String secret) {
|
||||
String file = String.format("%s/%s.live.mp4", app, streamId);
|
||||
String host = String.format("%s:%s", mediaInfo.getIp(), mediaInfo.getPortHttp());
|
||||
String hosts = String.format("%s:%s", mediaInfo.getDomain(), mediaInfo.getPortHttps());
|
||||
String host = buildHttpHost(mediaInfo);
|
||||
String hosts = buildHttpsHost(mediaInfo);
|
||||
streamUrl.setFmp4(String.format("http://%s/%s?secret=%s", host, file, secret));
|
||||
streamUrl.setWs_fmp4(String.format("ws://%s/%s?secret=%s", host, file, secret));
|
||||
streamUrl.setHttps_fmp4(String.format("https://%s/%s?secret=%s", hosts, file, secret));
|
||||
@ -416,8 +434,8 @@ public class ZmlHookServiceImpl implements IZmlHookService {
|
||||
|
||||
public void setHls(String app, Stream streamUrl, MediaServer mediaInfo, String streamId, String secret) {
|
||||
String file = String.format("%s/%s/hls.m3u8", app, streamId);
|
||||
String host = String.format("%s:%s", mediaInfo.getIp(), mediaInfo.getPortHttp());
|
||||
String hosts = String.format("%s:%s", mediaInfo.getDomain(), mediaInfo.getPortHttps());
|
||||
String host = buildHttpHost(mediaInfo);
|
||||
String hosts = buildHttpsHost(mediaInfo);
|
||||
streamUrl.setHls(String.format("http://%s/%s?secret=%s", host, file, secret));
|
||||
streamUrl.setWs_hls(String.format("ws://%s/%s?secret=%s", host, file, secret));
|
||||
streamUrl.setHttps_hls(String.format("https://%s/%s?secret=%s", hosts, file, secret));
|
||||
@ -426,8 +444,8 @@ public class ZmlHookServiceImpl implements IZmlHookService {
|
||||
|
||||
public void setRtc(String app, Stream streamUrl, MediaServer mediaInfo, String streamId, boolean isPlay) {
|
||||
String file = String.format("index/api/webrtc?app=%s&stream=%s&type=%s", app, streamId, isPlay ? "play" : "push");
|
||||
String host = String.format("%s:%s", mediaInfo.getIp(), mediaInfo.getPortHttp());
|
||||
String hosts = String.format("%s:%s", mediaInfo.getDomain(), mediaInfo.getPortHttps());
|
||||
String host = buildHttpHost(mediaInfo);
|
||||
String hosts = buildHttpsHost(mediaInfo);
|
||||
streamUrl.setRtc(String.format("http://%s/%s", host, file));
|
||||
streamUrl.setRtcs(String.format("https://%s/%s", hosts, file));
|
||||
}
|
||||
|
||||
@ -567,7 +567,7 @@ export default {
|
||||
type: 'warning'
|
||||
});
|
||||
const res = await removeAutoCalibrationConfig({
|
||||
deviceId: config.deviceId,
|
||||
serialNumber: config.serialNumber,
|
||||
identifier: config.identifier
|
||||
});
|
||||
if (res.code === 200) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user