648540858
2021-11-12 eca1e05aeed3c51cce36bbce80c71bc3cbcea87d
src/main/java/com/genersoft/iot/vmp/web/ApiStreamController.java
@@ -1,27 +1,25 @@
package com.genersoft.iot.vmp.web;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
import com.genersoft.iot.vmp.vmanager.play.PlayController;
import com.genersoft.iot.vmp.vmanager.gb28181.play.PlayController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.async.DeferredResult;
/**
 * 兼容LiveGBS的API:实时直播
 * API兼容:实时直播
 */
@SuppressWarnings(value = {"rawtypes", "unchecked"})
@CrossOrigin
@RestController
@RequestMapping(value = "/api/v1/stream")
@@ -35,11 +33,12 @@
    @Autowired
    private IVideoManagerStorager storager;
    private boolean closeWaitRTPInfo = false;
    @Autowired
    private ZLMRESTfulUtils zlmresTfulUtils;
    private IRedisCatchStorage redisCatchStorage;
    // @Autowired
    // private ZLMRESTfulUtils zlmresTfulUtils;
    @Autowired
@@ -86,6 +85,8 @@
            JSONObject result = new JSONObject();
            result.put("error","timeout");
            resultDeferredResult.setResult(result);
             // 清理RTP server
        });
        DeviceChannel deviceChannel = storager.queryChannel(serial, code);
@@ -156,14 +157,15 @@
    ){
        StreamInfo streamInfo = storager.queryPlayByDevice(serial, code);
        StreamInfo streamInfo = redisCatchStorage.queryPlayByDevice(serial, code);
        if (streamInfo == null) {
            JSONObject result = new JSONObject();
            result.put("error","未找到流信息");
            return result;
        }
        cmder.streamByeCmd(streamInfo.getStreamId());
        storager.stopPlay(streamInfo);
        cmder.streamByeCmd(serial, code);
        redisCatchStorage.stopPlay(streamInfo);
        storager.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId());
        return null;
    }