Commit 7609d7836c52a7619a51fa8b707502f027c2e1f0

Authored by 648540858
1 parent e78c402a

优化对讲逻辑

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 830 subscribeKey.put("app", app);
831 831 subscribeKey.put("stream", stream);
832 832 subscribeKey.put("regist", true);
833   - subscribeKey.put("schema", "rtmp");
  833 + subscribeKey.put("schema", "rtsp");
834 834 subscribeKey.put("mediaServerId", mediaServerItem.getId());
835 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 339 @PostMapping(value = "/on_stream_changed", produces = "application/json;charset=UTF-8")
340 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 343 String mediaServerId = item.getMediaServerId();
346 344 JSONObject json = (JSONObject) JSON.toJSON(item);
347 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 689 logger.warn("语音广播已经开启: {}", channelId);
690 690 event.call("语音广播已经开启");
691 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 713 public void stopAudioBroadcast(String deviceId, String channelId){
711 714 AudioBroadcastCatch audioBroadcastCatch = audioBroadcastManager.get(deviceId, channelId);
712 715 if (audioBroadcastCatch != null) {
713   - audioBroadcastManager.del(deviceId, audioBroadcastCatch.getChannelId());
  716 +
714 717 try {
715 718 SendRtpItem sendRtpItem = redisCatchStorage.querySendRTPServer(deviceId, audioBroadcastCatch.getChannelId(), null, null);
716 719 if (sendRtpItem != null) {
... ... @@ -722,11 +725,12 @@ public class PlayServiceImpl implements IPlayService {
722 725 param.put("stream", sendRtpItem.getStreamId());
723 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 730 if (audioBroadcastCatch.getStatus() == AudioBroadcastCatchStatus.Ok) {
728 731 cmder.streamByeCmd(audioBroadcastCatch.getDialog(), audioBroadcastCatch.getRequest(), null);
729 732 }
  733 + audioBroadcastManager.del(deviceId, channelId);
730 734  
731 735 } catch (SipException e) {
732 736 throw new RuntimeException(e);
... ...
web_src/src/components/dialog/devicePlayer.vue
... ... @@ -278,8 +278,9 @@
278 278 </el-tab-pane>
279 279 <el-tab-pane label="语音对讲" name="broadcast" >
280 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 282 <p>
  283 + <span v-if="broadcastStatus === -2">正在释放资源</span>
283 284 <span v-if="broadcastStatus === -1">点击开始对讲</span>
284 285 <span v-if="broadcastStatus === 0">等待接通中...</span>
285 286 <span v-if="broadcastStatus === 1">请说话</span>
... ... @@ -371,7 +372,7 @@ export default {
371 372 showTimeText: "00:00:00",
372 373 streamInfo: null,
373 374 broadcastRtc: null,
374   - broadcastStatus: -1, // -1 默认状态 0 等待接通 1 接通成功
  375 + broadcastStatus: -1, // -2 正在释放资源 -1 默认状态 0 等待接通 1 接通成功
375 376 };
376 377 },
377 378 methods: {
... ... @@ -821,6 +822,9 @@ export default {
821 822 });
822 823 },
823 824 getBroadcastStatus() {
  825 + if (this.broadcastStatus == -2) {
  826 + return "primary"
  827 + }
824 828 if (this.broadcastStatus == -1) {
825 829 return "primary"
826 830 }
... ... @@ -835,6 +839,7 @@ export default {
835 839 broadcastStatusClick() {
836 840 if (this.broadcastStatus == -1) {
837 841 // 默认状态, 开始
  842 + this.broadcastStatus = 0
838 843 // 发起语音对讲
839 844 this.$axios({
840 845 method: 'get',
... ... @@ -924,7 +929,7 @@ export default {
924 929 });
925 930 },
926 931 stopBroadcast(){
927   - this.broadcastRtc.close()
  932 + this.broadcastStatus = -2;
928 933 this.broadcastRtc = null;
929 934 this.$axios({
930 935 method: 'get',
... ... @@ -932,7 +937,6 @@ export default {
932 937 }).then( (res)=> {
933 938 if (res.data.code == 0) {
934 939 // this.broadcastStatus = -1;
935   -
936 940 }else {
937 941 this.$message({
938 942 showClose: true,
... ...