Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
mickel8 committed Apr 19, 2024
1 parent 945615b commit a15555c
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions lib/ex_webrtc/sdp_utils.ex
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,21 @@ defmodule ExWebRTC.SDPUtils do

@spec add_ice_candidates(ExSDP.t(), [String.t()]) :: ExSDP.t()
def add_ice_candidates(sdp, candidates) do
# we only add candidates to the first mline
# as we don't support bundle-policies other than "max-bundle"
candidates = Enum.map(candidates, &{"candidate", &1})
media = Enum.map(sdp.media, &ExSDP.add_attributes(&1, candidates))
%ExSDP{sdp | media: media}

if sdp.media != [] do
mline =
sdp.media
|> List.first()
|> ExSDP.add_attribute(candidates)

media = List.replace_at(sdp.media, 0, mline)
%ExSDP{sdp | media: media}
else
sdp
end
end

@spec get_dtls_role(ExSDP.t()) ::
Expand Down

0 comments on commit a15555c

Please sign in to comment.