Commit 1171cf1ea9a2c69916bfb49181ecb5bf66055b33

Authored by 648540858
1 parent 61e91afd

使用zlm新特性支持对与国标流关闭音频以加快拉流速度

src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
@@ -9,9 +9,12 @@ import com.genersoft.iot.vmp.common.StreamInfo; @@ -9,9 +9,12 @@ import com.genersoft.iot.vmp.common.StreamInfo;
9 import com.genersoft.iot.vmp.conf.MediaConfig; 9 import com.genersoft.iot.vmp.conf.MediaConfig;
10 import com.genersoft.iot.vmp.conf.UserSetup; 10 import com.genersoft.iot.vmp.conf.UserSetup;
11 import com.genersoft.iot.vmp.gb28181.bean.Device; 11 import com.genersoft.iot.vmp.gb28181.bean.Device;
  12 +import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
12 import com.genersoft.iot.vmp.gb28181.bean.GbStream; 13 import com.genersoft.iot.vmp.gb28181.bean.GbStream;
  14 +import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction;
13 import com.genersoft.iot.vmp.gb28181.event.EventPublisher; 15 import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
14 import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent; 16 import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
  17 +import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
15 import com.genersoft.iot.vmp.media.zlm.dto.*; 18 import com.genersoft.iot.vmp.media.zlm.dto.*;
16 import com.genersoft.iot.vmp.service.*; 19 import com.genersoft.iot.vmp.service.*;
17 import com.genersoft.iot.vmp.service.bean.SSRCInfo; 20 import com.genersoft.iot.vmp.service.bean.SSRCInfo;
@@ -81,7 +84,7 @@ public class ZLMHttpHookListener { @@ -81,7 +84,7 @@ public class ZLMHttpHookListener {
81 private UserSetup userSetup; 84 private UserSetup userSetup;
82 85
83 @Autowired 86 @Autowired
84 - private MediaConfig mediaConfig; 87 + private VideoStreamSessionManager sessionManager;
85 88
86 /** 89 /**
87 * 服务器定时上报时间,上报间隔可配置,默认10s上报一次 90 * 服务器定时上报时间,上报间隔可配置,默认10s上报一次
@@ -204,15 +207,15 @@ public class ZLMHttpHookListener { @@ -204,15 +207,15 @@ public class ZLMHttpHookListener {
204 }else { 207 }else {
205 ret.put("enableMP4", userSetup.isRecordPushLive()); 208 ret.put("enableMP4", userSetup.isRecordPushLive());
206 } 209 }
207 - StreamInfo streamInfo = redisCatchStorage.queryPlaybackByStreamId(stream);  
208 -  
209 - // 录像回放时不进行录像下载  
210 - if (streamInfo != null) {  
211 - ret.put("enableMP4", false);  
212 - }else {  
213 - ret.put("enableMP4", userSetup.isRecordPushLive()); 210 + List<SsrcTransaction> ssrcTransactionForAll = sessionManager.getSsrcTransactionForAll(null, null, null, stream);
  211 + if (ssrcTransactionForAll != null && ssrcTransactionForAll.size() == 1) {
  212 + String deviceId = ssrcTransactionForAll.get(0).getDeviceId();
  213 + String channelId = ssrcTransactionForAll.get(0).getChannelId();
  214 + DeviceChannel deviceChannel = storager.queryChannel(deviceId, channelId);
  215 + if (deviceChannel != null) {
  216 + ret.put("enable_audio", deviceChannel.isHasAudio());
  217 + }
214 } 218 }
215 -  
216 return new ResponseEntity<String>(ret.toString(), HttpStatus.OK); 219 return new ResponseEntity<String>(ret.toString(), HttpStatus.OK);
217 } 220 }
218 221
@@ -347,8 +350,12 @@ public class ZLMHttpHookListener { @@ -347,8 +350,12 @@ public class ZLMHttpHookListener {
347 redisCatchStorage.stopPlay(streamInfo); 350 redisCatchStorage.stopPlay(streamInfo);
348 storager.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId()); 351 storager.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId());
349 }else{ 352 }else{
350 - streamInfo = redisCatchStorage.queryPlaybackByStreamId(streamId);  
351 - redisCatchStorage.stopPlayback(streamInfo); 353 + streamInfo = redisCatchStorage.queryPlayback(null, null, streamId, null);
  354 + if (streamInfo != null) {
  355 + redisCatchStorage.stopPlayback(streamInfo.getDeviceID(), streamInfo.getChannelId(),
  356 + streamInfo.getStream(), null);
  357 + }
  358 +
352 } 359 }
353 }else { 360 }else {
354 if (!"rtp".equals(app)){ 361 if (!"rtp".equals(app)){
@@ -440,18 +447,19 @@ public class ZLMHttpHookListener { @@ -440,18 +447,19 @@ public class ZLMHttpHookListener {
440 ret.put("close", false); 447 ret.put("close", false);
441 } else { 448 } else {
442 cmder.streamByeCmd(streamInfoForPlayCatch.getDeviceID(), streamInfoForPlayCatch.getChannelId(), 449 cmder.streamByeCmd(streamInfoForPlayCatch.getDeviceID(), streamInfoForPlayCatch.getChannelId(),
443 - streamInfoForPlayCatch.getStream()); 450 + streamInfoForPlayCatch.getStream(), null);
444 redisCatchStorage.stopPlay(streamInfoForPlayCatch); 451 redisCatchStorage.stopPlay(streamInfoForPlayCatch);
445 storager.stopPlay(streamInfoForPlayCatch.getDeviceID(), streamInfoForPlayCatch.getChannelId()); 452 storager.stopPlay(streamInfoForPlayCatch.getDeviceID(), streamInfoForPlayCatch.getChannelId());
446 } 453 }
447 }else{ 454 }else{
448 - StreamInfo streamInfoForPlayBackCatch = redisCatchStorage.queryPlaybackByStreamId(streamId); 455 + StreamInfo streamInfoForPlayBackCatch = redisCatchStorage.queryPlayback(null, null, streamId, null);
449 if (streamInfoForPlayBackCatch != null) { 456 if (streamInfoForPlayBackCatch != null) {
450 cmder.streamByeCmd(streamInfoForPlayBackCatch.getDeviceID(), 457 cmder.streamByeCmd(streamInfoForPlayBackCatch.getDeviceID(),
451 - streamInfoForPlayBackCatch.getChannelId(), streamInfoForPlayBackCatch.getStream());  
452 - redisCatchStorage.stopPlayback(streamInfoForPlayBackCatch); 458 + streamInfoForPlayBackCatch.getChannelId(), streamInfoForPlayBackCatch.getStream(), null);
  459 + redisCatchStorage.stopPlayback(streamInfoForPlayBackCatch.getDeviceID(),
  460 + streamInfoForPlayBackCatch.getChannelId(), streamInfoForPlayBackCatch.getStream(), null);
453 }else { 461 }else {
454 - StreamInfo streamInfoForDownload = redisCatchStorage.queryDownloadByStreamId(streamId); 462 + StreamInfo streamInfoForDownload = redisCatchStorage.queryDownload(null, null, streamId, null);
455 // 进行录像下载时无人观看不断流 463 // 进行录像下载时无人观看不断流
456 if (streamInfoForDownload != null) { 464 if (streamInfoForDownload != null) {
457 ret.put("close", false); 465 ret.put("close", false);