Windows Nuget package

Last modified by Simon Morlat on 2024/10/15 12:24

 

Making a UWP or WPF application with linphone-sdk

A brief introduction to windows architecture

There are 3 kinds of native code binaries in the Microsoft Windows architecture.

  • Win32 : this is a standard version for Windows with all features, suitable to make a WPF or .Net Core application, but not a UWP one. The name 'Win32' is misleading: it does not imply a 32 bit architecture, it can be 64 bit (x64) as well.
  • WindowsStore : this is a variant of the Win32 build, but with specific compilation options to allow a UWP application to make use of it, and hence being publishable in Windows Store. The WindowsStore variant was later introduced by Microsoft to take into account the difficulty to port Win32 libraries to the UWP framework.
  • UWP : This version is to be used within UWP application. It is not all featured (for example: before 5.2, OpenH264 wasn't available )

All of these kinds of binaries can be built at least on x86 (32 bits) and x64 (64 bits).

Installing the Nuget package

A NuGet package (.nupkg) embedding and wrapping the Linphone SDK for UWP development on Windows is provided for your convenience.

It supports 3 frameworks, depending on which kind of Windows application is targetted

  • netcore (WindowsStore, x64 and x86) is suitable for doing a UWP or .NET Core application
  • netcore45 (Win32, x64 and x86) is suitable for doing a WPF or Windows Forms application (.NET Framework)
  • uap10.0 (UWP, x64) is suitable for doing a UWP or .NET Core application.

Some other frameworks are provided for convenience but aren't fully tested:

  • - net5.0 : .NET 5
  • - netstandard2.1:.NET Standard
  • - netcoreapp3.1 : .NET Core
  • - net48 : .NET Framework

If you would like to use another framework, you can build a nuget package from source. In the project, you have to add a target framework in 'cmake/NuGet/windows/LinphoneSDK.nuspec.in' by adding your item in 'dependencies' section:

<group targetFramework="<your target framework>" />

From our Package Registry

Since version 5.2.0, the nupkg is availble for download from our self-hosted NuGet package registry.

  1. Add the Linphone package source to your development environment (You only need to do that once)
    nuget source Add -Name "Linphone" -Source "https://gitlab.linphone.org/api/v4/projects/411/packages/nuget/index.json"
    Or in Visual Studio, go to Tools->Nuget Package Manager->Package Manager Settings, go to Package sources, add a new package source with the URL above. (See below for screenshots of a similar process)
  2. Install the LinphoneSDK.Windows package from that new source
    nuget install LinphoneSDK.Windows -Source "Linphone"

You will then be able to update the package as you do for other NuGet packages.

From a local package source

It is still possible to download the NuGet package from our NuGet package registry, or build it from source code, and place it into a local folder, and request Visual Studio to use this folder as a source of Nuget packages.

Go to Tools->Nuget Package Manager->Package Manager Settings, go to Package sources, add a new package source to the folder.

packagesources.png

After this go to Tools->Nuget Package Manager->Manage Nuget Packages for solution. Select the local source.

selectSource.png

Select the project which the sdk will be install.

installnuget.png

On updating, be careful to the version : If the version is the same as an old version (for example, it can happen when building your own package), you have to manually delete the folder in .nuget:
C:\Users\<UserName>\.nuget\packages\linphonesdk
Visual Studio try to use the cache before using the version inside the custom folder where you put your package.

Get Liblinphone Log in Visual Studio Output

To set the log in Liblinphone your need to call this:

Linphone.LoggingService.Instance.LogLevel = Linphone.LogLevel.Debug;
// Define a custom log handler
Linphone.LoggingService.Listener.OnLogMessageWritten = MyLogHandler;

(...)
/* define the log handler to write to console */
void MyLogHandler(LoggingService logService, string domain, LogLevel lev, string message){
/*...*/
}

Enabling mixed (native/managed) debugging

By default, the Visual Studio debugger will stop the application upon managed code errors, with convenient diagnosis displayed.

However, should a crash happen in the native code, it will be of no help. To troubleshoot issues with native code, the debugger has to be switched to mixed mode.

Go to the properties of your UWP project:

1506944770356-563.png

Select the "Mixed (Managed and Native)" option for the Debugger type.

1506944730498-818.png

Running under mixed debugger is extremely slow ! Do this only if you encounter a native crash. It is actually so slow that application is almost unusable, with audio and video totally garbled.

Application capabilities

Don't forget to set permissions for your applications, otherwise nothing will work as expected: no network access, no access to sound or video devices...

Open Package.appxmanifest:

1506947395922-745.png

Set the capabilities needed for your application:

1506947413617-757.png

More Help

Documentation : https://download.linphone.org/releases/docs/liblinphone/latest/cs/

Tutorials : https://gitlab.linphone.org/BC/public/tutorials/-/tree/dev/c%23/cs

A legacy demo application, not maintained : https://gitlab.linphone.org/BC/public/linphone-windows10/