From 13811b0c78a2676eada42dfd1835f5f2790b21af Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期四, 20 七月 2023 17:51:16 +0800
Subject: [PATCH] Merge branch '2.6.8' into wvp-28181-2.0
---
src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiStreamController.java | 120 ++++++++++++++++++---------------------
src/main/resources/all-application.yml | 4
2 files changed, 57 insertions(+), 67 deletions(-)
diff --git a/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiStreamController.java b/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiStreamController.java
index 18fdfa9..8a1d079 100644
--- a/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiStreamController.java
+++ b/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiStreamController.java
@@ -1,8 +1,7 @@
package com.genersoft.iot.vmp.web.gb28181;
import com.alibaba.fastjson2.JSONObject;
-import com.genersoft.iot.vmp.common.InviteInfo;
-import com.genersoft.iot.vmp.common.InviteSessionType;
+import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.conf.UserSetting;
import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException;
import com.genersoft.iot.vmp.gb28181.bean.Device;
@@ -10,18 +9,13 @@
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
import com.genersoft.iot.vmp.service.IDeviceService;
-import com.genersoft.iot.vmp.service.IInviteStreamService;
import com.genersoft.iot.vmp.service.IPlayService;
-import com.genersoft.iot.vmp.service.bean.InviteErrorCode;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.ResponseBody;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.async.DeferredResult;
import javax.sip.InvalidArgumentException;
@@ -50,9 +44,6 @@
@Autowired
private IRedisCatchStorage redisCatchStorage;
-
- @Autowired
- private IInviteStreamService inviteStreamService;
@Autowired
private IDeviceService deviceService;
@@ -92,7 +83,7 @@
result.put("error","device[ " + serial + " ]鏈壘鍒�");
resultDeferredResult.setResult(result);
return resultDeferredResult;
- }else if (!device.isOnLine()) {
+ }else if (device.getOnline() == 0) {
JSONObject result = new JSONObject();
result.put("error","device[ " + code + " ]offline");
resultDeferredResult.setResult(result);
@@ -113,60 +104,59 @@
result.put("error","channel[ " + code + " ]鏈壘鍒�");
resultDeferredResult.setResult(result);
return resultDeferredResult;
- }else if (!deviceChannel.isStatus()) {
+ }else if (deviceChannel.getStatus() == 0) {
JSONObject result = new JSONObject();
result.put("error","channel[ " + code + " ]offline");
resultDeferredResult.setResult(result);
return resultDeferredResult;
}
MediaServerItem newMediaServerItem = playService.getNewMediaServerItem(device);
-
-
- playService.play(newMediaServerItem, serial, code, null, (errorCode, msg, data) -> {
- if (errorCode == InviteErrorCode.SUCCESS.getCode()) {
- InviteInfo inviteInfo = inviteStreamService.getInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, serial, code);
- if (inviteInfo != null && inviteInfo.getStreamInfo() != null) {
- JSONObject result = new JSONObject();
- result.put("StreamID", inviteInfo.getStreamInfo().getStream());
- result.put("DeviceID", device.getDeviceId());
- result.put("ChannelID", code);
- result.put("ChannelName", deviceChannel.getName());
- result.put("ChannelCustomName", "");
- result.put("FLV", inviteInfo.getStreamInfo().getFlv().getUrl());
- result.put("WS_FLV", inviteInfo.getStreamInfo().getWs_flv().getUrl());
- result.put("RTMP", inviteInfo.getStreamInfo().getRtmp().getUrl());
- result.put("HLS", inviteInfo.getStreamInfo().getHls().getUrl());
- result.put("RTSP", inviteInfo.getStreamInfo().getRtsp().getUrl());
- result.put("WEBRTC", inviteInfo.getStreamInfo().getRtc().getUrl());
- result.put("CDN", "");
- result.put("SnapURL", "");
- result.put("Transport", device.getTransport());
- result.put("StartAt", "");
- result.put("Duration", "");
- result.put("SourceVideoCodecName", "");
- result.put("SourceVideoWidth", "");
- result.put("SourceVideoHeight", "");
- result.put("SourceVideoFrameRate", "");
- result.put("SourceAudioCodecName", "");
- result.put("SourceAudioSampleRate", "");
- result.put("AudioEnable", "");
- result.put("Ondemand", "");
- result.put("InBytes", "");
- result.put("InBitRate", "");
- result.put("OutBytes", "");
- result.put("NumOutputs", "");
- result.put("CascadeSize", "");
- result.put("RelaySize", "");
- result.put("ChannelPTZType", "0");
- resultDeferredResult.setResult(result);
- }
- }else {
- JSONObject result = new JSONObject();
- result.put("error", "channel[ " + code + " ] " + msg);
- resultDeferredResult.setResult(result);
- }
- });
-
+ playService.play(newMediaServerItem, serial, code, (mediaServerItem, response)->{
+ StreamInfo streamInfo = redisCatchStorage.queryPlayByDevice(serial, code);
+ JSONObject result = new JSONObject();
+ result.put("StreamID", streamInfo.getStream());
+ result.put("DeviceID", device.getDeviceId());
+ result.put("ChannelID", code);
+ result.put("ChannelName", deviceChannel.getName());
+ result.put("ChannelCustomName", "");
+ result.put("FLV", streamInfo.getFlv().getUrl());
+ result.put("HTTPS_FLV", streamInfo.getHttps_flv().getUrl());
+ result.put("WS_FLV", streamInfo.getWs_flv().getUrl());
+ result.put("WSS_FLV", streamInfo.getWss_flv().getUrl());
+ result.put("RTMP", streamInfo.getRtmp().getUrl());
+ result.put("RTMPS", streamInfo.getRtmps().getUrl());
+ result.put("HLS", streamInfo.getHls().getUrl());
+ result.put("HTTPS_HLS", streamInfo.getHttps_hls().getUrl());
+ result.put("RTSP", streamInfo.getRtsp().getUrl());
+ result.put("RTSPS", streamInfo.getRtsps().getUrl());
+ result.put("WEBRTC", streamInfo.getRtc().getUrl());
+ result.put("HTTPS_WEBRTC", streamInfo.getRtcs().getUrl());
+ result.put("CDN", "");
+ result.put("SnapURL", "");
+ result.put("Transport", device.getTransport());
+ result.put("StartAt", "");
+ result.put("Duration", "");
+ result.put("SourceVideoCodecName", "");
+ result.put("SourceVideoWidth", "");
+ result.put("SourceVideoHeight", "");
+ result.put("SourceVideoFrameRate", "");
+ result.put("SourceAudioCodecName", "");
+ result.put("SourceAudioSampleRate", "");
+ result.put("AudioEnable", "");
+ result.put("Ondemand", "");
+ result.put("InBytes", "");
+ result.put("InBitRate", "");
+ result.put("OutBytes", "");
+ result.put("NumOutputs", "");
+ result.put("CascadeSize", "");
+ result.put("RelaySize", "");
+ result.put("ChannelPTZType", "0");
+ resultDeferredResult.setResult(result);
+ }, (eventResult) -> {
+ JSONObject result = new JSONObject();
+ result.put("error", "channel[ " + code + " ] " + eventResult.msg);
+ resultDeferredResult.setResult(result);
+ }, null);
return resultDeferredResult;
}
@@ -187,8 +177,8 @@
){
- InviteInfo inviteInfo = inviteStreamService.getInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, serial, code);
- if (inviteInfo == null) {
+ StreamInfo streamInfo = redisCatchStorage.queryPlayByDevice(serial, code);
+ if (streamInfo == null) {
JSONObject result = new JSONObject();
result.put("error","鏈壘鍒版祦淇℃伅");
return result;
@@ -200,14 +190,14 @@
return result;
}
try {
- cmder.streamByeCmd(device, code, inviteInfo.getStream(), null);
+ cmder.streamByeCmd(device, code, streamInfo.getStream(), null);
} catch (InvalidArgumentException | ParseException | SipException | SsrcTransactionNotFoundException e) {
JSONObject result = new JSONObject();
result.put("error","鍙戦�丅YE澶辫触锛�" + e.getMessage());
return result;
}
- inviteStreamService.removeInviteInfo(inviteInfo);
- storager.stopPlay(inviteInfo.getDeviceId(), inviteInfo.getChannelId());
+ redisCatchStorage.stopPlay(streamInfo);
+ storager.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId());
return null;
}
diff --git a/src/main/resources/all-application.yml b/src/main/resources/all-application.yml
index e982b2b..99caa02 100644
--- a/src/main/resources/all-application.yml
+++ b/src/main/resources/all-application.yml
@@ -145,8 +145,8 @@
enable: true
# [鍙�塢 鍦ㄦ鑼冨洿鍐呴�夋嫨绔彛鐢ㄤ簬濯掍綋娴佷紶杈�, 蹇呴』鎻愬墠鍦▃lm涓婇厤缃灞炴�э紝涓嶇劧鑷姩閰嶇疆姝ゅ睘鎬у彲鑳戒笉鎴愬姛
port-range: 30000,30500 # 绔彛鑼冨洿
- # [鍙�塢 鍥芥爣绾ц仈鍦ㄦ鑼冨洿鍐呴�夋嫨绔彛鍙戦�佸獟浣撴祦
- send-port-range: 30000,30500 # 绔彛鑼冨洿
+ # [鍙�塢 鍥芥爣绾ц仈鍦ㄦ鑼冨洿鍐呴�夋嫨绔彛鍙戦�佸獟浣撴祦锛岃涓嶈涓庢敹娴佺鍙h寖鍥撮噸鍚�
+ send-port-range: 50502,50506 # 绔彛鑼冨洿
# 褰曞儚杈呭姪鏈嶅姟锛� 閮ㄧ讲姝ゆ湇鍔″彲浠ュ疄鐜皕lm褰曞儚鐨勭鐞嗕笌涓嬭浇锛� 0 琛ㄧず涓嶄娇鐢�
record-assist-port: 0
--
Gitblit v1.8.0