StreamInfo.java 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527
  1. package com.genersoft.iot.vmp.common;
  2. import io.swagger.v3.oas.annotations.media.Schema;
  3. import java.io.Serializable;
  4. @Schema(description = "流信息")
  5. public class StreamInfo implements Serializable, Cloneable{
  6. @Schema(description = "应用名")
  7. private String app;
  8. @Schema(description = "流ID")
  9. private String stream;
  10. @Schema(description = "设备编号")
  11. private String deviceID;
  12. @Schema(description = "通道编号")
  13. private String channelId;
  14. @Schema(description = "IP")
  15. private String ip;
  16. @Schema(description = "HTTP-FLV流地址")
  17. private StreamURL flv;
  18. @Schema(description = "HTTPS-FLV流地址")
  19. private StreamURL https_flv;
  20. @Schema(description = "Websocket-FLV流地址")
  21. private StreamURL ws_flv;
  22. @Schema(description = "Websockets-FLV流地址")
  23. private StreamURL wss_flv;
  24. @Schema(description = "HTTP-FMP4流地址")
  25. private StreamURL fmp4;
  26. @Schema(description = "HTTPS-FMP4流地址")
  27. private StreamURL https_fmp4;
  28. @Schema(description = "Websocket-FMP4流地址")
  29. private StreamURL ws_fmp4;
  30. @Schema(description = "Websockets-FMP4流地址")
  31. private StreamURL wss_fmp4;
  32. @Schema(description = "HLS流地址")
  33. private StreamURL hls;
  34. @Schema(description = "HTTPS-HLS流地址")
  35. private StreamURL https_hls;
  36. @Schema(description = "Websocket-HLS流地址")
  37. private StreamURL ws_hls;
  38. @Schema(description = "Websockets-HLS流地址")
  39. private StreamURL wss_hls;
  40. @Schema(description = "HTTP-TS流地址")
  41. private StreamURL ts;
  42. @Schema(description = "HTTPS-TS流地址")
  43. private StreamURL https_ts;
  44. @Schema(description = "Websocket-TS流地址")
  45. private StreamURL ws_ts;
  46. @Schema(description = "Websockets-TS流地址")
  47. private StreamURL wss_ts;
  48. @Schema(description = "RTMP流地址")
  49. private StreamURL rtmp;
  50. @Schema(description = "RTMPS流地址")
  51. private StreamURL rtmps;
  52. @Schema(description = "RTSP流地址")
  53. private StreamURL rtsp;
  54. @Schema(description = "RTSPS流地址")
  55. private StreamURL rtsps;
  56. @Schema(description = "RTC流地址")
  57. private StreamURL rtc;
  58. @Schema(description = "RTCS流地址")
  59. private StreamURL rtcs;
  60. @Schema(description = "流媒体ID")
  61. private String mediaServerId;
  62. @Schema(description = "流编码信息")
  63. private Object tracks;
  64. @Schema(description = "开始时间")
  65. private String startTime;
  66. @Schema(description = "结束时间")
  67. private String endTime;
  68. @Schema(description = "进度(录像下载使用)")
  69. private double progress;
  70. @Schema(description = "是否暂停(录像回放使用)")
  71. private boolean pause;
  72. public void setFlv(StreamURL flv) {
  73. this.flv = flv;
  74. }
  75. public void setHttps_flv(StreamURL https_flv) {
  76. this.https_flv = https_flv;
  77. }
  78. public void setWs_flv(StreamURL ws_flv) {
  79. this.ws_flv = ws_flv;
  80. }
  81. public void setWss_flv(StreamURL wss_flv) {
  82. this.wss_flv = wss_flv;
  83. }
  84. public void setFmp4(StreamURL fmp4) {
  85. this.fmp4 = fmp4;
  86. }
  87. public void setHttps_fmp4(StreamURL https_fmp4) {
  88. this.https_fmp4 = https_fmp4;
  89. }
  90. public void setWs_fmp4(StreamURL ws_fmp4) {
  91. this.ws_fmp4 = ws_fmp4;
  92. }
  93. public void setWss_fmp4(StreamURL wss_fmp4) {
  94. this.wss_fmp4 = wss_fmp4;
  95. }
  96. public void setHls(StreamURL hls) {
  97. this.hls = hls;
  98. }
  99. public void setHttps_hls(StreamURL https_hls) {
  100. this.https_hls = https_hls;
  101. }
  102. public void setWs_hls(StreamURL ws_hls) {
  103. this.ws_hls = ws_hls;
  104. }
  105. public void setWss_hls(StreamURL wss_hls) {
  106. this.wss_hls = wss_hls;
  107. }
  108. public void setTs(StreamURL ts) {
  109. this.ts = ts;
  110. }
  111. public void setHttps_ts(StreamURL https_ts) {
  112. this.https_ts = https_ts;
  113. }
  114. public void setWs_ts(StreamURL ws_ts) {
  115. this.ws_ts = ws_ts;
  116. }
  117. public void setWss_ts(StreamURL wss_ts) {
  118. this.wss_ts = wss_ts;
  119. }
  120. public void setRtmp(StreamURL rtmp) {
  121. this.rtmp = rtmp;
  122. }
  123. public void setRtmps(StreamURL rtmps) {
  124. this.rtmps = rtmps;
  125. }
  126. public void setRtsp(StreamURL rtsp) {
  127. this.rtsp = rtsp;
  128. }
  129. public void setRtsps(StreamURL rtsps) {
  130. this.rtsps = rtsps;
  131. }
  132. public void setRtc(StreamURL rtc) {
  133. this.rtc = rtc;
  134. }
  135. public void setRtcs(StreamURL rtcs) {
  136. this.rtcs = rtcs;
  137. }
  138. public void setRtmp(String host, int port, int sslPort, String app, String stream, String callIdParam) {
  139. String file = String.format("%s/%s/%s", app, stream, callIdParam);
  140. if (port > 0) {
  141. this.rtmp = new StreamURL("rtmp", host, port, file);
  142. }
  143. if (sslPort > 0) {
  144. this.rtmps = new StreamURL("rtmps", host, sslPort, file);
  145. }
  146. }
  147. public void setRtsp(String host, int port, int sslPort, String app, String stream, String callIdParam) {
  148. String file = String.format("%s/%s/%s", app, stream, callIdParam);
  149. if (port > 0) {
  150. this.rtsp = new StreamURL("rtsp", host, port, file);
  151. }
  152. if (sslPort > 0) {
  153. this.rtsps = new StreamURL("rtsps", host, sslPort, file);
  154. }
  155. }
  156. public void setFlv(String host, int port, int sslPort, String app, String stream, String callIdParam) {
  157. String file = String.format("%s/%s.live.flv%s", app, stream, callIdParam);
  158. if (port > 0) {
  159. this.flv = new StreamURL("http", host, port, file);
  160. }
  161. this.ws_flv = new StreamURL("ws", host, port, file);
  162. if (sslPort > 0) {
  163. this.https_flv = new StreamURL("https", host, sslPort, file);
  164. this.wss_flv = new StreamURL("wss", host, sslPort, file);
  165. }
  166. }
  167. public void setFmp4(String host, int port, int sslPort, String app, String stream, String callIdParam) {
  168. String file = String.format("%s/%s.live.mp4%s", app, stream, callIdParam);
  169. if (port > 0) {
  170. this.fmp4 = new StreamURL("http", host, port, file);
  171. this.ws_fmp4 = new StreamURL("ws", host, port, file);
  172. }
  173. if (sslPort > 0) {
  174. this.https_fmp4 = new StreamURL("https", host, sslPort, file);
  175. this.wss_fmp4 = new StreamURL("wss", host, sslPort, file);
  176. }
  177. }
  178. public void setHls(String host, int port, int sslPort, String app, String stream, String callIdParam) {
  179. String file = String.format("%s/%s/hls.m3u8%s", app, stream, callIdParam);
  180. if (port > 0) {
  181. this.hls = new StreamURL("http", host, port, file);
  182. this.ws_hls = new StreamURL("ws", host, port, file);
  183. }
  184. if (sslPort > 0) {
  185. this.https_hls = new StreamURL("https", host, sslPort, file);
  186. this.wss_hls = new StreamURL("wss", host, sslPort, file);
  187. }
  188. }
  189. public void setTs(String host, int port, int sslPort, String app, String stream, String callIdParam) {
  190. String file = String.format("%s/%s.live.ts%s", app, stream, callIdParam);
  191. if (port > 0) {
  192. this.ts = new StreamURL("http", host, port, file);
  193. this.ws_ts = new StreamURL("ws", host, port, file);
  194. }
  195. if (sslPort > 0) {
  196. this.https_ts = new StreamURL("https", host, sslPort, file);
  197. this.wss_ts = new StreamURL("wss", host, sslPort, file);
  198. }
  199. }
  200. public void setRtc(String host, int port, int sslPort, String app, String stream, String callIdParam) {
  201. String file = String.format("index/api/webrtc?app=%s&stream=%s&type=play%s", app, stream, callIdParam);
  202. if (port > 0) {
  203. this.rtc = new StreamURL("http", host, port, file);
  204. }
  205. if (sslPort > 0) {
  206. this.rtcs = new StreamURL("https", host, sslPort, file);
  207. }
  208. }
  209. public void channgeStreamIp(String localAddr) {
  210. if (this.flv != null) {
  211. this.flv.setHost(localAddr);
  212. }
  213. if (this.ws_flv != null ){
  214. this.ws_flv.setHost(localAddr);
  215. }
  216. if (this.hls != null ) {
  217. this.hls.setHost(localAddr);
  218. }
  219. if (this.ws_hls != null ) {
  220. this.ws_hls.setHost(localAddr);
  221. }
  222. if (this.ts != null ) {
  223. this.ts.setHost(localAddr);
  224. }
  225. if (this.ws_ts != null ) {
  226. this.ws_ts.setHost(localAddr);
  227. }
  228. if (this.fmp4 != null ) {
  229. this.fmp4.setHost(localAddr);
  230. }
  231. if (this.ws_fmp4 != null ) {
  232. this.ws_fmp4.setHost(localAddr);
  233. }
  234. if (this.rtc != null ) {
  235. this.rtc.setHost(localAddr);
  236. }
  237. if (this.https_flv != null) {
  238. this.https_flv.setHost(localAddr);
  239. }
  240. if (this.wss_flv != null) {
  241. this.wss_flv.setHost(localAddr);
  242. }
  243. if (this.https_hls != null) {
  244. this.https_hls.setHost(localAddr);
  245. }
  246. if (this.wss_hls != null) {
  247. this.wss_hls.setHost(localAddr);
  248. }
  249. if (this.wss_ts != null) {
  250. this.wss_ts.setHost(localAddr);
  251. }
  252. if (this.https_fmp4 != null) {
  253. this.https_fmp4.setHost(localAddr);
  254. }
  255. if (this.wss_fmp4 != null) {
  256. this.wss_fmp4.setHost(localAddr);
  257. }
  258. if (this.rtcs != null) {
  259. this.rtcs.setHost(localAddr);
  260. }
  261. if (this.rtsp != null) {
  262. this.rtsp.setHost(localAddr);
  263. }
  264. if (this.rtsps != null) {
  265. this.rtsps.setHost(localAddr);
  266. }
  267. if (this.rtmp != null) {
  268. this.rtmp.setHost(localAddr);
  269. }
  270. if (this.rtmps != null) {
  271. this.rtmps.setHost(localAddr);
  272. }
  273. }
  274. public static class TransactionInfo{
  275. public String callId;
  276. public String localTag;
  277. public String remoteTag;
  278. public String branch;
  279. }
  280. private TransactionInfo transactionInfo;
  281. public String getApp() {
  282. return app;
  283. }
  284. public void setApp(String app) {
  285. this.app = app;
  286. }
  287. public String getDeviceID() {
  288. return deviceID;
  289. }
  290. public void setDeviceID(String deviceID) {
  291. this.deviceID = deviceID;
  292. }
  293. public String getChannelId() {
  294. return channelId;
  295. }
  296. public void setChannelId(String channelId) {
  297. this.channelId = channelId;
  298. }
  299. public String getStream() {
  300. return stream;
  301. }
  302. public void setStream(String stream) {
  303. this.stream = stream;
  304. }
  305. public String getIp() {
  306. return ip;
  307. }
  308. public void setIp(String ip) {
  309. this.ip = ip;
  310. }
  311. public StreamURL getFlv() {
  312. return flv;
  313. }
  314. public StreamURL getHttps_flv() {
  315. return https_flv;
  316. }
  317. public StreamURL getWs_flv() {
  318. return ws_flv;
  319. }
  320. public StreamURL getWss_flv() {
  321. return wss_flv;
  322. }
  323. public StreamURL getFmp4() {
  324. return fmp4;
  325. }
  326. public StreamURL getHttps_fmp4() {
  327. return https_fmp4;
  328. }
  329. public StreamURL getWs_fmp4() {
  330. return ws_fmp4;
  331. }
  332. public StreamURL getWss_fmp4() {
  333. return wss_fmp4;
  334. }
  335. public StreamURL getHls() {
  336. return hls;
  337. }
  338. public StreamURL getHttps_hls() {
  339. return https_hls;
  340. }
  341. public StreamURL getWs_hls() {
  342. return ws_hls;
  343. }
  344. public StreamURL getWss_hls() {
  345. return wss_hls;
  346. }
  347. public StreamURL getTs() {
  348. return ts;
  349. }
  350. public StreamURL getHttps_ts() {
  351. return https_ts;
  352. }
  353. public StreamURL getWs_ts() {
  354. return ws_ts;
  355. }
  356. public StreamURL getWss_ts() {
  357. return wss_ts;
  358. }
  359. public StreamURL getRtmp() {
  360. return rtmp;
  361. }
  362. public StreamURL getRtmps() {
  363. return rtmps;
  364. }
  365. public StreamURL getRtsp() {
  366. return rtsp;
  367. }
  368. public StreamURL getRtsps() {
  369. return rtsps;
  370. }
  371. public StreamURL getRtc() {
  372. return rtc;
  373. }
  374. public StreamURL getRtcs() {
  375. return rtcs;
  376. }
  377. public String getMediaServerId() {
  378. return mediaServerId;
  379. }
  380. public void setMediaServerId(String mediaServerId) {
  381. this.mediaServerId = mediaServerId;
  382. }
  383. public Object getTracks() {
  384. return tracks;
  385. }
  386. public void setTracks(Object tracks) {
  387. this.tracks = tracks;
  388. }
  389. public String getStartTime() {
  390. return startTime;
  391. }
  392. public void setStartTime(String startTime) {
  393. this.startTime = startTime;
  394. }
  395. public String getEndTime() {
  396. return endTime;
  397. }
  398. public void setEndTime(String endTime) {
  399. this.endTime = endTime;
  400. }
  401. public double getProgress() {
  402. return progress;
  403. }
  404. public void setProgress(double progress) {
  405. this.progress = progress;
  406. }
  407. public boolean isPause() {
  408. return pause;
  409. }
  410. public void setPause(boolean pause) {
  411. this.pause = pause;
  412. }
  413. public TransactionInfo getTransactionInfo() {
  414. return transactionInfo;
  415. }
  416. public void setTransactionInfo(TransactionInfo transactionInfo) {
  417. this.transactionInfo = transactionInfo;
  418. }
  419. @Override
  420. public StreamInfo clone() {
  421. StreamInfo instance = null;
  422. try{
  423. instance = (StreamInfo)super.clone();
  424. }catch(CloneNotSupportedException e) {
  425. e.printStackTrace();
  426. }
  427. return instance;
  428. }
  429. }