Browse Source

Merge pull request #14 from lawrencehj/wvp-28181-2.0

修正上级注册的代码
pull/15/head
648540858 4 years ago
committed by GitHub
parent
commit
bc2e5e7a37
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderProvider.java
  2. 2
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java
  3. 16
      src/main/java/com/genersoft/iot/vmp/vmanager/platform/PlatformController.java
  4. 156
      web_src/src/components/platformEdit.vue

12
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderProvider.java

@ -173,7 +173,7 @@ public class SIPRequestHeaderProvider {
}
public Request createRegisterRequest(@NotNull ParentPlatform platform, String fromTag, String viaTag) throws ParseException, InvalidArgumentException, PeerUnavailableException {
public Request createRegisterRequest(@NotNull ParentPlatform platform, long CSeq, String fromTag, String viaTag) throws ParseException, InvalidArgumentException, PeerUnavailableException {
Request request = null;
String sipAddress = sipConfig.getSipIp() + ":" + sipConfig.getSipPort();
//请求行
@ -206,7 +206,7 @@ public class SIPRequestHeaderProvider {
MaxForwardsHeader maxForwards = sipFactory.createHeaderFactory().createMaxForwardsHeader(70);
//ceq
CSeqHeader cSeqHeader = sipFactory.createHeaderFactory().createCSeqHeader(1L, Request.REGISTER);
CSeqHeader cSeqHeader = sipFactory.createHeaderFactory().createCSeqHeader(CSeq, Request.REGISTER);
request = sipFactory.createMessageFactory().createRequest(requestLine, Request.REGISTER, callIdHeader,
cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards);
@ -214,12 +214,15 @@ public class SIPRequestHeaderProvider {
.createSipURI(platform.getDeviceGBId(), sipAddress));
request.addHeader(sipFactory.createHeaderFactory().createContactHeader(concatAddress));
ExpiresHeader expires = sipFactory.createHeaderFactory().createExpiresHeader(3600);
request.addHeader(expires);
return request;
}
public Request createRegisterRequest(@NotNull ParentPlatform parentPlatform, String fromTag, String viaTag,
String callId, String realm, String nonce, String scheme) throws ParseException, PeerUnavailableException, InvalidArgumentException {
Request registerRequest = createRegisterRequest(parentPlatform, fromTag, viaTag);
Request registerRequest = createRegisterRequest(parentPlatform, 2L, fromTag, viaTag);
CallIdHeader callIdHeader = (CallIdHeader)registerRequest.getHeader(CallIdHeader.NAME);
callIdHeader.setCallId(callId);
@ -233,8 +236,7 @@ public class SIPRequestHeaderProvider {
String RESPONSE = DigestUtils.md5DigestAsHex((HA1 + ":" + nonce + ":" + HA2).getBytes());
String authorizationHeaderContent = scheme + " username=\"" + parentPlatform.getDeviceGBId() + "\", " + "realm=\""
+ realm + "\", uri=\"" + uri + "\", response=\"" + RESPONSE + "\", nonce=\""
+ nonce + "\"";
+ realm + "\", nonce=\"" + nonce + "\", uri=\"" + uri + "\", response=\"" + RESPONSE + "\"" + ", algorithm=MD5";
AuthorizationHeader authorizationHeader = sipFactory.createHeaderFactory().createAuthorizationHeader(authorizationHeaderContent);
registerRequest.addHeader(authorizationHeader);

2
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java

@ -52,7 +52,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
try {
Request request = null;
if (realm == null || nonce == null) {
request = headerProvider.createRegisterRequest(parentPlatform, null, null);
request = headerProvider.createRegisterRequest(parentPlatform, 1L, null, null);
}else {
request = headerProvider.createRegisterRequest(parentPlatform, null, null, callId, realm, nonce, scheme);
}

16
src/main/java/com/genersoft/iot/vmp/vmanager/platform/PlatformController.java

@ -1,5 +1,6 @@
package com.genersoft.iot.vmp.vmanager.platform;
import com.alibaba.fastjson.JSONObject;
import com.genersoft.iot.vmp.common.PageResult;
import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
@ -15,6 +16,8 @@ import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import com.genersoft.iot.vmp.conf.SipConfig;
@CrossOrigin
@RestController
@ -29,6 +32,19 @@ public class PlatformController {
@Autowired
private ISIPCommanderForPlatform commanderForPlatform;
@Autowired
private SipConfig sipConfig;
@GetMapping("/platforms/serverconfig")
public ResponseEntity<JSONObject> serverConfig() {
JSONObject result = new JSONObject();
result.put("deviceIp", sipConfig.getSipIp());
result.put("devicePort", sipConfig.getSipPort());
result.put("username", sipConfig.getSipId());
result.put("password", sipConfig.getSipPassword());
return new ResponseEntity<>(result, HttpStatus.OK);
}
@GetMapping("/platforms/{count}/{page}")
public PageResult<ParentPlatform> platforms(@PathVariable int page, @PathVariable int count){

156
web_src/src/components/platformEdit.vue

@ -1,11 +1,18 @@
<template>
<div id="addlatform" v-loading="isLoging">
<el-dialog title="添加平台" width="70%" top="2rem" :close-on-click-modal="false" :visible.sync="showDialog" :destroy-on-close="true" @close="close()">
<div id="shared" style="text-align: right; margin-top: 1rem;">
<div id="addlatform" v-loading="isLoging">
<el-dialog
title="添加平台"
width="70%"
top="2rem"
:close-on-click-modal="false"
:visible.sync="showDialog"
:destroy-on-close="true"
@close="close()"
>
<div id="shared" style="text-align: right; margin-top: 1rem">
<el-row :gutter="24">
<el-col :span="11">
<el-form ref="platform1" :rules="rules" :model="platform" label-width="160px" >
<el-form ref="platform1" :rules="rules" :model="platform" label-width="160px">
<el-form-item label="名称" prop="name">
<el-input v-model="platform.name"></el-input>
</el-form-item>
@ -30,7 +37,6 @@
<el-form-item label="本地端口" prop="devicePort">
<el-input v-model="platform.devicePort" :disabled="true"></el-input>
</el-form-item>
</el-form>
</el-col>
<el-col :span="12">
@ -48,24 +54,34 @@
<el-input v-model="platform.keepTimeout"></el-input>
</el-form-item>
<el-form-item label="信令传输" prop="transport">
<el-select v-model="platform.transport" style="width:100%" placeholder="请选择信令传输方式">
<el-select
v-model="platform.transport"
style="width: 100%"
placeholder="请选择信令传输方式"
>
<el-option label="UDP" value="UDP"></el-option>
<el-option label="TCP" value="TCP"></el-option>
</el-select>
</el-form-item>
<el-form-item label="字符集" prop="characterSet">
<el-select v-model="platform.characterSet" style="width:100%" placeholder="请选择字符集">
<el-select
v-model="platform.characterSet"
style="width: 100%"
placeholder="请选择字符集"
>
<el-option label="GB2312" value="GB2312"></el-option>
<el-option label="UTF-8" value="UTF-8"></el-option>
</el-select>
</el-form-item>
<el-form-item label="其他选项" >
<el-checkbox label="启用" v-model="platform.enable" ></el-checkbox>
<el-form-item label="其他选项">
<el-checkbox label="启用" v-model="platform.enable"></el-checkbox>
<el-checkbox label="云台控制" v-model="platform.PTZEnable"></el-checkbox>
<el-checkbox label="RTCP保活" v-model="platform.rtcp"></el-checkbox>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="onSubmit">{{onSubmit_text}}</el-button>
<el-button type="primary" @click="onSubmit">{{
onSubmit_text
}}</el-button>
<el-button @click="close">取消</el-button>
</el-form-item>
</el-form>
@ -73,30 +89,28 @@
</el-row>
</div>
</el-dialog>
</div>
</div>
</template>
<script>
export default {
name: 'platformEdit',
name: "platformEdit",
props: {},
computed: {
},
computed: {},
created() {},
data() {
var deviceGBIdRules = async (rule, value, callback) => {
console.log(value)
if (value === '') {
callback(new Error('请输入设备国标编号'));
console.log(value);
if (value === "") {
callback(new Error("请输入设备国标编号"));
} else {
var exit = await this.deviceGBIdExit(value);
console.log(exit)
console.log(exit == "true")
console.log(exit === "true")
console.log(exit);
console.log(exit == "true");
console.log(exit === "true");
if (exit) {
callback(new Error('设备国标编号已存在'));
}else {
callback(new Error("设备国标编号已存在"));
} else {
callback();
}
}
@ -105,7 +119,7 @@ export default {
listChangeCallback: null,
showDialog: false,
isLoging: false,
onSubmit_text:"立即创建",
onSubmit_text: "立即创建",
// platform: {
// enable: false,
// PTZEnable: true,
@ -145,71 +159,66 @@ export default {
characterSet: "GB2312",
},
rules: {
name: [
{ required: true, message:"请输入平台名称", trigger: 'blur' }
],
name: [{ required: true, message: "请输入平台名称", trigger: "blur" }],
serverGBId: [
{ required: true, message:"请输入SIP服务国标编码", trigger: 'blur' }
{ required: true, message: "请输入SIP服务国标编码", trigger: "blur" },
],
serverGBDomain: [
{ required: true, message:"请输入SIP服务国标域", trigger: 'blur' }
],
serverIP: [
{ required: true, message:"请输入SIP服务IP", trigger: 'blur' }
{ required: true, message: "请输入SIP服务国标域", trigger: "blur" },
],
serverPort: [
{ required: true, message:"请输入SIP服务端口", trigger: 'blur' }
],
deviceGBId: [
{validator: deviceGBIdRules, trigger: 'blur' }
],
username: [
{ required: false, message:"请输入SIP认证用户名", trigger: 'blur' }
],
password: [
{ required: false, message:"请输入SIP认证密码", trigger: 'blur' }
],
expires: [
{ required: true, message:"请输入注册周期", trigger: 'blur' }
],
keepTimeout: [
{ required: true, message:"请输入心跳周期", trigger: 'blur' }
],
transport: [
{ required: true, message:"请选择信令传输", trigger: 'blur' }
],
characterSet: [
{ required: true, message:"请选择编码字符集", trigger: 'blur' }
]
}
serverIP: [{ required: true, message: "请输入SIP服务IP", trigger: "blur" }],
serverPort: [{ required: true, message: "请输入SIP服务端口", trigger: "blur" }],
deviceGBId: [{ validator: deviceGBIdRules, trigger: "blur" }],
username: [{ required: false, message: "请输入SIP认证用户名", trigger: "blur" }],
password: [{ required: false, message: "请输入SIP认证密码", trigger: "blur" }],
expires: [{ required: true, message: "请输入注册周期", trigger: "blur" }],
keepTimeout: [{ required: true, message: "请输入心跳周期", trigger: "blur" }],
transport: [{ required: true, message: "请选择信令传输", trigger: "blur" }],
characterSet: [{ required: true, message: "请选择编码字符集", trigger: "blur" }],
},
};
},
methods: {
openDialog: function (platform, callback) {
var that = this;
this.$axios
.get(`/api/platforms/serverconfig`)
.then(function (res) {
console.log(res);
that.platform.deviceGBId = res.data.username;
that.platform.deviceIp = res.data.deviceIp;
that.platform.devicePort = res.data.devicePort;
that.platform.username = res.data.username;
that.platform.password = res.data.password;
})
.catch(function (error) {
console.log(error);
});
this.showDialog = true;
this.listChangeCallback = callback;
if (platform != null) {
this.platform = platform;
this.onSubmit_text = "保存"
this.onSubmit_text = "保存";
} else {
}
},
onSubmit: function () {
console.log('onSubmit');
console.log("onSubmit");
var that = this;
that.$axios.post(`/api/platforms/save`, that.platform)
that.$axios
.post(`/api/platforms/save`, that.platform)
.then(function (res) {
console.log(res)
console.log(res.data == "success")
console.log(res);
console.log(res.data == "success");
if (res.data == "success") {
that.$message({
showClose: true,
message: '保存成功',
type: 'success'
message: "保存成功",
type: "success",
});
that.showDialog = false;
if (that.listChangeCallback != null) {
that.listChangeCallback()
that.listChangeCallback();
}
}
})
@ -218,15 +227,16 @@ export default {
});
},
close: function () {
console.log('关闭添加视频平台');
console.log("关闭添加视频平台");
this.showDialog = false;
this.$refs.platform1.resetFields();
this.$refs.platform2.resetFields();
},
deviceGBIdExit: async function (deviceGbId) {
var result = false;
var that = this
await that.$axios.post(`/api/platforms/exit/${deviceGbId}`)
var that = this;
await that.$axios
.post(`/api/platforms/exit/${deviceGbId}`)
.then(function (res) {
result = res.data;
})
@ -234,10 +244,8 @@ export default {
console.log(error);
});
return result;
}
}
},
},
};
</script>

Loading…
Cancel
Save