StreamInfo.java 16 KB

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