Commit 381e3129a3e4efbf2423be6a63342fc9c35befbc
1 parent
dcd78a1c
存储部分使用sqlite代替redis-4
Showing
6 changed files
with
39 additions
and
18 deletions
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java
| ... | ... | @@ -357,11 +357,7 @@ public class SIPCommander implements ISIPCommander { |
| 357 | 357 | |
| 358 | 358 | ClientTransaction transaction = transmitRequest(device, request, errorEvent); |
| 359 | 359 | streamSession.put(streamId, transaction); |
| 360 | - DeviceChannel deviceChannel = storager.queryChannel(device.getDeviceId(), channelId); | |
| 361 | - if (deviceChannel != null) { | |
| 362 | - deviceChannel.setStreamId(streamId); | |
| 363 | - storager.updateChannel(device.getDeviceId(), deviceChannel); | |
| 364 | - } | |
| 360 | + | |
| 365 | 361 | |
| 366 | 362 | |
| 367 | 363 | } catch ( SipException | ParseException | InvalidArgumentException e) { | ... | ... |
src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java
| ... | ... | @@ -23,7 +23,8 @@ public interface DeviceChannelMapper { |
| 23 | 23 | "SET name=#{name}, manufacture=#{manufacture}, model=#{model}, owner=#{owner}, civilCode=#{civilCode}, " + |
| 24 | 24 | "block=#{block}, address=#{address}, parental=#{parental}, parentId=#{parentId}, safetyWay=#{safetyWay}, " + |
| 25 | 25 | "registerWay=#{registerWay}, certNum=#{certNum}, certifiable=#{certifiable}, errCode=#{errCode}, secrecy=#{secrecy}, " + |
| 26 | - "ipAddress=#{ipAddress}, port=#{port}, password=#{password}, PTZType=#{PTZType}, status=#{status} " + | |
| 26 | + "ipAddress=#{ipAddress}, port=#{port}, password=#{password}, PTZType=#{PTZType}, status=#{status}, streamId=#{streamId}, " + | |
| 27 | + "hasAudio=#{hasAudio}" + | |
| 27 | 28 | "WHERE deviceId=#{deviceId} AND channelId=#{channelId}") |
| 28 | 29 | int update(DeviceChannel channel); |
| 29 | 30 | ... | ... |
src/main/java/com/genersoft/iot/vmp/vmanager/service/impl/PlayServiceImpl.java
| ... | ... | @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON; |
| 4 | 4 | import com.alibaba.fastjson.JSONObject; |
| 5 | 5 | import com.genersoft.iot.vmp.common.StreamInfo; |
| 6 | 6 | import com.genersoft.iot.vmp.conf.MediaServerConfig; |
| 7 | +import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; | |
| 7 | 8 | import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; |
| 8 | 9 | import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; |
| 9 | 10 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| ... | ... | @@ -37,6 +38,12 @@ public class PlayServiceImpl implements IPlayService { |
| 37 | 38 | msg.setId(DeferredResultHolder.CALLBACK_CMD_PlAY + uuid); |
| 38 | 39 | StreamInfo streamInfo = onPublishHandler(resonse, deviceId, channelId, uuid); |
| 39 | 40 | if (streamInfo != null) { |
| 41 | + DeviceChannel deviceChannel = storager.queryChannel(deviceId, channelId); | |
| 42 | + if (deviceChannel != null) { | |
| 43 | + deviceChannel.setStreamId(streamInfo.getStreamId()); | |
| 44 | + storager.updateChannel(deviceId, deviceChannel); | |
| 45 | + } | |
| 46 | + | |
| 40 | 47 | redisCatchStorage.startPlay(streamInfo); |
| 41 | 48 | msg.setData(JSON.toJSONString(streamInfo)); |
| 42 | 49 | resultHolder.invokeResult(msg); | ... | ... |
src/main/resources/application-dev.yml
| ... | ... | @@ -20,13 +20,20 @@ spring: |
| 20 | 20 | timeout: 10000 |
| 21 | 21 | # [不可用] jdbc数据库配置, 暂不支持 |
| 22 | 22 | datasource: |
| 23 | + # name: eiot | |
| 24 | + # url: jdbc:mysql://127.0.0.1:3306/eiot?useUnicode=true&characterEncoding=UTF8&rewriteBatchedStatements=true | |
| 25 | + # username: | |
| 26 | + # password: | |
| 27 | + # type: com.alibaba.druid.pool.DruidDataSource | |
| 28 | + # driver-class-name: com.mysql.jdbc.Driver | |
| 23 | 29 | name: eiot |
| 24 | - url: jdbc:mysql://127.0.0.1:3306/eiot?useUnicode=true&characterEncoding=UTF8&rewriteBatchedStatements=true | |
| 30 | + url: jdbc:sqlite::resource:wvp.sqlite | |
| 25 | 31 | username: |
| 26 | 32 | password: |
| 27 | 33 | type: com.alibaba.druid.pool.DruidDataSource |
| 28 | - driver-class-name: com.mysql.jdbc.Driver | |
| 29 | - | |
| 34 | + driver-class-name: org.sqlite.JDBC | |
| 35 | + max-active: 1 | |
| 36 | + min-idle: 1 | |
| 30 | 37 | |
| 31 | 38 | # [可选] WVP监听的HTTP端口, 网页和接口调用都是这个端口 |
| 32 | 39 | server: | ... | ... |
src/main/resources/wvp.sqlite
No preview for this file type
web_src/src/components/channelList.vue
| ... | ... | @@ -19,12 +19,12 @@ |
| 19 | 19 | <el-option label="设备" value="false"></el-option> |
| 20 | 20 | <el-option label="子目录" value="true"></el-option> |
| 21 | 21 | </el-select> |
| 22 | - 在线状态: <el-select size="mini" @change="search" v-model="online" placeholder="请选择" default-first-option> | |
| 22 | + 在线状态: <el-select size="mini" style="margin-right: 1rem;" @change="search" v-model="online" placeholder="请选择" default-first-option> | |
| 23 | 23 | <el-option label="全部" value=""></el-option> |
| 24 | 24 | <el-option label="在线" value="true"></el-option> |
| 25 | 25 | <el-option label="离线" value="false"></el-option> |
| 26 | 26 | </el-select> |
| 27 | - | |
| 27 | + <el-checkbox size="mini" style="margin-right: 1rem; float: right;" v-model="autoList" @change="autoListChange">自动刷新</el-checkbox> | |
| 28 | 28 | </div> |
| 29 | 29 | <devicePlayer ref="devicePlayer" v-loading="isLoging"></devicePlayer> |
| 30 | 30 | <!--设备列表--> |
| ... | ... | @@ -56,7 +56,7 @@ |
| 56 | 56 | <el-button-group> |
| 57 | 57 | <!-- <el-button size="mini" icon="el-icon-video-play" v-if="scope.row.parental == 0" @click="sendDevicePush(scope.row)">播放</el-button> --> |
| 58 | 58 | <el-button size="mini" icon="el-icon-video-play" @click="sendDevicePush(scope.row)">播放</el-button> |
| 59 | - <el-button size="mini" icon="el-icon-switch-button" type="danger" v-if="scope.row.play" @click="stopDevicePush(scope.row)">停止</el-button> | |
| 59 | + <el-button size="mini" icon="el-icon-switch-button" type="danger" v-if="!!scope.row.streamId" @click="stopDevicePush(scope.row)">停止</el-button> | |
| 60 | 60 | <el-button size="mini" icon="el-icon-s-open" type="primary" v-if="scope.row.parental == 1" @click="changeSubchannel(scope.row)">查看</el-button> |
| 61 | 61 | <el-button size="mini" icon="el-icon-video-camera" type="primary" @click="queryRecords(scope.row)">设备录象</el-button> |
| 62 | 62 | <!-- <el-button size="mini" @click="sendDevicePush(scope.row)">录像查询</el-button> --> |
| ... | ... | @@ -98,13 +98,17 @@ export default { |
| 98 | 98 | count: parseInt(this.$route.params.count), |
| 99 | 99 | total: 0, |
| 100 | 100 | beforeUrl: "/videoList", |
| 101 | - isLoging: false | |
| 101 | + isLoging: false, | |
| 102 | + autoList: false | |
| 102 | 103 | }; |
| 103 | 104 | }, |
| 104 | 105 | |
| 105 | 106 | mounted() { |
| 106 | 107 | this.initData(); |
| 107 | - this.updateLooper = setInterval(this.initData, 1000); | |
| 108 | + if (this.autoList) { | |
| 109 | + this.updateLooper = setInterval(this.initData, 1500); | |
| 110 | + } | |
| 111 | + | |
| 108 | 112 | }, |
| 109 | 113 | destroyed() { |
| 110 | 114 | this.$destroy('videojs'); |
| ... | ... | @@ -179,12 +183,11 @@ export default { |
| 179 | 183 | let deviceId = this.deviceId; |
| 180 | 184 | this.isLoging = true; |
| 181 | 185 | let channelId = itemData.channelId; |
| 182 | - let getEncoding = itemData.hasAudio ? '1' : '0' | |
| 183 | - console.log("通知设备推流1:" + deviceId + " : " + channelId + ":" + getEncoding); | |
| 186 | + console.log("通知设备推流1:" + deviceId + " : " + channelId ); | |
| 184 | 187 | let that = this; |
| 185 | 188 | this.$axios({ |
| 186 | 189 | method: 'get', |
| 187 | - url: '/api/play/' + deviceId + '/' + channelId + '?getEncoding=' + getEncoding | |
| 190 | + url: '/api/play/' + deviceId + '/' + channelId | |
| 188 | 191 | }).then(function (res) { |
| 189 | 192 | console.log(res.data) |
| 190 | 193 | let streamId = res.data.streamId; |
| ... | ... | @@ -258,7 +261,7 @@ export default { |
| 258 | 261 | }) |
| 259 | 262 | .then(function (res) { |
| 260 | 263 | that.total = res.data.total; |
| 261 | - that.deviceChannelList = res.data.data; | |
| 264 | + that.deviceChannelList = res.data.list; | |
| 262 | 265 | // 防止出现表格错位 |
| 263 | 266 | that.$nextTick(() => { |
| 264 | 267 | that.$refs.channelListTable.doLayout(); |
| ... | ... | @@ -283,6 +286,13 @@ export default { |
| 283 | 286 | }).then(function (res) { |
| 284 | 287 | console.log(JSON.stringify(res)); |
| 285 | 288 | }); |
| 289 | + }, | |
| 290 | + autoListChange: function () { | |
| 291 | + if (this.autoList) { | |
| 292 | + this.updateLooper = setInterval(this.initData, 1500); | |
| 293 | + }else{ | |
| 294 | + window.clearInterval(this.updateLooper); | |
| 295 | + } | |
| 286 | 296 | } |
| 287 | 297 | |
| 288 | 298 | } | ... | ... |