liusuyi
2026-05-18 0b8c8d8986a35c3e36db1503125e2dff79d6d10e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package com.ard.zlm.api;
 
import com.ard.common.core.domain.R;
import com.ard.common.core.domain.RtpServerParam;
import com.ard.zlm.api.domain.ZlmMediaServer;
import com.ard.zlm.service.IMediaServerService;
import com.ard.zlm.session.SSRCFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
/**
 * zlm接口
 *
 * @FileName ZlmApiController
 * @Description
 * @Author fengcheng
 * @date 2026-04-01
 **/
@Slf4j
@RestController
@RequestMapping("/api/zlm")
public class ZlmApiController {
 
    @Autowired
    private IMediaServerService mediaServerService;
 
    @Autowired
    private SSRCFactory ssrcFactory;
 
    @DeleteMapping("/sessionManagerPut/{mediaServerId}/{ssrc}")
    R<Void> releaseSsrc(@PathVariable String mediaServerId, @PathVariable String ssrc) {
        ssrcFactory.releaseSsrc(mediaServerId, ssrc);
        return R.ok();
    }
 
    /**
     * 关闭rtp服务
     *
     * @param mediaServerId
     * @param rtpServer
     */
    @PostMapping("/closeRTPServer/{mediaServerId}")
    R<Void> closeRTPServer(@PathVariable String mediaServerId, @RequestBody RtpServerParam rtpServer) {
        ZlmMediaServer mediaServer = mediaServerService.getOneFromDatabase(mediaServerId);
        mediaServerService.closeRTPServer(mediaServer, rtpServer.getStream());
        return R.ok();
    }
 
    /**
     * 连接rtp服务
     *
     * @param mediaServerId
     * @param address
     * @param port
     * @param stream
     * @return
     */
    @PostMapping("/connectRtpServer/{mediaServerId}")
    R<Boolean> connectRtpServer(@PathVariable String mediaServerId, @RequestParam String address, @RequestParam int port, @RequestParam String stream) {
        ZlmMediaServer mediaServer = mediaServerService.getOneFromDatabase(mediaServerId);
        Boolean b = mediaServerService.connectRtpServer(mediaServer, address, port, stream);
        return R.ok(b);
    }
}