Commit Graph

320 Commits

Author SHA1 Message Date
obasajujoshua31
7d79c766c9 Add GetMediaStats to StatsReport
Add an API to get basic stats around media.

Relates to #610

mend
2020-09-22 14:05:06 -04:00
obasajujoshua31
9d393905c1 Add GetMediaStats to StatsReport
Add an API to get basic stats around certificate

Relates to #610
2020-09-22 12:03:52 -04:00
mission-liao
062e55d769 Avoid acquiring two reader privilege of a lock
It's an anti-pattern when using sync.RWMutex in golang.
After acquiring two reader privilege of a rwlock, it will deadlock if
another routine tries to acquire a writer lock.

In pion/webrtc, this calling sequence might happen when calling
GetTransceivers during track events.

Resolves #1425
2020-09-19 13:26:03 -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
tarrencev
81cfadaf06 Fix: CreateOffer race condition
Fixes a race condition that occurs when the local media (transceivers)
are mutated during the offer generation process.
2020-09-11 14:05:19 -04:00
tarrencev
fc11e7c66c Fix: negotiation state race conditions
Adds a few locks to solve a few race conditions with renegotiations
2020-09-10 22:58:32 -07:00
tarrencev
611e675862 Fix(peerconnection): fix negotiation needed race
safely access transceivers and signaling state
2020-09-08 10:38:13 -04:00
Sean DuBois
69883c5d5a Fix renegotation race
checkNegotiationNeeded accessed RtpSender field with taking lock

Resolves #1384
2020-09-07 22:52:44 -07:00
soolaugust
c01b447517 Add signaling state case in CreateAnswer()
According to
https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-createanswer.
If connection's signaling state is neither "have-remote-offer" nor
"have-local-pranswer", return a newly created InvalidStateError.
2020-09-03 13:46:46 -07:00
Roman Romanenko
c0b9c12b11 Use named return value from GetReceivers
Makes function a shorter and makes GoDoc a little better!
2020-08-23 23:20:05 -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
soolaugust
6f6de25b24 Modify all hdlr to handler for better reading
change hdlr -> handler, Hdlr -> Handler for better reading.
Since this is first commit, add myself to contributors
2020-08-17 22:04:29 -07:00
Sean DuBois
cbbede4bee Remove some invalid RTC Prefix comments
These were renamed after v1, but never updated
2020-08-13 22:33:35 -07:00
JooYoung
23d7b23563 Update AddTransceiverFromTrack comment
Improve comment and fix typo
2020-08-13 22:26:45 -07:00
Sean DuBois
9f1417347a Support creating a DataChannel during renegotation
Before when creating an offer during renegotation we didn't support
adding a DataChannel.

Resolves #1361
2020-08-12 21:43:34 -07:00
Woodrow Douglass
abd6a35654 Create data media sections for each requested
Don't create data media sections unless we're asked to

Fixes #1349
2020-07-29 12:57:37 -07:00
Sean DuBois
d893dcf4c7 Simplify startRTPReceivers
pc.startReceiver will set the receive flag for Transceivers so
no reason to do extra filtering here.

Relates to #1016
2020-07-25 02:39:51 -07:00
Jason
6ee528d349 Add Simulcast support
Resolves #1016
2020-07-24 01:01:43 -07:00
Atsushi Watanabe
fe63deaeb5 Fix JSEP SDP Session ID
Fix to use crypto random and add error handling.
Update github.com/pion/sdp/v2 to v2.4.0.
2020-07-14 12:38:19 +09:00
Sean DuBois
addb9594f2 Assert SDPType in setDescription
Before users could pass a SessionDescription with a 0 type. This would
be discarded silently. Now we return an error that matches browser
behavior.

Resolves #1297
2020-07-13 14:38:09 -07:00
Atsushi Watanabe
0157f347e4 Fix randoms
Use seeded mathematical random where uniqueness is needed
but not required to be cryptographic.
2020-07-13 14:42:53 +09: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
Jerko Steiner
e3cda91a59 Get a list of transceivers before starting RTP
Related to #1290
2020-06-30 11:48:24 -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
Sean DuBois
f2941469f4 Implement ICE Restarts
Resolves #1251
2020-06-29 23:09:18 -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
Sean DuBois
f78334d9d4 Only start SCTP if RemoteDescription requests
Relates to #346
2020-05-18 00:05:40 -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
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