Windows UWP with linphone-sdk

You can get pre-built UWP packages from :
- https://www.linphone.org/snapshots/windows/sdk/
- https://www.linphone.org/releases/windows/sdk/ (only available when 5.0 will be out)

Or you can build yourself from the source:
- https://gitlab.linphone.org/BC/public/linphone-sdk

The Nuget package supports 3 frameworks:

  • - netcore (WindowsStore-32bits)
  • - netcore45 (Win32-32bits)
  • - uap10.0 (UWP-64bits)

Some other frameworks are provided for convenience but wasn'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/windows/nuget/LinphoneSDK.nuspec.in' by adding your item in 'dependencies' section:
<group targetFramework="<your target framework>" />

Install local nuget package

Download the nuget package and place it in the folder of your choice

In Visual Studio with your project, 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;

After this, 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

Application capabilities

Don't forget to set permission for your applications.

Open Package.appxmanifest:

1506947395922-745.png

Set the capabilities needed for your application:

1506947413617-757.png

More Help

Demo application : https://gitlab.linphone.org/BC/public/linphone-windows10/

Documentation : https://linphone.org/releases/docs/liblinphone/4.5/cs/api/Linphone.html

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

Windows UWP with Old Win32 linphone-sdk

This is working only with linphone SDK >= 4.0 and without the current nuget version (5.0)

The ability to create a Windows app package for your desktop application (otherwise known as the Desktop Bridge) was introduced in Windows 10, version 1607, and it can only be used in projects that target Windows 10 Anniversary Update (10.0; Build 14393) or a later release in Visual Studio.

https://docs.microsoft.com/en-us/windows/uwp/porting/desktop-to-uwp-root

Create the desktop project for UWP

Just follow steps here: https://docs.microsoft.com/en-us/windows/uwp/porting/desktop-to-uwp-packaging-dot-net

Resources to be embedded in application

liblinphone does requires 2 resources files from the nuget paquet to be embedded in the application.

<Content Include="Assets\belr\grammars\cpim_grammar">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Assets\belr\grammars\vcard_grammar">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>

Display video

You need to clone the repository "mswinrtvid" add to your project visual studio the project ./mswinrtvid/MSWinRTVideo.vcxproj
Reference MSWinRTVideo in your project. This project will add a new UI form "SwapChainPanel"
Add in your "Package.appxmanifest":

<Package>
...
<Extensions>
<Extension Category="windows.activatableClass.inProcessServer">
<InProcessServer>
<Path>MSWinRTVideo.dll</Path>
<ActivatableClass ActivatableClassId="MSWinRTVideo.SchemeHandler" ThreadingModel="both" />
</InProcessServer>
</Extension>
</Extensions>
</Package>

Example:
View.xaml

<SwapChainPanel x:Name="VideoSwapChainPanel" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="3" Grid.RowSpan="3"/>
<SwapChainPanel x:Name="PreviewSwapChainPanel" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Column="2" Grid.Row="2" RenderTransformOrigin="0.5,0.5">
<SwapChainPanel.RenderTransform>
<CompositeTransform x:Name="PreviewRender" ScaleX="-1"/>
</SwapChainPanel.RenderTransform>
</SwapChainPanel>

View.xaml.cs

 private void StartVideoStream() {
           try {
               _videoSource = new MSWinRTVideo.SwapChainPanelSource();
               _videoSource.Start(VideoSwapChainPanel);
               _previewSource = new MSWinRTVideo.SwapChainPanelSource();
               _previewSource.Start(PreviewSwapChainPanel);

               LinphoneManager.Instance.Core.NativeVideoWindowIdString = VideoSwapChainPanel.Name;
               LinphoneManager.Instance.Core.NativePreviewWindowIdString = PreviewSwapChainPanel.Name;
            } catch (Exception e) {
               Debug.WriteLine(String.Format("StartVideoStream: Exception {0}", e.Message));
            }
        }

       private void StopVideoStream() {
           try {
               if (_videoSource != null) {
                   _videoSource.Stop();
                   _videoSource = null;
                }
               if (_previewSource != null) {
                   _previewSource.Stop();
                   _previewSource = null;
                }
            } catch (Exception e) {
               Debug.WriteLine(String.Format("StopVideoStream: Exception {0}", e.Message));
            }

        }
Tags:
Created by Erwan Croze on 2017/08/28 16:03