function secondDisplay(enable) {
    if (enable == 0) {
        $(".tab_card").addClass("display_off");
        $(".tip_content").addClass("display_off");
        $(".tab_content").addClass("display_off");

        $("#encodePart_tab").removeClass("display_off");
        $("#secondDisable_tip").removeClass("display_off");
    } else {
        $("#secondDisable_tip").addClass("display_off");
    }
}

function refreshEncode() {
    $.ajax({
        type: "GET",
        url: "/get_output?input=" + input + "&output=" + output,
        dataType: "xml",
        cache: false,
        success: function (data) {
            if (output != 0) {
                var venc_enable = $(data).find("venc_enable").text();
                secondDisplay(venc_enable);
            }
            var venc_codec_supported = $(data).find("venc_codec_supported").text();
            var venc_codec_words = venc_codec_supported.split(',');
            var venc_codec_option = "";
            for (var i = 0; i < venc_codec_words.length; ++i) {
                var codec_val = 96;
                if (venc_codec_words[i] == "H.264") {
                    codec_val = 96;
                } else if (venc_codec_words[i] == "H.265") {
                    codec_val = 265;
                } else if (venc_codec_words[i] == "MJPEG") {
                    codec_val = 1002;
                }
                venc_codec_option += "<option value='" + codec_val + "'>" + venc_codec_words[i] + "</option>";
            }
            $("#venc_codec").html(venc_codec_option);

            var venc_codec = $(data).find("venc_codec").text();
            $("#venc_codec").val(venc_codec);

            var venc_prefer_framerate = $(data).find("venc_prefer_framerate").text();
            var venc_framerate = $(data).find("venc_framerate").text();
            if (venc_prefer_framerate == "6000000" || venc_prefer_framerate == "3000000") {
                $("#venc_framerate").val(venc_prefer_framerate);
            } else {
                $("#venc_framerate").val(0);
            }
            $("#venc_framerate_custom").val(venc_framerate);
            onChangeSelectFramerate();

            var venc_gop = $(data).find("venc_gop").text();
            $("#venc_gopTxt").val(venc_gop);

            var width = $(data).find("vi_cap_width").text();
            var height = $(data).find("vi_cap_height").text();
            var des_width = $(data).find("venc_width").text();
            var des_height = $(data).find("venc_height").text();
            var venc_width_height_same_as_input = $(data).find("venc_width_height_same_as_input").text();
            var max_venc_width = $(data).find("max_venc_width").text();
            var max_venc_height = $(data).find("max_venc_height").text();
            var VideoSizehtml = GetVideoSize(
                venc_width_height_same_as_input,
                width,
                height,
                des_width,
                des_height,
                max_venc_width,
                max_venc_height
            );
            $("#Videosize").html(VideoSizehtml);

            var mjpeg_qfactor = $(data).find("mjpeg_qfactor").text();
            $("#mjpeg_qfactor").val(mjpeg_qfactor);

            var venc_profile = $(data).find("venc_profile").text();
            $("#venc_profile").val(venc_profile);

            var venc_cbr_stable = $(data).find("venc_cbr_stable").text();
            $("#venc_cbr_stable").val(venc_cbr_stable);

            var venc_num_b_frames = $(data).find("venc_num_b_frames").text();
            $("#venc_num_b_frames").val(venc_num_b_frames);

            var http_hls_enable = $(data).find("http_hls_enable").text();
            $("#http_hls_enableSle").val(http_hls_enable);

            var http_hls_fmp4_enable = $(data).find("http_hls_fmp4_enable").text();
            $("#http_hls_fmp4_enable").val(http_hls_fmp4_enable);

            var hls_publish_enable = $(data).find("hls_publish_enable").text();
            $("#hls_publish_enable").val(hls_publish_enable);
        }
    });
    $.ajax({
        type: "GET",
        url: "/get_sys",
        dataType: "xml",
        cache: false,
        success: function (data) {
            bFrameMode = $(data).find("b_frame_mode").text();
            if (typeof updateBFrameMode === "function") {
                updateBFrameMode();
            }
        }
    });
}

function OnSelectRtmpType(type) {
    void (type);
}

function checkDress(str) {
    if (typeof str !== "string") return true;
    var trimmed = str.trim();
    return !/^(rtmps?|rtsp):\/\//i.test(trimmed);
}

function refreshTS() {
    $.ajax({
        type: "GET",
        url: "/get_output?input=" + input + "&output=" + output,
        dataType: "xml",
        cache: false,
        success: function (data) {
            var http_ts_uri = $(data).find("http_ts_uri").text();
            $("#http_ts_uriTxt").val(http_ts_uri);

            var http_ts_enable = $(data).find("http_ts_enable").text();
            $("#http_ts_enableSle").val(http_ts_enable);

            var multicast_enable = $(data).find("multicast_enable").text();
            $("#multicast_enable").val(multicast_enable);
            var multicast_ip = $(data).find("multicast_ip").text();
            $("#multicast_ip").val(multicast_ip);
            var multicast_port = $(data).find("multicast_port").text();
            $("#multicast_port").val(multicast_port);

            var venc_codec = $(data).find("venc_codec").text();
            $("#venc_codec").val(venc_codec);
            SetType();

            var ts_muxrate = $(data).find("ts_muxrate").text();
            var venc_rc_mode = $(data).find("venc_rc_mode").text();
            var venc_bitrate = $(data).find("venc_bitrate").text();
            if (ts_muxrate != "0") {
                venc_rc_mode = "5";
                venc_bitrate = ts_muxrate;
            }
            $("#venc_rc_modeSle").val(venc_rc_mode);
            $("#venc_bitrateTxt").val(venc_bitrate);

            var venc_max_qp = $(data).find("venc_max_qp").text();
            var venc_min_qp = $(data).find("venc_min_qp").text();
            $("#venc_max_qp").val(venc_max_qp);
            on_change_rcmode();
            var ts_video_pid = $(data).find("ts_video_pid").text();
            $("#ts_video_pid").val(ts_video_pid);
            var ts_audio_pid = $(data).find("ts_audio_pid").text();
            $("#ts_audio_pid").val(ts_audio_pid);
            var sap_name = $(data).find("sap_name").text();
            $("#sap_name").val(sap_name);

            var ts_transport_stream_id = $(data).find("ts_transport_stream_id").text();
            $("#ts_transport_stream_id").val(ts_transport_stream_id);
            var ts_start_pid = $(data).find("ts_start_pid").text();
            $("#ts_start_pid").val(ts_start_pid);
            var ts_tables_version = $(data).find("ts_tables_version").text();
            $("#ts_tables_version").val(ts_tables_version);
            var ts_rc_mode = $(data).find("ts_rc_mode").text();
            $("#ts_rc_mode").val(ts_rc_mode);
            var ts_service_name = $(data).find("ts_service_name").text();
            $("#ts_service_name").val(ts_service_name);
            var ts_service_provider = $(data).find("ts_service_provider").text();
            $("#ts_service_provider").val(ts_service_provider);
            var ts_pcr_period = $(data).find("ts_pcr_period").text();
            $("#ts_pcr_period").val(ts_pcr_period);
            var ts_pmt_start_pid = $(data).find("ts_pmt_start_pid").text();
            $("#ts_pmt_start_pid").val(ts_pmt_start_pid);
            var ts_original_network_id = $(data).find("ts_original_network_id").text();
            $("#ts_original_network_id").val(ts_original_network_id);
            var ts_system_b = $(data).find("ts_system_b").text();
            $("#ts_system_b").val(ts_system_b);
            var ts_service_id = $(data).find("ts_service_id").text();
            $("#ts_service_id").val(ts_service_id);
            var ts_tdt_enable = $(data).find("ts_tdt_enable").text();
            $("#ts_tdt_enable").val(ts_tdt_enable);

        }
    });
}

function refreshMJPEG() {
    $.ajax({
        type: "GET",
        url: "/get_output?input=" + input + "&output=" + output,
        dataType: "xml",
        cache: false,
        success: function (data) {
            var http_jpg_enable = $(data).find("http_jpg_enable").text();
            $("#http_jpg_enable").val(http_jpg_enable);
            var http_jpg_uri = $(data).find("http_jpg_uri").text();
            $("#http_jpg_uri").val(http_jpg_uri);
            var http_mjpg_enable = $(data).find("http_mjpg_enable").text();
            $("#http_mjpg_enable").val(http_mjpg_enable);
            var http_mjpg_uri = $(data).find("http_mjpg_uri").text();
            $("#http_mjpg_uri").val(http_mjpg_uri);
        }
    });
}

function refreshRTSP() {
    $.ajax({
        type: "GET",
        url: "/get_output?input=" + input + "&output=" + output,
        dataType: "xml",
        cache: false,
        success: function (data) {
            var rtsp_uri = $(data).find("rtsp_uri").text();
            $("#rtsp_uriTxt").val(rtsp_uri);

            var rtsp_enable = $(data).find("rtsp_enable").text();
            $("#rtsp_enableSle").val(rtsp_enable);

            var rtsp_multicast_ip = $(data).find("rtsp_multicast_ip").text();
            $("#rtsp_multicast_ipTxt").val(rtsp_multicast_ip);
            var rtsp_multicast_port = $(data).find("rtsp_multicast_port").text();
            $("#rtsp_multicast_portTxt").val(rtsp_multicast_port);
            OnSelectRtspType();
        }
    });
}

function refreshRTMP() {
    $.ajax({
        type: "GET",
        url: "/get_output?input=" + input + "&output=" + output,
        dataType: "xml",
        cache: false,
        success: function (data) {
            var rtmp_uri = $(data).find("rtmp_uri").text();
            $("#rtmp_uriTxt").val(rtmp_uri);

            var rtmp_enable = $(data).find("rtmp_enable").text();
            $("#rtmp_enableSle").val(rtmp_enable);

            var rtmp_publish_uri_0 = $(data).find("rtmp_publish_uri_0").text();
            $("#rtmp_publish_uri_0").val(rtmp_publish_uri_0);
            var rtmp_publish_uri_1 = $(data).find("rtmp_publish_uri_1").text();
            $("#rtmp_publish_uri_1").val(rtmp_publish_uri_1);
            var rtmp_publish_uri_2 = $(data).find("rtmp_publish_uri_2").text();
            $("#rtmp_publish_uri_2").val(rtmp_publish_uri_2);
            var rtmp_publish_enable_0 = $(data).find("rtmp_publish_enable_0").text();
            $("#rtmp_publish_enableSle_0").val(rtmp_publish_enable_0);
            var rtmp_publish_enable_1 = $(data).find("rtmp_publish_enable_1").text();
            $("#rtmp_publish_enableSle_1").val(rtmp_publish_enable_1);
            var rtmp_publish_enable_2 = $(data).find("rtmp_publish_enable_2").text();
            $("#rtmp_publish_enableSle_2").val(rtmp_publish_enable_2);
            var rtmp_mode = $(data).find("rtmp_mode").text();
            if (rtmp_mode === "") rtmp_mode = "0";
            $("#rtmp_mode").val(rtmp_mode);
        }
    });
}

