实现对ZLM全部HOOK的支持.

pull/1019/head
AlphaWu 2023-08-21 13:29:50 +08:00
parent a9202bd004
commit 42cfa4aaef
10 changed files with 828 additions and 10 deletions

View File

@ -126,6 +126,35 @@ public class ZLMHttpHookListener {
@Autowired
private RedisTemplate<Object, Object> redisTemplate;
/**
* general.flowThreshold
*
*/
@ResponseBody
@PostMapping(value = "/on_flow_report", produces = "application/json;charset=UTF-8")
public HookResult onFlowReport(@RequestBody OnFlowReportHookParam param){
if (logger.isDebugEnabled()) {
logger.debug("[ ZLM HOOK ] on_flow_report API调用参数{}" , param);
}
return HookResult.SUCCESS();
}
/**
* 访httphls
*
*/
@ResponseBody
@PostMapping(value = "/on_http_access", produces = "application/json;charset=UTF-8")
public HookResult onHttpAccess(@RequestBody JSONObject json){
if (logger.isDebugEnabled()) {
logger.debug("[ ZLM HOOK ] on_http_access API调用参数{}" , json);
}
return HookResult.SUCCESS();
}
/**
* 10s
*/
@ -133,7 +162,9 @@ public class ZLMHttpHookListener {
@PostMapping(value = "/on_server_keepalive", produces = "application/json;charset=UTF-8")
public HookResult onServerKeepalive(@RequestBody OnServerKeepaliveHookParam param) {
if (logger.isDebugEnabled()) {
logger.debug("[ ZLM HOOK ] on_server_keepalive API调用参数{}" , param);
}
taskExecutor.execute(() -> {
List<ZlmHttpHookSubscribe.Event> subscribes = this.subscribe.getSubscribes(HookType.on_server_keepalive);
@ -187,10 +218,10 @@ public class ZLMHttpHookListener {
@ResponseBody
@PostMapping(value = "/on_publish", produces = "application/json;charset=UTF-8")
public HookResultForOnPublish onPublish(@RequestBody OnPublishHookParam param) {
JSONObject json = (JSONObject) JSON.toJSON(param);
logger.info("[ZLM HOOK]推流鉴权:{}->{}", param.getMediaServerId(), param);
if (logger.isDebugEnabled()) {
logger.debug("[ZLM HOOK]推流鉴权:{}->{}", param.getMediaServerId(), param);
}
String mediaServerId = json.getString("mediaServerId");
MediaServerItem mediaInfo = mediaServerService.getOne(mediaServerId);
@ -306,11 +337,82 @@ public class ZLMHttpHookListener {
result.setEnable_mp4(true);
}
}
logger.info("[ZLM HOOK]推流鉴权 响应:{}->{}->>>>{}", param.getMediaServerId(), param, result);
if (logger.isDebugEnabled()) {
logger.debug("[ZLM HOOK]推流鉴权 响应:{}->{}->>>>{}", param.getMediaServerId(), param, result);
}
return result;
}
/**
* mp4
*
*/
@ResponseBody
@PostMapping(value = "/on_record_mp4", produces = "application/json;charset=UTF-8")
public HookResult onRecordMp4(@RequestBody OnRecordHookParam param){
if (logger.isDebugEnabled()) {
logger.debug("[ ZLM HOOK ] on_record_mp4 API调用参数" + param.toString());
}
return HookResult.SUCCESS();
}
/**
* hls
*
*/
@ResponseBody
@PostMapping(value = "/on_record_ts", produces = "application/json;charset=UTF-8")
public HookResult onRecordTs(@RequestBody OnRecordHookParam param){
if (logger.isDebugEnabled()) {
logger.debug("[ ZLM HOOK ] on_record_ts API调用参数" + param.toString());
}
return HookResult.SUCCESS();
}
/**
* rtspon_rtsp_realmon_rtsp_auth
*
*/
@ResponseBody
@PostMapping(value = "/on_rtsp_realm", produces = "application/json;charset=UTF-8")
public HookResult onRtspRealm(@RequestBody OnRtspRealmHookParam param){
if (logger.isDebugEnabled()) {
logger.debug("[ ZLM HOOK ] on_rtsp_realm API调用参数{}" , param.toString());
}
return HookResult.SUCCESS();
}
/**
* rtsprtspon_rtsp_authrtspurl
*
*/
@ResponseBody
@PostMapping(value = "/on_rtsp_auth", produces = "application/json;charset=UTF-8")
public HookResult onRtspAuth(@RequestBody OnRtspAuthHookParam param){
if (logger.isDebugEnabled()) {
logger.debug("[ ZLM HOOK ] on_rtsp_auth API调用参数{}" , param.toString());
}
return HookResult.SUCCESS();
}
/**
* shellZLMediaKittelnet使telnet 127.0.0.1 9000MediaServershell
*
*/
@ResponseBody
@PostMapping(value = "/on_shell_login", produces = "application/json;charset=UTF-8")
public HookResult onShellLogin(@RequestBody OnShellLoginHookParam param){
if (logger.isDebugEnabled()) {
logger.debug("[ ZLM HOOK ] on_shell_login API调用参数{}" , param.toString());
}
return HookResult.SUCCESS();
}
/**
* rtsp/rtmp
*/
@ -703,6 +805,19 @@ public class ZLMHttpHookListener {
return HookResult.SUCCESS();
}
/**
* 退退
*
*/
@ResponseBody
@PostMapping(value = "/on_server_exited", produces = "application/json;charset=UTF-8")
public HookResult onServerExited(@RequestBody OnServerExitedHookParam param){
if (logger.isDebugEnabled()) {
logger.debug("[ ZLM HOOK ] on_server_exited API调用参数{}" , param.toString());
}
return HookResult.SUCCESS();
}
/**
* rtp(startSendRtp)
*/

View File

@ -1,4 +1,166 @@
package com.genersoft.iot.vmp.media.zlm.dto;
import com.fasterxml.jackson.annotation.JsonProperty;
public class ServerKeepaliveData {
@JsonProperty("Buffer")
public int buffer;
@JsonProperty("BufferLikeString")
public int bufferLikeString;
@JsonProperty("BufferList")
public int bufferList;
@JsonProperty("BufferRaw")
public int bufferRaw;
@JsonProperty("Frame")
public int frame;
@JsonProperty("FrameImp")
public int frameImp;
@JsonProperty("MediaSource")
public int mediaSource;
@JsonProperty("MultiMediaSourceMuxer")
public int multiMediaSourceMuxer;
@JsonProperty("RtmpPacket")
public int rtmpPacket;
@JsonProperty("RtpPacket")
public int rtpPacket;
@JsonProperty("Socket")
public int socket;
@JsonProperty("TcpClient")
public int tcpClient;
@JsonProperty("TcpServer")
public int tcpServer;
@JsonProperty("TcpSession")
public int tcpSession;
@JsonProperty("UdpServer")
public int udpServer;
@JsonProperty("UdpSession")
public int udpSession;
public int getBuffer() {
return buffer;
}
public void setBuffer(int buffer) {
this.buffer = buffer;
}
public int getBufferLikeString() {
return bufferLikeString;
}
public void setBufferLikeString(int bufferLikeString) {
this.bufferLikeString = bufferLikeString;
}
public int getBufferList() {
return bufferList;
}
public void setBufferList(int bufferList) {
this.bufferList = bufferList;
}
public int getBufferRaw() {
return bufferRaw;
}
public void setBufferRaw(int bufferRaw) {
this.bufferRaw = bufferRaw;
}
public int getFrame() {
return frame;
}
public void setFrame(int frame) {
this.frame = frame;
}
public int getFrameImp() {
return frameImp;
}
public void setFrameImp(int frameImp) {
this.frameImp = frameImp;
}
public int getMediaSource() {
return mediaSource;
}
public void setMediaSource(int mediaSource) {
this.mediaSource = mediaSource;
}
public int getMultiMediaSourceMuxer() {
return multiMediaSourceMuxer;
}
public void setMultiMediaSourceMuxer(int multiMediaSourceMuxer) {
this.multiMediaSourceMuxer = multiMediaSourceMuxer;
}
public int getRtmpPacket() {
return rtmpPacket;
}
public void setRtmpPacket(int rtmpPacket) {
this.rtmpPacket = rtmpPacket;
}
public int getRtpPacket() {
return rtpPacket;
}
public void setRtpPacket(int rtpPacket) {
this.rtpPacket = rtpPacket;
}
public int getSocket() {
return socket;
}
public void setSocket(int socket) {
this.socket = socket;
}
public int getTcpClient() {
return tcpClient;
}
public void setTcpClient(int tcpClient) {
this.tcpClient = tcpClient;
}
public int getTcpServer() {
return tcpServer;
}
public void setTcpServer(int tcpServer) {
this.tcpServer = tcpServer;
}
public int getTcpSession() {
return tcpSession;
}
public void setTcpSession(int tcpSession) {
this.tcpSession = tcpSession;
}
public int getUdpServer() {
return udpServer;
}
public void setUdpServer(int udpServer) {
this.udpServer = udpServer;
}
public int getUdpSession() {
return udpSession;
}
public void setUdpSession(int udpSession) {
this.udpSession = udpSession;
}
}

View File

@ -6,7 +6,7 @@ package com.genersoft.iot.vmp.media.zlm.dto.hook;
*/
public class HookParam {
private String mediaServerId;
private int hook_index;
public String getMediaServerId() {
return mediaServerId;
}
@ -14,4 +14,12 @@ public class HookParam {
public void setMediaServerId(String mediaServerId) {
this.mediaServerId = mediaServerId;
}
public int getHook_index() {
return hook_index;
}
public void setHook_index(int hook_index) {
this.hook_index = hook_index;
}
}

View File

@ -0,0 +1,125 @@
package com.genersoft.iot.vmp.media.zlm.dto.hook;
/**
* zlm hookon_flow_report
* @author AlphaWu
*/
public class OnFlowReportHookParam extends HookParam{
private String app;
private int duration;
private String params;
private boolean player;
private String schema;
private String stream;
private int totalBytes;
private String vhost;
private String ip;
private int port;
private String id;
public String getApp() {
return app;
}
public void setApp(String app) {
this.app = app;
}
public int getDuration() {
return duration;
}
public void setDuration(int duration) {
this.duration = duration;
}
public String getParams() {
return params;
}
public void setParams(String params) {
this.params = params;
}
public boolean isPlayer() {
return player;
}
public void setPlayer(boolean player) {
this.player = player;
}
public String getSchema() {
return schema;
}
public void setSchema(String schema) {
this.schema = schema;
}
public String getStream() {
return stream;
}
public void setStream(String stream) {
this.stream = stream;
}
public int getTotalBytes() {
return totalBytes;
}
public void setTotalBytes(int totalBytes) {
this.totalBytes = totalBytes;
}
public String getVhost() {
return vhost;
}
public void setVhost(String vhost) {
this.vhost = vhost;
}
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip;
}
public int getPort() {
return port;
}
public void setPort(int port) {
this.port = port;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
@Override
public String toString() {
return "OnFlowReportHookParam{" +
"mediaServerId='" + super.getMediaServerId() + '\'' +
"app='" + app + '\'' +
", duration=" + duration +
", params='" + params + '\'' +
", player=" + player +
", schema='" + schema + '\'' +
", stream='" + stream + '\'' +
", totalBytes=" + totalBytes +
", vhost='" + vhost + '\'' +
", ip='" + ip + '\'' +
", port=" + port +
", id='" + id + '\'' +
'}';
}
}

View File

@ -0,0 +1,115 @@
package com.genersoft.iot.vmp.media.zlm.dto.hook;
/**
* zlm hookon_record_mp4on_record_ts
* @author AlphaWu
*/
public class OnRecordHookParam extends HookParam{
private String app;
private String file_name;
private String file_path;
private int file_size;
private String folder;
private int start_time;
private String stream;
private double time_len;
private String url;
private String vhost;
public String getApp() {
return app;
}
public void setApp(String app) {
this.app = app;
}
public String getFile_name() {
return file_name;
}
public void setFile_name(String file_name) {
this.file_name = file_name;
}
public String getFile_path() {
return file_path;
}
public void setFile_path(String file_path) {
this.file_path = file_path;
}
public int getFile_size() {
return file_size;
}
public void setFile_size(int file_size) {
this.file_size = file_size;
}
public String getFolder() {
return folder;
}
public void setFolder(String folder) {
this.folder = folder;
}
public int getStart_time() {
return start_time;
}
public void setStart_time(int start_time) {
this.start_time = start_time;
}
public String getStream() {
return stream;
}
public void setStream(String stream) {
this.stream = stream;
}
public double getTime_len() {
return time_len;
}
public void setTime_len(double time_len) {
this.time_len = time_len;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getVhost() {
return vhost;
}
public void setVhost(String vhost) {
this.vhost = vhost;
}
@Override
public String toString() {
return "OnRecordHookParam{" +
"mediaServerId='" + super.getMediaServerId() + '\'' +
"app='" + app + '\'' +
", file_name='" + file_name + '\'' +
", file_path='" + file_path + '\'' +
", file_size=" + file_size +
", folder='" + folder + '\'' +
", start_time=" + start_time +
", stream='" + stream + '\'' +
", time_len=" + time_len +
", url='" + url + '\'' +
", vhost='" + vhost + '\'' +
'}';
}
}

View File

@ -0,0 +1,125 @@
package com.genersoft.iot.vmp.media.zlm.dto.hook;
/**
* zlm hookon_rtsp_auth
* @author AlphaWu
*/
public class OnRtspAuthHookParam extends HookParam{
private String app;
private String id;
private String ip;
private boolean must_no_encrypt;
private String params;
private int port;
private String realm;
private String schema;
private String stream;
private String user_name;
private String vhost;
public String getApp() {
return app;
}
public void setApp(String app) {
this.app = app;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip;
}
public boolean isMust_no_encrypt() {
return must_no_encrypt;
}
public void setMust_no_encrypt(boolean must_no_encrypt) {
this.must_no_encrypt = must_no_encrypt;
}
public String getParams() {
return params;
}
public void setParams(String params) {
this.params = params;
}
public int getPort() {
return port;
}
public void setPort(int port) {
this.port = port;
}
public String getRealm() {
return realm;
}
public void setRealm(String realm) {
this.realm = realm;
}
public String getSchema() {
return schema;
}
public void setSchema(String schema) {
this.schema = schema;
}
public String getStream() {
return stream;
}
public void setStream(String stream) {
this.stream = stream;
}
public String getUser_name() {
return user_name;
}
public void setUser_name(String user_name) {
this.user_name = user_name;
}
public String getVhost() {
return vhost;
}
public void setVhost(String vhost) {
this.vhost = vhost;
}
@Override
public String toString() {
return "OnRtspAuthHookParam{" +
"mediaServerId='" + super.getMediaServerId() + '\'' +
"app='" + app + '\'' +
", id='" + id + '\'' +
", ip='" + ip + '\'' +
", must_no_encrypt=" + must_no_encrypt +
", params='" + params + '\'' +
", port=" + port +
", realm='" + realm + '\'' +
", schema='" + schema + '\'' +
", stream='" + stream + '\'' +
", user_name='" + user_name + '\'' +
", vhost='" + vhost + '\'' +
'}';
}
}

View File

@ -0,0 +1,95 @@
package com.genersoft.iot.vmp.media.zlm.dto.hook;
/**
* zlm hookon_rtsp_realm
* @author AlphaWu
*/
public class OnRtspRealmHookParam extends HookParam{
private String app;
private String id;
private String ip;
private String params;
private int port;
private String schema;
private String stream;
private String vhost;
public String getApp() {
return app;
}
public void setApp(String app) {
this.app = app;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip;
}
public String getParams() {
return params;
}
public void setParams(String params) {
this.params = params;
}
public int getPort() {
return port;
}
public void setPort(int port) {
this.port = port;
}
public String getSchema() {
return schema;
}
public void setSchema(String schema) {
this.schema = schema;
}
public String getStream() {
return stream;
}
public void setStream(String stream) {
this.stream = stream;
}
public String getVhost() {
return vhost;
}
public void setVhost(String vhost) {
this.vhost = vhost;
}
@Override
public String toString() {
return "OnRtspRealmHookParam{" +
"mediaServerId='" + super.getMediaServerId() + '\'' +
"app='" + app + '\'' +
", id='" + id + '\'' +
", ip='" + ip + '\'' +
", params='" + params + '\'' +
", port=" + port +
", schema='" + schema + '\'' +
", stream='" + stream + '\'' +
", vhost='" + vhost + '\'' +
'}';
}
}

View File

@ -0,0 +1,9 @@
package com.genersoft.iot.vmp.media.zlm.dto.hook;
/**
* zlm hookon_server_exited
* @author AlphaWu
*/
public class OnServerExitedHookParam extends HookParam{
}

View File

@ -1,9 +1,10 @@
package com.genersoft.iot.vmp.media.zlm.dto.hook;
import com.alibaba.fastjson2.JSONObject;
import com.genersoft.iot.vmp.media.zlm.dto.ServerKeepaliveData;
/**
* zlm hookon_play
* zlm hook on_server_keepalive
* @author lin
*/
public class OnServerKeepaliveHookParam extends HookParam{
@ -20,8 +21,6 @@ public class OnServerKeepaliveHookParam extends HookParam{
@Override
public String toString() {
return "OnServerKeepaliveHookParam{" +
"data=" + data +
'}';
return JSONObject.toJSONString(this);
}
}

View File

@ -0,0 +1,65 @@
package com.genersoft.iot.vmp.media.zlm.dto.hook;
/**
* zlm hookon_shell_login
* @author AlphaWu
*/
public class OnShellLoginHookParam extends HookParam{
private String id;
private String ip;
private String passwd;
private float port;
private String user_name;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip;
}
public String getPasswd() {
return passwd;
}
public void setPasswd(String passwd) {
this.passwd = passwd;
}
public float getPort() {
return port;
}
public void setPort(float port) {
this.port = port;
}
public String getUser_name() {
return user_name;
}
public void setUser_name(String user_name) {
this.user_name = user_name;
}
@Override
public String toString() {
return "OnShellLoginHookParam{" +
"mediaServerId='" + super.getMediaServerId() + '\'' +
"id='" + id + '\'' +
", ip='" + ip + '\'' +
", passwd='" + passwd + '\'' +
", port=" + port +
", user_name='" + user_name + '\'' +
'}';
}
}