JT1078Controller.java 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package com.genersoft.iot.vmp.jt1078.config;
  2. import com.genersoft.iot.vmp.jt1078.cmd.JT1078Template;
  3. import com.genersoft.iot.vmp.jt1078.proc.response.*;
  4. import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
  5. import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
  6. import org.springframework.web.bind.annotation.GetMapping;
  7. import org.springframework.web.bind.annotation.PathVariable;
  8. import org.springframework.web.bind.annotation.RequestMapping;
  9. import org.springframework.web.bind.annotation.RestController;
  10. import javax.annotation.Resource;
  11. /**
  12. * curl http://localhost:18080/api/jt1078/start/live/18864197066/1
  13. *
  14. * @author QingtaiJiang
  15. * @date 2023/4/27 18:12
  16. * @email qingtaij@163.com
  17. */
  18. @ConditionalOnProperty(value = "jt1078.enable", havingValue = "true")
  19. @RestController
  20. @RequestMapping("/api/jt1078")
  21. public class JT1078Controller {
  22. @Resource
  23. JT1078Template jt1078Template;
  24. /**
  25. * jt1078Template 调用示例
  26. */
  27. @GetMapping("/start/live/{deviceId}/{channelId}")
  28. public WVPResult<?> startLive(@PathVariable String deviceId, @PathVariable String channelId) {
  29. J9101 j9101 = new J9101();
  30. j9101.setChannel(Integer.valueOf(channelId));
  31. j9101.setIp("192.168.1.1");
  32. j9101.setRate(1);
  33. j9101.setTcpPort(7618);
  34. j9101.setUdpPort(7618);
  35. j9101.setType(0);
  36. // TODO 分配ZLM,获取IP、端口
  37. String s = jt1078Template.startLive(deviceId, j9101, 6);
  38. // TODO 设备响应成功后,封装拉流结果集
  39. WVPResult<String> wvpResult = new WVPResult<>();
  40. wvpResult.setCode(200);
  41. wvpResult.setData(String.format("http://192.168.1.1/rtp/%s_%s.live.mp4", deviceId, channelId));
  42. return wvpResult;
  43. }
  44. }