|
@@ -191,11 +191,17 @@ public class VideoDeviceService {
|
|
|
session.setStatus("ACTIVE");
|
|
session.setStatus("ACTIVE");
|
|
|
session.setGbDeviceId(row.getGbDeviceId());
|
|
session.setGbDeviceId(row.getGbDeviceId());
|
|
|
session.setGbChannelId(row.getGbChannelId());
|
|
session.setGbChannelId(row.getGbChannelId());
|
|
|
- session.setStreamId((String)data.get("stream"));
|
|
|
|
|
- session.setProxyKey((String)data.remove("proxyKey"));
|
|
|
|
|
|
|
+ session.setStreamId(data.get("stream") instanceof String?(String)data.get("stream"):null);
|
|
|
|
|
+ Object proxyKey=data.remove("proxyKey");
|
|
|
|
|
+ session.setProxyKey(proxyKey instanceof String?(String)proxyKey:null);
|
|
|
session.setCreateTime(LocalDateTime.now(clock));
|
|
session.setCreateTime(LocalDateTime.now(clock));
|
|
|
session.setLastSeen(session.getCreateTime());
|
|
session.setLastSeen(session.getCreateTime());
|
|
|
try {
|
|
try {
|
|
|
|
|
+ if(!List.of("url","flv","https_flv","ws_flv","wss_flv","hls","https_hls","webrtc").stream()
|
|
|
|
|
+ .map(data::get).anyMatch(VideoDeviceService::isPlayableAddress))throw new ServiceException("媒体服务没有返回有效播放地址");
|
|
|
|
|
+ if(GB28181.equals(row.getSourceType())||!Boolean.TRUE.equals(data.get("native")))safeStream(session.getStreamId());
|
|
|
|
|
+ if(!GB28181.equals(row.getSourceType())&&!Boolean.TRUE.equals(data.get("native"))&&session.getProxyKey()==null)
|
|
|
|
|
+ throw new ServiceException("媒体服务没有返回代理清理标识");
|
|
|
if(sessions.insert(session)!=1)throw new ServiceException("播放会话登记失败");
|
|
if(sessions.insert(session)!=1)throw new ServiceException("播放会话登记失败");
|
|
|
} catch(RuntimeException registrationFailure) {
|
|
} catch(RuntimeException registrationFailure) {
|
|
|
try { stopMedia(session,existingLive); }
|
|
try { stopMedia(session,existingLive); }
|
|
@@ -243,6 +249,14 @@ public class VideoDeviceService {
|
|
|
return s;
|
|
return s;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private static boolean isPlayableAddress(Object value) {
|
|
|
|
|
+ if(!(value instanceof String))return false;
|
|
|
|
|
+ try {
|
|
|
|
|
+ URI uri=URI.create((String)value);
|
|
|
|
|
+ return uri.getHost()!=null&&Set.of("http","https","ws","wss").contains(uri.getScheme());
|
|
|
|
|
+ } catch(IllegalArgumentException invalid) { return false; }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private static String tokenHash(String token) {
|
|
private static String tokenHash(String token) {
|
|
|
try {
|
|
try {
|
|
|
return Base64.getUrlEncoder().withoutPadding().encodeToString(
|
|
return Base64.getUrlEncoder().withoutPadding().encodeToString(
|