Skip to content

Commit 6675529

Browse files
committed
Add close/1. Handle DTLS close_notify alert.
1 parent 598dc4e commit 6675529

File tree

19 files changed

+466
-88
lines changed

19 files changed

+466
-88
lines changed

examples/chat/lib/chat/peer_handler.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ defmodule Chat.PeerHandler do
106106
defp handle_webrtc_msg({:connection_state_change, conn_state}, state) do
107107
Logger.info("Connection state changed: #{conn_state}")
108108

109-
if conn_state == :failed do
110-
{:stop, {:shutdown, :pc_failed}, state}
109+
if conn_state in [:failed, :closed] do
110+
{:stop, {:shutdown, :pc_failed_or_closed}, state}
111111
else
112112
{:ok, state}
113113
end

examples/dtmf/lib/dtmf/peer_handler.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ defmodule Dtmf.PeerHandler do
125125
defp handle_webrtc_msg({:connection_state_change, conn_state}, state) do
126126
Logger.info("Connection state changed: #{conn_state}")
127127

128-
if conn_state == :failed do
129-
{:stop, {:shutdown, :pc_failed}, state}
128+
if conn_state in [:failed, :closed] do
129+
{:stop, {:shutdown, :pc_failed_or_closed}, state}
130130
else
131131
{:ok, state}
132132
end

examples/echo/lib/echo/peer_handler.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ defmodule Echo.PeerHandler do
115115
defp handle_webrtc_msg({:connection_state_change, conn_state}, state) do
116116
Logger.info("Connection state changed: #{conn_state}")
117117

118-
if conn_state == :failed do
119-
{:stop, {:shutdown, :pc_failed}, state}
118+
if conn_state in [:failed, :closed] do
119+
{:stop, {:shutdown, :pc_failed_or_closed}, state}
120120
else
121121
{:ok, state}
122122
end

examples/save_to_file/lib/save_to_file/peer_handler.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ defmodule SaveToFile.PeerHandler do
136136
defp handle_webrtc_msg({:connection_state_change, conn_state}, state) do
137137
Logger.info("Connection state changed: #{conn_state}")
138138

139-
if conn_state == :failed do
140-
{:stop, {:shutdown, :pc_failed}, state}
139+
if conn_state in [:failed, :closed] do
140+
{:stop, {:shutdown, :pc_failed_or_closed}, state}
141141
else
142142
{:ok, state}
143143
end

examples/send_from_file/lib/send_from_file/peer_handler.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,8 @@ defmodule SendFromFile.PeerHandler do
249249
defp handle_webrtc_msg({:connection_state_change, conn_state}, state) do
250250
Logger.info("Connection state changed: #{conn_state}")
251251

252-
if conn_state == :failed do
253-
{:stop, {:shutdown, :pc_failed}, state}
252+
if conn_state in [:failed, :closed] do
253+
{:stop, {:shutdown, :pc_failed_or_closed}, state}
254254
else
255255
{:ok, state}
256256
end

examples/whip_whep/lib/whip_whep/forwarder.ex

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,38 @@ defmodule WhipWhep.Forwarder do
6868
{:noreply, state}
6969
end
7070

71+
@impl true
72+
def handle_info(
73+
{:ex_webrtc, pc, {:connection_state_change, conn_state}},
74+
%{input_pc: pc} = state
75+
)
76+
when conn_state in [:failed, :closed] do
77+
Logger.info("Input peer connection (#{inspect(pc)}) state change: #{conn_state}. Removing.")
78+
:ok = PeerConnection.stop(state.input_pc)
79+
80+
Enum.each(state.pending_outputs, &PeerConnection.close(&1))
81+
Enum.each(state.outputs, fn {pc, _output} -> PeerConnection.close(pc) end)
82+
83+
state = %{
84+
state
85+
| input_pc: nil,
86+
audio_input: nil,
87+
video_input: nil,
88+
pending_outputs: [],
89+
outputs: %{}
90+
}
91+
92+
{:noreply, state}
93+
end
94+
95+
@impl true
96+
def handle_info(
97+
{:ex_webrtc, pc, {:connection_state_change, _conn_state}},
98+
%{input_pc: pc} = state
99+
) do
100+
{:noreply, state}
101+
end
102+
71103
@impl true
72104
def handle_info({:ex_webrtc, pc, {:connection_state_change, :connected}}, state) do
73105
state =
@@ -92,9 +124,10 @@ defmodule WhipWhep.Forwarder do
92124
end
93125

