@@ -142,6 +142,16 @@ defmodule ExWebRTC.PeerConnection do
142142 GenServer . call ( peer_connection , { :controlling_process , controlling_process } )
143143 end
144144
145+ @ doc """
146+ Returns current `peer_connection` configuration.
147+
148+ Note: the configuration may change after applying remote description.
149+ """
150+ @ spec get_configuration ( peer_connection ( ) ) :: Configuration . t ( )
151+ def get_configuration ( peer_connection ) do
152+ GenServer . call ( peer_connection , :get_configuration )
153+ end
154+
145155 @ doc """
146156 Sends an RTP packet to the remote peer using the track specified by the `track_id`.
147157
@@ -561,6 +571,11 @@ defmodule ExWebRTC.PeerConnection do
561571 { :reply , :ok , state }
562572 end
563573
574+ @ impl true
575+ def handle_call ( :get_configuration , _from , state ) do
576+ { :reply , state . config , state }
577+ end
578+
564579 @ impl true
565580 def handle_call ( :get_connection_state , _from , state ) do
566581 { :reply , state . conn_state , state }
@@ -1097,6 +1112,12 @@ defmodule ExWebRTC.PeerConnection do
10971112 |> Enum . find ( fn { tr , _idx } -> tr . sender . track && tr . sender . track . id == track_id end )
10981113 |> case do
10991114 { tr , idx } ->
1115+ # When RTP packet comes from another peer connection,
1116+ # it can already have some extensions, in particular,
1117+ # extensions that we didn't negotiate (consider simulcast and rid).
1118+ # Remove these extensions and add ours.
1119+ packet = ExRTP.Packet . remove_extensions ( packet )
1120+
11001121 { packet , state } =
11011122 case state . twcc_extension_id do
11021123 nil ->
@@ -1107,10 +1128,7 @@ defmodule ExWebRTC.PeerConnection do
11071128 ExRTP.Packet.Extension.TWCC . new ( state . sent_packets )
11081129 |> ExRTP.Packet.Extension.TWCC . to_raw ( id )
11091130
1110- packet =
1111- packet
1112- |> ExRTP.Packet . remove_extension ( id )
1113- |> ExRTP.Packet . add_extension ( twcc )
1131+ packet = ExRTP.Packet . add_extension ( packet , twcc )
11141132
11151133 state = % { state | sent_packets: state . sent_packets + 1 &&& 0xFFFF }
11161134 { packet , state }
0 commit comments