调整
This commit is contained in:
parent
971e9c2589
commit
f23b64038d
@ -40,6 +40,7 @@ import javax.sip.header.CallIdHeader;
|
|||||||
import javax.sip.message.Request;
|
import javax.sip.message.Request;
|
||||||
import javax.sip.message.Response;
|
import javax.sip.message.Response;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.concurrent.Flow;
|
import java.util.concurrent.Flow;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@ -59,6 +60,17 @@ public class PlayService {
|
|||||||
return StringUtils.joinWith("/", zlmMediaConfig.getUrl(),"rtp", streamId + ".live.flv");
|
return StringUtils.joinWith("/", zlmMediaConfig.getUrl(),"rtp", streamId + ".live.flv");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private DeferredResult<JsonResponse<String>> makeResult(String deviceId, String channelId, long timeout, DockingDevice device) {
|
||||||
|
DeferredResult<JsonResponse<String>> result = new DeferredResult<>(TimeUnit.SECONDS.toMillis(timeout));
|
||||||
|
if (device == null) {
|
||||||
|
log.info("未能找到 编码为 => {} 的设备", deviceId);
|
||||||
|
result.setResult(JsonResponse.error(null, "未找到设备"));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 实时视频点播
|
* 实时视频点播
|
||||||
* @param deviceId 设备id
|
* @param deviceId 设备id
|
||||||
@ -66,11 +78,9 @@ public class PlayService {
|
|||||||
*/
|
*/
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
public DeferredResult<JsonResponse<String>> realTimePlay(String deviceId, String channelId, long timeout){
|
public DeferredResult<JsonResponse<String>> realTimePlay(String deviceId, String channelId, long timeout){
|
||||||
DeferredResult<JsonResponse<String>> result = new DeferredResult<>(TimeUnit.SECONDS.toMillis(timeout));
|
|
||||||
DockingDevice device = deviceService.getDevice(deviceId);
|
DockingDevice device = deviceService.getDevice(deviceId);
|
||||||
if (device == null) {
|
DeferredResult<JsonResponse<String>> result = makeResult(deviceId,channelId,timeout, device);
|
||||||
log.info("未能找到 编码为 => {} 的设备", deviceId);
|
if(result.hasResult()){
|
||||||
result.setResult(JsonResponse.error(null, "未找到设备"));
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,7 +93,7 @@ public class PlayService {
|
|||||||
|
|
||||||
GetRtpInfoResp rtpInfo = zlmMediaService.getRtpInfo(streamId);
|
GetRtpInfoResp rtpInfo = zlmMediaService.getRtpInfo(streamId);
|
||||||
if(rtpInfo.getExist()){
|
if(rtpInfo.getExist()){
|
||||||
result.setResult(JsonResponse.error(MessageFormat.format("实时流 {0} 已存在", streamId)));
|
result.setResult(JsonResponse.error(MessageFormat.format("流 {0} 已存在", streamId)));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,4 +198,23 @@ public class PlayService {
|
|||||||
RedisUtil.KeyOps.delete(key);
|
RedisUtil.KeyOps.delete(key);
|
||||||
return JsonResponse.success(null);
|
return JsonResponse.success(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SneakyThrows
|
||||||
|
public DeferredResult<JsonResponse<String>> recordPlay(String deviceId, String channelId, Date startTime, Date endTime, long timeout){
|
||||||
|
DockingDevice device = deviceService.getDevice(deviceId);
|
||||||
|
long start = startTime.toInstant().getEpochSecond();
|
||||||
|
long end = endTime.toInstant().getEpochSecond();
|
||||||
|
String streamId = MediaSdpHelper.getStreamId(deviceId,channelId,String.valueOf(start), String.valueOf(end));
|
||||||
|
DeferredResult<JsonResponse<String>> result = makeResult(deviceId,channelId,timeout,device);
|
||||||
|
if(result.hasResult()){
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
String key = CacheUtil.getKey(MediaSdpHelper.Action.PLAY_BACK.getAction(), deviceId, channelId);
|
||||||
|
if(RedisUtil.KeyOps.hasKey(key)){
|
||||||
|
result.setResult(JsonResponse.success(videoUrl(streamId)));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user