Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
LVala committed Nov 24, 2023
1 parent 37ebbf0 commit 1672d8d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
6 changes: 6 additions & 0 deletions lib/ex_webrtc/dtls_transport.ex
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@ defmodule ExWebRTC.DTLSTransport do
{:noreply, state}
end

@impl true
def handle_cast({:send_rtp, _data}, state) do
Logger.warning("Attemped to send RTP before DTLS handshake has been finished")
{:noreply, state}
end

@impl true
def handle_cast({:send_rtcp, _data}, state) do
# TODO: implement
Expand Down
6 changes: 2 additions & 4 deletions lib/ex_webrtc/peer_connection.ex
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,6 @@ defmodule ExWebRTC.PeerConnection do
@impl true
def handle_info(msg, state) do
Logger.info("OTHER MSG #{inspect(msg)}")

{:noreply, state}
end

Expand Down Expand Up @@ -450,6 +449,8 @@ defmodule ExWebRTC.PeerConnection do
:ok = ICEAgent.set_remote_credentials(state.ice_agent, ice_ufrag, ice_pwd)
:ok = ICEAgent.gather_candidates(state.ice_agent)

# TODO: this needs a look

new_remote_tracks =
new_transceivers
# only take new transceivers that can receive tracks
Expand All @@ -463,9 +464,6 @@ defmodule ExWebRTC.PeerConnection do
notify(state.owner, {:track, track})
end

tracks_map = Map.new(new_remote_tracks, &{&1.id, &1})
state = %{state | tracks: Map.merge(state.tracks, tracks_map)}

state = set_description(:remote, type, sdp, state)

if type == :answer do
Expand Down
2 changes: 1 addition & 1 deletion test/ex_webrtc/dtls_transport_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ defmodule ExWebRTC.DTLSTransportTest do
end

test "cannot send data when handshake not finished", %{dtls: dtls} do
DTLSTransport.send_data(dtls, <<1, 2, 3>>)
DTLSTransport.send_rtp(dtls, <<1, 2, 3>>)

refute_receive {:fake_ice, _data}
end
Expand Down
4 changes: 2 additions & 2 deletions test/ex_webrtc/peer_connection_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ defmodule ExWebRTC.PeerConnectionTest do
offer = %SessionDescription{type: :offer, sdp: File.read!("test/fixtures/audio_sdp.txt")}
:ok = PeerConnection.set_remote_description(pc, offer)

assert_receive {:ex_webrtc, ^pc, {:track, %MediaStreamTrack{mid: "0", kind: :audio}}}
assert_receive {:ex_webrtc, ^pc, {:track, %MediaStreamTrack{kind: :audio}}}

offer = %SessionDescription{
type: :offer,
Expand All @@ -24,7 +24,7 @@ defmodule ExWebRTC.PeerConnectionTest do

:ok = PeerConnection.set_remote_description(pc, offer)

assert_receive {:ex_webrtc, ^pc, {:track, %MediaStreamTrack{mid: "1", kind: :video}}}
assert_receive {:ex_webrtc, ^pc, {:track, %MediaStreamTrack{kind: :video}}}
refute_receive {:ex_webrtc, ^pc, {:track, %MediaStreamTrack{}}}
end

Expand Down

0 comments on commit 1672d8d

Please sign in to comment.