StreamPush.java 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. package com.genersoft.iot.vmp.streamPush.bean;
  2. import com.genersoft.iot.vmp.common.StreamInfo;
  3. import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel;
  4. import com.genersoft.iot.vmp.media.event.media.MediaArrivalEvent;
  5. import com.genersoft.iot.vmp.utils.DateUtil;
  6. import io.swagger.v3.oas.annotations.media.Schema;
  7. import lombok.Data;
  8. import lombok.EqualsAndHashCode;
  9. import org.jetbrains.annotations.NotNull;
  10. import org.springframework.util.ObjectUtils;
  11. @Data
  12. @Schema(description = "推流信息")
  13. @EqualsAndHashCode(callSuper = true)
  14. public class StreamPush extends CommonGBChannel implements Comparable<StreamPush>{
  15. /**
  16. * id
  17. */
  18. @Schema(description = "id")
  19. private Integer id;
  20. /**
  21. * 应用名
  22. */
  23. @Schema(description = "应用名")
  24. private String app;
  25. /**
  26. * 流id
  27. */
  28. @Schema(description = "流id")
  29. private String stream;
  30. /**
  31. * 使用的流媒体ID
  32. */
  33. @Schema(description = "使用的流媒体ID")
  34. private String mediaServerId;
  35. /**
  36. * 使用的服务ID
  37. */
  38. @Schema(description = "使用的服务ID")
  39. private String serverId;
  40. /**
  41. * 推流时间
  42. */
  43. @Schema(description = "推流时间")
  44. private String pushTime;
  45. /**
  46. * 更新时间
  47. */
  48. @Schema(description = "更新时间")
  49. private String updateTime;
  50. /**
  51. * 创建时间
  52. */
  53. @Schema(description = "创建时间")
  54. private String createTime;
  55. /**
  56. * 是否正在推流
  57. */
  58. @Schema(description = "是否正在推流")
  59. private boolean pushing;
  60. /**
  61. * 拉起离线推流
  62. */
  63. @Schema(description = "拉起离线推流")
  64. private boolean startOfflinePush;
  65. private String uniqueKey;
  66. @Override
  67. public int compareTo(@NotNull StreamPush streamPushItem) {
  68. return Long.valueOf(DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(this.createTime)
  69. - DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(streamPushItem.getCreateTime())).intValue();
  70. }
  71. public static StreamPush getInstance(StreamInfo streamInfo) {
  72. StreamPush streamPush = new StreamPush();
  73. streamPush.setApp(streamInfo.getApp());
  74. if (streamInfo.getMediaServer() != null) {
  75. streamPush.setMediaServerId(streamInfo.getMediaServer().getId());
  76. }
  77. streamPush.setStream(streamInfo.getStream());
  78. streamPush.setCreateTime(DateUtil.getNow());
  79. streamPush.setServerId(streamInfo.getServerId());
  80. return streamPush;
  81. }
  82. public static StreamPush getInstance(MediaArrivalEvent event, String serverId){
  83. StreamPush streamPushItem = new StreamPush();
  84. streamPushItem.setApp(event.getApp());
  85. streamPushItem.setMediaServerId(event.getMediaServer().getId());
  86. streamPushItem.setStream(event.getStream());
  87. streamPushItem.setCreateTime(DateUtil.getNow());
  88. streamPushItem.setServerId(serverId);
  89. return streamPushItem;
  90. }
  91. public CommonGBChannel buildCommonGBChannel() {
  92. if (ObjectUtils.isEmpty(this.getGbDeviceId())) {
  93. return null;
  94. }
  95. if (ObjectUtils.isEmpty(this.getGbName())) {
  96. this.setGbName( app+ "-" +stream);
  97. }
  98. this.setStreamPushId(this.getId());
  99. return this;
  100. }
  101. }