public IEnumerator MediaStreamTrackThrowExceptionAfterPeerDisposed() { 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); MediaStreamTrack track1 = null; peer2.OnTrack = e => { track1 = e.Track; }; yield return(SignalingOffer(peer1, peer2)); Assert.That(track1, Is.Not.Null); peer2.Dispose(); Assert.That(() => track1.Id, Throws.TypeOf <ObjectDisposedException>()); track.Dispose(); track1.Dispose(); Object.DestroyImmediate(source.clip); Object.DestroyImmediate(obj); }
public IEnumerator MediaStreamTrackThrowExceptionAfterPeerDisposed() { 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); MediaStreamTrack track1 = null; peer2.OnTrack = e => { track1 = e.Track; }; yield return(SignalingOffer(peer1, peer2)); Assert.That(track1, Is.Not.Null); peer2.Dispose(); Assert.That(() => track1.Id, Throws.TypeOf <InvalidOperationException>()); track.Dispose(); track1.Dispose(); }