StreamURL.java 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 StreamURL implements Serializable,Cloneable {
  6. @Schema(description = "协议")
  7. private String protocol;
  8. @Schema(description = "主机地址")
  9. private String host;
  10. @Schema(description = "端口")
  11. private int port = -1;
  12. @Schema(description = "定位位置")
  13. private String file;
  14. @Schema(description = "拼接后的地址")
  15. private String url;
  16. public StreamURL() {
  17. }
  18. public StreamURL(String protocol, String host, int port, String file) {
  19. this.protocol = protocol;
  20. this.host = host;
  21. this.port = port;
  22. this.file = file;
  23. }
  24. public String getProtocol() {
  25. return protocol;
  26. }
  27. public void setProtocol(String protocol) {
  28. this.protocol = protocol;
  29. }
  30. public String getHost() {
  31. return host;
  32. }
  33. public void setHost(String host) {
  34. this.host = host;
  35. }
  36. public int getPort() {
  37. return port;
  38. }
  39. public void setPort(int port) {
  40. this.port = port;
  41. }
  42. public String getFile() {
  43. return file;
  44. }
  45. public void setFile(String file) {
  46. this.file = file;
  47. }
  48. public String getUrl() {
  49. return this.toString();
  50. }
  51. @Override
  52. public String toString() {
  53. if (protocol != null && host != null && port != -1 ) {
  54. return String.format("%s://%s:%s/%s", protocol, host, port, file);
  55. }else {
  56. return null;
  57. }
  58. }
  59. @Override
  60. public StreamURL clone() throws CloneNotSupportedException {
  61. return (StreamURL) super.clone();
  62. }
  63. }