webrtc_sdp_media (webrtc v0.1.0)

View Source

Queries and updates on parsed SDP for JSEP.

Attribute lookups take the key used in webrtc_sdp:attribute() (an atom for typed attributes, a binary for others). Functions taking both a media section and the session apply the session-level fallback rules: ice-ufrag, ice-pwd and ice-options (RFC 8839 §5.4, §5.6), fingerprint (RFC 8122 §5), setup (RFC 4145 §4) and direction (RFC 8866 §6.7).

  [Audio | _] = webrtc_sdp_media:sections(Sdp),
  {ok, #{ufrag := U, pwd := P}} = webrtc_sdp_media:ice_credentials(Audio, Sdp),
  [#{name := <<"opus">>} | _] = webrtc_sdp_media:codecs(Audio).

Summary

Functions

Append an attribute.

First value of attribute Key at this level only.

All values of attribute Key at this level, in order.

Attributes describing Codecs: for each codec its rtpmap, its rtcp-fb lines, then its fmtp when it has parameters (the order used by libwebrtc).

Codecs of an RTP media section in m= line order, merging rtpmap, fmtp and rtcp-fb. Wildcard (*) feedback is copied into every codec. A payload type without rtpmap uses the RFC 3551 static assignment; one that has neither is skipped.

Media direction; defaults to sendrecv (RFC 8866 §6.7).

First value of Key in the media section, else at session level.

Values of Key in the media section if there is any, else the session-level values. Levels are not merged.

Fingerprints for a media section: the media-level ones if any, else the session-level ones (RFC 8122 §5).

Mid lists of the session-level groups with these semantics, for example groups(<<"BUNDLE">>, Sdp).

ICE credentials of a media section, each falling back to the session level (RFC 8839 §5.4).

True when the session declares a=ice-lite (session level only).

The Ta the session asks for (a=ice-pacing, session level, RFC 8839 §5.5), 50 ms when absent.

Payload types of the m= line, for RTP media.

Replace the first Key attribute (dropping the others), or append.

The media sections in order.

Replace the codecs of a media section: the m= line payload types and the rtpmap, fmtp and rtcp-fb attributes. The new codec attributes take the place of the first old one; other attributes keep their order.

a=setup role, media level first. JSEP (RFC 8842 §5.1) requires the attribute, so an absent one is reported rather than defaulted.

Types

codec/0

-type codec() ::
          #{pt := 0..127,
            name := binary(),
            clock_rate := pos_integer(),
            channels := pos_integer() | undefined,
            fmtp := [webrtc_sdp_rtp:fmtp_param()],
            rtcp_fb := [#{type := binary(), param := binary() | undefined}]}.

container/0

-type container() ::
          #sdp{version :: non_neg_integer(),
               origin ::
                   #sdp_origin{username :: binary(),
                               sess_id :: non_neg_integer(),
                               sess_version :: non_neg_integer(),
                               nettype :: binary(),
                               addrtype :: binary(),
                               address :: binary()},
               session_name :: binary(),
               information :: binary() | undefined,
               uri :: binary() | undefined,
               emails :: [binary()],
               phones :: [binary()],
               connection ::
                   #sdp_connection{nettype :: binary(), addrtype :: binary(), address :: binary()} |
                   undefined,
               bandwidths :: [{binary(), non_neg_integer()}],
               times ::
                   [#sdp_time{start :: non_neg_integer(),
                              stop :: non_neg_integer(),
                              repeats :: [[binary(), ...]],
                              zones :: [{non_neg_integer(), binary()}]},
                    ...],
               key :: binary() | undefined,
               attributes :: [webrtc_sdp:attribute()],
               media ::
                   [#sdp_media{media :: binary(),
                               port :: inet:port_number(),
                               port_count :: pos_integer() | undefined,
                               proto :: binary(),
                               fmts :: [binary()],
                               information :: binary() | undefined,
                               connections ::
                                   [#sdp_connection{nettype :: binary(),
                                                    addrtype :: binary(),
                                                    address :: binary()}],
                               bandwidths :: [{binary(), non_neg_integer()}],
                               key :: binary() | undefined,
                               attributes :: [webrtc_sdp:attribute()]}]} |
          #sdp_media{media :: binary(),
                     port :: inet:port_number(),
                     port_count :: pos_integer() | undefined,
                     proto :: binary(),
                     fmts :: [binary()],
                     information :: binary() | undefined,
                     connections ::
                         [#sdp_connection{nettype :: binary(),
                                          addrtype :: binary(),
                                          address :: binary()}],
                     bandwidths :: [{binary(), non_neg_integer()}],
                     key :: binary() | undefined,
                     attributes :: [webrtc_sdp:attribute()]}.

