更新MediaStreamUtil中的应用常量,统一使用RTP_APP替代GB28181,调整相关逻辑以支持单端口收流

This commit is contained in:
lin 2026-04-13 23:05:14 +08:00
parent e88d26b1e9
commit ab3d0da115
15 changed files with 124 additions and 92 deletions

View File

@ -1,17 +1,62 @@
package com.genersoft.iot.vmp.common.enums; package com.genersoft.iot.vmp.common.enums;
public class MediaStreamUtil { public class MediaStreamUtil {
public final static String RTPServerApp = "rtp"; public final static String RTP_APP = "rtp";
public final static String GB28181 = "rtp"; public final static String RTP_STREAM_REST_PREFIX = "s";
public final static String GB28181_TALK = "talk"; public final static String GB28181_TALK = "talk";
public final static String GB28181_BROADCAST = "broadcast"; public final static String GB28181_BROADCAST = "broadcast";
public final static String JT1078 = "1078";
public final static String JT_TALK = "jt_talk";
public final static String JT1078_STREAM_PREFIX = RTP_STREAM_REST_PREFIX + "_jt";
public final static String JT1078_STREAM_PLAY_PREFIX = RTP_STREAM_REST_PREFIX + "_jt_play";
public final static String JT1078_STREAM_PLAYBACK_PREFIX = RTP_STREAM_REST_PREFIX + "_jt_playback";
public static boolean isKeywords(String app) { public static boolean isKeywords(String app) {
return GB28181.equals(app) || GB28181_TALK.equals(app) || GB28181_BROADCAST.equals(app) || JT1078.equals(app); return RTP_APP.equals(app) || GB28181_TALK.equals(app) || GB28181_BROADCAST.equals(app);
} }
public static boolean isGB28181(String app, String streamId) { public static boolean isGB28181(String app, String streamId) {
return GB28181.equals(app) || GB28181_TALK.equals(app) || GB28181_BROADCAST.equals(app); return RTP_APP.equals(app) || !streamId.startsWith(RTP_STREAM_REST_PREFIX);
}
public static boolean isTalk(String app, String streamId) {
return GB28181_TALK.equals(app);
}
public static boolean isBroadcast(String app, String streamId) {
return GB28181_BROADCAST.equals(app);
}
public static boolean isJT1078(String app, String streamId) {
return RTP_APP.equals(app) || streamId.startsWith(JT1078_STREAM_PREFIX);
}
public static String getJTPlayStreamId(String phoneNumber, int channelId) {
return String.format("%s_%s_%s", JT1078_STREAM_PLAY_PREFIX, phoneNumber, channelId);
}
public static boolean isJT1078Play(String app, String stream) {
return RTP_APP.equals(app) || stream.startsWith(JT1078_STREAM_PLAY_PREFIX);
}
public static boolean isJT1078Playback(String app, String stream) {
return RTP_APP.equals(app) || stream.startsWith(JT1078_STREAM_PLAYBACK_PREFIX);
}
public static boolean isJT1078Talk(String app, String stream) {
return JT_TALK.equals(app);
}
public static String getJTPlaybackStreamId(String phoneNumber, Integer channelId, String startTime, String endTime) {
return String.format("%s_%s_%s_%s_%s", JT1078_STREAM_PLAYBACK_PREFIX, phoneNumber, channelId, startTime, endTime);
}
public static String getJTTalkStreamId(String phoneNumber, Integer channelId) {
return String.format("%s_%s_%s", JT_TALK, phoneNumber, channelId);
}
public static String getJTTalkReceiveStreamId(String phoneNumber, Integer channelId) {
return getJTTalkStreamId(phoneNumber, channelId) + "_receive";
} }
} }

View File

