Commit Graph

2053 Commits

Author SHA1 Message Date
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
Benny Daon
0180ee3805 Use OnOpen handler for DataChannels
Using an improvment of pion/datachannel, the channel opener can now
set an event to be called when the DATA_CHANNEL_ACK message is recieved

Resolves #1063
Relates to pion/datachannel#81
2021-10-28 11:59:51 -04:00
Mathis Engelbart
1eb3d4ca8d Fix media WriteRTP with empty RTP packet
github.com/pion/rtp to v1.7.4 fixed the parsing of padding bytes as
media payload. This fix skips over RTP packets with an empty payload,
such as unmarshalled padding only packets.
2021-10-27 10:03:11 -04:00
Sean DuBois
7ff112fc34 UDPMuxParams use net.PacketConn instead of UDPConn
UDPConn satisifies the net.PacketConn interface. Allows us to pass in
structures that satisfy the interface, but aren't a UDPConn
v3.1.6
2021-10-26 14:54:57 -04:00
Andrew N. Shalaev
13c9fd5e23 Missed second slash in schema protocol
Should be `rtp://`
2021-10-25 07:25:20 +02:00
Kevin Staunton-Lambert
39a10ae662 Improve rtp-to-webrtc documentation
Add quoting to the sample ffmpeg command to make it more copyable
2021-10-24 13:17:56 -04:00
Renovate Bot
7ab4bb0b80 Update module github.com/pion/rtp to v1.7.4
Generated by renovateBot
2021-10-24 13:10:14 -04:00
Artur Shellunts
3bc0dacdfd Use Reader instead of ReadSeeker in OggReader
Seek is not used. Also it makes not possible to use
OggReader for network streams.
2021-10-22 04:04:49 -04:00
Štefan Uram
c306e481a0 Corrected comment for "ogg read part" in example
Just a small correction of the confusing comment
2021-10-17 21:30:21 -04: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.
v3.1.5
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
v3.1.4
2021-10-15 11:21:16 -04:00
boks1971
b1a08a7e0d Use transceiver's codec in getCodecs
Issue:
------
A transceiver's codecs can be modified using `SetCodecPreferences`.
When retrieving codecs from the transceiver after changing codec
preferences of the transceiver (for example changing the SDPFmtpLine),
the filter function was using codec from the media engine. Thus,
the change from `SetCodecPreferences` is lost.

Fix:
----
- When a match is found (either exact or partial), use the codec from
the transceiver instead of media engine.
- Based on feedback, add checks to ensure that PayloadType is not
set incorrectly (i. e. set with a default of 0). If it is set to 0,
use the PayloadType from the media engine, i. e. negotiated value.

Testing:
--------
- Modify SDPFmtpLine of a codec of a transceiver using
`SetCodecPreferences` method of `RTPTransceiver`.
- Invoke `GetParamters` of `RTPREceiver` and ensure that `Codecs`
has the SDPFmtpLine modification. Before this change the change
was not reflected in the returned `Codecs`.
- Check that SDP has payload from codec set via SetCodecPreferences
v3.1.3
2021-10-12 22:05:15 -07:00
Will Forcey
5d0ea98f08 Improve DataChannel.Ordered documentation
Explain what true/false values represent
2021-10-10 21:23:58 -04:00
Renovate Bot
27b58892b5 Update module github.com/pion/dtls/v2 to v2.0.10
Generated by renovateBot
2021-10-10 12:32:45 -04:00
Artur Shellunts
85ec020450 Be more explicit examples/save-to-disk
save-to-webm saves VP8+Opus inside of a webm
2021-10-10 12:32:18 -04:00
Renovate Bot
1a4c60cb34 Update golang.org/x/net commit hash to d4b1ae0
Generated by renovateBot
2021-10-04 22:12:19 -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.
v3.1.2
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.
v3.1.1
2021-09-24 18:46:42 +01:00
Sean DuBois
5e98c50d8b Remove 'New Release' Section
v3.1.0 has been released, information is stale
2021-09-23 12:17:06 -04: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
v3.1.0-beta.10 v3.1.0
2021-09-17 15:53:51 -04:00
Sean DuBois
1231f4f8ac Add link to Bandwidth Estimation Ticket
Update links to TWCC and RTCP Reports
2021-09-15 16:18:21 -04:00
Mathis Engelbart
931b84bf3a Enabel TWCC for audio by default
This is what chrome does as well.
2021-09-15 16:01:06 -04:00
Sean DuBois
a1e2e206e2 Reduce PeerConnection_Close_PreICE
Remove time.Sleep
2021-09-15 15:48:10 -04:00
Sean DuBois
67a9913f00 Reduce PeerConnection_Media_Disconnected runtime
Set custom ICE timing via SettingEngine
2021-09-15 15:29:20 -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
Renovate Bot
f8fa792477 Update module github.com/pion/rtcp to v1.2.8
Generated by renovateBot
2021-09-15 14:37:37 -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.
v3.1.0-beta.9
2021-09-14 14:33:43 -04:00
Mathis Engelbart
5003380054 Enable TWCC by default
Add functions to configure TWCC reports and TWCC header extensions.
Only TWCC reports are enabled by default, because there is no Congestion
Controller available to handle reports from a remote peer, yet.
v3.1.0-beta.8
2021-09-12 13:38:00 -04:00
Dean Sheather
f8ecedc524 Fix double loop in data channel ID generation
(*SCTPTransport).generateAndSetDataChannelID performed a double loop to
find the next available data channel ID. This changes that behavior to
generate a lookup map with the taken IDs first, so generating a data
channel ID takes much less time.