key/0

-type key() :: atom() | binary().

Functions

add_attr(Key, V, C)

-spec add_attr(key(), term(), C) -> C when C :: container().

Append an attribute.

attr(Key, C)

-spec attr(key(), container()) -> {ok, term()} | error.

First value of attribute Key at this level only.

attrs(Key, C)

-spec attrs(key(), container()) -> [term()].

All values of attribute Key at this level, in order.

candidates(Sdp_media)

-spec candidates(#sdp_media{media :: binary(),
                            port :: inet:port_number(),
                            port_count :: pos_integer() | undefined,
                            proto :: binary(),
                            fmts :: [binary()],
                            information :: binary() | undefined,
                            connections ::
                                [#sdp_connection{nettype :: binary(),
                                                 addrtype :: binary(),
                                                 address :: binary()}],
                            bandwidths :: [{binary(), non_neg_integer()}],
                            key :: binary() | undefined,
                            attributes :: [webrtc_sdp:attribute()]}) ->
                    [#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()}]}].

codec_attributes(Codecs)

-spec codec_attributes([codec()]) -> [webrtc_sdp:attribute()].

Attributes describing Codecs: for each codec its rtpmap, its rtcp-fb lines, then its fmtp when it has parameters (the order used by libwebrtc).

codecs(Sdp_media)

-spec codecs(#sdp_media{media :: binary(),
                        port :: inet:port_number(),
                        port_count :: pos_integer() | undefined,
                        proto :: binary(),
                        fmts :: [binary()],
                        information :: binary() | undefined,
                        connections ::
                            [#sdp_connection{nettype :: binary(),
                                             addrtype :: binary(),
                                             address :: binary()}],
                        bandwidths :: [{binary(), non_neg_integer()}],
                        key :: binary() | undefined,
                        attributes :: [webrtc_sdp:attribute()]}) ->
                [codec()].

Codecs of an RTP media section in m= line order, merging rtpmap, fmtp and rtcp-fb. Wildcard (*) feedback is copied into every codec. A payload type without rtpmap uses the RFC 3551 static assignment; one that has neither is skipped.

delete_attrs(Key, C)

-spec delete_attrs(key(), C) -> C when C :: container().

direction(Sdp_media, Sdp)

-spec direction(#sdp_media{media :: binary(),
                           port :: inet:port_number(),
                           port_count :: pos_integer() | undefined,
                           proto :: binary(),
                           fmts :: [binary()],
                           information :: binary() | undefined,
                           connections ::
                               [#sdp_connection{nettype :: binary(),
                                                addrtype :: binary(),
                                                address :: binary()}],
                           bandwidths :: [{binary(), non_neg_integer()}],
                           key :: binary() | undefined,
                           attributes :: [webrtc_sdp:attribute()]},
                #sdp{version :: non_neg_integer(),
                     origin ::
                         #sdp_origin{username :: binary(),
                                     sess_id :: non_neg_integer(),
                                     sess_version :: non_neg_integer(),
                                     nettype :: binary(),
                                     addrtype :: binary(),
                                     address :: binary()},
                     session_name :: binary(),
                     information :: binary() | undefined,
                     uri :: binary() | undefined,
                     emails :: [binary()],
                     phones :: [binary()],
                     connection ::
                         #sdp_connection{nettype :: binary(), addrtype :: binary(), address :: binary()} |
                         undefined,
                     bandwidths :: [{binary(), non_neg_integer()}],
                     times ::
                         [#sdp_time{start :: non_neg_integer(),
                                    stop :: non_neg_integer(),
                                    repeats :: [[binary(), ...]],
                                    zones :: [{non_neg_integer(), binary()}]},
                          ...],
                     key :: binary() | undefined,
                     attributes :: [webrtc_sdp:attribute()],
                     media ::
                         [#sdp_media{media :: binary(),
                                     port :: inet:port_number(),
                                     port_count :: pos_integer() | undefined,
                                     proto :: binary(),
                                     fmts :: [binary()],
                                     information :: binary() | undefined,
                                     connections ::
                                         [#sdp_connection{nettype :: binary(),
                                                          addrtype :: binary(),
                                                          address :: binary()}],
                                     bandwidths :: [{binary(), non_neg_integer()}],
                                     key :: binary() | undefined,
                                     attributes :: [webrtc_sdp:attribute()]}]}) ->
                   webrtc_sdp_rtp:direction().