@ -205,7 +205,7 @@ public class SendRtpInfo {
sendRtpItem.setChannelId(channelId); sendRtpItem.setChannelId(channelId);
sendRtpItem.setTcp(isTcp); sendRtpItem.setTcp(isTcp);
sendRtpItem.setRtcp(rtcp); sendRtpItem.setRtcp(rtcp);
sendRtpItem.setApp(MediaStreamUtil.GB28181); sendRtpItem.setApp(MediaStreamUtil.RTP_APP);
sendRtpItem.setLocalPort(localPort); sendRtpItem.setLocalPort(localPort);
sendRtpItem.setServerId(serverId); sendRtpItem.setServerId(serverId);
sendRtpItem.setMediaServerId(mediaServer.getId()); sendRtpItem.setMediaServerId(mediaServer.getId());

View File

@ -50,7 +50,7 @@ public class InviteStreamServiceImpl implements IInviteStreamService {
@Async @Async
@EventListener @EventListener
public void onApplicationEvent(MediaDepartureEvent event) { public void onApplicationEvent(MediaDepartureEvent event) {
if ("rtsp".equals(event.getSchema()) && MediaStreamUtil.GB28181.equals(event.getApp())) { if ("rtsp".equals(event.getSchema()) && MediaStreamUtil.isGB28181(event.getApp(), event.getStream())) {
InviteInfo inviteInfo = getInviteInfoByStream(null, event.getStream()); InviteInfo inviteInfo = getInviteInfoByStream(null, event.getStream());
if (inviteInfo != null && (inviteInfo.getType() == InviteSessionType.PLAY || inviteInfo.getType() == InviteSessionType.PLAYBACK)) { if (inviteInfo != null && (inviteInfo.getType() == InviteSessionType.PLAY || inviteInfo.getType() == InviteSessionType.PLAYBACK)) {
removeInviteInfo(inviteInfo); removeInviteInfo(inviteInfo);

View File

@ -228,7 +228,7 @@ public class PlayServiceImpl implements IPlayService {
} }
} }
} }
}else if (MediaStreamUtil.GB28181.equals(event.getApp())) { }else if (MediaStreamUtil.isGB28181(event.getApp(), event.getStream())) {
// 释放ssrc // 释放ssrc
InviteInfo inviteInfo = inviteStreamService.getInviteInfoByStream(null, event.getStream()); InviteInfo inviteInfo = inviteStreamService.getInviteInfoByStream(null, event.getStream());
if (inviteInfo != null && inviteInfo.getStatus() == InviteSessionStatus.ok if (inviteInfo != null && inviteInfo.getStatus() == InviteSessionStatus.ok
@ -246,7 +246,7 @@ public class PlayServiceImpl implements IPlayService {
@Async @Async
@EventListener @EventListener
public void onApplicationEvent(MediaNotFoundEvent event) { public void onApplicationEvent(MediaNotFoundEvent event) {
if (!MediaStreamUtil.GB28181.equals(event.getApp())) { if (!MediaStreamUtil.isGB28181(event.getApp(), event.getStream())) {
return; return;
} }
String[] s = event.getStream().split("_"); String[] s = event.getStream().split("_");
@ -354,7 +354,7 @@ public class PlayServiceImpl implements IPlayService {
return inviteInfoInCatch.getSsrcInfo(); return inviteInfoInCatch.getSsrcInfo();
} }
MediaServer mediaInfo = streamInfo.getMediaServer(); MediaServer mediaInfo = streamInfo.getMediaServer();
Boolean ready = mediaServerService.isStreamReady(mediaInfo, MediaStreamUtil.GB28181, streamId); Boolean ready = mediaServerService.isStreamReady(mediaInfo, MediaStreamUtil.RTP_APP, streamId);
if (ready != null && ready) { if (ready != null && ready) {
if(callback != null) { if(callback != null) {
callback.run(InviteErrorCode.SUCCESS.getCode(), InviteErrorCode.SUCCESS.getMsg(), streamInfo); callback.run(InviteErrorCode.SUCCESS.getCode(), InviteErrorCode.SUCCESS.getMsg(), streamInfo);
@ -410,14 +410,14 @@ public class PlayServiceImpl implements IPlayService {
} }
inviteStreamService.call(InviteSessionType.PLAY, channel.getId(), null, code, msg, null); inviteStreamService.call(InviteSessionType.PLAY, channel.getId(), null, code, msg, null);
inviteStreamService.removeInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, channel.getId()); inviteStreamService.removeInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, channel.getId());
SsrcTransaction ssrcTransaction = sessionManager.getSsrcTransactionByStream(MediaStreamUtil.GB28181, streamId); SsrcTransaction ssrcTransaction = sessionManager.getSsrcTransactionByStream(MediaStreamUtil.RTP_APP, streamId);
if (ssrcTransaction != null) { if (ssrcTransaction != null) {
try { try {
cmder.streamByeCmd(device, channel.getDeviceId(), MediaStreamUtil.GB28181, streamId, null, null); cmder.streamByeCmd(device, channel.getDeviceId(), MediaStreamUtil.RTP_APP, streamId, null, null);
} catch (InvalidArgumentException | ParseException | SipException | SsrcTransactionNotFoundException e) { } catch (InvalidArgumentException | ParseException | SipException | SsrcTransactionNotFoundException e) {
log.error("[点播超时] 发送BYE失败 {}", e.getMessage()); log.error("[点播超时] 发送BYE失败 {}", e.getMessage());
} finally { } finally {
sessionManager.removeByStream(MediaStreamUtil.GB28181, streamId); sessionManager.removeByStream(MediaStreamUtil.RTP_APP, streamId);
} }
} }
} }
@ -680,7 +680,7 @@ public class PlayServiceImpl implements IPlayService {
String fileName = deviceId + "_" + channelId + ".jpg"; String fileName = deviceId + "_" + channelId + ".jpg";
// 请求截图 // 请求截图
log.info("[请求截图]: " + fileName); log.info("[请求截图]: " + fileName);
mediaServerService.getSnap(mediaServerItemInuse, MediaStreamUtil.GB28181, stream, 15, 1, path, fileName); mediaServerService.getSnap(mediaServerItemInuse, MediaStreamUtil.RTP_APP, stream, 15, 1, path, fileName);
} }
public StreamInfo onPublishHandlerForPlay(MediaServer mediaServerItem, MediaInfo mediaInfo, Device device, DeviceChannel channel) { public StreamInfo onPublishHandlerForPlay(MediaServer mediaServerItem, MediaInfo mediaInfo, Device device, DeviceChannel channel) {
@ -791,14 +791,14 @@ public class PlayServiceImpl implements IPlayService {
} }
inviteStreamService.call(InviteSessionType.PLAYBACK, channel.getId(), null, code, msg, null); inviteStreamService.call(InviteSessionType.PLAYBACK, channel.getId(), null, code, msg, null);
inviteStreamService.removeInviteInfoByDeviceAndChannel(InviteSessionType.PLAYBACK, channel.getId()); inviteStreamService.removeInviteInfoByDeviceAndChannel(InviteSessionType.PLAYBACK, channel.getId());
SsrcTransaction ssrcTransaction = sessionManager.getSsrcTransactionByStream(MediaStreamUtil.GB28181, stream); SsrcTransaction ssrcTransaction = sessionManager.getSsrcTransactionByStream(MediaStreamUtil.RTP_APP, stream);
if (ssrcTransaction != null) { if (ssrcTransaction != null) {
try { try {
cmder.streamByeCmd(device, channel.getDeviceId(), MediaStreamUtil.GB28181, stream, null, null); cmder.streamByeCmd(device, channel.getDeviceId(), MediaStreamUtil.RTP_APP, stream, null, null);
} catch (InvalidArgumentException | ParseException | SipException | SsrcTransactionNotFoundException e) { } catch (InvalidArgumentException | ParseException | SipException | SsrcTransactionNotFoundException e) {
log.error("[录像回放] 发送BYE失败 {}", e.getMessage()); log.error("[录像回放] 发送BYE失败 {}", e.getMessage());
} finally { } finally {
sessionManager.removeByStream(MediaStreamUtil.GB28181, stream); sessionManager.removeByStream(MediaStreamUtil.RTP_APP, stream);
} }
} }
} }
@ -939,19 +939,19 @@ public class PlayServiceImpl implements IPlayService {
if (ssrcInResponse != null) { if (ssrcInResponse != null) {
// 单端口 // 单端口
// 重新订阅流上线 // 重新订阅流上线
SsrcTransaction ssrcTransaction = sessionManager.getSsrcTransactionByStream(MediaStreamUtil.GB28181, inviteInfo.getStream()); SsrcTransaction ssrcTransaction = sessionManager.getSsrcTransactionByStream(MediaStreamUtil.RTP_APP, inviteInfo.getStream());
if (ssrcTransaction == null) { if (ssrcTransaction == null) {
return; return;
} }
releaseAllocatedSsrc(mediaServerItem, ssrcInfo); releaseAllocatedSsrc(mediaServerItem, ssrcInfo);
sessionManager.removeByStream(MediaStreamUtil.GB28181, inviteInfo.getStream()); sessionManager.removeByStream(MediaStreamUtil.RTP_APP, inviteInfo.getStream());
inviteStreamService.updateInviteInfoForSSRC(inviteInfo, ssrcInResponse); inviteStreamService.updateInviteInfoForSSRC(inviteInfo, ssrcInResponse);
ssrcTransaction.setDeviceId(device.getDeviceId()); ssrcTransaction.setDeviceId(device.getDeviceId());
ssrcTransaction.setChannelId(ssrcTransaction.getChannelId()); ssrcTransaction.setChannelId(ssrcTransaction.getChannelId());
ssrcTransaction.setCallId(ssrcTransaction.getCallId()); ssrcTransaction.setCallId(ssrcTransaction.getCallId());
ssrcTransaction.setSsrc(ssrcInResponse); ssrcTransaction.setSsrc(ssrcInResponse);
ssrcTransaction.setAllocatedSsrc(null); ssrcTransaction.setAllocatedSsrc(null);
ssrcTransaction.setApp(MediaStreamUtil.GB28181); ssrcTransaction.setApp(MediaStreamUtil.RTP_APP);
ssrcTransaction.setStream(inviteInfo.getStream()); ssrcTransaction.setStream(inviteInfo.getStream());
ssrcTransaction.setMediaServerId(mediaServerItem.getId()); ssrcTransaction.setMediaServerId(mediaServerItem.getId());
ssrcTransaction.setSipTransactionInfo(new SipTransactionInfo((SIPResponse) responseEvent.getResponse())); ssrcTransaction.setSipTransactionInfo(new SipTransactionInfo((SIPResponse) responseEvent.getResponse()));
@ -1096,7 +1096,7 @@ public class PlayServiceImpl implements IPlayService {
inviteStreamService.updateInviteInfo(inviteInfoForNew, 60*15L); inviteStreamService.updateInviteInfo(inviteInfoForNew, 60*15L);
} }
}; };
Hook hook = Hook.getInstance(HookType.on_record_mp4, MediaStreamUtil.GB28181, ssrcInfo.getStream(), mediaServer.getId()); Hook hook = Hook.getInstance(HookType.on_record_mp4, MediaStreamUtil.RTP_APP, ssrcInfo.getStream(), mediaServer.getId());
// 设置过期时间下载失败时自动处理订阅数据 // 设置过期时间下载失败时自动处理订阅数据
hook.setExpireTime(System.currentTimeMillis() + 24 * 60 * 60 * 1000); hook.setExpireTime(System.currentTimeMillis() + 24 * 60 * 60 * 1000);
subscribe.addSubscribe(hook, hookEventForRecord); subscribe.addSubscribe(hook, hookEventForRecord);
@ -1116,7 +1116,7 @@ public class PlayServiceImpl implements IPlayService {
InviteInfo inviteInfo = inviteStreamService.getInviteInfo(InviteSessionType.DOWNLOAD, channel.getId(), stream); InviteInfo inviteInfo = inviteStreamService.getInviteInfo(InviteSessionType.DOWNLOAD, channel.getId(), stream);
if (inviteInfo == null) { if (inviteInfo == null) {
String app = MediaStreamUtil.GB28181; String app = MediaStreamUtil.RTP_APP;
StreamAuthorityInfo streamAuthorityInfo = redisCatchStorage.getStreamAuthorityInfo(app, stream); StreamAuthorityInfo streamAuthorityInfo = redisCatchStorage.getStreamAuthorityInfo(app, stream);
if (streamAuthorityInfo != null) { if (streamAuthorityInfo != null) {
List<CloudRecordItem> allList = cloudRecordService.getAllList(null, app, stream, null, null, null, streamAuthorityInfo.getCallId(), null); List<CloudRecordItem> allList = cloudRecordService.getAllList(null, app, stream, null, null, null, streamAuthorityInfo.getCallId(), null);
@ -1158,7 +1158,7 @@ public class PlayServiceImpl implements IPlayService {
log.warn("[获取下载进度] 查询录像信息时发现节点不存在"); log.warn("[获取下载进度] 查询录像信息时发现节点不存在");
return null; return null;
} }
String app = MediaStreamUtil.GB28181; String app = MediaStreamUtil.RTP_APP;
Long duration = mediaServerService.updateDownloadProcess(mediaServerItem, app, stream); Long duration = mediaServerService.updateDownloadProcess(mediaServerItem, app, stream);
if (duration == null || duration == 0) { if (duration == null || duration == 0) {
inviteInfo.getStreamInfo().setProgress(0); inviteInfo.getStreamInfo().setProgress(0);
@ -1201,7 +1201,7 @@ public class PlayServiceImpl implements IPlayService {
public StreamInfo onPublishHandler(MediaServer mediaServerItem, MediaInfo mediaInfo, Device device, DeviceChannel channel) { public StreamInfo onPublishHandler(MediaServer mediaServerItem, MediaInfo mediaInfo, Device device, DeviceChannel channel) {
StreamInfo streamInfo = mediaServerService.getStreamInfoByAppAndStream(mediaServerItem, MediaStreamUtil.GB28181, mediaInfo.getStream(), mediaInfo, null); StreamInfo streamInfo = mediaServerService.getStreamInfoByAppAndStream(mediaServerItem, MediaStreamUtil.RTP_APP, mediaInfo.getStream(), mediaInfo, null);
streamInfo.setDeviceId(device.getDeviceId()); streamInfo.setDeviceId(device.getDeviceId());
streamInfo.setChannelId(channel.getId()); streamInfo.setChannelId(channel.getId());
return streamInfo; return streamInfo;
@ -1647,7 +1647,7 @@ public class PlayServiceImpl implements IPlayService {
String path = "snap"; String path = "snap";
// 请求截图 // 请求截图
log.info("[请求截图]: " + fileName); log.info("[请求截图]: " + fileName);
mediaServerService.getSnap(mediaServer, MediaStreamUtil.GB28181, inviteInfo.getStreamInfo().getStream(), 15, 1, path, fileName); mediaServerService.getSnap(mediaServer, MediaStreamUtil.RTP_APP, inviteInfo.getStreamInfo().getStream(), 15, 1, path, fileName);
File snapFile = new File(path + File.separator + fileName); File snapFile = new File(path + File.separator + fileName);
if (snapFile.exists()) { if (snapFile.exists()) {
errorCallback.run(InviteErrorCode.SUCCESS.getCode(), InviteErrorCode.SUCCESS.getMsg(), snapFile.getAbsoluteFile()); errorCallback.run(InviteErrorCode.SUCCESS.getCode(), InviteErrorCode.SUCCESS.getMsg(), snapFile.getAbsoluteFile());
@ -1697,7 +1697,7 @@ public class PlayServiceImpl implements IPlayService {
String path = "snap"; String path = "snap";
// 请求截图 // 请求截图
log.info("[请求截图]: 返回byte数组" ); log.info("[请求截图]: 返回byte数组" );
byte[] snapByteArray = mediaServerService.getSnap(mediaServer, MediaStreamUtil.GB28181, inviteInfo.getStreamInfo().getStream(), 15, 1, path, null); byte[] snapByteArray = mediaServerService.getSnap(mediaServer, MediaStreamUtil.RTP_APP, inviteInfo.getStreamInfo().getStream(), 15, 1, path, null);
if (snapByteArray != null) { if (snapByteArray != null) {
errorCallback.run(InviteErrorCode.SUCCESS.getCode(), InviteErrorCode.SUCCESS.getMsg(), snapByteArray); errorCallback.run(InviteErrorCode.SUCCESS.getCode(), InviteErrorCode.SUCCESS.getMsg(), snapByteArray);
}else { }else {
@ -1711,7 +1711,7 @@ public class PlayServiceImpl implements IPlayService {
if (code == InviteErrorCode.SUCCESS.getCode()) { if (code == InviteErrorCode.SUCCESS.getCode()) {
InviteInfo inviteInfoForPlay = inviteStreamService.getInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, channel.getGbId()); InviteInfo inviteInfoForPlay = inviteStreamService.getInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, channel.getGbId());
if (inviteInfoForPlay != null && inviteInfoForPlay.getStreamInfo() != null) { if (inviteInfoForPlay != null && inviteInfoForPlay.getStreamInfo() != null) {
byte[] snapByteArray = mediaServerService.getSnap(data.getMediaServer(), MediaStreamUtil.GB28181, data.getStream(), 15, 1, null, null); byte[] snapByteArray = mediaServerService.getSnap(data.getMediaServer(), MediaStreamUtil.RTP_APP, data.getStream(), 15, 1, null, null);
errorCallback.run(InviteErrorCode.SUCCESS.getCode(), InviteErrorCode.SUCCESS.getMsg(), snapByteArray); errorCallback.run(InviteErrorCode.SUCCESS.getCode(), InviteErrorCode.SUCCESS.getMsg(), snapByteArray);
}else { }else {
errorCallback.run(InviteErrorCode.FAIL.getCode(), InviteErrorCode.FAIL.getMsg(), null); errorCallback.run(InviteErrorCode.FAIL.getCode(), InviteErrorCode.FAIL.getMsg(), null);
@ -1740,7 +1740,7 @@ public class PlayServiceImpl implements IPlayService {
if (InviteSessionStatus.ok == inviteInfo.getStatus()) { if (InviteSessionStatus.ok == inviteInfo.getStatus()) {
try { try {
log.info("[停止点播/回放/下载] {}/{}", device.getDeviceId(), channel.getDeviceId()); log.info("[停止点播/回放/下载] {}/{}", device.getDeviceId(), channel.getDeviceId());
cmder.streamByeCmd(device, channel.getDeviceId(), MediaStreamUtil.GB28181, inviteInfo.getStream(), null, null); cmder.streamByeCmd(device, channel.getDeviceId(), MediaStreamUtil.RTP_APP, inviteInfo.getStream(), null, null);
} catch (InvalidArgumentException | SipException | ParseException | SsrcTransactionNotFoundException e) { } catch (InvalidArgumentException | SipException | ParseException | SsrcTransactionNotFoundException e) {
log.error("[命令发送失败] 停止点播/回放/下载, 发送BYE: {}", e.getMessage()); log.error("[命令发送失败] 停止点播/回放/下载, 发送BYE: {}", e.getMessage());
throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage()); throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage());
@ -1751,7 +1751,7 @@ public class PlayServiceImpl implements IPlayService {
deviceChannelService.stopPlay(channel.getId()); deviceChannelService.stopPlay(channel.getId());
} }
if (inviteInfo.getStreamInfo() != null) { if (inviteInfo.getStreamInfo() != null) {
receiveRtpServerService.closeRTPServer(inviteInfo.getStreamInfo().getMediaServer(), MediaStreamUtil.GB28181, stream); receiveRtpServerService.closeRTPServer(inviteInfo.getStreamInfo().getMediaServer(), MediaStreamUtil.RTP_APP, stream);
} }
} }
} }
@ -1773,7 +1773,7 @@ public class PlayServiceImpl implements IPlayService {
if (InviteSessionStatus.ok == inviteInfo.getStatus()) { if (InviteSessionStatus.ok == inviteInfo.getStatus()) {
try { try {
log.info("[停止点播/回放/下载] {}/{}", device.getDeviceId(), channel.getDeviceId()); log.info("[停止点播/回放/下载] {}/{}", device.getDeviceId(), channel.getDeviceId());
cmder.streamByeCmd(device, channel.getDeviceId(), MediaStreamUtil.GB28181, inviteInfo.getStream(), null, null); cmder.streamByeCmd(device, channel.getDeviceId(), MediaStreamUtil.RTP_APP, inviteInfo.getStream(), null, null);
} catch (InvalidArgumentException | SipException | ParseException | SsrcTransactionNotFoundException e) { } catch (InvalidArgumentException | SipException | ParseException | SsrcTransactionNotFoundException e) {
log.warn("[命令发送失败] 停止点播/回放/下载, 发送BYE: {}", e.getMessage()); log.warn("[命令发送失败] 停止点播/回放/下载, 发送BYE: {}", e.getMessage());
} }
@ -1783,7 +1783,7 @@ public class PlayServiceImpl implements IPlayService {
deviceChannelService.stopPlay(channel.getId()); deviceChannelService.stopPlay(channel.getId());
} }
if (inviteInfo.getStreamInfo() != null) { if (inviteInfo.getStreamInfo() != null) {
receiveRtpServerService.closeRTPServer(inviteInfo.getStreamInfo().getMediaServer(), MediaStreamUtil.GB28181, inviteInfo.getStream()); receiveRtpServerService.closeRTPServer(inviteInfo.getStreamInfo().getMediaServer(), MediaStreamUtil.RTP_APP, inviteInfo.getStream());
} }
} }

View File

@ -509,7 +509,7 @@ public class SIPCommander implements ISIPCommander {
} }
log.info("[语音喊话] {} 分配的ZLM为: {} [{}:{}]", stream, mediaServerItem.getId(), mediaServerItem.getIp(), sendRtpItem.getPort()); log.info("[语音喊话] {} 分配的ZLM为: {} [{}:{}]", stream, mediaServerItem.getId(), mediaServerItem.getIp(), sendRtpItem.getPort());
Hook hook = Hook.getInstance(HookType.on_media_arrival, MediaStreamUtil.GB28181, stream, mediaServerItem.getId()); Hook hook = Hook.getInstance(HookType.on_media_arrival, MediaStreamUtil.RTP_APP, stream, mediaServerItem.getId());
subscribe.addSubscribe(hook, (hookData) -> { subscribe.addSubscribe(hook, (hookData) -> {
if (event != null) { if (event != null) {
event.response(hookData); event.response(hookData);
@ -519,7 +519,7 @@ public class SIPCommander implements ISIPCommander {
CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()), device.getTransport()); CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()), device.getTransport());
callIdHeader.setCallId(callId); callIdHeader.setCallId(callId);
Hook publishHook = Hook.getInstance(HookType.on_publish, MediaStreamUtil.GB28181, stream, mediaServerItem.getId()); Hook publishHook = Hook.getInstance(HookType.on_publish, MediaStreamUtil.RTP_APP, stream, mediaServerItem.getId());
subscribe.addSubscribe(publishHook, (hookData) -> { subscribe.addSubscribe(publishHook, (hookData) -> {
if (eventForPush != null) { if (eventForPush != null) {
eventForPush.response(hookData); eventForPush.response(hookData);
@ -1396,7 +1396,7 @@ public class SIPCommander implements ISIPCommander {
@Override @Override
public void playbackControlCmd(Device device, DeviceChannel channel, String stream, String content, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws SipException, InvalidArgumentException, ParseException { public void playbackControlCmd(Device device, DeviceChannel channel, String stream, String content, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws SipException, InvalidArgumentException, ParseException {
SsrcTransaction ssrcTransaction = sessionManager.getSsrcTransactionByStream(MediaStreamUtil.GB28181, stream); SsrcTransaction ssrcTransaction = sessionManager.getSsrcTransactionByStream(MediaStreamUtil.RTP_APP, stream);
if (ssrcTransaction == null) { if (ssrcTransaction == null) {
log.info("[回放控制]未找到视频流信息,设备:{}, 流ID: {}", device.getDeviceId(), stream); log.info("[回放控制]未找到视频流信息,设备:{}, 流ID: {}", device.getDeviceId(), stream);
return; return;

View File

@ -99,7 +99,7 @@ public class MediaStatusNotifyMessageHandler extends SIPRequestProcessorParent i
playService.stop(inviteInfo); playService.stop(inviteInfo);
} }
// 去除监听流注销自动停止下载的监听 // 去除监听流注销自动停止下载的监听
Hook hook = Hook.getInstance(HookType.on_media_arrival, MediaStreamUtil.GB28181, ssrcTransaction.getStream(), ssrcTransaction.getMediaServerId()); Hook hook = Hook.getInstance(HookType.on_media_arrival, MediaStreamUtil.RTP_APP, ssrcTransaction.getStream(), ssrcTransaction.getMediaServerId());
subscribe.removeSubscribe(hook); subscribe.removeSubscribe(hook);
if (ssrcTransaction.getPlatformId() != null) { if (ssrcTransaction.getPlatformId() != null) {
// 如果级联播放需要给上级发送此通知 TODO 多个上级同时观看一个下级 可能存在停错的问题需要将点播CallId进行上下级绑定 // 如果级联播放需要给上级发送此通知 TODO 多个上级同时观看一个下级 可能存在停错的问题需要将点播CallId进行上下级绑定

View File

@ -12,8 +12,6 @@ import java.util.List;
public interface Ijt1078PlayService { public interface Ijt1078PlayService {
JTMediaStreamType checkStreamFromJt(String stream);
void play(String phoneNumber, Integer channelId, int type, CommonCallback<WVPResult<StreamInfo>> callback); void play(String phoneNumber, Integer channelId, int type, CommonCallback<WVPResult<StreamInfo>> callback);
void playback(String phoneNumber, Integer channelId, String startTime, String endTime, Integer type, void playback(String phoneNumber, Integer channelId, String startTime, String endTime, Integer type,

View File

@ -53,8 +53,6 @@ import java.util.concurrent.ConcurrentHashMap;
@Slf4j @Slf4j
public class jt1078PlayServiceImpl implements Ijt1078PlayService { public class jt1078PlayServiceImpl implements Ijt1078PlayService {
public static final String talkApp = "jt_talk";
@Autowired @Autowired
private ISendRtpServerService sendRtpServerService; private ISendRtpServerService sendRtpServerService;
@ -88,7 +86,7 @@ public class jt1078PlayServiceImpl implements Ijt1078PlayService {
@Async @Async
@EventListener @EventListener
public void onApplicationEvent(MediaArrivalEvent event) { public void onApplicationEvent(MediaArrivalEvent event) {
if (event.getApp().equals(talkApp) && event.getStream().endsWith("_talk")) { if (MediaStreamUtil.JT_TALK.equals(event.getApp()) && event.getStream().endsWith("_talk")) {
// 收到对JT讲的流 // 收到对JT讲的流
if (event.getStream().indexOf("_") <= 0) { if (event.getStream().indexOf("_") <= 0) {
log.info("[JT-对讲流到来] 流格式有误stream应该为jt_[phoneNumber]_[channelId]_talk"); log.info("[JT-对讲流到来] 流格式有误stream应该为jt_[phoneNumber]_[channelId]_talk");
@ -129,7 +127,7 @@ public class jt1078PlayServiceImpl implements Ijt1078PlayService {
if (!userSetting.getAutoApplyPlay()) { if (!userSetting.getAutoApplyPlay()) {
return; return;
} }
JTMediaStreamType jtMediaStreamType = checkStreamFromJt(event.getStream()); JTMediaStreamType jtMediaStreamType = checkStreamFromJt(event.getApp(), event.getStream());
if (jtMediaStreamType == null){ if (jtMediaStreamType == null){
return; return;
} }
@ -163,17 +161,15 @@ public class jt1078PlayServiceImpl implements Ijt1078PlayService {
/** /**
* 校验流是否是属于部标的 * 校验流是否是属于部标的
*/ */
@Override private JTMediaStreamType checkStreamFromJt(String app, String stream) {
public JTMediaStreamType checkStreamFromJt(String stream) { if (!MediaStreamUtil.isJT1078(app, stream)) {
if (!stream.startsWith("jt_")) {
return null; return null;
} }
String[] streamParamArray = stream.split("_"); if (MediaStreamUtil.isJT1078Play(app, stream)) {
if (streamParamArray.length == 3) {
return JTMediaStreamType.PLAY; return JTMediaStreamType.PLAY;
}else if (streamParamArray.length == 5) { }else if (MediaStreamUtil.isJT1078Playback(app, stream)) {
return JTMediaStreamType.PLAYBACK; return JTMediaStreamType.PLAYBACK;
}else if (streamParamArray.length == 4) { }else if (MediaStreamUtil.isJT1078Talk(app, stream)) {
return JTMediaStreamType.TALK; return JTMediaStreamType.TALK;
}else { }else {
return null; return null;
@ -199,7 +195,7 @@ public class jt1078PlayServiceImpl implements Ijt1078PlayService {
private void play(JTDevice device, JTChannel channel, int type, CommonCallback<WVPResult<StreamInfo>> callback) { private void play(JTDevice device, JTChannel channel, int type, CommonCallback<WVPResult<StreamInfo>> callback) {
String phoneNumber = device.getPhoneNumber(); String phoneNumber = device.getPhoneNumber();
int channelId = channel.getChannelId(); int channelId = channel.getChannelId();
String stream = phoneNumber + "_" + channelId; String stream = MediaStreamUtil.getJTPlayStreamId(phoneNumber, channelId);
// 检查流是否已经存在存在则返回 // 检查流是否已经存在存在则返回
String playKey = VideoManagerConstants.INVITE_INFO_1078_PLAY + phoneNumber + ":" + channelId; String playKey = VideoManagerConstants.INVITE_INFO_1078_PLAY + phoneNumber + ":" + channelId;
List<CommonCallback<WVPResult<StreamInfo>>> errorCallbacks = inviteErrorCallbackMap.computeIfAbsent(playKey, k -> new ArrayList<>()); List<CommonCallback<WVPResult<StreamInfo>>> errorCallbacks = inviteErrorCallbackMap.computeIfAbsent(playKey, k -> new ArrayList<>());
@ -209,7 +205,7 @@ public class jt1078PlayServiceImpl implements Ijt1078PlayService {
MediaServer mediaServer = streamInfo.getMediaServer(); MediaServer mediaServer = streamInfo.getMediaServer();
if (mediaServer != null) { if (mediaServer != null) {
// 查询流是否存在不存在则删除缓存数据 // 查询流是否存在不存在则删除缓存数据
MediaInfo mediaInfo = mediaServerService.getMediaInfo(mediaServer, MediaStreamUtil.JT1078, streamInfo.getStream()); MediaInfo mediaInfo = mediaServerService.getMediaInfo(mediaServer, MediaStreamUtil.RTP_APP, streamInfo.getStream());
if (mediaInfo != null) { if (mediaInfo != null) {
log.info("[JT-点播] 点播已经存在,直接返回, phoneNumber {} channelId {}", phoneNumber, channelId); log.info("[JT-点播] 点播已经存在,直接返回, phoneNumber {} channelId {}", phoneNumber, channelId);
for (CommonCallback<WVPResult<StreamInfo>> errorCallback : errorCallbacks) { for (CommonCallback<WVPResult<StreamInfo>> errorCallback : errorCallbacks) {
@ -237,7 +233,7 @@ public class jt1078PlayServiceImpl implements Ijt1078PlayService {
// 开启收流端口 // 开启收流端口
RTPServerParam rtpServerParam = new RTPServerParam(); RTPServerParam rtpServerParam = new RTPServerParam();
rtpServerParam.setMediaServer(mediaServer); rtpServerParam.setMediaServer(mediaServer);
rtpServerParam.setApp(MediaStreamUtil.JT1078); rtpServerParam.setApp(MediaStreamUtil.RTP_APP);
rtpServerParam.setStreamId(stream); rtpServerParam.setStreamId(stream);
rtpServerParam.setPort(0); rtpServerParam.setPort(0);
rtpServerParam.setTcpMode(1); // 1 表示tcp被动 rtpServerParam.setTcpMode(1); // 1 表示tcp被动
@ -263,8 +259,8 @@ public class jt1078PlayServiceImpl implements Ijt1078PlayService {
String path = "snap"; String path = "snap";
String fileName = phoneNumber + "_" + channelId + ".jpg"; String fileName = phoneNumber + "_" + channelId + ".jpg";
// 请求截图 // 请求截图
log.info("[请求截图]: " + fileName); log.info("[请求截图]: {}", fileName);
mediaServerService.getSnap(mediaServer, MediaStreamUtil.JT1078, stream, 15, 1, path, fileName); mediaServerService.getSnap(mediaServer, MediaStreamUtil.RTP_APP, stream, 15, 1, path, fileName);
}else { }else {
if (callback != null) { if (callback != null) {
callback.run(WVPResult.fail(code, msg)); callback.run(WVPResult.fail(code, msg));
@ -294,7 +290,7 @@ public class jt1078PlayServiceImpl implements Ijt1078PlayService {
} }
public StreamInfo onPublishHandler(MediaServer mediaServerItem, HookData hookData, String phoneNumber, Integer channelId) { public StreamInfo onPublishHandler(MediaServer mediaServerItem, HookData hookData, String phoneNumber, Integer channelId) {
StreamInfo streamInfo = mediaServerService.getStreamInfoByAppAndStream(mediaServerItem, MediaStreamUtil.JT1078, hookData.getStream(), hookData.getMediaInfo(), null); StreamInfo streamInfo = mediaServerService.getStreamInfoByAppAndStream(mediaServerItem, MediaStreamUtil.RTP_APP, hookData.getStream(), hookData.getMediaInfo(), null);
streamInfo.setDeviceId(phoneNumber); streamInfo.setDeviceId(phoneNumber);
streamInfo.setChannelId(channelId); streamInfo.setChannelId(channelId);
return streamInfo; return streamInfo;
@ -437,8 +433,8 @@ public class jt1078PlayServiceImpl implements Ijt1078PlayService {
redisTemplate.delete(playbackKey); redisTemplate.delete(playbackKey);
} }
String app = MediaStreamUtil.JT1078; String app = MediaStreamUtil.RTP_APP;
String stream = String.format("%s_%s_%s_%s", phoneNumber, channelId, String stream = MediaStreamUtil.getJTPlaybackStreamId(phoneNumber, channelId,
DateUtil.yyyy_MM_dd_HH_mm_ssToUrl(startTime), DateUtil.yyyy_MM_dd_HH_mm_ssToUrl(endTime)); DateUtil.yyyy_MM_dd_HH_mm_ssToUrl(startTime), DateUtil.yyyy_MM_dd_HH_mm_ssToUrl(endTime));
MediaServer mediaServer; MediaServer mediaServer;
if (org.springframework.util.ObjectUtils.isEmpty(device.getMediaServerId()) || "auto".equals(device.getMediaServerId())) { if (org.springframework.util.ObjectUtils.isEmpty(device.getMediaServerId()) || "auto".equals(device.getMediaServerId())) {
@ -456,7 +452,7 @@ public class jt1078PlayServiceImpl implements Ijt1078PlayService {
// 开启收流端口 // 开启收流端口
RTPServerParam rtpServerParam = new RTPServerParam(); RTPServerParam rtpServerParam = new RTPServerParam();
rtpServerParam.setMediaServer(mediaServer); rtpServerParam.setMediaServer(mediaServer);
rtpServerParam.setApp(MediaStreamUtil.JT1078); rtpServerParam.setApp(MediaStreamUtil.RTP_APP);
rtpServerParam.setStreamId(stream); rtpServerParam.setStreamId(stream);
rtpServerParam.setPort(0); rtpServerParam.setPort(0);
rtpServerParam.setTcpMode(1); // 1 表示tcp被动 rtpServerParam.setTcpMode(1); // 1 表示tcp被动
@ -594,7 +590,7 @@ public class jt1078PlayServiceImpl implements Ijt1078PlayService {
JTDevice device = jt1078Service.getDevice(phoneNumber); JTDevice device = jt1078Service.getDevice(phoneNumber);
Assert.notNull(device, "部标设备不存在"); Assert.notNull(device, "部标设备不存在");
String stream = "jt_" + phoneNumber + "_" + channelId + "_talk"; String stream = MediaStreamUtil.getJTTalkStreamId(phoneNumber, channelId);
MediaServer mediaServer; MediaServer mediaServer;
if (org.springframework.util.ObjectUtils.isEmpty(device.getMediaServerId()) || "auto".equals(device.getMediaServerId())) { if (org.springframework.util.ObjectUtils.isEmpty(device.getMediaServerId()) || "auto".equals(device.getMediaServerId())) {
@ -604,9 +600,9 @@ public class jt1078PlayServiceImpl implements Ijt1078PlayService {
} }
// 检查待发送的流是否存在 // 检查待发送的流是否存在
MediaInfo mediaInfo = mediaServerService.getMediaInfo(mediaServer, talkApp, stream); MediaInfo mediaInfo = mediaServerService.getMediaInfo(mediaServer, MediaStreamUtil.JT_TALK, stream);
Assert.isNull(mediaInfo, "对讲已经存在"); Assert.isNull(mediaInfo, "对讲已经存在");
return mediaServerService.getStreamInfoByAppAndStream(mediaServer, talkApp, stream, null, null, null, false); return mediaServerService.getStreamInfoByAppAndStream(mediaServer, MediaStreamUtil.JT_TALK, stream, null, null, null, false);
} }
private void sendTalk(JTDevice device, Integer channelId, MediaServer mediaServer, String app, String stream) { private void sendTalk(JTDevice device, Integer channelId, MediaServer mediaServer, String app, String stream) {
@ -617,17 +613,17 @@ public class jt1078PlayServiceImpl implements Ijt1078PlayService {
} }
String phoneNumber = device.getPhoneNumber(); String phoneNumber = device.getPhoneNumber();
String receiveStream = MediaStreamUtil.getJTTalkReceiveStreamId(phoneNumber, channelId);
// 开启收流端口, zlm发送1078的rtp流需要将ssrc字段设置为 imei_channel格式 // 开启收流端口, zlm发送1078的rtp流需要将ssrc字段设置为 imei_channel格式
String ssrc = device.getPhoneNumber() + "_" + channelId; String ssrc = device.getPhoneNumber() + "_" + channelId;
SendRtpInfo sendRtpInfo = sendRtpServerService.createSendRtpInfo(mediaServer, null, null, ssrc, phoneNumber, talkApp, stream, channelId, true, false); SendRtpInfo sendRtpInfo = sendRtpServerService.createSendRtpInfo(mediaServer, null, null, ssrc, phoneNumber, MediaStreamUtil.JT_TALK, stream, channelId, true, false);
sendRtpInfo.setTcpActive(true); sendRtpInfo.setTcpActive(true);
sendRtpInfo.setUsePs(false); sendRtpInfo.setUsePs(false);
sendRtpInfo.setOnlyAudio(true); sendRtpInfo.setOnlyAudio(true);
sendRtpInfo.setReceiveStream(stream + "_talk"); sendRtpInfo.setReceiveStream(receiveStream);
// 设置hook监听 // 设置hook监听
Hook hook = Hook.getInstance(HookType.on_media_arrival, MediaStreamUtil.JT1078, sendRtpInfo.getReceiveStream(), mediaServer.getId()); Hook hook = Hook.getInstance(HookType.on_media_arrival, MediaStreamUtil.RTP_APP, sendRtpInfo.getReceiveStream(), mediaServer.getId());
subscribe.addSubscribe(hook, (hookData) -> { subscribe.addSubscribe(hook, (hookData) -> {
log.info("[JT-对讲] 对讲连接建立, phoneNumber {} channelId {}", phoneNumber, channelId); log.info("[JT-对讲] 对讲连接建立, phoneNumber {} channelId {}", phoneNumber, channelId);
subscribe.removeSubscribe(hook); subscribe.removeSubscribe(hook);

View File

@ -189,14 +189,14 @@ public class ABLHttpHookListener {
logger.info("[ABL HOOK] 码流不到达通知:{}->{}/{}", param.getMediaServerId(), param.getApp(), param.getStream()); logger.info("[ABL HOOK] 码流不到达通知:{}->{}/{}", param.getMediaServerId(), param.getApp(), param.getStream());
try { try {
if (MediaStreamUtil.GB28181.equals(param.getApp())) { if (MediaStreamUtil.RTP_APP.equals(param.getApp())) {
return HookResult.SUCCESS(); return HookResult.SUCCESS();
} }
MediaRtpServerTimeoutEvent event = new MediaRtpServerTimeoutEvent(this); MediaRtpServerTimeoutEvent event = new MediaRtpServerTimeoutEvent(this);
MediaServer mediaServerItem = mediaServerService.getOne(param.getMediaServerId()); MediaServer mediaServerItem = mediaServerService.getOne(param.getMediaServerId());
if (mediaServerItem != null) { if (mediaServerItem != null) {
event.setMediaServer(mediaServerItem); event.setMediaServer(mediaServerItem);
event.setApp(MediaStreamUtil.GB28181); event.setApp(MediaStreamUtil.RTP_APP);
applicationEventPublisher.publishEvent(event); applicationEventPublisher.publishEvent(event);
} }
}catch (Exception e) { }catch (Exception e) {

View File

@ -263,7 +263,7 @@ public class ZLMHttpHookListener {
log.info("[ZLM HOOK] rtp发送关闭{}->{}/{}", param.getMediaServerId(), param.getApp(), param.getStream()); log.info("[ZLM HOOK] rtp发送关闭{}->{}/{}", param.getMediaServerId(), param.getApp(), param.getStream());
// 查找对应的上级推流发送停止 // 查找对应的上级推流发送停止
if (!MediaStreamUtil.GB28181.equals(param.getApp())) { if (!MediaStreamUtil.RTP_APP.equals(param.getApp())) {
return HookResult.SUCCESS(); return HookResult.SUCCESS();
} }
try { try {
@ -294,7 +294,7 @@ public class ZLMHttpHookListener {
MediaServer mediaServerItem = mediaServerService.getOne(param.getMediaServerId()); MediaServer mediaServerItem = mediaServerService.getOne(param.getMediaServerId());
if (mediaServerItem != null) { if (mediaServerItem != null) {
event.setMediaServer(mediaServerItem); event.setMediaServer(mediaServerItem);
event.setApp(MediaStreamUtil.GB28181); event.setApp(MediaStreamUtil.RTP_APP);
applicationEventPublisher.publishEvent(event); applicationEventPublisher.publishEvent(event);
} }
}catch (Exception e) { }catch (Exception e) {

View File

@ -83,7 +83,7 @@ public class MediaServiceImpl implements IMediaService {
if (app == null || stream == null) { if (app == null || stream == null) {
return false; return false;
} }
if (MediaStreamUtil.GB28181.equals(app)) { if (MediaStreamUtil.RTP_APP.equals(app)) {
return true; return true;
} }
StreamAuthorityInfo streamAuthorityInfo = redisCatchStorage.getStreamAuthorityInfo(app, stream); StreamAuthorityInfo streamAuthorityInfo = redisCatchStorage.getStreamAuthorityInfo(app, stream);
@ -96,14 +96,8 @@ public class MediaServiceImpl implements IMediaService {
@Override @Override
public ResultForOnPublish authenticatePublish(MediaServer mediaServer, String app, String stream, String params) { public ResultForOnPublish authenticatePublish(MediaServer mediaServer, String app, String stream, String params) {
// 推流鉴权的处理 // 推流鉴权的处理
if (!MediaStreamUtil.GB28181.equals(app) && !MediaStreamUtil.JT1078.equals(app) ) { if (!MediaStreamUtil.RTP_APP.equals(app)) {
if (MediaStreamUtil.GB28181_TALK.equals(app) && stream.endsWith("_talk")) { if (MediaStreamUtil.GB28181_TALK.equals(app) || MediaStreamUtil.JT_TALK.equals(app)) {
ResultForOnPublish result = new ResultForOnPublish();
result.setEnable_mp4(false);
result.setEnable_audio(true);
return result;
}
if ("jt_talk".equals(app) && stream.endsWith("_talk")) {
ResultForOnPublish result = new ResultForOnPublish(); ResultForOnPublish result = new ResultForOnPublish();
result.setEnable_mp4(false); result.setEnable_mp4(false);
result.setEnable_audio(true); result.setEnable_audio(true);
@ -156,9 +150,8 @@ public class MediaServiceImpl implements IMediaService {
ResultForOnPublish result = new ResultForOnPublish(); ResultForOnPublish result = new ResultForOnPublish();
result.setEnable_audio(true); result.setEnable_audio(true);
// 国标流 // RTP SERVER 收流
if (MediaStreamUtil.GB28181.equals(app)) { if (MediaStreamUtil.isGB28181(app, stream)) {
InviteInfo inviteInfo = inviteStreamService.getInviteInfoByStream(null, stream); InviteInfo inviteInfo = inviteStreamService.getInviteInfoByStream(null, stream);
if (inviteInfo != null) { if (inviteInfo != null) {
@ -224,7 +217,7 @@ public class MediaServiceImpl implements IMediaService {
}else { }else {
result.setEnable_mp4(userSetting.getRecordPushLive()); result.setEnable_mp4(userSetting.getRecordPushLive());
} }
if (app.equalsIgnoreCase(MediaStreamUtil.GB28181)) { if (app.equalsIgnoreCase(MediaStreamUtil.RTP_APP)) {
String receiveKey = VideoManagerConstants.WVP_OTHER_RECEIVE_RTP_INFO + userSetting.getServerId() + "_" + stream; String receiveKey = VideoManagerConstants.WVP_OTHER_RECEIVE_RTP_INFO + userSetting.getServerId() + "_" + stream;
OtherRtpSendInfo otherRtpSendInfo = (OtherRtpSendInfo) redisTemplate.opsForValue().get(receiveKey); OtherRtpSendInfo otherRtpSendInfo = (OtherRtpSendInfo) redisTemplate.opsForValue().get(receiveKey);
@ -244,7 +237,7 @@ public class MediaServiceImpl implements IMediaService {
return false; return false;
} }
// 国标类型的流 // 国标类型的流
if (MediaStreamUtil.GB28181.equals(app)) { if (MediaStreamUtil.RTP_APP.equals(app)) {
result = userSetting.getStreamOnDemand(); result = userSetting.getStreamOnDemand();
// 国标流 点播/录像回放/录像下载 // 国标流 点播/录像回放/录像下载
InviteInfo inviteInfo = inviteStreamService.getInviteInfoByStream(null, stream); InviteInfo inviteInfo = inviteStreamService.getInviteInfoByStream(null, stream);
@ -261,7 +254,7 @@ public class MediaServiceImpl implements IMediaService {
} }
return result; return result;
} }
}else if (MediaStreamUtil.JT1078.equals(app)) { }else if (MediaStreamUtil.RTP_APP.equals(app)) {
// 判断是否是1078播放类型 // 判断是否是1078播放类型
JTMediaStreamType jtMediaStreamType = ijt1078Service.checkStreamFromJt(stream); JTMediaStreamType jtMediaStreamType = ijt1078Service.checkStreamFromJt(stream);
if (jtMediaStreamType != null) { if (jtMediaStreamType != null) {

View File

@ -101,11 +101,11 @@ public class RtpServerServiceImpl implements IReceiveRtpServerService {
log.warn("[openRTPServer] 平台对接时下级可能自定义ssrc但是tcp模式zlm收流目前无法更新ssrc可能收流超时此时请使用udp收流或者关闭ssrc校验"); log.warn("[openRTPServer] 平台对接时下级可能自定义ssrc但是tcp模式zlm收流目前无法更新ssrc可能收流超时此时请使用udp收流或者关闭ssrc校验");
} }
SSRCInfo ssrcInfo = new SSRCInfo(0, ssrc, MediaStreamUtil.GB28181, streamId); SSRCInfo ssrcInfo = new SSRCInfo(0, ssrc, MediaStreamUtil.RTP_APP, streamId);
if (presetSSRC == null) { if (presetSSRC == null) {
ssrcInfo.setAllocatedSsrc(ssrc); ssrcInfo.setAllocatedSsrc(ssrc);
} }
RTPServerParam rtpServerParam = new RTPServerParam(mediaServer, MediaStreamUtil.GB28181, streamId, ssrcCheck ? Long.parseLong(ssrc): 0L, null, onlyAuto, disableAuto, false, tcpMode); RTPServerParam rtpServerParam = new RTPServerParam(mediaServer, MediaStreamUtil.RTP_APP, streamId, ssrcCheck ? Long.parseLong(ssrc): 0L, null, onlyAuto, disableAuto, false, tcpMode);
int rtpServerPort = openRTPServer(rtpServerParam, ((code, msg, data) -> { int rtpServerPort = openRTPServer(rtpServerParam, ((code, msg, data) -> {
if (code == InviteErrorCode.SUCCESS.getCode()) { if (code == InviteErrorCode.SUCCESS.getCode()) {
OpenRTPServerResult openRTPServerResult = new OpenRTPServerResult(); OpenRTPServerResult openRTPServerResult = new OpenRTPServerResult();
@ -124,7 +124,7 @@ public class RtpServerServiceImpl implements IReceiveRtpServerService {
} }
})); }));
ssrcInfo.setPort(rtpServerPort); ssrcInfo.setPort(rtpServerPort);
return new SSRCInfo(rtpServerPort, ssrc, MediaStreamUtil.GB28181, streamId); return new SSRCInfo(rtpServerPort, ssrc, MediaStreamUtil.RTP_APP, streamId);
} }
@Override @Override

View File

@ -101,7 +101,7 @@ public class PsController {
RTPServerParam rtpServerParam = new RTPServerParam(); RTPServerParam rtpServerParam = new RTPServerParam();
rtpServerParam.setMediaServer(mediaServer); rtpServerParam.setMediaServer(mediaServer);
rtpServerParam.setApp(MediaStreamUtil.GB28181); rtpServerParam.setApp(MediaStreamUtil.RTP_APP);
rtpServerParam.setStreamId(stream); rtpServerParam.setStreamId(stream);
rtpServerParam.setSsrc(ssrcInt); rtpServerParam.setSsrc(ssrcInt);
rtpServerParam.setTcpMode(tcpMode); rtpServerParam.setTcpMode(tcpMode);
@ -162,7 +162,7 @@ public class PsController {
public void closeRtpServer(String stream) { public void closeRtpServer(String stream) {
log.info("[第三方PS服务对接->关闭收流] stream->{}", stream); log.info("[第三方PS服务对接->关闭收流] stream->{}", stream);
MediaServer mediaServerItem = mediaServerService.getDefaultMediaServer(); MediaServer mediaServerItem = mediaServerService.getDefaultMediaServer();
receiveRtpServerService.closeRTPServer(mediaServerItem, MediaStreamUtil.GB28181, stream); receiveRtpServerService.closeRTPServer(mediaServerItem, MediaStreamUtil.RTP_APP, stream);
String receiveKey = VideoManagerConstants.WVP_OTHER_RECEIVE_PS_INFO + userSetting.getServerId() + "_*_" + stream; String receiveKey = VideoManagerConstants.WVP_OTHER_RECEIVE_PS_INFO + userSetting.getServerId() + "_*_" + stream;
List<Object> scan = RedisUtil.scan(redisTemplate, receiveKey); List<Object> scan = RedisUtil.scan(redisTemplate, receiveKey);
if (!scan.isEmpty()) { if (!scan.isEmpty()) {

View File

@ -101,7 +101,7 @@ public class RtpController {
RTPServerParam rtpServerParam = new RTPServerParam(); RTPServerParam rtpServerParam = new RTPServerParam();
rtpServerParam.setMediaServer(mediaServer); rtpServerParam.setMediaServer(mediaServer);
rtpServerParam.setApp(MediaStreamUtil.GB28181); rtpServerParam.setApp(MediaStreamUtil.RTP_APP);
rtpServerParam.setStreamId(stream); rtpServerParam.setStreamId(stream);
rtpServerParam.setSsrc(ssrcInt); rtpServerParam.setSsrc(ssrcInt);
rtpServerParam.setTcpMode(tcpMode); rtpServerParam.setTcpMode(tcpMode);
@ -173,8 +173,8 @@ public class RtpController {
public void closeRtpServer(String stream) { public void closeRtpServer(String stream) {
log.info("[第三方服务对接->关闭收流] stream->{}", stream); log.info("[第三方服务对接->关闭收流] stream->{}", stream);
MediaServer mediaServerItem = mediaServerService.getDefaultMediaServer(); MediaServer mediaServerItem = mediaServerService.getDefaultMediaServer();
receiveRtpServerService.closeRTPServer(mediaServerItem, MediaStreamUtil.GB28181, stream); receiveRtpServerService.closeRTPServer(mediaServerItem, MediaStreamUtil.RTP_APP, stream);
receiveRtpServerService.closeRTPServer(mediaServerItem, MediaStreamUtil.GB28181, stream+ "_a"); receiveRtpServerService.closeRTPServer(mediaServerItem, MediaStreamUtil.RTP_APP, stream+ "_a");
String receiveKey = VideoManagerConstants.WVP_OTHER_RECEIVE_RTP_INFO + userSetting.getServerId() + "_*_" + stream; String receiveKey = VideoManagerConstants.WVP_OTHER_RECEIVE_RTP_INFO + userSetting.getServerId() + "_*_" + stream;
List<Object> scan = RedisUtil.scan(redisTemplate, receiveKey); List<Object> scan = RedisUtil.scan(redisTemplate, receiveKey);
if (scan.size() > 0) { if (scan.size() > 0) {

View File

@ -247,7 +247,7 @@ public class ApiStreamController {
} }
try { try {
cmder.streamByeCmd(device, code, MediaStreamUtil.GB28181, inviteInfo.getStream(), null, null); cmder.streamByeCmd(device, code, MediaStreamUtil.RTP_APP, inviteInfo.getStream(), null, null);
} catch (InvalidArgumentException | ParseException | SipException | SsrcTransactionNotFoundException e) { } catch (InvalidArgumentException | ParseException | SipException | SsrcTransactionNotFoundException e) {
JSONObject result = new JSONObject(); JSONObject result = new JSONObject();
result.put("error","发送BYE失败" + e.getMessage()); result.put("error","发送BYE失败" + e.getMessage());