RtpController.java 4.7 KB

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