Commit Graph

66 Commits

Author SHA1 Message Date
Juan Navarro
cbbb1c29e5 Fix disordered RIDs in SDP
Map iteration order is not guaranteed by Go, so it's an error to iterate
over a map in places where maintaining the same ordering is important.

This change replaces the map of simulcastRid{} with an array of the same
type. The simulcastRid{} type is extended to hold the rid-id which
previously was used as the key in the map.

Accesses to the map are replaced with range loops to find the desired
rid-id for each case.

Fixes #2838
2024-08-01 10:56:45 -04:00
cnderrauber
287d10638d Match header extensions to remote media sections
Firefox would send updated header extension
in renegotiation, e.g. publish a track without
simucalst then renegotiate second track with
simucalst, the two media secontions will have
different rtp header extensions in offer. Need
to match remote header extentions for each
media sections to avoid second track publish
failed.
2024-07-18 12:30:19 +08:00
knowmost
a97c420d0c Fix typos in multiple comments 2024-04-27 23:27:55 -04:00
Sean DuBois
fda6c4f836 Fix linter errors
golangci-lint upgrade to v1.56.2 added more checks

Relates to pion/.goassets#201
2024-03-16 21:09:38 -04:00
cnderrauber
2407bf2ed2 Refine rtx support
Always handle header extensions from packet read
from interceptor, let interceptor has consistent
chance to process headers

Fix rtx is not negotiated when there is multiple
codecs has same mime but different profile (H264)

Fix rtx stream info missed when SSRC group attr
shows after base track's ssrc attr.
2024-02-05 22:48:24 +08:00
cnderrauber
ee9717e95b Answer to paused simucalst stream correctly
Answer to paused simucalst stream correctly
2023-12-12 15:10:12 +08:00
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
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
renovate[bot]
ea23dec2b9 Update module transport, srtp, ice and turn
ReplayDetector introduced a breaking change
2023-09-03 23:59:43 -04:00
Steffen Vogel
683fc837d0 Make repo REUSE compliant 2023-05-05 11:58:49 -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
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
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
Daniele Sluijters
b8fd4d98ea Fix incorrect conversion between integer types
The result of strconv.Atoi uses an architecture dependent bit size. It
is not safe to use when converted to an integer type of a smaller size,
without performing bounds checking.

Instead, use Parse(U)int with the desired base and size. Though this
returns a (u)int64, it can then be safely converted into a (u)int8 etc.
2022-05-09 13:07:42 -04:00
Aaron Boushley
aa050eaa2f Resolve issue with rejecting tracks from Firefox
When running the reflect example against Firefox 99.0.1 I was receiving
errors around parsing the SDP from Pion.

The error was:

  SIPCC Failed to parse SDP: SDP Parse Error on line 50:  c= connection
  line not specified for every media level, validation failed.

