Commit 298a9f4280458062ed0fc32084d5bcce8bbf196c
1 parent
78f628dd
开始重构云端录像
Showing
8 changed files
with
369 additions
and
5 deletions
sql/2.6.9更新.sql
| @@ -6,3 +6,19 @@ alter table wvp_platform | @@ -6,3 +6,19 @@ alter table wvp_platform | ||
| 6 | 6 | ||
| 7 | alter table wvp_stream_proxy | 7 | alter table wvp_stream_proxy |
| 8 | add stream_key varying(255) | 8 | add stream_key varying(255) |
| 9 | + | ||
| 10 | +create table wvp_cloud_record ( | ||
| 11 | + id serial primary key, | ||
| 12 | + app character varying(255), | ||
| 13 | + stream character varying(255), | ||
| 14 | + call_id character varying(255), | ||
| 15 | + start_time integer, | ||
| 16 | + end_time integer, | ||
| 17 | + media_server_id character varying(50), | ||
| 18 | + file_name character varying(50), | ||
| 19 | + folder character varying(50), | ||
| 20 | + file_path character varying(255), | ||
| 21 | + file_size integer, | ||
| 22 | + time_len integer, | ||
| 23 | + constraint uk_stream_push_app_stream_path unique (app, stream, file_path) | ||
| 24 | +); |
sql/初始化.sql
| @@ -266,6 +266,21 @@ create table wvp_stream_push ( | @@ -266,6 +266,21 @@ create table wvp_stream_push ( | ||
| 266 | self bool default false, | 266 | self bool default false, |
| 267 | constraint uk_stream_push_app_stream unique (app, stream) | 267 | constraint uk_stream_push_app_stream unique (app, stream) |
| 268 | ); | 268 | ); |
| 269 | +create table wvp_cloud_record ( | ||
| 270 | + id serial primary key, | ||
| 271 | + app character varying(255), | ||
| 272 | + stream character varying(255), | ||
| 273 | + call_id character varying(255), | ||
| 274 | + start_time integer, | ||
| 275 | + end_time integer, | ||
| 276 | + mediaServerId character varying(50), | ||
| 277 | + file_name character varying(50), | ||
| 278 | + folder character varying(50), | ||
| 279 | + file_path character varying(255), | ||
| 280 | + file_size integer, | ||
| 281 | + time_len integer, | ||
| 282 | + constraint uk_stream_push_app_stream_path unique (app, stream, file_path) | ||
| 283 | +); | ||
| 269 | 284 | ||
| 270 | create table wvp_user ( | 285 | create table wvp_user ( |
| 271 | id serial primary key, | 286 | id serial primary key, |
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
| @@ -766,6 +766,21 @@ public class ZLMHttpHookListener { | @@ -766,6 +766,21 @@ public class ZLMHttpHookListener { | ||
| 766 | return HookResult.SUCCESS(); | 766 | return HookResult.SUCCESS(); |
| 767 | } | 767 | } |
| 768 | 768 | ||
| 769 | + /** | ||
| 770 | + * 录像完成事件 | ||
| 771 | + */ | ||
| 772 | + @ResponseBody | ||
| 773 | + @PostMapping(value = "/on_record_mp4", produces = "application/json;charset=UTF-8") | ||
| 774 | + public HookResult onRecordMp4(HttpServletRequest request, @RequestBody OnRecordMp4HookParam param) { | ||
| 775 | + logger.info("[ZLM HOOK] 录像完成事件:{}->{}", param.getMediaServerId(), param.getFile_path()); | ||
| 776 | + | ||
| 777 | + taskExecutor.execute(() -> { | ||
| 778 | + | ||
| 779 | + }); | ||
| 780 | + | ||
| 781 | + return HookResult.SUCCESS(); | ||
| 782 | + } | ||
| 783 | + | ||
| 769 | private Map<String, String> urlParamToMap(String params) { | 784 | private Map<String, String> urlParamToMap(String params) { |
| 770 | HashMap<String, String> map = new HashMap<>(); | 785 | HashMap<String, String> map = new HashMap<>(); |
| 771 | if (ObjectUtils.isEmpty(params)) { | 786 | if (ObjectUtils.isEmpty(params)) { |
src/main/java/com/genersoft/iot/vmp/media/zlm/dto/hook/OnRecordMp4HookParam.java
0 → 100755
| 1 | +package com.genersoft.iot.vmp.media.zlm.dto.hook; | ||
| 2 | + | ||
| 3 | +/** | ||
| 4 | + * zlm hook事件中的on_rtp_server_timeout事件的参数 | ||
| 5 | + * @author lin | ||
| 6 | + */ | ||
| 7 | +public class OnRecordMp4HookParam extends HookParam{ | ||
| 8 | + private String app; | ||
| 9 | + private String stream; | ||
| 10 | + private String file_name; | ||
| 11 | + private String file_path; | ||
| 12 | + private String file_size; | ||
| 13 | + private String folder; | ||
| 14 | + private String url; | ||
| 15 | + private String vhost; | ||
| 16 | + private long start_time; | ||
| 17 | + private long time_len; | ||
| 18 | + | ||
| 19 | + public String getApp() { | ||
| 20 | + return app; | ||
| 21 | + } | ||
| 22 | + | ||
| 23 | + public void setApp(String app) { | ||
| 24 | + this.app = app; | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + public String getStream() { | ||
| 28 | + return stream; | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + public void setStream(String stream) { | ||
| 32 | + this.stream = stream; | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + public String getFile_name() { | ||
| 36 | + return file_name; | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + public void setFile_name(String file_name) { | ||
| 40 | + this.file_name = file_name; | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + public String getFile_path() { | ||
| 44 | + return file_path; | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + public void setFile_path(String file_path) { | ||
| 48 | + this.file_path = file_path; | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + public String getFile_size() { | ||
| 52 | + return file_size; | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + public void setFile_size(String file_size) { | ||
| 56 | + this.file_size = file_size; | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + public String getFolder() { | ||
| 60 | + return folder; | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + public void setFolder(String folder) { | ||
| 64 | + this.folder = folder; | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | + public String getUrl() { | ||
| 68 | + return url; | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + public void setUrl(String url) { | ||
| 72 | + this.url = url; | ||
| 73 | + } | ||
| 74 | + | ||
| 75 | + public String getVhost() { | ||
| 76 | + return vhost; | ||
| 77 | + } | ||
| 78 | + | ||
| 79 | + public void setVhost(String vhost) { | ||
| 80 | + this.vhost = vhost; | ||
| 81 | + } | ||
| 82 | + | ||
| 83 | + public long getStart_time() { | ||
| 84 | + return start_time; | ||
| 85 | + } | ||
| 86 | + | ||
| 87 | + public void setStart_time(long start_time) { | ||
| 88 | + this.start_time = start_time; | ||
| 89 | + } | ||
| 90 | + | ||
| 91 | + public long getTime_len() { | ||
| 92 | + return time_len; | ||
| 93 | + } | ||
| 94 | + | ||
| 95 | + public void setTime_len(long time_len) { | ||
| 96 | + this.time_len = time_len; | ||
| 97 | + } | ||
| 98 | + | ||
| 99 | + @Override | ||
| 100 | + public String toString() { | ||
| 101 | + return "OnRecordMp4HookParam{" + | ||
| 102 | + "app='" + app + '\'' + | ||
| 103 | + ", stream='" + stream + '\'' + | ||
| 104 | + ", file_name='" + file_name + '\'' + | ||
| 105 | + ", file_path='" + file_path + '\'' + | ||
| 106 | + ", file_size='" + file_size + '\'' + | ||
| 107 | + ", folder='" + folder + '\'' + | ||
| 108 | + ", url='" + url + '\'' + | ||
| 109 | + ", vhost='" + vhost + '\'' + | ||
| 110 | + ", start_time=" + start_time + | ||
| 111 | + ", time_len=" + time_len + | ||
| 112 | + '}'; | ||
| 113 | + } | ||
| 114 | +} |
src/main/java/com/genersoft/iot/vmp/service/ICloudRecordService.java
0 → 100755
| 1 | +package com.genersoft.iot.vmp.service; | ||
| 2 | + | ||
| 3 | +import com.genersoft.iot.vmp.service.bean.CloudRecordItem; | ||
| 4 | +import com.github.pagehelper.PageInfo; | ||
| 5 | + | ||
| 6 | +import java.util.List; | ||
| 7 | + | ||
| 8 | +/** | ||
| 9 | + * 云端录像管理 | ||
| 10 | + * @author lin | ||
| 11 | + */ | ||
| 12 | +public interface ICloudRecordService { | ||
| 13 | + | ||
| 14 | + /** | ||
| 15 | + * 分页回去云端录像列表 | ||
| 16 | + */ | ||
| 17 | + PageInfo<CloudRecordItem> getList(int page, int count, String startTime, String endTime); | ||
| 18 | + | ||
| 19 | + /** | ||
| 20 | + * 获取所有的日期 | ||
| 21 | + */ | ||
| 22 | + List<String> getDateList(Integer year, Integer month, String app, String stream); | ||
| 23 | + | ||
| 24 | + | ||
| 25 | + | ||
| 26 | + | ||
| 27 | +} |
src/main/java/com/genersoft/iot/vmp/service/IStreamPushService.java
src/main/java/com/genersoft/iot/vmp/service/bean/CloudRecordItem.java
0 → 100644
| 1 | +package com.genersoft.iot.vmp.service.bean; | ||
| 2 | + | ||
| 3 | +/** | ||
| 4 | + * 云端录像数据 | ||
| 5 | + */ | ||
| 6 | +public class CloudRecordItem { | ||
| 7 | + /** | ||
| 8 | + * 主键 | ||
| 9 | + */ | ||
| 10 | + private int id; | ||
| 11 | + | ||
| 12 | + /** | ||
| 13 | + * 应用名 | ||
| 14 | + */ | ||
| 15 | + private String app; | ||
| 16 | + | ||
| 17 | + /** | ||
| 18 | + * 流 | ||
| 19 | + */ | ||
| 20 | + private String stream; | ||
| 21 | + | ||
| 22 | + /** | ||
| 23 | + * 健全ID | ||
| 24 | + */ | ||
| 25 | + private String callId; | ||
| 26 | + | ||
| 27 | + /** | ||
| 28 | + * 开始时间 | ||
| 29 | + */ | ||
| 30 | + private long startTime; | ||
| 31 | + | ||
| 32 | + /** | ||
| 33 | + * 结束时间 | ||
| 34 | + */ | ||
| 35 | + private long endTime; | ||
| 36 | + | ||
| 37 | + /** | ||
| 38 | + * ZLM Id | ||
| 39 | + */ | ||
| 40 | + private String mediaServerId; | ||
| 41 | + | ||
| 42 | + /** | ||
| 43 | + * 文件名称 | ||
| 44 | + */ | ||
| 45 | + private String fileName; | ||
| 46 | + | ||
| 47 | + /** | ||
| 48 | + * 文件路径 | ||
| 49 | + */ | ||
| 50 | + private String filePath; | ||
| 51 | + | ||
| 52 | + /** | ||
| 53 | + * 文件夹 | ||
| 54 | + */ | ||
| 55 | + private String folder; | ||
| 56 | + | ||
| 57 | + /** | ||
| 58 | + * 收藏类型,收藏的文件不移除 | ||
| 59 | + */ | ||
| 60 | + private String collectType; | ||
| 61 | + | ||
| 62 | + /** | ||
| 63 | + * 文件大小 | ||
| 64 | + */ | ||
| 65 | + private long fileSize; | ||
| 66 | + | ||
| 67 | + /** | ||
| 68 | + * 文件时长 | ||
| 69 | + */ | ||
| 70 | + private long timeLen; | ||
| 71 | + | ||
| 72 | + public int getId() { | ||
| 73 | + return id; | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + public void setId(int id) { | ||
| 77 | + this.id = id; | ||
| 78 | + } | ||
| 79 | + | ||
| 80 | + public String getApp() { | ||
| 81 | + return app; | ||
| 82 | + } | ||
| 83 | + | ||
| 84 | + public void setApp(String app) { | ||
| 85 | + this.app = app; | ||
| 86 | + } | ||
| 87 | + | ||
| 88 | + public String getStream() { | ||
| 89 | + return stream; | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | + public void setStream(String stream) { | ||
| 93 | + this.stream = stream; | ||
| 94 | + } | ||
| 95 | + | ||
| 96 | + public String getCallId() { | ||
| 97 | + return callId; | ||
| 98 | + } | ||
| 99 | + | ||
| 100 | + public void setCallId(String callId) { | ||
| 101 | + this.callId = callId; | ||
| 102 | + } | ||
| 103 | + | ||
| 104 | + public long getStartTime() { | ||
| 105 | + return startTime; | ||
| 106 | + } | ||
| 107 | + | ||
| 108 | + public void setStartTime(long startTime) { | ||
| 109 | + this.startTime = startTime; | ||
| 110 | + } | ||
| 111 | + | ||
| 112 | + public long getEndTime() { | ||
| 113 | + return endTime; | ||
| 114 | + } | ||
| 115 | + | ||
| 116 | + public void setEndTime(long endTime) { | ||
| 117 | + this.endTime = endTime; | ||
| 118 | + } | ||
| 119 | + | ||
| 120 | + public String getMediaServerId() { | ||
| 121 | + return mediaServerId; | ||
| 122 | + } | ||
| 123 | + | ||
| 124 | + public void setMediaServerId(String mediaServerId) { | ||
| 125 | + this.mediaServerId = mediaServerId; | ||
| 126 | + } | ||
| 127 | + | ||
| 128 | + public String getFileName() { | ||
| 129 | + return fileName; | ||
| 130 | + } | ||
| 131 | + | ||
| 132 | + public void setFileName(String fileName) { | ||
| 133 | + this.fileName = fileName; | ||
| 134 | + } | ||
| 135 | + | ||
| 136 | + public String getFilePath() { | ||
| 137 | + return filePath; | ||
| 138 | + } | ||
| 139 | + | ||
| 140 | + public void setFilePath(String filePath) { | ||
| 141 | + this.filePath = filePath; | ||
| 142 | + } | ||
| 143 | + | ||
| 144 | + public String getFolder() { | ||
| 145 | + return folder; | ||
| 146 | + } | ||
| 147 | + | ||
| 148 | + public void setFolder(String folder) { | ||
| 149 | + this.folder = folder; | ||
| 150 | + } | ||
| 151 | + | ||
| 152 | + public long getFileSize() { | ||
| 153 | + return fileSize; | ||
| 154 | + } | ||
| 155 | + | ||
| 156 | + public void setFileSize(long fileSize) { | ||
| 157 | + this.fileSize = fileSize; | ||
| 158 | + } | ||
| 159 | + | ||
| 160 | + public long getTimeLen() { | ||
| 161 | + return timeLen; | ||
| 162 | + } | ||
| 163 | + | ||
| 164 | + public void setTimeLen(long timeLen) { | ||
| 165 | + this.timeLen = timeLen; | ||
| 166 | + } | ||
| 167 | + | ||
| 168 | + public String getCollectType() { | ||
| 169 | + return collectType; | ||
| 170 | + } | ||
| 171 | + | ||
| 172 | + public void setCollectType(String collectType) { | ||
| 173 | + this.collectType = collectType; | ||
| 174 | + } | ||
| 175 | +} |
src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java
| @@ -587,11 +587,12 @@ public class MediaServerServiceImpl implements IMediaServerService { | @@ -587,11 +587,12 @@ public class MediaServerServiceImpl implements IMediaServerService { | ||
| 587 | param.put("hook.on_server_keepalive",String.format("%s/on_server_keepalive", hookPrex)); | 587 | param.put("hook.on_server_keepalive",String.format("%s/on_server_keepalive", hookPrex)); |
| 588 | param.put("hook.on_send_rtp_stopped",String.format("%s/on_send_rtp_stopped", hookPrex)); | 588 | param.put("hook.on_send_rtp_stopped",String.format("%s/on_send_rtp_stopped", hookPrex)); |
| 589 | param.put("hook.on_rtp_server_timeout",String.format("%s/on_rtp_server_timeout", hookPrex)); | 589 | param.put("hook.on_rtp_server_timeout",String.format("%s/on_rtp_server_timeout", hookPrex)); |
| 590 | - if (mediaServerItem.getRecordAssistPort() > 0) { | ||
| 591 | - param.put("hook.on_record_mp4",String.format("http://127.0.0.1:%s/api/record/on_record_mp4", mediaServerItem.getRecordAssistPort())); | ||
| 592 | - }else { | ||
| 593 | - param.put("hook.on_record_mp4",""); | ||
| 594 | - } | 590 | + param.put("hook.on_record_mp4",String.format("%s/on_record_mp4", hookPrex)); |
| 591 | +// if (mediaServerItem.getRecordAssistPort() > 0) { | ||
| 592 | +// param.put("hook.on_record_mp4",String.format("http://127.0.0.1:%s/api/record/on_record_mp4", mediaServerItem.getRecordAssistPort())); | ||
| 593 | +// }else { | ||
| 594 | +// param.put("hook.on_record_mp4",""); | ||
| 595 | +// } | ||
| 595 | param.put("hook.timeoutSec","20"); | 596 | param.put("hook.timeoutSec","20"); |
| 596 | // 推流断开后可以在超时时间内重新连接上继续推流,这样播放器会接着播放。 | 597 | // 推流断开后可以在超时时间内重新连接上继续推流,这样播放器会接着播放。 |
| 597 | // 置0关闭此特性(推流断开会导致立即断开播放器) | 598 | // 置0关闭此特性(推流断开会导致立即断开播放器) |