[WebRTC] Disable MediaPacket native handle destroy (#4642)
[platform/core/csapi/tizenfx.git] / src / Tizen.Multimedia / MediaTool / MediaPacket.cs
index b492ade..affdc4d 100644 (file)
@@ -547,7 +547,11 @@ namespace Tizen.Multimedia
 
             if (_handle != IntPtr.Zero)
             {
-                Native.Unref(_handle);
+                if (_isNativeHandleDestroyEnabled)
+                {
+                    Native.Unref(_handle);
+                }
+
                 _handle = IntPtr.Zero;
             }
 
@@ -565,6 +569,15 @@ namespace Tizen.Multimedia
                 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()