648540858
2022-03-02 1dcdbc3742835ccab28a8983ae002d2bbdba87eb
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/ByeRequestProcessor.java
@@ -28,10 +28,8 @@
import java.util.HashMap;
import java.util.Map;
/**
 * @description: BYE请求处理器
 * @author: lawrencehj
 * @date:   2021年3月9日
/**
 * SIP命令类型: BYE请求
 */
@Component
public class ByeRequestProcessor extends SIPRequestProcessorParent implements InitializingBean, ISIPRequestProcessor {
@@ -89,18 +87,29 @@
               MediaServerItem mediaInfo = mediaServerService.getOne(sendRtpItem.getMediaServerId());
               zlmrtpServerFactory.stopSendRtpStream(mediaInfo, param);
               redisCatchStorage.deleteSendRTPServer(platformGbId, channelId);
               if (zlmrtpServerFactory.totalReaderCount(mediaInfo, sendRtpItem.getApp(), streamId) == 0) {
               int totalReaderCount = zlmrtpServerFactory.totalReaderCount(mediaInfo, sendRtpItem.getApp(), streamId);
               if (totalReaderCount == 0) {
                  logger.info(streamId + "无其它观看者,通知设备停止推流");
                  cmder.streamByeCmd(sendRtpItem.getDeviceId(), channelId);
               }else if (totalReaderCount == -1){
                  logger.warn(streamId + " 查找其它观看者失败");
               }
            }
            // 可能是设备主动停止
            Device device = storager.queryVideoDeviceByChannelId(platformGbId);
            if (device != null) {
               StreamInfo streamInfo = redisCatchStorage.queryPlayByDevice(device.getDeviceId(), channelId);
               if (streamInfo != null) {
                  redisCatchStorage.stopPlay(streamInfo);
               if (sendRtpItem.isPlay()) {
                  StreamInfo streamInfo = redisCatchStorage.queryPlayByDevice(device.getDeviceId(), channelId);
                  if (streamInfo != null) {
                     redisCatchStorage.stopPlay(streamInfo);
                  }
               }else {
                  StreamInfo streamInfo = redisCatchStorage.queryPlaybackByDevice(device.getDeviceId(), channelId);
                  if (streamInfo != null) {
                     redisCatchStorage.stopPlayback(streamInfo);
                  }
               }
               storager.stopPlay(device.getDeviceId(), channelId);
               mediaServerService.closeRTPServer(device, channelId);
            }