优化Track的构建
parent
913099291b
commit
4134c73745
|
@ -1,10 +1,13 @@
|
||||||
package com.genersoft.iot.vmp.media.abl;
|
package com.genersoft.iot.vmp.media.abl;
|
||||||
|
|
||||||
import com.genersoft.iot.vmp.common.CommonCallback;
|
import com.genersoft.iot.vmp.common.CommonCallback;
|
||||||
|
import com.genersoft.iot.vmp.common.StreamInfo;
|
||||||
import com.genersoft.iot.vmp.media.service.IMediaNodeServerService;
|
import com.genersoft.iot.vmp.media.service.IMediaNodeServerService;
|
||||||
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
|
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Service("abl")
|
@Service("abl")
|
||||||
public class ABLMediaNodeServerService implements IMediaNodeServerService {
|
public class ABLMediaNodeServerService implements IMediaNodeServerService {
|
||||||
|
|
||||||
|
@ -47,4 +50,19 @@ public class ABLMediaNodeServerService implements IMediaNodeServerService {
|
||||||
public MediaServerItem checkMediaServer(String ip, int port, String secret) {
|
public MediaServerItem checkMediaServer(String ip, int port, String secret) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean stopSendRtp(MediaServerItem mediaInfo, String app, String stream, String ssrc) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean deleteRecordDirectory(MediaServerItem mediaServerItem, String app, String stream, String date, String fileName) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<StreamInfo> getMediaList(MediaServerItem mediaServerItem, String app, String stream, String callId) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,12 @@
|
||||||
package com.genersoft.iot.vmp.media.bean;
|
package com.genersoft.iot.vmp.media.bean;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONArray;
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.genersoft.iot.vmp.media.zlm.dto.hook.OnStreamChangedHookParam;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 视频信息
|
* 视频信息
|
||||||
*/
|
*/
|
||||||
|
@ -22,6 +27,97 @@ public class Track {
|
||||||
@Schema(description = "音频采样率")
|
@Schema(description = "音频采样率")
|
||||||
private Integer audioSampleRate;
|
private Integer audioSampleRate;
|
||||||
|
|
||||||
|
public static Track getInstance(JSONObject jsonObject) {
|
||||||
|
Track track = new Track();
|
||||||
|
Integer totalReaderCount = jsonObject.getInteger("totalReaderCount");
|
||||||
|
if (totalReaderCount != null) {
|
||||||
|
track.setReaderCount(totalReaderCount);
|
||||||
|
}
|
||||||
|
JSONArray jsonArray = jsonObject.getJSONArray("tracks");
|
||||||
|
if (jsonArray.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < jsonArray.size(); i++) {
|
||||||
|
JSONObject trackJson = jsonArray.getJSONObject(i);
|
||||||
|
Integer channels = trackJson.getInteger("channels");
|
||||||
|
Integer codecId = trackJson.getInteger("codec_id");
|
||||||
|
Integer codecType = trackJson.getInteger("codec_type");
|
||||||
|
Integer sampleRate = trackJson.getInteger("sample_rate");
|
||||||
|
Integer height = trackJson.getInteger("height");
|
||||||
|
Integer width = trackJson.getInteger("height");
|
||||||
|
if (channels != null) {
|
||||||
|
track.setAudioChannels(channels);
|
||||||
|
}
|
||||||
|
if (sampleRate != null) {
|
||||||
|
track.setAudioSampleRate(sampleRate);
|
||||||
|
}
|
||||||
|
if (height != null) {
|
||||||
|
track.setHeight(height);
|
||||||
|
}
|
||||||
|
if (width != null) {
|
||||||
|
track.setWidth(width);
|
||||||
|
}
|
||||||
|
if (codecId != null) {
|
||||||
|
switch (codecId) {
|
||||||
|
case 0:
|
||||||
|
track.setVideoCodec("H264");
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
track.setVideoCodec("H265");
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
track.setAudioCodec("AAC");
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
track.setAudioCodec("G711A");
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
track.setAudioCodec("G711U");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return track;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Track getInstance(OnStreamChangedHookParam param) {
|
||||||
|
List<OnStreamChangedHookParam.MediaTrack> tracks = param.getTracks();
|
||||||
|
Track track = new Track();
|
||||||
|
track.setReaderCount(param.getTotalReaderCount());
|
||||||
|
for (OnStreamChangedHookParam.MediaTrack mediaTrack : tracks) {
|
||||||
|
switch (mediaTrack.getCodec_id()) {
|
||||||
|
case 0:
|
||||||
|
track.setVideoCodec("H264");
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
track.setVideoCodec("H265");
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
track.setAudioCodec("AAC");
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
track.setAudioCodec("G711A");
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
track.setAudioCodec("G711U");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (mediaTrack.getSample_rate() > 0) {
|
||||||
|
track.setAudioSampleRate(mediaTrack.getSample_rate());
|
||||||
|
}
|
||||||
|
if (mediaTrack.getChannels() > 0) {
|
||||||
|
track.setAudioChannels(mediaTrack.getChannels());
|
||||||
|
}
|
||||||
|
if (mediaTrack.getHeight() > 0) {
|
||||||
|
track.setHeight(mediaTrack.getHeight());
|
||||||
|
}
|
||||||
|
if (mediaTrack.getWidth() > 0) {
|
||||||
|
track.setWidth(mediaTrack.getWidth());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return track;
|
||||||
|
}
|
||||||
|
|
||||||
public Integer getReaderCount() {
|
public Integer getReaderCount() {
|
||||||
return readerCount;
|
return readerCount;
|
||||||
}
|
}
|
||||||
|
|
|
@ -369,40 +369,6 @@ public class ZLMHttpHookListener {
|
||||||
subscribe.response(mediaInfo, param);
|
subscribe.response(mediaInfo, param);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<OnStreamChangedHookParam.MediaTrack> tracks = param.getTracks();
|
|
||||||
Track track = new Track();
|
|
||||||
track.setReaderCount(param.getTotalReaderCount());
|
|
||||||
for (OnStreamChangedHookParam.MediaTrack mediaTrack : tracks) {
|
|
||||||
switch (mediaTrack.getCodec_id()) {
|
|
||||||
case 0:
|
|
||||||
track.setVideoCodec("H264");
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
track.setVideoCodec("H265");
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
track.setAudioCodec("AAC");
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
track.setAudioCodec("G711A");
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
track.setAudioCodec("G711U");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (mediaTrack.getSample_rate() > 0) {
|
|
||||||
track.setAudioSampleRate(mediaTrack.getSample_rate());
|
|
||||||
}
|
|
||||||
if (mediaTrack.getChannels() > 0) {
|
|
||||||
track.setAudioChannels(mediaTrack.getChannels());
|
|
||||||
}
|
|
||||||
if (mediaTrack.getHeight() > 0) {
|
|
||||||
track.setHeight(mediaTrack.getHeight());
|
|
||||||
}
|
|
||||||
if (mediaTrack.getWidth() > 0) {
|
|
||||||
track.setWidth(mediaTrack.getWidth());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// TODO 重构此处逻辑
|
// TODO 重构此处逻辑
|
||||||
if (param.isRegist()) {
|
if (param.isRegist()) {
|
||||||
// 处理流注册的鉴权信息, 流注销这里不再删除鉴权信息,下次来了新的鉴权信息会对就的进行覆盖
|
// 处理流注册的鉴权信息, 流注销这里不再删除鉴权信息,下次来了新的鉴权信息会对就的进行覆盖
|
||||||
|
@ -506,7 +472,7 @@ public class ZLMHttpHookListener {
|
||||||
callId = streamAuthorityInfo.getCallId();
|
callId = streamAuthorityInfo.getCallId();
|
||||||
}
|
}
|
||||||
StreamInfo streamInfoByAppAndStream = mediaService.getStreamInfoByAppAndStream(mediaInfo,
|
StreamInfo streamInfoByAppAndStream = mediaService.getStreamInfoByAppAndStream(mediaInfo,
|
||||||
param.getApp(), param.getStream(), track, callId);
|
param.getApp(), param.getStream(), Track.getInstance(param), callId);
|
||||||
param.setStreamInfo(new StreamContent(streamInfoByAppAndStream));
|
param.setStreamInfo(new StreamContent(streamInfoByAppAndStream));
|
||||||
redisCatchStorage.addStream(mediaInfo, type, param.getApp(), param.getStream(), param);
|
redisCatchStorage.addStream(mediaInfo, type, param.getApp(), param.getStream(), param);
|
||||||
if (param.getOriginType() == OriginType.RTSP_PUSH.ordinal()
|
if (param.getOriginType() == OriginType.RTSP_PUSH.ordinal()
|
||||||
|
|
|
@ -158,9 +158,8 @@ public class ZLMMediaNodeServerService implements IMediaNodeServerService {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
JSONObject mediaJSON = data.getJSONObject(0);
|
JSONObject mediaJSON = data.getJSONObject(0);
|
||||||
JSONArray tracks = mediaJSON.getJSONArray("tracks");
|
Track track = Track.getInstance(mediaJSON);
|
||||||
|
StreamInfo streamInfo = getStreamInfoByAppAndStream(mediaServerItem, app, stream, track, callId, true);
|
||||||
StreamInfo streamInfo = getStreamInfoByAppAndStream(mediaServerItem, app, stream, tracks, null, callId, true);
|
|
||||||
if (streamInfo != null) {
|
if (streamInfo != null) {
|
||||||
streamInfoList.add(streamInfo);
|
streamInfoList.add(streamInfo);
|
||||||
}
|
}
|
||||||
|
@ -169,14 +168,11 @@ public class ZLMMediaNodeServerService implements IMediaNodeServerService {
|
||||||
return streamInfoList;
|
return streamInfoList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public StreamInfo getStreamInfoByAppAndStream(MediaServerItem mediaInfo, String app, String stream, Track track, String addr, String callId, boolean isPlay) {
|
public StreamInfo getStreamInfoByAppAndStream(MediaServerItem mediaInfo, String app, String stream, Track track, String callId, boolean isPlay) {
|
||||||
StreamInfo streamInfoResult = new StreamInfo();
|
StreamInfo streamInfoResult = new StreamInfo();
|
||||||
streamInfoResult.setStream(stream);
|
streamInfoResult.setStream(stream);
|
||||||
streamInfoResult.setApp(app);
|
streamInfoResult.setApp(app);
|
||||||
if (addr == null) {
|
String addr = mediaInfo.getStreamIp();
|
||||||
addr = mediaInfo.getStreamIp();
|
|
||||||
}
|
|
||||||
|
|
||||||
streamInfoResult.setIp(addr);
|
streamInfoResult.setIp(addr);
|
||||||
streamInfoResult.setMediaServerId(mediaInfo.getId());
|
streamInfoResult.setMediaServerId(mediaInfo.getId());
|
||||||
String callIdParam = ObjectUtils.isEmpty(callId)?"":"?callId=" + callId;
|
String callIdParam = ObjectUtils.isEmpty(callId)?"":"?callId=" + callId;
|
||||||
|
|
|
@ -2,4 +2,4 @@ spring:
|
||||||
application:
|
application:
|
||||||
name: wvp
|
name: wvp
|
||||||
profiles:
|
profiles:
|
||||||
active: local
|
active: abl
|
Loading…
Reference in New Issue