|
|
@@ -1,13 +1,23 @@
|
|
|
package com.middle.platform.stream.biz.service.impl;
|
|
|
|
|
|
+import com.github.pagehelper.PageInfo;
|
|
|
+import com.middle.platform.stream.biz.domain.res.RecordPageRes;
|
|
|
+import com.middle.platform.stream.biz.pojo.RecordPage;
|
|
|
+import com.middle.platform.stream.biz.pojo.RecordPageFiles;
|
|
|
import com.middle.platform.stream.biz.pojo.StreamRecordPage;
|
|
|
+import com.middle.platform.stream.biz.properties.StreamMediaProperties;
|
|
|
import com.middle.platform.stream.biz.service.ApiProxy;
|
|
|
import com.middle.platform.stream.biz.service.StreamMediaService;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
+import java.time.Instant;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.ZoneOffset;
|
|
|
+import java.util.List;
|
|
|
+import java.util.regex.Matcher;
|
|
|
+import java.util.regex.Pattern;
|
|
|
|
|
|
/**
|
|
|
* @author xucaiqin
|
|
|
@@ -19,19 +29,55 @@ import java.util.ArrayList;
|
|
|
public class StreamMediaServiceImpl implements StreamMediaService {
|
|
|
private final ApiProxy apiProxy;
|
|
|
|
|
|
+ private final StreamMediaProperties streamMediaProperties;
|
|
|
|
|
|
@Override
|
|
|
- public ArrayList<Object> recordPage(StreamRecordPage streamRecordPage) {
|
|
|
+ public Object recordPage(StreamRecordPage streamRecordPage) {
|
|
|
log.info("recordPage in...");
|
|
|
+ PageInfo<RecordPageRes> pageInfo = new PageInfo<>();
|
|
|
//API调用
|
|
|
- Object o = apiProxy.recordListPage("mp4", streamRecordPage.getPage(), streamRecordPage.getPageSize(), streamRecordPage.getPath());
|
|
|
- log.info("rtmpList:{}", o);
|
|
|
- return new ArrayList<>() {{
|
|
|
- add(o);
|
|
|
- }};
|
|
|
+ RecordPage recordPage = apiProxy.recordListPage("mp4", streamRecordPage.getPage(), streamRecordPage.getPageSize(), streamRecordPage.getPath());
|
|
|
+ log.info("recordPage:{}", recordPage);
|
|
|
+ pageInfo.setPageSize(streamRecordPage.getPageSize());
|
|
|
+ pageInfo.setPages(streamRecordPage.getPage());
|
|
|
+ pageInfo.setTotal(recordPage.getTotalCount());
|
|
|
+ List<RecordPageRes> recordPageResList = new java.util.ArrayList<>();
|
|
|
+ // 匹配字符串中的时间戳
|
|
|
+ Pattern pattern = Pattern.compile("\\d+\\.mp4$");
|
|
|
+ for (RecordPageFiles recordPageFiles : recordPage.getFiles()) {
|
|
|
+ Matcher matcher = pattern.matcher(recordPageFiles.getPath());
|
|
|
+ // 提取时间戳字符串
|
|
|
+ String timestampStr = "";
|
|
|
+ if (matcher.find()) {
|
|
|
+ timestampStr = matcher.group().replace(".mp4", "");
|
|
|
+ }
|
|
|
+ // 转换为LocalDateTime格式
|
|
|
+ LocalDateTime dateTime = LocalDateTime.ofInstant(Instant.ofEpochSecond(Long.parseLong(timestampStr)), ZoneOffset.UTC);
|
|
|
+ recordPageResList.add(new RecordPageRes(recordPageFiles.getPath(), recordPageFiles.getSize(), dateTime));
|
|
|
+ }
|
|
|
+ pageInfo.setList(recordPageResList);
|
|
|
+ return pageInfo;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取回放播放信息
|
|
|
+ * @author Aick Spt
|
|
|
+ * @date 2024-05-09 11:35
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Object getRecordVideoUrl(String path) {
|
|
|
|
|
|
+ return streamMediaProperties.getUrl() + path;
|
|
|
+ }
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取回放视频下载地址
|
|
|
+ * @author Aick Spt
|
|
|
+ * @date 2024-05-09 11:37
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Object getDownLoadUrl(String path) {
|
|
|
|
|
|
+ return streamMediaProperties.getUrl() + path;
|
|
|
+ }
|
|
|
}
|