Skip to content

Commit

Permalink
Review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sgfn committed Aug 23, 2024
1 parent 91ad873 commit 1db1043
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/ex_webrtc/dtls_transport.ex
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ defmodule ExWebRTC.DTLSTransport do
{:ok, state}

{:error, reason} = error ->
# TODO: consider buffering DTLS packets that came out of order during the handshake
Logger.debug("DTLS error: #{reason}")
error
end
Expand Down Expand Up @@ -393,7 +394,7 @@ defmodule ExWebRTC.DTLSTransport do
They will be processed after the completion of the handshake.\
""")

state = %{state | buffered_remote_rtp_packets: state.buffered_remote_rtp_packets ++ [data]}
state = %{state | buffered_remote_rtp_packets: [data | state.buffered_remote_rtp_packets]}
{:ok, state}
end

Expand Down Expand Up @@ -438,10 +439,8 @@ defmodule ExWebRTC.DTLSTransport do
%{state | remote_cert: cert, remote_base64_cert: base64_cert, remote_fingerprint: fingerprint}
end

defp flush_buffered_remote_rtp_packets(%{buffered_remote_rtp_packets: []} = state), do: state

defp flush_buffered_remote_rtp_packets(state) do
for data <- state.buffered_remote_rtp_packets do
for data <- Enum.reverse(state.buffered_remote_rtp_packets) do
send(self(), {:ex_ice, state.ice_pid, {:data, data}})
end

Expand Down

0 comments on commit 1db1043

Please sign in to comment.