Commit 116d979d87f53f878a8c930cfad2c6a7cc831b19

Authored by 648540858
1 parent 8b0ff376

合并主线

src/main/java/com/genersoft/iot/vmp/conf/security/dto/LoginUser.java
... ... @@ -98,5 +98,8 @@ public class LoginUser implements UserDetails, CredentialsContainer {
98 98 return user.getRole();
99 99 }
100 100  
  101 + public String getPushKey() {
  102 + return user.getPushKey();
  103 + }
101 104  
102 105 }
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java
... ... @@ -23,10 +23,7 @@ import com.genersoft.iot.vmp.media.zlm.ZLMHttpHookSubscribe;
23 23 import com.genersoft.iot.vmp.media.zlm.ZLMMediaListManager;
24 24 import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils;
25 25 import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory;
26   -import com.genersoft.iot.vmp.media.zlm.dto.MediaItem;
27   -import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
28   -import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItemLite;
29   -import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
  26 +import com.genersoft.iot.vmp.media.zlm.dto.*;
30 27 import com.genersoft.iot.vmp.service.IMediaServerService;
31 28 import com.genersoft.iot.vmp.service.IMediaService;
32 29 import com.genersoft.iot.vmp.service.IPlayService;
... ... @@ -883,101 +880,15 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
883 880  
884 881 // hook监听等待设备推流上来
885 882 // 添加订阅
886   - JSONObject subscribeKey = new JSONObject();
887   - subscribeKey.put("app", app);
888   - subscribeKey.put("stream", stream);
889   - subscribeKey.put("regist", true);
890   - subscribeKey.put("schema", "rtsp");
891   - subscribeKey.put("mediaServerId", mediaServerItem.getId());
  883 + HookSubscribeForStreamChange subscribeKey = HookSubscribeFactory.on_stream_changed(app, stream, true, "rtsp", mediaServerItem.getId());
  884 +
