MixedReality-WebRTC icon indicating copy to clipboard operation
MixedReality-WebRTC copied to clipboard

No ICE Gathering event fired

Open drejx opened this issue 6 years ago • 6 comments

In the current SDK there is no event which tells the user when ICE gathering has completed. This can cause issues if an application wishes to wait for ICE gathering to be complete before advancing further.

Based on the remarks in the IceConnectionState enum it seems it's grouped into the IceConnectionState enums:

namespace Microsoft.MixedReality.WebRTC
{
    //
    // Summary:
    //     State of an ICE connection.
    //
    // Remarks:
    //     Due to the underlying implementation, this is currently a mix of the RTPIceGatheringState
    //     and the RTPPeerConnectionState from the WebRTC 1.0 standard.
    public enum IceConnectionState
    {
        //
        // Summary:
        //     Newly created ICE connection. This is the starting state.
        New = 0,
        //
        // Summary:
        //     ICE connection received an offer, but transports are not writable yet.
        Checking = 1,
        ....
        <snip>

But the PeerConnection.IceStateChanged event is not fired during ICE gathering (i.e. right after the initial CreateOffer(), where SetLocalDescription() is internally called).

Looking a bit closer the IceConnectionState enum is actually a 1:1 mapping to RTCIceConnectionState and doesn't have any RTCIceGatheringState, so maybe the code comment is unintended?

Note that I've been migrating an application from webrtc-uwp-sdk to the MixedReality-SDK and in the former there is an ICE Gathering event which gets fired and the final event is RTCIceGatheringState_complete. This event is also fired in standard javascript implementations (Chrome/Firefox) so believe it might be a bug in the MixedReality-SDK.

Cheers, Andrej

drejx avatar Dec 14 '19 02:12 drejx

The comments are correct. The IceGatheringState event is not implemented.

jehumb-havok avatar Dec 16 '19 10:12 jehumb-havok

Fixed. I added an example use in TestAppUWP, under the remote video you can see a new "ICE gathering" state in addition of the already existing "ICE connection" state.

jehumb-havok avatar Dec 16 '19 10:12 jehumb-havok

Wow, that is great, thank you! I'll test it out on my end.

One thing I noticed is the IceConnectionState enum (PeerConnection.cs) still has the note about it being a mix of the connection and gathering states:

    /// Due to the underlying implementation, this is currently a mix of the RTPIceGatheringState
    /// and the RTPPeerConnectionState
   ...
    public enum IceConnectionState : int

Cheers, Andrej

drejx avatar Dec 16 '19 20:12 drejx

Yes and as I pointed this comment is correct, this is an implementation "design"/"issue" from the Google code, which is fixed in a later Google milestone, but in the one we use (M71) this is like this, and the comment is an almost exact copy of the one found in the Google code.

jehumb-havok avatar Dec 17 '19 11:12 jehumb-havok

Tested the new IceGatheringStateChanged event and it works great, thanks again :)

Regarding the IceConnectionState enum being a mix of IceGatheringState/IceConnectionState I wasn't aware it came directly from the m71 codebase, good to know. I made my comment based on pure observation.

Cheers, Andrej

drejx avatar Dec 17 '19 23:12 drejx

Yes this is confusing, I don't know why Google did that. This is fixed in a later milestone so hopefully this will go away and match the WebRTC 1.0 Standard once we upgraded to a later Google milestone.

jehumb-havok avatar Dec 18 '19 10:12 jehumb-havok