예제 #1
0
        public IEnumerator RestartIceInvokeOnNegotiationNeeded()
        {
            RTCConfiguration config = default;

            config.iceServers = new[] { new RTCIceServer {
                                            urls = new[] { "stun:stun.l.google.com:19302" }
                                        } };
            var peer1 = new RTCPeerConnection(ref config);
            var peer2 = new RTCPeerConnection(ref config);

            peer1.OnIceCandidate = candidate => { peer2.AddIceCandidate(candidate); };
            peer2.OnIceCandidate = candidate => { peer1.AddIceCandidate(candidate); };

            var obj    = new GameObject("audio");
            var source = obj.AddComponent <AudioSource>();

            source.clip = AudioClip.Create("test", 480, 2, 48000, false);
            AudioStreamTrack track = new AudioStreamTrack(source);

            peer1.AddTrack(track);

            yield return(SignalingOffer(peer1, peer2));

            bool isInvokeOnNegotiationNeeded1 = false;
            bool isInvokeOnNegotiationNeeded2 = false;

            peer1.OnNegotiationNeeded = () => isInvokeOnNegotiationNeeded1 = true;
            peer2.OnNegotiationNeeded = () => isInvokeOnNegotiationNeeded2 = true;

            peer1.RestartIce();
            var op9 = new WaitUntilWithTimeout(() => isInvokeOnNegotiationNeeded1, 5000);

            yield return(op9);

            Assert.That(op9.IsCompleted, Is.True);

            peer2.RestartIce();
            var op10 = new WaitUntilWithTimeout(() => isInvokeOnNegotiationNeeded2, 5000);

            yield return(op10);

            Assert.That(op10.IsCompleted, Is.True);

            track.Dispose();
            peer1.Close();
            peer2.Close();
            Object.DestroyImmediate(source.clip);
            Object.DestroyImmediate(obj);
        }
        public IEnumerator RestartIceInvokeOnNegotiationNeeded()
        {
            RTCConfiguration config = default;

            config.iceServers = new[] { new RTCIceServer {
                                            urls = new[] { "stun:stun.l.google.com:19302" }
                                        } };
            var peer1 = new RTCPeerConnection(ref config);
            var peer2 = new RTCPeerConnection(ref config);

            peer1.OnIceCandidate = candidate => { peer2.AddIceCandidate(candidate); };
            peer2.OnIceCandidate = candidate => { peer1.AddIceCandidate(candidate); };

            AudioStreamTrack track = new AudioStreamTrack();

            peer1.AddTrack(track);

            yield return(SignalingOffer(peer1, peer2));

            bool isInvokeOnNegotiationNeeded1 = false;
            bool isInvokeOnNegotiationNeeded2 = false;

            peer1.OnNegotiationNeeded = () => isInvokeOnNegotiationNeeded1 = true;
            peer2.OnNegotiationNeeded = () => isInvokeOnNegotiationNeeded2 = true;

            peer1.RestartIce();
            var op9 = new WaitUntilWithTimeout(() => isInvokeOnNegotiationNeeded1, 5000);

            yield return(op9);

            Assert.That(op9.IsCompleted, Is.True);

            peer2.RestartIce();
            var op10 = new WaitUntilWithTimeout(() => isInvokeOnNegotiationNeeded2, 5000);

            yield return(op10);

            Assert.That(op10.IsCompleted, Is.True);

            track.Dispose();
            peer1.Close();
            peer2.Close();
        }
예제 #3
0
    private void RestartIce()
    {
        restartButton.interactable = false;

        _pc1.RestartIce();
    }