892 885 String finalSsrc = ssrc;
893 886 // 流已经存在时直接推流
894   -// JSONObject mediaInfo = zlmresTfulUtils.getMediaList(mediaServerItem, app, stream);
895   -// System.out.println(mediaInfo != null);
896   -// System.out.println(mediaInfo);
897   -// if (mediaInfo != null &&
898   -// (mediaInfo.getInteger("code") != null && mediaInfo.getInteger("code") == 0
899   -// && mediaInfo.getJSONArray("data") != null && mediaInfo.getJSONArray("data").size() > 0)) {
900   -// logger.info("发现已经在推流");
901   -// JSONArray tracks = mediaInfo.getJSONArray("data").getJSONObject(0).getJSONArray("tracks");
902   -// Integer codecId = null;
903   -// if (tracks != null && tracks.size() > 0) {
904   -// for (int i = 0; i < tracks.size(); i++) {
905   -// MediaItem.MediaTrack track = JSON.toJavaObject((JSON)tracks.get(i),MediaItem.MediaTrack.class);
906   -// if (track.getCodecType() == 1) {
907   -// codecId = track.getCodecId();
908   -// break;
909   -// }
910   -// }
911   -// }
912   -// sendRtpItem.setStatus(2);
913   -// redisCatchStorage.updateSendRTPSever(sendRtpItem);
914   -// StringBuffer content = new StringBuffer(200);
915   -// content.append("v=0\r\n");
916   -// content.append("o="+ config.getId() +" "+ sdp.getOrigin().getSessionId() +" " + sdp.getOrigin().getSessionVersion() + " IN IP4 "+mediaServerItem.getSdpIp()+"\r\n");
917   -// content.append("s=Play\r\n");
918   -// content.append("c=IN IP4 "+mediaServerItem.getSdpIp()+"\r\n");
919   -// content.append("t=0 0\r\n");
920   -// if (codecId == null) {
921   -// if (mediaTransmissionTCP) {
922   -// content.append("m=audio "+ sendRtpItem.getLocalPort()+" TCP/RTP/AVP 8\r\n");
923   -// }else {
924   -// content.append("m=audio "+ sendRtpItem.getLocalPort()+" RTP/AVP 8\r\n");
925   -// }
926   -//
927   -// content.append("a=rtpmap:8 PCMA/8000\r\n");
928   -// }else {
929   -// if (codecId == 4) {
930   -// if (mediaTransmissionTCP) {
931   -// content.append("m=audio "+ sendRtpItem.getLocalPort()+" TCP/RTP/AVP 0\r\n");
932   -// }else {
933   -// content.append("m=audio "+ sendRtpItem.getLocalPort()+" RTP/AVP 0\r\n");
934   -// }
935   -// content.append("a=rtpmap:0 PCMU/8000\r\n");
936   -// }else {
937   -// if (mediaTransmissionTCP) {
938   -// content.append("m=audio "+ sendRtpItem.getLocalPort()+" TCP/RTP/AVP 8\r\n");
939   -// }else {
940   -// content.append("m=audio "+ sendRtpItem.getLocalPort()+" RTP/AVP 8\r\n");
941   -// }
942   -// content.append("a=rtpmap:8 PCMA/8000\r\n");
943   -// }
944   -// }
945   -// if (sendRtpItem.isTcp()) {
946   -// content.append("a=connection:new\r\n");
947   -// if (!sendRtpItem.isTcpActive()) {
948   -// content.append("a=setup:active\r\n");
949   -// }else {
950   -// content.append("a=setup:passive\r\n");
951   -// }
952   -// }
953   -// content.append("a=sendonly\r\n");
954   -// content.append("y="+ finalSsrc + "\r\n");
955   -// content.append("f=v/////a/1/8/1\r\n");
956   -//
957   -// ParentPlatform parentPlatform = new ParentPlatform();
958   -// parentPlatform.setServerIP(device.getIp());
959   -// parentPlatform.setServerPort(device.getPort());
960   -// parentPlatform.setServerGBId(device.getDeviceId());
961   -// try {
962   -// responseSdpAck(evt, content.toString(), parentPlatform);
963   -// Dialog dialog = evt.getDialog();
964   -// audioBroadcastCatch.setDialog((SIPDialog) dialog);
965   -// audioBroadcastCatch.setRequest((SIPRequest) request);
966   -// audioBroadcastManager.update(audioBroadcastCatch);
967   -// } catch (SipException e) {
968   -// throw new RuntimeException(e);
969   -// } catch (InvalidArgumentException e) {
970   -// throw new RuntimeException(e);
971   -// } catch (ParseException e) {
972   -// throw new RuntimeException(e);
973   -// }
974   -// }else {
975   - // 流不存在时监听流上线
976 887 // 设置等待推流的超时; 默认20s
977 888 String waiteStreamTimeoutTaskKey = "waite-stream-" + device.getDeviceId() + audioBroadcastCatch.getChannelId();
978 889 dynamicTask.startDelay(waiteStreamTimeoutTaskKey, ()->{
979 890 logger.info("等待推流超时: {}/{}", app, stream);
980   - subscribe.removeSubscribe(ZLMHttpHookSubscribe.HookType.on_stream_changed, subscribeKey);
  891 + subscribe.removeSubscribe(subscribeKey);
981 892 playService.stopAudioBroadcast(device.getDeviceId(), audioBroadcastCatch.getChannelId());
982 893 // 发送bye
983 894 try {
... ... @@ -992,9 +903,10 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
992 903 }, 20*1000);
993 904  
994 905 boolean finalMediaTransmissionTCP = mediaTransmissionTCP;
995   - subscribe.addSubscribe(ZLMHttpHookSubscribe.HookType.on_stream_changed, subscribeKey,
  906 + subscribe.addSubscribe(subscribeKey,
996 907 (MediaServerItem mediaServerItemInUse, JSONObject json)->{
997 908 logger.info("收到语音对讲推流");
  909 + dynamicTask.stop(waiteStreamTimeoutTaskKey);
998 910 MediaItem mediaItem = JSON.toJavaObject(json, MediaItem.class);
999 911 Integer audioCodecId = null;
1000 912 if (mediaItem.getTracks() != null && mediaItem.getTracks().size() > 0) {
... ...
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
... ... @@ -238,7 +238,7 @@ public class ZLMHttpHookListener {
238 238 // 鉴权通过
239 239 redisCatchStorage.updateStreamAuthorityInfo(param.getApp(), param.getStream(), streamAuthorityInfo);
240 240 // 通知assist新的callId
241   - if (mediaInfo != null) {
  241 + if (mediaInfo != null && mediaInfo.getRecordAssistPort() > 0) {
242 242 assistRESTfulUtils.addStreamCallInfo(mediaInfo, param.getApp(), param.getStream(), callId, null);
243 243 }
244 244 }else {
... ...
src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java
... ... @@ -69,7 +69,7 @@ public class MediaServiceImpl implements IMediaService {
69 69 if (authority) {
70 70 streamInfo = getStreamInfoByAppAndStream(mediaInfo, app, stream, tracks, addr,streamAuthorityInfo.getCallId(), true);
71 71 }else {
72   - streamInfo = getStreamInfoByAppAndStream(mediaInfo, app, stream, tracks, addr,null);
  72 + streamInfo = getStreamInfoByAppAndStream(mediaInfo, app, stream, tracks, addr,null, true);
73 73 }
74 74  
75 75 }
... ...
src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java
... ... @@ -8,6 +8,7 @@ import java.util.UUID;
8 8  
9 9 import javax.sip.ResponseEvent;
10 10  
  11 +import com.genersoft.iot.vmp.gb28181.bean.*;
11 12 import org.slf4j.Logger;
12 13 import org.slf4j.LoggerFactory;
13 14 import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -23,13 +24,6 @@ import com.genersoft.iot.vmp.common.StreamInfo;
23 24 import com.genersoft.iot.vmp.conf.DynamicTask;
24 25 import com.genersoft.iot.vmp.conf.SipConfig;
25 26 import com.genersoft.iot.vmp.conf.UserSetting;
26   -import com.genersoft.iot.vmp.gb28181.bean.Device;
27   -import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
28   -import com.genersoft.iot.vmp.gb28181.bean.InviteStreamCallback;
29   -import com.genersoft.iot.vmp.gb28181.bean.InviteStreamInfo;
30   -import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
31   -import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem;
32   -import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction;
33 27 import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
34 28 import com.genersoft.iot.vmp.gb28181.session.AudioBroadcastManager;
35 29 import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
... ...
web_src/src/components/Login.vue
... ... @@ -35,6 +35,7 @@
35 35  
36 36 <script>
37 37 import crypto from 'crypto'
  38 +import Vue from 'vue'
38 39 export default {
39 40 name: 'Login',
40 41 data(){
... ... @@ -84,11 +85,13 @@ export default {
84 85 url:"/api/user/login",
85 86 params: loginParam
86 87 }).then(function (res) {
87   - console.log(JSON.stringify(res));
  88 + console.log(res);
  89 + console.log(res.data.data);
88 90 if (res.data.code == 0 && res.data.msg == "success") {
89 91 that.$cookies.set("session", {"username": that.username,"roleId":res.data.data.role.id}) ;
90 92 //登录成功后
91 93 that.cancelEnterkeyDefaultAction();
  94 + Vue.prototype.$loginUser = res.data.data
92 95 that.$router.push('/');
93 96 }else{
94 97 that.isLoging = false;
... ...
web_src/src/components/dialog/devicePlayer.vue
... ... @@ -298,6 +298,7 @@
298 298  
299 299 <script>
300 300 import rtcPlayer from '../dialog/rtcPlayer.vue'
  301 +import crypto from 'crypto'
301 302 // import LivePlayer from '@liveqing/liveplayer'
302 303 // import player from '../dialog/easyPlayer.vue'
303 304 import jessibucaPlayer from '../common/jessibuca.vue'
... ... @@ -861,6 +862,10 @@ export default {
861 862 }
862 863 },
863 864 startBroadcast(url){
  865 + // 获取推流鉴权KEY
  866 + console.log(this.$loginUser)
  867 + console.log(this.$loginUser.pushKey)
  868 + url += "&sign=" + crypto.createHash('md5').update(this.$loginUser.pushKey, "utf8").digest('hex')
864 869 console.log("开始语音对讲: " + url)
865 870 this.broadcastRtc = new ZLMRTCClient.Endpoint({
866 871 debug: true, // 是否打印日志
... ...