|
@@ -1,22 +1,33 @@
|
|
|
package org.jetlinks.community.media.zlm;
|
|
package org.jetlinks.community.media.zlm;
|
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.json.JSONObject;
|
|
import cn.hutool.json.JSONObject;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.hswebframework.web.authorization.annotation.Authorize;
|
|
import org.hswebframework.web.authorization.annotation.Authorize;
|
|
|
|
|
+import org.jetlinks.community.media.contanst.VideoManagerConstants;
|
|
|
|
|
+import org.jetlinks.community.media.entity.GbStream;
|
|
|
import org.jetlinks.community.media.bean.StreamInfo;
|
|
import org.jetlinks.community.media.bean.StreamInfo;
|
|
|
|
|
+import org.jetlinks.community.media.entity.MediaDeviceChannel;
|
|
|
|
|
+import org.jetlinks.community.media.service.LocalGbStreamService;
|
|
|
|
|
+import org.jetlinks.community.media.service.LocalMediaDeviceChannelService;
|
|
|
import org.jetlinks.community.media.service.LocalMediaServerItemService;
|
|
import org.jetlinks.community.media.service.LocalMediaServerItemService;
|
|
|
import org.jetlinks.community.media.storage.impl.RedisCacheStorageImpl;
|
|
import org.jetlinks.community.media.storage.impl.RedisCacheStorageImpl;
|
|
|
import org.jetlinks.community.media.zlm.dto.MediaItem;
|
|
import org.jetlinks.community.media.zlm.dto.MediaItem;
|
|
|
-import org.jetlinks.community.media.zlm.entity.MediaServerItem;
|
|
|
|
|
|
|
+import org.jetlinks.community.media.zlm.dto.StreamPushItem;
|
|
|
import org.jetlinks.community.media.zlm.dto.OriginType;
|
|
import org.jetlinks.community.media.zlm.dto.OriginType;
|
|
|
|
|
+import org.jetlinks.community.utils.ZlmSubscribeTopic;
|
|
|
|
|
+import org.jetlinks.core.cluster.ClusterEventBus;
|
|
|
import org.jetlinks.core.event.EventBus;
|
|
import org.jetlinks.core.event.EventBus;
|
|
|
import org.springframework.http.HttpStatus;
|
|
import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.server.ServerWebExchange;
|
|
import org.springframework.web.server.ServerWebExchange;
|
|
|
import reactor.core.publisher.Mono;
|
|
import reactor.core.publisher.Mono;
|
|
|
|
|
+
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -34,6 +45,11 @@ public class ZLMHttpHookListener {
|
|
|
private final RedisCacheStorageImpl redisCatchStorage;
|
|
private final RedisCacheStorageImpl redisCatchStorage;
|
|
|
private final ZLMHttpHookSubscribe subscribe;
|
|
private final ZLMHttpHookSubscribe subscribe;
|
|
|
private final EventBus eventBus;
|
|
private final EventBus eventBus;
|
|
|
|
|
+ private final LocalMediaDeviceChannelService channelService;
|
|
|
|
|
+ private final ZLMMediaListManager zlmMediaListManager;
|
|
|
|
|
+ private final LocalGbStreamService gbStreamService;
|
|
|
|
|
+ private final ClusterEventBus clusterEventBus;
|
|
|
|
|
+ private final String serverId="";
|
|
|
/**
|
|
/**
|
|
|
* 服务器定时上报时间,上报间隔可配置,默认10s上报一次
|
|
* 服务器定时上报时间,上报间隔可配置,默认10s上报一次
|
|
|
*
|
|
*
|
|
@@ -45,16 +61,10 @@ public class ZLMHttpHookListener {
|
|
|
if (log.isDebugEnabled()) {
|
|
if (log.isDebugEnabled()) {
|
|
|
log.debug("[ ZLM HOOK ]on_server_keepalive API调用,参数:" + json.toString());
|
|
log.debug("[ ZLM HOOK ]on_server_keepalive API调用,参数:" + json.toString());
|
|
|
}
|
|
}
|
|
|
-// List<ZLMHttpHookSubscribe.Event> subscribes = this.subscribe.getSubscribes(ZLMHttpHookSubscribe.HookType.on_server_keepalive);
|
|
|
|
|
-// if (subscribes != null && subscribes.size() > 0) {
|
|
|
|
|
-// for (ZLMHttpHookSubscribe.Event subscribe : subscribes) {
|
|
|
|
|
-// subscribe.response(null, json);
|
|
|
|
|
-// }
|
|
|
|
|
-// }
|
|
|
|
|
|
|
|
|
|
- JSONObject ret = new JSONObject();
|
|
|
|
|
- ret.put("code", 0);
|
|
|
|
|
- ret.put("msg", "success");
|
|
|
|
|
|
|
+ JSONObject ret = new JSONObject()
|
|
|
|
|
+ .append("code", 0)
|
|
|
|
|
+ .append("msg", "success");
|
|
|
return eventBus.
|
|
return eventBus.
|
|
|
publish(ZLMHttpHookSubscribe.HookType.on_server_keepalive.name(),json)
|
|
publish(ZLMHttpHookSubscribe.HookType.on_server_keepalive.name(),json)
|
|
|
.thenReturn(ResponseEntity.ok(ret.toString()));
|
|
.thenReturn(ResponseEntity.ok(ret.toString()));
|
|
@@ -112,7 +122,7 @@ public class ZLMHttpHookListener {
|
|
|
// String mediaServerId = json.getString("mediaServerId");
|
|
// String mediaServerId = json.getString("mediaServerId");
|
|
|
// ZLMHttpHookSubscribe.Event subscribe = this.subscribe.getSubscribe(ZLMHttpHookSubscribe.HookType.on_play, json);
|
|
// ZLMHttpHookSubscribe.Event subscribe = this.subscribe.getSubscribe(ZLMHttpHookSubscribe.HookType.on_play, json);
|
|
|
// if (subscribe != null ) {
|
|
// if (subscribe != null ) {
|
|
|
-// MediaServerItem mediaInfo = mediaServerService.getOne(mediaServerId);
|
|
|
|
|
|
|
+// MediaServerItem mediaInfo = mediaServerService.getOneByServerId(mediaServerId);
|
|
|
// if (mediaInfo != null) {
|
|
// if (mediaInfo != null) {
|
|
|
// subscribe.response(mediaInfo, json);
|
|
// subscribe.response(mediaInfo, json);
|
|
|
// }
|
|
// }
|
|
@@ -123,25 +133,25 @@ public class ZLMHttpHookListener {
|
|
|
// ret.put("msg", "success");
|
|
// ret.put("msg", "success");
|
|
|
// return new ResponseEntity<String>(ret.toString(), HttpStatus.OK);
|
|
// return new ResponseEntity<String>(ret.toString(), HttpStatus.OK);
|
|
|
// }
|
|
// }
|
|
|
-//
|
|
|
|
|
-// /**
|
|
|
|
|
-// * rtsp/rtmp/rtp推流鉴权事件。
|
|
|
|
|
-// *
|
|
|
|
|
-// */
|
|
|
|
|
-// @ResponseBody
|
|
|
|
|
-// @PostMapping(value = "/on_publish", produces = "application/json;charset=UTF-8")
|
|
|
|
|
-// public ResponseEntity<String> onPublish(@RequestBody JSONObject json) {
|
|
|
|
|
-//
|
|
|
|
|
-// logger.debug("[ ZLM HOOK ]on_publish API调用,参数:" + json.toString());
|
|
|
|
|
-// JSONObject ret = new JSONObject();
|
|
|
|
|
-// ret.put("code", 0);
|
|
|
|
|
-// ret.put("msg", "success");
|
|
|
|
|
-// ret.put("enableHls", true);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * rtsp/rtmp/rtp推流鉴权事件。
|
|
|
|
|
+ *
|
|
|
|
|
+ */
|
|
|
|
|
+ @ResponseBody
|
|
|
|
|
+ @PostMapping(value = "/on_publish", produces = "application/json;charset=UTF-8")
|
|
|
|
|
+ public ResponseEntity<String> onPublish(@RequestBody JSONObject json) {
|
|
|
|
|
+
|
|
|
|
|
+ log.debug("[ ZLM HOOK ]on_publish API调用,参数:" + json.toString());
|
|
|
|
|
+ JSONObject ret = new JSONObject();
|
|
|
|
|
+ ret.put("code", 0);
|
|
|
|
|
+ ret.put("msg", "success");
|
|
|
|
|
+ ret.put("enableHls", true);
|
|
|
// ret.put("enableMP4", userSetup.isRecordPushLive());
|
|
// ret.put("enableMP4", userSetup.isRecordPushLive());
|
|
|
// String mediaServerId = json.getString("mediaServerId");
|
|
// String mediaServerId = json.getString("mediaServerId");
|
|
|
// ZLMHttpHookSubscribe.Event subscribe = this.subscribe.getSubscribe(ZLMHttpHookSubscribe.HookType.on_publish, json);
|
|
// ZLMHttpHookSubscribe.Event subscribe = this.subscribe.getSubscribe(ZLMHttpHookSubscribe.HookType.on_publish, json);
|
|
|
// if (subscribe != null) {
|
|
// if (subscribe != null) {
|
|
|
-// MediaServerItem mediaInfo = mediaServerService.getOne(mediaServerId);
|
|
|
|
|
|
|
+// MediaServerItem mediaInfo = mediaServerService.getOneByServerId(mediaServerId);
|
|
|
// if (mediaInfo != null) {
|
|
// if (mediaInfo != null) {
|
|
|
// subscribe.response(mediaInfo, json);
|
|
// subscribe.response(mediaInfo, json);
|
|
|
// }else {
|
|
// }else {
|
|
@@ -159,9 +169,9 @@ public class ZLMHttpHookListener {
|
|
|
// }else {
|
|
// }else {
|
|
|
// ret.put("enableMP4", userSetup.isRecordPushLive());
|
|
// ret.put("enableMP4", userSetup.isRecordPushLive());
|
|
|
// }
|
|
// }
|
|
|
-//
|
|
|
|
|
-// return new ResponseEntity<String>(ret.toString(), HttpStatus.OK);
|
|
|
|
|
-// }
|
|
|
|
|
|
|
+
|
|
|
|
|
+ return new ResponseEntity<String>(ret.toString(), HttpStatus.OK);
|
|
|
|
|
+ }
|
|
|
//
|
|
//
|
|
|
// /**
|
|
// /**
|
|
|
// * 录制mp4完成后通知事件;此事件对回复不敏感。
|
|
// * 录制mp4完成后通知事件;此事件对回复不敏感。
|
|
@@ -236,7 +246,7 @@ public class ZLMHttpHookListener {
|
|
|
// String mediaServerId = json.getString("mediaServerId");
|
|
// String mediaServerId = json.getString("mediaServerId");
|
|
|
// ZLMHttpHookSubscribe.Event subscribe = this.subscribe.getSubscribe(ZLMHttpHookSubscribe.HookType.on_shell_login, json);
|
|
// ZLMHttpHookSubscribe.Event subscribe = this.subscribe.getSubscribe(ZLMHttpHookSubscribe.HookType.on_shell_login, json);
|
|
|
// if (subscribe != null ) {
|
|
// if (subscribe != null ) {
|
|
|
-// MediaServerItem mediaInfo = mediaServerService.getOne(mediaServerId);
|
|
|
|
|
|
|
+// MediaServerItem mediaInfo = mediaServerService.getOneByServerId(mediaServerId);
|
|
|
// if (mediaInfo != null) {
|
|
// if (mediaInfo != null) {
|
|
|
// subscribe.response(mediaInfo, json);
|
|
// subscribe.response(mediaInfo, json);
|
|
|
// }
|
|
// }
|
|
@@ -248,91 +258,136 @@ public class ZLMHttpHookListener {
|
|
|
// ret.put("msg", "success");
|
|
// ret.put("msg", "success");
|
|
|
// return new ResponseEntity<String>(ret.toString(), HttpStatus.OK);
|
|
// return new ResponseEntity<String>(ret.toString(), HttpStatus.OK);
|
|
|
// }
|
|
// }
|
|
|
-//
|
|
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* rtsp/rtmp流注册或注销时触发此事件;此事件对回复不敏感。
|
|
* rtsp/rtmp流注册或注销时触发此事件;此事件对回复不敏感。
|
|
|
*
|
|
*
|
|
|
*/
|
|
*/
|
|
|
-// @ResponseBody
|
|
|
|
|
- @PostMapping(value = "/on_stream_changed", produces = "application/json;charset=UTF-8")
|
|
|
|
|
|
|
+ @PostMapping(value = "/on_stream_changed")
|
|
|
public Mono<ResponseEntity<String>> onStreamChanged(@RequestBody MediaItem item){
|
|
public Mono<ResponseEntity<String>> onStreamChanged(@RequestBody MediaItem item){
|
|
|
if (log.isDebugEnabled()) {
|
|
if (log.isDebugEnabled()) {
|
|
|
log.debug("[ ZLM HOOK ]on_stream_changed API调用,参数:" + JSONUtil.toJsonStr(item));
|
|
log.debug("[ ZLM HOOK ]on_stream_changed API调用,参数:" + JSONUtil.toJsonStr(item));
|
|
|
}
|
|
}
|
|
|
String mediaServerId = item.getMediaServerId();
|
|
String mediaServerId = item.getMediaServerId();
|
|
|
- JSONObject json = JSONUtil.parseObj(item);
|
|
|
|
|
- Mono<ResponseEntity<String>> result=null;
|
|
|
|
|
- //todo 这里订阅/发布采用eventBus 模式进行
|
|
|
|
|
-// ZLMHttpHookSubscribe.Event subscribe = this.subscribe.getSubscribe(ZLMHttpHookSubscribe.HookType.on_stream_changed, json);
|
|
|
|
|
-// if (subscribe != null ) {
|
|
|
|
|
-// MediaServerItem mediaInfo = mediaServerService.getOne(mediaServerId);
|
|
|
|
|
-// if (mediaInfo != null) {
|
|
|
|
|
-// subscribe.response(mediaInfo, json);
|
|
|
|
|
-// }
|
|
|
|
|
-// }
|
|
|
|
|
- // 流消失移除redis play
|
|
|
|
|
//获取流应用名
|
|
//获取流应用名
|
|
|
String app = item.getApp();
|
|
String app = item.getApp();
|
|
|
//获取流ID
|
|
//获取流ID
|
|
|
String streamId = item.getStream();
|
|
String streamId = item.getStream();
|
|
|
//rtsp或rtmp
|
|
//rtsp或rtmp
|
|
|
String schema = item.getSchema();
|
|
String schema = item.getSchema();
|
|
|
- //音频轨道
|
|
|
|
|
- List<MediaItem.MediaTrack> tracks = item.getTracks();
|
|
|
|
|
|
|
+ JSONObject json = JSONUtil.parseObj(item);
|
|
|
|
|
+ //todo 这里订阅/发布采用eventBus 模式进行
|
|
|
|
|
+ //on_stream_changed+{mediaServerId}+{streamId}+app
|
|
|
|
|
+ Mono<Long> result = Mono.fromRunnable(()->clusterEventBus.publish(ZlmSubscribeTopic.getOnStreamChanged(app, streamId, mediaServerId), json)).thenReturn(1L);
|
|
|
|
|
+ // 流消失移除redis play
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
boolean regist = item.isRegist();
|
|
boolean regist = item.isRegist();
|
|
|
if ("rtmp".equals(schema)){
|
|
if ("rtmp".equals(schema)){
|
|
|
log.info("on_stream_changed:注册(true)/注销(false)->{}, app->{}, stream->{}", regist, app, streamId);
|
|
log.info("on_stream_changed:注册(true)/注销(false)->{}, app->{}, stream->{}", regist, app, streamId);
|
|
|
if (regist) {
|
|
if (regist) {
|
|
|
- result=mediaServerItemService.addCount(mediaServerId).then(Mono.empty());
|
|
|
|
|
|
|
+ result=result.flatMap(__->mediaServerItemService.addCount(mediaServerId).thenReturn(1L));
|
|
|
}else {
|
|
}else {
|
|
|
- result=mediaServerItemService.removeCount(mediaServerId).then(Mono.empty());
|
|
|
|
|
|
|
+ result=result.flatMap(__->mediaServerItemService.removeCount(mediaServerId).thenReturn(1L));
|
|
|
|
|
+ }
|
|
|
|
|
+ if (item.getOriginType() == OriginType.PULL.ordinal()
|
|
|
|
|
+ || item.getOriginType() == OriginType.FFMPEG_PULL.ordinal()) {
|
|
|
|
|
+ // 设置拉流代理上线/离线 todo
|
|
|
|
|
+// streamProxyService.updateStatus(regist, app, streamId);
|
|
|
}
|
|
}
|
|
|
|
|
+ //播放结束
|
|
|
if ("rtp".equals(app) && !regist ) {
|
|
if ("rtp".equals(app) && !regist ) {
|
|
|
StreamInfo streamInfo = redisCatchStorage.queryPlayByStreamId(streamId);
|
|
StreamInfo streamInfo = redisCatchStorage.queryPlayByStreamId(streamId);
|
|
|
if (streamInfo!=null){
|
|
if (streamInfo!=null){
|
|
|
redisCatchStorage.stopPlay(streamInfo);
|
|
redisCatchStorage.stopPlay(streamInfo);
|
|
|
-// storager.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId());
|
|
|
|
|
|
|
+ String deviceId = streamInfo.getDeviceID();
|
|
|
|
|
+ String channelId = streamInfo.getChannelId();
|
|
|
|
|
+ //终止播放
|
|
|
|
|
+ result=result.flatMap(__->channelService.createUpdate()
|
|
|
|
|
+ .set(MediaDeviceChannel::getStreamId,null)
|
|
|
|
|
+ .where(MediaDeviceChannel::getDeviceId,deviceId)
|
|
|
|
|
+ .where(MediaDeviceChannel::getChannelId,channelId)
|
|
|
|
|
+ .execute()
|
|
|
|
|
+ .thenReturn(1L));
|
|
|
}else{
|
|
}else{
|
|
|
streamInfo = redisCatchStorage.queryPlaybackByStreamId(streamId);
|
|
streamInfo = redisCatchStorage.queryPlaybackByStreamId(streamId);
|
|
|
-// redisCatchStorage.stopPlayback(streamInfo);
|
|
|
|
|
|
|
+ final StreamInfo paramInfo = BeanUtil.toBean(streamInfo, StreamInfo.class);
|
|
|
|
|
+ result=result.flatMap(__->channelService.stopPlayback(paramInfo).thenReturn(1L));
|
|
|
}
|
|
}
|
|
|
}else {
|
|
}else {
|
|
|
if (!"rtp".equals(app)){
|
|
if (!"rtp".equals(app)){
|
|
|
- String type = OriginType.values()[item.getOriginType()].getType();
|
|
|
|
|
-// MediaServerItem mediaServerItem = mediaServerService.getOne(mediaServerId);
|
|
|
|
|
- MediaServerItem mediaServerItem =null;
|
|
|
|
|
- if (mediaServerItem != null){
|
|
|
|
|
- if (regist) {
|
|
|
|
|
- redisCatchStorage.addStream(mediaServerItem, type, app, streamId, item);
|
|
|
|
|
- if (item.getOriginType() == OriginType.RTSP_PUSH.ordinal()
|
|
|
|
|
- || item.getOriginType() == OriginType.RTMP_PUSH.ordinal()
|
|
|
|
|
- || item.getOriginType() == OriginType.RTC_PUSH.ordinal() ) {
|
|
|
|
|
-// zlmMediaListManager.addPush(item);
|
|
|
|
|
- }
|
|
|
|
|
- }else {
|
|
|
|
|
- // 兼容流注销时类型从redis记录获取
|
|
|
|
|
- MediaItem mediaItem = redisCatchStorage.getStreamInfo(app, streamId, mediaServerId);
|
|
|
|
|
- type = OriginType.values()[mediaItem.getOriginType()].getType();
|
|
|
|
|
-// zlmMediaListManager.removeMedia(app, streamId);
|
|
|
|
|
- redisCatchStorage.removeStream(mediaServerItem.getId(), type, app, streamId);
|
|
|
|
|
- }
|
|
|
|
|
- // 发送流变化redis消息
|
|
|
|
|
- JSONObject jsonObject = new JSONObject()
|
|
|
|
|
- .append("serverId", mediaServerId)
|
|
|
|
|
- .append("app", app)
|
|
|
|
|
- .append("stream", streamId)
|
|
|
|
|
- .append("register", regist)
|
|
|
|
|
- .append("mediaServerId", mediaServerId);
|
|
|
|
|
- redisCatchStorage.sendStreamChangeMsg(type, jsonObject);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ result=result.flatMap(ingore->
|
|
|
|
|
+ mediaServerItemService.findById(mediaServerId)
|
|
|
|
|
+ .doOnNext(mediaServerItem -> {
|
|
|
|
|
+ String type = OriginType.values()[item.getOriginType()].getType();
|
|
|
|
|
+ if (regist) {
|
|
|
|
|
+ redisCatchStorage.addStream(mediaServerItem, type, app, streamId, item);
|
|
|
|
|
+ }else {
|
|
|
|
|
+ redisCatchStorage.removeStream(mediaServerItem.getId(), type, app, streamId);
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ .flatMap(mediaServerItem -> {
|
|
|
|
|
+ //注册
|
|
|
|
|
+ String type = OriginType.values()[item.getOriginType()].getType();
|
|
|
|
|
+ Mono<Void> mono=null;
|
|
|
|
|
+
|
|
|
|
|
+ if (regist) {
|
|
|
|
|
+ StreamPushItem streamPushItem = null;
|
|
|
|
|
+ if (item.getOriginType() == OriginType.RTSP_PUSH.ordinal()
|
|
|
|
|
+ || item.getOriginType() == OriginType.RTMP_PUSH.ordinal()
|
|
|
|
|
+ || item.getOriginType() == OriginType.RTC_PUSH.ordinal() ) {
|
|
|
|
|
+ mono= zlmMediaListManager
|
|
|
|
|
+ .addPush(item)
|
|
|
|
|
+ .flatMap(streamPush->{
|
|
|
|
|
+ if(StrUtil.isEmpty(streamPush.getGbId())){
|
|
|
|
|
+ return gbStreamService.getByAppAndStreamId(app,streamId);
|
|
|
|
|
+ }
|
|
|
|
|
+ return Mono.just(streamPush);
|
|
|
|
|
+ })
|
|
|
|
|
+ .switchIfEmpty(gbStreamService.getByAppAndStreamId(app,streamId))
|
|
|
|
|
+ .then();
|
|
|
|
|
+ //todo 新的流信息发布
|
|
|
|
|
+// .doOnNext(streamPush-> eventPublisher.catalogEventPublishForStream(null, gbStreams, CatalogEvent.ON))
|
|
|
|
|
+// ;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }else {
|
|
|
|
|
+ // 兼容流注销时类型从redis记录获取
|
|
|
|
|
+ MediaItem mediaItem = redisCatchStorage.getStreamInfo(app, streamId, mediaServerId);
|
|
|
|
|
+ if (mediaItem != null) {
|
|
|
|
|
+ type = OriginType.values()[mediaItem.getOriginType()].getType();
|
|
|
|
|
+ redisCatchStorage.removeStream(mediaServerItem.getId(), type, app, streamId);
|
|
|
|
|
+ }
|
|
|
|
|
+ mono= gbStreamService.getByAppAndStreamId(app,streamId).then();
|
|
|
|
|
+ //todo
|
|
|
|
|
+
|
|
|
|
|
+// .doOnNext(gbStream -> eventPublisher.catalogEventPublishForStream(null, gbStream, CatalogEvent.OFF))
|
|
|
|
|
+// zlmMediaListManager.removeMedia(app, streamId);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (type != null) {
|
|
|
|
|
+ // 发送流变化redis消息
|
|
|
|
|
+ JSONObject jsonObject = new JSONObject()
|
|
|
|
|
+ .append("serverId", serverId)
|
|
|
|
|
+ .append("app", app)
|
|
|
|
|
+ .append("stream", streamId)
|
|
|
|
|
+ .append("register", regist)
|
|
|
|
|
+ .append("mediaServerId", mediaServerId);
|
|
|
|
|
+ if(mono!=null){
|
|
|
|
|
+ String originType=type;
|
|
|
|
|
+ mono=mono.doOnNext(___->clusterEventBus.publish(VideoManagerConstants.WVP_SERVER_STREAM_PREFIX+"_"+originType,jsonObject));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return mono;
|
|
|
|
|
+ })
|
|
|
|
|
+ .thenReturn(1L));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
JSONObject ret = new JSONObject()
|
|
JSONObject ret = new JSONObject()
|
|
|
.append("code", 0)
|
|
.append("code", 0)
|
|
|
.append("msg", "success");
|
|
.append("msg", "success");
|
|
|
- return result==null?Mono.just(ResponseEntity.ok(ret.toString())):result.thenReturn(ResponseEntity.ok(ret.toString()));
|
|
|
|
|
-// return Mono.just(ResponseEntity.ok(ret.toString()));
|
|
|
|
|
|
|
+ return result
|
|
|
|
|
+ .thenReturn(ResponseEntity.ok(ret.toString()));
|
|
|
}
|
|
}
|
|
|
//
|
|
//
|
|
|
// /**
|
|
// /**
|
|
@@ -376,7 +431,7 @@ public class ZLMHttpHookListener {
|
|
|
// }
|
|
// }
|
|
|
// }
|
|
// }
|
|
|
// }
|
|
// }
|
|
|
-// MediaServerItem mediaServerItem = mediaServerService.getOne(mediaServerId);
|
|
|
|
|
|
|
+// MediaServerItem mediaServerItem = mediaServerService.getOneByServerId(mediaServerId);
|
|
|
// if (mediaServerItem != null && "-1".equals(mediaServerItem.getStreamNoneReaderDelayMS())) {
|
|
// if (mediaServerItem != null && "-1".equals(mediaServerItem.getStreamNoneReaderDelayMS())) {
|
|
|
// ret.put("close", false);
|
|
// ret.put("close", false);
|
|
|
// }
|
|
// }
|
|
@@ -406,7 +461,7 @@ public class ZLMHttpHookListener {
|
|
|
// logger.debug("[ ZLM HOOK ]on_stream_not_found API调用,参数:" + json.toString());
|
|
// logger.debug("[ ZLM HOOK ]on_stream_not_found API调用,参数:" + json.toString());
|
|
|
// }
|
|
// }
|
|
|
// String mediaServerId = json.getString("mediaServerId");
|
|
// String mediaServerId = json.getString("mediaServerId");
|
|
|
-// MediaServerItem mediaInfo = mediaServerService.getOne(mediaServerId);
|
|
|
|
|
|
|
+// MediaServerItem mediaInfo = mediaServerService.getOneByServerId(mediaServerId);
|
|
|
// if (userSetup.isAutoApplyPlay() && mediaInfo != null) {
|
|
// if (userSetup.isAutoApplyPlay() && mediaInfo != null) {
|
|
|
// String app = json.getString("app");
|
|
// String app = json.getString("app");
|
|
|
// String streamId = json.getString("stream");
|
|
// String streamId = json.getString("stream");
|