94126
@impl true
95-
def handle_info({:ex_webrtc, pc, {:connection_state_change, :failed}}, state) do
96-
Logger.info("Output peer connection (#{inspect(pc)}) state change: failed. Removing.")
97-
:ok = PeerConnection.close(pc)
127+
def handle_info({:ex_webrtc, pc, {:connection_state_change, conn_state}}, state)
128+
when conn_state in [:failed, :closed] do
129+
Logger.info("Output peer connection (#{inspect(pc)}) state change: #{conn_state}. Removing.")
130+
:ok = PeerConnection.stop(pc)
98131
pending_outputs = List.delete(state.pending_outputs, pc)
99132
outputs = Map.delete(state.outputs, pc)
100133
state = %{state | pending_outputs: pending_outputs, outputs: outputs}

examples/whip_whep/lib/whip_whep/peer_supervisor.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ defmodule WhipWhep.PeerSupervisor do
6969

7070
{:ok, pc, pc_id, answer.sdp}
7171
else
72-
{:error, res} = err ->
73-
Logger.info("Failed to complete negotiation for #{inspect(pc)}")
72+
{:error, _res} = err ->
73+
Logger.info("Failed to complete negotiation for #{inspect(pc)}, #{inspect(err)}")
7474
terminate_pc(pc)
7575
err
7676
end

