Commit 7609d7836c52a7619a51fa8b707502f027c2e1f0
1 parent
e78c402a
优化对讲逻辑
Showing
4 changed files
with
16 additions
and
10 deletions
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java
| @@ -830,7 +830,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements | @@ -830,7 +830,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements | ||
| 830 | subscribeKey.put("app", app); | 830 | subscribeKey.put("app", app); |
| 831 | subscribeKey.put("stream", stream); | 831 | subscribeKey.put("stream", stream); |
| 832 | subscribeKey.put("regist", true); | 832 | subscribeKey.put("regist", true); |
| 833 | - subscribeKey.put("schema", "rtmp"); | 833 | + subscribeKey.put("schema", "rtsp"); |
| 834 | subscribeKey.put("mediaServerId", mediaServerItem.getId()); | 834 | subscribeKey.put("mediaServerId", mediaServerItem.getId()); |
| 835 | String finalSsrc = ssrc; | 835 | String finalSsrc = ssrc; |
| 836 | // 流已经存在时直接推流 | 836 | // 流已经存在时直接推流 |
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
| @@ -339,9 +339,7 @@ public class ZLMHttpHookListener { | @@ -339,9 +339,7 @@ public class ZLMHttpHookListener { | ||
| 339 | @PostMapping(value = "/on_stream_changed", produces = "application/json;charset=UTF-8") | 339 | @PostMapping(value = "/on_stream_changed", produces = "application/json;charset=UTF-8") |
| 340 | public ResponseEntity<String> onStreamChanged(@RequestBody MediaItem item){ | 340 | public ResponseEntity<String> onStreamChanged(@RequestBody MediaItem item){ |
| 341 | 341 | ||
| 342 | - if (logger.isDebugEnabled()) { | ||
| 343 | - logger.debug("[ ZLM HOOK ]on_stream_changed API调用,参数:" + JSONObject.toJSONString(item)); | ||
| 344 | - } | 342 | + logger.info("[ ZLM HOOK ]on_stream_changed API调用,参数:" + JSONObject.toJSONString(item)); |
| 345 | String mediaServerId = item.getMediaServerId(); | 343 | String mediaServerId = item.getMediaServerId(); |
| 346 | JSONObject json = (JSONObject) JSON.toJSON(item); | 344 | JSONObject json = (JSONObject) JSON.toJSON(item); |
| 347 | ZLMHttpHookSubscribe.Event subscribe = this.subscribe.getSubscribe(ZLMHttpHookSubscribe.HookType.on_stream_changed, json); | 345 | ZLMHttpHookSubscribe.Event subscribe = this.subscribe.getSubscribe(ZLMHttpHookSubscribe.HookType.on_stream_changed, json); |
src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java
| @@ -689,6 +689,9 @@ public class PlayServiceImpl implements IPlayService { | @@ -689,6 +689,9 @@ public class PlayServiceImpl implements IPlayService { | ||
| 689 | logger.warn("语音广播已经开启: {}", channelId); | 689 | logger.warn("语音广播已经开启: {}", channelId); |
| 690 | event.call("语音广播已经开启"); | 690 | event.call("语音广播已经开启"); |
| 691 | return; | 691 | return; |
| 692 | + }else { | ||
| 693 | + audioBroadcastManager.del(deviceChannel.getDeviceId(),channelId); | ||
| 694 | + redisCatchStorage.deleteSendRTPServer(device.getDeviceId(), channelId, sendRtpItem.getCallId(), sendRtpItem.getStreamId()); | ||
| 692 | } | 695 | } |
| 693 | } | 696 | } |
| 694 | } | 697 | } |
| @@ -710,7 +713,7 @@ public class PlayServiceImpl implements IPlayService { | @@ -710,7 +713,7 @@ public class PlayServiceImpl implements IPlayService { | ||
| 710 | public void stopAudioBroadcast(String deviceId, String channelId){ | 713 | public void stopAudioBroadcast(String deviceId, String channelId){ |
| 711 | AudioBroadcastCatch audioBroadcastCatch = audioBroadcastManager.get(deviceId, channelId); | 714 | AudioBroadcastCatch audioBroadcastCatch = audioBroadcastManager.get(deviceId, channelId); |
| 712 | if (audioBroadcastCatch != null) { | 715 | if (audioBroadcastCatch != null) { |
| 713 | - audioBroadcastManager.del(deviceId, audioBroadcastCatch.getChannelId()); | 716 | + |
| 714 | try { | 717 | try { |
| 715 | SendRtpItem sendRtpItem = redisCatchStorage.querySendRTPServer(deviceId, audioBroadcastCatch.getChannelId(), null, null); | 718 | SendRtpItem sendRtpItem = redisCatchStorage.querySendRTPServer(deviceId, audioBroadcastCatch.getChannelId(), null, null); |
| 716 | if (sendRtpItem != null) { | 719 | if (sendRtpItem != null) { |
| @@ -722,11 +725,12 @@ public class PlayServiceImpl implements IPlayService { | @@ -722,11 +725,12 @@ public class PlayServiceImpl implements IPlayService { | ||
| 722 | param.put("stream", sendRtpItem.getStreamId()); | 725 | param.put("stream", sendRtpItem.getStreamId()); |
| 723 | zlmresTfulUtils.stopSendRtp(mediaInfo, param); | 726 | zlmresTfulUtils.stopSendRtp(mediaInfo, param); |
| 724 | // 立刻结束设备的推流,等待自行结束太慢 | 727 | // 立刻结束设备的推流,等待自行结束太慢 |
| 725 | -// zlmresTfulUtils.closeStreams(mediaInfo, sendRtpItem.getApp(), sendRtpItem.getStreamId()); | 728 | + zlmresTfulUtils.closeStreams(mediaInfo, sendRtpItem.getApp(), sendRtpItem.getStreamId()); |
| 726 | } | 729 | } |
| 727 | if (audioBroadcastCatch.getStatus() == AudioBroadcastCatchStatus.Ok) { | 730 | if (audioBroadcastCatch.getStatus() == AudioBroadcastCatchStatus.Ok) { |
| 728 | cmder.streamByeCmd(audioBroadcastCatch.getDialog(), audioBroadcastCatch.getRequest(), null); | 731 | cmder.streamByeCmd(audioBroadcastCatch.getDialog(), audioBroadcastCatch.getRequest(), null); |
| 729 | } | 732 | } |
| 733 | + audioBroadcastManager.del(deviceId, channelId); | ||
| 730 | 734 | ||
| 731 | } catch (SipException e) { | 735 | } catch (SipException e) { |
| 732 | throw new RuntimeException(e); | 736 | throw new RuntimeException(e); |
web_src/src/components/dialog/devicePlayer.vue
| @@ -278,8 +278,9 @@ | @@ -278,8 +278,9 @@ | ||
| 278 | </el-tab-pane> | 278 | </el-tab-pane> |
| 279 | <el-tab-pane label="语音对讲" name="broadcast" > | 279 | <el-tab-pane label="语音对讲" name="broadcast" > |
| 280 | <div class="trank" style="text-align: center;"> | 280 | <div class="trank" style="text-align: center;"> |
| 281 | - <el-button @click="broadcastStatusClick()" :type="getBroadcastStatus()" circle icon="el-icon-microphone" style="font-size: 32px; padding: 24px;margin-top: 24px;"/> | 281 | + <el-button @click="broadcastStatusClick()" :type="getBroadcastStatus()" :disabled="broadcastStatus === -2" circle icon="el-icon-microphone" style="font-size: 32px; padding: 24px;margin-top: 24px;"/> |
| 282 | <p> | 282 | <p> |
| 283 | + <span v-if="broadcastStatus === -2">正在释放资源</span> | ||
| 283 | <span v-if="broadcastStatus === -1">点击开始对讲</span> | 284 | <span v-if="broadcastStatus === -1">点击开始对讲</span> |
| 284 | <span v-if="broadcastStatus === 0">等待接通中...</span> | 285 | <span v-if="broadcastStatus === 0">等待接通中...</span> |
| 285 | <span v-if="broadcastStatus === 1">请说话</span> | 286 | <span v-if="broadcastStatus === 1">请说话</span> |
| @@ -371,7 +372,7 @@ export default { | @@ -371,7 +372,7 @@ export default { | ||
| 371 | showTimeText: "00:00:00", | 372 | showTimeText: "00:00:00", |
| 372 | streamInfo: null, | 373 | streamInfo: null, |
| 373 | broadcastRtc: null, | 374 | broadcastRtc: null, |
| 374 | - broadcastStatus: -1, // -1 默认状态 0 等待接通 1 接通成功 | 375 | + broadcastStatus: -1, // -2 正在释放资源 -1 默认状态 0 等待接通 1 接通成功 |
| 375 | }; | 376 | }; |
| 376 | }, | 377 | }, |
| 377 | methods: { | 378 | methods: { |
| @@ -821,6 +822,9 @@ export default { | @@ -821,6 +822,9 @@ export default { | ||
| 821 | }); | 822 | }); |
| 822 | }, | 823 | }, |
| 823 | getBroadcastStatus() { | 824 | getBroadcastStatus() { |
| 825 | + if (this.broadcastStatus == -2) { | ||
| 826 | + return "primary" | ||
| 827 | + } | ||
| 824 | if (this.broadcastStatus == -1) { | 828 | if (this.broadcastStatus == -1) { |
| 825 | return "primary" | 829 | return "primary" |
| 826 | } | 830 | } |
| @@ -835,6 +839,7 @@ export default { | @@ -835,6 +839,7 @@ export default { | ||
| 835 | broadcastStatusClick() { | 839 | broadcastStatusClick() { |
| 836 | if (this.broadcastStatus == -1) { | 840 | if (this.broadcastStatus == -1) { |
| 837 | // 默认状态, 开始 | 841 | // 默认状态, 开始 |
| 842 | + this.broadcastStatus = 0 | ||
| 838 | // 发起语音对讲 | 843 | // 发起语音对讲 |
| 839 | this.$axios({ | 844 | this.$axios({ |
| 840 | method: 'get', | 845 | method: 'get', |
| @@ -924,7 +929,7 @@ export default { | @@ -924,7 +929,7 @@ export default { | ||
| 924 | }); | 929 | }); |
| 925 | }, | 930 | }, |
| 926 | stopBroadcast(){ | 931 | stopBroadcast(){ |
| 927 | - this.broadcastRtc.close() | 932 | + this.broadcastStatus = -2; |
| 928 | this.broadcastRtc = null; | 933 | this.broadcastRtc = null; |
| 929 | this.$axios({ | 934 | this.$axios({ |
| 930 | method: 'get', | 935 | method: 'get', |
| @@ -932,7 +937,6 @@ export default { | @@ -932,7 +937,6 @@ export default { | ||
| 932 | }).then( (res)=> { | 937 | }).then( (res)=> { |
| 933 | if (res.data.code == 0) { | 938 | if (res.data.code == 0) { |
| 934 | // this.broadcastStatus = -1; | 939 | // this.broadcastStatus = -1; |
| 935 | - | ||
| 936 | }else { | 940 | }else { |
| 937 | this.$message({ | 941 | this.$message({ |
| 938 | showClose: true, | 942 | showClose: true, |