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

Add multi-track support to C# library via transceiver API #221

Merged
merged 26 commits into from
Mar 19, 2020

Conversation

djee-ms
Copy link
Member

@djee-ms djee-ms commented Mar 12, 2020

This is part 2/N of the multi-track support : C# library. See part 1 (interop; #202) for an overall description of the API changes.

Bug: #152

djee-ms added 11 commits March 12, 2020 14:49
This follows the change in the interop DLL.
Callbacks from native code (reverse P/Invoke) are invoked on the
signaling thread and should not call into the native WebRTC API again.
For the RenegotiationNeeded event, since it is common for the user to
call CreateOffer() as a result of this event, move its call to a worker
thread. In addition, delay the call until the C# Transceiver wrapper has
been fully constructed (and its handle set) to avoid invoking an event
with a partially-constructed object.
Wait until the SDP exchange is completed to continue testing, otherwise
some RenegotiationNeeded event or other might be invoked due to
SetRemoteDescription() in parallel of another call due to setting a
transceiver direction, among other issues.
@djee-ms djee-ms added the enhancement New feature or request label Mar 12, 2020
@djee-ms djee-ms added this to the 2.0.0 milestone Mar 12, 2020
@djee-ms djee-ms requested review from stephenatwork and fibann March 12, 2020 15:05
@djee-ms djee-ms self-assigned this Mar 12, 2020
Comment on lines +558 to +559
// Cannot run in UI thread on UWP because this will initialize the global factory
// (first library call) which needs to be done on a background thread.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: not for this review, but this looks like a very easy pitfall, it might be better to have an explicit initialization call instead.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, although explicit call is quite tricky in Unity

Copy link
Member

@fibann fibann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments

djee-ms added 3 commits March 16, 2020 14:55
Media tracks attached to the peer connection are those tracks attached
to an owned transceiver, so can be enumerated from them. This simplifies
the implementation and avoid the need to keep track of those tracks
explicitly.
Rely on peer connection callbacks during Close() to clean-up the remote
tracks. Also fix a bug where those callbacks are fired after the tracks
have been destroyed.
- Fix bug in implementation passing the wrong address as the data
  channel object handle, which results in stack corruption of the
  managed engine.
- Drive data channel clean-up from the DataChannelRemoved callback,
  whether invoked from the user removing a data channel or from a data
  channel being removed/destroyed automatically by the implementation.
djee-ms added 5 commits March 16, 2020 17:51
This is redundant with the Transceiver.DesiredDirection setter.
Like remote tracks, data channels are essentially owned by the peer
connection, even if the user can manually initiate creation. Therefore
make DataChannel a regular non-disposable class to avoid confusion with
implementation destroying a data channel.
}

internal void Destroy()
internal void DestroyNative()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The call to GC.SuppressFinalize is unnecessary now, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@djee-ms djee-ms merged commit 187b48e into microsoft:merge/multi_track Mar 19, 2020
@djee-ms djee-ms deleted the merge/multi_track_cs branch March 19, 2020 09:30
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants