| | |
| | | @Resource |
| | | private RedisTemplate redisTemplate; |
| | | |
| | | @Value("${live.output.path}") |
| | | private String outputPath; |
| | | @Value("${live.hls.output-path}") |
| | | private String hlsOutputPath; |
| | | |
| | | @Value("${live.ip}") |
| | | private String liveIp; |
| | | @Value("${live.hls.ip}") |
| | | private String hlsIp; |
| | | |
| | | @Value("${live.port}") |
| | | private Integer livePort; |
| | | @Value("${live.hls.port}") |
| | | private Integer hlsPort; |
| | | |
| | | @Value("${live.flv.ip}") |
| | | private String flvIp; |
| | | |
| | | @Value("${live.flv.rtmp-port}") |
| | | private Integer flvRtmpPort; |
| | | |
| | | @Value("${live.flv.http-port}") |
| | | private Integer flvHttpPort; |
| | | |
| | | |
| | | @GetMapping("/getOrderList") |
| | |
| | | if (200 == startupAckVoR.getCode()) { |
| | | UPPlaybackMsgStartupAckVo data = startupAckVoR.getData(); |
| | | RealVideoResp resp = new RealVideoResp(); |
| | | String path = outputPath + "hls\\" + car.getVehicleNumber() + "\\live.m3u8"; |
| | | String folderPath = outputPath + "hls\\" + car.getVehicleNumber(); |
| | | FileUtil.mkParentDirs(path); |
| | | File file = new File(path); |
| | | if (!file.exists()) { |
| | | try { |
| | | file.createNewFile(); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | |
| | | //执行拉流和推流 |
| | | ExecutorService executorService = new ThreadPoolExecutor(1, 1, |
| | | 0L, TimeUnit.MILLISECONDS, |
| | | new LinkedBlockingQueue<Runnable>()); |
| | | executorService.execute(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | JavaCVStreamUtil.push_hls(data.getUrl(), path, id, folderPath); |
| | | } |
| | | }); |
| | | resp.setServerIp(liveIp); |
| | | resp.setServerPort(livePort); |
| | | // live_hls(data.getUrl(), car); |
| | | // resp.setServerIp(hlsIp); |
| | | // resp.setServerPort(hlsPort); |
| | | |
| | | live_flv(data.getUrl(), car.getId()); |
| | | resp.setServerIp(flvIp); |
| | | resp.setServerPort(flvHttpPort); |
| | | return R.ok(resp); |
| | | } |
| | | return R.fail(startupAckVoR.getMsg()); |
| | | } |
| | | |
| | | |
| | | public void live_hls(String input, Car car){ |
| | | String path = hlsOutputPath + "hls\\" + car.getVehicleNumber() + "\\live.m3u8"; |
| | | String folderPath = hlsOutputPath + "hls\\" + car.getVehicleNumber(); |
| | | FileUtil.mkParentDirs(path); |
| | | File file = new File(path); |
| | | if (!file.exists()) { |
| | | try { |
| | | file.createNewFile(); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | |
| | | //执行拉流和推流 |
| | | ExecutorService executorService = new ThreadPoolExecutor(1, 1, |
| | | 0L, TimeUnit.MILLISECONDS, |
| | | new LinkedBlockingQueue<Runnable>()); |
| | | executorService.execute(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | JavaCVStreamUtil.push_hls(input, path, car.getId(), folderPath); |
| | | } |
| | | }); |
| | | carService.taskPlayDetection(car.getId()); |
| | | } |
| | | |
| | | public void live_flv(String input, Integer id){ |
| | | String url = "rtsp://" + flvIp + ":" + flvRtmpPort + "/flv/" + id; |
| | | //执行拉流和推流 |
| | | ExecutorService executorService = new ThreadPoolExecutor(1, 1, |
| | | 0L, TimeUnit.MILLISECONDS, |
| | | new LinkedBlockingQueue<Runnable>()); |
| | | executorService.execute(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | JavaCVStreamUtil.push_flv(input, url, id); |
| | | } |
| | | }); |
| | | carService.taskPlayDetection(id); |
| | | } |
| | | } |