Commit Graph

114 Commits

Author SHA1 Message Date
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
Atsushi Watanabe
27d9bbb7bd Upgrade golangci-lint to 1.19.1
Fix whitespace and stylecheck errors.
Disable godox.
2020-01-11 22:59:33 -08:00
Lukas Herman
8cd3fdc980 Expose an API to get registered RTPCodec list
Add a new public method, GetRegisteredRTPCodecs, under PeerConnection
to allow access to get the registered list of RTPCodec from the
underlying MediaEngine for developers who want to build libraries on
top of pion.

Resolves #966
2020-01-05 21:13:45 -08:00
Sean DuBois
721b342e2e Properly generate DataChannel streamId
Before we computed DataChannel IDs before signaling, this
is incorrect because IDs must take into account if we are
running an DTLS Client or Server.

This updates the DataChannel ID generation code to take this
into account before generating a streamId.

Resolves #908
2019-11-14 10:51:05 -08:00
Sean DuBois
2356373aac Fix all routine leaks in tests
Fix tests that didn't properly close and add
test.CheckRoutines everywhere. No changes in pion/webrtc
but we did catch hanging thread in pion/ice
2019-10-24 00:09:43 -07:00
Yutaka Takeda
7878bd8499 Fix goroutine leaks in the test
Bump pion/datachannel ver to 1.4.12
Resolves #895
2019-10-23 20:36:01 -07:00
Sean DuBois
7584762124 Expose Answering DTLSRole via SettingEngine
User can now control what DTLSRole the local client
takes when answering via the SettingEngine.

Relates to #880
2019-10-22 01:11:21 -07:00
Sean DuBois
4a7a812332 Add test for undeclared SSRCs
Resolves #880
2019-10-20 02:05:43 -07:00
Vicken Simonian
5f25df2209 Various spell fixes
For error types, vars, docs and comments
2019-10-17 23:31:21 -07:00
Chris Hiszpanski
93802b1a56 Add test for answer with unsupported media
Test functionality in addTransceiverSDP which omits unsupported media
from the group BUNDLE attribute.
2019-09-26 19:35:55 -07:00
Sean DuBois
d7ae1a87ba Delete TestSRTPDrainLeak
This test was added to assert that rogue RTP/RTCP packets didn't cause
us to leak. The code that was actually causing the leak was removed,
so this isn't actually testing anything useful anymore

Resolves #823
2019-09-26 00:55:16 -07:00
Sean DuBois
d8b7905aaf Improve TestSRTPDrainLeak
TestSRTPDrainLeak asserts that we notify the user
of SRTP/SRTCP packets that can't be handled. Before
we tested by sending 5 packets, and looking for a log
message. If these 5 packets were lost the test would fail.

Now we send packets in a loop until they are seen.

Resolves #823
2019-09-16 10:36:12 -07:00
Hugo Arregui
6997cc792c Linter fixes
Disable funlen and some fixes

Co-authored-by: Sean DuBois <sean@siobud.com>
2019-09-10 21:48:25 -07:00
Rafael Viscarra
1464ad4131 Implemented AddTransceiverFrom* methods
This allows to have SendOnly transceivers while keeping the API
relatively consistent with the browser's
2019-07-31 01:57:17 -06:00
Sean DuBois
eb737ba0b2 Fix routine leak in drainSRTP
Store orphaned SRTP/SRTCP streams and discard them
when we close the PeerConnection

Resolves #729
2019-07-06 22:58:07 +01:00
Sean DuBois
85a1602698 Populate incoming Label/ID
Populate the Label/ID for incoming tracks. Before we
emitted them to the user with empty values

Resolves #670
2019-05-12 00:55:37 -05:00
Sean DuBois
bf8502ef02 AddTrack now creates SendRecv Transceiver
Before we incorrectly created a Sendonly transceiver
2019-05-06 00:35:36 -07:00
Sean DuBois
e8fe7aa48d Bump SRTP/RTCP and update RTCP API
Reading/Writing RTCP packets now return a slice

Relates to pion/srtp#29
2019-04-11 16:03:26 -07:00
Max Hawkins
7f6c01d5bc Move missing codec test to media_test
So it doesn't conflict with WASM.

Related to #449
2019-04-09 18:12:58 -07:00