RtpController.java 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. package com.genersoft.iot.vmp.vmanager.rtp;
  2. import com.genersoft.iot.vmp.conf.SipConfig;
  3. import com.genersoft.iot.vmp.conf.UserSetting;
  4. import com.genersoft.iot.vmp.conf.VersionInfo;
  5. import com.genersoft.iot.vmp.conf.exception.ControllerException;
  6. import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem;
  7. import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe;
  8. import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
  9. import com.genersoft.iot.vmp.service.*;
  10. import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
  11. import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
  12. import io.swagger.v3.oas.annotations.Operation;
  13. import io.swagger.v3.oas.annotations.Parameter;
  14. import io.swagger.v3.oas.annotations.tags.Tag;
  15. import org.springframework.beans.factory.annotation.Autowired;
  16. import org.springframework.beans.factory.annotation.Value;
  17. import org.springframework.web.bind.annotation.GetMapping;
  18. import org.springframework.web.bind.annotation.RequestMapping;
  19. import org.springframework.web.bind.annotation.ResponseBody;
  20. import org.springframework.web.bind.annotation.RestController;
  21. @SuppressWarnings("rawtypes")
  22. @Tag(name = "第三方服务对接")
  23. @RestController
  24. @RequestMapping("/api/rtp")
  25. public class RtpController {
  26. @Autowired
  27. private ZlmHttpHookSubscribe zlmHttpHookSubscribe;
  28. @Autowired
  29. private IMediaServerService mediaServerService;
  30. @Autowired
  31. private VersionInfo versionInfo;
  32. @Autowired
  33. private SipConfig sipConfig;
  34. @Autowired
  35. private UserSetting userSetting;
  36. @Autowired
  37. private IDeviceService deviceService;
  38. @Autowired
  39. private IDeviceChannelService channelService;
  40. @Autowired
  41. private IStreamPushService pushService;
  42. @Autowired
  43. private IStreamProxyService proxyService;
  44. @Value("${server.port}")
  45. private int serverPort;
  46. @Autowired
  47. private IRedisCatchStorage redisCatchStorage;
  48. @GetMapping(value = "/receive/open")
  49. @ResponseBody
  50. @Operation(summary = "开启收流和获取发流信息")
  51. @Parameter(name = "isSend", description = "是否发送,false时只开启收流, true同时返回推流信息", required = true)
  52. @Parameter(name = "callId", description = "整个过程的唯一标识,为了与后续接口关联", required = true)
  53. @Parameter(name = "ssrc", description = "来源流的SSRC,不传则不校验来源ssrc", required = false)
  54. @Parameter(name = "stream", description = "形成的流的ID", required = true)
  55. @Parameter(name = "tcpMode", description = "收流模式, 0为UDP, 1为TCP被动", required = true)
  56. @Parameter(name = "callBack", description = "回调地址,如果收流超时会通道回调通知,回调为get请求,参数为callId", required = true)
  57. public SendRtpItem openRtpServer(Boolean isSend, String ssrc, String callId, String stream, Integer tcpMode, String callBack) {
  58. MediaServerItem mediaServerItem = mediaServerService.getMediaServerForMinimumLoad(null);
  59. if (mediaServerItem == null) {
  60. throw new ControllerException(ErrorCode.ERROR100.getCode(),"没有可用的MediaServer");
  61. }
  62. return null;
  63. }
  64. @GetMapping(value = "/receive/close")
  65. @ResponseBody
  66. @Operation(summary = "关闭收流")
  67. @Parameter(name = "stream", description = "流的ID", required = true)
  68. public void closeRtpServer(String stream) {
  69. }
  70. @GetMapping(value = "/send/start")
  71. @ResponseBody
  72. @Operation(summary = "发送流")
  73. @Parameter(name = "ssrc", description = "发送流的SSRC", required = true)
  74. @Parameter(name = "ip", description = "目标IP", required = true)
  75. @Parameter(name = "port", description = "目标端口", required = true)
  76. @Parameter(name = "app", description = "待发送应用名", required = true)
  77. @Parameter(name = "stream", description = "待发送流Id", required = true)
  78. @Parameter(name = "callId", description = "整个过程的唯一标识,不传则使用随机端口发流", required = true)
  79. @Parameter(name = "onlyAudio", description = "是否只有音频", required = true)
  80. @Parameter(name = "streamType", description = "流类型,1为es流,2为ps流, 默认es流", required = false)
  81. public void sendRTP(String ssrc, String ip, Integer port, String app, String stream, String callId, Boolean onlyAudio, Integer streamType) {
  82. }
  83. @GetMapping(value = "/send/stop")
  84. @ResponseBody
  85. @Operation(summary = "关闭发送流")
  86. @Parameter(name = "callId", description = "整个过程的唯一标识,不传则使用随机端口发流", required = true)
  87. public void closeSendRTP(String callId) {
  88. }
  89. }