| | |
| | | |
| | | import com.alibaba.fastjson2.JSONArray; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.genersoft.iot.vmp.media.abl.bean.hook.OnStreamArriveABLHookParam; |
| | | import com.genersoft.iot.vmp.media.zlm.dto.hook.OnStreamChangedHookParam; |
| | | import com.genersoft.iot.vmp.media.zlm.dto.hook.OriginType; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | |
| | | import java.util.List; |
| | |
| | | */ |
| | | @Schema(description = "视频信息") |
| | | public class MediaInfo { |
| | | @Schema(description = "应用名") |
| | | private String app; |
| | | @Schema(description = "流ID") |
| | | private String stream; |
| | | @Schema(description = "流媒体节点") |
| | | private MediaServer mediaServer; |
| | | @Schema(description = "协议") |
| | | private String schema; |
| | | |
| | | @Schema(description = "观看人数") |
| | | private Integer readerCount; |
| | | @Schema(description = "视频编码类型") |
| | |
| | | @Schema(description = "数据产生速度,单位byte/s") |
| | | private Long bytesSpeed; |
| | | |
| | | public static MediaInfo getInstance(JSONObject jsonObject) { |
| | | public static MediaInfo getInstance(JSONObject jsonObject, MediaServer mediaServer) { |
| | | MediaInfo mediaInfo = new MediaInfo(); |
| | | mediaInfo.setMediaServer(mediaServer); |
| | | String app = jsonObject.getString("app"); |
| | | mediaInfo.setApp(app); |
| | | String stream = jsonObject.getString("stream"); |
| | | mediaInfo.setStream(stream); |
| | | String schema = jsonObject.getString("schema"); |
| | | mediaInfo.setSchema(schema); |
| | | Integer totalReaderCount = jsonObject.getInteger("totalReaderCount"); |
| | | Boolean online = jsonObject.getBoolean("online"); |
| | | Integer originType = jsonObject.getInteger("originType"); |
| | |
| | | return mediaInfo; |
| | | } |
| | | |
| | | public static MediaInfo getInstance(OnStreamChangedHookParam param) { |
| | | List<OnStreamChangedHookParam.MediaTrack> tracks = param.getTracks(); |
| | | public static MediaInfo getInstance(OnStreamChangedHookParam param, MediaServer mediaServer) { |
| | | |
| | | MediaInfo mediaInfo = new MediaInfo(); |
| | | mediaInfo.setApp(param.getApp()); |
| | | mediaInfo.setStream(param.getStream()); |
| | | mediaInfo.setSchema(param.getSchema()); |
| | | mediaInfo.setMediaServer(mediaServer); |
| | | mediaInfo.setReaderCount(param.getTotalReaderCount()); |
| | | mediaInfo.setOnline(param.isRegist()); |
| | | mediaInfo.setOriginType(param.getOriginType()); |
| | | mediaInfo.setAliveSecond(param.getAliveSecond()); |
| | | mediaInfo.setBytesSpeed(param.getBytesSpeed()); |
| | | List<OnStreamChangedHookParam.MediaTrack> tracks = param.getTracks(); |
| | | if (tracks == null || tracks.isEmpty()) { |
| | | return mediaInfo; |
| | | } |
| | | for (OnStreamChangedHookParam.MediaTrack mediaTrack : tracks) { |
| | | switch (mediaTrack.getCodec_id()) { |
| | | case 0: |
| | |
| | | mediaInfo.setWidth(mediaTrack.getWidth()); |
| | | } |
| | | } |
| | | return mediaInfo; |
| | | } |
| | | |
| | | public static MediaInfo getInstance(OnStreamArriveABLHookParam param, MediaServer mediaServer) { |
| | | |
| | | MediaInfo mediaInfo = new MediaInfo(); |
| | | mediaInfo.setApp(param.getApp()); |
| | | mediaInfo.setStream(param.getStream()); |
| | | mediaInfo.setMediaServer(mediaServer); |
| | | mediaInfo.setReaderCount(param.getReaderCount()); |
| | | mediaInfo.setOnline(true); |
| | | mediaInfo.setVideoCodec(param.getVideoCodec()); |
| | | switch (param.getNetworkType()) { |
| | | case 21: |
| | | mediaInfo.setOriginType(OriginType.RTMP_PUSH.ordinal()); |
| | | break; |
| | | case 23: |
| | | mediaInfo.setOriginType(OriginType.RTSP_PUSH.ordinal()); |
| | | break; |
| | | case 30: |
| | | case 31: |
| | | case 32: |
| | | case 33: |
| | | mediaInfo.setOriginType(OriginType.PULL.ordinal()); |
| | | break; |
| | | default: |
| | | mediaInfo.setOriginType(OriginType.UNKNOWN.ordinal()); |
| | | break; |
| | | |
| | | } |
| | | mediaInfo.setWidth(param.getWidth()); |
| | | mediaInfo.setHeight(param.getHeight()); |
| | | mediaInfo.setAudioCodec(param.getAudioCodec()); |
| | | mediaInfo.setAudioChannels(param.getAudioChannels()); |
| | | mediaInfo.setAudioSampleRate(param.getAudioSampleRate()); |
| | | |
| | | return mediaInfo; |
| | | } |
| | | |
| | |
| | | public void setBytesSpeed(Long bytesSpeed) { |
| | | this.bytesSpeed = bytesSpeed; |
| | | } |
| | | |
| | | public String getApp() { |
| | | return app; |
| | | } |
| | | |
| | | public void setApp(String app) { |
| | | this.app = app; |
| | | } |
| | | |
| | | public String getStream() { |
| | | return stream; |
| | | } |
| | | |
| | | public void setStream(String stream) { |
| | | this.stream = stream; |
| | | } |
| | | |
| | | public MediaServer getMediaServer() { |
| | | return mediaServer; |
| | | } |
| | | |
| | | public void setMediaServer(MediaServer mediaServer) { |
| | | this.mediaServer = mediaServer; |
| | | } |
| | | |
| | | public String getSchema() { |
| | | return schema; |
| | | } |
| | | |
| | | public void setSchema(String schema) { |
| | | this.schema = schema; |
| | | } |
| | | } |