Commit Graph

276 Commits

Author SHA1 Message Date
Woodrow Douglass
13450332a4 Remove the "Unknown" constant
This commit replaces the Unknown constant with
separate constants for each enumeration that
uses it.

Fixes #1293
2023-09-12 13:29:05 -04:00
Sean DuBois
5cf4168432 Fix OnICEGatheringStateChange Signature
Return ICEGatheringState not ICEGathererState

Relates to #2557
2023-09-11 14:32:23 -04:00
Aleksandr Alekseev
e507d46e1c Improve checkNegotiationNeeded replaceTrack
replaceTrack with nil would cause a crash
2023-09-08 14:08:02 -04:00
cnderrauber
2225386c41 Generate answer to match group bundle in offer
Generate answer to match group bundle in offer
2023-09-08 09:30:52 -07:00
Sean DuBois
dc4b591c4d Start pion/webrtc/v4
60eea43 is a breaking change
2023-09-05 11:48:14 -04:00
Sean DuBois
60eea430ac Close PeerConnection on DTLS CloseNotify
Resolves #1767
Resolves pion/dtls#151
2023-09-05 04:52:17 -04:00
renovate[bot]
ea23dec2b9 Update module transport, srtp, ice and turn
ReplayDetector introduced a breaking change
2023-09-03 23:59:43 -04:00
zhngs
20f83933c3 Fix incorrect ice-lite comment
The lite agent is controlled, not controlling.
2023-09-03 14:09:14 -04:00
Hao
1390b16097 Fix typo 'Renegotation' across project
'Renegotation' -> 'Renegotiation'
2023-08-24 14:14:29 -04:00
Kunal Singh
1df634e118 Remove golint from godoc and move no next line 2023-05-22 15:20:59 -04:00
Steffen Vogel
683fc837d0 Make repo REUSE compliant 2023-05-05 11:58:49 -04:00
Jerry Tao
16fea9ee04 Set DataChannel SCTPTransport before OnDataChannel
ORTC API would return a nil SCTPTransport for DataChannels returned via
Callback
2023-04-24 00:51:50 -04:00
streamer45
d08b3dc403 Handle Simulcast Offer with one Media Section
Everytime we receieve a new SSRC we probe it and try to determine the
proper way to handle it. In most cases a Track explicitly declares a
SSRC and a OnTrack is fired. In two cases we don't know the SSRC
ahead of time
* Undeclared SSRC in a single media section (pion/webrtc#880)
* Simulcast

The Undeclared SSRC processing code would run before Simulcast.
If a Simulcast Offer/Answer only contained one Media Section we
would never fire the OnTrack. We would assume it was a failed
Undeclared SSRC processing. This commit fixes the behavior.
2023-04-23 00:04:54 -04:00
cnderrauber
6114c278c1 Fix simucalst track set to incorrect detail
When there are more than one simucalst media lines in sdp,
we need check mid when parse detail for simulcast track.
2023-04-14 08:56:55 -07:00
Pion
308f8616a3 Update CI configs to v0.10.6
Update lint scripts and CI configs.
2023-04-08 14:24:19 -04:00
Eric Daniels
777e03ca3c Fix negotiation needed panic on nil Sendonly track
In step 5.3.1, since we do not have a sender we can only choose
to signal that we need negotiation.
2023-03-07 22:59:45 -08:00
cnderrauber
220b1f37ee Refine updateConnectionState
Make updateConnectionState consistent with
https://www.w3.org/TR/webrtc/#rtcpeerconnectionstate-enum
2023-03-03 15:35:49 +08:00
cnderrauber
3c802f7169 Reuse passive created sendonly transceiver
When peerconnection create a transceiver by remote's recvonly
offer, the transceiver will have nil sender but can't be reused
since its currentDirection is set to sendonly. This pr change
the currentDirection to inactive so it can be reused by AddTrack.
2023-01-31 19:18:35 +01:00
Jerko Steiner
5b41ed600e Revert "Revert "Add currentDirection to RTPTransceiver""
This reverts commit a92c400e5a.
2023-01-28 13:39:58 +01:00
Jerko Steiner
a92c400e5a Revert "Add currentDirection to RTPTransceiver"
This reverts commit 045df4c4bf.
2023-01-28 13:37:08 +01:00
cnderrauber
fa6be2c31d Fix lint error
Fix lint error
2022-11-15 17:12:22 +08:00
cnderrauber
9713221231 Close unhandled stream when peerconnection closed
When PeerConnection closed, need call unhandled stream's
close method to release buffer created by BufferFactory,
otherwise might cause resource leak if user
provide BufferFactory need close to release the resource.
2022-11-15 17:12:22 +08:00
cnderrauber
81376b2ca8 Fix generated Mid conflict with user set Mid
Inside one cycle renegotiation, if user both has manually set Mid
and auto generated Mid for transceivers, CreateOffer will failed
for Mid conflict.
2022-09-30 14:54:41 +08:00
cnderrauber
045df4c4bf Add currentDirection to RTPTransceiver
add currentDirection to RTPTransceiver, don't reuse
transceiver if its currentDirection is sendrecv or sendonly
2022-09-15 09:24:56 +08:00
Sean DuBois
7367daf232 Increase requirements for Plan-B detection
Before a SessionDescription was assumed to be Plan-B if it contained a
MediaName of `audio` or `video`. This PR Changes that behavior.

If SDPSemantics is UnifiedPlan the SessionDescription must contain a
MediaDescription with two SSRCes to be considered a Plan-B. Before if
the MediaDescription had name of `audio` or `video` it was assumed to be
Plan-B.

If SDPSemantics is PlanB or UnifiedPlanWithFallback it maintains the
existing behavior.

Resolves #2193
2022-05-23 10:13:02 -04:00
Forest Johnson
5c737e1f87 Add note to OnICECandidate on when ICE Gathering
ICE Gathering is triggered by SetLocalDescription and
SetRemoteDescription
2022-05-13 12:51:06 -04:00
cnderrauber
0c8ce8e15c Set extmap-allow-mixed by default
For support with dependency descriptor, chrome will use
mixed extmap both one-byte and two-byte defined in RFC8285,
add the attribute to support that
2022-05-12 12:19:25 +08:00
Pion
c1467e4871 Update CI configs to v0.7.2
Update lint scripts and CI configs.
2022-04-27 23:00:19 -04:00
Sean DuBois
2cc6ea01ba Use ICETransport private fields for PeerConnection
PeerConnection used the public OnConnectionStateChange to track the
status of the ICETransport. This was incorrect because a user can
override this value at anytime.

Add a new internalOnConnectionStateChangeHandler that is set directly by
the PeerConnection and not accessible to the user.
2022-04-22 23:47:56 -04:00
boks1971
8796a5c5a7 Use ICE role to set DTLS role in answer
When creating answer, check ICE role while determining DTLS role.
ORTC thread on how roles are set
https://github.com/w3c/ortc/issues/167#issuecomment-69409953

When remote is ice-lite and there is no answering role set,
the answer uses the default which is DTLS client. So 'setup'
is set as 'active' and answer sent.

But, when DTLS transport is started, it checks the ICE role
and sets itself as DTLS server (because remote is lite
and hence local agent becomes controlling ICE agent).

So, both sides end up being DTLS server and nobody sends
client hello.
2022-02-02 12:33:59 -05:00
Sean DuBois
65b51732e2 Don't close the SRTP Stream in handleIncomingSSRC
`AcceptStream` will then be fired again for this SSRC. We depend on the
behavior of AcceptStream only returning once for each SSRC.
2022-01-31 16:27:11 -05:00
Sean DuBois
2949e539b7 Ignore explicit SSRCes in RID Simulcast processing
If the SRTP Stream hasn't been opened yet we would attempt to process
(and fail) RTP traffic. This change causes us to not even attempt to
read.

No behavior change from this, but will cause less useless logging.
2022-01-31 16:27:11 -05:00
Sean DuBois
157220e800 Run gofmt to add new build constraints
Also remove some 1.13 specific WASM code
2022-01-17 22:36:01 -05:00
boks1971
04ca4493f6 Set up RTP Receivers synchronously
Do the set up of RTP receivers synchronously so that they
are ready to receive media as soon as signalling to remote
side is sent. Once signalling to remote side is sent, the
remote can send media at any time and receiver has to be ready.

Like the bug mentions, a negotiation quickly followed by
a renegotiation left the RTP receivers of the tracks in the
second offer not set up. If the tracks in the renegotiation
happen to be simulcast tracks, they are missed as browsers
send RID only in the first few packets.

The problem can be reproduced by introducing a 1 second
delay in Downstream direction in Network Link Conditioner
and using a modified version of LiveKit JS SDK sample app to
force a double negotiation spaced closely.

With this change, onTrack fires, but the unhandled warning
from RTCP for the highest layer still happens. But, the
track fires almost immediately following that warning
(less than 5 ms later). So, all the simulcast layers
are available.

Resolves #2054
2022-01-17 14:57:24 -05:00
cnderrauber
dd9d4c503c Make setMid of Transceiver public
in some case like session migration from one sfu node
to another, we need manual set mid of transceiver instead of
auto generate, to make mid consistent between to sfu node.
2022-01-06 22:06:18 +08:00
Len
425f5c6cef Handle implicitly created inactive transceiver
If SetRemoteDescription is called with offer SDP which
has a=invalid, PeerConnection sets its transceiver direction
as recvonly. Fix direction recvonly to invalid.

Resolves #2050
2021-12-28 20:22:36 -05:00
Sean DuBois
6160e8033f Handle unknown ICE Candidate Transport
rfc8839#section-5.1 specifies that a WebRTC Agent MUST
ignore any name/value pairs it doesn't understand. When
we parse a candidate and it fails because we don't understand
the type we now log and continue.

Resolves pion/webrtc#1949
2021-12-15 15:58:48 -05:00
Sean DuBois
2699584e9a Handle unknown ICE Candidate Type
rfc8839#section-5.1 specifies that a WebRTC Agent MUST
ignore any name/value pairs it doesn't understand. When
we parse a candidate and it fails because we don't understand
the type we now log and continue.

Resolves pion/webrtc#1949
2021-12-15 13:37:34 -05:00
Sean DuBois
8a10f67d5a Better error message on SDPSemantics mismatch
Tell user what RemoteDescription was detected as, and what was expected

Resolves #2011
2021-12-12 23:09:23 -05:00
brian
883973804d Add swap function to atomicBool
PeerConnection setting to closed was not an atomic operation before
2021-11-20 13:44:43 -05:00
cnderrauber
635bfd9cad Set prefer codec created by remote sdp
If a transceiver is created by remote sdp, then set
prefer codec same as offer peer.
For pion's codec match, it will use exact match
first, and then partial match. If patial match
only, the partial match codecs will become
negotiated codes. So it will be set prefer codec
when only exist partial match. And has same payload.

Add test cast for this.

refer to https://www.w3.org/TR/webrtc/#bib-rfc8829
2021-11-12 14:05:33 +08:00
Sean DuBois
1705641fa4 Open all DataChannels before accepting remote
A race existed with Negotiated DataChannels before this. Before
the remote could sends us a DataChannel message before the
datachannel was negotiated locally. We would then discard the
message and print an error.

This PR moves the processing of remote datachannel messages after
we have registered all local ones. It also informs
datachannel.Accept of existing datachannels in order to prevent
any initialization logic from proceeding incorrectly.
2021-11-09 10:51:14 -05:00
Sean DuBois
b8aacec16f Fix typo in f5840a
When filtering SSRCes we were running the filter operation on the source
slice and not the filtered slice. Causing us to ignore all the filter
operations that had been previously run.
2021-10-15 12:00:34 -04:00
boks1971
f5840a7dc8 Fix Simulcast + non-simulcast remote tracks
Problem:
--------
In the following negotiation sequence, the Simulcast track is lost.
1. Remote Offer with Simulcast tracks with rids
2. A new track added to Remote Offer with tracks using SSRCs

When the updated `offer` is received, the Simulcast transceiver's
receiver gets overwritten because the tracks from SDP is compared
against current transceivers. The current transceiver for the
Simulcast track already had SSRCs set as media has been received.
But, tracks read from the SDP only has `rid`. So, no current
transceiver matches and hence a new receiver is created which
clobeers the good Simulcast receiver.

Fix:
----
- Prioritize search by `rid`.
- Also found a case of a loop where the index was missing entries
in the loop. Fix it.

Testing:
--------
- The above case works
2021-10-15 11:21:16 -04:00
Sean DuBois
80da22268a Handle non-Simulcast Repair Streams
Same issue with TWCC enabled as 11b887. We need to process the
RTX packets so that we can emit proper reports.
2021-10-04 22:08:27 -04:00
digitalix
f93ea80d85 Revert "Make RTPTransceiver Stopped an atomic"
This reverts commit 6c3620093d.
This commit would cause sender.ReadRTCP() to never return
even when pc associated with this sender was closed.
The aftermath is leaked goroutines that will never stop.
2021-09-24 18:46:42 +01:00
Sean DuBois
dce9704383 Add InterceptorFactory
Interceptors are being accidentally misused by users.
The issue is that an Interceptor can be re-used between
multiple PeerConnections. Interceptors were designed to only be
single PeerConnection aware, so state is being corrupted.

Instead we are now going to provide InterceptorFactories. The default
API of pion/webrtc will now be safe to use between PeerConnections.

Resolves webrtc#1956
2021-09-17 15:53:51 -04:00
Sean DuBois
11b8873da2 Handle Simulcast RepairStream
Read + Discard packets from the Simulcast repair stream. When a
Simulcast stream is enabled the remote will send packets via the repair
stream for probing. We can't ignore these packets anymore because it
will cause gaps in the feedback reports

Resolves #1957
2021-09-15 15:08:22 -04:00
Sean DuBois
6c3620093d Make RTPTransceiver Stopped an atomic
Add an accessor to make getting value easy. Also add
TestPeerConnection_SkipStoppedTransceiver. This commit also cleans
up RTPTransceiver creation. We used a helper function, when we should
have just used the provide constructor
2021-09-04 15:15:36 -04:00
Sean DuBois
294595aff5 Start undeclaredMediaProcessor before RTP Handlers
Before we wouldn't start the undeclaredMediaProcessor until SCTP had
finished. If SCTP never finishes an inbound RTP packet with an unknown
SSRC would cause all RTP processing to hang.
2021-09-03 12:23:56 -04:00