Commit Graph

190 Commits

Author SHA1 Message Date
Jerko Steiner
b66c3c4903 Add operations queue for setting descriptions
Most likely fixes #1157
2020-05-13 22:00:52 +02:00
Jerko Steiner
a2c7665fad Call startRenegotiation from SetLocalDescription
Fixes #1191
2020-05-13 22:00:52 +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
Simone Gotti
d3fe4071a1 Fix "tranceiver" instead of "transceiver" typos
Fix some typos where "tranceiver" was used instead of "transceiver".
2020-04-30 00:43:57 +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
Sean DuBois
efb33be1f4 Simplify populateLocalCandidates
populateLocalCandidates was created when refactoring, logic that should
have existed in the caller was pushed into it.

Relates to #1143
2020-04-18 16:16:46 -07:00
Sean DuBois
208e06832b Populate candidates in LocalDescription
Use populateLocalCandidates in LocalDescription. Before we incorrectly
never populated candidates.

Resolves #1143
2020-04-18 00:18:51 -07:00
Jerko Steiner
2709d513a1 Start a goroutine from startReceiver
According to @at-wat's suggestions. In my previous commit, there was no
guarantee that the initial Track().id and Track().label would be set
before the second answer with a `a=msid` section was received.
2020-04-14 08:42:00 +02:00
Jerko Steiner
eafd869204 Re-set track.id and track.label before OnTrack
See https://github.com/pion/webrtc/issues/1134
2020-04-14 08:42:00 +02:00
Sean DuBois
b1bb363bc0 Fix candidate population in SDP
* Don't add end-of-candidates until gathering complete
* Don't double add candidates

Resolves #1121
2020-04-04 22:51:39 -07:00
Yuki Igarashi
dba6716b39 Use AddTransceiverFromKind
Move from AddTransceiver to AddTransceiverFromKind.
2020-04-04 21:35:45 -07:00
Sean DuBois
364d0def74 Don't call OnTrack for same SSRC multiple times
During re-negotiation we didn't properly filter SSRCes that we had
already handled.  This makes sure to loop the existing transceivers
and asserts we don't try to handle the same SSRC again.

Resolves #1122
2020-04-03 19:39:29 -07:00
Marouane
1231bbc07a Remove Renegotation ApplicationFirst test
we now use pc.generateMatchedSDP, this test is unnecessary
2020-04-01 12:15:53 -07:00
nindolabs
56804bc5c7 Append media data section after transceivers
Edge prechromium does not like app data section before video/audio.
It generates the following error:
0: Unable to get property 'state' of undefined or null reference
rtcpeerconnection.js (1016,1)
2020-04-01 12:15:53 -07:00
Atsushi Watanabe
4cb3b1a7c6 Guarantee order of startRenegotation
As the order of function execution of multiple goroutine is not
guaranteed, startRenegotation could be called before startTransports.
2020-03-22 18:05:55 +09:00
Sean DuBois
825b5e41f7 Process SetRemoteDescription calls serially
Each negotation must be finished before processing the next one.
Before we would process multiple calls at once, and since they are
performed async we would have undefined behavior.

Resolves #1074
2020-03-11 22:24:08 -07:00
Sean DuBois
912779df43 Change incoming orphaned SSRC log level
Move this from Error -> Warn. Now that re-negotiation has landed users
will see this a lot more, and it isn't helpful by default. We still want
this message in case users are trying to debug if an OnTrack isn't
fired.
2020-03-09 22:51:46 +08:00
Sean DuBois
1f448413f2 Handle changing role during re-negotiation
On all subsequent re-offers make sure to order
of media sections.

Add TestPeerConnection_RoleSwitch to assert this behavior

Resolves #1058
2020-03-08 21:29:20 -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
Jorropo
8fe6f7fa34 Adding documentation about OnICECandidate
Follow up to #1051.
2020-02-26 20:30:15 -08:00
Guilherme
4541f49b80 Fix race in PeerConnection.ConnectionState
The data race detector detects a race if
PeerConnection.ConnectionState is called while
PeerConnection.updateConnectionState is changing
the connection state
2020-02-20 11:37:48 -08:00
Sean DuBois
00ba9ab52e Split ICE and DTLS related SDP parsing out
Move this stuff out of SetRemoteDescription so it will be easier to test

Relates to #1023
2020-02-14 18:53: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
f39a6c6c1f Fix race in PeerConnection.setDescription
Resolves #1012
2020-02-09 22:21:45 -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
Sean DuBois
6847421118 Implement Adding tracks after signaling
Relates to #207
2020-02-09 21:40:37 -08:00
Sean DuBois
53014d3eb8 Move SDP code into dedicated file
Remove some duplication that makes re-negotiation harder.
By splitting parsing of inbound SDP and creation of outbound
it makes the next step a lot easier.

Relates to #207
2020-02-09 21:40:37 -08:00
Sean DuBois
f1ffb81649 Remove code duplication in track/transceiver code
Have AddTrack call transceiver code. Also update AddTransceiverFromKind
to call AddTransceiverFromTrack

Relates to #207
2020-02-09 21:40:37 -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
adwpc
da03cb4a4d RTP codec and sdp support transport-cc
RTP codec and sdp support transport-cc
2020-01-08 22:31:56 +08:00
adwpc
bac0c492a9 Sdp support transport-cc
Sdp support transport-cc
2020-01-08 22:31:56 +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
77c6e3b827 Properly sanitize STUN urls
Currently we error if a STUN URL passed to Configuration.ICEServers
contained a query parameter. Fix this by using the getICEServers
function that sanitizes these for us.
2019-12-11 00:18:39 -08:00
Yutaka Takeda
7d99edd21a Added logging throughput
Resolves #778
2019-12-08 01:03:17 -08:00
Sean DuBois
bba6460597 Allow user to Close DataChannel before signaling
Match W3C WebRTC and allow a DataChannel to close even before
signaling happens. When SCTPTransport opens make sure
to check the readyState first.
2019-11-25 17:18:47 -08:00
Sean DuBois
1c32bc9a46 Properly set DataChannel readyState on Close
DataChannel readyState should be set to Closed on PeerConnection
shutdown. If not properly set it would attempt to interact with
state that doesn't exist after the PeerConnection has been Closed.

Setting the readyState is also clearly defined in the W3C webrtc-pc

Resolves #915
2019-11-22 18:06:43 -08:00
Sean DuBois
36b02632d1 Match W3C when closing
PeerConnection.Close() doesn't match the W3C RFC on closing,
re-order the transports so that they close in the proper order.

In the future we will use the DTLS Close alert and RTCP Bye to
better communicate shutdown
2019-11-21 11:55:48 -08:00
Sean DuBois
b5154b499e Only create ICEGather via API
Use values directly from SettingValues instead of just copying
when calling NewICEGatherer. This greatly reduces the LoC and makes
the public API a little cleaner.

Resolves #872
2019-11-21 11:18:05 -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
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
c6ad8c78ea Handle undeclared SSRCes
If we receive an unknown SSRC and we have a single
media section with no SSRCes declared fire an OnTrack
with that stream

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
Sean DuBois
92867d3de6 Support negotiated DataChannels in Go
Relates to #748
2019-09-28 22:34:57 -07:00
Sean DuBois
d692ddfa54 Support DataChannel protocol in Go
Relates to #748
2019-09-27 16:19:49 -07:00
Chris Hiszpanski
69dffdf4b5 Fix answer bundle for rejected media
When rejecting media, the identification-tag (i.e. media ID) must
be removed from the bundle in addition to setting the m-line port
to zero.
2019-09-26 19:35:55 -07:00