Media direction; defaults to sendrecv (RFC 8866 §6.7).

end_of_candidates(Sdp_media)

-spec end_of_candidates(#sdp_media{media :: binary(),
                                   port :: inet:port_number(),
                                   port_count :: pos_integer() | undefined,
                                   proto :: binary(),
                                   fmts :: [binary()],
                                   information :: binary() | undefined,
                                   connections ::
                                       [#sdp_connection{nettype :: binary(),
                                                        addrtype :: binary(),
                                                        address :: binary()}],
                                   bandwidths :: [{binary(), non_neg_integer()}],
                                   key :: binary() | undefined,
                                   attributes :: [webrtc_sdp:attribute()]}) ->
                           boolean().

find_attr(Key, Sdp_media, Sdp)

-spec find_attr(key(),
                #sdp_media{media :: binary(),
                           port :: inet:port_number(),
                           port_count :: pos_integer() | undefined,
                           proto :: binary(),
                           fmts :: [binary()],
                           information :: binary() | undefined,
                           connections ::
                               [#sdp_connection{nettype :: binary(),
                                                addrtype :: binary(),
                                                address :: binary()}],
                           bandwidths :: [{binary(), non_neg_integer()}],
                           key :: binary() | undefined,
                           attributes :: [webrtc_sdp:attribute()]},
                #sdp{version :: non_neg_integer(),
                     origin ::
                         #sdp_origin{username :: binary(),
                                     sess_id :: non_neg_integer(),
                                     sess_version :: non_neg_integer(),
                                     nettype :: binary(),
                                     addrtype :: binary(),
                                     address :: binary()},
                     session_name :: binary(),
                     information :: binary() | undefined,
                     uri :: binary() | undefined,
                     emails :: [binary()],
                     phones :: [binary()],
                     connection ::
                         #sdp_connection{nettype :: binary(), addrtype :: binary(), address :: binary()} |
                         undefined,
                     bandwidths :: [{binary(), non_neg_integer()}],
                     times ::
                         [#sdp_time{start :: non_neg_integer(),
                                    stop :: non_neg_integer(),
                                    repeats :: [[binary(), ...]],
                                    zones :: [{non_neg_integer(), binary()}]},
                          ...],
                     key :: binary() | undefined,
                     attributes :: [webrtc_sdp:attribute()],
                     media ::
                         [#sdp_media{media :: binary(),
                                     port :: inet:port_number(),
                                     port_count :: pos_integer() | undefined,
                                     proto :: binary(),
                                     fmts :: [binary()],
                                     information :: binary() | undefined,
                                     connections ::
                                         [#sdp_connection{nettype :: binary(),
                                                          addrtype :: binary(),
                                                          address :: binary()}],
                                     bandwidths :: [{binary(), non_neg_integer()}],
                                     key :: binary() | undefined,
                                     attributes :: [webrtc_sdp:attribute()]}]}) ->
                   {ok, term()} | error.

First value of Key in the media section, else at session level.

find_attrs(Key, Sdp_media, Sdp)

