Commit cfe9c762d680569136d0246ab61c79cd7e4eba50
1 parent
03d6ad28
修复前端播放
Showing
6 changed files
with
44 additions
and
44 deletions
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java
| ... | ... | @@ -41,7 +41,9 @@ import javax.sip.header.*; |
| 41 | 41 | import javax.sip.message.Request; |
| 42 | 42 | import java.lang.reflect.Field; |
| 43 | 43 | import java.text.ParseException; |
| 44 | +import java.util.ArrayList; | |
| 44 | 45 | import java.util.HashSet; |
| 46 | +import java.util.List; | |
| 45 | 47 | |
| 46 | 48 | /** |
| 47 | 49 | * @description:设备能力接口,用于定义设备的控制、查询能力 |
| ... | ... | @@ -685,15 +687,7 @@ public class SIPCommander implements ISIPCommander { |
| 685 | 687 | // 增加Contact header |
| 686 | 688 | Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getIp()+":"+sipConfig.getPort())); |
| 687 | 689 | byeRequest.addHeader(sipFactory.createHeaderFactory().createContactHeader(concatAddress)); |
| 688 | - List<String> agentParam = new ArrayList<>(); | |
| 689 | - agentParam.add("wvp-pro"); | |
| 690 | - // TODO 添加版本信息以及日期 | |
| 691 | - UserAgentHeader userAgentHeader = null; | |
| 692 | - try { | |
| 693 | - userAgentHeader = sipFactory.createHeaderFactory().createUserAgentHeader(agentParam); | |
| 694 | - } catch (ParseException e) { | |
| 695 | - throw new RuntimeException(e); | |
| 696 | - } | |
| 690 | + UserAgentHeader userAgentHeader = HeaderUtils.createUserAgentHeader(sipFactory); | |
| 697 | 691 | byeRequest.addHeader(userAgentHeader); |
| 698 | 692 | ClientTransaction clientTransaction = null; |
| 699 | 693 | if("TCP".equals(protocol)) { | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/SIPRequestProcessorParent.java
| ... | ... | @@ -63,12 +63,9 @@ public abstract class SIPRequestProcessorParent { |
| 63 | 63 | System.out.println(serverTransaction.getState().toString()); |
| 64 | 64 | } |
| 65 | 65 | // 判断TCP还是UDP |
| 66 | - boolean isTcp = false; | |
| 67 | 66 | ViaHeader reqViaHeader = (ViaHeader) request.getHeader(ViaHeader.NAME); |
| 68 | 67 | String transport = reqViaHeader.getTransport(); |
| 69 | - if (transport.equals("TCP")) { | |
| 70 | - isTcp = true; | |
| 71 | - } | |
| 68 | + boolean isTcp = "TCP".equals(transport); | |
| 72 | 69 | |
| 73 | 70 | if (serverTransaction == null) { |
| 74 | 71 | try { | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java
| ... | ... | @@ -126,7 +126,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements |
| 126 | 126 | private DeferredResultHolder resultHolder; |
| 127 | 127 | |
| 128 | 128 | @Autowired |
| 129 | - private ZLMHttpHookSubscribe subscribe; | |
| 129 | + private ZlmHttpHookSubscribe subscribe; | |
| 130 | 130 | |
| 131 | 131 | @Autowired |
| 132 | 132 | private SipConfig config; |
| ... | ... | @@ -776,13 +776,13 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements |
| 776 | 776 | } |
| 777 | 777 | } |
| 778 | 778 | |
| 779 | - public void inviteFromDeviceHandle(RequestEvent evt, String requesterId, String channelId1) throws InvalidArgumentException, ParseException, SipException, SdpException { | |
| 779 | + public void inviteFromDeviceHandle(RequestEvent evt, String requesterId, String channelId) throws InvalidArgumentException, ParseException, SipException, SdpException { | |
| 780 | 780 | |
| 781 | 781 | // 非上级平台请求,查询是否设备请求(通常为接收语音广播的设备) |
| 782 | 782 | Device device = redisCatchStorage.getDevice(requesterId); |
| 783 | - AudioBroadcastCatch audioBroadcastCatch = audioBroadcastManager.get(requesterId, channelId1); | |
| 783 | + AudioBroadcastCatch audioBroadcastCatch = audioBroadcastManager.get(requesterId, channelId); | |
| 784 | 784 | if (audioBroadcastCatch == null) { |
| 785 | - logger.warn("来自设备的Invite请求非语音广播,已忽略"); | |
| 785 | + logger.warn("来自设备的Invite请求非语音广播,已忽略,requesterId: {}/{}", requesterId, channelId); | |
| 786 | 786 | responseAck(evt, Response.FORBIDDEN); |
| 787 | 787 | return; |
| 788 | 788 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java
| ... | ... | @@ -108,7 +108,7 @@ public class MediaServiceImpl implements IMediaService { |
| 108 | 108 | streamInfoResult.setWs_fmp4(String.format("ws://%s:%s/%s/%s.live.mp4%s", addr, mediaInfo.getHttpPort(), app, stream, callIdParam)); |
| 109 | 109 | streamInfoResult.setTs(String.format("http://%s:%s/%s/%s.live.ts%s", addr, mediaInfo.getHttpPort(), app, stream, callIdParam)); |
| 110 | 110 | streamInfoResult.setWs_ts(String.format("ws://%s:%s/%s/%s.live.ts%s", addr, mediaInfo.getHttpPort(), app, stream, callIdParam)); |
| 111 | - streamInfoResult.setRtc(String.format("http://%s:%s/index/api/webrtc?app=%s&stream=%s&type=play%s", mediaInfo.getStreamIp(), mediaInfo.getHttpPort(), app, stream, ObjectUtils.isEmpty(callId)?"":"&callId=" + callId)); | |
| 111 | + streamInfoResult.setRtc(String.format("http://%s:%s/index/api/webrtc?app=%s&stream=%s&type=%s%s", mediaInfo.getStreamIp(), mediaInfo.getHttpPort(), app, stream, isPlay?"play":"push", ObjectUtils.isEmpty(callId)?"":"&callId=" + callId)); | |
| 112 | 112 | if (mediaInfo.getHttpSSlPort() != 0) { |
| 113 | 113 | streamInfoResult.setHttps_flv(String.format("https://%s:%s/%s/%s.live.flv%s", addr, mediaInfo.getHttpSSlPort(), app, stream, callIdParam)); |
| 114 | 114 | streamInfoResult.setWss_flv(String.format("wss://%s:%s/%s/%s.live.flv%s", addr, mediaInfo.getHttpSSlPort(), app, stream, callIdParam)); |
| ... | ... | @@ -119,7 +119,7 @@ public class MediaServiceImpl implements IMediaService { |
| 119 | 119 | streamInfoResult.setHttps_ts(String.format("https://%s:%s/%s/%s.live.ts%s", addr, mediaInfo.getHttpSSlPort(), app, stream, callIdParam)); |
| 120 | 120 | streamInfoResult.setWss_ts(String.format("wss://%s:%s/%s/%s.live.ts%s", addr, mediaInfo.getHttpSSlPort(), app, stream, callIdParam)); |
| 121 | 121 | streamInfoResult.setWss_ts(String.format("wss://%s:%s/%s/%s.live.ts%s", addr, mediaInfo.getHttpSSlPort(), app, stream, callIdParam)); |
| 122 | - streamInfoResult.setRtcs(String.format("https://%s:%s/index/api/webrtc?app=%s&stream=%s&type=play%s", mediaInfo.getStreamIp(), mediaInfo.getHttpSSlPort(), app, stream, ObjectUtils.isEmpty(callId)?"":"&callId=" + callId)); | |
| 122 | + streamInfoResult.setRtcs(String.format("https://%s:%s/index/api/webrtc?app=%s&stream=%s&type=%s%s", mediaInfo.getStreamIp(), mediaInfo.getHttpSSlPort(), app, stream, isPlay?"play":"push", ObjectUtils.isEmpty(callId)?"":"&callId=" + callId)); | |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | streamInfoResult.setTracks(tracks); | ... | ... |
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java
| ... | ... | @@ -266,12 +266,11 @@ public class PlayController { |
| 266 | 266 | @Parameter(name = "channelId", description = "通道Id", required = true) |
| 267 | 267 | @GetMapping("/broadcast/stop/{deviceId}/{channelId}") |
| 268 | 268 | @PostMapping("/broadcast/stop/{deviceId}/{channelId}") |
| 269 | - public WVPResult<String> stopBroadcastA(@PathVariable String deviceId, @PathVariable String channelId) { | |
| 269 | + public void stopBroadcastA(@PathVariable String deviceId, @PathVariable String channelId) { | |
| 270 | 270 | if (logger.isDebugEnabled()) { |
| 271 | 271 | logger.debug("停止语音广播API调用"); |
| 272 | 272 | } |
| 273 | 273 | playService.stopAudioBroadcast(deviceId, channelId); |
| 274 | - return new WVPResult<>(0, "success", null); | |
| 275 | 274 | } |
| 276 | 275 | |
| 277 | 276 | @Operation(summary = "获取所有的ssrc") | ... | ... |
web_src/src/components/dialog/devicePlayer.vue
| 1 | 1 | <template> |
| 2 | 2 | <div id="devicePlayer" v-loading="isLoging"> |
| 3 | 3 | |
| 4 | - <el-dialog title="视频播放" top="0" :close-on-click-modal="false" :visible.sync="showVideoDialog" @close="close()"> | |
| 4 | + <el-dialog title="视频播放" top="0" :close-on-click-modal="false" :visible.sync="showVideoDialog" :destroy-on-close="true" @close="close()"> | |
| 5 | 5 | <!-- <LivePlayer v-if="showVideoDialog" ref="videoPlayer" :videoUrl="videoUrl" :error="videoError" :message="videoError" :hasaudio="hasaudio" fluent autoplay live></LivePlayer> --> |
| 6 | 6 | <div style="width: 100%; height: 100%"> |
| 7 | 7 | <el-tabs type="card" :stretch="true" v-model="activePlayer" @tab-click="changePlayer" v-if="Object.keys(this.player).length > 1"> |
| ... | ... | @@ -319,7 +319,9 @@ export default { |
| 319 | 319 | } |
| 320 | 320 | }, |
| 321 | 321 | created() { |
| 322 | + console.log("created") | |
| 322 | 323 | console.log(this.player) |
| 324 | + this.broadcastStatus = -1; | |
| 323 | 325 | if (Object.keys(this.player).length === 1) { |
| 324 | 326 | this.activePlayer = Object.keys(this.player)[0] |
| 325 | 327 | } |
| ... | ... | @@ -332,7 +334,7 @@ export default { |
| 332 | 334 | // 如何你只是用一种播放器,直接注释掉不用的部分即可 |
| 333 | 335 | player: { |
| 334 | 336 | jessibuca : ["ws_flv", "wss_flv"], |
| 335 | - webRTC: ["rtc", "rtc"], | |
| 337 | + webRTC: ["rtc", "rtcs"], | |
| 336 | 338 | }, |
| 337 | 339 | videoHistory: { |
| 338 | 340 | date: '', |
| ... | ... | @@ -540,9 +542,7 @@ export default { |
| 540 | 542 | this.stopPlayRecord(); |
| 541 | 543 | } |
| 542 | 544 | this.recordPlay = '' |
| 543 | - if (this.broadcastStatus === 1) { | |
| 544 | - this.stopBroadcast() | |
| 545 | - } | |
| 545 | + this.stopBroadcast() | |
| 546 | 546 | }, |
| 547 | 547 | |
| 548 | 548 | copySharedInfo: function (data) { |
| ... | ... | @@ -857,7 +857,12 @@ export default { |
| 857 | 857 | }).then( (res)=> { |
| 858 | 858 | if (res.data.code == 0) { |
| 859 | 859 | let streamInfo = res.data.data.streamInfo; |
| 860 | - this.startBroadcast(streamInfo.rtc) | |
| 860 | + if (document.location.protocol.includes("https")) { | |
| 861 | + this.startBroadcast(streamInfo.rtcs) | |
| 862 | + }else { | |
| 863 | + this.startBroadcast(streamInfo.rtc) | |
| 864 | + } | |
| 865 | + | |
| 861 | 866 | }else { |
| 862 | 867 | this.$message({ |
| 863 | 868 | showClose: true, |
| ... | ... | @@ -958,23 +963,28 @@ export default { |
| 958 | 963 | |
| 959 | 964 | }, |
| 960 | 965 | stopBroadcast(){ |
| 961 | - this.broadcastStatus = -2; | |
| 962 | - this.broadcastRtc = null; | |
| 963 | - this.$axios({ | |
| 964 | - method: 'get', | |
| 965 | - url: '/api/play/broadcast/stop/' + this.deviceId + '/' + this.channelId | |
| 966 | - }).then( (res)=> { | |
| 967 | - if (res.data.code == 0) { | |
| 968 | - // this.broadcastStatus = -1; | |
| 969 | - // this.broadcastRtc.close() | |
| 970 | - }else { | |
| 971 | - this.$message({ | |
| 972 | - showClose: true, | |
| 973 | - message: res.data.msg, | |
| 974 | - type: "error", | |
| 975 | - }); | |
| 976 | - } | |
| 977 | - }); | |
| 966 | + if (this.broadcastStatus === -1) { | |
| 967 | + this.broadcastStatus = 1; | |
| 968 | + }else { | |
| 969 | + this.broadcastStatus = -2; | |
| 970 | + this.broadcastRtc = null; | |
| 971 | + this.$axios({ | |
| 972 | + method: 'get', | |
| 973 | + url: '/api/play/broadcast/stop/' + this.deviceId + '/' + this.channelId | |
| 974 | + }).then( (res)=> { | |
| 975 | + if (res.data.code == 0) { | |
| 976 | + // this.broadcastStatus = -1; | |
| 977 | + // this.broadcastRtc.close() | |
| 978 | + }else { | |
| 979 | + this.$message({ | |
| 980 | + showClose: true, | |
| 981 | + message: res.data.msg, | |
| 982 | + type: "error", | |
| 983 | + }); | |
| 984 | + } | |
| 985 | + }); | |
| 986 | + } | |
| 987 | + | |
| 978 | 988 | |
| 979 | 989 | } |
| 980 | 990 | } | ... | ... |