@@ -230,14 +230,6 @@ public void Dispose()
230230 _logs . Warning ( $ "Disposing PeerConnection [{ _peerType } ]") ;
231231#endif
232232
233- #if STREAM_NATIVE_AUDIO
234- if ( PublisherAudioTrack != null )
235- {
236- //StreamTODO: call this when PublisherAudioTrack is set to null
237- PublisherAudioTrack . StopLocalAudioCapture ( ) ;
238- }
239- #endif
240-
241233 _mediaInputProvider . AudioInputChanged -= OnAudioInputChanged ;
242234 _mediaInputProvider . VideoSceneInputChanged -= OnVideoSceneInputChanged ;
243235 _mediaInputProvider . VideoInputChanged -= OnVideoInputChanged ;
@@ -252,13 +244,28 @@ public void Dispose()
252244 _peerConnection . OnConnectionStateChange -= OnConnectionStateChange ;
253245 _peerConnection . OnTrack -= OnTrack ;
254246
247+ #if STREAM_NATIVE_AUDIO
248+ if ( PublisherAudioTrack != null )
249+ {
250+ //StreamTODO: call this when PublisherAudioTrack is set to null
251+ PublisherAudioTrack . StopLocalAudioCapture ( ) ;
252+ }
253+ #endif
254+
255+ if ( _publisherVideoTrackTexture != null )
256+ {
257+ _publisherVideoTrackTexture . Release ( ) ;
258+ _publisherVideoTrackTexture = null ;
259+ }
260+
255261 PublisherAudioTrack ? . Stop ( ) ;
256262 PublisherVideoTrack ? . Stop ( ) ;
257263 PublisherAudioTrack = null ;
258264 PublisherVideoTrack = null ;
259265
260266 _tracer ? . Trace ( PeerConnectionTraceKey . Close , null ) ;
261267 _peerConnection . Close ( ) ;
268+ _peerConnection . Dispose ( ) ;
262269
263270#if STREAM_DEBUG_ENABLED
264271 _logs . Warning ( $ "Disposed PeerConnection [{ _peerType } ]") ;
0 commit comments