2021与蓝度共同重构项目,服务端
liuhaonan
2022-10-25 d495f9b8cdc83663e4189bc3cc72ac9543ff5555
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
package com.sandu.ximon.admin.controller;
 
import com.sandu.common.domain.ResponseVO;
import com.sandu.common.security.annotation.AnonymousAccess;
import com.sandu.common.util.ResponseUtil;
import com.sandu.ximon.admin.config.VnnoxConstant;
import com.sandu.ximon.admin.param.AsyncStatusParam;
import com.sandu.ximon.admin.param.VnnoxProgressParam;
import com.sandu.ximon.admin.param.VnnoxScreenShotParam;
import com.sandu.ximon.admin.utils.CountDownLatchUtil;
import com.sandu.ximon.admin.utils.RedisUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
//诺瓦回调
@RestController
@RequestMapping("/serv/vnnox")
public class ServVnnoxController {
 
    @Autowired
    private RedisUtils redisUtils;
    @Autowired
    private CountDownLatchUtil countDownLatchUtil;
 
 
    @AnonymousAccess
    @PostMapping("/screenshot")
    public ResponseVO<Object> screenshot(@RequestBody VnnoxScreenShotParam vnnoxScreenShot) {
        String url = vnnoxScreenShot.getScreenShotUrl().replace("&amp;", "&");
        System.out.println(vnnoxScreenShot);
        redisUtils.set(VnnoxConstant.REDIS_SCREEN_SHOT + vnnoxScreenShot.getPlayerId(), url);
        return ResponseUtil.success("ok");
    }
 
 
    @AnonymousAccess
    @PostMapping("/progress")
    public ResponseVO<Object> progress(@RequestBody VnnoxProgressParam vnnoxProgress) {
        redisUtils.set(VnnoxConstant.REDIS_PROGRESS + vnnoxProgress.getPlayerId(), vnnoxProgress.getPrecess());
        return ResponseUtil.success("ok");
    }
 
 
    @AnonymousAccess
    @PostMapping("/asyncStatus")
    public ResponseVO<Object> asyncStatus(@RequestBody AsyncStatusParam asyncStatusParam) {
        System.out.println(asyncStatusParam.toString());
        if ("brightnessValue".equals(asyncStatusParam.getCommand())) {
            //亮度
            String ratio = asyncStatusParam.getData().getRatio();
            int i = Integer.parseInt(ratio);
            redisUtils.set(VnnoxConstant.REDIS_BRIGHTNESS + asyncStatusParam.getPlayerId(), i + "", VnnoxConstant.STATUS_TIME);
        } else if ("volumeValue".equals(asyncStatusParam.getCommand())) {
            //音量
            String ratio = asyncStatusParam.getData().getRatio();
            int i = Integer.parseInt(ratio);
            redisUtils.set(VnnoxConstant.REDIS_VOL + asyncStatusParam.getPlayerId(), i + "", VnnoxConstant.STATUS_TIME);
        } else if ("videoSourceValue".equals(asyncStatusParam.getCommand())) {
            //当前视频源
            redisUtils.set(VnnoxConstant.VIDEO_SOURCE_VALUE + asyncStatusParam.getPlayerId(), asyncStatusParam.getData().getVideoSource(), VnnoxConstant.STATUS_TIME);
        } else if ("timeValue".equals(asyncStatusParam.getCommand())) {
            //当前时区和时间
            redisUtils.set(VnnoxConstant.TIME_VALUE_TIME + asyncStatusParam.getPlayerId(), asyncStatusParam.getData().getCurrentTime(), VnnoxConstant.STATUS_TIME);
            redisUtils.set(VnnoxConstant.TIME_VALUE_TIMEZONE + asyncStatusParam.getPlayerId(), asyncStatusParam.getData().getTimeZone(), VnnoxConstant.STATUS_TIME);
        } else if ("screenPowerStatus".equals(asyncStatusParam.getCommand())) {
            //屏幕状态
            if ("OPEN".equals(asyncStatusParam.getData().getState())) {
                redisUtils.set(VnnoxConstant.REDIS_SCREEN_STATUS + asyncStatusParam.getPlayerId(), "1", VnnoxConstant.STATUS_TIME);
            } else {
                redisUtils.set(VnnoxConstant.REDIS_SCREEN_STATUS + asyncStatusParam.getPlayerId(), "0", VnnoxConstant.STATUS_TIME);
            }
            ;
        } else if ("syncPlayStatus".equals(asyncStatusParam.getCommand())) {
            //同步播放状态
            redisUtils.set(VnnoxConstant.SYNC_PLAY_STATUS + asyncStatusParam.getPlayerId(), asyncStatusParam.getData().getEnable(), VnnoxConstant.STATUS_TIME);
        }
        countDownLatchUtil.countDown(asyncStatusParam.getLogid());
        return ResponseUtil.success("ok");
    }
 
}