function refreshSRT() {
    $.ajax({
        type: "GET",
        url: "/get_output?input=" + input + "&output=" + output,
        dataType: "xml",
        cache: false,
        success: function (data) {
            var srt_enable = $(data).find("srt_enable").text();
            $("#srt_enable").val(srt_enable);
            var srt_listener_uri = $(data).find("srt_listener_uri").text();
            $("#srt_listener_uri").val(srt_listener_uri);
            var srt_publish_enable = $(data).find("srt_publish_enable").text();
            $("#srt_publish_enable").val(srt_publish_enable);
            var srt_publish_uri = $(data).find("srt_publish_uri").text();
            $("#srt_publish_uri").val(srt_publish_uri);
        }
    });
}

function refreshWHIP() {
    $.ajax({
        type: "GET",
        url: "/get_output?input=" + input + "&output=" + output,
        dataType: "xml",
        cache: false,
        success: function (data) {
            var webrtc_p2p_http_enable = $(data).find("webrtc_p2p_http_enable").text();
            $("#webrtc_p2p_http_enable").val(webrtc_p2p_http_enable);
            var whip_publish_token = $(data).find("whip_publish_token").text();
            $("#whip_publish_token").val(whip_publish_token);
            var whip_publish_enable = $(data).find("whip_publish_enable").text();
            $("#whip_publish_enable").val(whip_publish_enable);
            var whip_publish_server = $(data).find("whip_publish_server").text();
            $("#whip_publish_server").val(whip_publish_server);
            var webrtc_p2p_ws_url = $(data).find("webrtc_p2p_ws_url").text();
            $("#webrtc_p2p_ws_url").val(webrtc_p2p_ws_url);
            var webrtc_p2p_ws_enable = $(data).find("webrtc_p2p_ws_enable").text();
            $("#webrtc_p2p_ws_enable").val(webrtc_p2p_ws_enable);
            var webrtc_p2p_ws_uuid = $(data).find("webrtc_p2p_ws_uuid").text();
            $("#webrtc_p2p_ws_uuid").val(webrtc_p2p_ws_uuid);
            var webrtc_p2p_ws_auth_token = $(data).find("webrtc_p2p_ws_auth_token").text();
            $("#webrtc_p2p_ws_auth_token").val(webrtc_p2p_ws_auth_token);
        }
    });
}

function uuidv4() {
  const bytes = crypto.getRandomValues(new Uint8Array(16));
  // RFC4122 v4
  bytes[6] = (bytes[6] & 0x0f) | 0x40; // version 4
  bytes[8] = (bytes[8] & 0x3f) | 0x80; // variant 10

  const hex = [...bytes].map(b => b.toString(16).padStart(2, "0")).join("");
  return `${hex.slice(0,8)}-${hex.slice(8,12)}-${hex.slice(12,16)}-${hex.slice(16,20)}-${hex.slice(20)}`;
}

function regenerateUUID() {
    var uuidInput = document.getElementById('webrtc_p2p_ws_uuid');
    var oldUuid = uuidInput.value;
    var preservedPart = '0000';

    // 提取旧 UUID 的第三段 (例如 77c1ccbd-7a3a-05c1-9f4e-... 中的 05c1)
    if (oldUuid && oldUuid.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i)) {
        var parts = oldUuid.split('-');
        preservedPart = parts[2];  // 第三段
    }

    // 生成新的 UUID
    var newUuid = uuidv4();

    // 替换第三段为保留的部分
    var newParts = newUuid.split('-');
    newParts[2] = preservedPart;
    uuidInput.value = newParts.join('-');
}

function refreshTRTC() {
    $.ajax({
        type: "GET",
        url: "/get_output?input=" + input + "&output=" + output,
        dataType: "xml",
        cache: false,
        success: function (data) {
            var trtc_publish_app_id = $(data).find("trtc_publish_app_id").text();
            $("#trtc_publish_app_id").val(trtc_publish_app_id);
            var trtc_publish_enable = $(data).find("trtc_publish_enable").text();
            $("#trtc_publish_enable").val(trtc_publish_enable);
            var trtc_publish_room_id = $(data).find("trtc_publish_room_id").text();
            $("#trtc_publish_room_id").val(trtc_publish_room_id);
            var trtc_publish_user_id = $(data).find("trtc_publish_user_id").text();
            $("#trtc_publish_user_id").val(trtc_publish_user_id);
            var trtc_publish_user_sig = $(data).find("trtc_publish_user_sig").text();
            $("#trtc_publish_user_sig").val(trtc_publish_user_sig);
            changeEncodingtype();
            var trtc_publish_room_id_type = $(data).find("trtc_publish_room_id_type").text();
            $("#trtc_publish_room_id_type").val(trtc_publish_room_id_type);
            var trtc_publish_room_password = $(data).find("trtc_publish_room_password").text();
            $("#trtc_publish_room_password").val(trtc_publish_room_password);
        }
    });
}

function refreshHLS() {
    $.ajax({
        type: "GET",
        url: "/get_output?input=" + input + "&output=" + output,
        dataType: "xml",
        cache: false,
        success: function (data) {
            var http_hls_uri = $(data).find("http_hls_uri").text();
            $("#http_hls_uriTxt").val(http_hls_uri);
            var http_hls_enable = $(data).find("http_hls_enable").text();
            $("#http_hls_enableSle").val(http_hls_enable);
            var hls_publish_enable = $(data).find("hls_publish_enable").text();
            $("#hls_publish_enable").val(hls_publish_enable);
            var hls_publish_uri = $(data).find("hls_publish_uri").text();
            $("#hls_publish_uri").val(hls_publish_uri);
            var http_hls_fmp4_enable = $(data).find("http_hls_fmp4_enable").text();
            $("#http_hls_fmp4_enable").val(http_hls_fmp4_enable);
            var http_hls_fmp4_uri = $(data).find("http_hls_fmp4_uri").text();
            $("#http_hls_fmp4_uri").val(http_hls_fmp4_uri);
        }
    });
}

function refreshOther() {
    $.ajax({
        type: "GET",
        url: "/get_output?input=" + input + "&output=" + output,
        dataType: "xml",
        cache: false,
        success: function (data) {
            var http_flv_uri = $(data).find("http_flv_uri").text();
            $("#http_flv_uriTxt").val(http_flv_uri);

            var http_flv_enable = $(data).find("http_flv_enable").text();
            $("#http_flv_enableSle").val(http_flv_enable);

            var http_fmp4_enable = $(data).find("http_fmp4_enable").text();
            $("#http_fmp4_enable").val(http_fmp4_enable);
            var http_fmp4_uri = $(data).find("http_fmp4_uri").text();
            $("#http_fmp4_uri").val(http_fmp4_uri);

            if (output == 0) {
                var shoutcast_publish_enable = $(data).find("shoutcast_publish_enable").text();
                $("#shoutcast_publish_enable").change(function () {
                    if ($(this).val() === "1" && aenc_codec !== '4') {
                        alert(i18n.t('output.messages.mp3Required'));
                        $(this).val("0");
                        return false;
                    }
                });
                $("#shoutcast_publish_enable").val(shoutcast_publish_enable);
                var shoutcast_publish_uri = $(data).find("shoutcast_publish_uri").text();
                $("#shoutcast_publish_uri").val(shoutcast_publish_uri);
            }

            if (output == 0 || output == 1) {
                var icecast_publish_enable = $(data).find("icecast_publish_enable").text();
                $("#icecast_publish_enable").change(function () {
                    if ($(this).val() === "1" && aenc_codec !== '4') {
                        alert(i18n.t('output.messages.mp3Required'));
                        $(this).val("0");
                        return false;
                    }
                });
                $("#icecast_publish_enable").val(icecast_publish_enable);
                var icecast_publish_uri = $(data).find("icecast_publish_uri").text();
                $("#icecast_publish_uri").val(icecast_publish_uri);
            }

        }
    });
}

function SetSRTInput() {
    var tmp = "";
    var srt_enable = $("#srt_enable").val();
    var srt_listener_uri = $("#srt_listener_uri").val();
    srt_listener_uri = encodeURIComponent(srt_listener_uri);
    var srt_publish_enable = $("#srt_publish_enable").val();
    var srt_publish_uri = $("#srt_publish_uri").val();
    srt_publish_uri = encodeURIComponent(srt_publish_uri);

    tmp += "&srt_enable=" + srt_enable;
    tmp += "&srt_listener_uri=" + srt_listener_uri;
    tmp += "&srt_publish_enable=" + srt_publish_enable;
    tmp += "&srt_publish_uri=" + srt_publish_uri;

    var validated = IsSRTValidate();
    if (validated == true) {
        $.ajax({
            url: "/set_output?input=" + input + "&output=" + output + tmp,
            dataType: "text",
            cache: false,
            success: function (data) {
                if (data == "succeed") {
                    alert(i18n.t('output.messages.success'));
                } else {
                    alert(i18n.t('output.messages.failed'));
                }
            }
        });
    }
}

function IsSRTValidate() {
    validated = true;
    var srt_publish_uri = $("#srt_publish_uri").val();
    var srt_listener_uri = $("#srt_listener_uri").val();
    var Intsrt_listener_uri = isInteger(srt_listener_uri);

    if (srt_listener_uri == "" || srt_publish_uri == "") {
        alert(i18n.t('output.messages.emptyError'));
        validated = false;
    } else if (srt_listener_uri.indexOf("srt://") != 0) {
        alert(i18n.t('output.messages.srtListenerFormatError'));
        return false;
    } else if (srt_publish_uri.indexOf("srt://") != 0) {
        alert(i18n.t('output.messages.srtCallerFormatError'));
        return false;
    }

    return validated;
}

