Commit Graph

82 Commits

Author SHA1 Message Date
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
Sean DuBois
b03856c6c1 Populate ID/StreamID for Undeclared SSRC
Relates to #1808
2021-08-22 21:56:32 -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
Sean DuBois
cffa6afc34 Rollback pion/rtp to v0
Resolves #1908
2021-08-02 18:05:45 -04:00
Sean DuBois
a67c66a0c5 Upgrade pion/rtp to v2
Also updates interceptor and srtp
2021-07-29 11:18:41 -04:00
Markus Tzoe
a0b3117680 RtpTransceiverInit => RTPTransceiverInit
since RtpTransceiverInit is deprecated
2021-04-15 06:19:26 +08:00
Tomek
9b859870c0 Implement WASM Media methods
Add AddTransceiverFromKind and GetTransceivers. This doesn't support
everything, but enough to at least build a recvonly experience.

Resolves #500
2021-04-12 18:55:56 -07:00
Markus Tzoe
338dfa81f1 SCTPTransport: add association()
use assocation() instead of accessing private struct member from
outside
2021-04-06 20:54:46 -07: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
9c7b365144 Use closePairNow in tests
Instead of explicitly closing each PeerConnection use helper.
No change in test behavior, just makes code more consistent.
2021-02-16 15:47:58 -08:00
mission-liao
40eb352909 Add SetReadDeadline to RTPSender
ReadDeadline is supported by RTPReceiver but not RTPSender. This
commit attempts to provide similar method for RTPSender.

If SetReadDeadine is called with:
- an empty time.Time: it will clear all previous set deadline.
- a non-empty time.Time: it will abort all pending "ReadRTCP" calls if
  the specified time is up.
2021-02-04 10:16:44 +08:00
Juliusz Chroboczek
16407672bd Avoid infinite loop in CreateOffer
If the local description keeps getting changed, or in case of a but
in Pion, CreateOffer never terminates, which could cause client software
to hang.  Set an arbitrary bound on the number of iterations.

Relates to #1656
2021-02-03 08:50:38 -08:00
Sean DuBois
67826b1914 Update Interceptors to use []byte based API
Also update test to assert Attributes get passed all the way through

Resolves pion/interceptor#14
2020-12-13 18:40:33 -08:00
Sean DuBois
63401a8837 Store Accepted Simulcast in routine
pion/srtp requires that all incoming streams are accepted. You
can't close if you have unaccepted streams. At the same time
storeSimulcastStream blocks on taking the DTLSTransport lock.

Move `storeSimulcastStream` into a routine so that all streams can
be accepted and aren't blocked on taking the DTLSTransport lock.

Resolves #1586
2020-12-08 18:33:48 -08:00
Sean DuBois
70fb90c7fd Fix Simulcast routine leak
When a new SSRC is seen we start a Read loop for the packets. However if
we only see one packet this loop will just sit forever. If a user
doesn't send us enough packets to finish probing it will prevent any
subsequent streams from being probed.

Relates to #1345
2020-12-07 09:18:15 -08:00
Sean DuBois
9715626a0c Revert "Read/Write RTP/RTCP packets with context"
This change caused a ~24% performance decrease

Relates to pion/webrtc#1564

This reverts commit 47a7a64898.
2020-12-02 20:11:06 -08:00
Atsushi Watanabe
47a7a64898 Read/Write RTP/RTCP packets with context
Control cancel/timeout by context.
2020-12-01 11:08:48 +09:00
Sean DuBois
e32d766199 Improve TrackLocal error handling
* Return error to user when remote doesn't support codecs
* Assert that bindings are properly incremented/decremented
* Assert that a added track doesn't error even when disconnected

Relates to #1526
2020-11-27 23:07:29 -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
Juliusz Chroboczek
a952829951 Don't lose packet for OnTrack PayloadType probe
Dropping a packet at the beginning of every track is bad, since
it corrupts the first keyframe of each video track.  This works
by adding a peek method to Track, and using it in NewTrack.

The peeked data is protected by the RWLock already associated
with the track.  We check for its presence with the reader lock
taken, which avoids taking the writer lock (or doing an atomic read)
in the common case (no peeked data).

Fixes #1001
2020-10-05 19:05:27 -07: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
Woodrow Douglass
8090cca216 Refactor some PeerConnection Tests
This is to support the removal of implicitly
created data channels.
2020-07-29 12:57:37 -07:00
Sean DuBois
bb3aa9717f Move to pion/ice@v2
Removed support for trickle ice

Resolves #1274
2020-06-28 00:01:47 -07:00
Sean DuBois
89d7de1787 Start /v3
See #9 for the features we have planned, and the breaking changes that
may occur.
2020-06-25 09:45:27 -07:00
Sean DuBois
1cbdd5f45a Fix single track PlanB offers
We had an off-by-one when generating PlanB offers. Fix and add a test
2020-06-02 12:10:36 -07:00
Juliusz Chroboczek
9bbffdd5aa Simplify operations
Operations is now essentially a slice protected by a single lock.  No
lock is held during execution, serialisation is guaranteed by ensuring
that there is at most one goroutine running at a time.  A coincidental
benefit is that we now won't deadlock if an operation panics.

