Xiajijian
2025-10-28 502730fd95761286a0bd530435d54217d9e4db35
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
package com.ard.web.controller.sample;
 
import com.ard.common.core.domain.entity.SysUser;
import com.ard.common.utils.SecurityUtils;
import com.ard.sample.common.model.ResponseResult;
import com.ard.sample.component.mqtt.model.ChannelName;
import com.ard.sample.manage.model.dto.CapacityDeviceDTO;
import com.ard.sample.manage.model.dto.LiveTypeDTO;
import com.ard.sample.manage.model.receiver.LiveCapacityReceiver;
import com.ard.sample.manage.service.ILiveStreamService;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.integration.annotation.ServiceActivator;
import org.springframework.messaging.MessageHeaders;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
 
import javax.servlet.http.HttpServletRequest;
import java.util.List;
 
/**
 * @author sean.zhou
 * @version 0.1
 * @date 2021/11/19
 */
 
@Api(tags = "直播功能")
@RestController
@Slf4j
@RequestMapping("/dock/live")
public class LiveStreamController {
 
    @Autowired
    private ILiveStreamService liveStreamService;
 
    @Autowired
    private ObjectMapper mapper;
 
    /**
     * Analyze the live streaming capabilities of drones.
     * This data is necessary if drones are required for live streaming.
     *
     * @param liveCapacity the capacity of drone and dock
     */
    @ServiceActivator(inputChannel = ChannelName.INBOUND_STATE_CAPACITY)
    public void stateCapacity(LiveCapacityReceiver liveCapacity, MessageHeaders headers) {
        liveStreamService.saveLiveCapacity(liveCapacity, headers.getTimestamp());
    }
 
    /**
     * Get live capability data of all drones in the current user's workspace from the database.
     *
     * @param request
     * @return live capability
     */
    @ApiOperation(value = "获取直播能力数据", notes = "获取当前用户工作空间下所有无人机的直播能力数据")
    @PreAuthorize("@ss.hasPermi('dock:live:capacity')")
    @GetMapping("/capacity")
    public ResponseResult<List<CapacityDeviceDTO>> getLiveCapacity(HttpServletRequest request) {
        // Get information about the current user.
        List<CapacityDeviceDTO> liveCapacity = liveStreamService.getLiveCapacity();
 
        return ResponseResult.success(liveCapacity);
    }
 
    /**
     * Live streaming according to the parameters passed in from the web side.
     *
     * @param liveParam Live streaming parameters.
     * @return
     */
    @ApiOperation(value = "开始直播", notes = "根据前端传入的参数开始直播")
    @PreAuthorize("@ss.hasPermi('dock:live:start')")
    @PostMapping("/streams/start")
    public ResponseResult liveStart(@RequestBody LiveTypeDTO liveParam) {
        return liveStreamService.liveStart(liveParam);
    }
 
    /**
     * Stop live streaming according to the parameters passed in from the web side.
     *
     * @param liveParam Live streaming parameters.
     * @return
     */
    @ApiOperation(value = "停止直播", notes = "根据前端传入的参数停止直播")
    @PreAuthorize("@ss.hasPermi('dock:live:stop')")
    @PostMapping("/streams/stop")
    public ResponseResult liveStop(@RequestBody LiveTypeDTO liveParam) {
        return liveStreamService.liveStop(liveParam.getVideoId());
    }
 
    /**
     * Set the quality of the live streaming according to the parameters passed in from the web side.
     *
     * @param liveParam Live streaming parameters.
     * @return
     */
    @ApiOperation(value = "设置直播质量", notes = "根据前端传入的参数设置直播质量")
    @PreAuthorize("@ss.hasPermi('dock:live:quality')")
    @PostMapping("/quality/switch")
    public ResponseResult liveSetQuality(@RequestBody LiveTypeDTO liveParam) {
        return liveStreamService.liveSetQuality(liveParam);
    }
 
    @ApiOperation(value = "切换镜头", notes = "根据前端传入的参数切换镜头")
    @PreAuthorize("@ss.hasPermi('dock:live:lens')")
    @PostMapping("/lens/switch")
    public ResponseResult liveLensChange(@RequestBody LiveTypeDTO liveParam) {
        return liveStreamService.liveLensChange(liveParam);
    }
 
    @ApiOperation(value = "机场直播相机切换", notes = "根据前端传入的参数切换相机")
    @PreAuthorize("@ss.hasPermi('dock:live:camera')")
    @PostMapping("/camera/switch")
    public ResponseResult liveCameraChange(@RequestBody LiveTypeDTO liveParam) {
        return liveStreamService.liveCameraChange(liveParam);
    }
 
}