function SetTRTCInput() {
    var venc_codec = $("#venc_codec").val();
    var trtc_publish_enable = $("#trtc_publish_enable").val();
    var trtc_publish_app_id = $("#trtc_publish_app_id").val();
    var trtc_publish_room_id = $("#trtc_publish_room_id").val();
    var trtc_publish_user_id = $("#trtc_publish_user_id").val();
    var trtc_publish_user_sig = $("#trtc_publish_user_sig").val();
    var trtc_publish_room_id_type = $("#trtc_publish_room_id_type").val();
    var trtc_publish_room_password = $("#trtc_publish_room_password").val();
    if (trtc_publish_room_password === "") {
        trtc_publish_room_password = "0";
    }
    var uri = "/set_output?input=" + input + "&output=" + output + "&venc_codec=" + venc_codec + "&trtc_publish_enable=" + trtc_publish_enable + "&trtc_publish_app_id=" + trtc_publish_app_id + "&trtc_publish_room_id=" + trtc_publish_room_id + "&trtc_publish_user_id=" + trtc_publish_user_id + "&trtc_publish_user_sig=" + trtc_publish_user_sig + "&trtc_publish_room_id_type=" + trtc_publish_room_id_type + "&trtc_publish_room_password=" + trtc_publish_room_password;

    // 只有在 TRTC 开启并且之前因为开启 TRTC 自动把编码从非 H.264 改成 H.264 时才提示，
    // 避免在已经是 H.264 的情况下每次点击“设置”都弹出。
    if (trtc_publish_enable === "1" && typeof trtcCodecAutoChanged !== "undefined" && trtcCodecAutoChanged) {
        alert(i18n.t('output.messages.trtcH264Only'));
    }

    $.ajax({
        url: uri,
        dataType: "text",
        cache: false,
        success: function (data) {
            if (data == "succeed") {
                alert(i18n.t('output.messages.success'));
            } else {
                alert(i18n.t('output.messages.failed'));
            }
        }
    });
}

function SetRTMPInput() {
    var tmp = "";
    var rtmp_uri = $("#rtmp_uriTxt").val();
    var rtmp_enable = $("#rtmp_enableSle").val();
    var rtmp_publish_enable_0 = $("#rtmp_publish_enableSle_0").val();
    var rtmp_publish_enable_1 = $("#rtmp_publish_enableSle_1").val();
    var rtmp_publish_enable_2 = $("#rtmp_publish_enableSle_2").val();
    var rtmp_mode = $("#rtmp_mode").val();
    var rtmp_publish_uri_0 = $("#rtmp_publish_uri_0").val();
    var rtmp_publish_uri_1 = $("#rtmp_publish_uri_1").val();
    var rtmp_publish_uri_2 = $("#rtmp_publish_uri_2").val();
    rtmp_publish_uri_0 = encodeURIComponent(rtmp_publish_uri_0);
    rtmp_publish_uri_1 = encodeURIComponent(rtmp_publish_uri_1);
    rtmp_publish_uri_2 = encodeURIComponent(rtmp_publish_uri_2);

    tmp += "&rtmp_uri=" + rtmp_uri;
    tmp += "&rtmp_enable=" + rtmp_enable;
    tmp += "&rtmp_publish_enable_0=" + rtmp_publish_enable_0;
    tmp += "&rtmp_publish_enable_1=" + rtmp_publish_enable_1;
    tmp += "&rtmp_publish_enable_2=" + rtmp_publish_enable_2;
    tmp += "&rtmp_mode=" + rtmp_mode;
    tmp += "&rtmp_publish_uri_0=" + rtmp_publish_uri_0;
    tmp += "&rtmp_publish_uri_1=" + rtmp_publish_uri_1;
    tmp += "&rtmp_publish_uri_2=" + rtmp_publish_uri_2;

    var validated = IsRTMPValidate();
    if (validated == true) {
        $.ajax({
            url: "/set_output?input=" + input + "&output=" + output + tmp,
            dataType: "text",
            cache: false,
            success: function (data) {
                if (data == "succeed") {
                    alert(i18n.t('output.messages.success'));
                } else {
                    alert(i18n.t('output.messages.failed'));
                }
            }
        });
    }
}

function IsRTMPValidate() {
    validated = true;

    var rtmp_enable = $("#rtmp_enableSle").val();
    var rtmp_uri = $("#rtmp_uriTxt").val();

    if (rtmp_enable == "1" && rtmp_uri == "") {
        alert(i18n.t('output.messages.emptyError'));
        validated = false;
    }

    for (var k = 0; k < 3; ++k) {
        var enable = $("#rtmp_publish_enableSle_" + k).val();
        var uri = $("#rtmp_publish_uri_" + k).val();
        if (enable == "1") {
            if (uri == "") {
                alert(i18n.t('output.messages.emptyError'));
                validated = false;
                break;
            }
            if (checkDress(uri)) {
                alert(i18n.t('output.messages.rtmpFormatError'));
                validated = false;
                break;
            }
        }
    }

    return validated;
}

function SetHLSInput() {
    var tmp = "";
    var http_hls_uri = $("#http_hls_uriTxt").val();
    var http_hls_enable = $("#http_hls_enableSle").val();
    var hls_publish_enable = $("#hls_publish_enable").val();
    var hls_publish_uri = $("#hls_publish_uri").val();
    hls_publish_uri = encodeURIComponent(hls_publish_uri);
    var http_hls_fmp4_enable = $("#http_hls_fmp4_enable").val();
    var http_hls_fmp4_uri = $("#http_hls_fmp4_uri").val();
    http_hls_fmp4_uri = encodeURIComponent(http_hls_fmp4_uri);

    tmp += "&http_hls_uri=" + http_hls_uri;
    tmp += "&http_hls_enable=" + http_hls_enable;
    tmp += "&hls_publish_enable=" + hls_publish_enable;
    tmp += "&hls_publish_uri=" + hls_publish_uri;
    tmp += "&http_hls_fmp4_enable=" + http_hls_fmp4_enable;
    tmp += "&http_hls_fmp4_uri=" + http_hls_fmp4_uri;

    var validated = IsHLSValidate(http_hls_enable, hls_publish_enable, http_hls_fmp4_enable);
    if (validated == true) {
        $.ajax({
            url: "/set_output?input=" + input + "&output=" + output + tmp,
            dataType: "text",
            cache: false,
            success: function (data) {
                if (data == "succeed") {
                    alert(i18n.t('output.messages.success'));
                } else {
                    alert(i18n.t('output.messages.failed'));
                }
            }
        });
    }
}

function IsHLSValidate(http_hls_enable, hls_publish_enable, http_hls_fmp4_enable) {
    validated = true;

    var hls_publish_uri = $("#hls_publish_uri").val();
    var http_hls_uri = $("#http_hls_uriTxt").val();
    var http_hls_fmp4_uri = $("#http_hls_fmp4_uri").val();
    var venc_bitrate = $("#venc_bitrateTxt").val();
    var IntVenc_bitrate = isInteger(venc_bitrate);
    if (http_hls_uri == "" || hls_publish_uri == "" || http_hls_fmp4_uri == "") {
        alert(i18n.t('output.messages.emptyError'));
        validated = false;
    } else if ((http_hls_enable == 1 || http_hls_fmp4_enable == 1 || hls_publish_enable == 1) && (venc_bitrate < 32 || venc_bitrate > 8000 || IntVenc_bitrate == false)) {
        alert(i18n.t('output.messages.hlsBitrateError'));
        validated = false;
    } else if (hls_publish_uri.indexOf("https://") != 0) {
        alert(i18n.t('output.messages.hlsFormatError'));
        return false;
    }

    return validated;
}

function SetWHIPInput() {
    var tmp = "";
    var webrtc_p2p_http_enable = $("#webrtc_p2p_http_enable").val();
    var whip_publish_token = $("#whip_publish_token").val();
    if(whip_publish_token == ""){
        whip_publish_token = 0;
    }
    whip_publish_token = encodeURIComponent(whip_publish_token);
    var whip_publish_enable = $("#whip_publish_enable").val();
    var whip_publish_server = $("#whip_publish_server").val();
    whip_publish_server = encodeURIComponent(whip_publish_server);
    var webrtc_p2p_ws_url = $("#webrtc_p2p_ws_url").val();
    webrtc_p2p_ws_url = encodeURIComponent(webrtc_p2p_ws_url);
    var webrtc_p2p_ws_enable = $("#webrtc_p2p_ws_enable").val();
    var webrtc_p2p_ws_uuid = $("#webrtc_p2p_ws_uuid").val();
    var webrtc_p2p_ws_auth_token = $("#webrtc_p2p_ws_auth_token").val();

    tmp += "&webrtc_p2p_http_enable=" + webrtc_p2p_http_enable;
    tmp += "&whip_publish_token=" + whip_publish_token;
    tmp += "&whip_publish_enable=" + whip_publish_enable;
    tmp += "&whip_publish_server=" + whip_publish_server;
    tmp += "&webrtc_p2p_ws_url=" + webrtc_p2p_ws_url;
    tmp += "&webrtc_p2p_ws_enable=" + webrtc_p2p_ws_enable;
    tmp += "&webrtc_p2p_ws_uuid=" + webrtc_p2p_ws_uuid;
    if(webrtc_p2p_ws_auth_token == '') webrtc_p2p_ws_auth_token = 0;
    tmp += "&webrtc_p2p_ws_auth_token=" + webrtc_p2p_ws_auth_token;

    $.ajax({
        url: "/set_output?input=" + input + "&output=" + output + tmp,
        dataType: "text",
        cache: false,
        success: function (data) {
            if (data == "succeed") {
                alert(i18n.t('output.messages.success'));
            } else {
                alert(i18n.t('output.messages.failed'));
            }
        }
    });
}

function SetRTSPInput() {
    var tmp = "";
    var rtsp_uri = $("#rtsp_uriTxt").val();
    var rtsp_enable = $("#rtsp_enableSle").val();
    rtsp_uri = encodeURIComponent(rtsp_uri);
    var rtsp_multicast_ip = $("#rtsp_multicast_ipTxt").val();
    var rtsp_multicast_port = $("#rtsp_multicast_portTxt").val();

    tmp += "&rtsp_uri=" + rtsp_uri;
    tmp += "&rtsp_enable=" + rtsp_enable;
    tmp += "&rtsp_multicast_ip=" + rtsp_multicast_ip;
    tmp += "&rtsp_multicast_port=" + rtsp_multicast_port;

    var validated = IsRTSPValidate(rtsp_uri, rtsp_enable, rtsp_multicast_ip, rtsp_multicast_port);
    if (validated == true) {
        $.ajax({
            url: "/set_output?input=" + input + "&output=" + output + tmp,
            dataType: "text",
            cache: false,
            success: function (data) {
                if (data == "succeed") {
                    alert(i18n.t('output.messages.success'));
                } else {
                    alert(i18n.t('output.messages.failed'));
                }
            }
        });
    }
}