-spec find_attrs(key(),
                 #sdp_media{media :: binary(),
                            port :: inet:port_number(),
                            port_count :: pos_integer() | undefined,
                            proto :: binary(),
                            fmts :: [binary()],
                            information :: binary() | undefined,
                            connections ::
                                [#sdp_connection{nettype :: binary(),
                                                 addrtype :: binary(),
                                                 address :: binary()}],
                            bandwidths :: [{binary(), non_neg_integer()}],
                            key :: binary() | undefined,
                            attributes :: [webrtc_sdp:attribute()]},
                 #sdp{version :: non_neg_integer(),
                      origin ::
                          #sdp_origin{username :: binary(),
                                      sess_id :: non_neg_integer(),
                                      sess_version :: non_neg_integer(),
                                      nettype :: binary(),
                                      addrtype :: binary(),
                                      address :: binary()},
                      session_name :: binary(),
                      information :: binary() | undefined,
                      uri :: binary() | undefined,
                      emails :: [binary()],
                      phones :: [binary()],
                      connection ::
                          #sdp_connection{nettype :: binary(),
                                          addrtype :: binary(),
                                          address :: binary()} |
                          undefined,
                      bandwidths :: [{binary(), non_neg_integer()}],
                      times ::
                          [#sdp_time{start :: non_neg_integer(),
                                     stop :: non_neg_integer(),
                                     repeats :: [[binary(), ...]],
                                     zones :: [{non_neg_integer(), binary()}]},
                           ...],
                      key :: binary() | undefined,
                      attributes :: [webrtc_sdp:attribute()],
                      media ::
                          [#sdp_media{media :: binary(),
                                      port :: inet:port_number(),
                                      port_count :: pos_integer() | undefined,
                                      proto :: binary(),
                                      fmts :: [binary()],
                                      information :: binary() | undefined,
                                      connections ::
                                          [#sdp_connection{nettype :: binary(),
                                                           addrtype :: binary(),
                                                           address :: binary()}],
                                      bandwidths :: [{binary(), non_neg_integer()}],
                                      key :: binary() | undefined,
                                      attributes :: [webrtc_sdp:attribute()]}]}) ->
                    [term()].

Values of Key in the media section if there is any, else the session-level values. Levels are not merged.

fingerprints(Sdp_media, Sdp)

-spec fingerprints(#sdp_media{media :: binary(),
                              port :: inet:port_number(),
                              port_count :: pos_integer() | undefined,
                              proto :: binary(),
                              fmts :: [binary()],
                              information :: binary() | undefined,
                              connections ::
                                  [#sdp_connection{nettype :: binary(),
                                                   addrtype :: binary(),
                                                   address :: binary()}],
                              bandwidths :: [{binary(), non_neg_integer()}],
                              key :: binary() | undefined,
                              attributes :: [webrtc_sdp:attribute()]},
                   #sdp{version :: non_neg_integer(),
                        origin ::
                            #sdp_origin{username :: binary(),
                                        sess_id :: non_neg_integer(),
                                        sess_version :: non_neg_integer(),
                                        nettype :: binary(),
                                        addrtype :: binary(),
                                        address :: binary()},
                        session_name :: binary(),
                        information :: binary() | undefined,
                        uri :: binary() | undefined,
                        emails :: [binary()],
                        phones :: [binary()],
                        connection ::
                            #sdp_connection{nettype :: binary(),
                                            addrtype :: binary(),
                                            address :: binary()} |
                            undefined,
                        bandwidths :: [{binary(), non_neg_integer()}],
                        times ::
                            [#sdp_time{start :: non_neg_integer(),
                                       stop :: non_neg_integer(),
                                       repeats :: [[binary(), ...]],
                                       zones :: [{non_neg_integer(), binary()}]},
                             ...],
                        key :: binary() | undefined,
                        attributes :: [webrtc_sdp:attribute()],
                        media ::
                            [#sdp_media{media :: binary(),
                                        port :: inet:port_number(),
                                        port_count :: pos_integer() | undefined,
                                        proto :: binary(),
                                        fmts :: [binary()],
                                        information :: binary() | undefined,
                                        connections ::
                                            [#sdp_connection{nettype :: binary(),
                                                             addrtype :: binary(),
                                                             address :: binary()}],
                                        bandwidths :: [{binary(), non_neg_integer()}],
                                        key :: binary() | undefined,
                                        attributes :: [webrtc_sdp:attribute()]}]}) ->
                      [webrtc_sdp_attr:fingerprint()].

Fingerprints for a media section: the media-level ones if any, else the session-level ones (RFC 8122 §5).

groups(Semantics, Sdp)

