| | |
| | | import com.genersoft.iot.vmp.storager.dao.StreamProxyMapper; |
| | | import com.genersoft.iot.vmp.utils.DateUtil; |
| | | import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; |
| | | import com.genersoft.iot.vmp.vmanager.bean.ResourceBaceInfo; |
| | | import com.genersoft.iot.vmp.vmanager.bean.ResourceBaseInfo; |
| | | import com.github.pagehelper.PageInfo; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | |
| | | } |
| | | JSONArray dataArray = jsonObject.getJSONArray("data"); |
| | | JSONObject mediaServerConfig = dataArray.getJSONObject(0); |
| | | String ffmpegCmd = mediaServerConfig.getString(param.getFfmpeg_cmd_key()); |
| | | String ffmpegCmd = mediaServerConfig.getString(param.getFfmpegCmdKey()); |
| | | String schema = getSchemaFromFFmpegCmd(ffmpegCmd); |
| | | if (schema == null) { |
| | | throw new ControllerException(ErrorCode.ERROR100.getCode(), "ffmpeg拉流代理无法从ffmpeg cmd中获取到输出格式"); |
| | |
| | | dstUrl = String.format("rtmp://%s:%s/%s/%s", "127.0.0.1", mediaInfo.getRtmpPort(), param.getApp(), |
| | | param.getStream()); |
| | | } |
| | | param.setDst_url(dstUrl); |
| | | param.setDstUrl(dstUrl); |
| | | logger.info("[拉流代理] 输出地址为:{}", dstUrl); |
| | | param.setMediaServerId(mediaInfo.getId()); |
| | | boolean saveResult; |
| | |
| | | }else { |
| | | param.setEnable(false); |
| | | // 直接移除 |
| | | if (param.isEnable_remove_none_reader()) { |
| | | if (param.isEnableRemoveNoneReader()) { |
| | | del(param.getApp(), param.getStream()); |
| | | }else { |
| | | updateStreamProxy(param); |
| | |
| | | } |
| | | if ("default".equals(param.getType())){ |
| | | result = zlmresTfulUtils.addStreamProxy(mediaServerItem, param.getApp(), param.getStream(), param.getUrl(), |
| | | param.isEnable_audio(), param.isEnable_mp4(), param.getRtp_type()); |
| | | param.isEnableAudio(), param.isEnableMp4(), param.getRtpType()); |
| | | }else if ("ffmpeg".equals(param.getType())) { |
| | | result = zlmresTfulUtils.addFFmpegSource(mediaServerItem, param.getSrc_url(), param.getDst_url(), |
| | | param.getTimeout_ms() + "", param.isEnable_audio(), param.isEnable_mp4(), |
| | | param.getFfmpeg_cmd_key()); |
| | | System.out.println(result); |
| | | result = zlmresTfulUtils.addFFmpegSource(mediaServerItem, param.getSrcUrl(), param.getDstUrl(), |
| | | param.getTimeoutMs() + "", param.isEnableAudio(), param.isEnableMp4(), |
| | | param.getFfmpegCmdKey()); |
| | | } |
| | | return result; |
| | | } |
| | |
| | | updateStreamProxy(streamProxy); |
| | | }else { |
| | | logger.info("启用代理失败: {}/{}->{}({})", app, stream, jsonObject.getString("msg"), |
| | | streamProxy.getSrc_url() == null? streamProxy.getUrl():streamProxy.getSrc_url()); |
| | | streamProxy.getSrcUrl() == null? streamProxy.getUrl():streamProxy.getSrcUrl()); |
| | | } |
| | | } |
| | | return result; |
| | |
| | | @Override |
| | | public void zlmServerOnline(String mediaServerId) { |
| | | // 移除开启了无人观看自动移除的流 |
| | | List<StreamProxyItem> streamProxyItemList = streamProxyMapper.selecAutoRemoveItemByMediaServerId(mediaServerId); |
| | | List<StreamProxyItem> streamProxyItemList = streamProxyMapper.selectAutoRemoveItemByMediaServerId(mediaServerId); |
| | | if (streamProxyItemList.size() > 0) { |
| | | gbStreamMapper.batchDel(streamProxyItemList); |
| | | } |
| | |
| | | @Override |
| | | public void zlmServerOffline(String mediaServerId) { |
| | | // 移除开启了无人观看自动移除的流 |
| | | List<StreamProxyItem> streamProxyItemList = streamProxyMapper.selecAutoRemoveItemByMediaServerId(mediaServerId); |
| | | List<StreamProxyItem> streamProxyItemList = streamProxyMapper.selectAutoRemoveItemByMediaServerId(mediaServerId); |
| | | if (streamProxyItemList.size() > 0) { |
| | | gbStreamMapper.batchDel(streamProxyItemList); |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public ResourceBaceInfo getOverview() { |
| | | return streamProxyMapper.getOverview(); |
| | | public ResourceBaseInfo getOverview() { |
| | | |
| | | int total = streamProxyMapper.getAllCount(); |
| | | int online = streamProxyMapper.getOnline(); |
| | | |
| | | return new ResourceBaseInfo(total, online); |
| | | } |
| | | } |