Phase 7:GB/T 28181-2016 应用层消息(MANSCDP XML) - #11
Draft
lixuanqun wants to merge 1 commit into
Draft
Conversation
新模块 sip-gb28181(第 10 个模块)
- GbCommand 枚举:覆盖 10 个标准 CmdType
Keepalive / Catalog / DeviceInfo / DeviceStatus / DeviceControl /
DeviceConfig / Alarm / MobilePosition / RecordInfo / Broadcast
· of(wireName) 大小写不敏感、未知抛 IllegalArgumentException
- GbXmlBuilder:手写 XML 构造器
· envelope(rootElement).text(name, value).build()
· 自动 XML declaration + UTF-8
· escape: < > & " '
- GbXmlParser:手写 XML 解析器(针对 GB28181 扁平结构调优)
· 接受 root + 子元素的 name/text 对
· 处理 declaration、self-closing、entity 反转义(含 numeric &#x...)
· 不支持嵌套/属性/命名空间(GB28181 用不到,避免拉 JAXB)
- GbMessages:常用消息建造
· keepaliveXml / catalogQueryXml / deviceInfoQueryXml / deviceStatusQueryXml
· manscdpMessage:把 XML body 包到 SIP MESSAGE 请求里
· Content-Type: Application/MANSCDP+xml
· Via 带 rport、User-Agent 等
· 单调 SN 序列号生成器
测试(11 个)
- GbXmlTest(8 个):build/parse keepalive、Catalog query、unescape entities、
escape special chars、未知 CmdType 拒、case-insensitive lookup
- GbMessagesTest(3 个):manscdpMessage SIP encode→parse→XML parse 全闭环、
Catalog query roundtrip、SN 单调
模块用 -Xlint:-module 局部抑制 'terminal digits in module name' 警告
('gb28181' 是国标编号,命名不可妥协)
mvn verify:10 模块 SUCCESS。总 169 tests。
Co-authored-by: li xuanqun <793005378@qq.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概述
完成第一阶段目标(B 场景):GB28181 国标应用层。新模块
sip-gb28181把 MANSCDP XML 消息纳入协议栈。新模块结构
GbCommand
10 个标准 CmdType:
KEEPALIVE— 心跳CATALOG— 设备目录查询DEVICE_INFO/DEVICE_STATUS/DEVICE_CONTROL/DEVICE_CONFIGALARM— 报警通知MOBILE_POSITION— 移动位置RECORD_INFO— 历史录像查询BROADCAST— 语音广播GbCommand.of(wireName)大小写不敏感;未知 CmdType 抛IllegalArgumentException。XML
GbXmlBuilder—envelope("Notify").text("CmdType", "Keepalive").text("SN", "1").build()GbXmlParser— 处理 declaration、self-closing、entity unescape(含 numeric&#x...)GbMessages
把 MANSCDP XML 封装到 SIP MESSAGE 请求:
Content-Type: Application/MANSCDP+xml测试
11 个新测试:
GbXmlTest(8 个):build/parse Keepalive、Catalog query、entity unescape、escape special chars、未知 CmdType 拒、case-insensitive lookupGbMessagesTest(3 个):完整 SIP encode→parse→XML parse roundtrip、Catalog query、SN 单调验证
工程化细节
模块名
com.sip.gb28181末尾有数字,JPMS 默认-Xlint:module会警告"avoid terminal digits"。该模块本地用-Xlint:all,-module抑制 — GB28181 是国标编号,命名不可妥协。其他模块继续严格 lint。