* [WebRTC] Disable MediaPacket native handle destroy
throw new ArgumentException("Audio is not configured with the current source.");
}
+ // MediaPacket native handle will be destroyed internally in native webrtc fw
+ packet.DisableNativeHandleDestroy();
+
NativeWebRTC.PushMediaPacket(WebRtc.Handle, SourceId.Value, packet.GetHandle()).
ThrowIfFailed("Failed to push the packet to the WebRTC");
}
if (_handle != IntPtr.Zero)
{
- Native.Unref(_handle);
+ if (_isNativeHandleDestroyEnabled)
+ {
+ Native.Unref(_handle);
+ }
+
_handle = IntPtr.Zero;
}
throw new ObjectDisposedException("This packet has already been disposed.");
}
}
+
+ private bool _isNativeHandleDestroyEnabled = true;
+ /// <summary>
+ /// Disables native handle destruction when native fw destroys media packet handle itself.
+ /// </summary>
+ internal void DisableNativeHandleDestroy()
+ {
+ _isNativeHandleDestroyEnabled = false;
+ }
#endregion
internal IntPtr GetHandle()