diff --git a/lib/ex_webrtc/peer_connection.ex b/lib/ex_webrtc/peer_connection.ex index 1e890a1c..702c9abb 100644 --- a/lib/ex_webrtc/peer_connection.ex +++ b/lib/ex_webrtc/peer_connection.ex @@ -545,7 +545,7 @@ defmodule ExWebRTC.PeerConnection do } end - defp set_description(:local, other, sdp, state) when other in [:answer, :pranswer] do + defp set_description(:local, other, sdp, state) when other in [:offer, :pranswer] do %{state | pending_local_desc: {other, sdp}} end diff --git a/test/peer_connection_test.exs b/test/peer_connection_test.exs index 5b7051f0..7727767e 100644 --- a/test/peer_connection_test.exs +++ b/test/peer_connection_test.exs @@ -102,6 +102,20 @@ defmodule ExWebRTC.PeerConnectionTest do refute_receive {:ex_webrtc, ^pc, {:track, %MediaStreamTrack{}}} end + test "offer/answer exchange" do + {:ok, pc1} = PeerConnection.start_link() + {:ok, _} = PeerConnection.add_transceiver(pc1, :audio) + {:ok, offer} = PeerConnection.create_offer(pc1) + :ok = PeerConnection.set_local_description(pc1, offer) + + {:ok, pc2} = PeerConnection.start_link() + :ok = PeerConnection.set_remote_description(pc2, offer) + {:ok, answer} = PeerConnection.create_answer(pc2) + :ok = PeerConnection.set_local_description(pc2, answer) + + :ok = PeerConnection.set_remote_description(pc1, answer) + end + describe "set_remote_description/2" do test "MID" do {:ok, pc} = PeerConnection.start_link()