Commit 82adc0cb23f3ee47322e78889cdaba57e9309000

Authored by 648540858
1 parent 455e58f8

完善语音对讲级联

src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderProvider.java
... ... @@ -170,11 +170,11 @@ public class SIPRequestHeaderProvider {
170 170 //from
171 171 SipURI fromSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(),sipConfig.getDomain());
172 172 Address fromAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(fromSipURI);
173   - FromHeader fromHeader = sipLayer.getSipFactory().createHeaderFactory().createFromHeader(fromAddress, transactionInfo.getFromTag());
  173 + FromHeader fromHeader = sipLayer.getSipFactory().createHeaderFactory().createFromHeader(fromAddress, !transactionInfo.isAsSender()? transactionInfo.getToTag():transactionInfo.getFromTag());
174 174 //to
175 175 SipURI toSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(channelId,device.getHostAddress());
176 176 Address toAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(toSipURI);
177   - ToHeader toHeader = sipLayer.getSipFactory().createHeaderFactory().createToHeader(toAddress, transactionInfo.getToTag());
  177 + ToHeader toHeader = sipLayer.getSipFactory().createHeaderFactory().createToHeader(toAddress, !transactionInfo.isAsSender()? transactionInfo.getToTag(): transactionInfo.getFromTag());
178 178  
179 179 //Forwards
180 180 MaxForwardsHeader maxForwards = sipLayer.getSipFactory().createHeaderFactory().createMaxForwardsHeader(70);
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/ByeRequestProcessor.java
... ... @@ -204,28 +204,33 @@ public class ByeRequestProcessor extends SIPRequestProcessorParent implements In
204 204 // case download:
205 205 // break;
206 206 case broadcast:
207   - String deviceId = ssrcTransaction.getDeviceId();
208 207 String channelId1 = ssrcTransaction.getChannelId();
209 208  
210   - Device deviceFromTransaction = storager.queryVideoDevice(deviceId);
  209 + Device deviceFromTransaction = storager.queryVideoDevice(ssrcTransaction.getDeviceId());
211 210 if (deviceFromTransaction == null) {
212   - ParentPlatform parentPlatform = storager.queryParentPlatByServerGBId(deviceId);
  211 + ParentPlatform parentPlatform = storager.queryParentPlatByServerGBId(ssrcTransaction.getDeviceId());
213 212 if (parentPlatform != null) {
214 213 // 来自上级平台的停止对讲
  214 + logger.info("[停止对讲] 来自上级,平台:{}, 通道:{}", ssrcTransaction.getDeviceId(), channelId1);
215 215 // 释放ssrc
216   - MediaServerItem mediaServerItemFromTransaction = mediaServerService.getOne(ssrcTransaction.getMediaServerId());
217   - if (mediaServerItemFromTransaction != null) {
218   - mediaServerService.releaseSsrc(mediaServerItemFromTransaction.getId(), ssrcTransaction.getSsrc());
219   - }
220 216 streamSession.remove(ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId(), ssrcTransaction.getStream());
  217 + if (mediaServerItem != null) {
  218 + zlmrtpServerFactory.closeRtpServer(mediaServerItem, ssrcTransaction.getStream());
  219 + }
  220 + // 查找来源的对讲设备,发送停止
  221 + Device sourceDevice = storager.queryVideoDeviceByPlatformIdAndChannelId(ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId());
  222 + if (sourceDevice != null) {
  223 + playService.stopAudioBroadcast(sourceDevice.getDeviceId(), channelId);
  224 + }
221 225 }
222 226 }else {
223 227 // 来自设备的停止对讲
  228 +
224 229 // 如果是来自设备,则听停止推流。 来自上级则停止收流
225   - AudioBroadcastCatch audioBroadcastCatch = audioBroadcastManager.get(deviceId, channelId1);
  230 + AudioBroadcastCatch audioBroadcastCatch = audioBroadcastManager.get(ssrcTransaction.getDeviceId(), channelId1);
226 231 if (audioBroadcastCatch != null) {
227 232 //
228   - SendRtpItem sendRtpItemForBroadcast = redisCatchStorage.querySendRTPServer(deviceId, channelId1,
  233 + SendRtpItem sendRtpItemForBroadcast = redisCatchStorage.querySendRTPServer(ssrcTransaction.getDeviceId(), channelId1,
229 234 audioBroadcastCatch.getStream(), audioBroadcastCatch.getSipTransactionInfo().getCallId());
230 235 if (sendRtpItemForBroadcast != null) {
231 236 MediaServerItem mediaServerItemForBroadcast = mediaServerService.getOne(sendRtpItem.getMediaServerId());
... ... @@ -257,6 +262,7 @@ public class ByeRequestProcessor extends SIPRequestProcessorParent implements In
257 262 commanderForPlatform.streamByeCmd(parentPlatform, channelId1, transaction.getStream(), transaction.getCallId(), eventResult -> {
258 263 streamSession.remove(transaction.getDeviceId(), transaction.getChannelId(), transaction.getStream());
259 264 });
  265 + audioBroadcastManager.del(transaction.getDeviceId(), channelId1);
260 266 } catch (InvalidArgumentException | SipException | ParseException |
261 267 SsrcTransactionNotFoundException e) {
262 268 logger.error("[命令发送失败] 向{}发送bye失败", transaction.getDeviceId());
... ... @@ -273,14 +279,13 @@ public class ByeRequestProcessor extends SIPRequestProcessorParent implements In
273 279 }
274 280  
275 281 }
276   - redisCatchStorage.deleteSendRTPServer(deviceId, channelId1,
  282 + redisCatchStorage.deleteSendRTPServer(ssrcTransaction.getDeviceId(), channelId1,
277 283 audioBroadcastCatch.getStream(), audioBroadcastCatch.getSipTransactionInfo().getCallId());
278 284  
279 285 }
280   -
281   - audioBroadcastManager.del(deviceId, channelId1);
282 286 }
283 287 }
  288 + audioBroadcastManager.del(ssrcTransaction.getDeviceId(), channelId1);
284 289 break;
285 290 default:
286 291 break;
... ...
src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java
... ... @@ -1039,6 +1039,7 @@ public class PlayServiceImpl implements IPlayService {
1039 1039  
1040 1040 @Override
1041 1041 public void stopAudioBroadcast(String deviceId, String channelId) {
  1042 + logger.info("[停止对讲] 设备:{}, 通道:{}", deviceId, channelId);
1042 1043 List<AudioBroadcastCatch> audioBroadcastCatchList = new ArrayList<>();
1043 1044 if (channelId == null) {
1044 1045 audioBroadcastCatchList.addAll(audioBroadcastManager.get(deviceId));
... ...