| | |
| | | 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);
|
| | | ret.put("enableMP4", userSetup.isRecordPushLive());
|
| | | String mediaServerId = json.getString("mediaServerId");
|
| | | ZLMHttpHookSubscribe.Event subscribe = this.subscribe.getSubscribe(ZLMHttpHookSubscribe.HookType.on_publish, json);
|
| | | if (subscribe != null) {
|
| | | MediaServerItem mediaInfo = mediaServerService.getOne(mediaServerId);
|
| | | if (mediaInfo != null) {
|
| | | subscribe.response(mediaInfo, json);
|
| | | }else {
|
| | | ret.put("code", 1);
|
| | | ret.put("msg", "zlm not register");
|
| | | }
|
| | | }
|
| | | String app = json.getString("app");
|
| | | String stream = json.getString("stream");
|
| | | StreamInfo streamInfo = redisCatchStorage.queryPlaybackByStreamId(stream);
|
| | | JSONObject ret = new JSONObject();
|
| | |
|
| | | // 录像回放时不进行录像下载
|
| | | if (streamInfo != null) {
|
| | | ret.put("enableMP4", false);
|
| | | }else {
|
| | | ret.put("enableMP4", userSetup.isRecordPushLive());
|
| | | }
|
| | | ret.put("code", 0);
|
| | | ret.put("msg", "success");
|
| | | ret.put("enableHls", true);
|
| | | ret.put("enableMP4", userSetup.isRecordPushLive());
|
| | |
|
| | | return new ResponseEntity<String>(ret.toString(), HttpStatus.OK);
|
| | | }
|
| | |
|
| | |
| | | if (!"rtp".equals(app)){
|
| | | String type = OriginType.values()[item.getOriginType()].getType();
|
| | | MediaServerItem mediaServerItem = mediaServerService.getOne(mediaServerId);
|
| | | if (mediaServerItem != null){
|
| | | if (regist) {
|
| | | StreamInfo streamInfo = mediaService.getStreamInfoByAppAndStream(mediaServerItem, app, streamId, tracks);
|
| | | redisCatchStorage.addStream(mediaServerItem, type, app, streamId, streamInfo);
|
| | |
| | | }
|
| | | }
|
| | | zlmMediaListManager.removeMedia(app, streamId);
|
| | | redisCatchStorage.removeStream(mediaServerItem, type, app, streamId);
|
| | | redisCatchStorage.removeStream(mediaServerItem.getId(), type, app, streamId);
|
| | | }
|
| | |
|
| | | // 发送流变化redis消息
|
| | | JSONObject jsonObject = new JSONObject();
|
| | | jsonObject.put("serverId", userSetup.getServerId());
|
| | |
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | JSONObject ret = new JSONObject();
|
| | | ret.put("code", 0);
|