-spec groups(binary(),
             #sdp{version :: non_neg_integer(),
                  origin ::
                      #sdp_origin{username :: binary(),
                                  sess_id :: non_neg_integer(),
                                  sess_version :: non_neg_integer(),
                                  nettype :: binary(),
                                  addrtype :: binary(),
                                  address :: binary()},
                  session_name :: binary(),
                  information :: binary() | undefined,
                  uri :: binary() | undefined,
                  emails :: [binary()],
                  phones :: [binary()],
                  connection ::
                      #sdp_connection{nettype :: binary(), addrtype :: binary(), address :: binary()} |
                      undefined,
                  bandwidths :: [{binary(), non_neg_integer()}],
                  times ::
                      [#sdp_time{start :: non_neg_integer(),
                                 stop :: non_neg_integer(),
                                 repeats :: [[binary(), ...]],
                                 zones :: [{non_neg_integer(), binary()}]},
                       ...],
                  key :: binary() | undefined,
                  attributes :: [webrtc_sdp:attribute()],
                  media ::
                      [#sdp_media{media :: binary(),
                                  port :: inet:port_number(),
                                  port_count :: pos_integer() | undefined,
                                  proto :: binary(),
                                  fmts :: [binary()],
                                  information :: binary() | undefined,
                                  connections ::
                                      [#sdp_connection{nettype :: binary(),
                                                       addrtype :: binary(),
                                                       address :: binary()}],
                                  bandwidths :: [{binary(), non_neg_integer()}],
                                  key :: binary() | undefined,
                                  attributes :: [webrtc_sdp:attribute()]}]}) ->
                [[binary()]].

Mid lists of the session-level groups with these semantics, for example groups(<<"BUNDLE">>, Sdp).

ice_credentials(Sdp_media, Sdp)

-spec ice_credentials(#sdp_media{media :: binary(),
                                 port :: inet:port_number(),
                                 port_count :: pos_integer() | undefined,
                                 proto :: binary(),
                                 fmts :: [binary()],
                                 information :: binary() | undefined,
                                 connections ::
                                     [#sdp_connection{nettype :: binary(),
                                                      addrtype :: binary(),
                                                      address :: binary()}],
                                 bandwidths :: [{binary(), non_neg_integer()}],
                                 key :: binary() | undefined,
                                 attributes :: [webrtc_sdp:attribute()]},
                      #sdp{version :: non_neg_integer(),
                           origin ::
                               #sdp_origin{username :: binary(),
                                           sess_id :: non_neg_integer(),
                                           sess_version :: non_neg_integer(),
                                           nettype :: binary(),
                                           addrtype :: binary(),
                                           address :: binary()},
                           session_name :: binary(),
                           information :: binary() | undefined,
                           uri :: binary() | undefined,
                           emails :: [binary()],
                           phones :: [binary()],
                           connection ::
                               #sdp_connection{nettype :: binary(),
                                               addrtype :: binary(),
                                               address :: binary()} |
                               undefined,
                           bandwidths :: [{binary(), non_neg_integer()}],
                           times ::
                               [#sdp_time{start :: non_neg_integer(),
                                          stop :: non_neg_integer(),
                                          repeats :: [[binary(), ...]],
                                          zones :: [{non_neg_integer(), binary()}]},
                                ...],
                           key :: binary() | undefined,
                           attributes :: [webrtc_sdp:attribute()],
                           media ::
                               [#sdp_media{media :: binary(),
                                           port :: inet:port_number(),
                                           port_count :: pos_integer() | undefined,
                                           proto :: binary(),
                                           fmts :: [binary()],
                                           information :: binary() | undefined,
                                           connections ::
                                               [#sdp_connection{nettype :: binary(),
                                                                addrtype :: binary(),
                                                                address :: binary()}],
                                           bandwidths :: [{binary(), non_neg_integer()}],
                                           key :: binary() | undefined,
                                           attributes :: [webrtc_sdp:attribute()]}]}) ->
                         {ok, #{ufrag := binary(), pwd := binary()}} | {error, missing_ice_credentials}.

ICE credentials of a media section, each falling back to the session level (RFC 8839 §5.4).

ice_lite(Sdp)

-spec ice_lite(#sdp{version :: non_neg_integer(),
                    origin ::
                        #sdp_origin{username :: binary(),
                                    sess_id :: non_neg_integer(),
                                    sess_version :: non_neg_integer(),
                                    nettype :: binary(),
                                    addrtype :: binary(),
                                    address :: binary()},
                    session_name :: binary(),
                    information :: binary() | undefined,
                    uri :: binary() | undefined,
                    emails :: [binary()],
                    phones :: [binary()],
                    connection ::
                        #sdp_connection{nettype :: binary(), addrtype :: binary(), address :: binary()} |
                        undefined,
                    bandwidths :: [{binary(), non_neg_integer()}],
                    times ::
                        [#sdp_time{start :: non_neg_integer(),
                                   stop :: non_neg_integer(),
                                   repeats :: [[binary(), ...]],
                                   zones :: [{non_neg_integer(), binary()}]},
                         ...],
                    key :: binary() | undefined,
                    attributes :: [webrtc_sdp:attribute()],
                    media ::
                        [#sdp_media{media :: binary(),
                                    port :: inet:port_number(),
                                    port_count :: pos_integer() | undefined,
                                    proto :: binary(),
                                    fmts :: [binary()],
                                    information :: binary() | undefined,
                                    connections ::
                                        [#sdp_connection{nettype :: binary(),
                                                         addrtype :: binary(),
                                                         address :: binary()}],
                                    bandwidths :: [{binary(), non_neg_integer()}],
                                    key :: binary() | undefined,
                                    attributes :: [webrtc_sdp:attribute()]}]}) ->
                  boolean().

