修复回看控制失效 #619
parent
386b48192d
commit
a4f48a1522
|
@ -39,6 +39,8 @@ public class StreamInfo {
|
||||||
private String endTime;
|
private String endTime;
|
||||||
private double progress;
|
private double progress;
|
||||||
|
|
||||||
|
private boolean pause;
|
||||||
|
|
||||||
public static class TransactionInfo{
|
public static class TransactionInfo{
|
||||||
public String callId;
|
public String callId;
|
||||||
public String localTag;
|
public String localTag;
|
||||||
|
@ -312,4 +314,12 @@ public class StreamInfo {
|
||||||
public void setRtcs(String rtcs) {
|
public void setRtcs(String rtcs) {
|
||||||
this.rtcs = rtcs;
|
this.rtcs = rtcs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isPause() {
|
||||||
|
return pause;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPause(boolean pause) {
|
||||||
|
this.pause = pause;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
package com.genersoft.iot.vmp.conf.exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author lin
|
||||||
|
*/
|
||||||
|
public class ServiceException extends Exception{
|
||||||
|
private String msg;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public ServiceException(String msg) {
|
||||||
|
this.msg = msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMsg() {
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMsg(String msg) {
|
||||||
|
this.msg = msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMessage() {
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
}
|
|
@ -39,12 +39,12 @@ public class SsrcTransactionNotFoundException extends Exception{
|
||||||
@Override
|
@Override
|
||||||
public String getMessage() {
|
public String getMessage() {
|
||||||
StringBuffer msg = new StringBuffer();
|
StringBuffer msg = new StringBuffer();
|
||||||
msg.append(StringFormatter.format("缓存事务信息未找到,device:%s channel: %s ", deviceId, channelId));
|
msg.append(String.format("缓存事务信息未找到,device:%s channel: %s ", deviceId, channelId));
|
||||||
if (callId != null) {
|
if (callId != null) {
|
||||||
msg.append("callId: " + callId);
|
msg.append(",callId: " + callId);
|
||||||
}
|
}
|
||||||
if (stream != null) {
|
if (stream != null) {
|
||||||
msg.append("stream: " + stream);
|
msg.append(",stream: " + stream);
|
||||||
}
|
}
|
||||||
return msg.toString();
|
return msg.toString();
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,6 +129,7 @@ public interface ISIPCommander {
|
||||||
* 视频流停止
|
* 视频流停止
|
||||||
*/
|
*/
|
||||||
void streamByeCmd(Device device, String channelId, String stream, String callId, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException, SsrcTransactionNotFoundException;
|
void streamByeCmd(Device device, String channelId, String stream, String callId, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException, SsrcTransactionNotFoundException;
|
||||||
|
|
||||||
void streamByeCmd(Device device, String channelId, String stream, String callId) throws InvalidArgumentException, ParseException, SipException, SsrcTransactionNotFoundException;
|
void streamByeCmd(Device device, String channelId, String stream, String callId) throws InvalidArgumentException, ParseException, SipException, SsrcTransactionNotFoundException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -521,10 +521,15 @@ public class ZLMHttpHookListener {
|
||||||
if (sendRtpItem.getApp().equals(app)) {
|
if (sendRtpItem.getApp().equals(app)) {
|
||||||
String platformId = sendRtpItem.getPlatformId();
|
String platformId = sendRtpItem.getPlatformId();
|
||||||
ParentPlatform platform = storager.queryParentPlatByServerGBId(platformId);
|
ParentPlatform platform = storager.queryParentPlatByServerGBId(platformId);
|
||||||
|
Device device = deviceService.queryDevice(platformId);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
commanderFroPlatform.streamByeCmd(platform, sendRtpItem);
|
if (platform != null) {
|
||||||
} catch (SipException | InvalidArgumentException | ParseException e) {
|
commanderFroPlatform.streamByeCmd(platform, sendRtpItem);
|
||||||
|
}else {
|
||||||
|
cmder.streamByeCmd(device, sendRtpItem.getChannelId(), stream, sendRtpItem.getCallId());
|
||||||
|
}
|
||||||
|
} catch (SipException | InvalidArgumentException | ParseException | SsrcTransactionNotFoundException e) {
|
||||||
logger.error("[命令发送失败] 国标级联 发送BYE: {}", e.getMessage());
|
logger.error("[命令发送失败] 国标级联 发送BYE: {}", e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -587,19 +592,24 @@ public class ZLMHttpHookListener {
|
||||||
storager.stopPlay(streamInfoForPlayCatch.getDeviceID(), streamInfoForPlayCatch.getChannelId());
|
storager.stopPlay(streamInfoForPlayCatch.getDeviceID(), streamInfoForPlayCatch.getChannelId());
|
||||||
}else{
|
}else{
|
||||||
StreamInfo streamInfoForPlayBackCatch = redisCatchStorage.queryPlayback(null, null, streamId, null);
|
StreamInfo streamInfoForPlayBackCatch = redisCatchStorage.queryPlayback(null, null, streamId, null);
|
||||||
if (streamInfoForPlayBackCatch != null) {
|
if (streamInfoForPlayBackCatch != null ) {
|
||||||
Device device = deviceService.queryDevice(streamInfoForPlayCatch.getDeviceID());
|
if (streamInfoForPlayBackCatch.isPause()) {
|
||||||
if (device != null) {
|
ret.put("close", false);
|
||||||
try {
|
}else {
|
||||||
cmder.streamByeCmd(device,streamInfoForPlayBackCatch.getChannelId(),
|
Device device = deviceService.queryDevice(streamInfoForPlayBackCatch.getDeviceID());
|
||||||
streamInfoForPlayBackCatch.getStream(), null);
|
if (device != null) {
|
||||||
} catch (InvalidArgumentException | ParseException | SipException |
|
try {
|
||||||
SsrcTransactionNotFoundException e) {
|
cmder.streamByeCmd(device,streamInfoForPlayBackCatch.getChannelId(),
|
||||||
logger.error("[无人观看]回放, 发送BYE失败 {}", e.getMessage());
|
streamInfoForPlayBackCatch.getStream(), null);
|
||||||
|
} catch (InvalidArgumentException | ParseException | SipException |
|
||||||
|
SsrcTransactionNotFoundException e) {
|
||||||
|
logger.error("[无人观看]回放, 发送BYE失败 {}", e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
redisCatchStorage.stopPlayback(streamInfoForPlayBackCatch.getDeviceID(),
|
||||||
|
streamInfoForPlayBackCatch.getChannelId(), streamInfoForPlayBackCatch.getStream(), null);
|
||||||
}
|
}
|
||||||
redisCatchStorage.stopPlayback(streamInfoForPlayBackCatch.getDeviceID(),
|
|
||||||
streamInfoForPlayBackCatch.getChannelId(), streamInfoForPlayBackCatch.getStream(), null);
|
|
||||||
}else {
|
}else {
|
||||||
StreamInfo streamInfoForDownload = redisCatchStorage.queryDownload(null, null, streamId, null);
|
StreamInfo streamInfoForDownload = redisCatchStorage.queryDownload(null, null, streamId, null);
|
||||||
// 进行录像下载时无人观看不断流
|
// 进行录像下载时无人观看不断流
|
||||||
|
|
|
@ -23,6 +23,9 @@ public class ZLMRESTfulUtils {
|
||||||
|
|
||||||
private final static Logger logger = LoggerFactory.getLogger(ZLMRESTfulUtils.class);
|
private final static Logger logger = LoggerFactory.getLogger(ZLMRESTfulUtils.class);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public interface RequestCallback{
|
public interface RequestCallback{
|
||||||
void run(JSONObject response);
|
void run(JSONObject response);
|
||||||
}
|
}
|
||||||
|
@ -322,10 +325,22 @@ public class ZLMRESTfulUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getSnap(MediaServerItem mediaServerItem, String flvUrl, int timeout_sec, int expire_sec, String targetPath, String fileName) {
|
public void getSnap(MediaServerItem mediaServerItem, String flvUrl, int timeout_sec, int expire_sec, String targetPath, String fileName) {
|
||||||
Map<String, Object> param = new HashMap<>();
|
Map<String, Object> param = new HashMap<>(3);
|
||||||
param.put("url", flvUrl);
|
param.put("url", flvUrl);
|
||||||
param.put("timeout_sec", timeout_sec);
|
param.put("timeout_sec", timeout_sec);
|
||||||
param.put("expire_sec", expire_sec);
|
param.put("expire_sec", expire_sec);
|
||||||
sendGetForImg(mediaServerItem, "getSnap", param, targetPath, fileName);
|
sendGetForImg(mediaServerItem, "getSnap", param, targetPath, fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public JSONObject pauseRtpCheck(MediaServerItem mediaServerItem, String streamId) {
|
||||||
|
Map<String, Object> param = new HashMap<>(1);
|
||||||
|
param.put("stream_id", streamId);
|
||||||
|
return sendPost(mediaServerItem, "pauseRtpCheck",param, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public JSONObject resumeRtpCheck(MediaServerItem mediaServerItem, String streamId) {
|
||||||
|
Map<String, Object> param = new HashMap<>(1);
|
||||||
|
param.put("stream_id", streamId);
|
||||||
|
return sendPost(mediaServerItem, "resumeRtpCheck",param, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,7 +103,6 @@ public class ZLMRTPServerFactory {
|
||||||
param.put("stream_id", streamId);
|
param.put("stream_id", streamId);
|
||||||
JSONObject jsonObject = zlmresTfulUtils.closeRtpServer(mediaServerItem, param);
|
JSONObject jsonObject = zlmresTfulUtils.closeRtpServer(mediaServerItem, param);
|
||||||
if (jsonObject != null ) {
|
if (jsonObject != null ) {
|
||||||
System.out.println(jsonObject);
|
|
||||||
if (jsonObject.getInteger("code") == 0) {
|
if (jsonObject.getInteger("code") == 0) {
|
||||||
return createRTPServer(mediaServerItem, streamId, ssrc, port);
|
return createRTPServer(mediaServerItem, streamId, ssrc, port);
|
||||||
}else {
|
}else {
|
||||||
|
@ -150,7 +149,6 @@ public class ZLMRTPServerFactory {
|
||||||
param.put("stream_id", streamId);
|
param.put("stream_id", streamId);
|
||||||
JSONObject jsonObject = zlmresTfulUtils.closeRtpServer(serverItem, param);
|
JSONObject jsonObject = zlmresTfulUtils.closeRtpServer(serverItem, param);
|
||||||
if (jsonObject != null ) {
|
if (jsonObject != null ) {
|
||||||
System.out.println(jsonObject);
|
|
||||||
if (jsonObject.getInteger("code") == 0) {
|
if (jsonObject.getInteger("code") == 0) {
|
||||||
result = jsonObject.getInteger("hit") == 1;
|
result = jsonObject.getInteger("hit") == 1;
|
||||||
}else {
|
}else {
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.genersoft.iot.vmp.service;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.genersoft.iot.vmp.common.StreamInfo;
|
import com.genersoft.iot.vmp.common.StreamInfo;
|
||||||
|
import com.genersoft.iot.vmp.conf.exception.ServiceException;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.Device;
|
import com.genersoft.iot.vmp.gb28181.bean.Device;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.InviteStreamCallback;
|
import com.genersoft.iot.vmp.gb28181.bean.InviteStreamCallback;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.InviteStreamInfo;
|
import com.genersoft.iot.vmp.gb28181.bean.InviteStreamInfo;
|
||||||
|
@ -15,6 +16,10 @@ import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
|
||||||
import com.genersoft.iot.vmp.vmanager.gb28181.play.bean.PlayResult;
|
import com.genersoft.iot.vmp.vmanager.gb28181.play.bean.PlayResult;
|
||||||
import org.springframework.web.context.request.async.DeferredResult;
|
import org.springframework.web.context.request.async.DeferredResult;
|
||||||
|
|
||||||
|
import javax.sip.InvalidArgumentException;
|
||||||
|
import javax.sip.SipException;
|
||||||
|
import java.text.ParseException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 点播处理
|
* 点播处理
|
||||||
*/
|
*/
|
||||||
|
@ -42,4 +47,8 @@ public interface IPlayService {
|
||||||
StreamInfo getDownLoadInfo(String deviceId, String channelId, String stream);
|
StreamInfo getDownLoadInfo(String deviceId, String channelId, String stream);
|
||||||
|
|
||||||
void zlmServerOnline(String mediaServerId);
|
void zlmServerOnline(String mediaServerId);
|
||||||
|
|
||||||
|
void pauseRtp(String streamId) throws ServiceException, InvalidArgumentException, ParseException, SipException;
|
||||||
|
|
||||||
|
void resumeRtp(String streamId) throws ServiceException, InvalidArgumentException, ParseException, SipException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,10 +9,13 @@ import javax.sip.InvalidArgumentException;
|
||||||
import javax.sip.ResponseEvent;
|
import javax.sip.ResponseEvent;
|
||||||
import javax.sip.SipException;
|
import javax.sip.SipException;
|
||||||
|
|
||||||
|
import com.genersoft.iot.vmp.common.VideoManagerConstants;
|
||||||
import com.genersoft.iot.vmp.conf.exception.ControllerException;
|
import com.genersoft.iot.vmp.conf.exception.ControllerException;
|
||||||
|
import com.genersoft.iot.vmp.conf.exception.ServiceException;
|
||||||
import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException;
|
import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.*;
|
import com.genersoft.iot.vmp.gb28181.bean.*;
|
||||||
import com.genersoft.iot.vmp.service.IDeviceService;
|
import com.genersoft.iot.vmp.service.IDeviceService;
|
||||||
|
import com.genersoft.iot.vmp.utils.redis.RedisUtil;
|
||||||
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
|
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -822,4 +825,52 @@ public class PlayServiceImpl implements IPlayService {
|
||||||
// }
|
// }
|
||||||
// }));
|
// }));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void pauseRtp(String streamId) throws ServiceException, InvalidArgumentException, ParseException, SipException {
|
||||||
|
String key = redisCatchStorage.queryPlaybackForKey(null, null, streamId, null);
|
||||||
|
StreamInfo streamInfo = redisCatchStorage.queryPlayback(null, null, streamId, null);
|
||||||
|
if (null == streamInfo) {
|
||||||
|
logger.warn("streamId不存在!");
|
||||||
|
throw new ServiceException("streamId不存在");
|
||||||
|
}
|
||||||
|
streamInfo.setPause(true);
|
||||||
|
RedisUtil.set(key, streamInfo);
|
||||||
|
MediaServerItem mediaServerItem = mediaServerService.getOne(streamInfo.getMediaServerId());
|
||||||
|
if (null == mediaServerItem) {
|
||||||
|
logger.warn("mediaServer 不存在!");
|
||||||
|
throw new ServiceException("mediaServer不存在");
|
||||||
|
}
|
||||||
|
// zlm 暂停RTP超时检查
|
||||||
|
JSONObject jsonObject = zlmresTfulUtils.pauseRtpCheck(mediaServerItem, streamId);
|
||||||
|
if (jsonObject == null || jsonObject.getInteger("code") != 0) {
|
||||||
|
throw new ServiceException("暂停RTP接收失败");
|
||||||
|
}
|
||||||
|
Device device = storager.queryVideoDevice(streamInfo.getDeviceID());
|
||||||
|
cmder.playPauseCmd(device, streamInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void resumeRtp(String streamId) throws ServiceException, InvalidArgumentException, ParseException, SipException {
|
||||||
|
String key = redisCatchStorage.queryPlaybackForKey(null, null, streamId, null);
|
||||||
|
StreamInfo streamInfo = redisCatchStorage.queryPlayback(null, null, streamId, null);
|
||||||
|
if (null == streamInfo) {
|
||||||
|
logger.warn("streamId不存在!");
|
||||||
|
throw new ServiceException("streamId不存在");
|
||||||
|
}
|
||||||
|
streamInfo.setPause(false);
|
||||||
|
RedisUtil.set(key, streamInfo);
|
||||||
|
MediaServerItem mediaServerItem = mediaServerService.getOne(streamInfo.getMediaServerId());
|
||||||
|
if (null == mediaServerItem) {
|
||||||
|
logger.warn("mediaServer 不存在!");
|
||||||
|
throw new ServiceException("mediaServer不存在");
|
||||||
|
}
|
||||||
|
// zlm 暂停RTP超时检查
|
||||||
|
JSONObject jsonObject = zlmresTfulUtils.resumeRtpCheck(mediaServerItem, streamId);
|
||||||
|
if (jsonObject == null || jsonObject.getInteger("code") != 0) {
|
||||||
|
throw new ServiceException("继续RTP接收失败");
|
||||||
|
}
|
||||||
|
Device device = storager.queryVideoDevice(streamInfo.getDeviceID());
|
||||||
|
cmder.playResumeCmd(device, streamInfo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,6 +56,8 @@ public interface IRedisCatchStorage {
|
||||||
|
|
||||||
StreamInfo queryPlayback(String deviceId, String channelID, String stream, String callId);
|
StreamInfo queryPlayback(String deviceId, String channelID, String stream, String callId);
|
||||||
|
|
||||||
|
String queryPlaybackForKey(String deviceId, String channelId, String stream, String callId);
|
||||||
|
|
||||||
void updatePlatformCatchInfo(ParentPlatformCatch parentPlatformCatch);
|
void updatePlatformCatchInfo(ParentPlatformCatch parentPlatformCatch);
|
||||||
|
|
||||||
ParentPlatformCatch queryPlatformCatchInfo(String platformGbId);
|
ParentPlatformCatch queryPlatformCatchInfo(String platformGbId);
|
||||||
|
|
|
@ -9,7 +9,6 @@ import com.genersoft.iot.vmp.conf.UserSetting;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.*;
|
import com.genersoft.iot.vmp.gb28181.bean.*;
|
||||||
import com.genersoft.iot.vmp.media.zlm.dto.MediaItem;
|
import com.genersoft.iot.vmp.media.zlm.dto.MediaItem;
|
||||||
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
|
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
|
||||||
import com.genersoft.iot.vmp.media.zlm.dto.OnPublishHookParam;
|
|
||||||
import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo;
|
import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo;
|
||||||
import com.genersoft.iot.vmp.service.bean.GPSMsgInfo;
|
import com.genersoft.iot.vmp.service.bean.GPSMsgInfo;
|
||||||
import com.genersoft.iot.vmp.service.bean.MessageForPushChannel;
|
import com.genersoft.iot.vmp.service.bean.MessageForPushChannel;
|
||||||
|
@ -22,7 +21,6 @@ import com.genersoft.iot.vmp.utils.redis.RedisUtil;
|
||||||
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;
|
||||||
import org.springframework.context.annotation.DependsOn;
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
@ -127,6 +125,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public StreamInfo queryPlayByStreamId(String streamId) {
|
public StreamInfo queryPlayByStreamId(String streamId) {
|
||||||
|
System.out.println(String.format("%S_%s_%s_*", VideoManagerConstants.PLAYER_PREFIX, userSetting.getServerId(), streamId));
|
||||||
List<Object> playLeys = RedisUtil.scan(String.format("%S_%s_%s_*", VideoManagerConstants.PLAYER_PREFIX, userSetting.getServerId(), streamId));
|
List<Object> playLeys = RedisUtil.scan(String.format("%S_%s_%s_*", VideoManagerConstants.PLAYER_PREFIX, userSetting.getServerId(), streamId));
|
||||||
if (playLeys == null || playLeys.size() == 0) {
|
if (playLeys == null || playLeys.size() == 0) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -165,6 +164,8 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean startPlayback(StreamInfo stream, String callId) {
|
public boolean startPlayback(StreamInfo stream, String callId) {
|
||||||
|
System.out.println(String.format("%S_%s_%s_%s_%s_%s", VideoManagerConstants.PLAY_BLACK_PREFIX,
|
||||||
|
userSetting.getServerId(), stream.getDeviceID(), stream.getChannelId(), stream.getStream(), callId));
|
||||||
return RedisUtil.set(String.format("%S_%s_%s_%s_%s_%s", VideoManagerConstants.PLAY_BLACK_PREFIX,
|
return RedisUtil.set(String.format("%S_%s_%s_%s_%s_%s", VideoManagerConstants.PLAY_BLACK_PREFIX,
|
||||||
userSetting.getServerId(), stream.getDeviceID(), stream.getChannelId(), stream.getStream(), callId), stream);
|
userSetting.getServerId(), stream.getDeviceID(), stream.getChannelId(), stream.getStream(), callId), stream);
|
||||||
}
|
}
|
||||||
|
@ -285,6 +286,34 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String queryPlaybackForKey(String deviceId, String channelId, String stream, String callId) {
|
||||||
|
if (stream == null && callId == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (deviceId == null) {
|
||||||
|
deviceId = "*";
|
||||||
|
}
|
||||||
|
if (channelId == null) {
|
||||||
|
channelId = "*";
|
||||||
|
}
|
||||||
|
if (stream == null) {
|
||||||
|
stream = "*";
|
||||||
|
}
|
||||||
|
if (callId == null) {
|
||||||
|
callId = "*";
|
||||||
|
}
|
||||||
|
String key = String.format("%S_%s_%s_%s_%s_%s", VideoManagerConstants.PLAY_BLACK_PREFIX,
|
||||||
|
userSetting.getServerId(),
|
||||||
|
deviceId,
|
||||||
|
channelId,
|
||||||
|
stream,
|
||||||
|
callId
|
||||||
|
);
|
||||||
|
List<Object> streamInfoScan = RedisUtil.scan(key);
|
||||||
|
return (String) streamInfoScan.get(0);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updatePlatformCatchInfo(ParentPlatformCatch parentPlatformCatch) {
|
public void updatePlatformCatchInfo(ParentPlatformCatch parentPlatformCatch) {
|
||||||
String key = VideoManagerConstants.PLATFORM_CATCH_PREFIX + userSetting.getServerId() + "_" + parentPlatformCatch.getId();
|
String key = VideoManagerConstants.PLATFORM_CATCH_PREFIX + userSetting.getServerId() + "_" + parentPlatformCatch.getId();
|
||||||
|
|
|
@ -2,9 +2,11 @@ package com.genersoft.iot.vmp.vmanager.gb28181.playback;
|
||||||
|
|
||||||
import com.genersoft.iot.vmp.common.StreamInfo;
|
import com.genersoft.iot.vmp.common.StreamInfo;
|
||||||
import com.genersoft.iot.vmp.conf.exception.ControllerException;
|
import com.genersoft.iot.vmp.conf.exception.ControllerException;
|
||||||
|
import com.genersoft.iot.vmp.conf.exception.ServiceException;
|
||||||
import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException;
|
import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException;
|
||||||
import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
|
import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
|
||||||
import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
|
import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
|
||||||
|
import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory;
|
||||||
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
||||||
import com.genersoft.iot.vmp.service.IPlayService;
|
import com.genersoft.iot.vmp.service.IPlayService;
|
||||||
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
|
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
|
||||||
|
@ -45,6 +47,9 @@ public class PlaybackController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private SIPCommander cmder;
|
private SIPCommander cmder;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ZLMRTPServerFactory zlmrtpServerFactory;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IVideoManagerStorage storager;
|
private IVideoManagerStorage storager;
|
||||||
|
|
||||||
|
@ -113,14 +118,11 @@ public class PlaybackController {
|
||||||
@GetMapping("/pause/{streamId}")
|
@GetMapping("/pause/{streamId}")
|
||||||
public void playPause(@PathVariable String streamId) {
|
public void playPause(@PathVariable String streamId) {
|
||||||
logger.info("playPause: "+streamId);
|
logger.info("playPause: "+streamId);
|
||||||
StreamInfo streamInfo = redisCatchStorage.queryPlayback(null, null, streamId, null);
|
|
||||||
if (null == streamInfo) {
|
|
||||||
logger.warn("streamId不存在!");
|
|
||||||
throw new ControllerException(ErrorCode.ERROR400.getCode(), "streamId不存在");
|
|
||||||
}
|
|
||||||
Device device = storager.queryVideoDevice(streamInfo.getDeviceID());
|
|
||||||
try {
|
try {
|
||||||
cmder.playPauseCmd(device, streamInfo);
|
playService.pauseRtp(streamId);
|
||||||
|
} catch (ServiceException e) {
|
||||||
|
throw new ControllerException(ErrorCode.ERROR400.getCode(), e.getMessage());
|
||||||
} catch (InvalidArgumentException | ParseException | SipException e) {
|
} catch (InvalidArgumentException | ParseException | SipException e) {
|
||||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), e.getMessage());
|
throw new ControllerException(ErrorCode.ERROR100.getCode(), e.getMessage());
|
||||||
}
|
}
|
||||||
|
@ -132,14 +134,10 @@ public class PlaybackController {
|
||||||
@GetMapping("/resume/{streamId}")
|
@GetMapping("/resume/{streamId}")
|
||||||
public void playResume(@PathVariable String streamId) {
|
public void playResume(@PathVariable String streamId) {
|
||||||
logger.info("playResume: "+streamId);
|
logger.info("playResume: "+streamId);
|
||||||
StreamInfo streamInfo = redisCatchStorage.queryPlayback(null, null, streamId, null);
|
|
||||||
if (null == streamInfo) {
|
|
||||||
logger.warn("streamId不存在!");
|
|
||||||
throw new ControllerException(ErrorCode.ERROR400.getCode(), "streamId不存在");
|
|
||||||
}
|
|
||||||
Device device = storager.queryVideoDevice(streamInfo.getDeviceID());
|
|
||||||
try {
|
try {
|
||||||
cmder.playResumeCmd(device, streamInfo);
|
playService.resumeRtp(streamId);
|
||||||
|
} catch (ServiceException e) {
|
||||||
|
throw new ControllerException(ErrorCode.ERROR400.getCode(), e.getMessage());
|
||||||
} catch (InvalidArgumentException | ParseException | SipException e) {
|
} catch (InvalidArgumentException | ParseException | SipException e) {
|
||||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), e.getMessage());
|
throw new ControllerException(ErrorCode.ERROR100.getCode(), e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue