优化接收BYE消息后的处理
parent
d79298c795
commit
632075da9b
|
@ -175,13 +175,13 @@ public class ByeRequestProcessor extends SIPRequestProcessorParent implements In
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
System.out.println(callIdHeader.getCallId());
|
||||||
// 可能是设备发送的停止
|
// 可能是设备发送的停止
|
||||||
SsrcTransaction ssrcTransaction = streamSession.getSsrcTransactionByCallId(callIdHeader.getCallId());
|
SsrcTransaction ssrcTransaction = streamSession.getSsrcTransactionByCallId(callIdHeader.getCallId());
|
||||||
if (ssrcTransaction == null) {
|
if (ssrcTransaction == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
logger.info("[收到bye] 来自设备:{}, 通道已停止推流: {}", ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId());
|
logger.info("[收到bye] 来自设备:{}, 通道: {}, 类型: {}", ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId(), ssrcTransaction.getType());
|
||||||
|
|
||||||
ParentPlatform platform = platformService.queryPlatformByServerGBId(ssrcTransaction.getDeviceId());
|
ParentPlatform platform = platformService.queryPlatformByServerGBId(ssrcTransaction.getDeviceId());
|
||||||
if (platform != null ) {
|
if (platform != null ) {
|
||||||
|
@ -210,13 +210,35 @@ public class ByeRequestProcessor extends SIPRequestProcessorParent implements In
|
||||||
logger.info("[收到bye] 未找到通道,设备:{}, 通道:{}", ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId());
|
logger.info("[收到bye] 未找到通道,设备:{}, 通道:{}", ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
storager.stopPlay(device.getDeviceId(), channel.getChannelId());
|
switch (ssrcTransaction.getType()){
|
||||||
InviteInfo inviteInfo = inviteStreamService.getInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, device.getDeviceId(), channel.getChannelId());
|
case PLAY:
|
||||||
if (inviteInfo != null) {
|
case PLAYBACK:
|
||||||
inviteStreamService.removeInviteInfo(inviteInfo);
|
case DOWNLOAD:
|
||||||
if (inviteInfo.getStreamInfo() != null) {
|
InviteInfo inviteInfo = inviteStreamService.getInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, device.getDeviceId(), channel.getChannelId());
|
||||||
mediaServerService.closeRTPServer(inviteInfo.getStreamInfo().getMediaServerId(), inviteInfo.getStreamInfo().getStream());
|
if (inviteInfo != null) {
|
||||||
}
|
storager.stopPlay(device.getDeviceId(), channel.getChannelId());
|
||||||
|
inviteStreamService.removeInviteInfo(inviteInfo);
|
||||||
|
if (inviteInfo.getStreamInfo() != null) {
|
||||||
|
mediaServerService.closeRTPServer(inviteInfo.getStreamInfo().getMediaServerId(), inviteInfo.getStreamInfo().getStream());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case BROADCAST:
|
||||||
|
case TALK:
|
||||||
|
// 查找来源的对讲设备,发送停止
|
||||||
|
Device sourceDevice = storager.queryVideoDeviceByPlatformIdAndChannelId(ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId());
|
||||||
|
AudioBroadcastCatch audioBroadcastCatch = audioBroadcastManager.get(ssrcTransaction.getDeviceId(), channel.getChannelId());
|
||||||
|
if (sourceDevice != null) {
|
||||||
|
playService.stopAudioBroadcast(sourceDevice.getDeviceId(), channel.getChannelId());
|
||||||
|
}
|
||||||
|
if (audioBroadcastCatch != null) {
|
||||||
|
// 来自上级平台的停止对讲
|
||||||
|
logger.info("[停止对讲] 来自上级,平台:{}, 通道:{}", ssrcTransaction.getDeviceId(), channel.getChannelId());
|
||||||
|
audioBroadcastManager.del(ssrcTransaction.getDeviceId(), channel.getChannelId());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
// 释放ssrc
|
// 释放ssrc
|
||||||
MediaServer mediaServerItem = mediaServerService.getOne(ssrcTransaction.getMediaServerId());
|
MediaServer mediaServerItem = mediaServerService.getOne(ssrcTransaction.getMediaServerId());
|
||||||
|
@ -224,19 +246,6 @@ public class ByeRequestProcessor extends SIPRequestProcessorParent implements In
|
||||||
mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcTransaction.getSsrc());
|
mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcTransaction.getSsrc());
|
||||||
}
|
}
|
||||||
streamSession.removeByCallId(device.getDeviceId(), channel.getChannelId(), ssrcTransaction.getCallId());
|
streamSession.removeByCallId(device.getDeviceId(), channel.getChannelId(), ssrcTransaction.getCallId());
|
||||||
if (ssrcTransaction.getType() == InviteSessionType.BROADCAST) {
|
|
||||||
// 查找来源的对讲设备,发送停止
|
|
||||||
Device sourceDevice = storager.queryVideoDeviceByPlatformIdAndChannelId(ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId());
|
|
||||||
if (sourceDevice != null) {
|
|
||||||
playService.stopAudioBroadcast(sourceDevice.getDeviceId(), channel.getChannelId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
AudioBroadcastCatch audioBroadcastCatch = audioBroadcastManager.get(ssrcTransaction.getDeviceId(), channel.getChannelId());
|
|
||||||
if (audioBroadcastCatch != null) {
|
|
||||||
// 来自上级平台的停止对讲
|
|
||||||
logger.info("[停止对讲] 来自上级,平台:{}, 通道:{}", ssrcTransaction.getDeviceId(), channel.getChannelId());
|
|
||||||
audioBroadcastManager.del(ssrcTransaction.getDeviceId(), channel.getChannelId());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -202,15 +202,16 @@ public class ZLMHttpHookListener {
|
||||||
if (mediaServer == null) {
|
if (mediaServer == null) {
|
||||||
return HookResult.SUCCESS();
|
return HookResult.SUCCESS();
|
||||||
}
|
}
|
||||||
|
if (param.getSchema().equalsIgnoreCase("rtsp")) {
|
||||||
if (param.isRegist()) {
|
if (param.isRegist()) {
|
||||||
logger.info("[ZLM HOOK] 流注册, {}->{}->{}/{}", param.getMediaServerId(), param.getSchema(), param.getApp(), param.getStream());
|
logger.info("[ZLM HOOK] 流注册, {}->{}->{}/{}", param.getMediaServerId(), param.getSchema(), param.getApp(), param.getStream());
|
||||||
MediaArrivalEvent mediaArrivalEvent = MediaArrivalEvent.getInstance(this, param, mediaServer);
|
MediaArrivalEvent mediaArrivalEvent = MediaArrivalEvent.getInstance(this, param, mediaServer);
|
||||||
applicationEventPublisher.publishEvent(mediaArrivalEvent);
|
applicationEventPublisher.publishEvent(mediaArrivalEvent);
|
||||||
} else {
|
} else {
|
||||||
logger.info("[ZLM HOOK] 流注销, {}->{}->{}/{}", param.getMediaServerId(), param.getSchema(), param.getApp(), param.getStream());
|
logger.info("[ZLM HOOK] 流注销, {}->{}->{}/{}", param.getMediaServerId(), param.getSchema(), param.getApp(), param.getStream());
|
||||||
MediaDepartureEvent mediaDepartureEvent = MediaDepartureEvent.getInstance(this, param, mediaServer);
|
MediaDepartureEvent mediaDepartureEvent = MediaDepartureEvent.getInstance(this, param, mediaServer);
|
||||||
applicationEventPublisher.publishEvent(mediaDepartureEvent);
|
applicationEventPublisher.publishEvent(mediaDepartureEvent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return HookResult.SUCCESS();
|
return HookResult.SUCCESS();
|
||||||
|
|
Loading…
Reference in New Issue