Unity-Technologies / Unity-Technologies/com.unity.webrtc

[BUG]: end of candidates indicator

Open
#983 15 comments 0 reactions 1 assignee View on GitHub

@karasusan is already working on this.

Since Sep 26, 2023.

bug issued
Dominant language
Assembly
Stars
852
Forks
238
PR merge metrics
No merged PRs in 30d

Description

Package version

3.0.0-pre.6

Environment
* OS: Windows 10
* Unity version: 2022.3.5f1
Steps To Reproduce

I'm able to connect to gstreamer signalling server, and connect to audio/video producers. Local tests work well.

In real conditions, with two different computers, I receive from the gstreamer producer that makes the SDP offer a null ice candidate {"type":"peer","sessionId":"c375043d-1145-4867-99de-97ed0240b898","ice":{"candidate":"","sdpMLineIndex":0}}. I believe this is supposed to mean the end of the sending of ice candidates (end of candidates indicator)

Current Behavior

Unity fails to make an empty ice candidate

ArgumentException: create candidate is failed. error type:InvalidParameter, candidate:
sdpMid:
sdpMLineIndex:0
  at Unity.WebRTC.RTCIceCandidate..ctor (Unity.WebRTC.RTCIceCandidateInit candidateInfo) [0x000c1] in .\Library\PackageCache\com.unity.webrtc@3.0.0-pre.6\Runtime\Scripts\RTCIceCandidate.cs:264 

I am supposed to simply ignore this ice candidate? (if I do so the connection if ended by gstreamer but I don't know exactly why yet)

Expected Behavior

This case should be managed by Unity. For now this function is designed to refuse any empty candidate

        public RTCIceCandidate(RTCIceCandidateInit candidateInfo = null)
        {
            candidateInfo = candidateInfo ?? new RTCIceCandidateInit();
            if(candidateInfo.sdpMLineIndex == null && candidateInfo.sdpMid == null)
                throw new ArgumentException("sdpMid and sdpMLineIndex are both null");

            RTCIceCandidateInitInternal option = (RTCIceCandidateInitInternal)candidateInfo;
            RTCErrorType error = NativeMethods.CreateIceCandidate(ref option, out self);
            if (error != RTCErrorType.None)
                throw new ArgumentException(
                        $"create candidate is failed. error type:{error}, " +
                        $"candidate:{candidateInfo.candidate}\n" +
                        $"sdpMid:{candidateInfo.sdpMid}\n" +
                        $"sdpMLineIndex:{candidateInfo.sdpMLineIndex}\n");

            NativeMethods.IceCandidateGetCandidate(self, out _candidate);
        }
    }
Anything else?

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.