Monica视频监控处理程序
xc
2021-02-08 6f86e7cee012a5798f0e361ec984e1daf36b3c2e
src/main/java/com/hbbh/adapter/manager/impl/MonibucaManagerImpl.java
@@ -7,6 +7,9 @@
import com.hbbh.adapter.vo.CallResult;
import com.hbbh.adapter.vo.MessageVO;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.LinkedHashMap;
@@ -16,12 +19,23 @@
@Service
public class MonibucaManagerImpl implements MonibucaManager {
    private static final Logger log = LoggerFactory.getLogger(Class.class);
    @Value("${monica.ip}")
    private String monicaIP;
    @Value("${monica.port}")
    private String monicaPort;
    //入参 rtsp视频流
    private String rtspDemo="rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov";
    //返回结果,通过配置文件即可反推得到 前提是调用 rtsp/pull 接口成功
    private String jessibucaDemo="ws://localhost:8080/live/test.flv";
    //StreamPath 是发布流的唯一标识
    private String streamPath="live/test";
    // =========== monica监控 ===========
@@ -37,7 +51,7 @@
        String url="http://localhost:8081/rtsp/pull";
        Map<String, String> params = Maps.newLinkedHashMap();
        params.put("target",rtspDemo);
        params.put("streamPath","live/test");
        params.put("streamPath",streamPath);
        String result = HttpClientUtil.doGet(url, params);
@@ -50,4 +64,18 @@
        }
        return jessibucaDemo;
    }
    /**
     *
     * @param param StreamPath 是发布流的唯一标识
     * 示例: http://localhost:8081/api/stop?stream=live/test
     */
    @Override
    public void stopStream(String param) {
        String url="http://"+monicaIP+":"+monicaPort+"/api/stop";
        Map<String, String> params = Maps.newLinkedHashMap();
        params.put("stream",param);
        String result = HttpClientUtil.doGet(url, params);
        log.info("调用 Monibuca 执行结果 : {}",result);
    }
}