True when the session declares a=ice-lite (session level only).

ice_options(Sdp_media, Sdp)

-spec ice_options(#sdp_media{media :: binary(),
                             port :: inet:port_number(),
                             port_count :: pos_integer() | undefined,
                             proto :: binary(),
                             fmts :: [binary()],
                             information :: binary() | undefined,
                             connections ::
                                 [#sdp_connection{nettype :: binary(),
                                                  addrtype :: binary(),
                                                  address :: binary()}],
                             bandwidths :: [{binary(), non_neg_integer()}],
                             key :: binary() | undefined,
                             attributes :: [webrtc_sdp:attribute()]},
                  #sdp{version :: non_neg_integer(),
                       origin ::
                           #sdp_origin{username :: binary(),
                                       sess_id :: non_neg_integer(),
                                       sess_version :: non_neg_integer(),
                                       nettype :: binary(),
                                       addrtype :: binary(),
                                       address :: binary()},
                       session_name :: binary(),
                       information :: binary() | undefined,
                       uri :: binary() | undefined,
                       emails :: [binary()],
                       phones :: [binary()],
                       connection ::
                           #sdp_connection{nettype :: binary(),
                                           addrtype :: binary(),
                                           address :: binary()} |
                           undefined,
                       bandwidths :: [{binary(), non_neg_integer()}],
                       times ::
                           [#sdp_time{start :: non_neg_integer(),
                                      stop :: non_neg_integer(),
                                      repeats :: [[binary(), ...]],
                                      zones :: [{non_neg_integer(), binary()}]},
                            ...],
                       key :: binary() | undefined,
                       attributes :: [webrtc_sdp:attribute()],
                       media ::
                           [#sdp_media{media :: binary(),
                                       port :: inet:port_number(),
                                       port_count :: pos_integer() | undefined,
                                       proto :: binary(),
                                       fmts :: [binary()],
                                       information :: binary() | undefined,
                                       connections ::
                                           [#sdp_connection{nettype :: binary(),
                                                            addrtype :: binary(),
                                                            address :: binary()}],
                                       bandwidths :: [{binary(), non_neg_integer()}],
                                       key :: binary() | undefined,
                                       attributes :: [webrtc_sdp:attribute()]}]}) ->
                     [binary()].

ice_pacing(Sdp)

