| | |
| | | import com.genersoft.iot.vmp.common.CommonCallback; |
| | | import com.genersoft.iot.vmp.conf.UserSetting; |
| | | import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem; |
| | | import com.genersoft.iot.vmp.media.zlm.dto.*; |
| | | import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeFactory; |
| | | import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForRtpServerTimeout; |
| | | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | if (jsonObject.getInteger("code") == 0) { |
| | | localPort = jsonObject.getInteger("port"); |
| | | HookSubscribeForRtpServerTimeout hookSubscribeForRtpServerTimeout = HookSubscribeFactory.on_rtp_server_timeout(ssrc, null, serverItem.getId()); |
| | | // 订阅 zlm启动事件, 新的zlm也会从这里进入系统 |
| | | hookSubscribe.addSubscribe(hookSubscribeForRtpServerTimeout, |
| | | (MediaServerItem mediaServerItem, JSONObject response)->{ |
| | | logger.info("[上级点播] {}->监听端口到期继续保持监听", ssrc); |
| | | keepPort(serverItem, ssrc); |
| | | int port = keepPort(serverItem, ssrc); |
| | | if (port == 0) { |
| | | logger.info("[上级点播] {}->监听端口失败,移除监听", ssrc); |
| | | hookSubscribe.removeSubscribe(hookSubscribeForRtpServerTimeout); |
| | | } |
| | | }); |
| | | logger.info("[上级点播] {}->监听端口: {}", ssrc, localPort); |
| | | }else { |
| | |
| | | */ |
| | | public Boolean isRtpReady(MediaServerItem mediaServerItem, String streamId) { |
| | | JSONObject mediaInfo = zlmresTfulUtils.getMediaInfo(mediaServerItem,"rtp", "rtsp", streamId); |
| | | if (mediaInfo.getInteger("code") == -2) { |
| | | return null; |
| | | } |
| | | return (mediaInfo.getInteger("code") == 0 && mediaInfo.getBoolean("online")); |
| | | } |
| | | |
| | |
| | | */ |
| | | public Boolean isStreamReady(MediaServerItem mediaServerItem, String app, String streamId) { |
| | | JSONObject mediaInfo = zlmresTfulUtils.getMediaList(mediaServerItem, app, streamId); |
| | | return mediaInfo != null && (mediaInfo.getInteger("code") == 0 |
| | | |
| | | if (mediaInfo == null || (mediaInfo.getInteger("code") == -2)) { |
| | | return null; |
| | | } |
| | | return (mediaInfo.getInteger("code") == 0 |
| | | && mediaInfo.getJSONArray("data") != null |
| | | && mediaInfo.getJSONArray("data").size() > 0); |
| | | } |
| | |
| | | public void closeAllSendRtpStream() { |
| | | |
| | | } |
| | | |
| | | public Boolean updateRtpServerSSRC(MediaServerItem mediaServerItem, String streamId, String ssrc) { |
| | | boolean result = false; |
| | | JSONObject jsonObject = zlmresTfulUtils.updateRtpServerSSRC(mediaServerItem, streamId, ssrc); |
| | | if (jsonObject == null) { |
| | | logger.error("[更新RTPServer] 失败: 请检查ZLM服务"); |
| | | } else if (jsonObject.getInteger("code") == 0) { |
| | | result= true; |
| | | logger.info("[更新RTPServer] 成功"); |
| | | } else { |
| | | logger.error("[更新RTPServer] 失败: {}, streamId:{},ssrc:{}->\r\n{}",jsonObject.getString("msg"), |
| | | streamId, ssrc, jsonObject); |
| | | } |
| | | return result; |
| | | } |
| | | } |