648540858
2021-12-08 ab81136765f1b641223b982b2baef13e06307fe4
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.genersoft.iot.vmp.media.zlm.event;
 
import com.genersoft.iot.vmp.conf.SipConfig;
import com.genersoft.iot.vmp.conf.UserSetup;
import com.genersoft.iot.vmp.service.IMediaServerService;
import com.genersoft.iot.vmp.service.IStreamProxyService;
import com.genersoft.iot.vmp.service.IStreamPushService;
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
import com.genersoft.iot.vmp.utils.redis.RedisUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;
 
import java.text.SimpleDateFormat;
 
/**
 * @description: 在线事件监听器,监听到离线后,修改设备离在线状态。 设备在线有两个来源:
 *               1、设备主动注销,发送注销指令
 *               2、设备未知原因离线,心跳超时
 * @author: swwheihei
 * @date: 2020年5月6日 下午1:51:23
 */
@Component
public class ZLMOnlineEventListener implements ApplicationListener<ZLMOnlineEvent> {
    
    private final static Logger logger = LoggerFactory.getLogger(ZLMOnlineEventListener.class);
 
    @Autowired
    private IVideoManagerStorager storager;
    
    @Autowired
    private RedisUtil redis;
 
    @Autowired
    private SipConfig sipConfig;
 
    @Autowired
    private UserSetup userSetup;
 
    @Autowired
    private IMediaServerService mediaServerService;
 
    @Autowired
    private IStreamPushService streamPushService;
 
    @Autowired
    private IStreamProxyService streamProxyService;
 
    private SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 
    @Override
    public void onApplicationEvent(ZLMOnlineEvent event) {
        
        if (logger.isDebugEnabled()) {
            logger.debug("ZLM上线事件触发,ID:" + event.getMediaServerId());
        }
        streamPushService.zlmServerOnline(event.getMediaServerId());
        streamProxyService.zlmServerOnline(event.getMediaServerId());
 
 
 
    }
}