合并主线

结构优化
648540858 2022-08-09 16:58:31 +08:00
parent 8b0ff3767b
commit 116d979d87
7 changed files with 21 additions and 104 deletions

View File

@ -98,5 +98,8 @@ public class LoginUser implements UserDetails, CredentialsContainer {
return user.getRole(); return user.getRole();
} }
public String getPushKey() {
return user.getPushKey();
}
} }

View File

@ -23,10 +23,7 @@ import com.genersoft.iot.vmp.media.zlm.ZLMHttpHookSubscribe;
import com.genersoft.iot.vmp.media.zlm.ZLMMediaListManager; import com.genersoft.iot.vmp.media.zlm.ZLMMediaListManager;
import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils;
import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory; import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory;
import com.genersoft.iot.vmp.media.zlm.dto.MediaItem; import com.genersoft.iot.vmp.media.zlm.dto.*;
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItemLite;
import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
import com.genersoft.iot.vmp.service.IMediaServerService; import com.genersoft.iot.vmp.service.IMediaServerService;
import com.genersoft.iot.vmp.service.IMediaService; import com.genersoft.iot.vmp.service.IMediaService;
import com.genersoft.iot.vmp.service.IPlayService; import com.genersoft.iot.vmp.service.IPlayService;
@ -883,101 +880,15 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
// hook监听等待设备推流上来 // hook监听等待设备推流上来
// 添加订阅 // 添加订阅
JSONObject subscribeKey = new JSONObject(); HookSubscribeForStreamChange subscribeKey = HookSubscribeFactory.on_stream_changed(app, stream, true, "rtsp", mediaServerItem.getId());
subscribeKey.put("app", app);
subscribeKey.put("stream", stream);
subscribeKey.put("regist", true);
subscribeKey.put("schema", "rtsp");
subscribeKey.put("mediaServerId", mediaServerItem.getId());
String finalSsrc = ssrc; String finalSsrc = ssrc;
// 流已经存在时直接推流 // 流已经存在时直接推流
// JSONObject mediaInfo = zlmresTfulUtils.getMediaList(mediaServerItem, app, stream);
// System.out.println(mediaInfo != null);
// System.out.println(mediaInfo);
// if (mediaInfo != null &&
// (mediaInfo.getInteger("code") != null && mediaInfo.getInteger("code") == 0
// && mediaInfo.getJSONArray("data") != null && mediaInfo.getJSONArray("data").size() > 0)) {
// logger.info("发现已经在推流");
// JSONArray tracks = mediaInfo.getJSONArray("data").getJSONObject(0).getJSONArray("tracks");
// Integer codecId = null;
// if (tracks != null && tracks.size() > 0) {
// for (int i = 0; i < tracks.size(); i++) {
// MediaItem.MediaTrack track = JSON.toJavaObject((JSON)tracks.get(i),MediaItem.MediaTrack.class);
// if (track.getCodecType() == 1) {
// codecId = track.getCodecId();
// break;
// }
// }
// }
// sendRtpItem.setStatus(2);
// redisCatchStorage.updateSendRTPSever(sendRtpItem);
// StringBuffer content = new StringBuffer(200);
// content.append("v=0\r\n");
// content.append("o="+ config.getId() +" "+ sdp.getOrigin().getSessionId() +" " + sdp.getOrigin().getSessionVersion() + " IN IP4 "+mediaServerItem.getSdpIp()+"\r\n");
// content.append("s=Play\r\n");
// content.append("c=IN IP4 "+mediaServerItem.getSdpIp()+"\r\n");
// content.append("t=0 0\r\n");
// if (codecId == null) {
// if (mediaTransmissionTCP) {
// content.append("m=audio "+ sendRtpItem.getLocalPort()+" TCP/RTP/AVP 8\r\n");
// }else {
// content.append("m=audio "+ sendRtpItem.getLocalPort()+" RTP/AVP 8\r\n");
// }
//
// content.append("a=rtpmap:8 PCMA/8000\r\n");
// }else {
// if (codecId == 4) {
// if (mediaTransmissionTCP) {
// content.append("m=audio "+ sendRtpItem.getLocalPort()+" TCP/RTP/AVP 0\r\n");
// }else {
// content.append("m=audio "+ sendRtpItem.getLocalPort()+" RTP/AVP 0\r\n");
// }
// content.append("a=rtpmap:0 PCMU/8000\r\n");
// }else {
// if (mediaTransmissionTCP) {
// content.append("m=audio "+ sendRtpItem.getLocalPort()+" TCP/RTP/AVP 8\r\n");
// }else {
// content.append("m=audio "+ sendRtpItem.getLocalPort()+" RTP/AVP 8\r\n");
// }
// content.append("a=rtpmap:8 PCMA/8000\r\n");
// }
// }
// if (sendRtpItem.isTcp()) {
// content.append("a=connection:new\r\n");
// if (!sendRtpItem.isTcpActive()) {
// content.append("a=setup:active\r\n");
// }else {
// content.append("a=setup:passive\r\n");
// }
// }
// content.append("a=sendonly\r\n");
// content.append("y="+ finalSsrc + "\r\n");
// content.append("f=v/////a/1/8/1\r\n");
//
// ParentPlatform parentPlatform = new ParentPlatform();
// parentPlatform.setServerIP(device.getIp());
// parentPlatform.setServerPort(device.getPort());
// parentPlatform.setServerGBId(device.getDeviceId());
// try {
// responseSdpAck(evt, content.toString(), parentPlatform);
// Dialog dialog = evt.getDialog();
// audioBroadcastCatch.setDialog((SIPDialog) dialog);
// audioBroadcastCatch.setRequest((SIPRequest) request);
// audioBroadcastManager.update(audioBroadcastCatch);
// } catch (SipException e) {
// throw new RuntimeException(e);
// } catch (InvalidArgumentException e) {
// throw new RuntimeException(e);
// } catch (ParseException e) {
// throw new RuntimeException(e);
// }
// }else {
// 流不存在时监听流上线
// 设置等待推流的超时; 默认20s // 设置等待推流的超时; 默认20s
String waiteStreamTimeoutTaskKey = "waite-stream-" + device.getDeviceId() + audioBroadcastCatch.getChannelId(); String waiteStreamTimeoutTaskKey = "waite-stream-" + device.getDeviceId() + audioBroadcastCatch.getChannelId();
dynamicTask.startDelay(waiteStreamTimeoutTaskKey, ()->{ dynamicTask.startDelay(waiteStreamTimeoutTaskKey, ()->{
logger.info("等待推流超时: {}/{}", app, stream); logger.info("等待推流超时: {}/{}", app, stream);
subscribe.removeSubscribe(ZLMHttpHookSubscribe.HookType.on_stream_changed, subscribeKey); subscribe.removeSubscribe(subscribeKey);
playService.stopAudioBroadcast(device.getDeviceId(), audioBroadcastCatch.getChannelId()); playService.stopAudioBroadcast(device.getDeviceId(), audioBroadcastCatch.getChannelId());
// 发送bye // 发送bye
try { try {
@ -992,9 +903,10 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
}, 20*1000); }, 20*1000);
boolean finalMediaTransmissionTCP = mediaTransmissionTCP; boolean finalMediaTransmissionTCP = mediaTransmissionTCP;
subscribe.addSubscribe(ZLMHttpHookSubscribe.HookType.on_stream_changed, subscribeKey, subscribe.addSubscribe(subscribeKey,
(MediaServerItem mediaServerItemInUse, JSONObject json)->{ (MediaServerItem mediaServerItemInUse, JSONObject json)->{
logger.info("收到语音对讲推流"); logger.info("收到语音对讲推流");
dynamicTask.stop(waiteStreamTimeoutTaskKey);
MediaItem mediaItem = JSON.toJavaObject(json, MediaItem.class); MediaItem mediaItem = JSON.toJavaObject(json, MediaItem.class);
Integer audioCodecId = null; Integer audioCodecId = null;
if (mediaItem.getTracks() != null && mediaItem.getTracks().size() > 0) { if (mediaItem.getTracks() != null && mediaItem.getTracks().size() > 0) {

View File

@ -238,7 +238,7 @@ public class ZLMHttpHookListener {
// 鉴权通过 // 鉴权通过
redisCatchStorage.updateStreamAuthorityInfo(param.getApp(), param.getStream(), streamAuthorityInfo); redisCatchStorage.updateStreamAuthorityInfo(param.getApp(), param.getStream(), streamAuthorityInfo);
// 通知assist新的callId // 通知assist新的callId
if (mediaInfo != null) { if (mediaInfo != null && mediaInfo.getRecordAssistPort() > 0) {
assistRESTfulUtils.addStreamCallInfo(mediaInfo, param.getApp(), param.getStream(), callId, null); assistRESTfulUtils.addStreamCallInfo(mediaInfo, param.getApp(), param.getStream(), callId, null);
} }
}else { }else {

View File

@ -69,7 +69,7 @@ public class MediaServiceImpl implements IMediaService {
if (authority) { if (authority) {
streamInfo = getStreamInfoByAppAndStream(mediaInfo, app, stream, tracks, addr,streamAuthorityInfo.getCallId(), true); streamInfo = getStreamInfoByAppAndStream(mediaInfo, app, stream, tracks, addr,streamAuthorityInfo.getCallId(), true);
}else { }else {
streamInfo = getStreamInfoByAppAndStream(mediaInfo, app, stream, tracks, addr,null); streamInfo = getStreamInfoByAppAndStream(mediaInfo, app, stream, tracks, addr,null, true);
} }
} }

View File

@ -8,6 +8,7 @@ import java.util.UUID;
import javax.sip.ResponseEvent; import javax.sip.ResponseEvent;
import com.genersoft.iot.vmp.gb28181.bean.*;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -23,13 +24,6 @@ import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.conf.DynamicTask; import com.genersoft.iot.vmp.conf.DynamicTask;
import com.genersoft.iot.vmp.conf.SipConfig; import com.genersoft.iot.vmp.conf.SipConfig;
import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.conf.UserSetting;
import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.gb28181.bean.InviteStreamCallback;
import com.genersoft.iot.vmp.gb28181.bean.InviteStreamInfo;
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem;
import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction;
import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
import com.genersoft.iot.vmp.gb28181.session.AudioBroadcastManager; import com.genersoft.iot.vmp.gb28181.session.AudioBroadcastManager;
import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;

View File

@ -35,6 +35,7 @@
<script> <script>
import crypto from 'crypto' import crypto from 'crypto'
import Vue from 'vue'
export default { export default {
name: 'Login', name: 'Login',
data(){ data(){
@ -84,11 +85,13 @@ export default {
url:"/api/user/login", url:"/api/user/login",
params: loginParam params: loginParam
}).then(function (res) { }).then(function (res) {
console.log(JSON.stringify(res)); console.log(res);
console.log(res.data.data);
if (res.data.code == 0 && res.data.msg == "success") { if (res.data.code == 0 && res.data.msg == "success") {
that.$cookies.set("session", {"username": that.username,"roleId":res.data.data.role.id}) ; that.$cookies.set("session", {"username": that.username,"roleId":res.data.data.role.id}) ;
// //
that.cancelEnterkeyDefaultAction(); that.cancelEnterkeyDefaultAction();
Vue.prototype.$loginUser = res.data.data
that.$router.push('/'); that.$router.push('/');
}else{ }else{
that.isLoging = false; that.isLoging = false;

View File

@ -298,6 +298,7 @@
<script> <script>
import rtcPlayer from '../dialog/rtcPlayer.vue' import rtcPlayer from '../dialog/rtcPlayer.vue'
import crypto from 'crypto'
// import LivePlayer from '@liveqing/liveplayer' // import LivePlayer from '@liveqing/liveplayer'
// import player from '../dialog/easyPlayer.vue' // import player from '../dialog/easyPlayer.vue'
import jessibucaPlayer from '../common/jessibuca.vue' import jessibucaPlayer from '../common/jessibuca.vue'
@ -861,6 +862,10 @@ export default {
} }
}, },
startBroadcast(url){ startBroadcast(url){
// KEY
console.log(this.$loginUser)
console.log(this.$loginUser.pushKey)
url += "&sign=" + crypto.createHash('md5').update(this.$loginUser.pushKey, "utf8").digest('hex')
console.log("开始语音对讲: " + url) console.log("开始语音对讲: " + url)
this.broadcastRtc = new ZLMRTCClient.Endpoint({ this.broadcastRtc = new ZLMRTCClient.Endpoint({
debug: true, // debug: true, //