Commit f9ab13a14590d310937de7d78a36ee599dce750b
1 parent
d4ae8194
添加通道音频设置
添加media配置
Showing
13 changed files
with
234 additions
and
23 deletions
pom.xml
| @@ -145,16 +145,19 @@ | @@ -145,16 +145,19 @@ | ||
| 145 | </dependency> | 145 | </dependency> |
| 146 | 146 | ||
| 147 | <dependency> | 147 | <dependency> |
| 148 | - <groupId>org.mitre.dsmiley.httpproxy</groupId> | ||
| 149 | - <artifactId>smiley-http-proxy-servlet</artifactId> | ||
| 150 | - <version>1.7</version> | ||
| 151 | - </dependency> | ||
| 152 | - <dependency> | ||
| 153 | <groupId>com.google.guava</groupId> | 148 | <groupId>com.google.guava</groupId> |
| 154 | <artifactId>guava</artifactId> | 149 | <artifactId>guava</artifactId> |
| 155 | <version>18.0</version> | 150 | <version>18.0</version> |
| 156 | </dependency> | 151 | </dependency> |
| 157 | - | 152 | + |
| 153 | + <!-- okhttp --> | ||
| 154 | + <dependency> | ||
| 155 | + <groupId>com.squareup.okhttp3</groupId> | ||
| 156 | + <artifactId>okhttp</artifactId> | ||
| 157 | + <version>4.9.0</version> | ||
| 158 | + </dependency> | ||
| 159 | + | ||
| 160 | + | ||
| 158 | </dependencies> | 161 | </dependencies> |
| 159 | 162 | ||
| 160 | <build> | 163 | <build> |
src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceChannel.java
| @@ -143,6 +143,11 @@ public class DeviceChannel { | @@ -143,6 +143,11 @@ public class DeviceChannel { | ||
| 143 | */ | 143 | */ |
| 144 | private String ssrc; | 144 | private String ssrc; |
| 145 | 145 | ||
| 146 | + /** | ||
| 147 | + * 是否含有音频 | ||
| 148 | + */ | ||
| 149 | + private boolean hasAudio; | ||
| 150 | + | ||
| 146 | public String getChannelId() { | 151 | public String getChannelId() { |
| 147 | return channelId; | 152 | return channelId; |
| 148 | } | 153 | } |
| @@ -371,4 +376,16 @@ public class DeviceChannel { | @@ -371,4 +376,16 @@ public class DeviceChannel { | ||
| 371 | public void setSubCount(int subCount) { | 376 | public void setSubCount(int subCount) { |
| 372 | this.subCount = subCount; | 377 | this.subCount = subCount; |
| 373 | } | 378 | } |
| 379 | + | ||
| 380 | + public void setPTZTypeText(String PTZTypeText) { | ||
| 381 | + this.PTZTypeText = PTZTypeText; | ||
| 382 | + } | ||
| 383 | + | ||
| 384 | + public boolean isHasAudio() { | ||
| 385 | + return hasAudio; | ||
| 386 | + } | ||
| 387 | + | ||
| 388 | + public void setHasAudio(boolean hasAudio) { | ||
| 389 | + this.hasAudio = hasAudio; | ||
| 390 | + } | ||
| 374 | } | 391 | } |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java
| @@ -241,13 +241,6 @@ public class SIPCommander implements ISIPCommander { | @@ -241,13 +241,6 @@ public class SIPCommander implements ISIPCommander { | ||
| 241 | 241 | ||
| 242 | StreamInfo streamInfo = new StreamInfo(); | 242 | StreamInfo streamInfo = new StreamInfo(); |
| 243 | streamInfo.setSsrc(ssrc); | 243 | streamInfo.setSsrc(ssrc); |
| 244 | -// String streamId = Integer.toHexString(Integer.parseInt(streamInfo.getSsrc())); | ||
| 245 | -// String streamId = String.format("%08x", Integer.parseInt(streamInfo.getSsrc())).toUpperCase(); // ZLM 要求大写且首位补零 | ||
| 246 | -// streamInfo.setFlv(String.format("http://%s:%s/rtp/%s.flv", mediaInfo.getLocalIP(), mediaInfo.getHttpPort(), streamId)); | ||
| 247 | -// streamInfo.setWS_FLV(String.format("ws://%s:%s/rtp/%s.flv", mediaInfo.getLocalIP(), mediaInfo.getHttpPort(), streamId)); | ||
| 248 | -// streamInfo.setRTMP(String.format("rtmp://%s:%s/rtp/%s", mediaInfo.getLocalIP(), mediaInfo.getRtmpPort(), streamId)); | ||
| 249 | -// streamInfo.setHLS(String.format("http://%s:%s/rtp/%s/hls.m3u8", mediaInfo.getLocalIP(), mediaInfo.getHttpPort(), streamId)); | ||
| 250 | -// streamInfo.setRTSP(String.format("rtsp://%s:%s/rtp/%s", mediaInfo.getLocalIP(), mediaInfo.getRtspPort(), streamId)); | ||
| 251 | streamInfo.setCahnnelId(channelId); | 244 | streamInfo.setCahnnelId(channelId); |
| 252 | streamInfo.setDeviceID(device.getDeviceId()); | 245 | streamInfo.setDeviceID(device.getDeviceId()); |
| 253 | storager.startPlay(streamInfo); | 246 | storager.startPlay(streamInfo); |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/MessageRequestProcessor.java
| @@ -200,6 +200,7 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor { | @@ -200,6 +200,7 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor { | ||
| 200 | deviceChannel.setLongitude(itemDevice.element("Longitude") == null? 0.00:Double.parseDouble(XmlUtil.getText(itemDevice,"Longitude"))); | 200 | deviceChannel.setLongitude(itemDevice.element("Longitude") == null? 0.00:Double.parseDouble(XmlUtil.getText(itemDevice,"Longitude"))); |
| 201 | deviceChannel.setLatitude(itemDevice.element("Latitude") == null? 0.00:Double.parseDouble(XmlUtil.getText(itemDevice,"Latitude"))); | 201 | deviceChannel.setLatitude(itemDevice.element("Latitude") == null? 0.00:Double.parseDouble(XmlUtil.getText(itemDevice,"Latitude"))); |
| 202 | deviceChannel.setPTZType(itemDevice.element("PTZType") == null? 0:Integer.parseInt(XmlUtil.getText(itemDevice,"PTZType"))); | 202 | deviceChannel.setPTZType(itemDevice.element("PTZType") == null? 0:Integer.parseInt(XmlUtil.getText(itemDevice,"PTZType"))); |
| 203 | + deviceChannel.setHasAudio(false); // 默认含有音频为false | ||
| 203 | storager.updateChannel(device.getDeviceId(), deviceChannel); | 204 | storager.updateChannel(device.getDeviceId(), deviceChannel); |
| 204 | } | 205 | } |
| 205 | // 更新 | 206 | // 更新 |
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHTTPProxyController.java
| @@ -2,7 +2,6 @@ package com.genersoft.iot.vmp.media.zlm; | @@ -2,7 +2,6 @@ package com.genersoft.iot.vmp.media.zlm; | ||
| 2 | 2 | ||
| 3 | import com.alibaba.fastjson.JSONObject; | 3 | import com.alibaba.fastjson.JSONObject; |
| 4 | import com.genersoft.iot.vmp.storager.IVideoManagerStorager; | 4 | import com.genersoft.iot.vmp.storager.IVideoManagerStorager; |
| 5 | -import org.apache.http.HttpResponse; | ||
| 6 | import org.slf4j.Logger; | 5 | import org.slf4j.Logger; |
| 7 | import org.slf4j.LoggerFactory; | 6 | import org.slf4j.LoggerFactory; |
| 8 | import org.springframework.beans.factory.annotation.Autowired; | 7 | import org.springframework.beans.factory.annotation.Autowired; |
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
| @@ -14,6 +14,7 @@ import com.genersoft.iot.vmp.utils.IpUtil; | @@ -14,6 +14,7 @@ import com.genersoft.iot.vmp.utils.IpUtil; | ||
| 14 | import org.slf4j.Logger; | 14 | import org.slf4j.Logger; |
| 15 | import org.slf4j.LoggerFactory; | 15 | import org.slf4j.LoggerFactory; |
| 16 | import org.springframework.beans.factory.annotation.Autowired; | 16 | import org.springframework.beans.factory.annotation.Autowired; |
| 17 | +import org.springframework.beans.factory.annotation.Value; | ||
| 17 | import org.springframework.http.HttpStatus; | 18 | import org.springframework.http.HttpStatus; |
| 18 | import org.springframework.http.ResponseEntity; | 19 | import org.springframework.http.ResponseEntity; |
| 19 | import org.springframework.web.bind.annotation.PostMapping; | 20 | import org.springframework.web.bind.annotation.PostMapping; |
| @@ -44,7 +45,13 @@ public class ZLMHttpHookListener { | @@ -44,7 +45,13 @@ public class ZLMHttpHookListener { | ||
| 44 | 45 | ||
| 45 | @Autowired | 46 | @Autowired |
| 46 | private IVideoManagerStorager storager; | 47 | private IVideoManagerStorager storager; |
| 47 | - | 48 | + |
| 49 | + @Value("${media.ip}") | ||
| 50 | + private String mediaIp; | ||
| 51 | + | ||
| 52 | + @Value("${media.port}") | ||
| 53 | + private int mediaPort; | ||
| 54 | + | ||
| 48 | /** | 55 | /** |
| 49 | * 流量统计事件,播放器或推流器断开时并且耗用流量超过特定阈值时会触发此事件,阈值通过配置文件general.flowThreshold配置;此事件对回复不敏感。 | 56 | * 流量统计事件,播放器或推流器断开时并且耗用流量超过特定阈值时会触发此事件,阈值通过配置文件general.flowThreshold配置;此事件对回复不敏感。 |
| 50 | * | 57 | * |
| @@ -308,6 +315,7 @@ public class ZLMHttpHookListener { | @@ -308,6 +315,7 @@ public class ZLMHttpHookListener { | ||
| 308 | // List<MediaServerConfig> mediaServerConfigs = JSON.parseArray(JSON.toJSONString(json), MediaServerConfig.class); | 315 | // List<MediaServerConfig> mediaServerConfigs = JSON.parseArray(JSON.toJSONString(json), MediaServerConfig.class); |
| 309 | // MediaServerConfig mediaServerConfig = mediaServerConfigs.get(0); | 316 | // MediaServerConfig mediaServerConfig = mediaServerConfigs.get(0); |
| 310 | MediaServerConfig mediaServerConfig = JSON.toJavaObject(json, MediaServerConfig.class); | 317 | MediaServerConfig mediaServerConfig = JSON.toJavaObject(json, MediaServerConfig.class); |
| 318 | + mediaServerConfig.setLocalIP(mediaIp); | ||
| 311 | storager.updateMediaInfo(mediaServerConfig); | 319 | storager.updateMediaInfo(mediaServerConfig); |
| 312 | // TODO Auto-generated method stub | 320 | // TODO Auto-generated method stub |
| 313 | 321 |
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java
0 → 100644
| 1 | +package com.genersoft.iot.vmp.media.zlm; | ||
| 2 | + | ||
| 3 | +import com.alibaba.fastjson.JSON; | ||
| 4 | +import com.alibaba.fastjson.JSONArray; | ||
| 5 | +import com.alibaba.fastjson.JSONObject; | ||
| 6 | +import com.genersoft.iot.vmp.conf.MediaServerConfig; | ||
| 7 | +import com.genersoft.iot.vmp.storager.IVideoManagerStorager; | ||
| 8 | +import okhttp3.*; | ||
| 9 | +import org.slf4j.Logger; | ||
| 10 | +import org.slf4j.LoggerFactory; | ||
| 11 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 12 | +import org.springframework.beans.factory.annotation.Value; | ||
| 13 | +import org.springframework.boot.CommandLineRunner; | ||
| 14 | +import org.springframework.core.annotation.Order; | ||
| 15 | +import org.springframework.stereotype.Component; | ||
| 16 | + | ||
| 17 | +import java.io.IOException; | ||
| 18 | +import java.io.UnsupportedEncodingException; | ||
| 19 | +import java.net.URLEncoder; | ||
| 20 | + | ||
| 21 | +@Component | ||
| 22 | +@Order(value=1) | ||
| 23 | +public class ZLMRunner implements CommandLineRunner { | ||
| 24 | + | ||
| 25 | + private final static Logger logger = LoggerFactory.getLogger(ZLMRunner.class); | ||
| 26 | + | ||
| 27 | + @Autowired | ||
| 28 | + private IVideoManagerStorager storager; | ||
| 29 | + | ||
| 30 | + @Value("${media.ip}") | ||
| 31 | + private String mediaIp; | ||
| 32 | + | ||
| 33 | + @Value("${media.port}") | ||
| 34 | + private int mediaPort; | ||
| 35 | + | ||
| 36 | + @Value("${media.secret}") | ||
| 37 | + private String mediaSecret; | ||
| 38 | + | ||
| 39 | + @Value("${sip.ip}") | ||
| 40 | + private String sipIP; | ||
| 41 | + | ||
| 42 | + @Value("${server.port}") | ||
| 43 | + private String serverPort; | ||
| 44 | + | ||
| 45 | + @Override | ||
| 46 | + public void run(String... strings) throws Exception { | ||
| 47 | + // 获取zlm信息 | ||
| 48 | + logger.info("等待zlm接入..."); | ||
| 49 | + MediaServerConfig mediaServerConfig = getMediaServerConfig(); | ||
| 50 | + if (mediaServerConfig != null) { | ||
| 51 | + logger.info("zlm接入成功..."); | ||
| 52 | + storager.updateMediaInfo(mediaServerConfig); | ||
| 53 | + logger.info("设置zlm..."); | ||
| 54 | + saveZLMConfig(); | ||
| 55 | + | ||
| 56 | + } | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + | ||
| 60 | + | ||
| 61 | + public MediaServerConfig getMediaServerConfig() { | ||
| 62 | + MediaServerConfig mediaServerConfig = null; | ||
| 63 | + OkHttpClient client = new OkHttpClient(); | ||
| 64 | + String url = String.format("http://%s:%s/index/api/getServerConfig?secret=%s", mediaIp, mediaPort, mediaSecret); | ||
| 65 | + //创建一个Request | ||
| 66 | + Request request = new Request.Builder() | ||
| 67 | + .get() | ||
| 68 | + .url(url) | ||
| 69 | + .build(); | ||
| 70 | + //通过client发起请求 | ||
| 71 | + final Call call = client.newCall(request); | ||
| 72 | + //执行同步请求,获取Response对象 | ||
| 73 | + Response response = null; | ||
| 74 | + try { | ||
| 75 | + response = call.execute(); | ||
| 76 | + if (response.isSuccessful()) { | ||
| 77 | + String responseStr = response.body().string(); | ||
| 78 | + if (responseStr != null) { | ||
| 79 | + JSONObject responseJSON = JSON.parseObject(responseStr); | ||
| 80 | + JSONArray data = responseJSON.getJSONArray("data"); | ||
| 81 | + if (data != null && data.size() > 0) { | ||
| 82 | + mediaServerConfig = JSON.parseObject(JSON.toJSONString(data.get(0)), MediaServerConfig.class); | ||
| 83 | + mediaServerConfig.setLocalIP(mediaIp); | ||
| 84 | + } | ||
| 85 | + } | ||
| 86 | + }else { | ||
| 87 | + logger.error("getMediaServerConfig失败, 1s后重试"); | ||
| 88 | + Thread.sleep(1000); | ||
| 89 | + getMediaServerConfig(); | ||
| 90 | + } | ||
| 91 | + } catch (IOException e) { | ||
| 92 | + e.printStackTrace(); | ||
| 93 | + } catch (InterruptedException e) { | ||
| 94 | + e.printStackTrace(); | ||
| 95 | + } | ||
| 96 | + | ||
| 97 | + return mediaServerConfig; | ||
| 98 | + } | ||
| 99 | + | ||
| 100 | + private void saveZLMConfig() { | ||
| 101 | + String hookIP = sipIP; | ||
| 102 | + if (mediaIp.equals(sipIP)) { | ||
| 103 | + hookIP = "127.0.0.1"; | ||
| 104 | + } | ||
| 105 | + OkHttpClient client = new OkHttpClient(); | ||
| 106 | + String url = String.format("http://%s:%s/index/api/setServerConfig", mediaIp, mediaPort); | ||
| 107 | + String hookPrex = String.format("http://%s:%s/index/hook", hookIP, serverPort); | ||
| 108 | + | ||
| 109 | + RequestBody body = new FormBody.Builder() | ||
| 110 | + .add("secret",mediaSecret) | ||
| 111 | + .add("hook.enable","1") | ||
| 112 | + .add("hook.on_flow_report","") | ||
| 113 | + .add("hook.on_http_access","") | ||
| 114 | + .add("hook.on_publish",String.format("%s/on_publish", hookPrex)) | ||
| 115 | + .add("hook.on_record_mp4","") | ||
| 116 | + .add("hook.on_record_ts","") | ||
| 117 | + .add("hook.on_rtsp_auth","") | ||
| 118 | + .add("hook.on_rtsp_realm","") | ||
| 119 | + .add("hook.on_server_started",String.format("%s/on_server_started", hookPrex)) | ||
| 120 | + .add("hook.on_shell_login",String.format("%s/on_shell_login", hookPrex)) | ||
| 121 | + .add("hook.on_stream_none_reader",String.format("%s/on_stream_none_reader", hookPrex)) | ||
| 122 | + .add("hook.on_stream_not_found",String.format("%s/on_stream_not_found", hookPrex)) | ||
| 123 | + .add("hook.timeoutSec","20") | ||
| 124 | + .build(); | ||
| 125 | + | ||
| 126 | + Request request = new Request.Builder() | ||
| 127 | + .post(body) | ||
| 128 | + .url(url) | ||
| 129 | + .build(); | ||
| 130 | + client.newCall(request).enqueue(new Callback() { | ||
| 131 | + @Override | ||
| 132 | + public void onFailure(Call call, IOException e) { | ||
| 133 | + logger.error("saveZLMConfig ",e); | ||
| 134 | + } | ||
| 135 | + @Override | ||
| 136 | + public void onResponse(Call call, Response response) throws IOException { | ||
| 137 | + if (response.isSuccessful()) { | ||
| 138 | + String responseStr = response.body().string(); | ||
| 139 | + if (responseStr != null) { | ||
| 140 | + JSONObject responseJSON = JSON.parseObject(responseStr); | ||
| 141 | + if (responseJSON.getInteger("code") == 0) { | ||
| 142 | + logger.info("设置zlm成功"); | ||
| 143 | + }else { | ||
| 144 | + logger.info("设置zlm失败: " + responseJSON.getString("msg")); | ||
| 145 | + } | ||
| 146 | + } | ||
| 147 | + } | ||
| 148 | + | ||
| 149 | + } | ||
| 150 | + }); | ||
| 151 | + } | ||
| 152 | +} |
src/main/java/com/genersoft/iot/vmp/storager/redis/VideoManagerRedisStoragerImpl.java
| @@ -344,6 +344,7 @@ public class VideoManagerRedisStoragerImpl implements IVideoManagerStorager { | @@ -344,6 +344,7 @@ public class VideoManagerRedisStoragerImpl implements IVideoManagerStorager { | ||
| 344 | */ | 344 | */ |
| 345 | @Override | 345 | @Override |
| 346 | public boolean stopPlay(StreamInfo streamInfo) { | 346 | public boolean stopPlay(StreamInfo streamInfo) { |
| 347 | + if (streamInfo == null) return false; | ||
| 347 | return redis.del(String.format("%S_%s_%s_%s", VideoManagerConstants.PLAYER_PREFIX, | 348 | return redis.del(String.format("%S_%s_%s_%s", VideoManagerConstants.PLAYER_PREFIX, |
| 348 | streamInfo.getSsrc(), | 349 | streamInfo.getSsrc(), |
| 349 | streamInfo.getDeviceID(), | 350 | streamInfo.getDeviceID(), |
src/main/java/com/genersoft/iot/vmp/vmanager/device/DeviceController.java
| @@ -144,4 +144,10 @@ public class DeviceController { | @@ -144,4 +144,10 @@ public class DeviceController { | ||
| 144 | PageResult pageResult = storager.querySubChannels(deviceId, channelId, query, channelType, online, page, count); | 144 | PageResult pageResult = storager.querySubChannels(deviceId, channelId, query, channelType, online, page, count); |
| 145 | return new ResponseEntity<>(pageResult,HttpStatus.OK); | 145 | return new ResponseEntity<>(pageResult,HttpStatus.OK); |
| 146 | } | 146 | } |
| 147 | + | ||
| 148 | + @PostMapping("channel/update/{deviceId}") | ||
| 149 | + public ResponseEntity<PageResult> updateChannel(@PathVariable String deviceId,DeviceChannel channel){ | ||
| 150 | + storager.updateChannel(deviceId, channel); | ||
| 151 | + return new ResponseEntity<>(null,HttpStatus.OK); | ||
| 152 | + } | ||
| 147 | } | 153 | } |
src/main/java/com/genersoft/iot/vmp/vmanager/play/PlayController.java
| @@ -67,6 +67,7 @@ public class PlayController { | @@ -67,6 +67,7 @@ public class PlayController { | ||
| 67 | 67 | ||
| 68 | cmder.streamByeCmd(ssrc); | 68 | cmder.streamByeCmd(ssrc); |
| 69 | StreamInfo streamInfo = storager.queryPlayBySSRC(ssrc); | 69 | StreamInfo streamInfo = storager.queryPlayBySSRC(ssrc); |
| 70 | + if (streamInfo == null) return new ResponseEntity<String>(HttpStatus.PAYMENT_REQUIRED); | ||
| 70 | storager.stopPlay(streamInfo); | 71 | storager.stopPlay(streamInfo); |
| 71 | if (logger.isDebugEnabled()) { | 72 | if (logger.isDebugEnabled()) { |
| 72 | logger.debug(String.format("设备预览停止API调用,ssrc:%s", ssrc)); | 73 | logger.debug(String.format("设备预览停止API调用,ssrc:%s", ssrc)); |
src/main/resources/application.yml
| @@ -25,7 +25,6 @@ spring: | @@ -25,7 +25,6 @@ spring: | ||
| 25 | server: | 25 | server: |
| 26 | port: 18080 | 26 | port: 18080 |
| 27 | sip: | 27 | sip: |
| 28 | -# ip: 10.200.64.63 | ||
| 29 | ip: 192.168.1.20 | 28 | ip: 192.168.1.20 |
| 30 | port: 5060 | 29 | port: 5060 |
| 31 | # 根据国标6.1.2中规定,domain宜采用ID统一编码的前十位编码。国标附录D中定义前8位为中心编码(由省级、市级、区级、基层编号组成,参照GB/T 2260-2007) | 30 | # 根据国标6.1.2中规定,domain宜采用ID统一编码的前十位编码。国标附录D中定义前8位为中心编码(由省级、市级、区级、基层编号组成,参照GB/T 2260-2007) |
| @@ -38,4 +37,10 @@ sip: | @@ -38,4 +37,10 @@ sip: | ||
| 38 | 37 | ||
| 39 | auth: #32位小写md5加密(默认密码为admin) | 38 | auth: #32位小写md5加密(默认密码为admin) |
| 40 | username: admin | 39 | username: admin |
| 41 | - password: 21232f297a57a5a743894a0e4a801fc3 | ||
| 42 | \ No newline at end of file | 40 | \ No newline at end of file |
| 41 | + password: 21232f297a57a5a743894a0e4a801fc3 | ||
| 42 | + | ||
| 43 | +media: #zlm服务器的ip与http端口, 重点: 这是http端口 | ||
| 44 | + ip: 192.168.1.20 | ||
| 45 | + port: 9080 | ||
| 46 | + secret: 035c73f7-bb6b-4889-a715-d9eb2d1925cc | ||
| 47 | + |
web_src/src/components/channelList.vue
| @@ -31,10 +31,19 @@ | @@ -31,10 +31,19 @@ | ||
| 31 | <el-table ref="channelListTable" :data="deviceChannelList" :height="winHeight" border style="width: 100%"> | 31 | <el-table ref="channelListTable" :data="deviceChannelList" :height="winHeight" border style="width: 100%"> |
| 32 | <el-table-column prop="channelId" label="通道编号" width="210"> | 32 | <el-table-column prop="channelId" label="通道编号" width="210"> |
| 33 | </el-table-column> | 33 | </el-table-column> |
| 34 | - <el-table-column prop="name" label="通道名称" width="500"> | 34 | + <el-table-column prop="name" label="通道名称"> |
| 35 | </el-table-column> | 35 | </el-table-column> |
| 36 | <el-table-column prop="subCount" label="子节点数"> | 36 | <el-table-column prop="subCount" label="子节点数"> |
| 37 | </el-table-column> | 37 | </el-table-column> |
| 38 | + <el-table-column label="开启音频" align="center"> | ||
| 39 | + <template slot-scope="scope"> | ||
| 40 | + <el-switch | ||
| 41 | + @change="updateChannel(scope.row)" | ||
| 42 | + v-model="scope.row.hasAudio" | ||
| 43 | + active-color="#409EFF"> | ||
| 44 | + </el-switch> | ||
| 45 | + </template> | ||
| 46 | + </el-table-column> | ||
| 38 | <el-table-column label="状态" width="180" align="center"> | 47 | <el-table-column label="状态" width="180" align="center"> |
| 39 | <template slot-scope="scope"> | 48 | <template slot-scope="scope"> |
| 40 | <div slot="reference" class="name-wrapper"> | 49 | <div slot="reference" class="name-wrapper"> |
| @@ -193,6 +202,7 @@ | @@ -193,6 +202,7 @@ | ||
| 193 | }, | 202 | }, |
| 194 | //通知设备上传媒体流 | 203 | //通知设备上传媒体流 |
| 195 | sendDevicePush: function(itemData) { | 204 | sendDevicePush: function(itemData) { |
| 205 | + console.log(itemData) | ||
| 196 | let deviceId = this.deviceId; | 206 | let deviceId = this.deviceId; |
| 197 | this.isLoging = true; | 207 | this.isLoging = true; |
| 198 | let channelId = itemData.channelId; | 208 | let channelId = itemData.channelId; |
| @@ -204,7 +214,7 @@ | @@ -204,7 +214,7 @@ | ||
| 204 | }).then(function(res) { | 214 | }).then(function(res) { |
| 205 | let ssrc = res.data.ssrc; | 215 | let ssrc = res.data.ssrc; |
| 206 | that.isLoging = false | 216 | that.isLoging = false |
| 207 | - that.$refs.devicePlayer.play(res.data,deviceId,channelId); | 217 | + that.$refs.devicePlayer.play(res.data,deviceId,channelId,itemData.hasAudio); |
| 208 | }).catch(function(e) { | 218 | }).catch(function(e) { |
| 209 | }); | 219 | }); |
| 210 | }, | 220 | }, |
| @@ -256,6 +266,16 @@ | @@ -256,6 +266,16 @@ | ||
| 256 | this.currentPage = 1; | 266 | this.currentPage = 1; |
| 257 | this.total = 0; | 267 | this.total = 0; |
| 258 | this.initData(); | 268 | this.initData(); |
| 269 | + }, | ||
| 270 | + updateChannel: function(row) { | ||
| 271 | + console.log(row) | ||
| 272 | + this.$axios({ | ||
| 273 | + method: 'post', | ||
| 274 | + url: `/api/channel/update/${this.deviceId}`, | ||
| 275 | + params: row | ||
| 276 | + }).then(function(res) { | ||
| 277 | + console.log(JSON.stringify(res)); | ||
| 278 | + }); | ||
| 259 | } | 279 | } |
| 260 | 280 | ||
| 261 | } | 281 | } |
web_src/src/components/gb28181/devicePlayer.vue
| 1 | <template> | 1 | <template> |
| 2 | <div id="devicePlayer"> | 2 | <div id="devicePlayer"> |
| 3 | <el-dialog title="视频播放" top="0" :visible.sync="showVideoDialog" :destroy-on-close="true" @close="stop()"> | 3 | <el-dialog title="视频播放" top="0" :visible.sync="showVideoDialog" :destroy-on-close="true" @close="stop()"> |
| 4 | - <LivePlayer v-if="showVideoDialog" ref="videoPlayer" :videoUrl="videoUrl" :error="videoError" fluent autoplay live stretch></LivePlayer> | 4 | + <LivePlayer v-if="showVideoDialog" ref="videoPlayer" :videoUrl="videoUrl" :error="videoError" :hasaudio="hasaudio" fluent autoplay live ></LivePlayer> |
| 5 | <div id="shared" style="text-align: right; margin-top: 1rem;"> | 5 | <div id="shared" style="text-align: right; margin-top: 1rem;"> |
| 6 | <el-tabs v-model="tabActiveName"> | 6 | <el-tabs v-model="tabActiveName"> |
| 7 | <el-tab-pane label="媒体流信息" name="media"> | 7 | <el-tab-pane label="媒体流信息" name="media"> |
| @@ -114,17 +114,22 @@ | @@ -114,17 +114,22 @@ | ||
| 114 | ssrc: '', | 114 | ssrc: '', |
| 115 | deviceId: '', | 115 | deviceId: '', |
| 116 | channelId: '', | 116 | channelId: '', |
| 117 | - tabActiveName: 'media' | 117 | + tabActiveName: 'media', |
| 118 | + hasaudio: false | ||
| 118 | 119 | ||
| 119 | }; | 120 | }; |
| 120 | }, | 121 | }, |
| 121 | methods: { | 122 | methods: { |
| 122 | 123 | ||
| 123 | - play: function(streamInfo, deviceId, channelId) { | 124 | + play: function(streamInfo, deviceId, channelId, hasAudio) { |
| 125 | + console.log(hasAudio); | ||
| 126 | + this.hasaudio = hasAudio; | ||
| 124 | this.ssrc = streamInfo.ssrc; | 127 | this.ssrc = streamInfo.ssrc; |
| 125 | this.deviceId = deviceId; | 128 | this.deviceId = deviceId; |
| 126 | this.channelId = channelId; | 129 | this.channelId = channelId; |
| 127 | - this.videoUrl = streamInfo.flv + "?" + new Date().getTime(); | 130 | + // this.$refs.videoPlayer.hasaudio = hasAudio; |
| 131 | + // this.videoUrl = streamInfo.flv + "?" + new Date().getTime(); | ||
| 132 | + this.videoUrl = streamInfo.ws_flv; | ||
| 128 | this.showVideoDialog = true; | 133 | this.showVideoDialog = true; |
| 129 | console.log(this.ssrc); | 134 | console.log(this.ssrc); |
| 130 | }, | 135 | }, |