function IsRTSPValidate(rtsp_uri, rtsp_enable, rtsp_multicast_ip, rtsp_multicast_port) {
    validated = true;
    if (rtsp_uri == "" || (rtsp_enable == "2" && (rtsp_multicast_ip == "" || rtsp_multicast_port == ""))) {
        alert(i18n.t('output.messages.emptyError'));
        validated = false;
    } else if ("2" == rtsp_enable && !isValidIP(rtsp_multicast_ip)) {
        alert(i18n.t('output.messages.rtspMulticastIpError'));
        validated = false;
    } else if ("2" == rtsp_enable && !isValidPort(rtsp_multicast_port, 1, 65535)) {
        alert(i18n.t('output.messages.rtspMulticastPortError'));
        validated = false;
    }
    return validated;
}

function SetOtherInput() {
    var tmp = "";
    var http_flv_uri = $("#http_flv_uriTxt").val();
    var http_flv_enable = $("#http_flv_enableSle").val();
    var http_fmp4_enable = $("#http_fmp4_enable").val();
    var http_fmp4_uri = $("#http_fmp4_uri").val();
    http_fmp4_uri = encodeURIComponent(http_fmp4_uri);

    tmp += "&http_flv_uri=" + http_flv_uri;
    tmp += "&http_flv_enable=" + http_flv_enable;
    tmp += "&http_fmp4_enable=" + http_fmp4_enable;
    tmp += "&http_fmp4_uri=" + http_fmp4_uri;

    if (output == 0) {
        var shoutcast_publish_enable = $("#shoutcast_publish_enable").val();
        var shoutcast_publish_uri = $("#shoutcast_publish_uri").val();
        shoutcast_publish_uri = encodeURIComponent(shoutcast_publish_uri);
        tmp += "&shoutcast_publish_enable=" + shoutcast_publish_enable;
        tmp += "&shoutcast_publish_uri=" + shoutcast_publish_uri;
    }

    if (output == 0 || output == 1) {
        var icecast_publish_enable = $("#icecast_publish_enable").val();
        var icecast_publish_uri = $("#icecast_publish_uri").val();
        icecast_publish_uri = encodeURIComponent(icecast_publish_uri);
        tmp += "&icecast_publish_enable=" + icecast_publish_enable;
        tmp += "&icecast_publish_uri=" + icecast_publish_uri;
    }

    var validated = IsOtherValidate();
    if (validated == true) {
        $.ajax({
            url: "/set_output?input=" + input + "&output=" + output + tmp,
            dataType: "text",
            cache: false,
            success: function (data) {
                if (data == "succeed") {
                    alert(i18n.t('output.messages.success'));
                } else {
                    alert(i18n.t('output.messages.failed'));
                }
            }
        });
    }
}

function IsOtherValidate() {
    validated = true;

    var http_fmp4_uri = $("#http_fmp4_uri").val();
    var http_flv_uri = $("#http_flv_uriTxt").val();
    var icecast_publish_uri = $("#icecast_publish_uri").val();
    var shoutcast_publish_uri = $("#shoutcast_publish_uri").val();

    if (http_flv_uri == "" || http_fmp4_uri == "" || ((output == 0 || output == 1) && icecast_publish_uri == "")) {
        alert(i18n.t('output.messages.emptyError'));
        validated = false;
    } else if ((output == 0 || output == 1) && icecast_publish_uri.trim().indexOf("icecast://") !== 0) {
        alert(i18n.t('output.messages.icecastFormatError'));
        return false;
    } else if ((output == 0) && shoutcast_publish_uri.trim().indexOf("http://") !== 0) {
        alert(i18n.t('output.messages.shoutcastFormatError'));
        return false;
    }

    return validated;
}

function SetMJPEGInput() {
    var tmp = "";
    var http_jpg_enable = $("#http_jpg_enable").val();
    var http_jpg_uri = $("#http_jpg_uri").val();
    http_jpg_uri = encodeURIComponent(http_jpg_uri);
    var http_mjpg_enable = $("#http_mjpg_enable").val();
    var http_mjpg_uri = $("#http_mjpg_uri").val();
    http_mjpg_uri = encodeURIComponent(http_mjpg_uri);

    tmp += "&http_jpg_enable=" + http_jpg_enable;
    tmp += "&http_jpg_uri=" + http_jpg_uri;
    tmp += "&http_mjpg_enable=" + http_mjpg_enable;
    tmp += "&http_mjpg_uri=" + http_mjpg_uri;

    var validated = checkMJPEGInput();
    if (validated == true) {
        $.ajax({
            url: "/set_output?input=" + input + "&output=" + output + tmp,
            dataType: "text",
            cache: false,
            success: function (data) {
                if (data == "succeed") {
                    alert(i18n.t('output.messages.success'));
                } else {
                    alert(i18n.t('output.messages.failed'));
                }
            }
        });
    }
}

function checkMJPEGInput() {
    validated = true;
    var http_jpg_uri = $("#http_jpg_uri").val();
    var http_mjpg_uri = $("#http_mjpg_uri").val();

    if (http_jpg_uri == "" || http_mjpg_uri == "") {
        alert(i18n.t('output.messages.emptyError'));
        validated = false;
    }

    return validated;
}

function SetEncodeInput() {
    var tmp = "";
    var venc_framerate = $("#venc_framerate").val();
    if (venc_framerate == "0") {
        venc_framerate = $("#venc_framerate_custom").val();
    }
    var mjpeg_qfactor = $("#mjpeg_qfactor").val();
    var venc_gop = $("#venc_gopTxt").val();
    var videosize = $("#VideosizeSle").val();
    var venc_width = videosize.split('x')[0];
    var venc_height = videosize.split('x')[1];
    if (output == 0 || output == 1) {
        var venc_width_height_same_as_input = 0;
        if (venc_width == "0" && venc_height == "0") {
            venc_width_height_same_as_input = 1;
        }
        tmp += "&venc_width_height_same_as_input=" + venc_width_height_same_as_input;
    }
    var venc_rc_mode = $("#venc_rc_modeSle").val();
    var venc_bitrate = $("#venc_bitrateTxt").val();
    var venc_profile = $("#venc_profile").val();
    var venc_codec = $("#venc_codec").val();
    var venc_max_qp = $("#venc_max_qp").val();
    var http_hls_fmp4_enable = $("#http_hls_fmp4_enable").val();
    var http_hls_enable = $("#http_hls_enableSle").val();
    var hls_publish_enable = $("#hls_publish_enable").val();
    var venc_cbr_stable = $("#venc_cbr_stable").val();
    var venc_num_b_frames = $("#venc_num_b_frames").val();

    tmp += "&venc_framerate=" + venc_framerate;
    tmp += "&mjpeg_qfactor=" + mjpeg_qfactor;
    tmp += "&venc_gop=" + venc_gop;
    tmp += "&venc_width=" + venc_width;
    tmp += "&venc_height=" + venc_height;
    tmp += "&venc_bitrate=" + venc_bitrate;
    tmp += "&venc_profile=" + venc_profile;
    tmp += "&venc_codec=" + venc_codec;
    tmp += "&venc_cbr_stable=" + venc_cbr_stable;
    tmp += "&venc_num_b_frames=" + venc_num_b_frames;

    var validated = IsEncodeValidate(venc_framerate, venc_gop, venc_bitrate, http_hls_fmp4_enable, http_hls_enable, hls_publish_enable);

    if (validated != 0) {
        if (venc_rc_mode == "5") {
            tmp += "&ts_muxrate=" + venc_bitrate;
        } else {
            tmp += "&venc_rc_mode=" + venc_rc_mode + "&ts_muxrate=0";
            if (venc_rc_mode == "1") tmp += "&max_qp=" + venc_max_qp;
        }

        if (validated == 2) {
            tmp += "&http_hls_enable=0";
            tmp += "&http_hls_fmp4_enable=0";
            tmp += "&hls_publish_enable=0";
        } else if (validated == 3) {
            tmp += "&trtc_publish_enable=0";
        }

        $.ajax({
            url: "/set_output?input=" + input + "&output=" + output + tmp,
            dataType: "text",
            cache: false,
            success: function (data) {
                if (data == "succeed") {
                    alert(i18n.t('output.messages.success'));
                } else {
                    alert(i18n.t('output.messages.failed'));
                }
            }
        });
    }
}

function IsEncodeValidate(venc_framerate, venc_gop, venc_bitrate, http_hls_fmp4_enable, http_hls_enable, hls_publish_enable) {
    validated = 1;
    var IntVenc_framerate = isInteger(venc_framerate);
    var IntVenc_gop = isInteger(venc_gop);
    var IntVenc_bitrate = isInteger(venc_bitrate);
    var mjpeg_qfactor = $("#mjpeg_qfactor").val();
    var IntMjpeg_qfactor = isInteger(mjpeg_qfactor);
    var venc_codec = $("#venc_codec").val();
    var trtc_publish_enable = $("#trtc_publish_enable").val();

    if (venc_framerate == "" || venc_gop == "" || venc_bitrate == "") {
        alert(i18n.t('output.messages.emptyError'));
        validated = 0;
    } else if ((venc_framerate != "6000000" && venc_framerate != "3000000") && (venc_framerate < 5 || venc_framerate > 60 || IntVenc_framerate == false)) {
        alert(i18n.t('output.messages.frameRateError'));
        validated = 0;
    } else if (venc_gop < 5 || venc_gop > 300 || IntVenc_gop == false) {
        alert(i18n.t('output.messages.gopError'));
        validated = 0;
    } else if (mjpeg_qfactor < 10 || mjpeg_qfactor > 99 || IntMjpeg_qfactor == false) {
        alert(i18n.t('output.messages.mjpegQualityError'));
        validated = 0;
    } else if ((http_hls_enable == 1 || http_hls_fmp4_enable == 1 || hls_publish_enable == 1) && (venc_bitrate < 32 || venc_bitrate > 8000 || IntVenc_bitrate == false)) {
        alert(i18n.t('output.messages.hlsBitrateWarning'));
        validated = 2;
    } else if (trtc_publish_enable == 1 && venc_codec != 96) {
        alert(i18n.t('output.messages.trtcCodecWarning'));
        validated = 3;
    }
    return validated;
}

