From 298a9f4280458062ed0fc32084d5bcce8bbf196c Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期四, 12 十月 2023 18:34:16 +0800
Subject: [PATCH] 开始重构云端录像

---
 src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java           |   15 ++
 src/main/java/com/genersoft/iot/vmp/service/ICloudRecordService.java             |   27 +++
 src/main/java/com/genersoft/iot/vmp/service/bean/CloudRecordItem.java            |  175 +++++++++++++++++++++++++
 sql/初始化.sql                                                                      |   15 ++
 src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java     |   11 
 sql/2.6.9更新.sql                                                                  |   16 ++
 src/main/java/com/genersoft/iot/vmp/media/zlm/dto/hook/OnRecordMp4HookParam.java |  114 ++++++++++++++++
 src/main/java/com/genersoft/iot/vmp/service/IStreamPushService.java              |    1 
 8 files changed, 369 insertions(+), 5 deletions(-)

diff --git "a/sql/2.6.9\346\233\264\346\226\260.sql" "b/sql/2.6.9\346\233\264\346\226\260.sql"
index 769004d..cb117b6 100644
--- "a/sql/2.6.9\346\233\264\346\226\260.sql"
+++ "b/sql/2.6.9\346\233\264\346\226\260.sql"
@@ -6,3 +6,19 @@
 
 alter table wvp_stream_proxy
     add stream_key varying(255)
+
+create table wvp_cloud_record (
+                                 id serial primary key,
+                                 app character varying(255),
+                                 stream character varying(255),
+                                 call_id character varying(255),
+                                 start_time integer,
+                                 end_time integer,
+                                 media_server_id character varying(50),
+                                 file_name character varying(50),
+                                 folder character varying(50),
+                                 file_path character varying(255),
+                                 file_size integer,
+                                 time_len integer,
+                                 constraint uk_stream_push_app_stream_path unique (app, stream, file_path)
+);
diff --git "a/sql/\345\210\235\345\247\213\345\214\226.sql" "b/sql/\345\210\235\345\247\213\345\214\226.sql"
index b95dd87..9fcbe36 100644
--- "a/sql/\345\210\235\345\247\213\345\214\226.sql"
+++ "b/sql/\345\210\235\345\247\213\345\214\226.sql"
@@ -266,6 +266,21 @@
                                  self bool default false,
                                  constraint uk_stream_push_app_stream unique (app, stream)
 );
+create table wvp_cloud_record (
+                                        id serial primary key,
+                                        app character varying(255),
+                                        stream character varying(255),
+                                        call_id character varying(255),
+                                        start_time integer,
+                                        end_time integer,
+                                        mediaServerId character varying(50),
+                                        file_name character varying(50),
+                                        folder character varying(50),
+                                        file_path character varying(255),
+                                        file_size integer,
+                                        time_len integer,
+                                        constraint uk_stream_push_app_stream_path unique (app, stream, file_path)
+);
 
 create table wvp_user (
                           id serial primary key,
diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
index 3c76883..3ad7b70 100755
--- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
+++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
@@ -766,6 +766,21 @@
         return HookResult.SUCCESS();
     }
 
