webrtc_sdp_attr (webrtc v0.1.0)

View Source

SDP attribute codec: maps a= lines to typed terms and back.

Known attributes become {Key, Value} with an atom key (see webrtc_sdp:attribute()); property attributes become {Key, true} and the four direction attributes become {direction, Dir}. Anything else is kept as {Name, Value} with a binary name and the raw value (undefined when the line has no colon), so unknown attributes round trip unchanged and in order.

Transport, ICE, DTLS and SCTP attributes are handled here, RTP ones in webrtc_sdp_rtp.

Summary

Functions

Encode one attribute as the text after a=.

SDP name of a typed attribute key.

Parse one attribute. Value is the text after the first colon, or undefined when there is no colon.

Types

attribute/0

-type attribute() ::
          {rtpmap, webrtc_sdp_rtp:rtpmap()} |
          {fmtp, webrtc_sdp_rtp:fmtp()} |
          {rtcp_fb, webrtc_sdp_rtp:rtcp_fb()} |
          {extmap, webrtc_sdp_rtp:extmap()} |
          {msid, webrtc_sdp_rtp:msid()} |
          {msid_semantic, webrtc_sdp_rtp:msid_semantic()} |
          {ssrc, webrtc_sdp_rtp:ssrc()} |
          {ssrc_group, webrtc_sdp_rtp:ssrc_group()} |
          {rid, webrtc_sdp_rid:rid()} |
          {simulcast, webrtc_sdp_rid:simulcast()} |
          {mid, binary()} |
          {group, #{semantics := binary(), mids := [binary()]}} |
          {ice_ufrag, binary()} |
          {ice_pwd, binary()} |
          {ice_options, [binary(), ...]} |
          {ice_pacing, non_neg_integer()} |
          {candidate,
           #sdp_candidate{foundation :: binary(),
                          component :: 1..256,
                          transport :: binary(),
                          priority :: 1..2147483647,
                          address :: webrtc_sdp_lex:address(),
                          port :: inet:port_number(),
                          type :: host | srflx | prflx | relay | binary(),
                          raddr :: webrtc_sdp_lex:address() | undefined,
                          rport :: inet:port_number() | undefined,
                          tcptype :: active | passive | so | undefined,
                          extensions :: [{binary(), binary()}]}} |
          {fingerprint, fingerprint()} |
          {setup, setup()} |
          {tls_id, binary()} |
          {connection, new | existing} |
          {sctp_port, inet:port_number()} |
          {max_message_size, non_neg_integer()} |
          {sctpmap, sctpmap()} |
          {rtcp, rtcp()} |
          {ptime | maxptime | framerate, number()} |
          {identity, identity()} |
          {label, binary()} |
          {content, [binary(), ...]} |
          {direction, webrtc_sdp_rtp:direction()} |
          {extmap_allow_mixed | bundle_only | ice_lite | ice_mismatch | end_of_candidates | rtcp_mux |
           rtcp_mux_only | rtcp_rsize | cryptex,
           true} |
          {binary(), binary() | undefined}.

fingerprint/0

-type fingerprint() :: #{hash := hash(), value := binary()}.

hash/0

-type hash() :: sha | sha224 | sha256 | sha384 | sha512 | md5 | md2 | binary().

identity/0

-type identity() :: #{assertion := binary(), extensions := [binary()]}.

rtcp/0

-type rtcp() ::
          #{port := inet:port_number(),
            connection :=
                #sdp_connection{nettype :: binary(), addrtype :: binary(), address :: binary()} |
                undefined}.

sctpmap/0

-type sctpmap() ::
          #{port := inet:port_number(), protocol := binary(), streams := pos_integer() | undefined}.

setup/0

-type setup() :: actpass | active | passive | holdconn.

Functions

encode(A)

-spec encode(attribute()) -> iodata().

Encode one attribute as the text after a=.

name(Key)

-spec name(atom()) -> binary().

SDP name of a typed attribute key.

parse(Name, Value)

-spec parse(binary(), binary() | undefined) -> {ok, attribute()} | error.

Parse one attribute. Value is the text after the first colon, or undefined when there is no colon.