| | |
| | | import com.genersoft.iot.vmp.gb28181.transmit.request.SIPRequestAbstractProcessor;
|
| | | import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory;
|
| | | import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
| | |
|
| | | import org.apache.log4j.Logger;
|
| | | import org.slf4j.Logger;
|
| | | import org.slf4j.LoggerFactory;
|
| | |
|
| | | import java.text.ParseException;
|
| | | import java.util.HashMap;
|
| | |
| | | * @date: 2021年3月9日
|
| | | */
|
| | | public class ByeRequestProcessor extends SIPRequestAbstractProcessor {
|
| | |
|
| | | private Logger logger = LoggerFactory.getLogger(ByeRequestProcessor.class);
|
| | |
|
| | | private ISIPCommander cmder;
|
| | |
|
| | |
| | | String platformGbId = ((SipURI) ((HeaderAddress) evt.getRequest().getHeader(FromHeader.NAME)).getAddress().getURI()).getUser();
|
| | | String channelId = ((SipURI) ((HeaderAddress) evt.getRequest().getHeader(ToHeader.NAME)).getAddress().getURI()).getUser();
|
| | | SendRtpItem sendRtpItem = redisCatchStorage.querySendRTPServer(platformGbId, channelId);
|
| | | if (sendRtpItem == null) return;
|
| | | String streamId = sendRtpItem.getStreamId();
|
| | | Map<String, Object> param = new HashMap<>();
|
| | | param.put("vhost","__defaultVhost__");
|
| | | param.put("app","rtp");
|
| | | param.put("app",sendRtpItem.getApp());
|
| | | param.put("stream",streamId);
|
| | | System.out.println("停止向上级推流:" + streamId);
|
| | | param.put("ssrc",sendRtpItem.getSsrc());
|
| | | logger.info("停止向上级推流:" + streamId);
|
| | | zlmrtpServerFactory.stopSendRtpStream(param);
|
| | | redisCatchStorage.deleteSendRTPServer(platformGbId, channelId);
|
| | | if (zlmrtpServerFactory.totalReaderCount(streamId) == 0) {
|
| | | System.out.println(streamId + "无其它观看者,通知设备停止推流");
|
| | | cmder.streamByeCmd(streamId);
|
| | | if (zlmrtpServerFactory.totalReaderCount(sendRtpItem.getApp(), streamId) == 0) {
|
| | | logger.info(streamId + "无其它观看者,通知设备停止推流");
|
| | | cmder.streamByeCmd(sendRtpItem.getDeviceId(), channelId);
|
| | | }
|
| | | }
|
| | | } catch (SipException e) {
|