liusuyi
2026-06-01 a2e7e8ff9cfaa69b001d483710bddbda50d55c91
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
package com.ard.zlm.service.impl;
 
import com.ard.common.core.enums.LiveStreamType;
import com.ard.qs.api.domain.QsDevice;
import com.ard.work.api.domian.ArdChannel;
import com.ard.zlm.api.domain.StreamInfo;
import com.ard.zlm.service.ErrorCallback;
import com.ard.zlm.service.IDevicePlayService;
import com.ard.zlm.service.ISourcePlayService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.Map;
 
/**
 * @FileName DevicePlayServiceImpl
 * @Description
 * @Author fengcheng
 * @date 2026-04-12
 **/
@Slf4j
@Service
public class DevicePlayServiceImpl implements IDevicePlayService {
 
    @Autowired
    private Map<String, ISourcePlayService> sourcePlayServiceMap;
 
    public final static String PLAY_SERVICE = "sourceDevicePlayService";
 
    @Override
    public void play(ArdChannel channel, Boolean record, ErrorCallback<StreamInfo> callback) {
        log.info("[设备] 播放, 类型: {}", LiveStreamType.getByCode(channel.getType()));
        ISourcePlayService sourceChannelPlayService = sourcePlayServiceMap.get(PLAY_SERVICE);
        if (sourceChannelPlayService == null) {
            // 设备数据异常
            log.error("[点播通用设备] 类型编号: {} 不支持实时流预览", LiveStreamType.getByCode(channel.getType()));
            throw new RuntimeException("Device not supported");
        }
        sourceChannelPlayService.play(channel, record, (code, msg, data) -> {
            callback.run(code, msg, data);
        });
    }
}