package com.jisco.dynamicweight.util;

import com.jisco.dynamicweight.dynamicbasecamera.model.DynamicBaseCamera;

/**
 * Created by Hzj on 2021/5/25.
 */
public class VideoUtil {

    public static String getRTSPUrl(DynamicBaseCamera camera) {
        String url = "";
        if (camera.getManufacturer().indexOf("海康") >= 0) {//海康
            url = "rtsp://" + camera.getUsername() + ":" + camera.getPassword() + "@" + camera.getCameraIp() + ":" + camera.getRstpPort() + "/Streaming/Channels/" + camera.getCameraChannel() + "0" + camera.getVedioType() + "?transportmode=unicast";
        } else if (camera.getManufacturer().indexOf("大华") >= 0) {//大华
            url = "rtsp://" + camera.getUsername() + ":" + camera.getPassword() + "@" + camera.getCameraIp() + ":" + camera.getRstpPort() + "/cam/realmonitor?channel=" + camera.getCameraChannel() + "&subtype=" + (camera.getVedioType() - 1) + "";
        } else {
            throw new RuntimeException("不支持的设备厂家");
        }
        return url;
    }

    //回放地址
    public static String getRTSPPlayBackUrl(DynamicBaseCamera camera) {
        String url = "rtsp://" + camera.getUsername() + ":" + camera.getPassword() + "@" + camera.getCameraIp() + ":" + camera.getRstpPort() + "/Streaming/tracks/" + camera.getCameraChannel() + "0" + camera.getVedioType() + "";
        return url;
    }
}