Before, it would take more than 1000ms to generate the next data channel
ID once you had roughly 50k of them. Now it only takes 4ms at that same
point.

Fixes #1945
v3.1.0-beta.7
2021-09-07 20:45:30 -04:00
cnderrauber
c1fa55d5ef Fix RtpSender: may block infinite in Read
In RtpSender, if Read has been called and wait for srtpReady,
then if we call Close() immediately after
rtpSender.trasport.srtpReady, that means srtpWriterFuture's Close
may be called when it's init method is executing.

In Read -> init, goroutine may run at:
	rtpWriteStream, err := srtpSession.OpenWriteStream()
	if err != nil {
		return err
	}

	s.rtcpReadStream.Store(rtcpReadStream)
	s.rtpWriteStream.Store(rtpWriteStream)

In Close, goroutine may run at
	if value := s.rtcpReadStream.Load(); value != nil {
		return value.(*srtp.ReadStreamSRTCP).Close()
	}

	return nil

s.rtcpReadStream could be nil in the check at Close, so it
will not be closed.

And in Read method, the init method initiates the stream and
return. Then read at the stream's buffer, and blocked infinite
because the buffer is not closed. And it will not be closed
if you call RtpSender's close method because it is already
closed.
2021-09-05 22:01:31 -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.
v3.1.0-beta.6
2021-09-03 12:23:56 -04:00
Sean DuBois
f1831eb5ee Update GenerateCertificate to match libwebrtc
When attempting to interact with a WebRTC service a user was getting a
DTLS alert of UnknownCA. The remote service was asserting the lifetime +
subject of the certificate. This PR modifies Pion's certificate
generation code to match libwebrtc so it can work with the WebRTC
service.

Resolves #1940
v3.1.0-beta.5
2021-09-03 11:00:55 -04:00
Sean DuBois
d5095a1464 Fix race condition in startReceiver
startReceiver doesn't hold the lock when getting the SSRC. Use the
thread safe accessor
2021-09-02 15:59:28 -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
Renovate Bot
b4314a64f6 Update golang.org/x/net commit hash to e898025
Generated by renovateBot
2021-09-01 20:34:18 -04:00
Sean DuBois
a630d62dd4 Move Simulcast SDP Modification into helper
Will be used by Simulcast renegotation tests as well

Relates to #1345
v3.1.0-beta.4
2021-08-29 20:54:44 -04:00
Sean DuBois
ec3d65ea35 Improve SSRC Based Simulcast test
Relates to #1345
2021-08-29 13:26:23 -04:00
Sean DuBois
d570b78ae1 Implement SSRC Based Simulcast
Resolves #1345
2021-08-28 11:00:44 -04:00
Sean DuBois
e3ced781d0 Add E2E RID Simulcast test
Relates to #1345
2021-08-26 16:52:14 -04:00
Sean DuBois
8cbcb571c2 Use constants for MimeType
Replace VP8/H264/Opus string usage
2021-08-25 21:41:49 -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
Juliusz Chroboczek
fad7214193 Adapt samplebuilder new depacketizer in pion/rtp
Both partition head and tail checking is now done in the
depacketizer.  For backwards compatibility, there are stubs
for PartitionHeadChecker and WithPartitionHeadChecker that do
nothing; these should be removed for 4.0.

This also fixes a bug with the depacketizer: if no head checker
was present, every packet would be considered as a potential
partition head, even if it was at the beginning of the buffer.
Since a partition head checker is now always present, the bug
cannot happen.

The tests assume the old bug, which is why the fakePacketizer
returns true if headBytes is empty.  It would be better to adapt
the tests to do the right thing, as in jech/depacketizer.
2021-08-23 11:22:53 -04:00
Twometer
efc9500227 Improve play-from-disk example READMEs
Include notes about setting the bitrate
2021-08-22 22:11:50 -04:00
Sean DuBois
b03856c6c1 Populate ID/StreamID for Undeclared SSRC
Relates to #1808
2021-08-22 21:56:32 -04:00
Renovate Bot
9cc973052a Update golang Docker tag to v1.17
Generated by renovateBot
2021-08-20 21:59:00 -04:00
bkim
3a6aea1d2d Add MTU Configuration to SettingEngine
This gives an option to raise the receive MTU as SettingEngine option.
If SettingEngine has not been set the MTU, then default value is used
instead, 1460

Resolves #1925
2021-08-20 09:59:56 -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
Renovate Bot
651eaaef0f Update module github.com/pion/ice/v2 to v2.1.12
Generated by renovateBot
2021-08-14 11:52:59 -04:00
Sean DuBois
fbcb9cb673 Use time.Ticker in play-from-disk
time.Sleep is not precise, instead use a ticker.

Relates to golang/go#44343

Co-authored-by: Twometer <twometer@outlook.de>
2021-08-13 10:33:07 -04:00