mirror of
https://gitee.com/pan648540858/wvp-GB28181-pro.git
synced 2026-05-22 21:37:48 +08:00
1078-支持无人观看自动停流
This commit is contained in:
parent
824690a37f
commit
46bf5b7a39
@ -25,6 +25,9 @@ import com.genersoft.iot.vmp.media.event.hook.Hook;
|
|||||||
import com.genersoft.iot.vmp.media.event.hook.HookData;
|
import com.genersoft.iot.vmp.media.event.hook.HookData;
|
||||||
import com.genersoft.iot.vmp.media.event.hook.HookSubscribe;
|
import com.genersoft.iot.vmp.media.event.hook.HookSubscribe;
|
||||||
import com.genersoft.iot.vmp.media.event.hook.HookType;
|
import com.genersoft.iot.vmp.media.event.hook.HookType;
|
||||||
|
import com.genersoft.iot.vmp.media.event.media.MediaArrivalEvent;
|
||||||
|
import com.genersoft.iot.vmp.media.event.media.MediaDepartureEvent;
|
||||||
|
import com.genersoft.iot.vmp.media.event.media.MediaNotFoundEvent;
|
||||||
import com.genersoft.iot.vmp.media.event.mediaServer.MediaSendRtpStoppedEvent;
|
import com.genersoft.iot.vmp.media.event.mediaServer.MediaSendRtpStoppedEvent;
|
||||||
import com.genersoft.iot.vmp.media.service.IMediaServerService;
|
import com.genersoft.iot.vmp.media.service.IMediaServerService;
|
||||||
import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils;
|
import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils;
|
||||||
@ -42,6 +45,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.event.EventListener;
|
import org.springframework.context.event.EventListener;
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
@ -71,27 +75,47 @@ public class jt1078ServiceImpl implements Ijt1078Service {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private IMediaServerService mediaServerService;
|
private IMediaServerService mediaServerService;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private IMediaService mediaService;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private DynamicTask dynamicTask;
|
private DynamicTask dynamicTask;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private UserSetting userSetting;
|
private UserSetting userSetting;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ZLMRESTfulUtils zlmresTfulUtils;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private CallbackManager callbackManager;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IRedisCatchStorage redisCatchStorage;
|
private IRedisCatchStorage redisCatchStorage;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private FtpSetting ftpSetting;
|
private FtpSetting ftpSetting;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 流到来的处理
|
||||||
|
*/
|
||||||
|
@Async("taskExecutor")
|
||||||
|
@org.springframework.context.event.EventListener
|
||||||
|
public void onApplicationEvent(MediaArrivalEvent event) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 流离开的处理
|
||||||
|
*/
|
||||||
|
@Async("taskExecutor")
|
||||||
|
@EventListener
|
||||||
|
public void onApplicationEvent(MediaDepartureEvent event) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 流未找到的处理
|
||||||
|
*/
|
||||||
|
@Async("taskExecutor")
|
||||||
|
@EventListener
|
||||||
|
public void onApplicationEvent(MediaNotFoundEvent event) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JTDevice getDevice(String phoneNumber) {
|
public JTDevice getDevice(String phoneNumber) {
|
||||||
@ -172,7 +196,7 @@ public class jt1078ServiceImpl implements Ijt1078Service {
|
|||||||
// 清理数据
|
// 清理数据
|
||||||
redisTemplate.delete(playKey);
|
redisTemplate.delete(playKey);
|
||||||
}
|
}
|
||||||
String stream = "jt_play_" + phoneNumber + "_" + channelId;
|
String stream = "jt_" + phoneNumber + "_" + channelId;
|
||||||
MediaServer mediaServer = mediaServerService.getMediaServerForMinimumLoad(null);
|
MediaServer mediaServer = mediaServerService.getMediaServerForMinimumLoad(null);
|
||||||
if (mediaServer == null) {
|
if (mediaServer == null) {
|
||||||
for (GeneralCallback<StreamInfo> errorCallback : errorCallbacks) {
|
for (GeneralCallback<StreamInfo> errorCallback : errorCallbacks) {
|
||||||
@ -354,7 +378,7 @@ public class jt1078ServiceImpl implements Ijt1078Service {
|
|||||||
}
|
}
|
||||||
String startTimeParam = DateUtil.yyyy_MM_dd_HH_mm_ssTo1078(startTime);
|
String startTimeParam = DateUtil.yyyy_MM_dd_HH_mm_ssTo1078(startTime);
|
||||||
String endTimeParam = DateUtil.yyyy_MM_dd_HH_mm_ssTo1078(endTime);
|
String endTimeParam = DateUtil.yyyy_MM_dd_HH_mm_ssTo1078(endTime);
|
||||||
String stream = phoneNumber + "_" + channelId + "_" + startTimeParam + "_" + endTimeParam;
|
String stream = "jt_" + phoneNumber + "_" + channelId + "_" + startTimeParam + "_" + endTimeParam;
|
||||||
MediaServer mediaServer = mediaServerService.getMediaServerForMinimumLoad(null);
|
MediaServer mediaServer = mediaServerService.getMediaServerForMinimumLoad(null);
|
||||||
if (mediaServer == null) {
|
if (mediaServer == null) {
|
||||||
for (GeneralCallback<StreamInfo> errorCallback : errorCallbacks) {
|
for (GeneralCallback<StreamInfo> errorCallback : errorCallbacks) {
|
||||||
|
|||||||
@ -10,6 +10,7 @@ import com.genersoft.iot.vmp.gb28181.bean.*;
|
|||||||
import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
|
import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
|
||||||
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander;
|
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander;
|
||||||
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
|
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
|
||||||
|
import com.genersoft.iot.vmp.jt1078.service.Ijt1078Service;
|
||||||
import com.genersoft.iot.vmp.media.bean.MediaServer;
|
import com.genersoft.iot.vmp.media.bean.MediaServer;
|
||||||
import com.genersoft.iot.vmp.media.bean.ResultForOnPublish;
|
import com.genersoft.iot.vmp.media.bean.ResultForOnPublish;
|
||||||
import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo;
|
import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo;
|
||||||
@ -72,6 +73,9 @@ public class MediaServiceImpl implements IMediaService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ISIPCommander commander;
|
private ISIPCommander commander;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private Ijt1078Service ijt1078Service;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean authenticatePlay(String app, String stream, String callId) {
|
public boolean authenticatePlay(String app, String stream, String callId) {
|
||||||
if (app == null || stream == null) {
|
if (app == null || stream == null) {
|
||||||
@ -267,10 +271,18 @@ public class MediaServiceImpl implements IMediaService {
|
|||||||
inviteInfo.getChannelId(), inviteInfo.getStream());
|
inviteInfo.getChannelId(), inviteInfo.getStream());
|
||||||
storager.stopPlay(inviteInfo.getDeviceId(), inviteInfo.getChannelId());
|
storager.stopPlay(inviteInfo.getDeviceId(), inviteInfo.getChannelId());
|
||||||
return result;
|
return result;
|
||||||
|
}else {
|
||||||
|
// 判断是否是1078点播
|
||||||
|
if (stream.startsWith("jt_")) {
|
||||||
|
String[] streamParamArray = stream.split("_");
|
||||||
|
if (streamParamArray.length == 3) {
|
||||||
|
ijt1078Service.stopPlay(streamParamArray[1], Integer.parseInt(streamParamArray[2]));
|
||||||
|
}else if (streamParamArray.length == 5) {
|
||||||
|
ijt1078Service.stopPlayback(streamParamArray[1], Integer.parseInt(streamParamArray[2]));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (stream.startsWith("1078")) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
SendRtpItem sendRtpItem = redisCatchStorage.querySendRTPServer(null, null, stream, null);
|
SendRtpItem sendRtpItem = redisCatchStorage.querySendRTPServer(null, null, stream, null);
|
||||||
if (sendRtpItem != null && "talk".equals(sendRtpItem.getApp() )) {
|
if (sendRtpItem != null && "talk".equals(sendRtpItem.getApp() )) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user