Skip to content
This repository has been archived by the owner on Mar 22, 2022. It is now read-only.

Add multi-track support #283

Merged
merged 152 commits into from
Apr 21, 2020
Merged
Show file tree
Hide file tree
Changes from 146 commits
Commits
Show all changes
152 commits
Select commit Hold shift + click to select a range
ba75e79
Add transceiver API to C++
djee-ms Feb 26, 2020
d27155d
Add mrs prefix to interop handles
djee-ms Feb 27, 2020
5b3f24b
Move interop headers of public API to include/
djee-ms Feb 27, 2020
b01c997
Fix includes + apply clang-format
djee-ms Feb 27, 2020
69fe9af
Add initial support for Plan B
djee-ms Mar 1, 2020
5208ee4
Merge A/V transceiver init structs
djee-ms Mar 1, 2020
a0ec761
Minor formating/comment changes
djee-ms Mar 1, 2020
a56e487
Add missing mrs prefixes on public API types
djee-ms Mar 1, 2020
70ba55c
Add more missing mrs prefixes in public API
djee-ms Mar 2, 2020
2bfe250
Merge audio and video transceivers
djee-ms Mar 2, 2020
0b5ed11
Move track-related init configs in their header
djee-ms Mar 2, 2020
5e8f6ba
Add named constructor to Transceiver
djee-ms Mar 2, 2020
3688237
Fix C++ tests for non-ref-owning handles
djee-ms Mar 2, 2020
20ac05e
Delete unused code and add comment and TODO
djee-ms Mar 2, 2020
afe7eae
Ensure SimpleInterop util fails test on exception
djee-ms Mar 3, 2020
b0f6fab
Silence warning in test util
djee-ms Mar 3, 2020
c842e5c
Deduplicate video transceiver test code
djee-ms Mar 3, 2020
87156e8
Remove transceiver checks from video tests
djee-ms Mar 3, 2020
e561ca9
Merge audio and video transceiver C++ tests
djee-ms Mar 3, 2020
3c1f7f5
Clean-up find/create Transceiver
djee-ms Mar 4, 2020
77c38fd
Merge OnAddTrack() and OnRemoveTrack() code
djee-ms Mar 4, 2020
016519b
Use named function ForceTestFailure for clarity
djee-ms Mar 4, 2020
580fa4e
Clean-up static_assert for transceiver direction
djee-ms Mar 4, 2020
ee6ddee
Use switch in ObjectTypeToString()
djee-ms Mar 4, 2020
d3be60d
Remove mention to internal function in API
djee-ms Mar 4, 2020
0c2219e
Remove list of local tracks on peer connection
djee-ms Mar 4, 2020
5de9908
Remove list of remote tracks from peer connection
djee-ms Mar 4, 2020
f4642d3
Remove unused code
djee-ms Mar 4, 2020
d093fd1
Merge A/V transceiver creation
djee-ms Mar 6, 2020
6ce478f
Fix tranceiver refcount bug in TrackAdded
djee-ms Mar 6, 2020
26322fd
Init media_kind with invalid value -1
djee-ms Mar 9, 2020
42406ab
Fix cast for invalid value (mrsMediaKind)-1
djee-ms Mar 10, 2020
6cc7679
Fix some interop comments
djee-ms Mar 10, 2020
3fadc17
Pass PeerConnectionConfiguration by reference
djee-ms Mar 10, 2020
be5bbf5
Remove "interop handles" and transceiver refcount
djee-ms Mar 8, 2020
51c51df
Remove refcount from remote media tracks
djee-ms Mar 8, 2020
aaf6a56
Get/set user data on transceiver and remote tracks
djee-ms Mar 8, 2020
939b998
Pass track info as argument to TrackAdded event
djee-ms Mar 9, 2020
50fe87c
Add a new TransceiverAdded event
djee-ms Mar 10, 2020
1502d9e
Fix data channel creation and missing user data
djee-ms Mar 10, 2020
8cb3a5b
Fix transceiver bug in Plan B
djee-ms Mar 10, 2020
88a770b
Fix comments on data channel API
djee-ms Mar 11, 2020
3bb63b8
Mark data channel callbacks as noexcept
djee-ms Mar 11, 2020
6c7f44d
Fix transceiver stream IDs propagation in Plan B
djee-ms Mar 11, 2020
cd9345b
Original C# library change before interop merge
djee-ms Mar 5, 2020
c4e8889
Merge audio and video transceivers C# interop
djee-ms Mar 5, 2020
2eec77f
Merge TestAppUWP changes
djee-ms Mar 6, 2020
54a4f17
Delayed RenegotiationNeeded to avoid reentrency
djee-ms Mar 6, 2020
40c9aea
Ensure C# LocalVideoTrack tests wait for SDP
djee-ms Mar 6, 2020
bd825a6
Parameterize LocalVideoTrackTests on SDP semantic
djee-ms Mar 6, 2020
2012904
Add missing XML comments
djee-ms Mar 6, 2020
4b4ec41
Minor comment fixes for transceivers
djee-ms Mar 7, 2020
3a64cd6
UserData-based wrapper creation and storage
djee-ms Mar 11, 2020
8da0c4a
Simplify C# tests with base class
djee-ms Mar 11, 2020
2d5aa02
Fix stream ID for transceivers
djee-ms Mar 12, 2020
b07680c
Remove dead code in RemoteAudioTrackInterop.cs
djee-ms Mar 13, 2020
b55bfc0
Mark DelayedEvent and co. as internal
djee-ms Mar 13, 2020
9a4fa9e
Merge AudioTransceiver and VideoTransceiver
djee-ms Mar 16, 2020
2892727
Add missing Transceiver merge for TestAppUWP
djee-ms Mar 16, 2020
6275aef
Simplify implementation of DelayedEvent
djee-ms Mar 16, 2020
1ceef89
Remove lists of media tracks in PeerConnection
djee-ms Mar 16, 2020
61ccc6e
Rely on PC callbacks to clean-up tracks
djee-ms Mar 16, 2020
4e85d77
Fix data channel destruction sequence
djee-ms Mar 16, 2020
0bc6b99
Clean-up remote tracks add/remove sync
djee-ms Mar 16, 2020
f999b03
Clean-up local tracks add/remove sync
djee-ms Mar 16, 2020
00202b1
Fix C# documenting comments after recent changes
djee-ms Mar 16, 2020
fc52e9e
Remove Transceiver.SetDirection()
djee-ms Mar 16, 2020
15f0081
Replace operator->() with get()
djee-ms Mar 16, 2020
f492660
Make DataChannel non-IDisposable
djee-ms Mar 18, 2020
187b48e
Remove unnecessary call to GC.SuppressFinalize()
djee-ms Mar 19, 2020
9b91961
Add missing data_channel_interop.cpp to UWP native
djee-ms Mar 18, 2020
68da182
[TestAppUWP] Avoid remote video duplicate create
djee-ms Mar 18, 2020
17de3de
Add support for multi-tracks to Unity integration
djee-ms Mar 12, 2020
b65edd8
Rename Unity files for IAudioSource/IVideoSource
djee-ms Mar 13, 2020
5259962
Clean-up media sources
djee-ms Mar 13, 2020
38b3d27
[Unity] Remove dead code in PeerConnection.cs
djee-ms Mar 13, 2020
0687440
Fix and clean-up WebcamSourceEditor
djee-ms Mar 13, 2020
bb038b0
Fix EOL to LF
djee-ms Mar 13, 2020
d993cc7
Automatically switch H.264 -> VP8 on Desktop
djee-ms Mar 13, 2020
a94d7ff
Fix VideoChatDemo
djee-ms Mar 13, 2020
9db4b0b
Remove H.265 from preferred codec enum popup
djee-ms Mar 13, 2020
33159e8
Add a warning when selecting H.264 preferred codec
djee-ms Mar 13, 2020
feeecb9
Force MediaSender track destruction when disabled
djee-ms Mar 14, 2020
a9a2aa5
[Unity] Improve the WebcamSource editor
djee-ms Mar 14, 2020
6006a0d
[Unity] Add ToggleLeft attribute for inspector
djee-ms Mar 15, 2020
da8cf1e
Allow configuring the webcam device to use
djee-ms Mar 15, 2020
7f2450d
[Unity] Add MicrophoneSource editor
djee-ms Mar 15, 2020
6946df6
[Unity] Improve PeerConnection editor
djee-ms Mar 15, 2020
bcbc483
Fixes after A/V transceivers merge in C# library
djee-ms Mar 18, 2020
7066a8d
Ignore TrackRemoved event with no MediaLine
djee-ms Mar 18, 2020
5102c5e
Make DelayedEvent thread-safe and null-safe
djee-ms Mar 18, 2020
8e7a90b
Rename FakeVideoSource to UniformColorVideoSource
djee-ms Mar 19, 2020
c247008
Rename HardcodedSignaler to LocalOnlySignaler
djee-ms Mar 19, 2020
fbbf6be
Remove unnecessary try/catch block
djee-ms Mar 19, 2020
cc3d5c3
Reword some variable names and comments
djee-ms Mar 19, 2020
8ea9a67
Some more comments and renames
djee-ms Mar 19, 2020
ab51305
Remove button from LocalOnlySignaler
djee-ms Mar 19, 2020
8621f9b
[Unity] Simplify VideoSourceTests.cs
djee-ms Mar 19, 2020
089db31
Fix AudioReceiver callback + many comments
djee-ms Mar 20, 2020
d18e528
Fix invalid XML comment references
djee-ms Mar 20, 2020
8b8b334
Fix typo in comment
djee-ms Mar 20, 2020
53c6e00
Use virtual dispatch for media attach/detach
djee-ms Mar 20, 2020
ff97b6a
Remove unnecessary asserts
djee-ms Mar 20, 2020
84b5590
Change transceiver dir. on sender/receiver changes
djee-ms Mar 23, 2020
b20b0c8
Add "Impl" suffix to CreateLocalAudioTrackAsync()
djee-ms Mar 23, 2020
dca2c85
Remove Signaler use from PeerConnection
djee-ms Mar 24, 2020
789f227
Update VideoChatDemo sample
djee-ms Mar 24, 2020
6c07715
[typo] Candiate => Candidate
djee-ms Mar 25, 2020
bb49761
Update Unity tutorial for multi-track changes (#236)
djee-ms Mar 30, 2020
b4e0cbd
Add migration guide (#243)
djee-ms Mar 30, 2020
74fb113
Add warnings to docs where due (#245)
djee-ms Mar 30, 2020
1aeb446
Merge master into merge/multi_track
djee-ms Mar 30, 2020
c516357
Fix TestNetCoreConsole to use the new API
djee-ms Mar 30, 2020
e74deac
Handle transceiver kind mismatching in Unity
djee-ms Mar 31, 2020
5d46fbe
Fix C++ tests with MRSW_EXCLUDE_DEVICE_TESTS
djee-ms Mar 31, 2020
af88a02
Merge master into merge/multi_track
djee-ms Mar 31, 2020
42ba921
Upgrade Android CMakeLists.txt after master merge
djee-ms Mar 31, 2020
70d5d88
Upgrade .NET Core UWP to 6.2.10
djee-ms Mar 31, 2020
6dc473c
Fix invariants of media source Unity events
djee-ms Apr 1, 2020
e5c71d5
Misc. documenting comments fixes
djee-ms Apr 1, 2020
c804c2e
[Unity] Normalize line endings to LF
djee-ms Apr 1, 2020
363f97c
Merge master into merge/multi_track
djee-ms Apr 2, 2020
9723a6c
Fix another assertion in media senders
djee-ms Apr 2, 2020
12fede6
Fix transceiver shutdown sequence when PC closes
djee-ms Apr 2, 2020
c7920c9
Fix duplicate DataChannelAdded event
djee-ms Apr 2, 2020
f62d1e6
Add IAudioTrack and IVideoTrack interfaces (#256)
djee-ms Apr 6, 2020
3a032fe
Expose real media line index in transceiver
djee-ms Apr 5, 2020
45e0f98
Add transceiver event raised when associated
djee-ms Apr 4, 2020
6373f15
Synchronize transceivers in linear time
djee-ms Apr 6, 2020
d0c7352
Fix invalid C# interop function signature
djee-ms Apr 4, 2020
00e0550
Fix some comments in native impl library
djee-ms Apr 6, 2020
045a772
Add transceiver direction changed event to C# API
djee-ms Apr 4, 2020
cf4570e
Add support for multi-track to TestAppUWP (#269)
djee-ms Apr 15, 2020
fe88908
Merge master into merge/multi_track
djee-ms Apr 15, 2020
2377529
Fix null crash in TestAppUWP
djee-ms Apr 16, 2020
0081379
[TestAppUWP] Pre-populate some fields
djee-ms Apr 16, 2020
861c0e4
[TestAppUWP] Allow changing desired direction
djee-ms Apr 16, 2020
7ca9a60
Threadsafe PropertyChanged for CollectionViewModel
djee-ms Apr 16, 2020
db5b216
[TestAppUWP] Re-add support for video profiles
djee-ms Apr 16, 2020
089d9f9
Downgrade TestAppUWP from 10.0.18134 to 10.0.17763
djee-ms Apr 16, 2020
edc08b4
Better logging when syncing transceivers
djee-ms Apr 20, 2020
6d87f56
Fix bug when matching wrappers by RTP transceiver
djee-ms Apr 20, 2020
f6f8c6c
Rename variable in Unity test for clarity
djee-ms Apr 20, 2020
d84faec
Remove wrong async/await in AddDataChannelAsync
djee-ms Apr 20, 2020
91830f4
Handle discontinuous media line index
djee-ms Apr 20, 2020
1194daa
Remove wrong check in SceneVideoSender
djee-ms Apr 20, 2020
9c13800
Replace DataChannel hard-coded value with flags
djee-ms Apr 21, 2020
9442688
[Unity] Rename AddTransceiver to AddMediaLine
djee-ms Apr 21, 2020
663698c
Avoid race condition in Unity test
djee-ms Apr 21, 2020
0e5773c
Disable C# video device enum tests on CI
djee-ms Apr 21, 2020
451a96b
Upgrade NUnit test adapter to 3.16.1
djee-ms Apr 21, 2020
82a8be3
Clarify comment and log msg on transceiver sync
djee-ms Apr 21, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions Microsoft.MixedReality.WebRTC.sln
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestNetCoreConsole", "examp
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestReceiveAV", "examples\TestReceiveAV\TestReceiveAV.csproj", "{209D1A4C-96F1-4F5E-9987-8C64E7998CC3}"
ProjectSection(ProjectDependencies) = postProject
{BD9DCE7E-7159-4DAA-AAEB-71A8261C02FF} = {BD9DCE7E-7159-4DAA-AAEB-71A8261C02FF}
{928899BC-F131-4343-A1AB-72F3A5787E41} = {928899BC-F131-4343-A1AB-72F3A5787E41}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -98,13 +102,11 @@ Global
{928899BC-F131-4343-A1AB-72F3A5787E41}.Release|x86.ActiveCfg = Release|Win32
{928899BC-F131-4343-A1AB-72F3A5787E41}.Release|x86.Build.0 = Release|Win32
{70AB2CE0-D35D-4911-AC83-545A611EA930}.Debug|ARM.ActiveCfg = Debug|Any CPU
{70AB2CE0-D35D-4911-AC83-545A611EA930}.Debug|ARM.Build.0 = Debug|Any CPU
{70AB2CE0-D35D-4911-AC83-545A611EA930}.Debug|x64.ActiveCfg = Debug|Any CPU
{70AB2CE0-D35D-4911-AC83-545A611EA930}.Debug|x64.Build.0 = Debug|Any CPU
{70AB2CE0-D35D-4911-AC83-545A611EA930}.Debug|x86.ActiveCfg = Debug|Any CPU
{70AB2CE0-D35D-4911-AC83-545A611EA930}.Debug|x86.Build.0 = Debug|Any CPU
{70AB2CE0-D35D-4911-AC83-545A611EA930}.Release|ARM.ActiveCfg = Release|Any CPU
{70AB2CE0-D35D-4911-AC83-545A611EA930}.Release|ARM.Build.0 = Release|Any CPU
{70AB2CE0-D35D-4911-AC83-545A611EA930}.Release|x64.ActiveCfg = Release|Any CPU
{70AB2CE0-D35D-4911-AC83-545A611EA930}.Release|x64.Build.0 = Release|Any CPU
{70AB2CE0-D35D-4911-AC83-545A611EA930}.Release|x86.ActiveCfg = Release|Any CPU
Expand All @@ -120,25 +122,21 @@ Global
{6D020425-2E3E-4BA7-BC46-00C8D29081C0}.Release|x86.ActiveCfg = Release|Win32
{6D020425-2E3E-4BA7-BC46-00C8D29081C0}.Release|x86.Build.0 = Release|Win32
{C17D2554-9409-4CC7-8337-E3FBE3CAE415}.Debug|ARM.ActiveCfg = Debug|Any CPU
{C17D2554-9409-4CC7-8337-E3FBE3CAE415}.Debug|ARM.Build.0 = Debug|Any CPU
{C17D2554-9409-4CC7-8337-E3FBE3CAE415}.Debug|x64.ActiveCfg = Debug|x64
{C17D2554-9409-4CC7-8337-E3FBE3CAE415}.Debug|x64.Build.0 = Debug|x64
{C17D2554-9409-4CC7-8337-E3FBE3CAE415}.Debug|x86.ActiveCfg = Debug|x86
{C17D2554-9409-4CC7-8337-E3FBE3CAE415}.Debug|x86.Build.0 = Debug|x86
{C17D2554-9409-4CC7-8337-E3FBE3CAE415}.Release|ARM.ActiveCfg = Release|Any CPU
{C17D2554-9409-4CC7-8337-E3FBE3CAE415}.Release|ARM.Build.0 = Release|Any CPU
{C17D2554-9409-4CC7-8337-E3FBE3CAE415}.Release|x64.ActiveCfg = Release|x64
{C17D2554-9409-4CC7-8337-E3FBE3CAE415}.Release|x64.Build.0 = Release|x64
{C17D2554-9409-4CC7-8337-E3FBE3CAE415}.Release|x86.ActiveCfg = Release|x86
{C17D2554-9409-4CC7-8337-E3FBE3CAE415}.Release|x86.Build.0 = Release|x86
{209D1A4C-96F1-4F5E-9987-8C64E7998CC3}.Debug|ARM.ActiveCfg = Debug|Any CPU
{209D1A4C-96F1-4F5E-9987-8C64E7998CC3}.Debug|ARM.Build.0 = Debug|Any CPU
{209D1A4C-96F1-4F5E-9987-8C64E7998CC3}.Debug|x64.ActiveCfg = Debug|Any CPU
{209D1A4C-96F1-4F5E-9987-8C64E7998CC3}.Debug|x64.Build.0 = Debug|Any CPU
{209D1A4C-96F1-4F5E-9987-8C64E7998CC3}.Debug|x86.ActiveCfg = Debug|Any CPU
{209D1A4C-96F1-4F5E-9987-8C64E7998CC3}.Debug|x86.Build.0 = Debug|Any CPU
{209D1A4C-96F1-4F5E-9987-8C64E7998CC3}.Release|ARM.ActiveCfg = Release|Any CPU
{209D1A4C-96F1-4F5E-9987-8C64E7998CC3}.Release|ARM.Build.0 = Release|Any CPU
{209D1A4C-96F1-4F5E-9987-8C64E7998CC3}.Release|x64.ActiveCfg = Release|Any CPU
{209D1A4C-96F1-4F5E-9987-8C64E7998CC3}.Release|x64.Build.0 = Release|Any CPU
{209D1A4C-96F1-4F5E-9987-8C64E7998CC3}.Release|x86.ActiveCfg = Release|Any CPU
Expand Down
5 changes: 3 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ title: Index
- Getting started
- [Download](manual/download.md)
- [Installation](manual/installation.md)
- [Migration Guide](manual/migration-guide.md)
- [Building from sources](manual/building.md)
- [C# tutorial (Desktop)](manual/cs/helloworld-cs-core3.md)
- [C# tutorial (UWP)](manual/cs/helloworld-cs-uwp.md)
Expand Down Expand Up @@ -50,5 +51,5 @@ title: Index
- The PeerConnection component builds on the same-named library class to expose a remote peer connection.
2. [Signaler](xref:Microsoft.MixedReality.WebRTC.Unity.Signaler)
- The abstract Signaler component is the base class for signaling implementations.
3. [LocalVideoSource](xref:Microsoft.MixedReality.WebRTC.Unity.LocalVideoSource)
- The LocalVideoSource component provides access to the local webcam for local rendering and remote streaming.
3. [WebcamSource](xref:Microsoft.MixedReality.WebRTC.Unity.WebcamSource)
- The WebcamSource component provides access to the local webcam for local rendering and remote streaming.
33 changes: 20 additions & 13 deletions docs/manual/cs/cs-peerconnection.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ A [`PeerConnection`](xref:Microsoft.MixedReality.WebRTC.PeerConnection) instance
[`InitializeAsync()`](xref:Microsoft.MixedReality.WebRTC.PeerConnection.InitializeAsync*) takes a [`PeerConnectionConfiguration`](xref:Microsoft.MixedReality.WebRTC.PeerConnectionConfiguration) and a [`CancellationToken`](xref:System.Threading.CancellationToken). The former allows configuring the peer connection about to be established, while the later allows cancelling that task while it is being processed.

[`PeerConnectionConfiguration`](xref:Microsoft.MixedReality.WebRTC.PeerConnectionConfiguration) contains several fields, but the most important are:

- [`IceServers`](xref:Microsoft.MixedReality.WebRTC.PeerConnectionConfiguration.IceServers) contains an optional collection of STUN and/or TURN servers used by the Interactive Connectivity Establishment (ICE) to establish a connection with the remote peer through routing devices (NATs). Without these, only direct connections to the remote peer can be established, which can be enough if the application knows in advance the network topology surrounding the two peers, but is generally recommended otherwise to increase the chances of establishing a connection over the Internet.
- [`SdpSemantic`](xref:Microsoft.MixedReality.WebRTC.PeerConnectionConfiguration.SdpSemantic) describes the semantic used by the Session Description Protocol (SDP) while trying to establish a connection. This is a compatibility feature, which allows connecting with older peers supporting only the deprecated _Plan B_ semantic. New code should always use the default _Unified Plan_, which is the only one accepted by the WebRTC 1.0 standard.

The other fields are for advanced use, and can be left with their default values.

Once the connection is initialized, two categories of actions can be performed, in any order:

- Attempt to establish a connection with the remote peer.
- Add some media tracks and/or data channels.

Expand All @@ -26,39 +28,44 @@ Media (audio and/or video) tracks and data channels added before the connection
## Events

A [`PeerConnection`](xref:Microsoft.MixedReality.WebRTC.PeerConnection) exposes several categories of events:

- **Signaling events** are related to establishing a connection to the remote peer.
- **Track and channel events** provide informational notifications about adding and removing media tracks and data channels.
- **Frame events** are high frequency per-frame callbacks invoked when and audio or video frame is available for local rendering.
- **Media and data channel events** provide informational notifications about adding and removing transceivers, media tracks, and data channels.

In general it is recommended to subscribe to these events before starting to establish a connection with the remote peer.
In general it is strongly recommended to subscribe to these events before starting to establish a connection to the remote peer.

### Signaling events

| Event | Status* | Description |
|---|---|---|
| [`Connected`](xref:Microsoft.MixedReality.WebRTC.PeerConnection.Connected) | Recommended |Invoked when the connection with the remote peer is established. This indicates that tracks and channel are ready for use, although ICE can continue its discovery in the background. |
| [`LocalSdpReadytoSend`](xref:Microsoft.MixedReality.WebRTC.PeerConnection.LocalSdpReadytoSend) | Mandatory | Invoked when the local peer finished crafting an SDP message, to request the user to send that message to the remote peer via its chosen signaling solution. |
| <span style="white-space: pre; word-break: break-word">[`IceCandidateReadytoSend`](xref:Microsoft.MixedReality.WebRTC.PeerConnection.IceCandidateReadytoSend)</span> | Mandatory | Invoked when the local peer finished crafting an ICE candidate message, to request the user to send that message to the remote peer via its chosen signaling solution. |
| [`IceStateChanged`](xref:Microsoft.MixedReality.WebRTC.PeerConnection.IceCandidateReadytoSend) | Optional | Invoked when the state of the local ICE connection changed. |
| [`RenegotiationNeeded`](xref:Microsoft.MixedReality.WebRTC.PeerConnection.IceCandidateReadytoSend) | Recommended | Invoked when the peer connection detected that the current session is obsolete, and needs to be renegotiated. This is generally the result of some media tracks or data channels being added or removed, and **must** be handled to make those changes available to the remote peer. However, it is perfectly acceptable to ignore **some** of those events, if several changes are expected in a short period of time, to avoid triggering multiple unnecessary renegotiations. However a renegotiation eventually needs to happen for the newly added tracks and channel to become open. |
| [`LocalSdpReadytoSend`](xref:Microsoft.MixedReality.WebRTC.PeerConnection.LocalSdpReadytoSend) | Mandatory | Raised when the local peer finished crafting an SDP message, to request the user to send that message to the remote peer via its chosen signaling solution. Failing to handle this event prevents the peer-to-peer connection from establishing. |
| <span style="white-space: pre; word-break: break-word">[`IceCandidateReadytoSend`](xref:Microsoft.MixedReality.WebRTC.PeerConnection.IceCandidateReadytoSend)</span> | Mandatory | Raised when the local peer finished crafting an ICE candidate message, to request the user to send that message to the remote peer via its chosen signaling solution. Failing to handle this event generally prevents the peer-to-peer connection from establishing. |
| [`Connected`](xref:Microsoft.MixedReality.WebRTC.PeerConnection.Connected) | Recommended |Raised when the connection with the remote peer is established. This indicates that tracks and channel are ready for use, although ICE can continue its discovery in the background. This does **not** indicate that the session negotiation is completed yet; this event is raised on the answering peer as soon as it creates an answer and applies it, before it is sent to the remote peer, while it is only raised later on the offering peer when that answer is actually received and applied. |
| [`RenegotiationNeeded`](xref:Microsoft.MixedReality.WebRTC.PeerConnection.IceCandidateReadytoSend) | Recommended | Raised when the peer connection detected that the current session is obsolete, and needs to be renegotiated. This is generally the result of some media tracks or data channels being added or removed, and **must** be handled to make those changes available to the remote peer. However, it is perfectly acceptable to ignore **some** of those events, if several changes are expected in a short period of time, to avoid triggering multiple unnecessary renegotiations. However a renegotiation eventually needs to happen for the newly added tracks and channel to become open. |
| [`IceStateChanged`](xref:Microsoft.MixedReality.WebRTC.PeerConnection.IceStateChanged) | Optional | Raised when the state of the local ICE connection changed. |
| [`IceGatheringStateChanged`](xref:Microsoft.MixedReality.WebRTC.PeerConnection.IceGatheringStateChanged) | Optional | Raised when the state of the ICE candidate gathering process changed. |

*_Status_ indicates the recommended subscription status for a working peer connection:

- **Mandatory** means those events must be handled, otherwise the connection cannot be established.
- **Recommended** means those events are typically handled, although not mandatory.
- **Optional** means those events are informational only, and it is entirely optional to subscribe to them.

### Track and channel events
### Media and data channel events

| Event | Status* | Description |
|---|---|---|
| [`TrackAdded`](xref:Microsoft.MixedReality.WebRTC.PeerConnection.TrackAdded) | Optional | Invoked when a media track (audio or video) was added on the remote peer, and received on the local peer after a renegotiation. This only concerns remotely-created tracks. Tracks whose creation was initied locally with _e.g._ [`AddLocalVideoTrackAsync()`](xref:Microsoft.MixedReality.WebRTC.PeerConnection.AddLocalVideoTrackAsync(Microsoft.MixedReality.WebRTC.PeerConnection.LocalVideoTrackSettings)) do not generate a [`TrackAdded`](xref:Microsoft.MixedReality.WebRTC.PeerConnection.TrackAdded) event. |
| [`TrackRemoved`](xref:Microsoft.MixedReality.WebRTC.PeerConnection.TrackRemoved) | Optional | Invoked when a media track (audio or video) was removed on the remote peer, and a remove message was received on the local peer after a renegotiation. This only concerns remotely-deleted tracks. Tracks removed locally with _e.g._ [`RemoveLocalVideoTrack(LocalVideoTrack)`](xref:Microsoft.MixedReality.WebRTC.PeerConnection.RemoveLocalVideoTrack(Microsoft.MixedReality.WebRTC.LocalVideoTrack)) do not generate a [`TrackRemoved`](xref:Microsoft.MixedReality.WebRTC.PeerConnection.TrackRemoved) event. |
| [`TransceiverAdded`](xref:Microsoft.MixedReality.WebRTC.PeerConnection.TransceiverAdded) | Optional | Raised when a transceiver was added to the peer connection, either manually by calling [`AddTransceiver()`](xref:Microsoft.MixedReality.WebRTC.PeerConnection.AddTransceiver(Microsoft.MixedReality.WebRTC.MediaKind,Microsoft.MixedReality.WebRTC.TransceiverInitSettings)), or automatically by the implementation when a remote session description is applied with [`SetRemoteDescriptionAsync()`](xref:Microsoft.MixedReality.WebRTC.PeerConnection.SetRemoteDescriptionAsync(System.String,System.String)) and the remote peer added a new transceiver. |
| [`AudioTrackAdded`](xref:Microsoft.MixedReality.WebRTC.PeerConnection.AudioTrackAdded) | Optional | Raised when an audio track was added on the remote peer, and received on the local peer after a session negotiation. This only concerns remotely-created tracks. Tracks whose creation was initied locally with _e.g._ [`LocalAudioTrack.CreateFromDeviceAsync()`](xref:Microsoft.MixedReality.WebRTC.LocalAudioTrack.CreateFromDeviceAsync(Microsoft.MixedReality.WebRTC.LocalAudioTrackSettings)) do not raise the [`AudioTrackAdded`](xref:Microsoft.MixedReality.WebRTC.PeerConnection.AudioTrackAdded) event. |
| [`AudioTrackRemoved`](xref:Microsoft.MixedReality.WebRTC.PeerConnection.AudioTrackRemoved) | Optional | Invoked when an audio track was removed on the remote peer, and a remove message was received on the local peer after a session negotiation. This only concerns remote tracks. Local tracks do not raise the [`AudioTrackRemoved`](xref:Microsoft.MixedReality.WebRTC.PeerConnection.AudioTrackRemoved) event. |
| [`VideoTrackAdded`](xref:Microsoft.MixedReality.WebRTC.PeerConnection.VideoTrackAdded) | Optional | Invoked when a video track was added on the remote peer, and received on the local peer after a session negotiation. This only concerns remotely-created tracks. Tracks whose creation was initied locally with _e.g._ [`LocalVideoTrack.CreateFromDeviceAsync()`](xref:Microsoft.MixedReality.WebRTC.LocalVideoTrack.CreateFromDeviceAsync(Microsoft.MixedReality.WebRTC.LocalVideoTrackSettings)) do not raise the [`VideoTrackAdded`](xref:Microsoft.MixedReality.WebRTC.PeerConnection.VideoTrackAdded) event. |
| [`VideoTrackRemoved`](xref:Microsoft.MixedReality.WebRTC.PeerConnection.VideoTrackRemoved) | Optional | Invoked when a video track was removed on the remote peer, and a remove message was received on the local peer after a session negotiation. This only concerns remote tracks. Local tracks do not raise the [`VideoTrackRemoved`](xref:Microsoft.MixedReality.WebRTC.PeerConnection.VideoTrackRemoved) event. |
| [`DataChannelAdded`](xref:Microsoft.MixedReality.WebRTC.PeerConnection.DataChannelAdded) | Optional | Invoked when a data channel was added to the local peer connection. This is always fired, irrelevant of how the data channel was initially created (in-band or out-of-band). |
| <span style="white-space: pre; word-break: break-word">[`DataChannelRemoved`](xref:Microsoft.MixedReality.WebRTC.PeerConnection.DataChannelRemoved)</span> | Optional | Invoked when a data channel was removed from the local peer connection. This is always fired, irrelevant of how the data channel was initially created (in-band or out-of-band). |

*_Status_ - See above.

### Frame events
<!-- ### Frame events

| Event | Status* | Description |
|---|---|---|
Expand All @@ -70,4 +77,4 @@ In general it is recommended to subscribe to these events before starting to est
*_Status_ - See above.

> [!NOTE]
> It is generally recommended to use the I420 callbacks instead of the ARGB ones. Even in situations where the processing (_e.g._ local rendering) requires ARGB frames, I420 frames are smaller thanks to the chroma downsampling, so faster to upload to GPU. And GPU-based I420-to-ARGB conversion via a custom pixel shader (fragment shader) is more efficient than the CPU conversion provided by the ARGB callbacks, even with the use of SIMD. See [`YUVFeedShaderUnlit.shader`](https://github.com/microsoft/MixedReality-WebRTC/blob/master/libs/Microsoft.MixedReality.WebRTC.Unity/Assets/Microsoft.MixedReality.WebRTC.Unity/Shaders/YUVFeedShaderUnlit.shader) in the Unity integration for an example of such conversion shader.
> It is generally recommended to use the I420 callbacks instead of the ARGB ones. Even in situations where the processing (_e.g._ local rendering) requires ARGB frames, I420 frames are smaller thanks to the chroma downsampling, so faster to upload to GPU. And GPU-based I420-to-ARGB conversion via a custom pixel shader (fragment shader) is more efficient than the CPU conversion provided by the ARGB callbacks, even with the use of SIMD. See [`YUVFeedShaderUnlit.shader`](https://github.com/microsoft/MixedReality-WebRTC/blob/master/libs/Microsoft.MixedReality.WebRTC.Unity/Assets/Microsoft.MixedReality.WebRTC.Unity/Shaders/YUVFeedShaderUnlit.shader) in the Unity integration for an example of such conversion shader. -->
Loading