+    /**
+     * 褰曞儚瀹屾垚浜嬩欢
+     */
+    @ResponseBody
+    @PostMapping(value = "/on_record_mp4", produces = "application/json;charset=UTF-8")
+    public HookResult onRecordMp4(HttpServletRequest request, @RequestBody OnRecordMp4HookParam param) {
+        logger.info("[ZLM HOOK] 褰曞儚瀹屾垚浜嬩欢锛歿}->{}", param.getMediaServerId(), param.getFile_path());
+
+        taskExecutor.execute(() -> {
+
+        });
+
+        return HookResult.SUCCESS();
+    }
+
     private Map<String, String> urlParamToMap(String params) {
         HashMap<String, String> map = new HashMap<>();
         if (ObjectUtils.isEmpty(params)) {
diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/hook/OnRecordMp4HookParam.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/hook/OnRecordMp4HookParam.java
new file mode 100755
index 0000000..92bca40
--- /dev/null
+++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/hook/OnRecordMp4HookParam.java
@@ -0,0 +1,114 @@
+package com.genersoft.iot.vmp.media.zlm.dto.hook;
+
+/**
+ * zlm hook浜嬩欢涓殑on_rtp_server_timeout浜嬩欢鐨勫弬鏁�
+ * @author lin
+ */
+public class OnRecordMp4HookParam extends HookParam{
+    private String app;
+    private String stream;
+    private String file_name;
+    private String file_path;
+    private String file_size;
+    private String folder;
+    private String url;
+    private String vhost;
+    private long start_time;
+    private long time_len;
+
+    public String getApp() {
+        return app;
+    }
+
+    public void setApp(String app) {
+        this.app = app;
+    }
+
+    public String getStream() {
+        return stream;
+    }
+
+    public void setStream(String stream) {
+        this.stream = stream;
+    }
+
+    public String getFile_name() {
+        return file_name;
+    }
+
+    public void setFile_name(String file_name) {
+        this.file_name = file_name;
+    }
+
+    public String getFile_path() {
+        return file_path;
+    }
+
+    public void setFile_path(String file_path) {
+        this.file_path = file_path;
+    }
+
+    public String getFile_size() {
+        return file_size;
+    }
+
+    public void setFile_size(String file_size) {
+        this.file_size = file_size;
+    }
+
+    public String getFolder() {
+        return folder;
+    }
+
+    public void setFolder(String folder) {
+        this.folder = folder;
+    }
+
+    public String getUrl() {
+        return url;
+    }
+
+    public void setUrl(String url) {
+        this.url = url;
+    }
+
+    public String getVhost() {
+        return vhost;
+    }
+
+    public void setVhost(String vhost) {
+        this.vhost = vhost;
+    }
+
+    public long getStart_time() {
+        return start_time;
+    }
+
+    public void setStart_time(long start_time) {
+        this.start_time = start_time;
+    }
+
+    public long getTime_len() {
+        return time_len;
+    }
+
+    public void setTime_len(long time_len) {
+        this.time_len = time_len;
+    }
+
+    @Override
+    public String toString() {
+        return "OnRecordMp4HookParam{" +
+                "app='" + app + '\'' +
+                ", stream='" + stream + '\'' +
+                ", file_name='" + file_name + '\'' +
+                ", file_path='" + file_path + '\'' +
+                ", file_size='" + file_size + '\'' +
+                ", folder='" + folder + '\'' +
+                ", url='" + url + '\'' +
+                ", vhost='" + vhost + '\'' +
+                ", start_time=" + start_time +
+                ", time_len=" + time_len +
+                '}';
+    }
+}
diff --git a/src/main/java/com/genersoft/iot/vmp/service/ICloudRecordService.java b/src/main/java/com/genersoft/iot/vmp/service/ICloudRecordService.java
new file mode 100755
index 0000000..3c8b9be
--- /dev/null
+++ b/src/main/java/com/genersoft/iot/vmp/service/ICloudRecordService.java
@@ -0,0 +1,27 @@
+package com.genersoft.iot.vmp.service;
+
+import com.genersoft.iot.vmp.service.bean.CloudRecordItem;
+import com.github.pagehelper.PageInfo;
+
+import java.util.List;
+
+/**
+ * 浜戠褰曞儚绠$悊
+ * @author lin
+ */
+public interface ICloudRecordService {
+
+    /**
+     * 鍒嗛〉鍥炲幓浜戠褰曞儚鍒楄〃
+     */
+    PageInfo<CloudRecordItem> getList(int page, int count, String startTime, String endTime);
+
+    /**
+     * 鑾峰彇鎵�鏈夌殑鏃ユ湡
+     */
+    List<String> getDateList(Integer year, Integer month, String app, String stream);
+
+
+
+
+}
diff --git a/src/main/java/com/genersoft/iot/vmp/service/IStreamPushService.java b/src/main/java/com/genersoft/iot/vmp/service/IStreamPushService.java
index 8d92002..333b7b3 100755
--- a/src/main/java/com/genersoft/iot/vmp/service/IStreamPushService.java
+++ b/src/main/java/com/genersoft/iot/vmp/service/IStreamPushService.java
@@ -114,4 +114,5 @@
      * @return
      */
     ResourceBaseInfo getOverview();
+
 }
diff --git a/src/main/java/com/genersoft/iot/vmp/service/bean/CloudRecordItem.java b/src/main/java/com/genersoft/iot/vmp/service/bean/CloudRecordItem.java
new file mode 100644
index 0000000..b374c13
--- /dev/null
+++ b/src/main/java/com/genersoft/iot/vmp/service/bean/CloudRecordItem.java
@@ -0,0 +1,175 @@
+package com.genersoft.iot.vmp.service.bean;
+
+/**
+ * 浜戠褰曞儚鏁版嵁
+ */
+public class CloudRecordItem {
+    /**
+     * 涓婚敭
+     */
+    private int id;
+    
+    /**
+     * 搴旂敤鍚�
+     */
+    private String app;
+    
+    /**
+     * 娴�
+     */
+    private String stream;
+    
+    /**
+     * 鍋ュ叏ID
+     */
+    private String callId;
+    
+    /**
+     * 寮�濮嬫椂闂�
+     */
+    private long startTime;
+    
+    /**
+     * 缁撴潫鏃堕棿
+     */
+    private long endTime;
+    
+    /**
+     * ZLM Id
+     */
+    private String mediaServerId;
+    
+    /**
+     * 鏂囦欢鍚嶇О
+     */
+    private String fileName;
+    
+    /**
+     * 鏂囦欢璺緞
+     */
+    private String filePath;
+    
+    /**
+     * 鏂囦欢澶�
+     */
+    private String folder;
+    
+    /**
+     * 鏀惰棌绫诲瀷锛屾敹钘忕殑鏂囦欢涓嶇Щ闄�
+     */
+    private String collectType;
+    
+    /**
+     * 鏂囦欢澶у皬
+     */
+    private long fileSize;
+    
+    /**
+     * 鏂囦欢鏃堕暱
+     */
+    private long timeLen;
+
+    public int getId() {
+        return id;
+    }
+
+    public void setId(int id) {
+        this.id = id;
+    }
+
+    public String getApp() {
+        return app;
+    }
+
+    public void setApp(String app) {
+        this.app = app;
+    }
+
+    public String getStream() {
+        return stream;
+    }
+
+    public void setStream(String stream) {
+        this.stream = stream;
+    }
+
+    public String getCallId() {
+        return callId;
+    }
+
+    public void setCallId(String callId) {
+        this.callId = callId;
+    }
+
+    public long getStartTime() {
+        return startTime;
+    }
+
+    public void setStartTime(long startTime) {
+        this.startTime = startTime;
+    }
+
+    public long getEndTime() {
+        return endTime;
+    }
+
+    public void setEndTime(long endTime) {
+        this.endTime = endTime;
+    }
+
+    public String getMediaServerId() {
+        return mediaServerId;
+    }
+
+    public void setMediaServerId(String mediaServerId) {
+        this.mediaServerId = mediaServerId;
+    }
+
+    public String getFileName() {
+        return fileName;
+    }
+
+    public void setFileName(String fileName) {
+        this.fileName = fileName;
+    }
+
+    public String getFilePath() {
+        return filePath;
+    }
+
+    public void setFilePath(String filePath) {
+        this.filePath = filePath;
+    }
+
+    public String getFolder() {
+        return folder;
+    }
+
+    public void setFolder(String folder) {
+        this.folder = folder;
+    }
+
+    public long getFileSize() {
+        return fileSize;
+    }
+
+    public void setFileSize(long fileSize) {
+        this.fileSize = fileSize;
+    }
+
+    public long getTimeLen() {
+        return timeLen;
+    }
+
+    public void setTimeLen(long timeLen) {
+        this.timeLen = timeLen;
+    }
+
+    public String getCollectType() {
+        return collectType;
+    }
+
+    public void setCollectType(String collectType) {
+        this.collectType = collectType;
+    }
+}
diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java
index 6bbb4bc..4c149d4 100755
--- a/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java
+++ b/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java
@@ -587,11 +587,12 @@
         param.put("hook.on_server_keepalive",String.format("%s/on_server_keepalive", hookPrex));
         param.put("hook.on_send_rtp_stopped",String.format("%s/on_send_rtp_stopped", hookPrex));
         param.put("hook.on_rtp_server_timeout",String.format("%s/on_rtp_server_timeout", hookPrex));
-        if (mediaServerItem.getRecordAssistPort() > 0) {
-            param.put("hook.on_record_mp4",String.format("http://127.0.0.1:%s/api/record/on_record_mp4", mediaServerItem.getRecordAssistPort()));
-        }else {
-            param.put("hook.on_record_mp4","");
-        }
+        param.put("hook.on_record_mp4",String.format("%s/on_record_mp4", hookPrex));
+//        if (mediaServerItem.getRecordAssistPort() > 0) {
+//            param.put("hook.on_record_mp4",String.format("http://127.0.0.1:%s/api/record/on_record_mp4", mediaServerItem.getRecordAssistPort()));
+//        }else {
+//            param.put("hook.on_record_mp4","");
+//        }
         param.put("hook.timeoutSec","20");
         // 鎺ㄦ祦鏂紑鍚庡彲浠ュ湪瓒呮椂鏃堕棿鍐呴噸鏂拌繛鎺ヤ笂缁х画鎺ㄦ祦锛岃繖鏍锋挱鏀惧櫒浼氭帴鐫�鎾斁銆�
         // 缃�0鍏抽棴姝ょ壒鎬�(鎺ㄦ祦鏂紑浼氬鑷寸珛鍗虫柇寮�鎾斁鍣�)

--
Gitblit v1.8.0