According to the RFC
[4566 5.7](https://datatracker.ietf.org/doc/html/rfc4566#section-5.7)

  A session description MUST contain either at least one "c=" field in
  each media description or a single "c=" field at the session level.
  It MAY contain a single session-level "c=" field and additional "c="
  field(s) per media description, in which case the per-media values
  override the session-level settings for the respective media.

I don't see any errors in the Pion repos for this. Interestingly the
webrtc-rs project that is porting Pion to rust has
[an issue](https://github.com/webrtc-rs/webrtc/issues/144)
where they're encountering this same error.
2022-05-02 10:46:31 -04:00
Yutaka Takeda
9f990dbca4 Fix ice-lite attribute
Fixes #2195
2022-04-27 17:07:09 -07:00
boks1971
37e16a3b15 Bolting on send side simulcast
Introduces AddEncoding method in RTP sender to add simulcast encodings.

Added UTs for AddEncoding.
Also modified the Simulcast send test to use the new API.
2022-02-24 23:55:17 -08: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
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
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
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
boks1971
ef285fbe09 Use RIDs for SSRC resolution
Problem:
--------
Firefox (testing with Firefox 93) sends an `offer`
with simulcast track which includes both RIDs and SSRCs.

When track details are gathered, RIDs are fetched
using `getRids` which returns a map. A `range` is
done on the returned map and RIDs are appended to
the `rids` array in `trackDetails`.

And then SSRCs are read from SDP and set into the
`ssrcs` array of `trackDetails`.

As map range order is not guaranteed, some times
the RID index and SSRC index in their respective arrays
do not match.

Due to the mismatch, services like ion-sfu which rely
on RID to find the correct spatial layer get confused
and end up forwarding the wrong layer.

Solution(s):
------------
There are three possible solutions I could think of

1. The simplest is to not populate SSRCs in `trackDetails`
if RIDs are available. Let `handleIncomingSSRC` do the
SSRC resolution based on RID.

According to RFC 8853 (https://www.ietf.org/rfc/rfc8853.pdf),
the binding to SSRC should happen using RID.

This is the change I have made in this PR. See testing
below for browsers tested.

2. Look for `simulcast` attribute in SDP and take
the RID ordering from that line in `getRids` if that
attribute is available. If not fall back to `rid` attribute.

Also, change `getRids` to return an array.

But, I cannot find an RFC which defines behaviour when
both RID and SSRC are used in `offer`. The question is,
"Will the `ssrc` attribute ordering match the `rid`
ordering?". If that is not guaranteed, this will run
into trouble.

This should be easy to do though if we want to go down this
route.

3. The hardest option is to change the receiver SSRC based
on RID. But, that makes it too complicated (for example
if we have to change SSRC binding of a receiver based on
received RID, there will be two receivers with the same SSRC
binding unless there is some way to swap bindings of receivers)

Testing:
--------
Tested on Firefox, Firefox 78.15.0esr, Chrome, Ssafari and
ensured that Simulcast sender and receiver are in sync for
rid/ssrc/spatial layer resolution.
2021-10-29 19:42:56 -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
Sean DuBois
f872a1cb12 Fix filterTrackWithSSRC
This function would only consider tracks with at least one SSRC
assigned. If it processed a RID based track it would discard it.
2021-09-14 14:33:43 -04:00
Sean DuBois
7e5b9c320f Implement Simulcast Track shutdown
Write tests for a Simulcast transceiver going to inactive and mid
changing
2021-09-02 15:31:11 -04:00
Sean DuBois
a630d62dd4 Move Simulcast SDP Modification into helper
Will be used by Simulcast renegotation tests as well

Relates to #1345
2021-08-29 20:54:44 -04:00
Sean DuBois
d570b78ae1 Implement SSRC Based Simulcast
Resolves #1345
2021-08-28 11:00:44 -04:00
Sean DuBois
89042ee5f6 Don't consider simulcast for undeclared SSRC
If we have a media section with no SSRC we would fire an OnTrack. This
code now properly ignores a MediaSection that has a rid attribute.

Resolves #1808
2021-08-24 17:02:21 -04:00
Sean DuBois
0735efd344 Throw error earlier for RTPSender with no codecs
It isn't possible to send media if a MediaEngine has no codecs. This
catches a common misconfiguration issues that users find themselves in.

Resolves #1702
2021-08-15 07:54:53 -04:00
digitalix
06a5a14197 Fixes issue 1822
Previously we could have situations where during
first condition like `transceiver.Sender() != nil`
there would be another condition like
`transceiver.Sender().isNegotiated()` where
`.Sender()` could become nil if changed in
a different goroutine.
2021-08-03 11:39:46 -04:00
digitalix
f524fea32a Implement SetCodecPreferences in RTPTransceiver
This allows to set supported codecs per transceiver.

Resolves #1847
2021-06-28 10:54:31 -04:00
Markus Tzoe
fb4b5826ae Fixes SDP session id
SDP session id should stay unchanged for subsequent offers/answers
2021-04-15 06:19:26 +08:00
Markus Tzoe
56ef4b73c5 PeerConnection: make AddTrack thread-safe
Use fine granularity rw-mutex to protect rtpTransceivers and for
exclusively accessing AddTrack and RemoveTrack

Fixes `shouldAddCandidates` typo in sdp.go
2021-04-03 10:51:19 -07:00
Sean DuBois
5a3d41ed77 Use proper values for application media section
Update from draft-ietf-mmusic-sctp-sdp
2020-12-23 23:44:23 -08:00
Sean DuBois
3d9a7ede1a Allow extensions to be configured with direction
RegisterHeaderExtension now allows users to enable headers depending on
the type of transceiver that was created.

Also expose GetParameters on RTPSender and RTPReceiver

Co-authored-by: OrlandoCo <luisorlando.co@gmail.com>

Resolves #1554
2020-12-04 11:52:48 -08:00
Sean DuBois
74e790aa11 Update to pion/sdp@v3.0.3
Minor API changes
2020-11-18 22:05:21 -08:00
Sean DuBois
7edfb701e0 New Track API
The Pion WebRTC API has been dramatically redesigned. The design docs
are located here [0]

You can also read the release notes [1] on how to migrate your
application.

[0] https://github.com/pion/webrtc-v3-design
[1] https://github.com/pion/webrtc/wiki/Release-WebRTC@v3.0.0
2020-11-15 09:20:47 -08:00
tarrencev
78f7c978fe Safely mutate local description
adding candidates races with negotiation check
2020-11-03 00:22:41 -05:00
tarrencev
0582c689dd Fix: only add ice candidates on first m section
The use of a BUNDLE transport allows the usage of a single set of
   Interactive Connectivity Establishment (ICE)
   [I-D.ietf-ice-rfc5245bis] candidates for the whole BUNDLE group.
   A given BUNDLE address:port MUST only be associated with a single
   BUNDLE group.  If an SDP offer or answer contains multiple BUNDLE
   groups, the procedures in this specification apply to each group
   independently.  All RTP-based bundled media associated with a given
   BUNDLE group belong to a single RTP session [RFC3550].
2020-11-03 00:22:41 -05:00
Sean DuBois
804a12fed3 Update CI configs to v0.4.7
Update lint scripts and CI configs.
2020-09-30 09:06:34 -07:00
Sean DuBois
2155a7d703 Move candidate parsing to pion/ice
Instead of having logic in pion/webrtc and pion/sdp move all logic to
pion/ice. Users of pion/ice don't want to import these packages to use
basic pion/ice functionality.
2020-09-13 00:05:09 -07:00
Sean DuBois
69883c5d5a Fix renegotation race
checkNegotiationNeeded accessed RtpSender field with taking lock

Resolves #1384
2020-09-07 22:52:44 -07:00
Kuzmin Vladimir
2c5819d521 Implement OnNegotiationNeeded
This event is fired when a change has occurred
which requires session negotiation.

Resolves #817
2020-08-19 14:37:18 -05:00
Jason
6ee528d349 Add Simulcast support
Resolves #1016
2020-07-24 01:01:43 -07:00
Jason
58956684f8 Implement answering to RIDs
When responding to a remote description
with RIDs we now properly respond
2020-07-10 15:14:44 -07:00
Sean DuBois
ef1d5a4a8b Add extmap support
Extmaps are configured via the SettingEngine. This allows a user
to set arbitrary values, and when answering ids and entries are
properly excluded.

Co-authored-by: Gabor Pongracz <gabor.pongracz@proemergotech.com>
2020-07-03 01:01:56 -07:00
Woodrow Douglass
baf14a9af4 Media Level Fingerprints Configuration Option
This commit adds an option to put DTLS Fingerprint specification
at the media description level rather then the session description
level. This enhances compatibility with some 3rd party webrtc
implementations (notably Kurento).
2020-06-30 01:37:15 -07:00
Ivan Egorov
57b83f2c55 Early for loop continue while sdp codecType check
In sdp.go in codecType zero check.
Don't enter media.Attributes loop.
2020-06-18 03:20:36 -07:00
Sean DuBois
3a60d8dae8 Support ICE values at session level
Also add tests to assert we don't have conflicting values. This could
have happened before but we never tested for it.
2020-06-10 00:17:06 -07:00