更新 gb28181-docking-platform 依赖到 0.1.0
新增 设备表添加 live_stream 字段 添加自动更新表结构
This commit is contained in:
parent
df68ad5c5e
commit
2124c20c7f
@ -38,7 +38,7 @@ docker run --name gb28181-mocking --rm \
|
||||
--log-opt max-size=1g \
|
||||
--network host \
|
||||
-v `pwd`/application.yml:/opt/gb28181-docking-platform-mocking/application.yml \
|
||||
skcks.cn/gb28181-docking-platform-mocking:0.0.1-SNAPSHOT
|
||||
skcks.cn/gb28181-docking-platform-mocking:0.1.0-SNAPSHOT
|
||||
```
|
||||
|
||||
### 打包到本地私仓
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>cn.skcks.docking</groupId>
|
||||
<artifactId>gb28181-mocking</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<version>0.1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<groupId>cn.skcks.docking.gb28181</groupId>
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>cn.skcks.docking</groupId>
|
||||
<artifactId>gb28181-mocking</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<version>0.1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<groupId>cn.skcks.docking.gb28181</groupId>
|
||||
|
@ -12,24 +12,55 @@ public final class MockingDeviceDynamicSqlSupport {
|
||||
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: mocking_device.id")
|
||||
public static final SqlColumn<Long> id = mockingDevice.id;
|
||||
|
||||
/**
|
||||
* Database Column Remarks:
|
||||
* 自定义21位设备编码
|
||||
*/
|
||||
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: mocking_device.device_code")
|
||||
public static final SqlColumn<String> deviceCode = mockingDevice.deviceCode;
|
||||
|
||||
/**
|
||||
* Database Column Remarks:
|
||||
* 设备id
|
||||
*/
|
||||
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: mocking_device.gb_device_id")
|
||||
public static final SqlColumn<String> gbDeviceId = mockingDevice.gbDeviceId;
|
||||
|
||||
/**
|
||||
* Database Column Remarks:
|
||||
* 通道id
|
||||
*/
|
||||
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: mocking_device.gb_channel_id")
|
||||
public static final SqlColumn<String> gbChannelId = mockingDevice.gbChannelId;
|
||||
|
||||
/**
|
||||
* Database Column Remarks:
|
||||
* 设备/通道名称
|
||||
*/
|
||||
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: mocking_device.name")
|
||||
public static final SqlColumn<String> name = mockingDevice.name;
|
||||
|
||||
/**
|
||||
* Database Column Remarks:
|
||||
* 设备地址信息
|
||||
*/
|
||||
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: mocking_device.address")
|
||||
public static final SqlColumn<String> address = mockingDevice.address;
|
||||
|
||||
/**
|
||||
* Database Column Remarks:
|
||||
* 是否启用
|
||||
*/
|
||||
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: mocking_device.enable")
|
||||
public static final SqlColumn<Boolean> enable = mockingDevice.enable;
|
||||
|
||||
/**
|
||||
* Database Column Remarks:
|
||||
* 实时视频流地址
|
||||
*/
|
||||
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: mocking_device.live_stream")
|
||||
public static final SqlColumn<String> liveStream = mockingDevice.liveStream;
|
||||
|
||||
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: mocking_device")
|
||||
public static final class MockingDevice extends AliasableSqlTable<MockingDevice> {
|
||||
public final SqlColumn<Long> id = column("id", JDBCType.BIGINT);
|
||||
@ -46,6 +77,8 @@ public final class MockingDeviceDynamicSqlSupport {
|
||||
|
||||
public final SqlColumn<Boolean> enable = column("enable", JDBCType.BIT);
|
||||
|
||||
public final SqlColumn<String> liveStream = column("live_stream", JDBCType.VARCHAR);
|
||||
|
||||
public MockingDevice() {
|
||||
super("mocking_device", MockingDevice::new);
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ import org.mybatis.dynamic.sql.util.mybatis3.MyBatis3Utils;
|
||||
@Mapper
|
||||
public interface MockingDeviceMapper extends CommonCountMapper, CommonDeleteMapper, CommonInsertMapper<MockingDevice>, CommonUpdateMapper {
|
||||
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: mocking_device")
|
||||
BasicColumn[] selectList = BasicColumn.columnList(id, deviceCode, gbDeviceId, gbChannelId, name, address, enable);
|
||||
BasicColumn[] selectList = BasicColumn.columnList(id, deviceCode, gbDeviceId, gbChannelId, name, address, enable, liveStream);
|
||||
|
||||
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: mocking_device")
|
||||
@SelectProvider(type=SqlProviderAdapter.class, method="select")
|
||||
@ -43,7 +43,8 @@ public interface MockingDeviceMapper extends CommonCountMapper, CommonDeleteMapp
|
||||
@Result(column="gb_channel_id", property="gbChannelId", jdbcType=JdbcType.VARCHAR),
|
||||
@Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
|
||||
@Result(column="address", property="address", jdbcType=JdbcType.VARCHAR),
|
||||
@Result(column="enable", property="enable", jdbcType=JdbcType.BIT)
|
||||
@Result(column="enable", property="enable", jdbcType=JdbcType.BIT),
|
||||
@Result(column="live_stream", property="liveStream", jdbcType=JdbcType.VARCHAR)
|
||||
})
|
||||
List<MockingDevice> selectMany(SelectStatementProvider selectStatement);
|
||||
|
||||
@ -79,6 +80,7 @@ public interface MockingDeviceMapper extends CommonCountMapper, CommonDeleteMapp
|
||||
.map(name).toProperty("name")
|
||||
.map(address).toProperty("address")
|
||||
.map(enable).toProperty("enable")
|
||||
.map(liveStream).toProperty("liveStream")
|
||||
);
|
||||
}
|
||||
|
||||
@ -92,6 +94,7 @@ public interface MockingDeviceMapper extends CommonCountMapper, CommonDeleteMapp
|
||||
.map(name).toProperty("name")
|
||||
.map(address).toProperty("address")
|
||||
.map(enable).toProperty("enable")
|
||||
.map(liveStream).toProperty("liveStream")
|
||||
);
|
||||
}
|
||||
|
||||
@ -105,6 +108,7 @@ public interface MockingDeviceMapper extends CommonCountMapper, CommonDeleteMapp
|
||||
.map(name).toPropertyWhenPresent("name", row::getName)
|
||||
.map(address).toPropertyWhenPresent("address", row::getAddress)
|
||||
.map(enable).toPropertyWhenPresent("enable", row::getEnable)
|
||||
.map(liveStream).toPropertyWhenPresent("liveStream", row::getLiveStream)
|
||||
);
|
||||
}
|
||||
|
||||
@ -143,7 +147,8 @@ public interface MockingDeviceMapper extends CommonCountMapper, CommonDeleteMapp
|
||||
.set(gbChannelId).equalTo(row::getGbChannelId)
|
||||
.set(name).equalTo(row::getName)
|
||||
.set(address).equalTo(row::getAddress)
|
||||
.set(enable).equalTo(row::getEnable);
|
||||
.set(enable).equalTo(row::getEnable)
|
||||
.set(liveStream).equalTo(row::getLiveStream);
|
||||
}
|
||||
|
||||
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: mocking_device")
|
||||
@ -154,7 +159,8 @@ public interface MockingDeviceMapper extends CommonCountMapper, CommonDeleteMapp
|
||||
.set(gbChannelId).equalToWhenPresent(row::getGbChannelId)
|
||||
.set(name).equalToWhenPresent(row::getName)
|
||||
.set(address).equalToWhenPresent(row::getAddress)
|
||||
.set(enable).equalToWhenPresent(row::getEnable);
|
||||
.set(enable).equalToWhenPresent(row::getEnable)
|
||||
.set(liveStream).equalToWhenPresent(row::getLiveStream);
|
||||
}
|
||||
|
||||
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: mocking_device")
|
||||
@ -166,6 +172,7 @@ public interface MockingDeviceMapper extends CommonCountMapper, CommonDeleteMapp
|
||||
.set(name).equalTo(row::getName)
|
||||
.set(address).equalTo(row::getAddress)
|
||||
.set(enable).equalTo(row::getEnable)
|
||||
.set(liveStream).equalTo(row::getLiveStream)
|
||||
.where(id, isEqualTo(row::getId))
|
||||
);
|
||||
}
|
||||
@ -179,6 +186,7 @@ public interface MockingDeviceMapper extends CommonCountMapper, CommonDeleteMapp
|
||||
.set(name).equalToWhenPresent(row::getName)
|
||||
.set(address).equalToWhenPresent(row::getAddress)
|
||||
.set(enable).equalToWhenPresent(row::getEnable)
|
||||
.set(liveStream).equalToWhenPresent(row::getLiveStream)
|
||||
.where(id, isEqualTo(row::getId))
|
||||
);
|
||||
}
|
||||
|
@ -11,24 +11,55 @@ public class MockingDevice {
|
||||
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: mocking_device.id")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* Database Column Remarks:
|
||||
* 自定义21位设备编码
|
||||
*/
|
||||
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: mocking_device.device_code")
|
||||
private String deviceCode;
|
||||
|
||||
/**
|
||||
* Database Column Remarks:
|
||||
* 设备id
|
||||
*/
|
||||
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: mocking_device.gb_device_id")
|
||||
private String gbDeviceId;
|
||||
|
||||
/**
|
||||
* Database Column Remarks:
|
||||
* 通道id
|
||||
*/
|
||||
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: mocking_device.gb_channel_id")
|
||||
private String gbChannelId;
|
||||
|
||||
/**
|
||||
* Database Column Remarks:
|
||||
* 设备/通道名称
|
||||
*/
|
||||
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: mocking_device.name")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* Database Column Remarks:
|
||||
* 设备地址信息
|
||||
*/
|
||||
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: mocking_device.address")
|
||||
private String address;
|
||||
|
||||
/**
|
||||
* Database Column Remarks:
|
||||
* 是否启用
|
||||
*/
|
||||
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: mocking_device.enable")
|
||||
private Boolean enable;
|
||||
|
||||
/**
|
||||
* Database Column Remarks:
|
||||
* 实时视频流地址
|
||||
*/
|
||||
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: mocking_device.live_stream")
|
||||
private String liveStream;
|
||||
|
||||
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: mocking_device.id")
|
||||
public Long getId() {
|
||||
return id;
|
||||
@ -98,4 +129,14 @@ public class MockingDevice {
|
||||
public void setEnable(Boolean enable) {
|
||||
this.enable = enable;
|
||||
}
|
||||
|
||||
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: mocking_device.live_stream")
|
||||
public String getLiveStream() {
|
||||
return liveStream;
|
||||
}
|
||||
|
||||
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: mocking_device.live_stream")
|
||||
public void setLiveStream(String liveStream) {
|
||||
this.liveStream = liveStream == null ? null : liveStream.trim();
|
||||
}
|
||||
}
|
@ -6,4 +6,7 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
public interface MockingOperateTableMapper {
|
||||
// int createNewTable(@Param("tableName")String tableName);
|
||||
void createDeviceTable();
|
||||
void dropProcedureUpdateDeviceTable();
|
||||
void createProcedureUpdateDeviceTable();
|
||||
void callProcedureUpdateDeviceTable();
|
||||
}
|
||||
|
@ -17,4 +17,24 @@
|
||||
UNIQUE KEY `gb_device_id` (`gb_device_id`,`gb_channel_id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
</update>
|
||||
|
||||
<update id="dropProcedureUpdateDeviceTable">
|
||||
DROP PROCEDURE IF EXISTS update_mocking_device;
|
||||
</update>
|
||||
|
||||
<update id="createProcedureUpdateDeviceTable">
|
||||
CREATE PROCEDURE update_mocking_device()
|
||||
BEGIN
|
||||
IF ISNULL((SELECT 1 FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = DATABASE()
|
||||
AND TABLE_NAME = "mocking_device"
|
||||
AND COLUMN_NAME = "live_stream" LIMIT 1)) THEN
|
||||
ALTER TABLE `mocking_device` ADD COLUMN live_stream VARCHAR(255) DEFAULT NULL;
|
||||
END IF;
|
||||
END;
|
||||
</update>
|
||||
|
||||
<update id="callProcedureUpdateDeviceTable">
|
||||
CALL update_mocking_device();
|
||||
</update>
|
||||
</mapper>
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>cn.skcks.docking</groupId>
|
||||
<artifactId>gb28181-mocking</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<version>0.1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<groupId>cn.skcks.docking.gb28181</groupId>
|
||||
|
@ -1,74 +0,0 @@
|
||||
package cn.skcks.docking.gb28181.mocking.core.sip.gb28181.sdp;
|
||||
|
||||
import com.fasterxml.jackson.databind.json.JsonMapper;
|
||||
import gov.nist.core.Separators;
|
||||
import gov.nist.javax.sdp.fields.SDPField;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
@Slf4j
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class FormatField extends SDPField {
|
||||
public static final String FORMAT_FIELD_NAME = "f";
|
||||
private static final String FORMAT_FIELD = FORMAT_FIELD_NAME + "=";
|
||||
public FormatField() {
|
||||
super(FORMAT_FIELD);
|
||||
}
|
||||
|
||||
/**
|
||||
* 视频编码格式
|
||||
*/
|
||||
private String videoFormat = "";
|
||||
/**
|
||||
* 视频分辨率
|
||||
*/
|
||||
private String videoRatio = "";
|
||||
/**
|
||||
* 视频帧率
|
||||
*/
|
||||
private String videoFrame = "";
|
||||
/**
|
||||
* 视频码率类型
|
||||
*/
|
||||
private String videoRateType = "";
|
||||
/**
|
||||
* 视频码率大小
|
||||
*/
|
||||
private String videoRateNum = "";
|
||||
/**
|
||||
* 音频编码格式
|
||||
*/
|
||||
private String audioFormat = "";
|
||||
/**
|
||||
* 音频码率大小
|
||||
*/
|
||||
private String audioRateNum = "";
|
||||
/**
|
||||
* 音频采样率
|
||||
*/
|
||||
private String audioSampling = "";
|
||||
|
||||
@SneakyThrows
|
||||
@Override
|
||||
public String encode() {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.append(FORMAT_FIELD);
|
||||
if(!StringUtils.isAllBlank(videoFormat, videoRatio, videoFrame, videoRateType, videoRateNum,audioFormat, audioRateNum, audioSampling)){
|
||||
String video = StringUtils.joinWith("/", "v", videoFormat, videoRatio, videoFrame, videoRateType, videoRateNum);
|
||||
String audio = StringUtils.joinWith("/", "a", audioFormat, audioRateNum, audioSampling);
|
||||
stringBuilder.append(StringUtils.joinWith("/",video,audio));
|
||||
}
|
||||
stringBuilder.append(Separators.NEWLINE);
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
|
||||
public String toString(){
|
||||
return encode();
|
||||
}
|
||||
}
|
@ -1,75 +0,0 @@
|
||||
package cn.skcks.docking.gb28181.mocking.core.sip.gb28181.sdp;
|
||||
|
||||
import gov.nist.javax.sdp.fields.SDPField;
|
||||
import gov.nist.javax.sdp.parser.Lexer;
|
||||
import gov.nist.javax.sdp.parser.SDPParser;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.text.ParseException;
|
||||
|
||||
@Slf4j
|
||||
public class FormatFieldParser extends SDPParser {
|
||||
public FormatFieldParser(String ssrcField) {
|
||||
this.lexer = new Lexer("charLexer", ssrcField);
|
||||
}
|
||||
|
||||
public FormatField formatField() throws ParseException {
|
||||
try {
|
||||
this.lexer.match('f');
|
||||
this.lexer.SPorHT();
|
||||
this.lexer.match('=');
|
||||
this.lexer.SPorHT();
|
||||
|
||||
FormatField formatField = new FormatField();
|
||||
String rest = lexer.getRest().trim();
|
||||
|
||||
String[] split = StringUtils.split(rest, 'a');
|
||||
if(split.length == 0){
|
||||
return formatField;
|
||||
}
|
||||
|
||||
log.info("{}", (Object) split);
|
||||
String video = split[0];
|
||||
String[] videoParams = StringUtils.split(video,"/");
|
||||
log.info("{}", (Object) videoParams);
|
||||
if(videoParams.length > 1){
|
||||
formatField.setVideoFormat(videoParams[1]);
|
||||
}
|
||||
if(videoParams.length > 2){
|
||||
formatField.setVideoRatio(videoParams[2]);
|
||||
}
|
||||
if(videoParams.length > 3){
|
||||
formatField.setVideoFrame(videoParams[3]);
|
||||
}
|
||||
if(videoParams.length > 4){
|
||||
formatField.setVideoRateType(videoParams[4]);
|
||||
}
|
||||
if(videoParams.length > 5){
|
||||
formatField.setVideoRateNum(videoParams[5]);
|
||||
}
|
||||
if(split.length < 2){
|
||||
return formatField;
|
||||
}
|
||||
String audio = split[1];
|
||||
String[] audioParams = audio.split("/");
|
||||
if(audioParams.length > 0){
|
||||
formatField.setAudioFormat(audioParams[0]);
|
||||
}
|
||||
if(audioParams.length > 1){
|
||||
formatField.setAudioRateNum(audioParams[1]);
|
||||
}
|
||||
if(audioParams.length > 2){
|
||||
formatField.setAudioSampling(audioParams[2]);
|
||||
}
|
||||
return formatField;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw lexer.createParseException();
|
||||
}
|
||||
}
|
||||
|
||||
public SDPField parse() throws ParseException {
|
||||
return this.formatField();
|
||||
}
|
||||
}
|
@ -1,90 +0,0 @@
|
||||
package cn.skcks.docking.gb28181.mocking.core.sip.gb28181.sdp;
|
||||
|
||||
import cn.skcks.docking.gb28181.core.sip.gb28181.sdp.GB28181Description;
|
||||
import cn.skcks.docking.gb28181.core.sip.gb28181.sdp.SsrcField;
|
||||
import gov.nist.core.ParserCore;
|
||||
import gov.nist.javax.sdp.SessionDescriptionImpl;
|
||||
import gov.nist.javax.sdp.fields.SDPField;
|
||||
import gov.nist.javax.sdp.parser.Lexer;
|
||||
import gov.nist.javax.sdp.parser.SDPParser;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.Vector;
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public class GB28181DescriptionParser extends ParserCore {
|
||||
protected Lexer lexer;
|
||||
protected Vector sdpMessage;
|
||||
|
||||
public GB28181DescriptionParser(Vector sdpMessage) {
|
||||
this.sdpMessage = sdpMessage;
|
||||
}
|
||||
|
||||
public GB28181DescriptionParser(String message) {
|
||||
int start = 0;
|
||||
String line = null;
|
||||
// Return trivially if there is no sdp announce message
|
||||
// to be parsed. Bruno Konik noticed this bug.
|
||||
if (message == null) return;
|
||||
sdpMessage = new Vector();
|
||||
// Strip off leading and trailing junk.
|
||||
String sdpAnnounce = message.trim() + "\r\n";
|
||||
// Bug fix by Andreas Bystrom.
|
||||
while (start < sdpAnnounce.length()) {
|
||||
// Major re-write by Ricardo Borba.
|
||||
int lfPos = sdpAnnounce.indexOf("\n", start);
|
||||
int crPos = sdpAnnounce.indexOf("\r", start);
|
||||
|
||||
if (lfPos >= 0 && crPos < 0) {
|
||||
// there are only "\n" separators
|
||||
line = sdpAnnounce.substring(start, lfPos);
|
||||
start = lfPos + 1;
|
||||
} else if (lfPos < 0 && crPos >= 0) {
|
||||
//bug fix: there are only "\r" separators
|
||||
line = sdpAnnounce.substring(start, crPos);
|
||||
start = crPos + 1;
|
||||
} else if (lfPos >= 0 && crPos >= 0) {
|
||||
// there are "\r\n" or "\n\r" (if exists) separators
|
||||
if (lfPos > crPos) {
|
||||
// assume "\r\n" for now
|
||||
line = sdpAnnounce.substring(start, crPos);
|
||||
// Check if the "\r" and "\n" are close together
|
||||
if (lfPos == crPos + 1) {
|
||||
start = lfPos + 1; // "\r\n"
|
||||
} else {
|
||||
start = crPos + 1; // "\r" followed by the next record and a "\n" further away
|
||||
}
|
||||
} else {
|
||||
// assume "\n\r" for now
|
||||
line = sdpAnnounce.substring(start, lfPos);
|
||||
// Check if the "\n" and "\r" are close together
|
||||
if (crPos == lfPos + 1) {
|
||||
start = crPos + 1; // "\n\r"
|
||||
} else {
|
||||
start = lfPos + 1; // "\n" followed by the next record and a "\r" further away
|
||||
}
|
||||
}
|
||||
} else if (lfPos < 0 && crPos < 0) { // end
|
||||
break;
|
||||
}
|
||||
sdpMessage.addElement(line);
|
||||
}
|
||||
}
|
||||
|
||||
public GB28181Description parse() throws ParseException {
|
||||
GB28181Description retval = GB28181Description.Convertor.convert(new SessionDescriptionImpl());
|
||||
for (int i = 0; i < sdpMessage.size(); i++) {
|
||||
String field = (String) sdpMessage.elementAt(i);
|
||||
SDPParser sdpParser = GB28181DescriptionParserFactory.createParser(field);
|
||||
SDPField sdpField = null;
|
||||
if (sdpParser != null) {
|
||||
sdpField = sdpParser.parse();
|
||||
}
|
||||
retval.addField(sdpField);
|
||||
if (sdpField instanceof SsrcField ssrc) {
|
||||
retval.setSsrcField(ssrc);
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
package cn.skcks.docking.gb28181.mocking.core.sip.gb28181.sdp;
|
||||
|
||||
import gov.nist.javax.sdp.parser.Lexer;
|
||||
import gov.nist.javax.sdp.parser.ParserFactory;
|
||||
import gov.nist.javax.sdp.parser.SDPParser;
|
||||
|
||||
import java.text.ParseException;
|
||||
|
||||
public class GB28181DescriptionParserFactory {
|
||||
public static SDPParser createParser(String field) throws ParseException {
|
||||
String fieldName = Lexer.getFieldName(field);
|
||||
if(fieldName.equalsIgnoreCase("y")){
|
||||
return new SsrcFieldParser(field);
|
||||
}
|
||||
if(fieldName.equalsIgnoreCase("f")){
|
||||
return new FormatFieldParser(field);
|
||||
}
|
||||
return ParserFactory.createParser(field);
|
||||
}
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
package cn.skcks.docking.gb28181.mocking.core.sip.gb28181.sdp;
|
||||
|
||||
import cn.skcks.docking.gb28181.core.sip.gb28181.sdp.SsrcField;
|
||||
import gov.nist.javax.sdp.fields.SDPField;
|
||||
import gov.nist.javax.sdp.parser.Lexer;
|
||||
import gov.nist.javax.sdp.parser.SDPParser;
|
||||
|
||||
import java.text.ParseException;
|
||||
|
||||
public class SsrcFieldParser extends SDPParser {
|
||||
public SsrcFieldParser(String ssrcField) {
|
||||
this.lexer = new Lexer("charLexer", ssrcField);
|
||||
}
|
||||
|
||||
public SsrcField ssrcField() throws ParseException {
|
||||
try {
|
||||
this.lexer.match('y');
|
||||
this.lexer.SPorHT();
|
||||
this.lexer.match('=');
|
||||
this.lexer.SPorHT();
|
||||
|
||||
SsrcField ssrcField = new SsrcField();
|
||||
String rest = lexer.getRest().trim();
|
||||
ssrcField.setSsrc(rest);
|
||||
return ssrcField;
|
||||
} catch (Exception e) {
|
||||
throw lexer.createParseException();
|
||||
}
|
||||
}
|
||||
|
||||
public SDPField parse() throws ParseException {
|
||||
return this.ssrcField();
|
||||
}
|
||||
}
|
@ -1,20 +1,19 @@
|
||||
package cn.skcks.docking.gb28181.mocking.core.sip.message.processor.invite.request;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.skcks.docking.gb28181.core.sip.gb28181.sdp.GB28181Description;
|
||||
import cn.skcks.docking.gb28181.core.sip.gb28181.sdp.MediaSdpHelper;
|
||||
import cn.skcks.docking.gb28181.core.sip.listener.SipListener;
|
||||
import cn.skcks.docking.gb28181.core.sip.message.processor.MessageProcessor;
|
||||
import cn.skcks.docking.gb28181.core.sip.message.subscribe.GenericSubscribe;
|
||||
import cn.skcks.docking.gb28181.media.proxy.ZlmMediaService;
|
||||
import cn.skcks.docking.gb28181.mocking.config.sip.FfmpegConfig;
|
||||
import cn.skcks.docking.gb28181.mocking.core.sip.gb28181.sdp.GB28181DescriptionParser;
|
||||
import cn.skcks.docking.gb28181.mocking.core.sip.message.subscribe.SipSubscribe;
|
||||
import cn.skcks.docking.gb28181.mocking.core.sip.response.SipResponseBuilder;
|
||||
import cn.skcks.docking.gb28181.mocking.core.sip.sender.SipSender;
|
||||
import cn.skcks.docking.gb28181.mocking.orm.mybatis.dynamic.model.MockingDevice;
|
||||
import cn.skcks.docking.gb28181.mocking.service.device.DeviceProxyService;
|
||||
import cn.skcks.docking.gb28181.mocking.service.device.DeviceService;
|
||||
import cn.skcks.docking.gb28181.sdp.GB28181Description;
|
||||
import cn.skcks.docking.gb28181.sdp.GB28181SDPBuilder;
|
||||
import cn.skcks.docking.gb28181.sdp.parser.GB28181DescriptionParser;
|
||||
import gov.nist.core.Separators;
|
||||
import gov.nist.javax.sdp.SessionDescriptionImpl;
|
||||
import gov.nist.javax.sdp.TimeDescriptionImpl;
|
||||
@ -196,7 +195,7 @@ public class InviteRequestProcessor implements MessageProcessor {
|
||||
|
||||
SdpFactory sdpFactory = SdpFactory.getInstance();
|
||||
SessionDescriptionImpl sessionDescription = new SessionDescriptionImpl();
|
||||
GB28181Description description = GB28181Description.Convertor.convert(sessionDescription);
|
||||
GB28181Description description = new GB28181Description(sessionDescription);
|
||||
description.setVersion(sdpFactory.createVersion(0));
|
||||
// 目前只配置 ipv4
|
||||
description.setOrigin(sdpFactory.createOrigin(channelId, 0, 0, ConnectionField.IN, Connection.IP4, senderIp));
|
||||
@ -212,7 +211,7 @@ public class InviteRequestProcessor implements MessageProcessor {
|
||||
String protocol = ((MediaDescription) gb28181Description.getMediaDescriptions(true).get(0)).getMedia().getProtocol();
|
||||
MediaDescription respMediaDescription = SdpFactory.getInstance().createMediaDescription("video", port, 0, StringUtils.isBlank(protocol)?SdpConstants.RTP_AVP:protocol, mediaTypeCodes);
|
||||
Arrays.stream(mediaTypeCodes).forEach((k)->{
|
||||
String v = MediaSdpHelper.RTPMAP.get(k);
|
||||
String v = GB28181SDPBuilder.RTPMAP.get(k);
|
||||
respMediaDescription.addAttribute((AttributeField) SdpFactory.getInstance().createAttribute(SdpConstants.RTPMAP, StringUtils.joinWith(Separators.SP,k,v)));
|
||||
});
|
||||
respMediaDescription.addAttribute((AttributeField) SdpFactory.getInstance().createAttribute("sendonly", null));
|
||||
|
@ -36,4 +36,9 @@ public class AckSubscribe implements GenericSubscribe<SIPRequest> {
|
||||
public void delPublisher(String key) {
|
||||
Helper.delPublisher(publishers, key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void complete(String key) {
|
||||
delPublisher(key);
|
||||
}
|
||||
}
|
||||
|
@ -36,4 +36,9 @@ public class ByeSubscribe implements GenericSubscribe<SIPRequest> {
|
||||
public void delPublisher(String key) {
|
||||
Helper.delPublisher(publishers, key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void complete(String key) {
|
||||
delPublisher(key);
|
||||
}
|
||||
}
|
||||
|
@ -36,4 +36,9 @@ public class RegisterSubscribe implements GenericSubscribe<SIPResponse> {
|
||||
public void delPublisher(String key) {
|
||||
Helper.delPublisher(publishers, key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void complete(String key) {
|
||||
delPublisher(key);
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
package cn.skcks.docking.gb28181.mocking.core.sip.response;
|
||||
|
||||
import cn.skcks.docking.gb28181.core.sip.gb28181.constant.GB28181Constant;
|
||||
import cn.skcks.docking.gb28181.core.sip.gb28181.sdp.GB28181Description;
|
||||
import cn.skcks.docking.gb28181.core.sip.message.MessageHelper;
|
||||
import cn.skcks.docking.gb28181.core.sip.utils.SipUtil;
|
||||
import cn.skcks.docking.gb28181.sdp.GB28181Description;
|
||||
import gov.nist.javax.sip.message.MessageFactoryImpl;
|
||||
import gov.nist.javax.sip.message.SIPRequest;
|
||||
import gov.nist.javax.sip.message.SIPResponse;
|
||||
|
@ -24,5 +24,13 @@ public class MockingOrmInitService {
|
||||
public void init(){
|
||||
log.info("[orm] 自动建表");
|
||||
mapper.createDeviceTable();
|
||||
|
||||
log.info("[orm] 自动更新表结构");
|
||||
mapper.dropProcedureUpdateDeviceTable();
|
||||
mapper.createProcedureUpdateDeviceTable();
|
||||
mapper.callProcedureUpdateDeviceTable();
|
||||
mapper.dropProcedureUpdateDeviceTable();
|
||||
|
||||
log.info("[orm] 初始化完成");
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.util.URLUtil;
|
||||
import cn.skcks.docking.gb28181.common.xml.XmlUtils;
|
||||
import cn.skcks.docking.gb28181.core.sip.gb28181.constant.GB28181Constant;
|
||||
import cn.skcks.docking.gb28181.core.sip.gb28181.sdp.GB28181Description;
|
||||
import cn.skcks.docking.gb28181.core.sip.message.subscribe.GenericSubscribe;
|
||||
import cn.skcks.docking.gb28181.core.sip.utils.SipUtil;
|
||||
import cn.skcks.docking.gb28181.media.config.ZlmMediaConfig;
|
||||
@ -17,7 +16,6 @@ import cn.skcks.docking.gb28181.media.proxy.ZlmMediaService;
|
||||
import cn.skcks.docking.gb28181.mocking.config.sip.DeviceProxyConfig;
|
||||
import cn.skcks.docking.gb28181.mocking.config.sip.ZlmHookConfig;
|
||||
import cn.skcks.docking.gb28181.mocking.config.sip.ZlmRtmpConfig;
|
||||
import cn.skcks.docking.gb28181.mocking.core.sip.gb28181.sdp.GB28181DescriptionParser;
|
||||
import cn.skcks.docking.gb28181.mocking.core.sip.message.processor.message.request.notify.dto.MediaStatusRequestDTO;
|
||||
import cn.skcks.docking.gb28181.mocking.core.sip.message.subscribe.SipSubscribe;
|
||||
import cn.skcks.docking.gb28181.mocking.core.sip.request.SipRequestBuilder;
|
||||
@ -26,7 +24,12 @@ import cn.skcks.docking.gb28181.mocking.core.sip.sender.SipSender;
|
||||
import cn.skcks.docking.gb28181.mocking.orm.mybatis.dynamic.model.MockingDevice;
|
||||
import cn.skcks.docking.gb28181.mocking.service.ffmpeg.FfmpegSupportService;
|
||||
import cn.skcks.docking.gb28181.mocking.service.zlm.hook.ZlmStreamChangeHookService;
|
||||
import com.github.rholder.retry.*;
|
||||
import cn.skcks.docking.gb28181.sdp.GB28181Description;
|
||||
import cn.skcks.docking.gb28181.sdp.parser.GB28181DescriptionParser;
|
||||
import com.github.rholder.retry.Retryer;
|
||||
import com.github.rholder.retry.RetryerBuilder;
|
||||
import com.github.rholder.retry.StopStrategies;
|
||||
import com.github.rholder.retry.WaitStrategies;
|
||||
import gov.nist.javax.sip.message.SIPRequest;
|
||||
import jakarta.annotation.PreDestroy;
|
||||
import lombok.*;
|
||||
|
@ -7,11 +7,11 @@
|
||||
<parent>
|
||||
<groupId>cn.skcks.docking</groupId>
|
||||
<artifactId>gb28181-mocking</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<version>0.1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>gb28181-mocking-starter</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<version>0.1.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<properties>
|
||||
|
@ -24,8 +24,8 @@ spring:
|
||||
username: root
|
||||
password: 123456a
|
||||
url: jdbc:mysql://192.168.1.241:3306/gb28181_docking_platform?createDatabaseIfNotExist=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
|
||||
profiles:
|
||||
active: local
|
||||
# profiles:
|
||||
# active: local
|
||||
|
||||
gb28181:
|
||||
# 作为28181服务器的配置
|
||||
@ -36,7 +36,7 @@ gb28181:
|
||||
ip:
|
||||
# - 10.27.0.1
|
||||
- 192.168.0.195
|
||||
- 172.16.1.90
|
||||
#- 172.16.1.90
|
||||
# - 192.168.10.195
|
||||
# - 10.10.10.20
|
||||
# - 10.27.0.6
|
||||
@ -63,15 +63,15 @@ gb28181:
|
||||
|
||||
media:
|
||||
local:
|
||||
hook: http://192.168.3.11:18182/zlm/hook
|
||||
hook: http://192.168.0.195:18182/zlm/hook
|
||||
ip: 192.168.3.12
|
||||
url: 'http://192.168.3.12:5081'
|
||||
url: 'http://192.168.3.12:5082'
|
||||
# url: 'http://10.10.10.200:12580/anything/'
|
||||
id: amrWMKmbKqoBjRQ9
|
||||
# secret: 035c73f7-bb6b-4889-a715-d9eb2d1925cc
|
||||
secret: 4155cca6-2f9f-11ee-85e6-8de4ce2e7333
|
||||
rtmp:
|
||||
port: 1935
|
||||
port: 1937
|
||||
proxy:
|
||||
device:
|
||||
url: http://192.168.2.3:18183
|
||||
@ -79,15 +79,27 @@ ffmpeg-support:
|
||||
task:
|
||||
# 最大同时推流任务数, <= 0 时不做限制
|
||||
max: 4
|
||||
ffmpeg: /usr/bin/ffmpeg/ffmpeg
|
||||
ffprobe: /usr/bin/ffmpeg/ffprobe
|
||||
# ffmpeg: /usr/bin/ffmpeg/ffmpeg
|
||||
# ffprobe: /usr/bin/ffmpeg/ffprobe
|
||||
ffmpeg: C:\ffmpeg\bin\ffmpeg.exe
|
||||
ffprobe: D:\Soft\Captura\ffmpeg\ffprobe.exe
|
||||
# rtp:
|
||||
# download: -i
|
||||
# input: -re -i
|
||||
# output: -vcodec h264 -acodec aac -preset ultrafast -vf scale=640:-1 -f flv
|
||||
# debug:
|
||||
# download: false
|
||||
# input: false
|
||||
# output: false
|
||||
rtp:
|
||||
download: -i
|
||||
input: -re -i
|
||||
output: -vcodec h264 -acodec aac -preset ultrafast -vf scale=640:-1 -f flv
|
||||
input: -thread_queue_size 128 -re -i http://192.168.3.12:5081/live/test.live.flv
|
||||
# input: -re -i
|
||||
output: -tune zerolatency -vcodec libx264 -acodec aac -preset ultrafast -vf scale=640:-1 -f flv #rtp_mpegts
|
||||
# output: -vcodec h264 -acodec aac -vf scale=640:-1 -f rtp_mpegts # -rtsp_transport tcp
|
||||
download: -i E:\Repository\other\happytime-gb28181-device-x64\666.mp4 -filter:v "setpts=4.0*PTS"
|
||||
debug:
|
||||
download: false
|
||||
input: false
|
||||
download: true
|
||||
input: true
|
||||
output: false
|
||||
|
||||
# [可选] 日志配置, 一般不需要改
|
||||
|
4
pom.xml
4
pom.xml
@ -10,7 +10,7 @@
|
||||
</parent>
|
||||
<groupId>cn.skcks.docking</groupId>
|
||||
<artifactId>gb28181-mocking</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<version>0.1.0-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>gb28181-docking-platform-mocking</name>
|
||||
<description>GB28181 Docking Platform</description>
|
||||
@ -57,7 +57,7 @@
|
||||
<!-- <docker.registry.password>XXX</docker.registry.password>-->
|
||||
<docker.maven.plugin.version>1.4.13</docker.maven.plugin.version>
|
||||
|
||||
<gb28181.docking.version>0.0.1-SNAPSHOT</gb28181.docking.version>
|
||||
<gb28181.docking.version>0.1.0-SNAPSHOT</gb28181.docking.version>
|
||||
</properties>
|
||||
|
||||
<profiles>
|
||||
|
Loading…
Reference in New Issue
Block a user