-spec ice_pacing(#sdp{version :: non_neg_integer(),
                      origin ::
                          #sdp_origin{username :: binary(),
                                      sess_id :: non_neg_integer(),
                                      sess_version :: non_neg_integer(),
                                      nettype :: binary(),
                                      addrtype :: binary(),
                                      address :: binary()},
                      session_name :: binary(),
                      information :: binary() | undefined,
                      uri :: binary() | undefined,
                      emails :: [binary()],
                      phones :: [binary()],
                      connection ::
                          #sdp_connection{nettype :: binary(),
                                          addrtype :: binary(),
                                          address :: binary()} |
                          undefined,
                      bandwidths :: [{binary(), non_neg_integer()}],
                      times ::
                          [#sdp_time{start :: non_neg_integer(),
                                     stop :: non_neg_integer(),
                                     repeats :: [[binary(), ...]],
                                     zones :: [{non_neg_integer(), binary()}]},
                           ...],
                      key :: binary() | undefined,
                      attributes :: [webrtc_sdp:attribute()],
                      media ::
                          [#sdp_media{media :: binary(),
                                      port :: inet:port_number(),
                                      port_count :: pos_integer() | undefined,
                                      proto :: binary(),
                                      fmts :: [binary()],
                                      information :: binary() | undefined,
                                      connections ::
                                          [#sdp_connection{nettype :: binary(),
                                                           addrtype :: binary(),
                                                           address :: binary()}],
                                      bandwidths :: [{binary(), non_neg_integer()}],
                                      key :: binary() | undefined,
                                      attributes :: [webrtc_sdp:attribute()]}]}) ->
                    non_neg_integer().

The Ta the session asks for (a=ice-pacing, session level, RFC 8839 §5.5), 50 ms when absent.

mid(Sdp_media)

-spec mid(#sdp_media{media :: binary(),
                     port :: inet:port_number(),
                     port_count :: pos_integer() | undefined,
                     proto :: binary(),
                     fmts :: [binary()],
                     information :: binary() | undefined,
                     connections ::
                         [#sdp_connection{nettype :: binary(),
                                          addrtype :: binary(),
                                          address :: binary()}],
                     bandwidths :: [{binary(), non_neg_integer()}],
                     key :: binary() | undefined,
                     attributes :: [webrtc_sdp:attribute()]}) ->
             binary() | undefined.

payload_types(Sdp_media)

-spec payload_types(#sdp_media{media :: binary(),
                               port :: inet:port_number(),
                               port_count :: pos_integer() | undefined,
                               proto :: binary(),
                               fmts :: [binary()],
                               information :: binary() | undefined,
                               connections ::
                                   [#sdp_connection{nettype :: binary(),
                                                    addrtype :: binary(),
                                                    address :: binary()}],
                               bandwidths :: [{binary(), non_neg_integer()}],
                               key :: binary() | undefined,
                               attributes :: [webrtc_sdp:attribute()]}) ->
                       [0..127].

Payload types of the m= line, for RTP media.

put_attr(Key, V, C)

-spec put_attr(key(), term(), C) -> C when C :: container().

Replace the first Key attribute (dropping the others), or append.

sections(Sdp)

-spec sections(#sdp{version :: non_neg_integer(),
                    origin ::
                        #sdp_origin{username :: binary(),
                                    sess_id :: non_neg_integer(),
                                    sess_version :: non_neg_integer(),
                                    nettype :: binary(),
                                    addrtype :: binary(),
                                    address :: binary()},
                    session_name :: binary(),
                    information :: binary() | undefined,
                    uri :: binary() | undefined,
                    emails :: [binary()],
                    phones :: [binary()],
                    connection ::
                        #sdp_connection{nettype :: binary(), addrtype :: binary(), address :: binary()} |
                        undefined,
                    bandwidths :: [{binary(), non_neg_integer()}],
                    times ::
                        [#sdp_time{start :: non_neg_integer(),
                                   stop :: non_neg_integer(),
                                   repeats :: [[binary(), ...]],
                                   zones :: [{non_neg_integer(), binary()}]},
                         ...],
                    key :: binary() | undefined,
                    attributes :: [webrtc_sdp:attribute()],
                    media ::
                        [#sdp_media{media :: binary(),
                                    port :: inet:port_number(),
                                    port_count :: pos_integer() | undefined,
                                    proto :: binary(),
                                    fmts :: [binary()],
                                    information :: binary() | undefined,
                                    connections ::
                                        [#sdp_connection{nettype :: binary(),
                                                         addrtype :: binary(),
                                                         address :: binary()}],
                                    bandwidths :: [{binary(), non_neg_integer()}],
                                    key :: binary() | undefined,
                                    attributes :: [webrtc_sdp:attribute()]}]}) ->
                  [#sdp_media{media :: binary(),
                              port :: inet:port_number(),
                              port_count :: pos_integer() | undefined,
                              proto :: binary(),
                              fmts :: [binary()],
                              information :: binary() | undefined,
                              connections ::
                                  [#sdp_connection{nettype :: binary(),
                                                   addrtype :: binary(),
                                                   address :: binary()}],
                              bandwidths :: [{binary(), non_neg_integer()}],
                              key :: binary() | undefined,
                              attributes :: [webrtc_sdp:attribute()]}].

