视频回放的接口返回值类型从StreamInfo修改为StreamContent,之前播放改了回放没改

This commit is contained in:
xuhong 2022-12-14 10:50:52 +08:00
parent 1516991372
commit fcb509c1f4
5 changed files with 33 additions and 29 deletions

View File

@ -12,6 +12,7 @@ import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
import com.genersoft.iot.vmp.service.bean.InviteTimeOutCallback;
import com.genersoft.iot.vmp.service.bean.PlayBackCallback;
import com.genersoft.iot.vmp.service.bean.SSRCInfo;
import com.genersoft.iot.vmp.vmanager.bean.StreamContent;
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
import org.springframework.web.context.request.async.DeferredResult;
@ -35,15 +36,15 @@ public interface IPlayService {
void onPublishHandlerForDownload(InviteStreamInfo inviteStreamInfo, String deviceId, String channelId, String toString);
DeferredResult<WVPResult<StreamInfo>> playBack(String deviceId, String channelId, String startTime, String endTime, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack);
DeferredResult<WVPResult<StreamInfo>> playBack(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo,String deviceId, String channelId, String startTime, String endTime, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack);
DeferredResult<WVPResult<StreamContent>> playBack(String deviceId, String channelId, String startTime, String endTime, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack);
DeferredResult<WVPResult<StreamContent>> playBack(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, String deviceId, String channelId, String startTime, String endTime, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack);
void zlmServerOffline(String mediaServerId);
DeferredResult<WVPResult<StreamInfo>> download(String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack);
DeferredResult<WVPResult<StreamInfo>> download(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo,String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack);
DeferredResult<WVPResult<StreamContent>> download(String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack);
DeferredResult<WVPResult<StreamContent>> download(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo,String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack);
StreamInfo getDownLoadInfo(String deviceId, String channelId, String stream);
StreamContent getDownLoadInfo(String deviceId, String channelId, String stream);
void zlmServerOnline(String mediaServerId);

View File

@ -35,6 +35,7 @@ import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import com.genersoft.iot.vmp.utils.DateUtil;
import com.genersoft.iot.vmp.utils.redis.RedisUtil;
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
import com.genersoft.iot.vmp.vmanager.bean.StreamContent;
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -427,9 +428,9 @@ public class PlayServiceImpl implements IPlayService {
}
@Override
public DeferredResult<WVPResult<StreamInfo>> playBack(String deviceId, String channelId, String startTime,
String endTime, InviteStreamCallback inviteStreamCallback,
PlayBackCallback callback) {
public DeferredResult<WVPResult<StreamContent>> playBack(String deviceId, String channelId, String startTime,
String endTime, InviteStreamCallback inviteStreamCallback,
PlayBackCallback callback) {
Device device = storager.queryVideoDevice(deviceId);
if (device == null) {
return null;
@ -441,7 +442,7 @@ public class PlayServiceImpl implements IPlayService {
}
@Override
public DeferredResult<WVPResult<StreamInfo>> playBack(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo,
public DeferredResult<WVPResult<StreamContent>> playBack(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo,
String deviceId, String channelId, String startTime,
String endTime, InviteStreamCallback infoCallBack,
PlayBackCallback playBackCallback) {
@ -454,8 +455,8 @@ public class PlayServiceImpl implements IPlayService {
if (device == null) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "设备: " + deviceId + "不存在");
}
DeferredResult<WVPResult<StreamInfo>> result = new DeferredResult<>(30000L);
resultHolder.put(DeferredResultHolder.CALLBACK_CMD_PLAYBACK + deviceId + channelId, uuid, result);
DeferredResult<WVPResult<StreamContent>> result = new DeferredResult<>(30000L);
resultHolder.put(key, uuid, result);
RequestMessage requestMessage = new RequestMessage();
requestMessage.setId(uuid);
requestMessage.setKey(key);
@ -481,7 +482,7 @@ public class PlayServiceImpl implements IPlayService {
// 回复之前所有的点播请求
playBackCallback.call(playBackResult);
result.setResult(WVPResult.fail(ErrorCode.ERROR100.getCode(), "回放超时"));
resultHolder.exist(DeferredResultHolder.CALLBACK_CMD_PLAYBACK + deviceId + channelId, uuid);
resultHolder.exist(key, uuid);
}, userSetting.getPlayTimeout());
SipSubscribe.Event errorEvent = event -> {
@ -507,7 +508,7 @@ public class PlayServiceImpl implements IPlayService {
return;
}
redisCatchStorage.startPlayback(streamInfo, inviteStreamInfo.getCallId());
WVPResult<StreamInfo> success = WVPResult.success(streamInfo);
WVPResult<StreamContent> success = WVPResult.success(new StreamContent(streamInfo));
requestMessage.setData(success);
playBackResult.setCode(ErrorCode.SUCCESS.getCode());
playBackResult.setMsg(ErrorCode.SUCCESS.getMsg());
@ -584,7 +585,7 @@ public class PlayServiceImpl implements IPlayService {
@Override
public DeferredResult<WVPResult<StreamInfo>> download(String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack) {
public DeferredResult<WVPResult<StreamContent>> download(String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack) {
Device device = storager.queryVideoDevice(deviceId);
if (device == null) {
return null;
@ -596,13 +597,13 @@ public class PlayServiceImpl implements IPlayService {
}
@Override
public DeferredResult<WVPResult<StreamInfo>> download(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack) {
public DeferredResult<WVPResult<StreamContent>> download(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack) {
if (mediaServerItem == null || ssrcInfo == null) {
return null;
}
String uuid = UUID.randomUUID().toString();
String key = DeferredResultHolder.CALLBACK_CMD_DOWNLOAD + deviceId + channelId;
DeferredResult<WVPResult<StreamInfo>> result = new DeferredResult<>(30000L);
DeferredResult<WVPResult<StreamContent>> result = new DeferredResult<>(30000L);
Device device = storager.queryVideoDevice(deviceId);
if (device == null) {
throw new ControllerException(ErrorCode.ERROR400.getCode(), "设备:" + deviceId + "不存在");
@ -612,7 +613,7 @@ public class PlayServiceImpl implements IPlayService {
RequestMessage requestMessage = new RequestMessage();
requestMessage.setId(uuid);
requestMessage.setKey(key);
WVPResult<StreamInfo> wvpResult = new WVPResult<>();
WVPResult<StreamContent> wvpResult = new WVPResult<>();
requestMessage.setData(wvpResult);
PlayBackResult<RequestMessage> downloadResult = new PlayBackResult<>();
downloadResult.setData(requestMessage);
@ -662,7 +663,7 @@ public class PlayServiceImpl implements IPlayService {
redisCatchStorage.startDownload(streamInfo, inviteStreamInfo.getCallId());
wvpResult.setCode(ErrorCode.SUCCESS.getCode());
wvpResult.setMsg(ErrorCode.SUCCESS.getMsg());
wvpResult.setData(streamInfo);
wvpResult.setData(new StreamContent(streamInfo));
downloadResult.setCode(ErrorCode.SUCCESS.getCode());
downloadResult.setMsg(ErrorCode.SUCCESS.getMsg());
downloadResult.setMediaServerItem(inviteStreamInfo.getMediaServerItem());
@ -680,11 +681,11 @@ public class PlayServiceImpl implements IPlayService {
}
@Override
public StreamInfo getDownLoadInfo(String deviceId, String channelId, String stream) {
public StreamContent getDownLoadInfo(String deviceId, String channelId, String stream) {
StreamInfo streamInfo = redisCatchStorage.queryDownload(deviceId, channelId, stream, null);
if (streamInfo != null) {
if (streamInfo.getProgress() == 1) {
return streamInfo;
return new StreamContent(streamInfo);
}
// 获取当前已下载时长
@ -716,7 +717,7 @@ public class PlayServiceImpl implements IPlayService {
}
}
}
return streamInfo;
return new StreamContent(streamInfo);
}
@Override

View File

@ -10,6 +10,7 @@ import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.service.IPlayService;
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
import com.genersoft.iot.vmp.vmanager.bean.StreamContent;
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
@ -68,8 +69,8 @@ public class PlaybackController {
@Parameter(name = "startTime", description = "开始时间", required = true)
@Parameter(name = "endTime", description = "结束时间", required = true)
@GetMapping("/start/{deviceId}/{channelId}")
public DeferredResult<WVPResult<StreamInfo>> play(@PathVariable String deviceId, @PathVariable String channelId,
String startTime, String endTime) {
public DeferredResult<WVPResult<StreamContent>> play(@PathVariable String deviceId, @PathVariable String channelId,
String startTime, String endTime) {
if (logger.isDebugEnabled()) {
logger.debug(String.format("设备回放 API调用deviceId%s channelId%s", deviceId, channelId));

View File

@ -8,6 +8,7 @@ import com.genersoft.iot.vmp.service.IDeviceService;
import com.genersoft.iot.vmp.service.IPlayService;
import com.genersoft.iot.vmp.utils.DateUtil;
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
import com.genersoft.iot.vmp.vmanager.bean.StreamContent;
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
import io.swagger.v3.oas.annotations.Operation;
@ -121,14 +122,14 @@ public class GBRecordController {
@Parameter(name = "endTime", description = "结束时间", required = true)
@Parameter(name = "downloadSpeed", description = "下载倍速", required = true)
@GetMapping("/download/start/{deviceId}/{channelId}")
public DeferredResult<WVPResult<StreamInfo>> download(@PathVariable String deviceId, @PathVariable String channelId,
String startTime, String endTime, String downloadSpeed) {
public DeferredResult<WVPResult<StreamContent>> download(@PathVariable String deviceId, @PathVariable String channelId,
String startTime, String endTime, String downloadSpeed) {
if (logger.isDebugEnabled()) {
logger.debug(String.format("历史媒体下载 API调用deviceId%schannelId%sdownloadSpeed%s", deviceId, channelId, downloadSpeed));
}
DeferredResult<WVPResult<StreamInfo>> result = playService.download(deviceId, channelId, startTime, endTime, Integer.parseInt(downloadSpeed), null, hookCallBack->{
DeferredResult<WVPResult<StreamContent>> result = playService.download(deviceId, channelId, startTime, endTime, Integer.parseInt(downloadSpeed), null, hookCallBack->{
resultHolder.invokeResult(hookCallBack.getData());
});
@ -168,7 +169,7 @@ public class GBRecordController {
@Parameter(name = "channelId", description = "通道国标编号", required = true)
@Parameter(name = "stream", description = "流ID", required = true)
@GetMapping("/download/progress/{deviceId}/{channelId}/{stream}")
public StreamInfo getProgress(@PathVariable String deviceId, @PathVariable String channelId, @PathVariable String stream) {
public StreamContent getProgress(@PathVariable String deviceId, @PathVariable String channelId, @PathVariable String stream) {
return playService.getDownLoadInfo(deviceId, channelId, stream);
}
}

View File

@ -140,9 +140,9 @@ export default {
if (res.data.code === 0 && res.data.data) {
let videoUrl;
if (location.protocol === "https:") {
videoUrl = res.data.data.wss_flv.url;
videoUrl = res.data.data.wss_flv;
} else {
videoUrl = res.data.data.ws_flv.url;
videoUrl = res.data.data.ws_flv;
}
itemData.playUrl = videoUrl;
that.setPlayUrl(videoUrl, idxTmp);