StreamInfo.java 16 KB

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