function SetTsInput() {
    var tmp = "";
    var multicast_enable = $("#multicast_enable").val();
    var multicast_ip = $("#multicast_ip").val();
    var multicast_port = $("#multicast_port").val();
    var sap_name = $("#sap_name").val();

    var http_ts_uri = $("#http_ts_uriTxt").val();
    var http_ts_enable = $("#http_ts_enableSle").val();
    var ts_tdt_enable = $("#ts_tdt_enable").val();
    var ts_transport_stream_id = $("#ts_transport_stream_id").val();
    var ts_original_network_id = $("#ts_original_network_id").val();
    var ts_pmt_start_pid = $("#ts_pmt_start_pid").val();
    var ts_start_pid = $("#ts_start_pid").val();
    var ts_tables_version = $("#ts_tables_version").val();
    var ts_rc_mode = $("#ts_rc_mode").val();
    var ts_service_name = $("#ts_service_name").val();
    var ts_service_provider = $("#ts_service_provider").val();
    var ts_pcr_period = $("#ts_pcr_period").val();
    var ts_service_id = $("#ts_service_id").val();
    var ts_system_b = $("#ts_system_b").val();
    var ts_video_pid = $("#ts_video_pid").val();
    var ts_audio_pid = $("#ts_audio_pid").val();

    tmp += "&multicast_enable=" + multicast_enable;
    tmp += "&multicast_ip=" + multicast_ip;
    tmp += "&multicast_port=" + multicast_port;
    tmp += "&sap_name=" + sap_name;

    tmp += "&http_ts_uri=" + http_ts_uri;
    tmp += "&http_ts_enable=" + http_ts_enable;
    tmp += "&ts_tdt_enable=" + ts_tdt_enable;
    tmp += "&ts_transport_stream_id=" + ts_transport_stream_id;
    tmp += "&ts_original_network_id=" + ts_original_network_id;
    tmp += "&ts_pmt_start_pid=" + ts_pmt_start_pid;
    tmp += "&ts_start_pid=" + ts_start_pid;
    tmp += "&ts_tables_version=" + ts_tables_version;
    tmp += "&ts_rc_mode=" + ts_rc_mode;
    tmp += "&ts_service_name=" + ts_service_name;
    tmp += "&ts_service_provider=" + ts_service_provider;
    tmp += "&ts_pcr_period=" + ts_pcr_period;
    tmp += "&ts_service_id=" + ts_service_id;
    tmp += "&ts_system_b=" + ts_system_b;
    tmp += "&ts_video_pid=" + ts_video_pid;
    tmp += "&ts_audio_pid=" + ts_audio_pid;

    if (true == checkTsInput()) {
        $.ajax({
            url: "/set_output?input=" + input + "&output=" + output + tmp,
            dataType: "text",
            cache: false,
            success: function (data) {
                if (data == "succeed") {
                    alert(i18n.t('output.messages.success'));
                } else {
                    alert(i18n.t('output.messages.failed'));
                }
            }
        });
    }
}

function checkTsInput() {
    validated = true;
    var multicast_ip = $("#multicast_ip").val();
    var multicast_port = $("#multicast_port").val();
    var sap_name = $("#sap_name").val();

    var http_ts_uri = $("#http_ts_uriTxt").val();
    var ts_service_name = $("#ts_service_name").val();
    var ts_service_provider = $("#ts_service_provider").val();
    var ts_pcr_period = $("#ts_pcr_period").val();
    var ts_transport_stream_id = $("#ts_transport_stream_id").val();
    var IntTs_transport_stream_id = isInteger(ts_transport_stream_id);
    var ts_original_network_id = $("#ts_original_network_id").val();
    var IntTs_original_network_id = isInteger(ts_original_network_id);
    var ts_pmt_start_pid = $("#ts_pmt_start_pid").val();
    var IntTs_pmt_start_pid = isInteger(ts_pmt_start_pid);
    var ts_start_pid = $("#ts_start_pid").val();
    var IntTs_start_pid = isInteger(ts_start_pid);
    var ts_tables_version = $("#ts_tables_version").val();
    var IntTs_tables_version = isInteger(ts_tables_version);
    var ts_service_id = $("#ts_service_id").val();
    var IntTS_Service_ID = isInteger(ts_service_id);
    var ts_video_pid = $("#ts_video_pid").val();
    var IntVideoPid = isInteger(ts_video_pid);
    var ts_audio_pid = $("#ts_audio_pid").val();
    var IntAudioPid = isInteger(ts_audio_pid);
    if (sap_name == "" || http_ts_uri == "" || ts_transport_stream_id == "" || ts_service_name == "" || ts_service_provider == "" || ts_original_network_id == "" || ts_service_id == "" || ts_pmt_start_pid == "" || ts_start_pid == "" || ts_tables_version == "" || ts_transport_stream_id == "" || ts_video_pid == "" || ts_audio_pid == "" || ts_pcr_period == '' || multicast_ip == "" || multicast_port == "") {
        alert(i18n.t('output.messages.emptyError'));
        validated = false;
    } else if (!isValidIP(multicast_ip)) {
        alert(i18n.t('output.messages.multicastIpError'));
        validated = false;
    } else if (!isValidPort(multicast_port, 1, 65535)) {
        alert(i18n.t('output.messages.multicastPortError'));
        return false;
    } else if (ts_transport_stream_id < 1 || ts_transport_stream_id > 65535 || IntTs_transport_stream_id == false) {
        alert(i18n.t('output.messages.tsTransportIdError'));
        validated = false;
    } else if (ts_original_network_id < 1 || ts_original_network_id > 65535 || IntTs_original_network_id == false) {
        alert(i18n.t('output.messages.tsNetworkIdError'));
        validated = false;
    } else if (ts_pmt_start_pid < 16 || ts_pmt_start_pid > 7936 || IntTs_pmt_start_pid == false) {
        alert(i18n.t('output.messages.tsPmtPidError'));
        validated = false;
    } else if (ts_start_pid < 32 || ts_start_pid > 3840 || IntTs_start_pid == false) {
        alert(i18n.t('output.messages.tsStartPidError'));
        validated = false;
    } else if (ts_pmt_start_pid == ts_start_pid) {
        alert(i18n.t('output.messages.tsPidConflict'))
        validated = false;
    } else if (ts_tables_version < 0 || ts_tables_version > 31 || IntTs_tables_version == false) {
        alert(i18n.t('output.messages.tsVersionError'));
        validated = false;
    } else if (ts_service_id < 1 || ts_service_id > 65535 || IntTS_Service_ID == false) {
        alert(i18n.t('output.messages.tsServiceIdError'));
        validated = false;
    } else if (ts_video_pid < 16 || ts_video_pid > 8190 || IntVideoPid == false) {
        alert(i18n.t('output.messages.tsVideoPidError'));
        validated = false;
    } else if (ts_audio_pid < 16 || ts_audio_pid > 8190 || IntAudioPid == false) {
        alert(i18n.t('output.messages.tsAudioPidError'));
        validated = false;
    } else if (ts_video_pid == ts_audio_pid) {
        alert(i18n.t('output.messages.tsVideoPidConflict'));
        validated = false;
    } else if (ts_pmt_start_pid == ts_audio_pid) {
        alert(i18n.t('output.messages.tsAudioPmtConflict'))
        validated = false;
    } else if (ts_pmt_start_pid == ts_video_pid) {
        alert(i18n.t('output.messages.tsVideoPmtConflict'))
        validated = false;
    }

    return validated;
}

function changeTab(tab) {
    // 更新 URL 参数
    const newUrl = new URL(window.location);
    newUrl.searchParams.set('tab', tab);
    window.history.replaceState({}, '', newUrl);

    // 切换 tab 样式
    $(".tab_card").removeClass("choosen_tab");
    $("#" + tab + "_tab").addClass("choosen_tab");

    // 切换内容显示
    $(".tab_content").addClass("display_off");
    $("#" + tab).removeClass("display_off");

    // 更新提示内容
    $(".tip_content").addClass("display_off");
    $("#" + tab + "_tip").removeClass("display_off");

    if (tab == "tsPart") {
        $("#adv_tip").removeClass("display_off");
    }
}

function initOutputPage() {
    if (output != 0) {
        $("#trtcPart_tab").addClass("display_off");
        $("#shoutcast_dl").addClass("display_off");
    }
    if (output == 2 || output == 3) {
        $("#icecast_dl").addClass("display_off");
    }
}

