From 1a3d851bb2f245c90cf8dee8e9c8a9df93eed863 Mon Sep 17 00:00:00 2001 From: zhouhao Date: Fri, 14 Jun 2024 18:54:21 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=BC=98=E5=8C=96=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../zlmedia/restful/ZLMediaConfigs.java | 47 ++++++++++++++++++- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/zlmedia4j-restful/src/main/java/org/jetlinks/zlmedia/restful/ZLMediaConfigs.java b/zlmedia4j-restful/src/main/java/org/jetlinks/zlmedia/restful/ZLMediaConfigs.java index 2c9f420..ca9b150 100644 --- a/zlmedia4j-restful/src/main/java/org/jetlinks/zlmedia/restful/ZLMediaConfigs.java +++ b/zlmedia4j-restful/src/main/java/org/jetlinks/zlmedia/restful/ZLMediaConfigs.java @@ -73,12 +73,12 @@ public class ZLMediaConfigs { /** * 自定义密钥 */ - private String secret = UUID.randomUUID().toString().replace("-",""); + private String secret = UUID.randomUUID().toString().replace("-", ""); public Map createConfigs() { Map configs = new HashMap<>(); - configs.put("api.secret",secret); + configs.put("api.secret", secret); if (others != null) { configs.putAll(others); @@ -120,6 +120,21 @@ public Map createConfigs() { return configs; } + public void setConfig(String key, String value) { + if (ports.setConfig(key, value)) { + return; + } + switch (key) { + case "api.secret": + secret = value; + break; + case "general.mediaServerId": + serverId = value; + break; + + } + } + @Getter @Setter public static class Ports { @@ -131,6 +146,34 @@ public static class Ports { private int rtc = 8000; private int srt = 9000; + public boolean setConfig(String key, String value) { + switch (key) { + case "rtsp.port": + setRtsp(Integer.parseInt(value)); + return true; + case "rtmp.port": + setRtmp(Integer.parseInt(value)); + return true; + case "http.port": + setHttp(Integer.parseInt(value)); + return true; + case "rtp_proxy.port": + setRtp(Integer.parseInt(value)); + return true; + case "rtp_proxy.port_range": + String[] range = value.split("-"); + setRtpRange(new int[]{Integer.parseInt(range[0]), Integer.parseInt(range[1])}); + return true; + case "rtc.port": + setRtc(Integer.parseInt(value)); + return true; + case "srt.port": + setSrt(Integer.parseInt(value)); + return true; + } + return false; + } + public void applyConfig(Map config) { config.put("http.port", String.valueOf(http));