国标级联--点播-未完成
parent
9d19f6b9d6
commit
c1b3f2beb4
|
@ -10,6 +10,7 @@ import javax.sip.message.Request;
|
||||||
import javax.sip.message.Response;
|
import javax.sip.message.Response;
|
||||||
|
|
||||||
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform;
|
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform;
|
||||||
|
import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory;
|
||||||
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.genersoft.iot.vmp.gb28181.transmit.response.impl.*;
|
import com.genersoft.iot.vmp.gb28181.transmit.response.impl.*;
|
||||||
|
@ -107,6 +108,9 @@ public class SIPProcessorFactory {
|
||||||
@Autowired
|
@Autowired
|
||||||
private IPlayService playService;
|
private IPlayService playService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ZLMRTPServerFactory zlmrtpServerFactory;
|
||||||
|
|
||||||
|
|
||||||
// 注:这里使用注解会导致循环依赖注入,暂用springBean
|
// 注:这里使用注解会导致循环依赖注入,暂用springBean
|
||||||
private SipProvider tcpSipProvider;
|
private SipProvider tcpSipProvider;
|
||||||
|
@ -128,6 +132,7 @@ public class SIPProcessorFactory {
|
||||||
processor.setCmderFroPlatform(cmderFroPlatform);
|
processor.setCmderFroPlatform(cmderFroPlatform);
|
||||||
processor.setPlayService(playService);
|
processor.setPlayService(playService);
|
||||||
processor.setStorager(storager);
|
processor.setStorager(storager);
|
||||||
|
processor.setZlmrtpServerFactory(zlmrtpServerFactory);
|
||||||
return processor;
|
return processor;
|
||||||
} else if (Request.REGISTER.equals(method)) {
|
} else if (Request.REGISTER.equals(method)) {
|
||||||
RegisterRequestProcessor processor = new RegisterRequestProcessor();
|
RegisterRequestProcessor processor = new RegisterRequestProcessor();
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.genersoft.iot.vmp.gb28181.transmit.request.impl;
|
package com.genersoft.iot.vmp.gb28181.transmit.request.impl;
|
||||||
|
|
||||||
|
import javax.sdp.*;
|
||||||
import javax.sip.InvalidArgumentException;
|
import javax.sip.InvalidArgumentException;
|
||||||
import javax.sip.RequestEvent;
|
import javax.sip.RequestEvent;
|
||||||
import javax.sip.SipException;
|
import javax.sip.SipException;
|
||||||
|
@ -11,20 +12,18 @@ import javax.sip.message.Request;
|
||||||
import javax.sip.message.Response;
|
import javax.sip.message.Response;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.genersoft.iot.vmp.conf.MediaServerConfig;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.Device;
|
import com.genersoft.iot.vmp.gb28181.bean.Device;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
|
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
|
||||||
import com.genersoft.iot.vmp.gb28181.sdp.Codec;
|
|
||||||
import com.genersoft.iot.vmp.gb28181.sdp.MediaDescription;
|
|
||||||
import com.genersoft.iot.vmp.gb28181.sdp.SdpParser;
|
|
||||||
import com.genersoft.iot.vmp.gb28181.sdp.SessionDescription;
|
|
||||||
import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
|
|
||||||
import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
|
|
||||||
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
|
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
|
||||||
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform;
|
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform;
|
||||||
import com.genersoft.iot.vmp.gb28181.transmit.request.SIPRequestAbstractProcessor;
|
import com.genersoft.iot.vmp.gb28181.transmit.request.SIPRequestAbstractProcessor;
|
||||||
|
import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory;
|
||||||
|
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
||||||
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
|
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
|
||||||
import com.genersoft.iot.vmp.vmanager.play.bean.PlayResult;
|
import com.genersoft.iot.vmp.vmanager.play.bean.PlayResult;
|
||||||
import com.genersoft.iot.vmp.vmanager.service.IPlayService;
|
import com.genersoft.iot.vmp.vmanager.service.IPlayService;
|
||||||
|
import gov.nist.javax.sdp.fields.SDPFormat;
|
||||||
import gov.nist.javax.sip.address.AddressImpl;
|
import gov.nist.javax.sip.address.AddressImpl;
|
||||||
import gov.nist.javax.sip.address.SipUri;
|
import gov.nist.javax.sip.address.SipUri;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -34,6 +33,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description:处理INVITE请求
|
* @Description:处理INVITE请求
|
||||||
|
@ -48,10 +49,22 @@ public class InviteRequestProcessor extends SIPRequestAbstractProcessor {
|
||||||
|
|
||||||
private IVideoManagerStorager storager;
|
private IVideoManagerStorager storager;
|
||||||
|
|
||||||
|
private IRedisCatchStorage redisCatchStorage;
|
||||||
|
|
||||||
private SIPCommander cmder;
|
private SIPCommander cmder;
|
||||||
|
|
||||||
private IPlayService playService;
|
private IPlayService playService;
|
||||||
|
|
||||||
|
private ZLMRTPServerFactory zlmrtpServerFactory;
|
||||||
|
|
||||||
|
public ZLMRTPServerFactory getZlmrtpServerFactory() {
|
||||||
|
return zlmrtpServerFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setZlmrtpServerFactory(ZLMRTPServerFactory zlmrtpServerFactory) {
|
||||||
|
this.zlmrtpServerFactory = zlmrtpServerFactory;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理invite请求
|
* 处理invite请求
|
||||||
*
|
*
|
||||||
|
@ -98,64 +111,105 @@ public class InviteRequestProcessor extends SIPRequestAbstractProcessor {
|
||||||
}else {
|
}else {
|
||||||
response100Ack(evt); // 通道存在,发100,trying
|
response100Ack(evt); // 通道存在,发100,trying
|
||||||
}
|
}
|
||||||
// 解析sdp消息
|
// 解析sdp消息, 使用jainsip 自带的sdp解析方式
|
||||||
SessionDescription sdp = new SdpParser().parse(request.getRawContent());
|
String contentString = new String(request.getRawContent());
|
||||||
|
SessionDescription sdp = SdpFactory.getInstance().createSessionDescription(contentString);
|
||||||
|
|
||||||
|
// TODO 区分TCP发流还是udp, 当前默认udp
|
||||||
// 获取支持的格式
|
// 获取支持的格式
|
||||||
List<MediaDescription> mediaDescriptions = sdp.getMediaDescriptions();
|
Vector mediaDescriptions = sdp.getMediaDescriptions(true);
|
||||||
// 查看是否支持PS 负载96
|
// 查看是否支持PS 负载96
|
||||||
String ip = null;
|
String ip = null;
|
||||||
int port = -1;
|
int port = -1;
|
||||||
for (MediaDescription mediaDescription : mediaDescriptions) {
|
for (int i = 0; i < mediaDescriptions.size(); i++) {
|
||||||
|
MediaDescription mediaDescription = (MediaDescription)mediaDescriptions.get(i);
|
||||||
List<Codec> codecs = mediaDescription.getCodecs();
|
Media media = mediaDescription.getMedia();
|
||||||
for (Codec codec : codecs) {
|
port = media.getMediaPort();
|
||||||
if("96".equals(codec.getPayloadType()) || "PS".equals(codec.getName()) || "ps".equals(codec.getName())) {
|
|
||||||
ip = mediaDescription.getIpAddress().getHostName();
|
|
||||||
port = mediaDescription.getPort();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
// for (MediaDescription mediaDescription : mediaDescriptions) {
|
||||||
}
|
//
|
||||||
if (ip == null || port == -1) { // TODO 没有合适的视频流格式, 可配置是否使用第一个media信息
|
// List<Codec> codecs = mediaDescription.getCodecs();
|
||||||
if (mediaDescriptions.size() > 0) {
|
// for (Codec codec : codecs) {
|
||||||
ip = mediaDescriptions.get(0).getIpAddress().getHostName();
|
// if("96".equals(codec.getPayloadType()) || "PS".equals(codec.getName()) || "ps".equals(codec.getName())) {
|
||||||
port = mediaDescriptions.get(0).getPort();
|
// // TODO 这里很慢
|
||||||
}
|
// ip = mediaDescription.getIpAddress().getHostName();
|
||||||
}
|
// port = mediaDescription.getPort();
|
||||||
|
// break;
|
||||||
if (ip == null || port == -1) {
|
// }
|
||||||
response488Ack(evt);
|
// }
|
||||||
return;
|
// }
|
||||||
}
|
// if (ip == null || port == -1) { // TODO 没有合适的视频流格式, 可配置是否使用第一个media信息
|
||||||
|
// if (mediaDescriptions.size() > 0) {
|
||||||
|
// ip = mediaDescriptions.get(0).getIpAddress().getHostName();
|
||||||
String ssrc = sdp.getSsrc();
|
// port = mediaDescriptions.get(0).getPort();
|
||||||
|
// }
|
||||||
Device device = storager.queryVideoDeviceByPlatformIdAndChannelId(platformId, channelId);
|
// }
|
||||||
if (device == null) {
|
//
|
||||||
logger.warn("点播平台{}的通道{}时未找到设备信息", platformId, channel);
|
// if (ip == null || port == -1) {
|
||||||
response500Ack(evt);
|
// response488Ack(evt);
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// 通知下级推流,
|
//
|
||||||
PlayResult playResult = playService.play(device.getDeviceId(), channelId, (response)->{
|
// String ssrc = sdp.getSsrc();
|
||||||
// 收到推流, 回复200OK
|
//
|
||||||
|
// Device device = storager.queryVideoDeviceByPlatformIdAndChannelId(platformId, channelId);
|
||||||
},(event -> {
|
// if (device == null) {
|
||||||
// 未知错误。直接转发设备点播的错误
|
// logger.warn("点播平台{}的通道{}时未找到设备信息", platformId, channel);
|
||||||
Response response = null;
|
// response500Ack(evt);
|
||||||
try {
|
// return;
|
||||||
response = getMessageFactory().createResponse(event.getResponse().getStatusCode(), evt.getRequest());
|
// }
|
||||||
getServerTransaction(evt).sendResponse(response);
|
//
|
||||||
|
// // 通知下级推流,
|
||||||
} catch (ParseException | SipException | InvalidArgumentException e) {
|
// PlayResult playResult = playService.play(device.getDeviceId(), channelId, (responseJSON)->{
|
||||||
e.printStackTrace();
|
// // 收到推流, 回复200OK
|
||||||
}
|
// UUID uuid = UUID.randomUUID();
|
||||||
}));
|
// int rtpServer = zlmrtpServerFactory.createRTPServer(uuid.toString());
|
||||||
playResult.getResult();
|
// if (rtpServer == -1) {
|
||||||
|
// logger.error("为获取到可用端口");
|
||||||
|
// return;
|
||||||
|
// }else {
|
||||||
|
// zlmrtpServerFactory.closeRTPServer(uuid.toString());
|
||||||
|
// }
|
||||||
|
// // TODO 添加对tcp的支持
|
||||||
|
// MediaServerConfig mediaInfo = redisCatchStorage.getMediaInfo();
|
||||||
|
// StringBuffer content = new StringBuffer(200);
|
||||||
|
// content.append("v=0\r\n");
|
||||||
|
// content.append("o="+"00000"+" 0 0 IN IP4 "+mediaInfo.getWanIp()+"\r\n");
|
||||||
|
// content.append("s=Play\r\n");
|
||||||
|
// content.append("c=IN IP4 "+mediaInfo.getWanIp()+"\r\n");
|
||||||
|
// content.append("t=0 0\r\n");
|
||||||
|
// content.append("m=video "+ rtpServer+" RTP/AVP 96\r\n");
|
||||||
|
// content.append("a=sendonly\r\n");
|
||||||
|
// content.append("a=rtpmap:96 PS/90000\r\n");
|
||||||
|
// content.append("y="+ ssrc + "\r\n");
|
||||||
|
// content.append("f=\r\n");
|
||||||
|
//
|
||||||
|
// try {
|
||||||
|
// responseAck(evt, content.toString());
|
||||||
|
// } catch (SipException e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
// } catch (InvalidArgumentException e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
// } catch (ParseException e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // 写入redis, 超时时回复
|
||||||
|
//// redisCatchStorage.waiteAck()
|
||||||
|
// },(event -> {
|
||||||
|
// // 未知错误。直接转发设备点播的错误
|
||||||
|
// Response response = null;
|
||||||
|
// try {
|
||||||
|
// response = getMessageFactory().createResponse(event.getResponse().getStatusCode(), evt.getRequest());
|
||||||
|
// getServerTransaction(evt).sendResponse(response);
|
||||||
|
//
|
||||||
|
// } catch (ParseException | SipException | InvalidArgumentException e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
// }
|
||||||
|
// }));
|
||||||
|
// playResult.getResult();
|
||||||
// 查找合适的端口推流,
|
// 查找合适的端口推流,
|
||||||
// 发送 200ok
|
|
||||||
// 收到ack后调用推流接口
|
// 收到ack后调用推流接口
|
||||||
|
|
||||||
|
|
||||||
|
@ -163,9 +217,12 @@ public class InviteRequestProcessor extends SIPRequestAbstractProcessor {
|
||||||
|
|
||||||
} catch (SipException | InvalidArgumentException | ParseException e) {
|
} catch (SipException | InvalidArgumentException | ParseException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (IOException e) {
|
|
||||||
logger.warn("sdp解析错误");
|
logger.warn("sdp解析错误");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
} catch (SdpParseException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (SdpException e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.genersoft.iot.vmp.storager.dao;
|
package com.genersoft.iot.vmp.storager.dao;
|
||||||
|
|
||||||
|
import com.genersoft.iot.vmp.gb28181.bean.Device;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
|
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
|
||||||
import com.genersoft.iot.vmp.vmanager.platform.bean.ChannelReduce;
|
import com.genersoft.iot.vmp.vmanager.platform.bean.ChannelReduce;
|
||||||
import org.apache.ibatis.annotations.Delete;
|
import org.apache.ibatis.annotations.Delete;
|
||||||
|
@ -45,4 +46,7 @@ public interface PatformChannelMapper {
|
||||||
@Select("SELECT * FROM device_channel WHERE deviceId = (SELECT deviceId FROM platform_gb_channel WHERE " +
|
@Select("SELECT * FROM device_channel WHERE deviceId = (SELECT deviceId FROM platform_gb_channel WHERE " +
|
||||||
"platformId='${platformId}' AND channelId='${channelId}' ) AND channelId='${channelId}'")
|
"platformId='${platformId}' AND channelId='${channelId}' ) AND channelId='${channelId}'")
|
||||||
DeviceChannel queryChannelInParentPlatform(String platformId, String channelId);
|
DeviceChannel queryChannelInParentPlatform(String platformId, String channelId);
|
||||||
|
|
||||||
|
@Select("SELECT * FROM device WHERE deviceId = (SELECT deviceId FROM platform_gb_channel WHERE platformId='${platformId}' AND channelId='${channelId}')")
|
||||||
|
Device queryVideoDeviceByPlatformIdAndChannelId(String platformId, String channelId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -338,6 +338,7 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Device queryVideoDeviceByPlatformIdAndChannelId(String platformId, String channelId) {
|
public Device queryVideoDeviceByPlatformIdAndChannelId(String platformId, String channelId) {
|
||||||
return null;
|
Device device = patformChannelMapper.queryVideoDeviceByPlatformIdAndChannelId(platformId, channelId);
|
||||||
|
return device;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ module.exports = {
|
||||||
// to edit target browsers: use "browserslist" field in package.json
|
// to edit target browsers: use "browserslist" field in package.json
|
||||||
"autoprefixer": {},
|
"autoprefixer": {},
|
||||||
'postcss-pxtorem': {
|
'postcss-pxtorem': {
|
||||||
rootValue: 24,
|
rootValue: 16,
|
||||||
propList: ['font-size'] // 只转化font-size
|
propList: ['font-size'] // 只转化font-size
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue