From 5a3fb74c1ec3d628af792268c97ddd306bf30a1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Ro=C5=BCnawski?= Date: Tue, 19 Nov 2024 18:38:07 +0100 Subject: [PATCH] Fix ICECandidate types --- lib/ex_webrtc/ice_candidate.ex | 6 +++--- lib/ex_webrtc/peer_connection.ex | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/ex_webrtc/ice_candidate.ex b/lib/ex_webrtc/ice_candidate.ex index 068ba118..59a77eea 100644 --- a/lib/ex_webrtc/ice_candidate.ex +++ b/lib/ex_webrtc/ice_candidate.ex @@ -5,14 +5,14 @@ defmodule ExWebRTC.ICECandidate do @type t() :: %__MODULE__{ candidate: binary(), - sdp_mid: non_neg_integer() | nil, + sdp_mid: binary() | nil, sdp_m_line_index: non_neg_integer() | nil, username_fragment: binary() | nil } defstruct [:candidate, :username_fragment, :sdp_mid, :sdp_m_line_index] - @spec to_json(t()) :: %{String.t() => String.t()} + @spec to_json(t()) :: %{String.t() => String.t() | non_neg_integer() | nil} def to_json(%__MODULE__{} = c) do %{ "candidate" => c.candidate, @@ -22,7 +22,7 @@ defmodule ExWebRTC.ICECandidate do } end - @spec from_json(%{String.t() => String.t()}) :: t() + @spec from_json(%{String.t() => String.t() | non_neg_integer() | nil}) :: t() def from_json(%{ "candidate" => c, "sdpMid" => mid, diff --git a/lib/ex_webrtc/peer_connection.ex b/lib/ex_webrtc/peer_connection.ex index 1178aaf6..0c12b4d2 100644 --- a/lib/ex_webrtc/peer_connection.ex +++ b/lib/ex_webrtc/peer_connection.ex @@ -1193,7 +1193,7 @@ defmodule ExWebRTC.PeerConnection do def handle_info({:ex_ice, _from, {:new_candidate, candidate}}, state) do candidate = %ICECandidate{ candidate: "candidate:" <> candidate, - sdp_mid: 0, + sdp_mid: "0", sdp_m_line_index: 0 # username_fragment: "vx/1" }