function generalContent() {
    var content = "";
    var t = i18n.t.bind(i18n);

    content += `<div class="content_box_header">
                    <div class="content_header_tab">
                        <div id="encodePart_tab" class="tab_card choosen_tab" onclick="changeTab('encodePart'); refreshEncode()">
                            <span>${t('output.tabs.encode')}</span>
                        </div>
                        <div id="tsPart_tab" class="tab_card" onclick="changeTab('tsPart'); refreshTS()">
                            <span>${t('output.tabs.ts')}</span>
                        </div>
                        <div id="mjpegPart_tab" class="tab_card" onclick="changeTab('mjpegPart'); refreshMJPEG()">
                            <span>${t('output.tabs.mjpeg')}</span>
                        </div>
                        <div id="rtspPart_tab" class="tab_card" onclick="changeTab('rtspPart'); refreshRTSP()">
                            <span>${t('output.tabs.rtsp')}</span>
                        </div>
                        <div id="rtmpPart_tab" class="tab_card" onclick="changeTab('rtmpPart'); refreshRTMP()">
                            <span>${t('output.tabs.rtmp')}</span>
                        </div>
                        <div id="srtPart_tab" class="tab_card" onclick="changeTab('srtPart'); refreshSRT()">
                            <span>${t('output.tabs.srt')}</span>
                        </div>
                        <div id="whipPart_tab" class="tab_card" onclick="changeTab('whipPart'); refreshWHIP()">
                            <span>${t('output.tabs.webrtc')}</span>
                        </div>
                        <div id="trtcPart_tab" class="tab_card" onclick="changeTab('trtcPart'); refreshTRTC()">
                            <span>${t('output.tabs.trtc')}</span>
                        </div>
                        <div id="hlsPart_tab" class="tab_card" onclick="changeTab('hlsPart'); refreshHLS()">
                            <span>${t('output.tabs.hls')}</span>
                        </div>
                        <div id="otherPart_tab" class="tab_card" onclick="changeTab('otherPart'); refreshOther()">
                            <span>${t('output.tabs.other')}</span>
                        </div>
                    </div>
                </div>
                <!-- End .content-box-header -->
                <!-- <DIV class="content-box-content"> -->
                <div class="content_box_content">
                    <div class="tab_content_wrap">
                        <div class="write tabWrite">
                            <div id="tab_content_tips_box" class="tab_tips_box">
                                <div id="secondDisable_tip" class="tip_content">
                                    <span>${t('output.messages.subStreamDisabled')}</span>
                                </div>
                                <div id="encodePart_tip" class="tip_content">
                                    <!-- 编码说明文字改这里 -->
                                    <span>${t('output.encode.tipCodec')}</span>
                                    <span>${t('output.encode.tipVbr')}</span>
                                    <span>${t('output.encode.tipCbr')}</span>
                                    <span>${t('output.encode.tipGop')}</span>
                                </div>
                                <div id="tsPart_tip" class="tip_content">
                                    <!-- TS/组播设置说明文字改这里 -->
                                    <span>${t('output.ts.tipMulticast')}</span>
                                    <span>${t('output.ts.tipVlc')}</span>
                                    <span>${t('output.ts.tipSap')}</span>
                                </div>
                                <div id="mjpegPart_tip" class="tip_content">
                                    <!-- MJPEG设置说明文字改这里 -->
                                    <span>${t('output.mjpeg.tipJpg')}</span>
                                    <span>${t('output.mjpeg.tipMjpg')}</span>
                                </div>
                                <div id="rtspPart_tip" class="tip_content">
                                    <!-- RTSP设置说明文字改这里 -->
                                    <span>${t('output.rtsp.tipEnable')}</span>
                                    <span>${t('output.rtsp.tipTcpOnly')}</span>
                                    <span>${t('output.rtsp.tipUdp')}</span>
                                    <span>${t('output.rtsp.tipMulticast')}</span>
                                </div>
                                <div id="rtmpPart_tip" class="tip_content">
                                    <!-- RTMP设置说明文字改这里 -->
                                    <span>${t('output.rtmp.tipPublish')}</span>
                                    <span>${t('output.rtmp.tipBuiltin')}</span>
                                    <span>${t('output.rtmp.tipMode')}</span>
                                </div>
                                <div id="srtPart_tip" class="tip_content">
                                    <!-- SRT设置说明文字改这里 -->
                                    <span>${t('output.srt.tipListener')}</span>
                                    <span>${t('output.srt.tipCaller')}</span>
                                    <span>${t('output.srt.tipParams')}</span>
                                </div>
                                <div id="whipPart_tip" class="tip_content">
                                    <!-- WHIP设置说明文字改这里 -->
                                    <span>${t('output.webrtc.tipPreview')}</span>
                                    <span>${t('output.webrtc.tipWhip')}</span>
                                    <span>${t('output.webrtc.tipP2p')}</span>
                                    <span>${t('output.webrtc.tipP2pNote')}</span>
                                </div>
                                <div id="trtcPart_tip" class="tip_content">
                                    <!-- TRTC设置说明文字改这里 -->
                                    <span>${t('output.trtc.tipTrtc')}</span>
                                </div>
                                <div id="hlsPart_tip" class="tip_content">
                                    <!-- HLS设置说明文字改这里 -->
                                    <span>${t('output.hls.tipHls')}</span>
                                    <span>${t('output.hls.tipPush')}</span>
                                </div>
                                <div id="otherPart_tip" class="tip_content">
                                    <!-- MP4/FLV/其他设置说明文字改这里 -->
                                    <span>${t('output.other.tipMp4')}</span>
                                    <span>${t('output.other.tipShoutcast')}</span>
                                </div>
                            </div>
                            <div id="encodePart" class="tab_content">
                                <dl>
                                    <dt>${t('output.encode.codecType')}</dt>
                                    <dd>
                                        <select name="venc_codec" id="venc_codec" onChange="SetType()">
                                        </select>
                                    </dd>
                                </dl>


                                <dl>
                                    <dt>${t('output.encode.frameRate')}</dt>
                                    <dd>
                                        <select name="venc_framerate" id="venc_framerate"
                                            onChange="onChangeSelectFramerate()">
                                            <option value="6000000">${t('output.encode.sameAsInput')}</option>
                                            <option value="3000000">${t('output.encode.auto')}</option>
                                            <option value="0">${t('output.encode.customFrameRate')}</option>
                                        </select>
                                    </dd>
                                </dl>
                                <dl id="venc_framerate_custom_dl">
                                    <dt>${t('output.encode.customFrameRateLabel')}</dt>
                                    <dd>
                                        <input id="venc_framerate_custom" name="venc_framerate_custom" maxlength="18"
                                            size="36" type="text" />[5-60]
                                    </dd>
                                </dl>

                                <dl id="venc_gop_div">
                                    <dt>${t('output.encode.gopInterval')}</dt>
                                    <dd>
                                        <input id="venc_gopTxt" name="venc_gopTxt" maxlength="18" size="36" type="text" />
                                        [5-300]
                                    </dd>
                                </dl>
                                <dl>
                                    <dt>${t('output.encode.bitrate')}</dt>
                                    <dd>
                                        <input id="venc_bitrateTxt" name="venc_bitrateTxt" maxlength="18" size="36"
                                            type="text" />[32-32000]
                                    </dd>
                                </dl>
                                <dl id="venc_max_qp_div">
                                    <dt>${t('output.encode.qualityRange')}</dt>
                                    <dd>
                                        <select id="venc_max_qp" name="venc_max_qp">
                                            <option value="25">${t('output.encode.qualityStrict')}</option>
                                            <option value="28">${t('output.encode.qualityTight')}</option>
                                            <option value="32">${t('output.encode.qualityNormal')}</option>
                                            <option value="38">${t('output.encode.qualityLoose')}</option>
                                            <option value="42">${t('output.encode.qualityWide')}</option>
                                        </select>
                                    </dd>
                                </dl>
                                <dl id="mjpeg_qfactor_div">
                                    <dt>${t('output.encode.mjpegQuality')}</dt>
                                    <dd>
                                        <input id="mjpeg_qfactor" name="mjpeg_qfactor" maxlength="18" size="36"
                                            type="text" />
                                        [10-99]
                                    </dd>
                                </dl>
                                <dl>
                                    <dt>${t('output.encode.outputResolution')}</dt>
                                    <dd id="Videosize">
                                    </dd>
                                </dl>
                                <dl id="venc_profile_div">
                                    <dt>${t('output.encode.h264Profile')}</dt>
                                    <dd>
                                        <select id="venc_profile" name="venc_profile">
                                            <option value="0" selected="selected">baseline profile</option>
                                            <option value="1">main profile</option>
                                            <option value="2">high profile</option>
                                        </select>
                                    </dd>
                                </dl>
                                <dl id="venc_rc_mode_div">
                                    <dt>${t('output.encode.bitrateControl')}</dt>
                                    <dd>
                                        <select id="venc_rc_modeSle" name="venc_rc_modeSle" onchange="on_change_rcmode()">
                                            <option value='0'>cbr</option>
                                            <option value='1'>vbr</option>
                                        </select>
                                    </dd>
                                </dl>
                                <dl id="venc_cbr_stable_div">
                                    <dt>${t('output.encode.cbrStableRange')}</dt>
                                    <dd>
                                        <select id="venc_cbr_stable" name="venc_cbr_stable">
                                            <option value="1">1 (${t('output.encode.cbrStableMin')})</option>
                                            <option value="2">2</option>
                                            <option value="3">3</option>
                                            <option value="4">4</option>
                                            <option value="5">5</option>
                                            <option value="6">6</option>
                                            <option value="7">7</option>
                                            <option value="8">8</option>
                                            <option value="9">9</option>
                                            <option value="10">10 (${t('output.encode.cbrStableMax')})</option>
                                        </select>
                                    </dd>
                                </dl>
                                <dl id="venc_num_b_frames_div">
                                    <dt>${t('output.encode.bFramesMode')}</dt>
                                    <dd>
                                        <select id="venc_num_b_frames" name="venc_num_b_frames">
                                            <option value="0">${t('output.encode.bFramesDisable')}</option>
                                            <option value="1">${t('output.encode.bFramesIbp')}</option>
                                            <option value="2">${t('output.encode.bFramesIbbp')}</option>
                                        </select>
                                    </dd>
                                </dl>
                                <dl>
                                    <dt>&nbsp;&nbsp;</dt>
                                    <dd>
                                        <button type="button" class="btn btn-primary btn-save" onclick="SetEncodeInput()" id="encodeSubBut">${t('common.save')}</button>
                                    </dd>
                                </dl>
                            
                            </div>

                            <div id="tsPart" class="tab_content display_off">
                                <dl>
                                    <dt>${t('output.ts.tsUri')}</dt>
                                    <dd>
                                        <input id="http_ts_uriTxt" name="http_ts_uriTxt" maxlength="128" size="36"
                                            type="text" />
                                        <select id="http_ts_enableSle" name="http_ts_enableSle">
                                            <option value="0" selected="selected">${t('common.disable')}</option>
                                            <option value="1">${t('common.enable')}</option>
                                        </select>

                                    </dd>
                                </dl>
                                <dl>
                                    <dt>${t('output.ts.multicastIp')}</dt>
                                    <dd>
                                        <input id="multicast_ip" name="multicast_ip" maxlength="128" size="36"
                                            type="text" />
                                        <select id="multicast_enable" name="select_lit">
                                            <option value="0">${t('common.disable')}</option>
                                            <option value="1">${t('common.enable')}</option>
                                        </select>
                                    </dd>
                                </dl>
                                <dl>
                                    <dt>${t('output.ts.multicastPort')}</dt>
                                    <dd>
                                        <input id="multicast_port" name="multicast_port" maxlength="18" size="36"
                                            type="text" />[1-65535]
                                    </dd>
                                </dl>
                                <dl>
                                    <dt>${t('output.ts.sapName')}</dt>
                                    <dd>
                                        <input id="sap_name" name="sap_name" maxlength="18" size="36" type="text" />
                                    </dd>
                                </dl>
                                <dl></dl>
                                <!-- <dl></dl> -->
                                <!-- <dl class="line2"></dl> -->
                                <div class="tab_tips_box">
                                    <div id="adv_tip" class="tip_content">
                                        <!-- TS高级设置说明文字改这里 -->
                                        <span>${t('output.ts.tipAdvanced')}</span>
                                        <span>${t('output.ts.tipIptv')}</span>
                                    </div>
                                </div>

                                <dl id="ts_video_pid_div">
                                    <dt>${t('output.ts.tsVideoPid')}</dt>
                                    <dd>
                                        <input id="ts_video_pid" name="ts_video_pid" maxlength="18" size="12" type="text" />
                                        [16-8190]
                                    </dd>
                                </dl>
                                <dl id="ts_audio_pid_div">
                                    <dt>${t('output.ts.tsAudioPid')}</dt>
                                    <dd>
                                        <input id="ts_audio_pid" name="ts_audio_pid" maxlength="18" size="12" type="text" />
                                        [16-8190]
                                    </dd>
                                </dl>
                                <dl>
                                    <dt>${t('output.ts.tsTransportStreamId')}</dt>
                                    <dd>
                                        <input id="ts_transport_stream_id" name="ts_transport_stream_id" maxlength="6"
                                            size="12" type="text" />[1-65535]
                                    </dd>
                                </dl>
                                <dl>
                                    <dt>${t('output.ts.tsOriginalNetworkId')}</dt>
                                    <dd>
                                        <input id="ts_original_network_id" name="ts_original_network_id" maxlength="6"
                                            size="12" type="text" />[1-65535]
                                    </dd>
                                </dl>
                                <dl>
                                    <dt>${t('output.ts.tsPmtStartPid')}</dt>
                                    <dd>
                                        <input id="ts_pmt_start_pid" name="ts_pmt_start_pid" maxlength="4" size="12"
                                            type="text" />[16-7936]
                                    </dd>
                                </dl>
                                <dl>
                                    <dt>${t('output.ts.tsStartPid')}</dt>
                                    <dd>
                                        <input id="ts_start_pid" name="ts_start_pid" maxlength="4" size="12" type="text" />
                                        [32-3840]
                                    </dd>
                                </dl>
                                <dl>
                                    <dt>${t('output.ts.tsTablesVersion')}</dt>
                                    <dd>
                                        <input id="ts_tables_version" name="ts_tables_version" maxlength="4" size="12"
                                            type="text" />[0-31]
                                    </dd>
                                </dl>
                                <dl>
                                    <dt>${t('output.ts.tsServiceId')}</dt>
                                    <dd>
                                        <input id="ts_service_id" name="ts_service_id" maxlength="256" size="12"
                                            type="text" />[1-65535]
                                    </dd>
                                </dl>
                                <dl>
                                    <dt>${t('output.ts.tsServiceName')}</dt>
                                    <dd>
                                        <input id="ts_service_name" name="ts_service_name" maxlength="256" size="12"
                                            type="text" />
                                    </dd>
                                </dl>
                                <dl>
                                    <dt>${t('output.ts.tsProviderName')}</dt>
                                    <dd>
                                        <input id="ts_service_provider" name="ts_service_provider" maxlength="256" size="12"
                                            type="text" />
                                    </dd>
                                </dl>
                                <dl>
                                    <dt>${t('output.ts.tsPcrPeriod')}</dt>
                                    <dd>
                                        <input id="ts_pcr_period" name="ts_pcr_period" maxlength="256" size="12"
                                            type="text" />[0-100](0=automatic)
                                    </dd>
                                </dl>
                                <dl>
                                    <dt>${t('output.ts.conformSystemB')}</dt>
                                    <dd>
                                        <select id="ts_system_b" name="ts_system_b">
                                            <option value="0">${t('common.disable')}</option>
                                            <option value="1">${t('common.enable')}</option>
                                        </select>
                                    </dd>
                                </dl>
                                <dl>
                                    <dt>${t('output.ts.tsNullPacket')}</dt>
                                    <dd>
                                        <select id="ts_rc_mode" name="ts_rc_mode">
                                            <option value="0">${t('output.ts.noInsert')}</option>
                                            <option value="12">${t('output.ts.insert12')}</option>
                                            <option value="13">${t('output.ts.insert13')}</option>
                                            <option value="15">${t('output.ts.insert15')}</option>
                                            <option value="20">${t('output.ts.insert20')}</option>
                                            <option value="25">${t('output.ts.insert25')}</option>
                                        </select>
                                    </dd>
                                </dl>
                                <dl>
                                    <dt>${t('output.ts.tsTdt')}</dt>
                                    <dd>
                                        <select id="ts_tdt_enable" name="ts_tdt_enable">
                                            <option value="0" selected="selected">${t('common.disable')}</option>
                                            <option value="1">${t('common.enable')}</option>
                                        </select>
                                    </dd>
                                </dl>
                                <dl>
                                    <dt>&nbsp;&nbsp;</dt>
                                    <dd>
                                        <button type="button" class="btn btn-primary btn-save" onclick="SetTsInput()" id="subBut">${t('common.save')}</button>
                                    </dd>
                                </dl>

                            </div>

                            <div id="mjpegPart" class="tab_content display_off">
                                <dl id="http_jpg_uri_dl">
                                    <dt>${t('output.mjpeg.jpgUri')}</dt>
                                    <dd>
                                        <input id="http_jpg_uri" name="http_jpg_uri" maxlength="128" size="36"
                                            type="text" />
                                        <select id="http_jpg_enable" name="http_jpg_enable">
                                            <option value="0" selected="selected">${t('common.disable')}</option>
                                            <option value="1">${t('common.enable')}</option>
                                        </select>
                                    </dd>
                                </dl>
                                <dl id="http_mjpg_uri_dl">
                                    <dt>${t('output.mjpeg.mjpgUri')}</dt>
                                    <dd>
                                        <input id="http_mjpg_uri" name="http_mjpg_uri" maxlength="128" size="36"
                                            type="text" />
                                        <select id="http_mjpg_enable" name="http_mjpg_enable">
                                            <option value="0" selected="selected">${t('common.disable')}</option>
                                            <option value="1">${t('common.enable')}</option>
                                        </select>
                                    </dd>
                                </dl>
                                <dl>
                                    <dt>&nbsp;&nbsp;</dt>
                                    <dd>
                                        <button type="button" class="btn btn-primary btn-save" onclick="SetMJPEGInput()" id="subBut">${t('common.save')}</button>
                                    </dd>
                                </dl>
                            </div>

                            <div id="rtspPart" class="tab_content display_off">

                                <dl>
                                    <dt>${t('output.rtsp.rtspUri')}</dt>
                                    <dd>
                                        <input id="rtsp_uriTxt" name="rtsp_uriTxt" maxlength="128" size="36" type="text" />
                                        <select id="rtsp_enableSle" name="rtsp_enableSle" onchange="OnSelectRtspType()">
                                            <option value="0" selected="selected">${t('common.disable')}</option>
                                            <option value="1">${t('common.enable')}</option>
                                            <option value="2">${t('output.rtsp.enableMulticast')}</option>
                                            <option value="4">${t('output.rtsp.enableTcpOnly')}</option>
                                        </select>
                                    </dd>
                                </dl>
                                <dl id="rtsp_multicast_ip_div">
                                    <dt>${t('output.rtsp.multicastIp')}</dt>
                                    <dd>
                                        <input id="rtsp_multicast_ipTxt" name="rtsp_multicast_ipTxt" maxlength="255"
                                            size="36" type="text" />
                                    </dd>
                                </dl>
                                <dl id="rtsp_multicast_port_div">
                                    <dt>${t('output.rtsp.multicastPort')}</dt>
                                    <dd>
                                        <input id="rtsp_multicast_portTxt" name="rtsp_multicast_portTxt" maxlength="18"
                                            size="36" type="text" />[1-65535]
                                    </dd>
                                </dl>

                                <dl>
                                    <dt>&nbsp;&nbsp;</dt>
                                    <dd>
                                        <button type="button" class="btn btn-primary btn-save" onclick="SetRTSPInput()" id="subBut">${t('common.save')}</button>
                                    </dd>
                                </dl>
                            </div>

                            <div id="rtmpPart" class="tab_content display_off">

                                <dl>
                                    <dt>${t('output.rtmp.rtmpUri')}</dt>
                                    <dd>
                                        <input id="rtmp_uriTxt" name="rtmp_uriTxt" maxlength="128" size="36" type="text" />
                                        <select id="rtmp_enableSle" name="select_lit" onchange="OnSelectRtmpType(0)">
                                            <option value="0" selected="selected">${t('common.disable')}</option>
                                            <option value="1">${t('common.enable')}</option>
                                        </select>
                                    </dd>
                                </dl>

                                <dl id="rtmp_publish_uri_dl_0">
                                    <dt>${t('output.rtmp.publishUri0')}</dt>
                                    <dd>
                                        <input id="rtmp_publish_uri_0" name="rtmp_publish_uri_0" maxlength="500" size="36"
                                            type="text" />
                                        <select id="rtmp_publish_enableSle_0" name="select_lit"
                                            onchange="OnSelectRtmpType(1)">
                                            <option value="0" selected="selected">${t('common.disable')}</option>
                                            <option value="1">${t('common.enable')}</option>
                                        </select>
                                    </dd>
                                </dl>
                                <dl id="rtmp_publish_uri_dl_1">
                                    <dt>${t('output.rtmp.publishUri1')}</dt>
                                    <dd>
                                        <input id="rtmp_publish_uri_1" name="rtmp_publish_uri_1" maxlength="500" size="36"
                                            type="text" />
                                        <select id="rtmp_publish_enableSle_1" name="select_lit">
                                            <option value="0" selected="selected">${t('common.disable')}</option>
                                            <option value="1">${t('common.enable')}</option>
                                        </select>
                                    </dd>
                                </dl>

                                <dl id="rtmp_publish_uri_dl_2">
                                    <dt>${t('output.rtmp.publishUri2')}</dt>
                                    <dd>
                                        <input id="rtmp_publish_uri_2" name="rtmp_publish_uri_2" maxlength="500" size="36"
                                            type="text" />
                                        <select id="rtmp_publish_enableSle_2" name="select_lit">
                                            <option value="0" selected="selected">${t('common.disable')}</option>
                                            <option value="1">${t('common.enable')}</option>
                                        </select>
                                    </dd>
                                </dl>
                                <dl id="rtmp_mode_dl">
                                    <dt>${t('output.rtmp.mode')}</dt>
                                    <dd>
                                        <select id="rtmp_mode" name="rtmp_mode">
                                            <option value="0" selected="selected">${t('output.rtmp.modeStandard')}</option>
                                            <option value="1">${t('output.rtmp.modeLegacy')}</option>
                                        </select>
                                    </dd>
                                </dl>
                                <dl>
                                    <dt>&nbsp;&nbsp;</dt>
                                    <dd>
                                        <button type="button" class="btn btn-primary btn-save" onclick="SetRTMPInput()" id="subBut">${t('common.save')}</button>
                                    </dd>
                                </dl>

                            </div>

                            <div id="hlsPart" class="tab_content display_off">

                                <dl>
                                    <dt>${t('output.hls.hlsTsUri')}</dt>
                                    <dd>
                                        <input id="http_hls_uriTxt" name="http_hls_uriTxt" maxlength="128" size="36"
                                            type="text" />
                                        <select id="http_hls_enableSle" name="http_hls_enableSle"
                                            onchange="OnSelectHLSType(0)">
                                            <option value="0" selected="selected">${t('common.disable')}</option>
                                            <option value="1">${t('common.enable')}</option>
                                        </select>

                                    </dd>
                                </dl>
                                <dl>
                                    <dt>${t('output.hls.hlsMp4Uri')}</dt>
                                    <dd>
                                        <input id="http_hls_fmp4_uri" name="http_hls_fmp4_uri" maxlength="128" size="36"
                                            type="text" />
                                        <select id="http_hls_fmp4_enable" name="http_hls_fmp4_enable"
                                            onchange="OnSelectHLSType(1)">
                                            <option value="0" selected="selected">${t('common.disable')}</option>
                                            <option value="1">${t('common.enable')}</option>
                                        </select>

                                    </dd>
                                </dl>
                                <dl>
                                    <dt>${t('output.hls.hlsPushUrl')}</dt>
                                    <dd>
                                        <input id="hls_publish_uri" name="hls_publish_uri" maxlength="256" size="36"
                                            type="text" />
                                        <select id="hls_publish_enable" name="select_lit" onchange="OnSelectHLSType(2)">
                                            <option value="0" selected="selected">${t('common.disable')}</option>
                                            <option value="1">${t('common.enable')}</option>
                                        </select>
                                    </dd>
                                </dl>

                                <dl>
                                    <dt>&nbsp;&nbsp;</dt>
                                    <dd>
                                        <button type="button" class="btn btn-primary btn-save" onclick="SetHLSInput()" id="subBut">${t('common.save')}</button>
                                    </dd>
                                </dl>
                            </div>

                            <div id="srtPart" class="tab_content display_off">

                                <dl>
                                    <dt>${t('output.srt.listenerUri')}</dt>
                                    <dd>
                                        <input id="srt_listener_uri" name="srt_listener_uri" maxlength="512" size="36" type="text" />
                                        <select id="srt_enable" name="select_lit">
                                            <option value="0" selected="selected">${t('common.disable')}</option>
                                            <option value="1">${t('common.enable')}</option>
                                        </select>
                                    </dd>
                                </dl>

                                <dl>
                                    <dt>${t('output.srt.callerUri')}</dt>
                                    <dd>
                                        <input id="srt_publish_uri" name="srt_publish_uri" maxlength="256" size="36"
                                            type="text" />
                                        <select id="srt_publish_enable" name="select_lit">
                                            <option value="0" selected="selected">${t('common.disable')}</option>
                                            <option value="1">${t('common.enable')}</option>
                                        </select>
                                    </dd>
                                </dl>

                                <dl>
                                    <dt>&nbsp;&nbsp;</dt>
                                    <dd>
                                        <button type="button" class="btn btn-primary btn-save" onclick="SetSRTInput()" id="subBut">${t('common.save')}</button>
                                    </dd>
                                </dl>

                            </div>

                            <div id="whipPart" class="tab_content display_off">
                                <dl>
                                    <dt>${t('output.webrtc.preview')}</dt>
                                    <dd>
                                        <select id="webrtc_p2p_http_enable" name="select_lit">
                                            <option value="0">${t('common.disable')}</option>
                                            <option value="1">${t('common.enable')}</option>
                                        </select>
                                    </dd>
                                </dl>
                                <dl>
                                    <dt>${t('output.webrtc.whipServer')}</dt>
                                    <dd>
                                        <input id="whip_publish_server" name="whip_publish_server" maxlength="2048"
                                            size="36" type="text" />
                                        <select id="whip_publish_enable" name="select_lit">
                                            <option value="0" selected="selected">${t('common.disable')}</option>
                                            <option value="1">${t('common.enable')}</option>
                                        </select>

                                    </dd>
                                </dl>
                                <dl>
                                    <dt>${t('output.webrtc.whipToken')}</dt>
                                    <dd>
                                        <input id="whip_publish_token" name="whip_publish_token" maxlength="2048" size="36"
                                            type="text" />
                                    </dd>
                                </dl>
                                <dl>
                                    <dt>${t('output.webrtc.p2pServer')}</dt>
                                    <dd>
                                        <input id="webrtc_p2p_ws_url" name="webrtc_p2p_ws_url" maxlength="2048" size="36" type="text" />
                                        <select id="webrtc_p2p_ws_enable" name="select_lit">
                                            <option value="0" selected="selected">${t('common.disable')}</option>
                                            <option value="1">${t('common.enable')}</option>
                                        </select>
                                    </dd>
                                </dl>
                                <dl>
                                    <dt>${t('output.webrtc.p2pUuid')}</dt>
                                    <dd>
                                        <input id="webrtc_p2p_ws_uuid" name="webrtc_p2p_ws_uuid" type="text"
                                            style="color: grey; cursor:default" readonly />
                                        <span class="span_href" onclick="regenerateUUID()">(${t('output.webrtc.regenerate')})</span>
                                    </dd>
                                </dl>
                                <dl>
                                    <dt>${t('output.webrtc.p2pAuthToken')}</dt>
                                    <dd>
                                        <input id="webrtc_p2p_ws_auth_token" name="webrtc_p2p_ws_auth_token" maxlength="2048" size="36" type="text" />
                                    </dd>
                                </dl>


                                <dl>
                                    <dt>&nbsp;&nbsp;</dt>
                                    <dd>
                                        <button type="button" class="btn btn-primary btn-save" onclick="SetWHIPInput()" id="subBut">${t('common.save')}</button>
                                    </dd>
                                </dl>
                            </div>

                            <div id="trtcPart" class="tab_content display_off">

                                <dl>
                                    <dt>${t('output.trtc.roomId')}</dt>
                                    <dd>
                                        <input id="trtc_publish_room_id" name="trtc_publish_room_id" maxlength="128"
                                            size="36" type="text" />
                                        <select id="trtc_publish_enable" name="trtc_publish_enable"
                                            onchange="changeEncodingtype()">
                                            <option value="0" selected="selected">${t('common.disable')}</option>
                                            <option value="1">${t('common.enable')}</option>
                                        </select>

                                    </dd>
                                </dl>
                                <dl>
                                    <dt>${t('output.trtc.userId')}</dt>
                                    <dd>
                                        <input id="trtc_publish_user_id" name="trtc_publish_user_id" maxlength="128"
                                            size="36" type="text" />
                                    </dd>
                                </dl>
                                <dl>
                                    <dt>${t('output.trtc.roomKey')}</dt>
                                    <dd>
                                        <input id="trtc_publish_room_password" name="trtc_publish_room_password" maxlength="1024"
                                            size="36" type="text" />
                                    </dd>
                                </dl>
                                <dl>
                                    <dt>${t('output.trtc.userSig')}</dt>
                                    <dd>
                                        <input id="trtc_publish_user_sig" name="trtc_publish_user_sig" mmaxlength="128"
                                            size="36" type="text" />
                                    </dd>
                                </dl>
                                <dl>
                                    <dt>${t('output.trtc.sdkAppId')}</dt>
                                    <dd>
                                        <input id="trtc_publish_app_id" name="trtc_publish_app_id" maxlength="2048"
                                            size="36" type="text" />
                                    </dd>
                                </dl>
                                <dl>
                                    <dt>${t('output.trtc.roomIdType')}</dt>
                                    <dd>

                                        <select id="trtc_publish_room_id_type" name="trtc_publish_room_id_type">
                                            <option value="0" selected="selected">${t('output.trtc.number')}</option>
                                            <option value="1">${t('output.trtc.string')}</option>
                                        </select>

                                    </dd>
                                </dl>
                                <dl>
                                    <dt>&nbsp;&nbsp;</dt>
                                    <dd>
                                        <button type="button" class="btn btn-primary btn-save" onclick="SetTRTCInput()" id="subBut">${t('common.save')}</button>
                                    </dd>
                                </dl>
                            </div>

                            <div id="otherPart" class="tab_content display_off">

                                <dl>
                                    <dt>${t('output.other.mp4Uri')}</dt>
                                    <dd>
                                        <input id="http_fmp4_uri" name="http_fmp4_uri" maxlength="128" size="36"
                                            type="text" />
                                        <select id="http_fmp4_enable" name="http_fmp4_enable">
                                            <option value="0" selected="selected">${t('common.disable')}</option>
                                            <option value="1">${t('common.enable')}</option>
                                        </select>

                                    </dd>
                                </dl>
                                <dl>
                                    <dt>${t('output.other.flvUri')}</dt>
                                    <dd>
                                        <input id="http_flv_uriTxt" name="http_flv_uriTxt" maxlength="128" size="36"
                                            type="text" />
                                        <select id="http_flv_enableSle" name="http_flv_enableSle">
                                            <option value="0" selected="selected">${t('common.disable')}</option>
                                            <option value="1">${t('common.enable')}</option>
                                        </select>
                                    </dd>
                                </dl>

                                <dl id="icecast_dl">
                                    <dt>${t('output.other.icecastPushUrl')}</dt>
                                    <dd>
                                        <input id="icecast_publish_uri" name="icecast_publish_uri" maxlength="256" size="36"
                                            type="text" />
                                        <select id="icecast_publish_enable" name="icecast_publish_enable">
                                            <option value="0" selected="selected">${t('common.disable')}</option>
                                            <option value="1">${t('common.enable')}</option>
                                        </select>
                                    </dd>
                                </dl>
                                <dl id="shoutcast_dl">
                                    <dt>${t('output.other.shoutcastPushUrl')}</dt>
                                    <dd>
                                        <input id="shoutcast_publish_uri" name="shoutcast_publish_uri" maxlength="256" size="36"
                                            type="text" />
                                        <select id="shoutcast_publish_enable" name="shoutcast_publish_enable">
                                            <option value="0" selected="selected">${t('common.disable')}</option>
                                            <option value="1">${t('common.enable')}</option>
                                        </select>
                                    </dd>
                                </dl>

                                <dl>
                                    <dt>&nbsp;&nbsp;</dt>
                                    <dd>
                                        <button type="button" class="btn btn-primary btn-save" onclick="SetOtherInput()" id="subBut">${t('common.save')}</button>
                                    </dd>
                                </dl>
                            </div>


                        </div>
                        <!-- End .tabWrite -->
                    </div>
                    <!-- End .tab_content_wrap -->
                </div>`;

    $("#ouputContentDiv").html(content);
}

$(function () {
    generalContent();
    initOutputPage();

    const urlParams = new URLSearchParams(window.location.search);
    const activeTab = urlParams.get('tab') || 'encodePart';

    // 激活对应的 tab
    changeTab(activeTab);
})