While this should be slightly faster, the main point of this change is
to reduce the amount of noise in the blocking profile.
2020-05-31 15:39:19 -07:00
Josh Bleecher Snyder
e42bb3e27a Use exported errors for stopped rtp i/o
This makes checking for these errors much more robust
than doing a string comparison.
2020-05-31 11:17:52 -07:00
cnderrauber
667941621d RtpSender/Receiver.Read return err when stopped
Rtpsender.Read & RtpReceiver.Read may block infinite when
it's stopped before Send/Receive has been called.
2020-05-28 20:24:19 -07:00
Jerko Steiner
b66c3c4903 Add operations queue for setting descriptions
Most likely fixes #1157
2020-05-13 22:00:52 +02:00
Jerko Steiner
b6e0eb2a34 Fix hanging test Transceiver_Mid
Fixes #1186
2020-05-06 21:43:17 +02:00
Simone Gotti
9cd89ddc00 Start the right receiver
From PR #1158 during negotiation every required transceiver is assigned
to a specific media section (using the media section mid value).

The same should be done when starting receivers. We should start the
receiver assigned to the media section of that track.
2020-05-06 19:37:45 +02:00
Simone Gotti
15638d89de Start only negotiated senders
Only start senders that were negotiated.

Since `startTransports`/`startRenegotiation` start rtp senders in a
goroutine, an user could call AddTrack/Add*Transceiver/RemoveTrack
causing a not negotiated sender track ssrc to be started.
2020-05-06 17:57:47 +02:00
Simone Gotti
1ba672fd11 Improve transceiver selection
This tries to better match the JSEP spec and will fix at least two
issues:

* #1171
* #1178

* Move transceiver selection/creation in SetRemoteDescription and
CreateOffer
* In SetRemoteDescription also create new Transceivers of type recvonly
when no satisfying transceiver is available
* In CreateOffer generate unique mid in number format avoiding possible
collisions with remote provide mids and to also already handle a future
implementation of m= section rejection and reuse
* Now generateMatchedSDP will just find the transceivers with the
required mid since they are already selected previously.

More details in these extract from JSEP:

JSEP 5.10 (Applying a Remote Description) says:

```
For each m= section, the following steps MUST be performed

[...]

If the m= section is not associated with any RtpTransceiver
(possibly because it was dissociated in the previous step),
either find an RtpTransceiver or create one according to the
following steps:
```

JSEP 5.2 (Constructing an Offer) says:

```
[...]

An m= section is generated for each RtpTransceiver
that has been added to the PeerConnection, excluding any stopped
RtpTransceivers;
```

Note that we are currently directly associating a mid to a transceiver
in CreateOffer, instead the spec says to also keep a m= section index
mapping to a transceiver and set the transceiver mid only when applying
the local description. This is needed to support rollback of proposed
offer/answer but currently we don't have support and tests for rollback
situations.
2020-05-05 14:03:20 +02:00
Jerko Steiner
8013159fff Add RTPTransceiver.Mid()
Refactor existing code for Unified Plan to ensure the same transceiver
will always be associated with the media description by mid.
2020-04-29 09:05:42 +02:00
Jerko Steiner
bddbfa7e11 Ensure existing transceivers are reused
Please see issue #1155 for more details
2020-04-20 23:41:34 +02:00
Sean DuBois
234a170fb4 Only call iceGatherer.Gather once
In SetLocalDescription guard iceGatherer.Gather by checking state.
We don't put this check inside Gather because ORTC doesn't have the
function as re-entrant

Resolves #1144

Co-authored-by: jeremija
2020-04-19 07:50:11 +02:00
Yuki Igarashi
dba6716b39 Use AddTransceiverFromKind
Move from AddTransceiver to AddTransceiverFromKind.
2020-04-04 21:35:45 -07:00
Sean DuBois
dfde058009 Put application media section first
When offering always put application first. Before during re-negotation
we would break the order if media sections because we would always place
it last. Instead of remembering what order the application was place
just always place it first.

Resolves #1055
2020-02-27 23:20:09 -08:00
Sean DuBois
f1fbbe7af8 Revert PopulateFromSDP RTCPFeedback support
This causes users who use PopulateFromSDP to declare
they support transport-cc.  Since they don't send receiver
reports. They will get a degraded experience unexpectedly.

Partially revert ce8de088e7.

Resolves #1026
2020-02-13 20:22:19 -08:00
Sean DuBois
0652581dd1 Add test for multi-track PlanB signaling
SDP parsing only supported one ssrc per media section.
Now we properly can handle multiple.

Resolves #1014
2020-02-11 13:15:41 -08:00
Sean DuBois
0b8bdebeeb Make RTPTransceiver thread safe
Sender, Receiver and Direction are now atomics with functions
for getters and setters

Relates to #207
2020-02-09 21:40:37 -08:00
Sean DuBois
512a7d3330 Implement RemoveTrack
RemoveTrack properly removes the Sender, and culls
the RtpReceiver on the remote

Relates to #207
2020-02-09 21:40:37 -08:00
Luke
ce8de088e7 Add RTCPFeedback support to PopulateFromSDP
Handles the newly added RTCPFeedback information from pion/sdp
2020-02-05 18:07:59 -05:00
Atsushi Watanabe
7f77abcfa2 Fix deadlock during ICETransport.Stop
Calling ConnectionStateChange handler during Stop caused mutex
deadlock. Add another Mutex to protect handler pointer to
avoid the deadlock.
2020-02-01 01:14:00 -08:00