| | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.genersoft.iot.vmp.conf.UserSetting; |
| | | import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem; |
| | | import com.genersoft.iot.vmp.media.zlm.dto.MediaItem; |
| | | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | |
| | | param.put("stream_id", streamId); |
| | | JSONObject jsonObject = zlmresTfulUtils.closeRtpServer(mediaServerItem, param); |
| | | if (jsonObject != null ) { |
| | | System.out.println(jsonObject); |
| | | if (jsonObject.getInteger("code") == 0) { |
| | | return createRTPServer(mediaServerItem, streamId, ssrc, port); |
| | | }else { |
| | |
| | | param.put("stream_id", streamId); |
| | | JSONObject jsonObject = zlmresTfulUtils.closeRtpServer(serverItem, param); |
| | | if (jsonObject != null ) { |
| | | System.out.println(jsonObject); |
| | | if (jsonObject.getInteger("code") == 0) { |
| | | result = jsonObject.getInteger("hit") == 1; |
| | | }else { |
| | |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | // private int getPortFromportRange(MediaServerItem mediaServerItem) { |
| | | // int currentPort = mediaServerItem.getCurrentPort(); |
| | | // if (currentPort == 0) { |
| | | // String[] portRangeStrArray = mediaServerItem.getSendRtpPortRange().split(","); |
| | | // if (portRangeStrArray.length != 2) { |
| | | // portRangeArray[0] = 30000; |
| | | // portRangeArray[1] = 30500; |
| | | // }else { |
| | | // portRangeArray[0] = Integer.parseInt(portRangeStrArray[0]); |
| | | // portRangeArray[1] = Integer.parseInt(portRangeStrArray[1]); |
| | | // } |
| | | // } |
| | | // |
| | | // if (currentPort == 0 || currentPort++ > portRangeArray[1]) { |
| | | // currentPort = portRangeArray[0]; |
| | | // mediaServerItem.setCurrentPort(currentPort); |
| | | // return portRangeArray[0]; |
| | | // } else { |
| | | // if (currentPort % 2 == 1) { |
| | | // currentPort++; |
| | | // } |
| | | // currentPort++; |
| | | // mediaServerItem.setCurrentPort(currentPort); |
| | | // return currentPort; |
| | | // } |
| | | // } |
| | | |
| | | /** |
| | | * 创建一个国标推流 |
| | |
| | | public void closeAllSendRtpStream() { |
| | | |
| | | } |
| | | |
| | | public MediaItem getMediaInfo(MediaServerItem mediaServerItem, String app, String stream) { |
| | | JSONObject json = zlmresTfulUtils.getMediaList(mediaServerItem, app, stream); |
| | | MediaItem mediaItem = null; |
| | | if (json == null || json.getInteger("code") != 0) { |
| | | return null; |
| | | } else { |
| | | JSONArray data = json.getJSONArray("data"); |
| | | if (data == null || data.size() == 0) { |
| | | return null; |
| | | }else { |
| | | mediaItem = JSONObject.toJavaObject(data.getJSONObject(0), MediaItem.class); |
| | | } |
| | | } |
| | | return mediaItem; |
| | | } |
| | | } |