examples/whip_whep/mix.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
"crc": {:hex, :crc, "0.10.5", "ee12a7c056ac498ef2ea985ecdc9fa53c1bfb4e53a484d9f17ff94803707dfd8", [:mix, :rebar3], [{:elixir_make, "~> 0.6", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "3e673b6495a9525c5c641585af1accba59a1eb33de697bedf341e247012c2c7f"},
1010
"elixir_make": {:hex, :elixir_make, "0.9.0", "6484b3cd8c0cee58f09f05ecaf1a140a8c97670671a6a0e7ab4dc326c3109726", [:mix], [], "hexpm", "db23d4fd8b757462ad02f8aa73431a426fe6671c80b200d9710caf3d1dd0ffdb"},
1111
"elixir_uuid": {:hex, :elixir_uuid, "1.2.1", "dce506597acb7e6b0daeaff52ff6a9043f5919a4c3315abb4143f0b00378c097", [:mix], [], "hexpm", "f7eba2ea6c3555cea09706492716b0d87397b88946e6380898c2889d68585752"},
12-
"ex_dtls": {:hex, :ex_dtls, "0.16.0", "3ae38025ccc77f6db573e2e391602fa9bbc02253c137d8d2d59469a66cbe806b", [:mix], [{:bundlex, "~> 1.5.3", [hex: :bundlex, repo: "hexpm", optional: false]}, {:unifex, "~> 1.0", [hex: :unifex, repo: "hexpm", optional: false]}], "hexpm", "2a4e30d74c6ddf95cc5b796423293c06a0da295454c3823819808ff031b4b361"},
13-
"ex_ice": {:hex, :ex_ice, "0.12.0", "b52ec3ff878d5fb632ef9facc7657dfdf59e2ff9f23e634b0918e6ce1a05af48", [:mix], [{:elixir_uuid, "~> 1.0", [hex: :elixir_uuid, repo: "hexpm", optional: false]}, {:ex_stun, "~> 0.2.0", [hex: :ex_stun, repo: "hexpm", optional: false]}, {:ex_turn, "~> 0.2.0", [hex: :ex_turn, repo: "hexpm", optional: false]}], "hexpm", "a86024a5fbf9431082784be4bb3606d3cde9218fb325a9f208ccd6e0abfd0d73"},
12+
"ex_dtls": {:git, "https://github.com/elixir-webrtc/ex_dtls.git", "5a9904d30d55005bcf91f3b87e5fcd5e936f7fb8", [branch: "disconnect"]},
13+
"ex_ice": {:git, "https://github.com/elixir-webrtc/ex_ice.git", "c13e5ad9d379efc5cad3977b3676cf5c34113a73", [branch: "close"]},
1414
"ex_libsrtp": {:hex, :ex_libsrtp, "0.7.2", "211bd89c08026943ce71f3e2c0231795b99cee748808ed3ae7b97cd8d2450b6b", [:mix], [{:bunch, "~> 1.6", [hex: :bunch, repo: "hexpm", optional: false]}, {:bundlex, "~> 1.3", [hex: :bundlex, repo: "hexpm", optional: false]}, {:membrane_precompiled_dependency_provider, "~> 0.1.0", [hex: :membrane_precompiled_dependency_provider, repo: "hexpm", optional: false]}, {:unifex, "~> 1.1", [hex: :unifex, repo: "hexpm", optional: false]}], "hexpm", "2e20645d0d739a4ecdcf8d4810a0c198120c8a2f617f2b75b2e2e704d59f492a"},
1515
"ex_rtcp": {:hex, :ex_rtcp, "0.4.0", "f9e515462a9581798ff6413583a25174cfd2101c94a2ebee871cca7639886f0a", [:mix], [], "hexpm", "28956602cf210d692fcdaf3f60ca49681634e1deb28ace41246aee61ee22dc3b"},
1616
"ex_rtp": {:hex, :ex_rtp, "0.4.0", "1f1b5c1440a904706011e3afbb41741f5da309ce251cb986690ce9fd82636658", [:mix], [], "hexpm", "0f72d80d5953a62057270040f0f1ee6f955c08eeae82ac659c038001d7d5a790"},
@@ -22,17 +22,17 @@
2222
"hpax": {:hex, :hpax, "0.1.2", "09a75600d9d8bbd064cdd741f21fc06fc1f4cf3d0fcc335e5aa19be1a7235c84", [:mix], [], "hexpm", "2c87843d5a23f5f16748ebe77969880e29809580efdaccd615cd3bed628a8c13"},
2323
"jason": {:hex, :jason, "1.4.4", "b9226785a9aa77b6857ca22832cffa5d5011a667207eb2a0ad56adb5db443b8a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "c5eb0cab91f094599f94d55bc63409236a8ec69a21a67814529e8d5f6cc90b3b"},
2424
"membrane_precompiled_dependency_provider": {:hex, :membrane_precompiled_dependency_provider, "0.1.2", "8af73b7dc15ba55c9f5fbfc0453d4a8edfb007ade54b56c37d626be0d1189aba", [:mix], [{:bundlex, "~> 1.4", [hex: :bundlex, repo: "hexpm", optional: false]}], "hexpm", "7fe3e07361510445a29bee95336adde667c4162b76b7f4c8af3aeb3415292023"},
25-
"mime": {:hex, :mime, "2.0.6", "8f18486773d9b15f95f4f4f1e39b710045fa1de891fada4516559967276e4dc2", [:mix], [], "hexpm", "c9945363a6b26d747389aac3643f8e0e09d30499a138ad64fe8fd1d13d9b153e"},
25+
"mime": {:hex, :mime, "2.0.7", "b8d739037be7cd402aee1ba0306edfdef982687ee7e9859bee6198c1e7e2f128", [:mix], [], "hexpm", "6171188e399ee16023ffc5b76ce445eb6d9672e2e241d2df6050f3c771e80ccd"},
2626
"mint": {:hex, :mint, "1.7.1", "113fdb2b2f3b59e47c7955971854641c61f378549d73e829e1768de90fc1abf1", [:mix], [{:castore, "~> 0.1.0 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:hpax, "~> 0.1.1 or ~> 0.2.0 or ~> 1.0", [hex: :hpax, repo: "hexpm", optional: false]}], "hexpm", "fceba0a4d0f24301ddee3024ae116df1c3f4bb7a563a731f45fdfeb9d39a231b"},
2727
"nimble_options": {:hex, :nimble_options, "1.1.1", "e3a492d54d85fc3fd7c5baf411d9d2852922f66e69476317787a7b2bb000a61b", [:mix], [], "hexpm", "821b2470ca9442c4b6984882fe9bb0389371b8ddec4d45a9504f00a66f650b44"},
2828
"nimble_ownership": {:hex, :nimble_ownership, "0.3.1", "99d5244672fafdfac89bfad3d3ab8f0d367603ce1dc4855f86a1c75008bce56f", [:mix], [], "hexpm", "4bf510adedff0449a1d6e200e43e57a814794c8b5b6439071274d248d272a549"},
2929
"nimble_pool": {:hex, :nimble_pool, "1.1.0", "bf9c29fbdcba3564a8b800d1eeb5a3c58f36e1e11d7b7fb2e084a643f645f06b", [:mix], [], "hexpm", "af2e4e6b34197db81f7aad230c1118eac993acc0dae6bc83bac0126d4ae0813a"},
3030
"observer_cli": {:hex, :observer_cli, "1.7.4", "3c1bfb6d91bf68f6a3d15f46ae20da0f7740d363ee5bc041191ce8722a6c4fae", [:mix, :rebar3], [{:recon, "~> 2.5.1", [hex: :recon, repo: "hexpm", optional: false]}], "hexpm", "50de6d95d814f447458bd5d72666a74624eddb0ef98bdcee61a0153aae0865ff"},
3131
"plug": {:hex, :plug, "1.15.3", "712976f504418f6dff0a3e554c40d705a9bcf89a7ccef92fc6a5ef8f16a30a97", [:mix], [{:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.1.1 or ~> 1.2 or ~> 2.0", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.3 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "cc4365a3c010a56af402e0809208873d113e9c38c401cabd88027ef4f5c01fd2"},
32-
"plug_crypto": {:hex, :plug_crypto, "2.1.0", "f44309c2b06d249c27c8d3f65cfe08158ade08418cf540fd4f72d4d6863abb7b", [:mix], [], "hexpm", "131216a4b030b8f8ce0f26038bc4421ae60e4bb95c5cf5395e1421437824c4fa"},
32+
"plug_crypto": {:hex, :plug_crypto, "2.1.1", "19bda8184399cb24afa10be734f84a16ea0a2bc65054e23a62bb10f06bc89491", [:mix], [], "hexpm", "6470bce6ffe41c8bd497612ffde1a7e4af67f36a15eea5f921af71cf3e11247c"},
3333
"qex": {:hex, :qex, "0.5.1", "0d82c0f008551d24fffb99d97f8299afcb8ea9cf99582b770bd004ed5af63fd6", [:mix], [], "hexpm", "935a39fdaf2445834b95951456559e9dc2063d0a055742c558a99987b38d6bab"},
3434
"recon": {:hex, :recon, "2.5.5", "c108a4c406fa301a529151a3bb53158cadc4064ec0c5f99b03ddb8c0e4281bdf", [:mix, :rebar3], [], "hexpm", "632a6f447df7ccc1a4a10bdcfce71514412b16660fe59deca0fcf0aa3c054404"},
35-
"req": {:hex, :req, "0.5.8", "50d8d65279d6e343a5e46980ac2a70e97136182950833a1968b371e753f6a662", [:mix], [{:brotli, "~> 0.3.1", [hex: :brotli, repo: "hexpm", optional: true]}, {:ezstd, "~> 1.0", [hex: :ezstd, repo: "hexpm", optional: true]}, {:finch, "~> 0.17", [hex: :finch, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:mime, "~> 2.0.6 or ~> 2.1", [hex: :mime, repo: "hexpm", optional: false]}, {:nimble_csv, "~> 1.0", [hex: :nimble_csv, repo: "hexpm", optional: true]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: true]}], "hexpm", "d7fc5898a566477e174f26887821a3c5082b243885520ee4b45555f5d53f40ef"},
35+
"req": {:hex, :req, "0.5.10", "a3a063eab8b7510785a467f03d30a8d95f66f5c3d9495be3474b61459c54376c", [:mix], [{:brotli, "~> 0.3.1", [hex: :brotli, repo: "hexpm", optional: true]}, {:ezstd, "~> 1.0", [hex: :ezstd, repo: "hexpm", optional: true]}, {:finch, "~> 0.17", [hex: :finch, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:mime, "~> 2.0.6 or ~> 2.1", [hex: :mime, repo: "hexpm", optional: false]}, {:nimble_csv, "~> 1.0", [hex: :nimble_csv, repo: "hexpm", optional: true]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: true]}], "hexpm", "8a604815743f8a2d3b5de0659fa3137fa4b1cffd636ecb69b30b2b9b2c2559be"},
3636
"shmex": {:hex, :shmex, "0.5.1", "81dd209093416bf6608e66882cb7e676089307448a1afd4fc906c1f7e5b94cf4", [:mix], [{:bunch_native, "~> 0.5.0", [hex: :bunch_native, repo: "hexpm", optional: false]}, {:bundlex, "~> 1.0", [hex: :bundlex, repo: "hexpm", optional: false]}], "hexpm", "c29f8286891252f64c4e1dac40b217d960f7d58def597c4e606ff8fbe71ceb80"},
3737
"telemetry": {:hex, :telemetry, "1.3.0", "fedebbae410d715cf8e7062c96a1ef32ec22e764197f70cda73d82778d61e7a2", [:rebar3], [], "hexpm", "7015fc8919dbe63764f4b4b87a95b7c0996bd539e0d499be6ec9d7f3875b79e6"},
3838
"thousand_island": {:hex, :thousand_island, "1.3.11", "b68f3e91f74d564ae20b70d981bbf7097dde084343c14ae8a33e5b5fbb3d6f37", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "555c18c62027f45d9c80df389c3d01d86ba11014652c00be26e33b1b64e98d29"},

lib/ex_webrtc/dtls_transport.ex

Lines changed: 53 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@ defmodule ExWebRTC.DTLSTransport do
101101
GenServer.cast(dtls_transport, {:set_packet_loss, packet_loss})
102102
end
103103

104+
@spec close(dtls_transport()) :: :ok
105+
def close(dtls_transport) do
106+
GenServer.call(dtls_transport, :close)
107+
end
108+
104109
@spec stop(dtls_transport()) :: :ok
105110
def stop(dtls_transport) do
106111
GenServer.stop(dtls_transport)
@@ -146,7 +151,7 @@ defmodule ExWebRTC.DTLSTransport do
146151
state = %{state | ice_connected: true}
147152

148153
if state.mode == :active do
149-
{packets, timeout} = ExDTLS.do_handshake(state.dtls)
154+
{:ok, packets, timeout} = ExDTLS.do_handshake(state.dtls)
150155
Process.send_after(self(), :dtls_timeout, timeout)
151156
:ok = do_send(state, packets)
152157
state = update_dtls_state(state, :connecting)
@@ -158,7 +163,7 @@ defmodule ExWebRTC.DTLSTransport do
158163
end
159164

160165
@impl true
161-
def handle_call(:set_ice_connected, _from, state) do
166+
def handle_call(:set_ice_connected, _from, %{dtls_state: :connecting} = state) do
162167
state = %{state | ice_connected: true}
163168

164169
if state.buffered_local_packets do
@@ -171,6 +176,17 @@ defmodule ExWebRTC.DTLSTransport do
171176
end
172177
end
173178

179+
@impl true
180+
def handle_call(:set_ice_connected, _from, state) do
181+
Logger.debug("""
182+
Setting ice connected in unexpected DTLS state: #{state.dtls_state}. \
183+
DTLS handshake won't be performed.\
184+
""")
185+
186+
state = %{state | ice_connected: true}
187+
{:reply, :ok, state}
188+
end
189+
174190
@impl true
175191
def handle_call(:get_certs_info, _from, state) do
176192
local_cert_info = %{
@@ -239,6 +255,19 @@ defmodule ExWebRTC.DTLSTransport do
239255
{:reply, {:error, :already_started}, state}
240256
end
241257

258+
@impl true
259+
def handle_call(:close, _from, %{state: :closed} = state) do
260+
{:reply, :ok, state}
261+
end
262+
263+
@impl true
264+
def handle_call(:close, _from, state) do
265+
{:ok, packets} = ExDTLS.close(state.dtls)
266+
:ok = do_send(state, packets)
267+
state = update_dtls_state(state, :closed, notify: false)
268+
{:reply, :ok, state}
269+
end
270+
242271
@impl true
243272
def handle_cast({:send_rtp, data}, %{dtls_state: :connected, ice_connected: true} = state) do
244273
case ExLibSRTP.protect(state.out_srtp, data) do
@@ -327,6 +356,14 @@ defmodule ExWebRTC.DTLSTransport do
327356
{:ok, state} ->
328357
{:noreply, state}
329358

359+
{:error, :peer_closed_for_writing} ->
360+
# See W3C WebRTC sec. 5.5.1
361+
# peer_closed_for_writing is returned when the remote side
362+
# sends close_notify alert
363+
ExDTLS.close(state.dtls)
364+
state = update_dtls_state(state, :closed)
365+
{:noreply, state}
366+
330367
{:error, _reason} ->
331368
# See W3C WebRTC sec. 5.5.
332369
state = update_dtls_state(state, :failed)
@@ -345,6 +382,12 @@ defmodule ExWebRTC.DTLSTransport do
345382
Logger.debug("Stopping DTLSTransport with reason: #{inspect(reason)}")
346383
end
347384

385+
defp handle_ice_data({:data, _data}, %{dtls_state: dtls_state} = state)
386+
when dtls_state in [:failed, :closed] do
387+
Logger.debug("Received DTLS packets in state #{dtls_state}. Ignoring.")
388+
{:ok, state}
389+
end
390+
348391
defp handle_ice_data({:data, data}, %{dtls: nil} = state) do
349392
# received DTLS data from remote peer before receiving an
350393
# SDP answer and initializing the DTLS Transport, will buffer the data
@@ -470,11 +513,16 @@ defmodule ExWebRTC.DTLSTransport do
470513
:ok
471514
end
472515

473-
defp update_dtls_state(%{dtls_state: dtls_state} = state, dtls_state), do: state
516+
defp update_dtls_state(state, dtls_state, otps \\ [])
517+
defp update_dtls_state(%{dtls_state: dtls_state} = state, dtls_state, _opts), do: state
474518

475-
defp update_dtls_state(state, new_dtls_state) do
519+
defp update_dtls_state(state, new_dtls_state, opts) do
476520
Logger.debug("Changing DTLS state: #{state.dtls_state} -> #{new_dtls_state}")
477-
notify(state.owner, {:state_change, new_dtls_state})
521+
522+
if opts[:notify] != false do
523+
notify(state.owner, {:state_change, new_dtls_state})
524+
end
525+
478526
%{state | dtls_state: new_dtls_state}
479527
end
480528

lib/ex_webrtc/ice_transport.ex

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ defmodule ExWebRTC.ICETransport do
33

44
# module implementing this behaviour
55
@type t() :: module()
6-
@type state() :: :checking | :connected | :completed | :failed
6+
@type state() :: :checking | :connected | :completed | :failed | :closed
77

88
@callback start_link(Keyword.t()) :: {:ok, pid()}
99
@callback on_data(pid(), pid()) :: :ok
@@ -19,6 +19,7 @@ defmodule ExWebRTC.ICETransport do
1919
@callback set_role(pid(), ExICE.ICEAgent.role()) :: :ok
2020
@callback set_remote_credentials(pid(), ufrag :: binary(), pwd :: binary()) :: :ok
2121
@callback get_stats(pid()) :: map()
22+
@callback close(pid()) :: :ok
2223
@callback stop(pid()) :: :ok
2324
end
2425

@@ -58,5 +59,7 @@ defmodule ExWebRTC.DefaultICETransport do
5859
@impl true
5960
defdelegate get_stats(pid), to: ICEAgent
6061
@impl true
62+
defdelegate close(pid), to: ICEAgent
63+
@impl true
6164
defdelegate stop(pid), to: ICEAgent
6265
end

0 commit comments

Comments
 (0)