diff --git a/README.md b/README.md index f286f79..27f14d9 100644 --- a/README.md +++ b/README.md @@ -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 ``` ### 打包到本地私仓 diff --git a/gb28181-mocking-api/pom.xml b/gb28181-mocking-api/pom.xml index 4407466..e1627c3 100644 --- a/gb28181-mocking-api/pom.xml +++ b/gb28181-mocking-api/pom.xml @@ -6,7 +6,7 @@ cn.skcks.docking gb28181-mocking - 0.0.1-SNAPSHOT + 0.1.0-SNAPSHOT cn.skcks.docking.gb28181 diff --git a/gb28181-mocking-orm/pom.xml b/gb28181-mocking-orm/pom.xml index 7a88c0d..d796535 100644 --- a/gb28181-mocking-orm/pom.xml +++ b/gb28181-mocking-orm/pom.xml @@ -6,7 +6,7 @@ cn.skcks.docking gb28181-mocking - 0.0.1-SNAPSHOT + 0.1.0-SNAPSHOT cn.skcks.docking.gb28181 diff --git a/gb28181-mocking-orm/src/main/java/cn/skcks/docking/gb28181/mocking/orm/mybatis/dynamic/mapper/MockingDeviceDynamicSqlSupport.java b/gb28181-mocking-orm/src/main/java/cn/skcks/docking/gb28181/mocking/orm/mybatis/dynamic/mapper/MockingDeviceDynamicSqlSupport.java index 15da2e9..4ab2373 100644 --- a/gb28181-mocking-orm/src/main/java/cn/skcks/docking/gb28181/mocking/orm/mybatis/dynamic/mapper/MockingDeviceDynamicSqlSupport.java +++ b/gb28181-mocking-orm/src/main/java/cn/skcks/docking/gb28181/mocking/orm/mybatis/dynamic/mapper/MockingDeviceDynamicSqlSupport.java @@ -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 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 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 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 gbChannelId = mockingDevice.gbChannelId; + /** + * Database Column Remarks: + * 设备/通道名称 + */ @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: mocking_device.name") public static final SqlColumn name = mockingDevice.name; + /** + * Database Column Remarks: + * 设备地址信息 + */ @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: mocking_device.address") public static final SqlColumn address = mockingDevice.address; + /** + * Database Column Remarks: + * 是否启用 + */ @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: mocking_device.enable") public static final SqlColumn enable = mockingDevice.enable; + /** + * Database Column Remarks: + * 实时视频流地址 + */ + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: mocking_device.live_stream") + public static final SqlColumn liveStream = mockingDevice.liveStream; + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: mocking_device") public static final class MockingDevice extends AliasableSqlTable { public final SqlColumn id = column("id", JDBCType.BIGINT); @@ -46,6 +77,8 @@ public final class MockingDeviceDynamicSqlSupport { public final SqlColumn enable = column("enable", JDBCType.BIT); + public final SqlColumn liveStream = column("live_stream", JDBCType.VARCHAR); + public MockingDevice() { super("mocking_device", MockingDevice::new); } diff --git a/gb28181-mocking-orm/src/main/java/cn/skcks/docking/gb28181/mocking/orm/mybatis/dynamic/mapper/MockingDeviceMapper.java b/gb28181-mocking-orm/src/main/java/cn/skcks/docking/gb28181/mocking/orm/mybatis/dynamic/mapper/MockingDeviceMapper.java index dc3993e..9b86134 100644 --- a/gb28181-mocking-orm/src/main/java/cn/skcks/docking/gb28181/mocking/orm/mybatis/dynamic/mapper/MockingDeviceMapper.java +++ b/gb28181-mocking-orm/src/main/java/cn/skcks/docking/gb28181/mocking/orm/mybatis/dynamic/mapper/MockingDeviceMapper.java @@ -32,7 +32,7 @@ import org.mybatis.dynamic.sql.util.mybatis3.MyBatis3Utils; @Mapper public interface MockingDeviceMapper extends CommonCountMapper, CommonDeleteMapper, CommonInsertMapper, 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 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)) ); } diff --git a/gb28181-mocking-orm/src/main/java/cn/skcks/docking/gb28181/mocking/orm/mybatis/dynamic/model/MockingDevice.java b/gb28181-mocking-orm/src/main/java/cn/skcks/docking/gb28181/mocking/orm/mybatis/dynamic/model/MockingDevice.java index 2e669ff..e0f9bac 100644 --- a/gb28181-mocking-orm/src/main/java/cn/skcks/docking/gb28181/mocking/orm/mybatis/dynamic/model/MockingDevice.java +++ b/gb28181-mocking-orm/src/main/java/cn/skcks/docking/gb28181/mocking/orm/mybatis/dynamic/model/MockingDevice.java @@ -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(); + } } \ No newline at end of file diff --git a/gb28181-mocking-orm/src/main/java/cn/skcks/docking/gb28181/mocking/orm/mybatis/operation/MockingOperateTableMapper.java b/gb28181-mocking-orm/src/main/java/cn/skcks/docking/gb28181/mocking/orm/mybatis/operation/MockingOperateTableMapper.java index a52f5de..1aaf579 100644 --- a/gb28181-mocking-orm/src/main/java/cn/skcks/docking/gb28181/mocking/orm/mybatis/operation/MockingOperateTableMapper.java +++ b/gb28181-mocking-orm/src/main/java/cn/skcks/docking/gb28181/mocking/orm/mybatis/operation/MockingOperateTableMapper.java @@ -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(); } diff --git a/gb28181-mocking-orm/src/main/java/cn/skcks/docking/gb28181/mocking/orm/mybatis/operation/MockingOperateTableMapper.xml b/gb28181-mocking-orm/src/main/java/cn/skcks/docking/gb28181/mocking/orm/mybatis/operation/MockingOperateTableMapper.xml index 86721ad..da3b52a 100644 --- a/gb28181-mocking-orm/src/main/java/cn/skcks/docking/gb28181/mocking/orm/mybatis/operation/MockingOperateTableMapper.xml +++ b/gb28181-mocking-orm/src/main/java/cn/skcks/docking/gb28181/mocking/orm/mybatis/operation/MockingOperateTableMapper.xml @@ -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; + + + DROP PROCEDURE IF EXISTS update_mocking_device; + + + + 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; + + + + CALL update_mocking_device(); + diff --git a/gb28181-mocking-service/pom.xml b/gb28181-mocking-service/pom.xml index d7be108..6616ffc 100644 --- a/gb28181-mocking-service/pom.xml +++ b/gb28181-mocking-service/pom.xml @@ -6,7 +6,7 @@ cn.skcks.docking gb28181-mocking - 0.0.1-SNAPSHOT + 0.1.0-SNAPSHOT cn.skcks.docking.gb28181 diff --git a/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/core/sip/gb28181/sdp/FormatField.java b/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/core/sip/gb28181/sdp/FormatField.java deleted file mode 100644 index b735c45..0000000 --- a/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/core/sip/gb28181/sdp/FormatField.java +++ /dev/null @@ -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(); - } -} diff --git a/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/core/sip/gb28181/sdp/FormatFieldParser.java b/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/core/sip/gb28181/sdp/FormatFieldParser.java deleted file mode 100644 index c538486..0000000 --- a/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/core/sip/gb28181/sdp/FormatFieldParser.java +++ /dev/null @@ -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(); - } -} diff --git a/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/core/sip/gb28181/sdp/GB28181DescriptionParser.java b/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/core/sip/gb28181/sdp/GB28181DescriptionParser.java deleted file mode 100644 index dc64fcc..0000000 --- a/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/core/sip/gb28181/sdp/GB28181DescriptionParser.java +++ /dev/null @@ -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; - } -} diff --git a/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/core/sip/gb28181/sdp/GB28181DescriptionParserFactory.java b/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/core/sip/gb28181/sdp/GB28181DescriptionParserFactory.java deleted file mode 100644 index bb1cf9c..0000000 --- a/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/core/sip/gb28181/sdp/GB28181DescriptionParserFactory.java +++ /dev/null @@ -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); - } -} diff --git a/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/core/sip/gb28181/sdp/SsrcFieldParser.java b/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/core/sip/gb28181/sdp/SsrcFieldParser.java deleted file mode 100644 index 751a195..0000000 --- a/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/core/sip/gb28181/sdp/SsrcFieldParser.java +++ /dev/null @@ -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(); - } -} diff --git a/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/core/sip/message/processor/invite/request/InviteRequestProcessor.java b/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/core/sip/message/processor/invite/request/InviteRequestProcessor.java index b389d02..dab73ca 100644 --- a/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/core/sip/message/processor/invite/request/InviteRequestProcessor.java +++ b/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/core/sip/message/processor/invite/request/InviteRequestProcessor.java @@ -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)); diff --git a/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/core/sip/message/subscribe/AckSubscribe.java b/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/core/sip/message/subscribe/AckSubscribe.java index ec9eda8..57069a6 100644 --- a/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/core/sip/message/subscribe/AckSubscribe.java +++ b/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/core/sip/message/subscribe/AckSubscribe.java @@ -36,4 +36,9 @@ public class AckSubscribe implements GenericSubscribe { public void delPublisher(String key) { Helper.delPublisher(publishers, key); } + + @Override + public void complete(String key) { + delPublisher(key); + } } diff --git a/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/core/sip/message/subscribe/ByeSubscribe.java b/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/core/sip/message/subscribe/ByeSubscribe.java index d2e70fd..7962633 100644 --- a/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/core/sip/message/subscribe/ByeSubscribe.java +++ b/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/core/sip/message/subscribe/ByeSubscribe.java @@ -36,4 +36,9 @@ public class ByeSubscribe implements GenericSubscribe { public void delPublisher(String key) { Helper.delPublisher(publishers, key); } + + @Override + public void complete(String key) { + delPublisher(key); + } } diff --git a/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/core/sip/message/subscribe/RegisterSubscribe.java b/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/core/sip/message/subscribe/RegisterSubscribe.java index 4f950b5..62d14ca 100644 --- a/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/core/sip/message/subscribe/RegisterSubscribe.java +++ b/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/core/sip/message/subscribe/RegisterSubscribe.java @@ -36,4 +36,9 @@ public class RegisterSubscribe implements GenericSubscribe { public void delPublisher(String key) { Helper.delPublisher(publishers, key); } + + @Override + public void complete(String key) { + delPublisher(key); + } } diff --git a/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/core/sip/response/SipResponseBuilder.java b/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/core/sip/response/SipResponseBuilder.java index fc51d4d..c50ba17 100644 --- a/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/core/sip/response/SipResponseBuilder.java +++ b/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/core/sip/response/SipResponseBuilder.java @@ -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; @@ -26,7 +26,7 @@ public class SipResponseBuilder { request.getToHeader().setTag(SipUtil.generateTag()); } - MessageFactoryImpl messageFactory = (MessageFactoryImpl)MessageHelper.getSipFactory().createMessageFactory(); + MessageFactoryImpl messageFactory = (MessageFactoryImpl) MessageHelper.getSipFactory().createMessageFactory(); // 使用 GB28181 默认编码 否则中文将会乱码 messageFactory.setDefaultContentEncodingCharset(GB28181Constant.CHARSET); SIPResponse response = (SIPResponse)messageFactory.createResponse(status, request); diff --git a/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/orm/MockingOrmInitService.java b/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/orm/MockingOrmInitService.java index 0e8a238..c4571cb 100644 --- a/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/orm/MockingOrmInitService.java +++ b/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/orm/MockingOrmInitService.java @@ -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] 初始化完成"); } } diff --git a/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/service/device/DeviceProxyService.java b/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/service/device/DeviceProxyService.java index b3a7822..9f29f72 100644 --- a/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/service/device/DeviceProxyService.java +++ b/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/service/device/DeviceProxyService.java @@ -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.*; diff --git a/gb28181-mocking-starter/pom.xml b/gb28181-mocking-starter/pom.xml index c2a82a4..70eb546 100644 --- a/gb28181-mocking-starter/pom.xml +++ b/gb28181-mocking-starter/pom.xml @@ -7,11 +7,11 @@ cn.skcks.docking gb28181-mocking - 0.0.1-SNAPSHOT + 0.1.0-SNAPSHOT gb28181-mocking-starter - 0.0.1-SNAPSHOT + 0.1.0-SNAPSHOT jar diff --git a/gb28181-mocking-starter/src/main/resources/application.yml b/gb28181-mocking-starter/src/main/resources/application.yml index 4094729..d37124c 100644 --- a/gb28181-mocking-starter/src/main/resources/application.yml +++ b/gb28181-mocking-starter/src/main/resources/application.yml @@ -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 # [可选] 日志配置, 一般不需要改 diff --git a/pom.xml b/pom.xml index 90a30ab..c1ebea3 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ cn.skcks.docking gb28181-mocking - 0.0.1-SNAPSHOT + 0.1.0-SNAPSHOT pom gb28181-docking-platform-mocking GB28181 Docking Platform @@ -57,7 +57,7 @@ 1.4.13 - 0.0.1-SNAPSHOT + 0.1.0-SNAPSHOT