From 153b905185b40182978758d409accbb76f678cb1 Mon Sep 17 00:00:00 2001
From: Pu Zhibing <393733352@qq.com>
Date: 星期四, 10 四月 2025 20:42:13 +0800
Subject: [PATCH] 修改视频直播方式为http-flv

---
 ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/OrderController.java |   93 ++++++++++++++++++++++++++++++++--------------
 1 files changed, 64 insertions(+), 29 deletions(-)

diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/OrderController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/OrderController.java
index 1c062f0..514a5a1 100644
--- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/OrderController.java
+++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/OrderController.java
@@ -75,14 +75,23 @@
 	@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")
@@ -187,32 +196,58 @@
 		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);
+	}
 }

--
Gitblit v1.7.1