| | |
| | | import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
|
| | | import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
|
| | | import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
|
| | | import com.genersoft.iot.vmp.media.bean.MediaInfo;
|
| | | import com.genersoft.iot.vmp.media.service.IMediaServerService;
|
| | | import com.genersoft.iot.vmp.media.zlm.dto.*;
|
| | | import com.genersoft.iot.vmp.media.zlm.dto.hook.*;
|
| | |
| | |
|
| | | @PostMapping(value = "/on_server_keepalive", produces = "application/json;charset=UTF-8")
|
| | | public HookResult onServerKeepalive(@RequestBody OnServerKeepaliveHookParam param) {
|
| | | taskExecutor.execute(() -> {
|
| | | List<ZlmHttpHookSubscribe.Event> subscribes = this.subscribe.getSubscribes(HookType.on_server_keepalive);
|
| | | if (subscribes != null && subscribes.size() > 0) {
|
| | | for (ZlmHttpHookSubscribe.Event subscribe : subscribes) {
|
| | | subscribe.response(null, param);
|
| | | }
|
| | | }
|
| | | });
|
| | | try {
|
| | | HookZlmServerKeepaliveEvent event = new HookZlmServerKeepaliveEvent(this);
|
| | | MediaServerItem mediaServerItem = mediaServerService.getOne(param.getMediaServerId());
|
| | | MediaServer mediaServerItem = mediaServerService.getOne(param.getMediaServerId());
|
| | | if (mediaServerItem != null) {
|
| | | event.setMediaServerItem(mediaServerItem);
|
| | | applicationEventPublisher.publishEvent(event);
|
| | |
| | | @PostMapping(value = "/on_play", produces = "application/json;charset=UTF-8")
|
| | | public HookResult onPlay(@RequestBody OnPlayHookParam param) {
|
| | | if (logger.isDebugEnabled()) {
|
| | | logger.debug("[ZLM HOOK] 播放鉴权:{}->{}" + param.getMediaServerId(), param);
|
| | | logger.debug("[ZLM HOOK] 播放鉴权:{}->{}", param.getMediaServerId(), param);
|
| | | }
|
| | | String mediaServerId = param.getMediaServerId();
|
| | |
|
| | |
| | | JSONObject json = (JSONObject) JSON.toJSON(param);
|
| | | ZlmHttpHookSubscribe.Event subscribe = this.subscribe.sendNotify(HookType.on_play, json);
|
| | | if (subscribe != null) {
|
| | | MediaServerItem mediaInfo = mediaServerService.getOne(mediaServerId);
|
| | | MediaServer mediaInfo = mediaServerService.getOne(mediaServerId);
|
| | | if (mediaInfo != null) {
|
| | | subscribe.response(mediaInfo, param);
|
| | | }
|
| | | }
|
| | | });
|
| | | // TODO 此处逻辑适合迁移到MediaService中
|
| | | if (!"rtp".equals(param.getApp())) {
|
| | | Map<String, String> paramMap = urlParamToMap(param.getParams());
|
| | | StreamAuthorityInfo streamAuthorityInfo = redisCatchStorage.getStreamAuthorityInfo(param.getApp(), param.getStream());
|
| | |
| | | // TODO 加快处理速度
|
| | |
|
| | | String mediaServerId = json.getString("mediaServerId");
|
| | | MediaServerItem mediaInfo = mediaServerService.getOne(mediaServerId);
|
| | | if (mediaInfo == null) {
|
| | | MediaServer mediaServer = mediaServerService.getOne(mediaServerId);
|
| | | if (mediaServer == null) {
|
| | | return new HookResultForOnPublish(200, "success");
|
| | | }
|
| | | // 推流鉴权的处理
|
| | |
| | | taskExecutor.execute(() -> {
|
| | | ZlmHttpHookSubscribe.Event subscribe = this.subscribe.sendNotify(HookType.on_publish, json);
|
| | | if (subscribe != null) {
|
| | | if (mediaInfo != null) {
|
| | | subscribe.response(mediaInfo, param);
|
| | | } else {
|
| | | new HookResultForOnPublish(1, "zlm not register");
|
| | | }
|
| | | subscribe.response(mediaServer, param);
|
| | | }
|
| | | });
|
| | |
|
| | |
| | | InviteInfo inviteInfo = inviteStreamService.getInviteInfoByStream(null, param.getStream());
|
| | |
|
| | | // 单端口模式下修改流 ID
|
| | | if (!mediaInfo.isRtpEnable() && inviteInfo == null) {
|
| | | if (!mediaServer.isRtpEnable() && inviteInfo == null) {
|
| | | String ssrc = String.format("%010d", Long.parseLong(param.getStream(), 16));
|
| | | inviteInfo = inviteStreamService.getInviteInfoBySSRC(ssrc);
|
| | | if (inviteInfo != null) {
|
| | |
| | | JSONObject json = (JSONObject) JSON.toJSON(param);
|
| | | taskExecutor.execute(() -> {
|
| | | ZlmHttpHookSubscribe.Event subscribe = this.subscribe.sendNotify(HookType.on_stream_changed, json);
|
| | | MediaServerItem mediaInfo = mediaServerService.getOne(param.getMediaServerId());
|
| | | MediaServer mediaInfo = mediaServerService.getOne(param.getMediaServerId());
|
| | | if (mediaInfo == null) {
|
| | | logger.info("[ZLM HOOK] 流变化未找到ZLM, {}", param.getMediaServerId());
|
| | | return;
|
| | |
| | | subscribe.response(mediaInfo, param);
|
| | | }
|
| | |
|
| | | List<OnStreamChangedHookParam.MediaTrack> tracks = param.getTracks();
|
| | | // TODO 重构此处逻辑
|
| | | if (param.isRegist()) {
|
| | | // 处理流注册的鉴权信息, 流注销这里不再删除鉴权信息,下次来了新的鉴权信息会对就的进行覆盖
|
| | |
| | | callId = streamAuthorityInfo.getCallId();
|
| | | }
|
| | | StreamInfo streamInfoByAppAndStream = mediaService.getStreamInfoByAppAndStream(mediaInfo,
|
| | | param.getApp(), param.getStream(), tracks, callId);
|
| | | param.getApp(), param.getStream(), MediaInfo.getInstance(param), callId);
|
| | | param.setStreamInfo(new StreamContent(streamInfoByAppAndStream));
|
| | | redisCatchStorage.addStream(mediaInfo, type, param.getApp(), param.getStream(), param);
|
| | | if (param.getOriginType() == OriginType.RTSP_PUSH.ordinal()
|
| | |
| | | }
|
| | | // 收到无人观看说明流也没有在往上级推送
|
| | | if (redisCatchStorage.isChannelSendingRTP(inviteInfo.getChannelId())) {
|
| | | List<SendRtpItem> sendRtpItems = redisCatchStorage.querySendRTPServerByChnnelId(
|
| | | List<SendRtpItem> sendRtpItems = redisCatchStorage.querySendRTPServerByChannelId(
|
| | | inviteInfo.getChannelId());
|
| | | if (sendRtpItems.size() > 0) {
|
| | | if (!sendRtpItems.isEmpty()) {
|
| | | for (SendRtpItem sendRtpItem : sendRtpItems) {
|
| | | ParentPlatform parentPlatform = storager.queryParentPlatByServerGBId(sendRtpItem.getPlatformId());
|
| | | try {
|
| | |
| | |
|
| | | DeferredResult<HookResult> defaultResult = new DeferredResult<>();
|
| | |
|
| | | MediaServerItem mediaInfo = mediaServerService.getOne(param.getMediaServerId());
|
| | | MediaServer mediaInfo = mediaServerService.getOne(param.getMediaServerId());
|
| | | if (!userSetting.isAutoApplyPlay() || mediaInfo == null) {
|
| | | defaultResult.setResult(new HookResult(ErrorCode.ERROR404.getCode(), ErrorCode.ERROR404.getMsg()));
|
| | | return defaultResult;
|
| | |
| | | logger.info("[ZLM HOOK] zlm 启动 " + zlmServerConfig.getGeneralMediaServerId());
|
| | | taskExecutor.execute(() -> {
|
| | | List<ZlmHttpHookSubscribe.Event> subscribes = this.subscribe.getSubscribes(HookType.on_server_started);
|
| | | if (subscribes != null && subscribes.size() > 0) {
|
| | | if (subscribes != null && !subscribes.isEmpty()) {
|
| | | for (ZlmHttpHookSubscribe.Event subscribe : subscribes) {
|
| | | subscribe.response(null, zlmServerConfig);
|
| | | }
|
| | |
| | | });
|
| | | try {
|
| | | HookZlmServerStartEvent event = new HookZlmServerStartEvent(this);
|
| | | MediaServerItem mediaServerItem = mediaServerService.getOne(zlmServerConfig.getMediaServerId());
|
| | | MediaServer mediaServerItem = mediaServerService.getOne(zlmServerConfig.getMediaServerId());
|
| | | if (mediaServerItem != null) {
|
| | | event.setMediaServerItem(mediaServerItem);
|
| | | applicationEventPublisher.publishEvent(event);
|
| | |
| | | */
|
| | | @ResponseBody
|
| | | @PostMapping(value = "/on_rtp_server_timeout", produces = "application/json;charset=UTF-8")
|
| | | public HookResult onRtpServerTimeout(HttpServletRequest request, @RequestBody OnRtpServerTimeoutHookParam
|
| | | public HookResult onRtpServerTimeout(@RequestBody OnRtpServerTimeoutHookParam
|
| | | param) {
|
| | | logger.info("[ZLM HOOK] rtpServer收流超时:{}->{}({})", param.getMediaServerId(), param.getStream_id(), param.getSsrc());
|
| | |
|
| | | taskExecutor.execute(() -> {
|
| | | JSONObject json = (JSONObject) JSON.toJSON(param);
|
| | | List<ZlmHttpHookSubscribe.Event> subscribes = this.subscribe.getSubscribes(HookType.on_rtp_server_timeout);
|
| | | if (subscribes != null && !subscribes.isEmpty()) {
|
| | | for (ZlmHttpHookSubscribe.Event subscribe : subscribes) {
|