diff --git a/springboot/fastbee-open-api/src/main/java/com/fastbee/data/controller/media/RecordController.java b/springboot/fastbee-open-api/src/main/java/com/fastbee/data/controller/media/RecordController.java deleted file mode 100644 index ba5586a4..00000000 --- a/springboot/fastbee-open-api/src/main/java/com/fastbee/data/controller/media/RecordController.java +++ /dev/null @@ -1,155 +0,0 @@ -package com.fastbee.data.controller.media; - -import com.fastbee.common.core.controller.BaseController; -import com.fastbee.common.core.domain.AjaxResult; -import com.fastbee.sip.model.RecordList; -import com.fastbee.sip.service.IRecordService; -import com.fastbee.sip.util.WebAsyncUtil; -import com.fastbee.sip.util.result.BaseResult; -import com.fastbee.sip.util.result.CodeEnum; -import com.fastbee.sip.util.result.DataResult; -import io.swagger.annotations.ApiOperation; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.web.bind.annotation.*; -import org.springframework.web.context.request.async.WebAsyncTask; - -@Slf4j -@RestController -@RequestMapping("/sip/record") -public class RecordController extends BaseController { - - @Autowired - private IRecordService recordService; - - @Qualifier("taskExecutor") - @Autowired - private ThreadPoolTaskExecutor taskExecutor; - @ApiOperation("设备录像查询") - @PreAuthorize("@ss.hasPermi('iot:video:list')") - @GetMapping("/devquery/{deviceId}/{channelId}") - public WebAsyncTask devquery(@PathVariable String deviceId, - @PathVariable String channelId, String start, String end) { - return WebAsyncUtil.init(taskExecutor, () -> { - try { - RecordList result = recordService.listDevRecord(deviceId, channelId, start, end); - return DataResult.out(CodeEnum.SUCCESS, result); - } catch (Exception e) { - log.error("", e); - return BaseResult.out(CodeEnum.FAIL, e.getMessage()); - } - }); - } - @ApiOperation("设备录像缓存查询") - @PreAuthorize("@ss.hasPermi('iot:video:list')") - @GetMapping("/query/{channelId}/{sn}") - public AjaxResult list(@PathVariable String channelId, - @PathVariable String sn) { - return AjaxResult.success("success!", recordService.listRecord(channelId, sn)); - } - - @ApiOperation("指定流ID开始录像") - @PreAuthorize("@ss.hasPermi('iot:video:list')") - @GetMapping("/start/{stream}") - public AjaxResult startRecord(@PathVariable String stream) { - boolean result = recordService.startRecord(stream); - if (result) { - return AjaxResult.success("success!"); - } else { - return AjaxResult.error("error!"); - } - } - - @ApiOperation("指定流ID停止录像") - @PreAuthorize("@ss.hasPermi('iot:video:list')") - @GetMapping("/stop/{stream}") - public AjaxResult stopRecord(@PathVariable String stream) { - boolean result = recordService.stopRecord(stream); - if (result) { - return AjaxResult.success("success!"); - } else { - return AjaxResult.error("error!"); - } - } - - @ApiOperation("获取流对应的录像文件列表") - @PreAuthorize("@ss.hasPermi('iot:video:list')") - @GetMapping("/file/{stream}/{period}") - public AjaxResult getMp4RecordFile(@PathVariable String stream, - @PathVariable String period) { - return AjaxResult.success("success!", recordService.getMp4RecordFile(stream, period)); - } - - @ApiOperation("直播录像") - @GetMapping("/play/{deviceId}/{channelId}") - public AjaxResult playRecord(@PathVariable String deviceId, @PathVariable String channelId) { - logger.debug(String.format("直播录像 API调用,deviceId:%s,channelId:%s", deviceId, channelId)); - return AjaxResult.success("success!", recordService.playRecord(deviceId, channelId)); - } - - @PreAuthorize("@ss.hasPermi('iot:sip:record:download')") - @ApiOperation("设备录像下载") - @GetMapping("/download/{deviceId}/{channelId}") - public AjaxResult download(@PathVariable String deviceId, @PathVariable String channelId, - String startTime, String endTime, String speed) { - logger.debug(String.format("设备录像下载 API调用,deviceId:%s,channelId:%s,downloadSpeed:%s", deviceId, channelId, speed)); - return AjaxResult.success("success!", recordService.download(deviceId, channelId, startTime, endTime, Integer.parseInt(speed))); - } - - - - @ApiOperation("查询服务端录像列表") - @PreAuthorize("@ss.hasPermi('iot:sip:record:list')") - @GetMapping("/serverRecord/list") - public AjaxResult listServerRecord(@RequestParam Integer pageNum, - @RequestParam Integer pageSize, @RequestParam String recordApi) { - try{ - Object data = recordService.listServerRecord(recordApi, pageNum, pageSize); - return AjaxResult.success("success!", data); - }catch(Exception e){ - return AjaxResult.error("连接超时或发生错误,未获取到数据!"); - } - } - @ApiOperation("通过日期查询服务端录像列表") - @PreAuthorize("@ss.hasPermi('iot:sip:record:list')") - @GetMapping("/serverRecord/date/list") - public AjaxResult listServerRecordByDate(@RequestParam(required = false) Integer year, - @RequestParam(required = false) Integer month, @RequestParam String app, @RequestParam String stream, @RequestParam String recordApi) { - return AjaxResult.success("success!", recordService.listServerRecordByDate(recordApi, year, month, app, stream)); - } - @ApiOperation("通过流ID查询服务端录像列表") - @PreAuthorize("@ss.hasPermi('iot:sip:record:list')") - @GetMapping("/serverRecord/stream/list") - public AjaxResult listServerRecordByStream(@RequestParam Integer pageNum, - @RequestParam Integer pageSize, @RequestParam String app, @RequestParam String recordApi) { - return AjaxResult.success("success!", recordService.listServerRecordByStream(recordApi, pageNum, pageSize, app)); - } - @ApiOperation("通过应用名查询服务端录像列表") - @PreAuthorize("@ss.hasPermi('iot:sip:record:list')") - @GetMapping("/serverRecord/app/list") - public AjaxResult listServerRecordByApp(@RequestParam Integer pageNum, - @RequestParam Integer pageSize, @RequestParam String recordApi) { - return AjaxResult.success("success!", recordService.listServerRecordByApp(recordApi, pageNum, pageSize)); - } - @ApiOperation("通过文件名查询服务端录像列表") - @PreAuthorize("@ss.hasPermi('iot:sip:record:list')") - @GetMapping("/serverRecord/file/list") - public AjaxResult listServerRecordByFile(@RequestParam Integer pageNum, @RequestParam Integer pageSize, - @RequestParam String app, @RequestParam String stream, - @RequestParam String startTime, @RequestParam String endTime, @RequestParam String recordApi) { - return AjaxResult.success("success!", recordService.listServerRecordByFile(recordApi, pageNum, pageSize, app, stream, startTime, endTime)); - } - - @ApiOperation("通过设备信息查询服务端录像列表") - @PreAuthorize("@ss.hasPermi('iot:sip:record:list')") - @GetMapping("/serverRecord/device/list") - public AjaxResult getServerRecordByDevice(@RequestParam Integer pageNum, @RequestParam Integer pageSize, - @RequestParam String deviceId, @RequestParam String channelId, - @RequestParam String startTime, @RequestParam String endTime) { - return AjaxResult.success("success!", recordService.listServerRecordByDevice(pageNum, pageSize, deviceId, channelId, startTime, endTime)); - } - -} diff --git a/springboot/fastbee-server/sip-server/src/main/java/com/fastbee/sip/handler/req/message/response/cmdType/RecordInfoHandler.java b/springboot/fastbee-server/sip-server/src/main/java/com/fastbee/sip/handler/req/message/response/cmdType/RecordInfoHandler.java deleted file mode 100644 index 55778c4d..00000000 --- a/springboot/fastbee-server/sip-server/src/main/java/com/fastbee/sip/handler/req/message/response/cmdType/RecordInfoHandler.java +++ /dev/null @@ -1,93 +0,0 @@ -package com.fastbee.sip.handler.req.message.response.cmdType; - -import com.fastbee.sip.domain.SipDevice; -import com.fastbee.sip.handler.req.ReqAbstractHandler; -import com.fastbee.sip.handler.req.message.IMessageHandler; -import com.fastbee.sip.handler.req.message.response.ResponseMessageHandler; -import com.fastbee.sip.model.RecordItem; -import com.fastbee.sip.model.RecordList; -import com.fastbee.sip.server.RecordCacheManager; -import com.fastbee.sip.service.ISipCacheService; -import com.fastbee.sip.util.SipUtil; -import com.fastbee.sip.util.XmlUtil; -import lombok.extern.slf4j.Slf4j; -import org.dom4j.DocumentException; -import org.dom4j.Element; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import javax.sip.InvalidArgumentException; -import javax.sip.RequestEvent; -import javax.sip.SipException; -import java.text.ParseException; -import java.util.Iterator; -import java.util.concurrent.locks.ReentrantLock; -@Slf4j -@Component -public class RecordInfoHandler extends ReqAbstractHandler implements InitializingBean, IMessageHandler { - - @Autowired - private ResponseMessageHandler responseMessageHandler; - - @Autowired - private ISipCacheService sipCacheService; - - @Autowired - private RecordCacheManager recordCacheManager; - @Override - public void handlerCmdType(RequestEvent evt, SipDevice device, Element element) { - try { - // 回复200 OK - responseAck(evt); - Element rootElement = getRootElement(evt); - String deviceId = rootElement.element("DeviceID").getText(); - String sn = XmlUtil.getText(rootElement, "SN"); - String sumNum = XmlUtil.getText(rootElement, "SumNum"); - String recordkey = deviceId + ":" + sn; - int recordnum = 0; - RecordList recordList = recordCacheManager.get(recordkey); - recordList.setDeviceID(deviceId); - Element recordListElement = rootElement.element("RecordList"); - if (recordListElement == null || sumNum == null || sumNum.equals("")) { - log.info("无录像数据"); - } else { - Iterator recordListIterator = recordListElement.elementIterator(); - if (recordListIterator != null) { - while (recordListIterator.hasNext()) { - Element itemRecord = recordListIterator.next(); - Element recordElement = itemRecord.element("DeviceID"); - if (recordElement == null) { - continue; - } - RecordItem item = new RecordItem(); - item.setStart(SipUtil.ISO8601Totimestamp(XmlUtil.getText(itemRecord, "StartTime"))); - item.setEnd(SipUtil.ISO8601Totimestamp(XmlUtil.getText(itemRecord, "EndTime"))); - recordList.addItem(item); - recordnum++; - } - } - } - log.info("getSumNum:{}", recordList.getSumNum()); - if (recordList.getSumNum() + recordnum == Integer.parseInt(sumNum)) { - //时间合并 保存到redia - recordList.mergeItems(); - log.info("mergeItems recordList:{}", recordList); - recordCacheManager.remove(recordkey); - sipCacheService.setRecordList(recordkey, recordList); - //发布设备property到emqx - } else { - recordList.setSumNum(recordList.getSumNum() + recordnum); - recordCacheManager.put(recordkey, recordList); - } - } catch (DocumentException | SipException | InvalidArgumentException | ParseException e) { - e.printStackTrace(); - } - } - - @Override - public void afterPropertiesSet() throws Exception { - String cmdType = "RecordInfo"; - responseMessageHandler.addHandler(cmdType, this); - } -} diff --git a/springboot/fastbee-server/sip-server/src/main/java/com/fastbee/sip/server/RecordCacheManager.java b/springboot/fastbee-server/sip-server/src/main/java/com/fastbee/sip/server/RecordCacheManager.java deleted file mode 100644 index 9f1e9870..00000000 --- a/springboot/fastbee-server/sip-server/src/main/java/com/fastbee/sip/server/RecordCacheManager.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.fastbee.sip.server; - -import com.fastbee.sip.model.RecordList; -import org.springframework.stereotype.Component; - -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.locks.ReentrantLock; - -@Component -public class RecordCacheManager { - private final ConcurrentHashMap recordMap = new ConcurrentHashMap<>(); - private final ConcurrentHashMap lockMap = new ConcurrentHashMap<>(); - - public void put(String key,RecordList list){ - recordMap.putIfAbsent(key, list); - } - - public RecordList get(String key){ - RecordList ret = recordMap.get(key); - if (ret == null) { - ret = new RecordList(); - recordMap.putIfAbsent(key, ret); - } - return ret; - } - - public void remove(String key) { - recordMap.remove(key); - lockMap.remove(key); - } - - public void addlock(String key){ - lockMap.put(key,new ReentrantLock()); - } - - public ReentrantLock getlock(String key){ - return lockMap.get(key); - } - - -} diff --git a/springboot/fastbee-server/sip-server/src/main/java/com/fastbee/sip/service/IRecordService.java b/springboot/fastbee-server/sip-server/src/main/java/com/fastbee/sip/service/IRecordService.java deleted file mode 100644 index 3c5182e4..00000000 --- a/springboot/fastbee-server/sip-server/src/main/java/com/fastbee/sip/service/IRecordService.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.fastbee.sip.service; - -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import com.fastbee.sip.model.RecordItem; -import com.fastbee.sip.model.RecordList; -import com.fastbee.sip.model.Stream; -import org.springframework.web.bind.annotation.RequestParam; - -import java.util.List; - -public interface IRecordService { - RecordList listDevRecord(String deviceId, String channelId, String startTime, String endTime); - List listRecord(String channelId, String sn); - - JSONObject listServerRecord(String recordApi, Integer pageNum, Integer pageSize); - JSONArray listServerRecordByDate(String recordApi, Integer year, Integer month, String app, String stream); - JSONObject listServerRecordByStream(String recordApi, Integer pageNum, Integer pageSize, String app); - JSONObject listServerRecordByApp(String recordApi, Integer pageNum, Integer pageSize); - JSONObject listServerRecordByFile(String recordApi, Integer pageNum, Integer pageSize, String app, String stream, String startTime, String endTime); - JSONObject listServerRecordByDevice(Integer pageNum, Integer pageSize, String deviceId, String channelId, String startTime, String endTime); - boolean startRecord(String stream); - boolean stopRecord(String stream); - boolean isRecording(String stream); - JSONObject getMp4RecordFile(String stream,String period); - Stream download(String deviceId, String channelId, - String startTime, String endTime, int downloadSpeed); - - Stream playRecord(String deviceId, String channelId); -} diff --git a/springboot/fastbee-server/sip-server/src/main/java/com/fastbee/sip/service/impl/RecordServiceImpl.java b/springboot/fastbee-server/sip-server/src/main/java/com/fastbee/sip/service/impl/RecordServiceImpl.java deleted file mode 100644 index ccb8e062..00000000 --- a/springboot/fastbee-server/sip-server/src/main/java/com/fastbee/sip/service/impl/RecordServiceImpl.java +++ /dev/null @@ -1,192 +0,0 @@ -package com.fastbee.sip.service.impl; - -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import com.fastbee.common.core.domain.entity.SysUser; -import com.fastbee.common.core.redis.RedisCache; -import com.fastbee.common.core.redis.RedisKeyBuilder; -import com.fastbee.sip.domain.MediaServer; -import com.fastbee.sip.domain.SipDevice; -import com.fastbee.sip.model.RecordItem; -import com.fastbee.sip.model.RecordList; -import com.fastbee.sip.model.Stream; -import com.fastbee.sip.model.VideoSessionInfo; -import com.fastbee.sip.server.ISipCmd; -import com.fastbee.sip.server.MessageInvoker; -import com.fastbee.sip.server.RecordCacheManager; -import com.fastbee.sip.service.*; -import com.fastbee.sip.util.RecordApiUtils; -import com.fastbee.sip.util.SipUtil; -import com.fastbee.sip.util.ZlmApiUtils; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.Comparator; -import java.util.List; -import java.util.Objects; - -import static com.fastbee.common.utils.SecurityUtils.getLoginUser; - -@Slf4j -@Service -public class RecordServiceImpl implements IRecordService { - - @Autowired - private MessageInvoker messageInvoker; - - @Autowired - private RedisCache redisCache; - - @Autowired - private RecordCacheManager recordCacheManager; - - @Autowired - private ISipDeviceService sipDeviceService; - - @Autowired - private IMediaServerService mediaServerService; - - @Autowired - private IZmlHookService zmlHookService; - - @Autowired - private ZlmApiUtils zlmApiUtils; - - @Autowired - private RecordApiUtils recordApiUtils; - - @Autowired - private ISipCmd sipCmd; - - @Autowired - private IPlayService playService; - - - @Override - public RecordList listDevRecord(String deviceId, String channelId, String start, String end) { - SipDevice dev = sipDeviceService.selectSipDeviceBySipId(deviceId); - if (dev != null) { - String sn = String.valueOf((int) ((Math.random() * 9 + 1) * 100000)); - String recordkey = channelId + ":" + sn; - recordCacheManager.addlock(recordkey); - messageInvoker.recordInfoQuery(dev, sn, channelId, SipUtil.timestampToDate(start), SipUtil.timestampToDate(end)); - String catchkey = RedisKeyBuilder.buildSipRecordinfoCacheKey(recordkey); - return (RecordList) messageInvoker.getExecResult(catchkey, SipUtil.DEFAULT_EXEC_TIMEOUT); - } - return null; - } - - @Override - public List listRecord(String channelId, String sn) { - String recordkey = channelId + ":" + sn; - String catchkey = RedisKeyBuilder.buildSipRecordinfoCacheKey(recordkey); - List items = redisCache.getCacheList(catchkey); - if (items.size() > 1) { - items.sort(Comparator.naturalOrder()); - } - return items; - } - - @Override - public JSONObject listServerRecord(String recordApi, Integer pageNum, Integer pageSize) { - return recordApiUtils.getRecordlist(recordApi, pageNum, pageSize, null).getJSONObject("data"); - } - - @Override - public JSONArray listServerRecordByDate(String recordApi, Integer year, Integer month, String app, String stream) { - return recordApiUtils.getRecordDatelist(recordApi, year, month, app, stream, null).getJSONArray("data"); - } - - @Override - public JSONObject listServerRecordByStream(String recordApi, Integer pageNum, Integer pageSize, String app) { - return recordApiUtils.getRecordStreamlist(recordApi, pageNum, pageSize, app, null).getJSONObject("data"); - } - - @Override - public JSONObject listServerRecordByApp(String recordApi, Integer pageNum, Integer pageSize) { - return recordApiUtils.getRecordApplist(recordApi, pageNum, pageSize, null).getJSONObject("data"); - } - - @Override - public JSONObject listServerRecordByFile(String recordApi, Integer pageNum, Integer pageSize, String app, String stream, String startTime, String endTime) { - return recordApiUtils.getRecordFilelist(recordApi, pageNum, pageSize, app, stream, startTime, endTime, null).getJSONObject("data"); - } - - @Override - public JSONObject listServerRecordByDevice(Integer pageNum, Integer pageSize, String deviceId, String channelId, String startTime, String endTime) { - String stream = "gb_play_" + deviceId + "_" + channelId; - MediaServer mediaServer = mediaServerService.selectMediaServerBydeviceSipId(deviceId); - String recordApi = ""; - if (mediaServer != null && Objects.equals(mediaServer.getProtocol(), "http")) { - recordApi = "http://" + mediaServer.getIp() + ":" + mediaServer.getRecordPort(); - } else if (mediaServer != null && Objects.equals(mediaServer.getProtocol(), "https")) { - recordApi = "https://" + mediaServer.getDomain() + ":" + mediaServer.getRecordPort(); - } - JSONObject obj = recordApiUtils.getRecordFilelist(recordApi, pageNum, pageSize, "rtp", - stream, startTime, endTime, null); - if (obj != null) { - obj = obj.getJSONObject("data"); - obj.put("recordApi", recordApi); - log.info("obj:{}", obj); - } - return obj; - } - - @Override - public boolean startRecord(String stream) { - SysUser user = getLoginUser().getUser(); - //缓存zlm服务器配置 - MediaServer media = mediaServerService.selectMediaServerBytenantId(user.getUserId()); - if (media != null) { - return zlmApiUtils.startRecord(media, "1", "live", stream).getBoolean("result"); - } - return false; - } - - @Override - public boolean stopRecord(String stream) { - SysUser user = getLoginUser().getUser(); - MediaServer media = mediaServerService.selectMediaServerBytenantId(user.getUserId()); - ; - if (media != null) { - return zlmApiUtils.stopRecord(media, "1", "live", stream).getBoolean("result"); - } - return false; - } - - @Override - public boolean isRecording(String stream) { - SysUser user = getLoginUser().getUser(); - MediaServer media = mediaServerService.selectMediaServerBytenantId(user.getUserId()); - ; - if (media != null) { - return zlmApiUtils.isRecording(media, "1", "live", stream).getBoolean("status"); - } - return false; - } - - @Override - public JSONObject getMp4RecordFile(String stream, String period) { - SysUser user = getLoginUser().getUser(); - MediaServer media = mediaServerService.selectMediaServerBytenantId(user.getUserId()); - if (media != null) { - return zlmApiUtils.getMp4RecordFile(media, period, "live", stream).getJSONObject("data"); - } - return null; - } - - @Override - public Stream download(String deviceId, String channelId, String startTime, String endTime, int downloadSpeed) { - SipDevice dev = sipDeviceService.selectSipDeviceBySipId(deviceId); - VideoSessionInfo info = sipCmd.downloadStreamCmd(dev, channelId, startTime, endTime, downloadSpeed); - return zmlHookService.updateStream(info); - } - - - - @Override - public Stream playRecord(String deviceId, String channelId) { - return playService.play(deviceId, channelId, true); - } -} diff --git a/springboot/fastbee-server/sip-server/src/main/java/com/fastbee/sip/util/RecordApiUtils.java b/springboot/fastbee-server/sip-server/src/main/java/com/fastbee/sip/util/RecordApiUtils.java deleted file mode 100644 index 7e9924b8..00000000 --- a/springboot/fastbee-server/sip-server/src/main/java/com/fastbee/sip/util/RecordApiUtils.java +++ /dev/null @@ -1,170 +0,0 @@ -package com.fastbee.sip.util; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import lombok.extern.slf4j.Slf4j; -import okhttp3.*; -import org.springframework.stereotype.Component; - -import javax.validation.constraints.NotNull; -import java.io.IOException; -import java.net.ConnectException; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@Slf4j -@Component -public class RecordApiUtils { - public interface RequestCallback { - void run(JSONObject response); - } - - private OkHttpClient getClient() { - OkHttpClient.Builder httpClientBuilder = new OkHttpClient.Builder(); - return httpClientBuilder.build(); - } - - public JSONObject sendGet(String recoreUrl, String api, Map param, RequestCallback callback) { - OkHttpClient client = getClient(); - StringBuilder stringBuffer = new StringBuilder(); - stringBuffer.append(String.format("%s/%s", recoreUrl, api)); - JSONObject responseJSON = null; - if (param != null && param.keySet().size() > 0) { - stringBuffer.append("?"); - int index = 1; - for (String key : param.keySet()) { - if (param.get(key) != null) { - stringBuffer.append(key).append("=").append(param.get(key)); - if (index < param.size()) { - stringBuffer.append("&"); - } - } - index++; - } - } - String url = stringBuffer.toString(); - Request request = new Request.Builder() - .get() - .url(url) - .build(); - if (callback == null) { - try { - Response response = client.newCall(request).execute(); - if (response.isSuccessful()) { - ResponseBody responseBody = response.body(); - if (responseBody != null) { - String responseStr = responseBody.string(); - responseJSON = JSON.parseObject(responseStr); - } - } else { - response.close(); - Objects.requireNonNull(response.body()).close(); - } - } catch (ConnectException e) { - log.error(String.format("连接Assist失败: %s, %s", e.getCause().getMessage(), e.getMessage())); - log.error("请检查media配置并确认Assist已启动..."); - } catch (IOException e) { - log.error(String.format("[ %s ]请求失败: %s", url, e.getMessage())); - } - } else { - client.newCall(request).enqueue(new Callback() { - @Override - public void onResponse(@NotNull Call call, @NotNull Response response) { - if (response.isSuccessful()) { - try { - String responseStr = Objects.requireNonNull(response.body()).string(); - callback.run(JSON.parseObject(responseStr)); - } catch (IOException e) { - log.error(String.format("[ %s ]请求失败: %s", url, e.getMessage())); - } - - } else { - response.close(); - Objects.requireNonNull(response.body()).close(); - } - } - - @Override - public void onFailure(@NotNull Call call, @NotNull IOException e) { - log.error(String.format("连接Assist失败: %s, %s", e.getCause().getMessage(), e.getMessage())); - log.info("请检查media配置并确认Assist已启动..."); - } - }); - } - return responseJSON; - } - - public JSONObject fileDuration(String recoreUrl, String app, String stream, RequestCallback callback) { - Map param = new HashMap<>(); - param.put("app", app); - param.put("stream", stream); - param.put("recordIng", true); - return sendGet(recoreUrl, "zlm/record//file/duration", param, callback); - } - - public JSONObject getInfo(String recoreUrl, RequestCallback callback) { - Map param = new HashMap<>(); - return sendGet(recoreUrl, "zlm/record//info", param, callback); - } - - public JSONObject getRecordlist(String recoreUrl, Integer pageNum, Integer pageSize, RequestCallback callback) { - Map param = new HashMap<>(); - param.put("pageNum", pageNum); - param.put("pageSize", pageSize); - return sendGet(recoreUrl, "zlm/record/list", param, callback); - } - - public JSONObject getRecordDatelist(String recoreUrl, Integer year, Integer month, String app, String stream, RequestCallback callback) { - Map param = new HashMap<>(); - if(year != null) { - param.put("year", year); - } - if(year != null) { - param.put("month", month); - } - param.put("app", app); - param.put("stream", stream); - return sendGet(recoreUrl, "zlm/record/date/list", param, callback); - } - - public JSONObject getRecordStreamlist(String recoreUrl, Integer pageNum, Integer pageSize, String app, RequestCallback callback) { - Map param = new HashMap<>(); - param.put("page", pageNum); - param.put("count", pageSize); - param.put("app", app); - return sendGet(recoreUrl, "zlm/record/stream/list", param, callback); - } - - public JSONObject getRecordApplist(String recoreUrl, Integer pageNum, Integer pageSize, RequestCallback callback) { - Map param = new HashMap<>(); - param.put("page", pageNum); - param.put("count", pageSize); - return sendGet(recoreUrl, "zlm/record/app/list", param, callback); - } - - public JSONObject getRecordFilelist(String recoreUrl, Integer pageNum, Integer pageSize, String app, String stream, String startTime, String endTime, RequestCallback callback) { - Map param = new HashMap<>(); - param.put("page", pageNum); - param.put("count", pageSize); - param.put("app", app); - param.put("stream", stream); - param.put("startTime", startTime); - param.put("endTime", endTime); - return sendGet(recoreUrl, "zlm/record/file/list", param, callback); - } - - public JSONObject addStreamCallInfo(String recoreUrl, String app, String stream, String callId, RequestCallback callback) { - Map param = new HashMap<>(); - param.put("app", app); - param.put("stream", stream); - param.put("callId", callId); - return sendGet(recoreUrl, "zlm/record/addStreamCallInfo", param, callback); - } - - public JSONObject uploadOss(String recoreUrl, String file, RequestCallback callback) { - Map param = new HashMap<>(); - param.put("resourcePath", file); - return sendGet(recoreUrl, "file/upload", param, callback); - } -} diff --git a/vue/src/views/components/player/deviceLiveStream.vue b/vue/src/views/components/player/deviceLiveStream.vue index 9efb0eb4..769af9b6 100644 --- a/vue/src/views/components/player/deviceLiveStream.vue +++ b/vue/src/views/components/player/deviceLiveStream.vue @@ -104,6 +104,7 @@ export default { }, 1000); }, startPushStream() { + console.log('开始通道: [' + this.channelId + ']'); if (!this.channelId) { console.log('开始通道: [' + this.channelId + ']'); return; @@ -135,17 +136,17 @@ export default { if (!this.$refs.player.isInit) { this.$refs.player.init(); } - this.$refs.player.registercallback('loadingTimeout', this.TimeoutCallback); - this.$refs.player.registercallback('delayTimeout', this.TimeoutCallback); + // this.$refs.player.registercallback('loadingTimeout', this.TimeoutCallback); + // this.$refs.player.registercallback('delayTimeout', this.TimeoutCallback); // this.$refs.player.play("https://sample-videos.com/video321/flv/480/big_buck_bunny_480p_1mb.flv"); if (this.playrecord) { } else { startPlay(this.deviceId, this.channelId).then((response) => { - console.log('开始推流: [' + this.streamId + ']'); const res = response.data; this.streamId = res.streamId; this.playurl = res.playurl; + console.log('开始推流: [' + this.streamId + ']'); this.$refs.player.play(res.playurl); this.playing = true; this.playrecording = false;