XSDP

XSDP validates and negotiates WebRTC session descriptions.

WebRTC peers must agree on codecs, encryption fingerprints, and network candidates before media flows. That agreement is written in Session Description Protocol (SDP). XSDP operates on %XMediaLib.SDP{} structs from xmedialib for parse/encode, then checks WebRTC rules and builds answers.

Validation

{:ok, sdp} = XSDP.validate(sdp_binary, ice_role: :full)
{:ok, answer} =
XSDP.validate_answer(offer, answer, ice_role: :lite, strict: false)

Checks BUNDLE mid consistency, DTLS fingerprints, RTCP-mux offer/answer rules, SCTP data-channel port negotiation, and ICE full vs lite role constraints.

XSDP.ICE.shape_for_role/2 adjusts session-level a=ice-lite.

Answer an offer body

{:ok, answer_bin} =
XSDP.answer_offer(offer_bin,
capabilities: %{
codecs: [%{name: "opus", clock_rate: 48000, encoding_params: "2"}],
extmaps: ["urn:ietf:params:rtp-hdrext:ssrc-audio-level"]
}
)

Session and answers

session = XSDP.Session.new(ice_role: :full)
{:ok, session} = XSDP.Session.set_remote_description(session, offer)
{:ok, answer} =
XSDP.Session.create_answer(session,
capabilities: %{
codecs: [%{name: "opus", clock_rate: 48000, encoding_params: "2"}],
extmaps: ["urn:ietf:params:rtp-hdrext:ssrc-audio-level"]
}
)
{:ok, session} = XSDP.Session.set_local_description(session, answer)

XSDP.Negotiator.negotiate_answer/3 intersects codecs, fmtp, extmaps, and SCTP fields against local capabilities.

Trickle ICE

{:ok, session} =
XSDP.Session.TrickleICE.add_remote_candidate(session, %{
mid: "0",
candidate: candidate_struct
})
{:ok, session} =
XSDP.Session.TrickleICE.add_remote_candidate(session, %{
mid: "0",
end_of_candidates: true
})

RFCs

Installation

def deps do
[
{:xmedialib, "~> 0.3.0"},
{:xsdp, "~> 0.1.0"}
]
end

Contact

For questions or suggestions, email experts@xirsys.com

Copyright (c) 2013 - 2026 Jahred Love & Xirsys LLC

All rights reserved.

XSDP is licensed by Xirsys, with permission, under the Apache License Version 2.0. See LICENSE for the full license text.