临时提交
This commit is contained in:
@@ -4,12 +4,14 @@ import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.hook.OnStreamChangedHookParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 视频信息
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "视频信息")
|
||||
public class MediaInfo {
|
||||
@Schema(description = "应用名")
|
||||
@@ -41,6 +43,8 @@ public class MediaInfo {
|
||||
private Boolean online;
|
||||
@Schema(description = "unknown = 0,rtmp_push=1,rtsp_push=2,rtp_push=3,pull=4,ffmpeg_pull=5,mp4_vod=6,device_chn=7")
|
||||
private Integer originType;
|
||||
@Schema(description = "产生流的源流地址")
|
||||
private String originUrl;
|
||||
@Schema(description = "存活时间,单位秒")
|
||||
private Long aliveSecond;
|
||||
@Schema(description = "数据产生速度,单位byte/s")
|
||||
@@ -60,6 +64,7 @@ public class MediaInfo {
|
||||
Integer totalReaderCount = jsonObject.getInteger("totalReaderCount");
|
||||
Boolean online = jsonObject.getBoolean("online");
|
||||
Integer originType = jsonObject.getInteger("originType");
|
||||
String originUrl = jsonObject.getString("originUrl");
|
||||
Long aliveSecond = jsonObject.getLong("aliveSecond");
|
||||
Long bytesSpeed = jsonObject.getLong("bytesSpeed");
|
||||
if (totalReaderCount != null) {
|
||||
@@ -71,6 +76,10 @@ public class MediaInfo {
|
||||
if (originType != null) {
|
||||
mediaInfo.setOriginType(originType);
|
||||
}
|
||||
if (originUrl != null) {
|
||||
mediaInfo.setOriginUrl(originUrl);
|
||||
}
|
||||
|
||||
if (aliveSecond != null) {
|
||||
mediaInfo.setAliveSecond(aliveSecond);
|
||||
}
|
||||
@@ -138,6 +147,7 @@ public class MediaInfo {
|
||||
mediaInfo.setReaderCount(param.getTotalReaderCount());
|
||||
mediaInfo.setOnline(param.isRegist());
|
||||
mediaInfo.setOriginType(param.getOriginType());
|
||||
mediaInfo.setOriginUrl(param.getOriginUrl());
|
||||
mediaInfo.setAliveSecond(param.getAliveSecond());
|
||||
mediaInfo.setBytesSpeed(param.getBytesSpeed());
|
||||
List<OnStreamChangedHookParam.MediaTrack> tracks = param.getTracks();
|
||||
@@ -177,140 +187,4 @@ public class MediaInfo {
|
||||
}
|
||||
return mediaInfo;
|
||||
}
|
||||
|
||||
public Integer getReaderCount() {
|
||||
return readerCount;
|
||||
}
|
||||
|
||||
public void setReaderCount(Integer readerCount) {
|
||||
this.readerCount = readerCount;
|
||||
}
|
||||
|
||||
public String getVideoCodec() {
|
||||
return videoCodec;
|
||||
}
|
||||
|
||||
public void setVideoCodec(String videoCodec) {
|
||||
this.videoCodec = videoCodec;
|
||||
}
|
||||
|
||||
public Integer getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
public void setWidth(Integer width) {
|
||||
this.width = width;
|
||||
}
|
||||
|
||||
public Integer getHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
public void setHeight(Integer height) {
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public String getAudioCodec() {
|
||||
return audioCodec;
|
||||
}
|
||||
|
||||
public void setAudioCodec(String audioCodec) {
|
||||
this.audioCodec = audioCodec;
|
||||
}
|
||||
|
||||
public Integer getAudioChannels() {
|
||||
return audioChannels;
|
||||
}
|
||||
|
||||
public void setAudioChannels(Integer audioChannels) {
|
||||
this.audioChannels = audioChannels;
|
||||
}
|
||||
|
||||
public Integer getAudioSampleRate() {
|
||||
return audioSampleRate;
|
||||
}
|
||||
|
||||
public void setAudioSampleRate(Integer audioSampleRate) {
|
||||
this.audioSampleRate = audioSampleRate;
|
||||
}
|
||||
|
||||
public Long getDuration() {
|
||||
return duration;
|
||||
}
|
||||
|
||||
public void setDuration(Long duration) {
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
public Boolean getOnline() {
|
||||
return online;
|
||||
}
|
||||
|
||||
public void setOnline(Boolean online) {
|
||||
this.online = online;
|
||||
}
|
||||
|
||||
public Integer getOriginType() {
|
||||
return originType;
|
||||
}
|
||||
|
||||
public void setOriginType(Integer originType) {
|
||||
this.originType = originType;
|
||||
}
|
||||
|
||||
public Long getAliveSecond() {
|
||||
return aliveSecond;
|
||||
}
|
||||
|
||||
public void setAliveSecond(Long aliveSecond) {
|
||||
this.aliveSecond = aliveSecond;
|
||||
}
|
||||
|
||||
public Long getBytesSpeed() {
|
||||
return bytesSpeed;
|
||||
}
|
||||
|
||||
public void setBytesSpeed(Long bytesSpeed) {
|
||||
this.bytesSpeed = bytesSpeed;
|
||||
}
|
||||
|
||||
public String getApp() {
|
||||
return app;
|
||||
}
|
||||
|
||||
public void setApp(String app) {
|
||||
this.app = app;
|
||||
}
|
||||
|
||||
public String getStream() {
|
||||
return stream;
|
||||
}
|
||||
|
||||
public void setStream(String stream) {
|
||||
this.stream = stream;
|
||||
}
|
||||
|
||||
public MediaServer getMediaServer() {
|
||||
return mediaServer;
|
||||
}
|
||||
|
||||
public void setMediaServer(MediaServer mediaServer) {
|
||||
this.mediaServer = mediaServer;
|
||||
}
|
||||
|
||||
public String getSchema() {
|
||||
return schema;
|
||||
}
|
||||
|
||||
public void setSchema(String schema) {
|
||||
this.schema = schema;
|
||||
}
|
||||
|
||||
public String getCallId() {
|
||||
return callId;
|
||||
}
|
||||
|
||||
public void setCallId(String callId) {
|
||||
this.callId = callId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.genersoft.iot.vmp.media.event.mediaServer;
|
||||
|
||||
import com.genersoft.iot.vmp.service.IPlayService;
|
||||
import com.genersoft.iot.vmp.streamProxy.service.IStreamProxyService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -22,9 +21,6 @@ public class MediaServerStatusEventListener {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(MediaServerStatusEventListener.class);
|
||||
|
||||
@Autowired
|
||||
private IStreamProxyService streamProxyService;
|
||||
|
||||
@Autowired
|
||||
private IPlayService playService;
|
||||
|
||||
@@ -32,7 +28,6 @@ public class MediaServerStatusEventListener {
|
||||
@EventListener
|
||||
public void onApplicationEvent(MediaServerOnlineEvent event) {
|
||||
logger.info("[媒体节点] 上线 ID:" + event.getMediaServerId());
|
||||
streamProxyService.zlmServerOnline(event.getMediaServerId());
|
||||
playService.zlmServerOnline(event.getMediaServerId());
|
||||
}
|
||||
|
||||
@@ -42,7 +37,6 @@ public class MediaServerStatusEventListener {
|
||||
|
||||
logger.info("[媒体节点] 离线,ID:" + event.getMediaServerId());
|
||||
// 处理ZLM离线
|
||||
streamProxyService.zlmServerOffline(event.getMediaServerId());
|
||||
playService.zlmServerOffline(event.getMediaServerId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ public interface IMediaNodeServerService {
|
||||
|
||||
WVPResult<String> addFFmpegSource(MediaServer mediaServer, String srcUrl, String dstUrl, int timeoutMs, boolean enableAudio, boolean enableMp4, String ffmpegCmdKey);
|
||||
|
||||
WVPResult<String> addStreamProxy(MediaServer mediaServer, String app, String stream, String url, boolean enableAudio, boolean enableMp4, String rtpType);
|
||||
WVPResult<String> addStreamProxy(MediaServer mediaServer, String app, String stream, String url, boolean enableAudio, boolean enableMp4, String rtpType, Integer timeout);
|
||||
|
||||
Boolean delFFmpegSource(MediaServer mediaServer, String streamKey);
|
||||
|
||||
@@ -65,4 +65,6 @@ public interface IMediaNodeServerService {
|
||||
Long updateDownloadProcess(MediaServer mediaServer, String app, String stream);
|
||||
|
||||
StreamInfo startProxy(MediaServer mediaServer, StreamProxy streamProxy);
|
||||
|
||||
void stopProxy(MediaServer mediaServer, String streamKey);
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ public interface IMediaServerService {
|
||||
void closeRTPServer(MediaServer mediaServerItem, String streamId);
|
||||
|
||||
void closeRTPServer(MediaServer mediaServerItem, String streamId, CommonCallback<Boolean> callback);
|
||||
|
||||
Boolean updateRtpServerSSRC(MediaServer mediaServerItem, String streamId, String ssrc);
|
||||
|
||||
void closeRTPServer(String mediaServerId, String streamId);
|
||||
@@ -98,7 +99,7 @@ public interface IMediaServerService {
|
||||
|
||||
WVPResult<String> addFFmpegSource(MediaServer mediaServerItem, String srcUrl, String dstUrl, int timeoutMs, boolean enableAudio, boolean enableMp4, String ffmpegCmdKey);
|
||||
|
||||
WVPResult<String> addStreamProxy(MediaServer mediaServerItem, String app, String stream, String url, boolean enableAudio, boolean enableMp4, String rtpType);
|
||||
WVPResult<String> addStreamProxy(MediaServer mediaServerItem, String app, String stream, String url, boolean enableAudio, boolean enableMp4, String rtpType, Integer timeout);
|
||||
|
||||
Boolean delFFmpegSource(MediaServer mediaServerItem, String streamKey);
|
||||
|
||||
@@ -155,4 +156,6 @@ public interface IMediaServerService {
|
||||
Long updateDownloadProcess(MediaServer mediaServerItem, String app, String stream);
|
||||
|
||||
StreamInfo startProxy(MediaServer mediaServer, StreamProxy streamProxy);
|
||||
|
||||
void stopProxy(MediaServer mediaServer, String streamKey);
|
||||
}
|
||||
|
||||
@@ -704,13 +704,14 @@ public class MediaServerServiceImpl implements IMediaServerService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public WVPResult<String> addStreamProxy(MediaServer mediaServer, String app, String stream, String url, boolean enableAudio, boolean enableMp4, String rtpType) {
|
||||
public WVPResult<String> addStreamProxy(MediaServer mediaServer, String app, String stream, String url,
|
||||
boolean enableAudio, boolean enableMp4, String rtpType, Integer timeout) {
|
||||
IMediaNodeServerService mediaNodeServerService = nodeServerServiceMap.get(mediaServer.getType());
|
||||
if (mediaNodeServerService == null) {
|
||||
logger.info("[addStreamProxy] 失败, mediaServer的类型: {},未找到对应的实现类", mediaServer.getType());
|
||||
return WVPResult.fail(ErrorCode.ERROR400);
|
||||
}
|
||||
return mediaNodeServerService.addStreamProxy(mediaServer, app, stream, url, enableAudio, enableMp4, rtpType);
|
||||
return mediaNodeServerService.addStreamProxy(mediaServer, app, stream, url, enableAudio, enableMp4, rtpType, timeout);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -930,4 +931,14 @@ public class MediaServerServiceImpl implements IMediaServerService {
|
||||
}
|
||||
return mediaNodeServerService.startProxy(mediaServer, streamProxy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopProxy(MediaServer mediaServer, String streamKey) {
|
||||
IMediaNodeServerService mediaNodeServerService = nodeServerServiceMap.get(mediaServer.getType());
|
||||
if (mediaNodeServerService == null) {
|
||||
logger.info("[stopProxy] 失败, mediaServer的类型: {},未找到对应的实现类", mediaServer.getType());
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到mediaServer对应的实现类");
|
||||
}
|
||||
mediaNodeServerService.stopProxy(mediaServer, streamKey);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,8 +14,7 @@ import com.genersoft.iot.vmp.media.zlm.dto.ZLMServerConfig;
|
||||
import com.genersoft.iot.vmp.streamProxy.bean.StreamProxy;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
@@ -25,10 +24,10 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@Service("zlm")
|
||||
public class ZLMMediaNodeServerService implements IMediaNodeServerService {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(ZLMMediaNodeServerService.class);
|
||||
|
||||
@Autowired
|
||||
private ZLMRESTfulUtils zlmresTfulUtils;
|
||||
@@ -134,7 +133,7 @@ public class ZLMMediaNodeServerService implements IMediaNodeServerService {
|
||||
}
|
||||
JSONObject jsonObject = zlmresTfulUtils.stopSendRtp(mediaInfo, param);
|
||||
if (jsonObject == null || jsonObject.getInteger("code") != 0 ) {
|
||||
logger.error("停止发流失败: {}, 参数:{}", jsonObject.getString("msg"), JSON.toJSONString(param));
|
||||
log.error("停止发流失败: {}, 参数:{}", jsonObject.getString("msg"), JSON.toJSONString(param));
|
||||
throw new ControllerException(jsonObject.getInteger("code"), jsonObject.getString("msg"));
|
||||
}
|
||||
return true;
|
||||
@@ -152,7 +151,7 @@ public class ZLMMediaNodeServerService implements IMediaNodeServerService {
|
||||
}
|
||||
JSONObject jsonObject = zlmresTfulUtils.stopSendRtp(mediaInfo, param);
|
||||
if (jsonObject == null || jsonObject.getInteger("code") != 0 ) {
|
||||
logger.error("停止发流失败: {}, 参数:{}", jsonObject.getString("msg"), JSON.toJSONString(param));
|
||||
log.error("停止发流失败: {}, 参数:{}", jsonObject.getString("msg"), JSON.toJSONString(param));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -160,13 +159,13 @@ public class ZLMMediaNodeServerService implements IMediaNodeServerService {
|
||||
|
||||
@Override
|
||||
public boolean deleteRecordDirectory(MediaServer mediaServer, String app, String stream, String date, String fileName) {
|
||||
logger.info("[zlm-deleteRecordDirectory] 删除磁盘文件, server: {} {}:{}->{}/{}", mediaServer.getId(), app, stream, date, fileName);
|
||||
log.info("[zlm-deleteRecordDirectory] 删除磁盘文件, server: {} {}:{}->{}/{}", mediaServer.getId(), app, stream, date, fileName);
|
||||
JSONObject jsonObject = zlmresTfulUtils.deleteRecordDirectory(mediaServer, app,
|
||||
stream, date, fileName);
|
||||
if (jsonObject.getInteger("code") == 0) {
|
||||
return true;
|
||||
}else {
|
||||
logger.info("[zlm-deleteRecordDirectory] 删除磁盘文件错误, server: {} {}:{}->{}/{}, 结果: {}", mediaServer.getId(), app, stream, date, fileName, jsonObject);
|
||||
log.info("[zlm-deleteRecordDirectory] 删除磁盘文件错误, server: {} {}:{}->{}/{}, 结果: {}", mediaServer.getId(), app, stream, date, fileName, jsonObject);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -218,7 +217,7 @@ public class ZLMMediaNodeServerService implements IMediaNodeServerService {
|
||||
@Override
|
||||
public Boolean connectRtpServer(MediaServer mediaServer, String address, int port, String stream) {
|
||||
JSONObject jsonObject = zlmresTfulUtils.connectRtpServer(mediaServer, address, port, stream);
|
||||
logger.info("[TCP主动连接对方] 结果: {}", jsonObject);
|
||||
log.info("[TCP主动连接对方] 结果: {}", jsonObject);
|
||||
return jsonObject.getInteger("code") == 0;
|
||||
}
|
||||
|
||||
@@ -252,7 +251,7 @@ public class ZLMMediaNodeServerService implements IMediaNodeServerService {
|
||||
public String getFfmpegCmd(MediaServer mediaServer, String cmdKey) {
|
||||
JSONObject jsonObject = zlmresTfulUtils.getMediaServerConfig(mediaServer);
|
||||
if (jsonObject.getInteger("code") != 0) {
|
||||
logger.warn("[getFfmpegCmd] 获取流媒体配置失败");
|
||||
log.warn("[getFfmpegCmd] 获取流媒体配置失败");
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "获取流媒体配置失败");
|
||||
}
|
||||
JSONArray dataArray = jsonObject.getJSONArray("data");
|
||||
@@ -267,7 +266,7 @@ public class ZLMMediaNodeServerService implements IMediaNodeServerService {
|
||||
public WVPResult<String> addFFmpegSource(MediaServer mediaServer, String srcUrl, String dstUrl, int timeoutMs, boolean enableAudio, boolean enableMp4, String ffmpegCmdKey) {
|
||||
JSONObject jsonObject = zlmresTfulUtils.addFFmpegSource(mediaServer, srcUrl, dstUrl, timeoutMs, enableAudio, enableMp4, ffmpegCmdKey);
|
||||
if (jsonObject.getInteger("code") != 0) {
|
||||
logger.warn("[getFfmpegCmd] 添加FFMPEG代理失败");
|
||||
log.warn("[getFfmpegCmd] 添加FFMPEG代理失败");
|
||||
return WVPResult.fail(ErrorCode.ERROR100.getCode(), "添加FFMPEG代理失败");
|
||||
}else {
|
||||
JSONObject data = jsonObject.getJSONObject("data");
|
||||
@@ -280,8 +279,9 @@ public class ZLMMediaNodeServerService implements IMediaNodeServerService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public WVPResult<String> addStreamProxy(MediaServer mediaServer, String app, String stream, String url, boolean enableAudio, boolean enableMp4, String rtpType) {
|
||||
JSONObject jsonObject = zlmresTfulUtils.addStreamProxy(mediaServer, app, stream, url, enableAudio, enableMp4, rtpType);
|
||||
public WVPResult<String> addStreamProxy(MediaServer mediaServer, String app, String stream, String url,
|
||||
boolean enableAudio, boolean enableMp4, String rtpType, Integer timeout) {
|
||||
JSONObject jsonObject = zlmresTfulUtils.addStreamProxy(mediaServer, app, stream, url, enableAudio, enableMp4, rtpType, timeout);
|
||||
if (jsonObject.getInteger("code") != 0) {
|
||||
return WVPResult.fail(ErrorCode.ERROR100.getCode(), "添加代理失败");
|
||||
}else {
|
||||
@@ -350,11 +350,11 @@ public class ZLMMediaNodeServerService implements IMediaNodeServerService {
|
||||
|
||||
JSONObject jsonObject = zlmServerFactory.startSendRtpPassive(mediaServer, param, null);
|
||||
if (jsonObject == null || jsonObject.getInteger("code") != 0 ) {
|
||||
logger.error("启动监听TCP被动推流失败: {}, 参数:{}", jsonObject.getString("msg"), JSON.toJSONString(param));
|
||||
log.error("启动监听TCP被动推流失败: {}, 参数:{}", jsonObject.getString("msg"), JSON.toJSONString(param));
|
||||
throw new ControllerException(jsonObject.getInteger("code"), jsonObject.getString("msg"));
|
||||
}
|
||||
logger.info("调用ZLM-TCP被动推流接口, 结果: {}", jsonObject);
|
||||
logger.info("启动监听TCP被动推流成功[ {}/{} ],{}->{}:{}, " , sendRtpItem.getApp(), sendRtpItem.getStream(),
|
||||
log.info("调用ZLM-TCP被动推流接口, 结果: {}", jsonObject);
|
||||
log.info("启动监听TCP被动推流成功[ {}/{} ],{}->{}:{}, " , sendRtpItem.getApp(), sendRtpItem.getStream(),
|
||||
jsonObject.getString("local_port"), param.get("dst_url"), param.get("dst_port"));
|
||||
}
|
||||
|
||||
@@ -386,7 +386,7 @@ public class ZLMMediaNodeServerService implements IMediaNodeServerService {
|
||||
public Long updateDownloadProcess(MediaServer mediaServer, String app, String stream) {
|
||||
MediaInfo mediaInfo = getMediaInfo(mediaServer, app, stream);
|
||||
if (mediaInfo == null) {
|
||||
logger.warn("[获取下载进度] 查询进度失败, 节点Id: {}, {}/{}", mediaServer.getId(), app, stream);
|
||||
log.warn("[获取下载进度] 查询进度失败, 节点Id: {}, {}/{}", mediaServer.getId(), app, stream);
|
||||
return null;
|
||||
}
|
||||
return mediaInfo.getDuration();
|
||||
@@ -427,12 +427,38 @@ public class ZLMMediaNodeServerService implements IMediaNodeServerService {
|
||||
}
|
||||
MediaInfo mediaInfo = getMediaInfo(mediaServer, streamProxy.getApp(), streamProxy.getStream());
|
||||
if (mediaInfo != null) {
|
||||
mediaServerService.closeStreams(mediaServer, param.getApp(), param.getStream());
|
||||
if (mediaInfo.getOriginUrl().equals(streamProxy.getSrcUrl())) {
|
||||
log.info("[启动拉流代理] 已存在, 直接返回, app: {}, stream: {}", mediaInfo.getApp(), streamProxy.getStream());
|
||||
return getStreamInfoByAppAndStream(mediaServer, streamProxy.getApp(), streamProxy.getStream(), null, null, true);
|
||||
}
|
||||
closeStreams(mediaServer, streamProxy.getApp(), streamProxy.getStream());
|
||||
}
|
||||
if (isStreamReady(mediaServer, param.getApp(), param.getStream())) {
|
||||
mediaServerService.closeStreams(mediaServer, param.getApp(), param.getStream());
|
||||
|
||||
JSONObject jsonObject = null;
|
||||
if ("ffmpeg".equalsIgnoreCase(streamProxy.getType())){
|
||||
if (streamProxy.getTimeout() == 0) {
|
||||
streamProxy.setTimeout(15);
|
||||
}
|
||||
jsonObject = zlmresTfulUtils.addFFmpegSource(mediaServer, streamProxy.getSrcUrl().trim(), dstUrl,
|
||||
streamProxy.getTimeout(), streamProxy.isEnableAudio(), streamProxy.isEnableMp4(),
|
||||
streamProxy.getFfmpegCmdKey());
|
||||
}else {
|
||||
jsonObject = zlmresTfulUtils.addStreamProxy(mediaServer, streamProxy.getApp(), streamProxy.getStream(), streamProxy.getSrcUrl().trim(),
|
||||
streamProxy.isEnableAudio(), streamProxy.isEnableMp4(), streamProxy.getRtspType(), streamProxy.getTimeout());
|
||||
}
|
||||
if (jsonObject == null) {
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "请求失败");
|
||||
}else if (jsonObject.getInteger("code") != 0) {
|
||||
throw new ControllerException(jsonObject.getInteger("code"), jsonObject.getString("msg"));
|
||||
}else {
|
||||
JSONObject data = jsonObject.getJSONObject("data");
|
||||
if (data == null) {
|
||||
throw new ControllerException(jsonObject.getInteger("code"), "代理结果异常: " + jsonObject);
|
||||
}else {
|
||||
streamProxy.setStreamKey(jsonObject.getString("key"));
|
||||
return getStreamInfoByAppAndStream(mediaServer, streamProxy.getApp(), streamProxy.getStream(), null, null, true);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String getSchemaFromFFmpegCmd(String ffmpegCmd) {
|
||||
@@ -453,4 +479,14 @@ public class ZLMMediaNodeServerService implements IMediaNodeServerService {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopProxy(MediaServer mediaServer, String streamKey) {
|
||||
JSONObject jsonObject = zlmresTfulUtils.delStreamProxy(mediaServer, streamKey);
|
||||
if (jsonObject == null) {
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "请求失败");
|
||||
}else if (jsonObject.getInteger("code") != 0) {
|
||||
throw new ControllerException(jsonObject.getInteger("code"), jsonObject.getString("msg"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -335,7 +335,7 @@ public class ZLMRESTfulUtils {
|
||||
return sendPost(mediaServerItem, "restartServer",null, null);
|
||||
}
|
||||
|
||||
public JSONObject addStreamProxy(MediaServer mediaServerItem, String app, String stream, String url, boolean enable_audio, boolean enable_mp4, String rtp_type) {
|
||||
public JSONObject addStreamProxy(MediaServer mediaServerItem, String app, String stream, String url, boolean enable_audio, boolean enable_mp4, String rtp_type, Integer timeOut) {
|
||||
Map<String, Object> param = new HashMap<>();
|
||||
param.put("vhost", "__defaultVhost__");
|
||||
param.put("app", app);
|
||||
@@ -344,6 +344,9 @@ public class ZLMRESTfulUtils {
|
||||
param.put("enable_mp4", enable_mp4?1:0);
|
||||
param.put("enable_audio", enable_audio?1:0);
|
||||
param.put("rtp_type", rtp_type);
|
||||
param.put("timeout_sec", timeOut);
|
||||
// 拉流重试次数,默认为3
|
||||
param.put("retry_count", 3);
|
||||
return sendPost(mediaServerItem, "addStreamProxy",param, null, 20);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user