RFC 8866 SDP parser, canonical writer, validator and RFC 3264 offer/answer analysis toolkit for MoonBit.
match @sdp.parse(input) {
Err(error) => println(error.to_display())
Ok(document) => {
println(document.to_debug_string())
println(@sdp.validate(document).to_text())
}
}D:\Moonbit\bin\moon.exe test --target native
D:\Moonbit\bin\moon.exe run examples/parse --target native
D:\Moonbit\bin\moon.exe run cmd/sdp-tool --target native -- version
.\scripts\verify_all.ps1| 指标 | 结果 |
|---|---|
| 具名测试 | 158 |
| 三目标执行量 | 474 次,全部通过 |
| 确定性属性用例 | 4000 组 |
| 一键验证 | 32/32 步通过 |
| 核心/测试/CLI/示例代码 | 3167/906/70/40 行 |
| MoonBit 非空非注释总计 | 4183 行 |
| 示例 | 5 个,三目标构建通过 |
pub struct Attribute {
name : String
value : String?
line : Int
}pub enum AuditSeverity {
High
Medium
Low
}pub struct Bandwidth {
modifier : String
value : Int
}pub struct Connection {
network_type : String
address_type : String
connection_address : String
ttl : Int?
address_count : Int?
}pub enum Direction {
SendRecv
SendOnly
RecvOnly
Inactive
Unspecified
}pub struct FormatParameters {
format : String
parameters : String
}pub enum IssueSeverity {
Error
Warning
Info
}pub struct Limits {
max_input_bytes : Int
max_lines : Int
max_line_bytes : Int
max_media : Int
max_attributes : Int
max_formats_per_media : Int
max_timings : Int
max_repeats_per_timing : Int
}fn MediaDescription::direction(self : MediaDescription, session_attributes : Array[Attribute]) -> Directionpub struct OfferAnswerIssue {
code : String
media_index : Int
message : String
reference : String
}pub struct OfferAnswerReport {
compatible : Bool
issues : Array[OfferAnswerIssue]
accepted_media : Int
rejected_media : Int
}pub struct Origin {
username : String
session_id : String
session_version : String
network_type : String
address_type : String
unicast_address : String
}pub struct RtpMap {
payload_type : Int
encoding_name : String
clock_rate : Int
encoding_parameters : String?
}pub struct SdpError {
stage : String
kind : String
line : Int
column : Int
context : String
message : String
}pub struct SdpLine {
kind : String
value : String
line : Int
}pub struct SessionDescription {
version : Int
origin : Origin?
session_name : String
information : String?
uri : String?
emails : Array[String]
phones : Array[String]
connection : Connection?
bandwidths : Array[Bandwidth]
timings : Array[Timing]
timezone_adjustments : String?
encryption_key : String?
attributes : Array[Attribute]
media_descriptions : Array[MediaDescription]
source_lines : Array[SdpLine]
raw_source : String
}fn SessionDescription::attributes_named(self : SessionDescription, name : String) -> Array[Attribute]pub struct SessionStats {
media_count : Int
active_media_count : Int
rejected_media_count : Int
session_attribute_count : Int
media_attribute_count : Int
rtp_payload_count : Int
connection_count : Int
bandwidth_count : Int
timing_count : Int
unknown_attribute_count : Int
}pub struct ValidationIssue {
severity : IssueSeverity
code : String
line : Int
scope : String
message : String
reference : String
}fn analyze_offer_answer(offer : SessionDescription, answer : SessionDescription) -> OfferAnswerReportfn canonical_is_idempotent(input : String) -> Boolfn connection(network_type : String, address_type : String, connection_address : String, ttl : Int?, address_count : Int?) -> Connectionfn effective_attribute(document : SessionDescription, media : MediaDescription, name : String) -> String?fn library_version() -> Stringfn limits(max_input_bytes : Int, max_lines : Int, max_line_bytes : Int, max_media : Int, max_attributes : Int, max_formats_per_media : Int, max_timings : Int, max_repeats_per_timing : Int) -> Limitsfn media_description(media : String, port : Int, port_count : Int, protocol : String, formats : Array[String]) -> MediaDescriptionfn origin(username : String, session_id : String, session_version : String, network_type : String, address_type : String, unicast_address : String) -> Originfn parse_options(strict : Bool, allow_lf : Bool, allow_obsolete_key : Bool, limits : Limits) -> ParseOptionsfn registry_snapshot_date() -> Stringfn rtp_map(payload_type : Int, encoding_name : String, clock_rate : Int, encoding_parameters : String?) -> RtpMapfn sdp_error(stage : String, kind : String, line : Int, column : Int, context : String, message : String) -> SdpErrorInstall
Download zipRFC 8866 SDP parser, canonical writer, validator and RFC 3264 offer/answer analysis toolkit for MoonBit.