<div class="layui-form" lay-filter="layuiadmin-form">
    <input type="hidden" name="id">
    <div class="layui-form-item">
        <label class="layui-form-label">通道名称</label>
        <div class="layui-input-inline">
            <input type="text" name="rtsp_name" placeholder="名称唯一" maxlength="100" lay-verify="required"
                autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">取流器</label>
        <div class="layui-input-inline">
            <select name="collector" id="collector" lay-verify="required">
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">rtsp地址</label>
        <div class="layui-input-inline" style="width:400px">
            <textarea name="rtsp_url" placeholder="rtsp://..." style="min-height: 60px;" onkeydown="checkEnter(event)" maxlength="1024"
                lay-verify="required" class="layui-textarea" />
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">推流地址</label>
        <div class="layui-input-inline" style="width:400px">
            <textarea name="rtmp_url" placeholder="可选 rtmp://127.0.0.1:1935/live/通道名称" style="min-height: 60px;"  onkeydown="checkEnter(event)"
                maxlength="1024" class="layui-textarea" />
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">推流模式</label>
        <div class="layui-input-inline">
            <select name="rtmp_mode" id="rtmp_mode" lay-verify="required">
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"></label>
        <div class="layui-input-inline">
            <input type="button" lay-submit lay-filter="LAY-front-submit" value="确认" class="layui-btn">
        </div>
    </div>
    <blockquote class="layui-elem-quote">推流模式说明:
        <ol>
            <li>1、预览推流：仅支持nginx-http-flv 或者 nginx-rtmp需要配置相关回调参数。此模式rtmp地址有格式要求如rtmp://127.0.0.1:1935/live/通道名称 ，后缀通道名称必须保持一致。</li>
            <li>2、持续推流：支持nginx-http-flv nginx-rtmp及第三方rtmp服务；此模式会一直保持推流请注意带宽流量，不再推流时请切换推流模式。</li>
            <li>3、推流视频支持H264，音频支持AAC PCMA PCMU。</li>
        </ol>
    </blockquote>
</div>

<script>
    layui.use(['admin', 'video', 'form'], function () {
        var $ = layui.$
            , form = layui.form;

        //加载取流器
        function bindCollector() {
            var _collector = $('#collector');
            _collector.empty();
            _collector.append("<option value='0' >默认取流器</option>");
            _collector.append("<option value='1' >旧版取流器</option>");
        }
        //加载推流模式
        function bindMode() {
            let _mode = $('#rtmp_mode');
            _mode.empty();
            _mode.append("<option value='0' >预览推流</option>");
            _mode.append("<option value='1' >持续推流</option>");
        }
        bindCollector();
        bindMode();
    })
    function checkEnter(e) {
        var et = e || window.event;
        var keycode = et.charCode || et.keyCode;
        if (keycode == 13) {
            if (window.event) {
                window.event.returnValue = false;
            } else {
                e.preventDefault();
            }
        }
    }
</script>