Skip to content

Commit

Permalink
📦 hook sevice onServerExited
Browse files Browse the repository at this point in the history
  • Loading branch information
chenzhangyue committed Dec 14, 2023
1 parent fc6db57 commit 2b4292c
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 4 deletions.
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>io.github.lunasaw</groupId>
<artifactId>zlm-spring-boot-starter</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>

<name>zlm-spring-boot-starter</name>
<description>ZLMediaKit restful api and hook starter</description>
Expand All @@ -17,11 +17,11 @@
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<spring-boot.version>2.7.18</spring-boot.version>
<luna-common.version>2.5.2</luna-common.version>
<luna-common.version>2.5.3</luna-common.version>
<httpclient5.version>5.2.1</httpclient5.version>
<github.username>lunasaw</github.username>
<app.profiles>${project.name}</app.profiles>
<zlm-spring-boot-starter.version>1.0.0</zlm-spring-boot-starter.version>
<zlm-spring-boot-starter.version>1.0.1</zlm-spring-boot-starter.version>
</properties>

<developers>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import io.github.lunasaw.zlm.entity.ServerNodeConfig;
import io.github.lunasaw.zlm.hook.param.*;
import io.github.lunasaw.zlm.hook.service.ZlmHookService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.core.task.AsyncTaskExecutor;
Expand All @@ -16,6 +17,7 @@
* @date 2023/12/3
* @description: ZLM钩子控制器
*/
@Slf4j
@RestController
@RequestMapping("/index/hook/")
public class ZlmHookController {
Expand Down Expand Up @@ -98,10 +100,18 @@ public HookResult onStreamNotFound(@RequestBody OnStreamNotFoundHookParam param)
@ResponseBody
@PostMapping(value = "/on_server_started", produces = "application/json;charset=UTF-8")
public HookResult onServerStarted(@RequestBody JSONObject param) {
log.info("onServerStarted::param = {}", param);
executor.execute(() -> zlmHookService.onServerStarted(JSON.parseObject(param.toJSONString(), ServerNodeConfig.class)));
return HookResult.SUCCESS();
}

@ResponseBody
@PostMapping(value = "/on_server_exited", produces = "application/json;charset=UTF-8")
public HookResult onServerExited(@RequestBody HookParam param) {
executor.execute(() -> zlmHookService.onServerExited(param));
return HookResult.SUCCESS();
}

/**
* 发送rtp(startSendRtp)被动关闭时回调
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,9 @@ public HookResultForOnRtspAuth onRtspAuth(OnRtspAuthHookParam param) {
public void onFlowReport(OnFlowReportHookParam param) {

}

@Override
public void onServerExited(HookParam param) {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,6 @@ public interface ZlmHookService {
HookResultForOnRtspAuth onRtspAuth(OnRtspAuthHookParam param);

void onFlowReport(OnFlowReportHookParam param);

void onServerExited(HookParam param);
}
2 changes: 1 addition & 1 deletion zlm-spring-boot-starter-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<dependency>
<groupId>io.github.lunasaw</groupId>
<artifactId>zlm-spring-boot-starter</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,9 @@ public HookResultForOnRtspAuth onRtspAuth(OnRtspAuthHookParam param) {
public void onFlowReport(OnFlowReportHookParam param) {
log.info("onFlowReport::param = {}", JSON.toJSONString(param));
}

@Override
public void onServerExited(HookParam param) {
log.info("onServerExited::param = {}", param);
}
}

0 comments on commit 2b4292c

Please sign in to comment.