The media sections in order.

set_codecs(Sdp_media, Codecs)

-spec set_codecs(#sdp_media{media :: binary(),
                            port :: inet:port_number(),
                            port_count :: pos_integer() | undefined,
                            proto :: binary(),
                            fmts :: [binary()],
                            information :: binary() | undefined,
                            connections ::
                                [#sdp_connection{nettype :: binary(),
                                                 addrtype :: binary(),
                                                 address :: binary()}],
                            bandwidths :: [{binary(), non_neg_integer()}],
                            key :: binary() | undefined,
                            attributes :: [webrtc_sdp:attribute()]},
                 [codec(), ...]) ->
                    #sdp_media{media :: binary(),
                               port :: inet:port_number(),
                               port_count :: pos_integer() | undefined,
                               proto :: binary(),
                               fmts :: [binary()],
                               information :: binary() | undefined,
                               connections ::
                                   [#sdp_connection{nettype :: binary(),
                                                    addrtype :: binary(),
                                                    address :: binary()}],
                               bandwidths :: [{binary(), non_neg_integer()}],
                               key :: binary() | undefined,
                               attributes :: [webrtc_sdp:attribute()]}.

Replace the codecs of a media section: the m= line payload types and the rtpmap, fmtp and rtcp-fb attributes. The new codec attributes take the place of the first old one; other attributes keep their order.

setup(Sdp_media, Sdp)

-spec setup(#sdp_media{media :: binary(),
                       port :: inet:port_number(),
                       port_count :: pos_integer() | undefined,
                       proto :: binary(),
                       fmts :: [binary()],
                       information :: binary() | undefined,
                       connections ::
                           [#sdp_connection{nettype :: binary(),
                                            addrtype :: binary(),
                                            address :: binary()}],
                       bandwidths :: [{binary(), non_neg_integer()}],
                       key :: binary() | undefined,
                       attributes :: [webrtc_sdp:attribute()]},
            #sdp{version :: non_neg_integer(),
                 origin ::
                     #sdp_origin{username :: binary(),
                                 sess_id :: non_neg_integer(),
                                 sess_version :: non_neg_integer(),
                                 nettype :: binary(),
                                 addrtype :: binary(),
                                 address :: binary()},
                 session_name :: binary(),
                 information :: binary() | undefined,
                 uri :: binary() | undefined,
                 emails :: [binary()],
                 phones :: [binary()],
                 connection ::
                     #sdp_connection{nettype :: binary(), addrtype :: binary(), address :: binary()} |
                     undefined,
                 bandwidths :: [{binary(), non_neg_integer()}],
                 times ::
                     [#sdp_time{start :: non_neg_integer(),
                                stop :: non_neg_integer(),
                                repeats :: [[binary(), ...]],
                                zones :: [{non_neg_integer(), binary()}]},
                      ...],
                 key :: binary() | undefined,
                 attributes :: [webrtc_sdp:attribute()],
                 media ::
                     [#sdp_media{media :: binary(),
                                 port :: inet:port_number(),
                                 port_count :: pos_integer() | undefined,
                                 proto :: binary(),
                                 fmts :: [binary()],
                                 information :: binary() | undefined,
                                 connections ::
                                     [#sdp_connection{nettype :: binary(),
                                                      addrtype :: binary(),
                                                      address :: binary()}],
                                 bandwidths :: [{binary(), non_neg_integer()}],
                                 key :: binary() | undefined,
                                 attributes :: [webrtc_sdp:attribute()]}]}) ->
               {ok, webrtc_sdp_attr:setup()} | error.

a=setup role, media level first. JSEP (RFC 8842 §5.1) requires the attribute, so an absent one is reported rather than defaulted.