优化对讲逻辑
parent
e78c402a24
commit
7609d7836c
|
@ -830,7 +830,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
|
||||||
subscribeKey.put("app", app);
|
subscribeKey.put("app", app);
|
||||||
subscribeKey.put("stream", stream);
|
subscribeKey.put("stream", stream);
|
||||||
subscribeKey.put("regist", true);
|
subscribeKey.put("regist", true);
|
||||||
subscribeKey.put("schema", "rtmp");
|
subscribeKey.put("schema", "rtsp");
|
||||||
subscribeKey.put("mediaServerId", mediaServerItem.getId());
|
subscribeKey.put("mediaServerId", mediaServerItem.getId());
|
||||||
String finalSsrc = ssrc;
|
String finalSsrc = ssrc;
|
||||||
// 流已经存在时直接推流
|
// 流已经存在时直接推流
|
||||||
|
|
|
@ -339,9 +339,7 @@ public class ZLMHttpHookListener {
|
||||||
@PostMapping(value = "/on_stream_changed", produces = "application/json;charset=UTF-8")
|
@PostMapping(value = "/on_stream_changed", produces = "application/json;charset=UTF-8")
|
||||||
public ResponseEntity<String> onStreamChanged(@RequestBody MediaItem item){
|
public ResponseEntity<String> onStreamChanged(@RequestBody MediaItem item){
|
||||||
|
|
||||||
if (logger.isDebugEnabled()) {
|
logger.info("[ ZLM HOOK ]on_stream_changed API调用,参数:" + JSONObject.toJSONString(item));
|
||||||
logger.debug("[ ZLM HOOK ]on_stream_changed API调用,参数:" + JSONObject.toJSONString(item));
|
|
||||||
}
|
|
||||||
String mediaServerId = item.getMediaServerId();
|
String mediaServerId = item.getMediaServerId();
|
||||||
JSONObject json = (JSONObject) JSON.toJSON(item);
|
JSONObject json = (JSONObject) JSON.toJSON(item);
|
||||||
ZLMHttpHookSubscribe.Event subscribe = this.subscribe.getSubscribe(ZLMHttpHookSubscribe.HookType.on_stream_changed, json);
|
ZLMHttpHookSubscribe.Event subscribe = this.subscribe.getSubscribe(ZLMHttpHookSubscribe.HookType.on_stream_changed, json);
|
||||||
|
|
|
@ -689,6 +689,9 @@ public class PlayServiceImpl implements IPlayService {
|
||||||
logger.warn("语音广播已经开启: {}", channelId);
|
logger.warn("语音广播已经开启: {}", channelId);
|
||||||
event.call("语音广播已经开启");
|
event.call("语音广播已经开启");
|
||||||
return;
|
return;
|
||||||
|
}else {
|
||||||
|
audioBroadcastManager.del(deviceChannel.getDeviceId(),channelId);
|
||||||
|
redisCatchStorage.deleteSendRTPServer(device.getDeviceId(), channelId, sendRtpItem.getCallId(), sendRtpItem.getStreamId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -710,7 +713,7 @@ public class PlayServiceImpl implements IPlayService {
|
||||||
public void stopAudioBroadcast(String deviceId, String channelId){
|
public void stopAudioBroadcast(String deviceId, String channelId){
|
||||||
AudioBroadcastCatch audioBroadcastCatch = audioBroadcastManager.get(deviceId, channelId);
|
AudioBroadcastCatch audioBroadcastCatch = audioBroadcastManager.get(deviceId, channelId);
|
||||||
if (audioBroadcastCatch != null) {
|
if (audioBroadcastCatch != null) {
|
||||||
audioBroadcastManager.del(deviceId, audioBroadcastCatch.getChannelId());
|
|
||||||
try {
|
try {
|
||||||
SendRtpItem sendRtpItem = redisCatchStorage.querySendRTPServer(deviceId, audioBroadcastCatch.getChannelId(), null, null);
|
SendRtpItem sendRtpItem = redisCatchStorage.querySendRTPServer(deviceId, audioBroadcastCatch.getChannelId(), null, null);
|
||||||
if (sendRtpItem != null) {
|
if (sendRtpItem != null) {
|
||||||
|
@ -722,11 +725,12 @@ public class PlayServiceImpl implements IPlayService {
|
||||||
param.put("stream", sendRtpItem.getStreamId());
|
param.put("stream", sendRtpItem.getStreamId());
|
||||||
zlmresTfulUtils.stopSendRtp(mediaInfo, param);
|
zlmresTfulUtils.stopSendRtp(mediaInfo, param);
|
||||||
// 立刻结束设备的推流,等待自行结束太慢
|
// 立刻结束设备的推流,等待自行结束太慢
|
||||||
// zlmresTfulUtils.closeStreams(mediaInfo, sendRtpItem.getApp(), sendRtpItem.getStreamId());
|
zlmresTfulUtils.closeStreams(mediaInfo, sendRtpItem.getApp(), sendRtpItem.getStreamId());
|
||||||
}
|
}
|
||||||
if (audioBroadcastCatch.getStatus() == AudioBroadcastCatchStatus.Ok) {
|
if (audioBroadcastCatch.getStatus() == AudioBroadcastCatchStatus.Ok) {
|
||||||
cmder.streamByeCmd(audioBroadcastCatch.getDialog(), audioBroadcastCatch.getRequest(), null);
|
cmder.streamByeCmd(audioBroadcastCatch.getDialog(), audioBroadcastCatch.getRequest(), null);
|
||||||
}
|
}
|
||||||
|
audioBroadcastManager.del(deviceId, channelId);
|
||||||
|
|
||||||
} catch (SipException e) {
|
} catch (SipException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
|
|
|
@ -278,8 +278,9 @@
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
<el-tab-pane label="语音对讲" name="broadcast" >
|
<el-tab-pane label="语音对讲" name="broadcast" >
|
||||||
<div class="trank" style="text-align: center;">
|
<div class="trank" style="text-align: center;">
|
||||||
<el-button @click="broadcastStatusClick()" :type="getBroadcastStatus()" circle icon="el-icon-microphone" style="font-size: 32px; padding: 24px;margin-top: 24px;"/>
|
<el-button @click="broadcastStatusClick()" :type="getBroadcastStatus()" :disabled="broadcastStatus === -2" circle icon="el-icon-microphone" style="font-size: 32px; padding: 24px;margin-top: 24px;"/>
|
||||||
<p>
|
<p>
|
||||||
|
<span v-if="broadcastStatus === -2">正在释放资源</span>
|
||||||
<span v-if="broadcastStatus === -1">点击开始对讲</span>
|
<span v-if="broadcastStatus === -1">点击开始对讲</span>
|
||||||
<span v-if="broadcastStatus === 0">等待接通中...</span>
|
<span v-if="broadcastStatus === 0">等待接通中...</span>
|
||||||
<span v-if="broadcastStatus === 1">请说话</span>
|
<span v-if="broadcastStatus === 1">请说话</span>
|
||||||
|
@ -371,7 +372,7 @@ export default {
|
||||||
showTimeText: "00:00:00",
|
showTimeText: "00:00:00",
|
||||||
streamInfo: null,
|
streamInfo: null,
|
||||||
broadcastRtc: null,
|
broadcastRtc: null,
|
||||||
broadcastStatus: -1, // -1 默认状态 0 等待接通 1 接通成功
|
broadcastStatus: -1, // -2 正在释放资源 -1 默认状态 0 等待接通 1 接通成功
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -821,6 +822,9 @@ export default {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
getBroadcastStatus() {
|
getBroadcastStatus() {
|
||||||
|
if (this.broadcastStatus == -2) {
|
||||||
|
return "primary"
|
||||||
|
}
|
||||||
if (this.broadcastStatus == -1) {
|
if (this.broadcastStatus == -1) {
|
||||||
return "primary"
|
return "primary"
|
||||||
}
|
}
|
||||||
|
@ -835,6 +839,7 @@ export default {
|
||||||
broadcastStatusClick() {
|
broadcastStatusClick() {
|
||||||
if (this.broadcastStatus == -1) {
|
if (this.broadcastStatus == -1) {
|
||||||
// 默认状态, 开始
|
// 默认状态, 开始
|
||||||
|
this.broadcastStatus = 0
|
||||||
// 发起语音对讲
|
// 发起语音对讲
|
||||||
this.$axios({
|
this.$axios({
|
||||||
method: 'get',
|
method: 'get',
|
||||||
|
@ -924,7 +929,7 @@ export default {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
stopBroadcast(){
|
stopBroadcast(){
|
||||||
this.broadcastRtc.close()
|
this.broadcastStatus = -2;
|
||||||
this.broadcastRtc = null;
|
this.broadcastRtc = null;
|
||||||
this.$axios({
|
this.$axios({
|
||||||
method: 'get',
|
method: 'get',
|
||||||
|
@ -932,7 +937,6 @@ export default {
|
||||||
}).then( (res)=> {
|
}).then( (res)=> {
|
||||||
if (res.data.code == 0) {
|
if (res.data.code == 0) {
|
||||||
// this.broadcastStatus = -1;
|
// this.broadcastStatus = -1;
|
||||||
|
|
||||||
}else {
|
}else {
|
||||||
this.$message({
|
this.$message({
|
||||||
showClose: true,
|
showClose: true,
|
||||||
|
|
Loading…
Reference in New Issue