public override void Dispose() { if (this.disposed) { return; } if (self != IntPtr.Zero && !WebRTC.Context.IsNull) { if (IsEncoderInitialized) { WebRTC.Context.FinalizeEncoder(self); if (RenderTexture.active == m_destTexture) { RenderTexture.active = null; } // Unity API must be called from main thread. WebRTC.DestroyOnMainThread(m_destTexture); } if (IsDecoderInitialized) { m_renderer.Dispose(); // Unity API must be called from main thread. WebRTC.DestroyOnMainThread(m_destTexture); } _source?.Dispose(); s_tracks.TryRemove(self, out var value); } base.Dispose(); }
public override void Dispose() { if (this.disposed) { return; } sourceTexture_ = null; // Unity API must be called from main thread. // This texture is referred from the rendering thread, // so set the delay 100ms to wait the task of another thread. WebRTC.DestroyOnMainThread(destTexture_, 0.1f); if (ptr_ != IntPtr.Zero) { // This buffer is referred from the rendering thread, // so set the delay 100ms to wait the task of another thread. WebRTC.DelayActionOnMainThread(() => { Marshal.FreeHGlobal(ptr_); }, 0.1f); } if (self != IntPtr.Zero && !WebRTC.Context.IsNull) { WebRTC.Table.Remove(self); } base.Dispose(); }
/// <summary> /// /// </summary> public override void Dispose() { if (this.disposed) { return; } if (self != IntPtr.Zero && !WebRTC.Context.IsNull) { if (_audioCapturer != null) { // Unity API must be called from main thread. _audioCapturer.onAudioRead -= SetData; WebRTC.DestroyOnMainThread(_audioCapturer); } if (_streamRenderer != null) { _streamRenderer?.Dispose(); _streamRenderer = null; } _trackSource?.Dispose(); _trackSource = null; } base.Dispose(); }
public void Dispose() { if (this.disposed) { return; } if (self != IntPtr.Zero && !WebRTC.Context.IsNull) { if (_track != null && WebRTC.Table.ContainsKey(_track.self)) { _track.RemoveSink(this); } WebRTC.Table.Remove(self); WebRTC.Context.DeleteAudioTrackSink(self); self = IntPtr.Zero; } if (_filter != null) { _filter.onAudioRead -= SetData; WebRTC.DestroyOnMainThread(_filter); } this.disposed = true; GC.SuppressFinalize(this); }
public void Dispose() { if (m_clip != null) { WebRTC.DestroyOnMainThread(m_clip); } m_clip = null; }
private void OnVideoFrameResizeInternal(int width, int height) { if (Texture != null && Texture.width == width && Texture.height == height) { return; } if (Texture != null) { WebRTC.DestroyOnMainThread(Texture); Texture = null; } var format = WebRTC.GetSupportedGraphicsFormat(SystemInfo.graphicsDeviceType); Texture = new Texture2D(width, height, format, TextureCreationFlags.None); track.OnVideoFrameResize(Texture); }
/// <summary> /// /// </summary> public override void Dispose() { if (this.disposed) { return; } if (self != IntPtr.Zero && !WebRTC.Context.IsNull) { if (_audioSourceRead != null) { // Unity API must be called from main thread. _audioSourceRead.onAudioRead -= SetData; WebRTC.DestroyOnMainThread(_audioSourceRead); } _streamRenderer?.Dispose(); _source?.Dispose(); WebRTC.Context.AudioTrackUnregisterAudioReceiveCallback(self); } base.Dispose(); }
public void Dispose() { if (this.disposed) { return; } if (self != IntPtr.Zero) { IntPtr trackPtr = track.GetSelfOrThrow(); if (trackPtr != IntPtr.Zero) { NativeMethods.VideoTrackRemoveSink(trackPtr, self); } WebRTC.DestroyOnMainThread(Texture); WebRTC.Context.DeleteVideoRenderer(self); WebRTC.Table.Remove(self); self = IntPtr.Zero; } this.disposed = true; GC.SuppressFinalize(this); }