VionConfig.java 2.08 KB
package com.viontech.fanxing.commons.config;

import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Configuration;

import java.util.List;

/**
 * .
 *
 * @author 谢明辉
 * @date 2021/9/8
 */
@RefreshScope
@Configuration
@Getter
@Setter
@ConfigurationProperties(prefix = "vion")
@Slf4j
public class VionConfig {

    private Image image;
    /** 是否启用转发 */
    private boolean enableForward;
    /** auth 服务地址 */
    private String authPath;
    private Gateway gateway;
    /** 支持的视频格式列表 */
    private List<String> supportedVideoFormats;
    /** 需要跳过 token 验证的 url 的正则表达式列表 */
    private List<String> skipAuth;
    /** 平台srs的配置 */
    private Srs srs;

    public @Getter
    @Setter
    static class Image {
        /** images 本地存储路径 */
        private String path;
        /** 图片保存天数 */
        private Integer keep;
        /** 访问 images 前缀,images 包含录像文件和分析图片 */
        private String urlPrefix;
    }

    public @Getter
    @Setter
    static class Gateway {
        /** 网关 ip,以后可能改为 nginx */
        private String ip;
        /** 网关端口 */
        private String port;
    }

    public @Getter
    @Setter
    static class Srs {
        private String ip;
        private String rtmpPort = "1935";
        private String httpPort = "8080";

        public String getRtmpUrl(String taskUnid) {
            String url = "rtmp://" + ip + ":" + rtmpPort + "/live/" + taskUnid;
            log.debug(url);
            return url;
        }

        public String getHttpUrl(String taskUnid) {
            String url = "http://36.112.68.214:30010/srs/live/" + taskUnid + ".flv";
//            String url = "http://" + ip + ":" + httpPort + "/srs/live/" + taskUnid + ".flv";
            log.debug(url);
            return url;
        }
    }


}