BelledonneCommunications / liblinphone

Linphone.org mirror for liblinphone (git://git.linphone.org/liblinphone.git)
http://linphone.org
GNU Affero General Public License v3.0
382 stars 219 forks source link

C# wrapper property setter ProxyConfig.Routes produces garbage on iOS #107

Open anders9ustafsson opened 5 years ago

anders9ustafsson commented 5 years ago

The ProxyConfig.Routes setter in the C# wrapper fails to conserve the strings provided by the user in an iOS application, subsequently resulting in failure to sufficiently establish media transfer when making a call.

Problem appears to be that the ProxyConfig.Routes setter is using the static method StringArrayToBctbxList to convert managed strings to unmanaged. On Android conversion seems to work, but on iOS the unmanaged string is completely distorted. Changing this line:

bctbx_list = bctbx_list_append(bctbx_list, s);

into this

bctbx_list = bctbx_list_append(bctbx_list, Marshal.StringToHGlobalAnsi(s));

does seem to help though.

anders9ustafsson commented 5 years ago

On a similar note, using Marshal.PtrToStringAuto appears to cause problems when appying the C# wrapper in a Windows Desktop application (yes, I am aware that this is not a supported scenario, but generally it works). Marshalling yields strings in Chinese. Marshal.PtrToStringAnsi seems to produce more correct results, at least when running on an en-US localized computer. The change does not appear to break anything for the other platforms either.