Commit 1334aa4d authored by Sylvain Berfini's avatar Sylvain Berfini 🎩
Browse files

Same changes for C# wrapper than for Java wrapper about how listener references are handled

parent 88facddb
......@@ -10,6 +10,11 @@ This changelog file was started on October 2019. Previous changes were more or l
## [5.0.0] Unreleased
### Changed
- Java wrapper now creates a separated managed object for const native pointers and print an error log when trying to use a non-const method on it.
- Java & C# wrapper now takes a strong reference on listeners, allowing to use inner classes & lambda expressions even without keeping parent object around.
- Deprecated methods for more than two years have been removed from wrappers (e.g. every setListener() on some objects).
### Removed
- Legacy Java wrapper for Android
......@@ -20,7 +25,7 @@ This changelog file was started on October 2019. Previous changes were more or l
- Automatic handling of some mobile OS behaviours
* enterForeground() and enterBackground() automatically called (iOS and Android).
* auto acquire and release of audio focus for Android.
* Core.iterate() is being called automatically internally for Android, it is no longer needed to create a timer in the application to call it.
* Core.iterate() is being called automatically internally for Android & iOS, it is no longer needed to create a timer in the application to call it.
- New audio routes API to choose which device use to capture & play audio (Android & iOS). The application can manage
audio route changes (bluetooth, speaker, earpiece) throug liblinphone's API.
- Added API to play user's ringtone instead of default ringtone for Android.
......@@ -29,7 +34,6 @@ This changelog file was started on October 2019. Previous changes were more or l
see specific documentation here: https://wiki.linphone.org/xwiki/wiki/public/view/Lib/Getting%20started/iOS/#HCallKitintegration
- client-based video conference in active speaker switching mode (beta feature).
### Changed
- Warning: some function parameters have been renamed for consistency, which modified the Swift API (where parameter names are part of the ABI).
As a result, adjustements in applications are expected when migrating a swift app based on liblinphone from 4.4 to 4.5.
......
......@@ -105,35 +105,35 @@ namespace Linphone
internal List<IntPtr> string_ptr_list;
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate void OnLinphoneObjectDataDestroyed(IntPtr data);
internal delegate void OnLinphoneObjectDataDestroyed(IntPtr data);
[DllImport(LinphoneWrapper.BELLE_SIP_LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
#if WINDOWS_UWP
static extern int belle_sip_object_data_set(IntPtr ptr, string name, IntPtr data, IntPtr cb);
internal static extern int belle_sip_object_data_set(IntPtr ptr, string name, IntPtr data, IntPtr cb);
#else
static extern int belle_sip_object_data_set(IntPtr ptr, string name, IntPtr data, OnLinphoneObjectDataDestroyed cb);
internal static extern int belle_sip_object_data_set(IntPtr ptr, string name, IntPtr data, OnLinphoneObjectDataDestroyed cb);
#endif
[DllImport(LinphoneWrapper.BELLE_SIP_LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr belle_sip_object_data_get(IntPtr ptr, string name);
internal static extern IntPtr belle_sip_object_data_get(IntPtr ptr, string name);
[DllImport(LinphoneWrapper.BELLE_SIP_LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr belle_sip_object_ref(IntPtr ptr);
internal static extern IntPtr belle_sip_object_ref(IntPtr ptr);
[DllImport(LinphoneWrapper.BELLE_SIP_LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
static extern void belle_sip_object_unref(IntPtr ptr);
internal static extern void belle_sip_object_unref(IntPtr ptr);
[DllImport(LinphoneWrapper.BELLE_SIP_LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
static extern void belle_sip_object_data_remove(IntPtr ptr, string name);
internal static extern void belle_sip_object_data_remove(IntPtr ptr, string name);
[DllImport(LinphoneWrapper.BCTOOLBOX_LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr bctbx_list_next(IntPtr ptr);
internal static extern IntPtr bctbx_list_next(IntPtr ptr);
[DllImport(LinphoneWrapper.BCTOOLBOX_LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr bctbx_list_get_data(IntPtr ptr);
internal static extern IntPtr bctbx_list_get_data(IntPtr ptr);
[DllImport(LinphoneWrapper.BCTOOLBOX_LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr bctbx_list_append(IntPtr elem, IntPtr data);
internal static extern IntPtr bctbx_list_append(IntPtr elem, IntPtr data);
~LinphoneObject()
{
......@@ -345,10 +345,6 @@ namespace Linphone
[StructLayout(LayoutKind.Sequential)]
public class {{interfaceName}} : LinphoneObject
{
~{{interfaceName}}()
{
unregister();
}
[DllImport(LinphoneWrapper.LIB_NAME, CallingConvention = CallingConvention.Cdecl)]
static extern void {{set_user_data_name}}(IntPtr thiz, IntPtr listener);
......@@ -421,35 +417,44 @@ namespace Linphone
{{/delegate}}
{{/methods}}
internal OnLinphoneObjectDataDestroyed onLinphoneListenerObjectDestroyed;
internal void on_linphone_cbs_data_destroyed(IntPtr data) {
if (data != IntPtr.Zero)
{
GCHandle.FromIntPtr(data).Free();
}
}
internal void register() {
IntPtr listener = {{get_user_data_name}}(nativePtr);
IntPtr listener = belle_sip_object_data_get(nativePtr, "cs_listener_obj");
if (listener == IntPtr.Zero)
{
GCHandle _handle = GCHandle.Alloc(this, GCHandleType.Normal);
listener = GCHandle.ToIntPtr(_handle);
} else
}
else
{
GCHandle _handle = GCHandle.FromIntPtr(listener);
if (_handle.Target == this)
{
return;
} else
}
else
{
_handle.Free();
_handle = GCHandle.Alloc(this, GCHandleType.Normal);
listener = GCHandle.ToIntPtr(_handle);
}
}
{{set_user_data_name}}(nativePtr, listener);
}
internal void unregister() {
IntPtr listener = {{get_user_data_name}}(nativePtr);
{{set_user_data_name}}(nativePtr, IntPtr.Zero);
if (listener != IntPtr.Zero)
{
GCHandle.FromIntPtr(listener).Free();
}
#if WINDOWS_UWP
onLinphoneListenerObjectDestroyed = on_linphone_cbs_data_destroyed;
IntPtr cb = Marshal.GetFunctionPointerForDelegate(onLinphoneListenerObjectDestroyed);
belle_sip_object_data_set(nativePtr, "cs_listener_obj", listener, cb);
#else
belle_sip_object_data_set(nativePtr, "cs_listener_obj", listener, on_linphone_cbs_data_destroyed);
#endif
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment