Tutorial for LinphoneSDK x UWP - C#
193
uwp/cs/03_OutgoingCall/03_OutgoingCall.csproj
Normal file
@@ -0,0 +1,193 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
|
||||
<ProjectGuid>{59E85455-ACC8-4F02-8E80-AD3C91167AF9}</ProjectGuid>
|
||||
<OutputType>AppContainerExe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>_03_OutgoingCall</RootNamespace>
|
||||
<AssemblyName>03_OutgoingCall</AssemblyName>
|
||||
<DefaultLanguage>en-US</DefaultLanguage>
|
||||
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
|
||||
<TargetPlatformVersion Condition=" '$(TargetPlatformVersion)' == '' ">10.0.19041.0</TargetPlatformVersion>
|
||||
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
|
||||
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<WindowsXamlEnableOverview>true</WindowsXamlEnableOverview>
|
||||
<AppxPackageSigningEnabled>false</AppxPackageSigningEnabled>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||
<OutputPath>bin\x86\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\ARM\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>ARM</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM'">
|
||||
<OutputPath>bin\ARM\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>ARM</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM64'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\ARM64\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>ARM64</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM64'">
|
||||
<OutputPath>bin\ARM64\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>ARM64</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x64\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<OutputPath>bin\x64\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="App.xaml.cs">
|
||||
<DependentUpon>App.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Service\VideoService.cs" />
|
||||
<Compile Include="Views\CallsPage.xaml.cs">
|
||||
<DependentUpon>CallsPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Service\CoreService.cs" />
|
||||
<Compile Include="Views\LoginPage.xaml.cs">
|
||||
<DependentUpon>LoginPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Views\NavigationRoot.xaml.cs">
|
||||
<DependentUpon>NavigationRoot.xaml</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AppxManifest Include="Package.appxmanifest">
|
||||
<SubType>Designer</SubType>
|
||||
</AppxManifest>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Properties\Default.rd.xml" />
|
||||
<Content Include="Assets\LockScreenLogo.scale-200.png" />
|
||||
<Content Include="Assets\SplashScreen.scale-200.png" />
|
||||
<Content Include="Assets\Square150x150Logo.scale-200.png" />
|
||||
<Content Include="Assets\Square44x44Logo.scale-200.png" />
|
||||
<Content Include="Assets\Square44x44Logo.targetsize-24_altform-unplated.png" />
|
||||
<Content Include="Assets\StoreLogo.png" />
|
||||
<Content Include="Assets\Wide310x150Logo.scale-200.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ApplicationDefinition Include="App.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
<Page Include="Views\LoginPage.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="Views\CallsPage.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="Views\NavigationRoot.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ANGLE.WindowsStore">
|
||||
<Version>2.1.13</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="LinphoneSDK">
|
||||
<Version>5.1.0-alpha.56</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
|
||||
<Version>6.2.11</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Readme.md" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '14.0' ">
|
||||
<VisualStudioVersion>14.0</VisualStudioVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
5
uwp/cs/03_OutgoingCall/App.xaml
Normal file
@@ -0,0 +1,5 @@
|
||||
<Application
|
||||
x:Class="_03_OutgoingCall.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
</Application>
|
||||
129
uwp/cs/03_OutgoingCall/App.xaml.cs
Normal file
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
* Copyright (c) 2010-2020 Belledonne Communications SARL.
|
||||
*
|
||||
* This file is part of Linphone TutorialCS.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using _03_OutgoingCall.Service;
|
||||
using _03_OutgoingCall.Views;
|
||||
using Linphone;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
using Windows.ApplicationModel;
|
||||
using Windows.ApplicationModel.Activation;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
|
||||
namespace _03_OutgoingCall
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides application-specific behavior to supplement the default Application class.
|
||||
/// </summary>
|
||||
sealed partial class App : Application
|
||||
{
|
||||
private CoreService CoreService { get; } = CoreService.Instance;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the singleton application object. This is the first line of authored code
|
||||
/// executed, and as such is the logical equivalent of main() or WinMain().
|
||||
/// </summary>
|
||||
public App()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
this.Suspending += OnSuspending;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when the application is launched normally by the end user. Other entry points
|
||||
/// will be used such as when the application is launched to open a specific file.
|
||||
/// </summary>
|
||||
/// <param name="e">Details about the launch request and process.</param>
|
||||
protected override void OnLaunched(LaunchActivatedEventArgs e)
|
||||
{
|
||||
Frame rootFrame = Window.Current.Content as Frame;
|
||||
|
||||
// Start Linphone
|
||||
LoggingService.Instance.LogLevel = LogLevel.Debug;
|
||||
LoggingService.Instance.Listener.OnLogMessageWritten = OnLog;
|
||||
|
||||
CoreService.CoreStart(Windows.ApplicationModel.Core.CoreApplication.GetCurrentView().CoreWindow.Dispatcher);
|
||||
|
||||
// Do not repeat app initialization when the Window already has content,
|
||||
// just ensure that the window is active
|
||||
if (rootFrame == null)
|
||||
{
|
||||
// Create a Frame to act as the navigation context and navigate to the first page
|
||||
rootFrame = new Frame();
|
||||
|
||||
rootFrame.NavigationFailed += OnNavigationFailed;
|
||||
|
||||
if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
|
||||
{
|
||||
//TODO: Load state from previously suspended application
|
||||
}
|
||||
|
||||
// Place the frame in the current Window
|
||||
Window.Current.Content = rootFrame;
|
||||
}
|
||||
|
||||
if (e.PrelaunchActivated == false)
|
||||
{
|
||||
if (rootFrame.Content == null)
|
||||
{
|
||||
// When the navigation stack isn't restored navigate to the first page,
|
||||
// configuring the new page by passing required information as a navigation
|
||||
// parameter
|
||||
rootFrame.Navigate(typeof(LoginPage), e.Arguments);
|
||||
}
|
||||
// Ensure the current window is active
|
||||
Window.Current.Activate();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnLog(LoggingService logService, string domain, LogLevel lev, string message)
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
_ = builder.Append("Linphone-[").Append(lev.ToString()).Append("](").Append(domain).Append(")").Append(message);
|
||||
Debug.WriteLine(builder.ToString());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when Navigation to a certain page fails
|
||||
/// </summary>
|
||||
/// <param name="sender">The Frame which failed navigation</param>
|
||||
/// <param name="e">Details about the navigation failure</param>
|
||||
private void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
|
||||
{
|
||||
throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when application execution is being suspended. Application state is saved
|
||||
/// without knowing whether the application will be terminated or resumed with the contents
|
||||
/// of memory still intact.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the suspend request.</param>
|
||||
/// <param name="e">Details about the suspend request.</param>
|
||||
private void OnSuspending(object sender, SuspendingEventArgs e)
|
||||
{
|
||||
var deferral = e.SuspendingOperation.GetDeferral();
|
||||
//TODO: Save application state and stop any background activity
|
||||
deferral.Complete();
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
uwp/cs/03_OutgoingCall/Assets/LockScreenLogo.scale-200.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
uwp/cs/03_OutgoingCall/Assets/SplashScreen.scale-200.png
Normal file
|
After Width: | Height: | Size: 7.5 KiB |
BIN
uwp/cs/03_OutgoingCall/Assets/Square150x150Logo.scale-200.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
uwp/cs/03_OutgoingCall/Assets/Square44x44Logo.scale-200.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
BIN
uwp/cs/03_OutgoingCall/Assets/StoreLogo.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
uwp/cs/03_OutgoingCall/Assets/Wide310x150Logo.scale-200.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
60
uwp/cs/03_OutgoingCall/Package.appxmanifest
Normal file
@@ -0,0 +1,60 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<Package
|
||||
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
|
||||
xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
|
||||
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
|
||||
xmlns:uap7="http://schemas.microsoft.com/appx/manifest/uap/windows10/7"
|
||||
xmlns:uap8="http://schemas.microsoft.com/appx/manifest/uap/windows10/8"
|
||||
IgnorableNamespaces="uap mp uap7 uap8">
|
||||
|
||||
<Identity
|
||||
Name="754c9d43-0820-475a-b433-8a1be86b241c"
|
||||
Publisher="CN=Anthony"
|
||||
Version="1.0.0.0" />
|
||||
|
||||
<mp:PhoneIdentity PhoneProductId="754c9d43-0820-475a-b433-8a1be86b241c" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>
|
||||
|
||||
<Properties>
|
||||
<DisplayName>03_OutgoingCall</DisplayName>
|
||||
<PublisherDisplayName>Anthony</PublisherDisplayName>
|
||||
<Logo>Assets\StoreLogo.png</Logo>
|
||||
</Properties>
|
||||
|
||||
<Dependencies>
|
||||
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />
|
||||
</Dependencies>
|
||||
|
||||
<Resources>
|
||||
<Resource Language="x-generate"/>
|
||||
</Resources>
|
||||
|
||||
<Applications>
|
||||
<Application Id="App"
|
||||
Executable="$targetnametoken$.exe"
|
||||
EntryPoint="_03_OutgoingCall.App">
|
||||
<uap:VisualElements
|
||||
DisplayName="03_OutgoingCall"
|
||||
Square150x150Logo="Assets\Square150x150Logo.png"
|
||||
Square44x44Logo="Assets\Square44x44Logo.png"
|
||||
Description="03_OutgoingCall"
|
||||
BackgroundColor="transparent">
|
||||
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png"/>
|
||||
<uap:SplashScreen Image="Assets\SplashScreen.png" />
|
||||
</uap:VisualElements>
|
||||
<uap7:Properties>
|
||||
<uap8:ActiveCodePage>UTF-8</uap8:ActiveCodePage>
|
||||
</uap7:Properties>
|
||||
</Application>
|
||||
</Applications>
|
||||
|
||||
<Capabilities>
|
||||
<Capability Name="internetClient" />
|
||||
<uap:Capability Name="voipCall"/>
|
||||
<Capability Name="codeGeneration"/>
|
||||
<uap:Capability Name="picturesLibrary"/>
|
||||
<uap:Capability Name="removableStorage"/>
|
||||
<DeviceCapability Name="microphone"/>
|
||||
<DeviceCapability Name="webcam"/>
|
||||
</Capabilities>
|
||||
</Package>
|
||||
28
uwp/cs/03_OutgoingCall/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("03_OutgoingCall")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("03_OutgoingCall")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2020")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
[assembly: ComVisible(false)]
|
||||
28
uwp/cs/03_OutgoingCall/Properties/Default.rd.xml
Normal file
@@ -0,0 +1,28 @@
|
||||
<!--
|
||||
This file contains Runtime Directives used by .NET Native. The defaults here are suitable for most
|
||||
developers. However, you can modify these parameters to modify the behavior of the .NET Native
|
||||
optimizer.
|
||||
|
||||
Runtime Directives are documented at https://go.microsoft.com/fwlink/?LinkID=391919
|
||||
|
||||
To fully enable reflection for App1.MyClass and all of its public/private members
|
||||
<Type Name="App1.MyClass" Dynamic="Required All" />
|
||||
|
||||
To enable dynamic creation of the specific instantiation of AppClass<T> over System.Int32
|
||||
<TypeInstantiation Name="App1.AppClass" Arguments="System.Int32" Activate="Required Public" />
|
||||
|
||||
Using the Namespace directive to apply reflection policy to all the types in a particular namespace
|
||||
<Namespace Name="DataClasses.ViewModels" Serialize="All" />
|
||||
-->
|
||||
|
||||
<Directives xmlns="http://schemas.microsoft.com/netfx/2013/01/metadata">
|
||||
<Application>
|
||||
<!--
|
||||
An Assembly element with Name="*Application*" applies to all assemblies in
|
||||
the application package. The asterisks are not wildcards.
|
||||
-->
|
||||
<Assembly Name="*Application*" Dynamic="Required All" />
|
||||
|
||||
<!-- Add your application specific runtime directives here. -->
|
||||
</Application>
|
||||
</Directives>
|
||||
23
uwp/cs/03_OutgoingCall/Readme.md
Normal file
@@ -0,0 +1,23 @@
|
||||
Linphone X UWP tutorial 03_OutgoingCall
|
||||
========================================
|
||||
|
||||
This time we are going to make our first video calls.
|
||||
|
||||
New/updated files :
|
||||
|
||||
```
|
||||
03_OutgoingCall
|
||||
│ Package.appxmanifest : For this step we added a new capability : Webcam.
|
||||
│
|
||||
└───Service :
|
||||
│ │ CoreService.cs : A singleton service which contains the Linphone.Core.
|
||||
│ │ Now updated with the ability to make video calls.
|
||||
│ │
|
||||
│ │ VideoService.cs : A singleton service which contains the code to render the video call
|
||||
│ │ on SwapChainPanel, using OpenGL.
|
||||
│
|
||||
│
|
||||
└───Views :
|
||||
│ │ CallsPage.xaml(.cs) : This is the page where you can make calls.
|
||||
│ │ This is where you will find the new Linphone's uses.
|
||||
```
|
||||
242
uwp/cs/03_OutgoingCall/Service/CoreService.cs
Normal file
@@ -0,0 +1,242 @@
|
||||
/*
|
||||
* Copyright (c) 2010-2020 Belledonne Communications SARL.
|
||||
*
|
||||
* This file is part of Linphone TutorialCS.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using Linphone;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Windows.Media.Audio;
|
||||
using Windows.Media.Capture;
|
||||
using Windows.Storage;
|
||||
using Windows.UI.Core;
|
||||
using static Linphone.CoreListener;
|
||||
|
||||
namespace _03_OutgoingCall.Service
|
||||
{
|
||||
internal class CoreService
|
||||
{
|
||||
private Timer Timer;
|
||||
|
||||
private static readonly CoreService instance = new CoreService();
|
||||
|
||||
public static CoreService Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
||||
private Core core;
|
||||
|
||||
public Core Core
|
||||
{
|
||||
get
|
||||
{
|
||||
if (core == null)
|
||||
{
|
||||
Factory factory = Factory.Instance;
|
||||
|
||||
string assetsPath = Path.Combine(Windows.ApplicationModel.Package.Current.InstalledLocation.Path, "share");
|
||||
factory.TopResourcesDir = assetsPath;
|
||||
factory.DataResourcesDir = assetsPath;
|
||||
factory.SoundResourcesDir = Path.Combine(assetsPath, "sounds", "linphone");
|
||||
factory.RingResourcesDir = Path.Combine(factory.SoundResourcesDir, "rings");
|
||||
factory.ImageResourcesDir = Path.Combine(assetsPath, "images");
|
||||
factory.MspluginsDir = ".";
|
||||
|
||||
core = factory.CreateCore("", "", IntPtr.Zero);
|
||||
|
||||
core.AudioPort = 7666;
|
||||
core.VideoPort = 9666;
|
||||
|
||||
core.RootCa = Path.Combine(Windows.ApplicationModel.Package.Current.InstalledLocation.Path, "share", "Linphone", "rootca.pem");
|
||||
core.UserCertificatesPath = ApplicationData.Current.LocalFolder.Path;
|
||||
|
||||
VideoActivationPolicy videoActivationPolicy = factory.CreateVideoActivationPolicy();
|
||||
videoActivationPolicy.AutomaticallyAccept = true;
|
||||
videoActivationPolicy.AutomaticallyInitiate = false;
|
||||
core.VideoActivationPolicy = videoActivationPolicy;
|
||||
|
||||
if (core.VideoSupported())
|
||||
{
|
||||
core.VideoCaptureEnabled = true;
|
||||
}
|
||||
core.UsePreviewWindow(true);
|
||||
}
|
||||
return core;
|
||||
}
|
||||
}
|
||||
|
||||
public void CoreStart(CoreDispatcher dispatcher)
|
||||
{
|
||||
Core.Start();
|
||||
|
||||
Timer = new Timer(OnTimedEvent, dispatcher, 20, 20);
|
||||
}
|
||||
|
||||
private async void OnTimedEvent(object state)
|
||||
{
|
||||
await ((CoreDispatcher)state).RunIdleAsync((args) =>
|
||||
{
|
||||
Core.Iterate();
|
||||
});
|
||||
}
|
||||
|
||||
public void AddOnAccountRegistrationStateChangedDelegate(OnAccountRegistrationStateChangedDelegate myDelegate)
|
||||
{
|
||||
Core.Listener.OnAccountRegistrationStateChanged += myDelegate;
|
||||
}
|
||||
|
||||
public void RemoveOnAccountRegistrationStateChangedDelegate(OnAccountRegistrationStateChangedDelegate myDelegate)
|
||||
{
|
||||
Core.Listener.OnAccountRegistrationStateChanged -= myDelegate;
|
||||
}
|
||||
|
||||
public void AddOnCallStateChangedDelegate(OnCallStateChangedDelegate myDelegate)
|
||||
{
|
||||
Core.Listener.OnCallStateChanged += myDelegate;
|
||||
}
|
||||
|
||||
public void RemoveOnCallStateChangedDelegate(OnCallStateChangedDelegate myDelegate)
|
||||
{
|
||||
Core.Listener.OnCallStateChanged -= myDelegate;
|
||||
}
|
||||
|
||||
public void LogIn(string identity, string password)
|
||||
{
|
||||
Address address = Factory.Instance.CreateAddress(identity);
|
||||
AuthInfo authInfo = Factory.Instance.CreateAuthInfo(address.Username, "", password, "", "", address.Domain);
|
||||
Core.AddAuthInfo(authInfo);
|
||||
|
||||
AccountParams accountParams = Core.CreateAccountParams();
|
||||
accountParams.IdentityAddress = address;
|
||||
string serverAddr = "sip:" + address.Domain + ";transport=tls";
|
||||
accountParams.ServerAddr = serverAddr;
|
||||
|
||||
accountParams.RegisterEnabled = true;
|
||||
|
||||
Account account = Core.CreateAccount(accountParams);
|
||||
Core.AddAccount(account);
|
||||
Core.DefaultAccount = account;
|
||||
}
|
||||
|
||||
public void LogOut()
|
||||
{
|
||||
Account account = Core.DefaultAccount;
|
||||
if (account != null)
|
||||
{
|
||||
AccountParams accountParams = account.Params.Clone();
|
||||
accountParams.RegisterEnabled = false;
|
||||
account.Params = accountParams;
|
||||
}
|
||||
}
|
||||
|
||||
public void ClearCoreAfterLogOut()
|
||||
{
|
||||
Core.ClearAllAuthInfo();
|
||||
Core.ClearAccounts();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Make a call.
|
||||
/// </summary>
|
||||
public async void Call(string uriToCall)
|
||||
{
|
||||
// We call this method to pop the microphone permission window.
|
||||
// If the permission was already granted for this app, no pop up
|
||||
// appears.
|
||||
await OpenMicrophonePopup();
|
||||
|
||||
// We create an Address object from the URI.
|
||||
// This method can create an SIP Address from a username
|
||||
// or phone number only.
|
||||
Address address = Core.InterpretUrl(uriToCall);
|
||||
|
||||
// Initiate an outgoing call to the given destination Address.
|
||||
Core.InviteAddress(address);
|
||||
}
|
||||
|
||||
public bool MicEnabledSwitch()
|
||||
{
|
||||
return Core.MicEnabled = !Core.MicEnabled;
|
||||
}
|
||||
|
||||
public bool SpeakerMutedSwitch()
|
||||
{
|
||||
return Core.CurrentCall.SpeakerMuted = !Core.CurrentCall.SpeakerMuted;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ask the peer of the current call to enable/disable the video call.
|
||||
/// </summary>
|
||||
public async Task<bool> CameraEnabledSwitchAsync()
|
||||
{
|
||||
// We call this method to pop up the webcam permission window.
|
||||
// If the permission was already granted for this app, no pop up
|
||||
// appears.
|
||||
await OpenCameraPopup();
|
||||
|
||||
// Retrieving the current call
|
||||
Call call = Core.CurrentCall;
|
||||
|
||||
// Core.createCallParams(call) create CallParams matching the Call parameters,
|
||||
// here the current call. CallParams contains a variety of parameters like
|
||||
// audio bandwidth limit, media encryption type... And if the video is enable
|
||||
// or not.
|
||||
CallParams param = core.CreateCallParams(call);
|
||||
|
||||
// Switch the current VideoEnableValue
|
||||
bool newValue = !param.VideoEnabled;
|
||||
param.VideoEnabled = newValue;
|
||||
|
||||
// Try to update the call parameters with those new CallParams.
|
||||
// If the video switch from true to false the peer can't refuse to disable the video.
|
||||
// If the video switch from false to true and the peer don't have videoActivationPolicy.AutomaticallyAccept = true
|
||||
// you have to wait for him to accept the update. The Call status is "Updating" during this time.
|
||||
call.Update(param);
|
||||
|
||||
return newValue;
|
||||
}
|
||||
|
||||
private async Task OpenMicrophonePopup()
|
||||
{
|
||||
AudioGraphSettings settings = new AudioGraphSettings(Windows.Media.Render.AudioRenderCategory.Media);
|
||||
CreateAudioGraphResult result = await AudioGraph.CreateAsync(settings);
|
||||
AudioGraph audioGraph = result.Graph;
|
||||
|
||||
CreateAudioDeviceInputNodeResult resultNode = await audioGraph.CreateDeviceInputNodeAsync(Windows.Media.Capture.MediaCategory.Media);
|
||||
AudioDeviceInputNode deviceInputNode = resultNode.DeviceInputNode;
|
||||
|
||||
deviceInputNode.Dispose();
|
||||
audioGraph.Dispose();
|
||||
}
|
||||
|
||||
private async Task OpenCameraPopup()
|
||||
{
|
||||
MediaCapture mediaCapture = new Windows.Media.Capture.MediaCapture();
|
||||
await mediaCapture.InitializeAsync(new MediaCaptureInitializationSettings
|
||||
{
|
||||
StreamingCaptureMode = StreamingCaptureMode.Video
|
||||
});
|
||||
mediaCapture.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
56
uwp/cs/03_OutgoingCall/Service/VideoService.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (c) 2010-2020 Belledonne Communications SARL.
|
||||
*
|
||||
* This file is part of Linphone TutorialCS.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using Windows.UI.Xaml.Controls;
|
||||
|
||||
namespace _03_OutgoingCall.Service
|
||||
{
|
||||
internal class VideoService
|
||||
{
|
||||
private static readonly VideoService instance = new VideoService();
|
||||
|
||||
public static VideoService Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
||||
private CoreService CoreService { get; } = CoreService.Instance;
|
||||
|
||||
/// <summary>
|
||||
/// When you want to start the video rendering you need to link the SwapChainPanel surface to Linphone.
|
||||
/// Core.NativePreviewWindowId for the preview surface and Core.CurrentCall.NativeVideoWindowId for the
|
||||
/// remote webcam surface.
|
||||
/// Simply doing this allow Linphone to render your preview and the remote camera if they are available.
|
||||
/// </summary>
|
||||
public void StartVideoStream(SwapChainPanel main, SwapChainPanel preview)
|
||||
{
|
||||
CoreService.Core.NativePreviewWindowId = preview;
|
||||
CoreService.Core.NativeVideoWindowId = main;
|
||||
}
|
||||
|
||||
public void StopVideoStream()
|
||||
{
|
||||
CoreService.Core.NativePreviewWindowId = null;
|
||||
CoreService.Core.NativeVideoWindowId = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
72
uwp/cs/03_OutgoingCall/Views/CallsPage.xaml
Normal file
@@ -0,0 +1,72 @@
|
||||
<Page
|
||||
x:Class="_03_OutgoingCall.Views.CallsPage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
||||
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Border Grid.Row="0" Background="{ThemeResource SystemAccentColorLight3}" Padding="10">
|
||||
<TextBlock x:Name="HelloText" HorizontalAlignment="Center" VerticalAlignment="Center" Style="{ThemeResource HeaderTextBlockStyle}" Text="Hello " />
|
||||
</Border>
|
||||
|
||||
<Grid Grid.Row="1">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="auto" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<StackPanel Grid.Row="0" VerticalAlignment="Center" Margin="20">
|
||||
<StackPanel Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<TextBlock Text="URI to call : " />
|
||||
<TextBox x:Name="UriToCall" Width="350" MinWidth="350" MaxWidth="350" Text="sip:" />
|
||||
</StackPanel>
|
||||
|
||||
<Button x:Name="CallButton" Content="Call" Click="CallClick" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="5" />
|
||||
|
||||
<TextBlock x:Name="CallText" Text="Your call state is : Idle" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="10" />
|
||||
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="10">
|
||||
<Button x:Name="HangOut" Content="Hang out" Click="HangOutClick" IsEnabled="False" />
|
||||
<Button x:Name="Sound" Content="Switch off Sound" Click="SoundClick" IsEnabled="False" />
|
||||
<Button x:Name="Camera" Content="Switch on Camera" Click="CameraClick" IsEnabled="False" />
|
||||
<Button x:Name="Mic" Content="Mute" Click="MicClick" IsEnabled="False" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
|
||||
<Grid Grid.Row="1" x:Name="VideoGrid" Canvas.ZIndex="-1" Background="Black" Visibility="Collapsed">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<SwapChainPanel x:Name="VideoSwapChainPanel" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2" Grid.RowSpan="3" />
|
||||
|
||||
<SwapChainPanel x:Name="PreviewSwapChainPanel" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Column="2" Grid.Row="0" Grid.RowSpan="3">
|
||||
</SwapChainPanel>
|
||||
</Grid>
|
||||
|
||||
<StackPanel Grid.Row="2" x:Name="IncomingCallStackPanel" Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center" Visibility="Collapsed" Margin="10">
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<TextBlock Text="You have a call from :" />
|
||||
<TextBlock x:Name="IncommingCallText" Text="" />
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<Button x:Name="Answer" Content="Answer" Click="AnswerClick" />
|
||||
<Button x:Name="Decline" Content="Decline" Click="DeclineClick" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Page>
|
||||
232
uwp/cs/03_OutgoingCall/Views/CallsPage.xaml.cs
Normal file
@@ -0,0 +1,232 @@
|
||||
/*
|
||||
* Copyright (c) 2010-2020 Belledonne Communications SARL.
|
||||
*
|
||||
* This file is part of Linphone TutorialCS.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using _03_OutgoingCall.Service;
|
||||
using Linphone;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
|
||||
namespace _03_OutgoingCall.Views
|
||||
{
|
||||
public sealed partial class CallsPage : Page
|
||||
{
|
||||
private CoreService CoreService { get; } = CoreService.Instance;
|
||||
|
||||
private VideoService VideoService { get; } = VideoService.Instance;
|
||||
|
||||
private Call IncommingCall;
|
||||
|
||||
public CallsPage()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// We just stop the video rendering when we leave the page.
|
||||
/// Details about the video rendering implementation are in Service/VideoService.cs
|
||||
/// </summary>
|
||||
protected override void OnNavigatedFrom(NavigationEventArgs e)
|
||||
{
|
||||
VideoService.StopVideoStream();
|
||||
CoreService.RemoveOnCallStateChangedDelegate(OnCallStateChanged);
|
||||
base.OnNavigatedFrom(e);
|
||||
}
|
||||
|
||||
protected override void OnNavigatedTo(NavigationEventArgs e)
|
||||
{
|
||||
base.OnNavigatedTo(e);
|
||||
|
||||
HelloText.Text += CoreService.Core.DefaultProxyConfig.FindAuthInfo().Username;
|
||||
CoreService.AddOnCallStateChangedDelegate(OnCallStateChanged);
|
||||
|
||||
if (CoreService.Core.CurrentCall != null)
|
||||
{
|
||||
OnCallStateChanged(CoreService.Core, CoreService.Core.CurrentCall, CoreService.Core.CurrentCall.State, null);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method called when the "Call" button is clicked, see CoreService.Call
|
||||
/// to learn how to make a call.
|
||||
/// </summary>
|
||||
private void CallClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
CoreService.Call(UriToCall.Text);
|
||||
}
|
||||
|
||||
private void HangOutClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
CoreService.Core.TerminateAllCalls();
|
||||
}
|
||||
|
||||
private void SoundClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (CoreService.SpeakerMutedSwitch())
|
||||
{
|
||||
Sound.Content = "Switch on Sound";
|
||||
}
|
||||
else
|
||||
{
|
||||
Sound.Content = "Switch off Sound";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method to turn on/off the video call.
|
||||
/// Watch CoreService.CameraEnabledSwitchAsync for more info.
|
||||
/// </summary>
|
||||
private async void CameraClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
await CoreService.CameraEnabledSwitchAsync();
|
||||
|
||||
// After CoreService.CameraEnabledSwitchAsync the Call state is "Updating".
|
||||
// We wait for the return of the "StreamsRunning" state to update the GUI
|
||||
// according to the final consensus between callers.
|
||||
Camera.Content = "Waiting for accept ...";
|
||||
Camera.IsEnabled = false;
|
||||
}
|
||||
|
||||
private void MicClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (CoreService.MicEnabledSwitch())
|
||||
{
|
||||
Mic.Content = "Mute";
|
||||
}
|
||||
else
|
||||
{
|
||||
Mic.Content = "Unmute";
|
||||
}
|
||||
}
|
||||
|
||||
private void OnCallStateChanged(Core core, Call call, CallState state, string message)
|
||||
{
|
||||
CallText.Text = "Your call state is : " + state.ToString();
|
||||
switch (state)
|
||||
{
|
||||
case CallState.IncomingReceived:
|
||||
IncommingCall = call;
|
||||
IncomingCallStackPanel.Visibility = Visibility.Visible;
|
||||
IncommingCallText.Text = " " + IncommingCall.RemoteAddress.AsString();
|
||||
|
||||
break;
|
||||
|
||||
case CallState.OutgoingInit:
|
||||
case CallState.OutgoingProgress:
|
||||
case CallState.OutgoingRinging:
|
||||
// Different states you go through when you start a call and before your peer answer.
|
||||
HangOut.IsEnabled = true;
|
||||
break;
|
||||
|
||||
case CallState.StreamsRunning:
|
||||
case CallState.UpdatedByRemote:
|
||||
// The StreamsRunning state is the default one during a call.
|
||||
// The UpdatedByRemote is triggered when the call's parameters are updated
|
||||
// for example when video is asked/removed by remote.
|
||||
|
||||
CallInProgressGuiUpdates();
|
||||
if (call.CurrentParams.VideoEnabled)
|
||||
{
|
||||
StartVideoAndUpdateGui();
|
||||
}
|
||||
else
|
||||
{
|
||||
StopVideoAndUpdateGui();
|
||||
}
|
||||
break;
|
||||
|
||||
case CallState.Error:
|
||||
case CallState.End:
|
||||
case CallState.Released:
|
||||
IncommingCall = null;
|
||||
EndingCallGuiUpdates();
|
||||
VideoService.StopVideoStream();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void AnswerClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (IncommingCall != null)
|
||||
{
|
||||
IncommingCall.Accept();
|
||||
IncommingCall = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void DeclineClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (IncommingCall != null)
|
||||
{
|
||||
IncommingCall.Decline(Reason.Declined);
|
||||
IncommingCall = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method to hide the webcam grid and stop the of the rendering remote and preview webcam.
|
||||
/// Watch VideoService and more specifically VideoService.StopVideoStream.
|
||||
/// </summary>
|
||||
private void StopVideoAndUpdateGui()
|
||||
{
|
||||
Camera.Content = "Switch on Camera";
|
||||
Camera.IsEnabled = true;
|
||||
VideoGrid.Visibility = Visibility.Collapsed;
|
||||
VideoService.StopVideoStream();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method to show the webcam grid and start rendering remote and preview webcam.
|
||||
/// Watch VideoService and more specifically VideoService.StartVideoStream to
|
||||
/// understand how to start the rendering on a SwapChainPanel.
|
||||
/// </summary>
|
||||
private void StartVideoAndUpdateGui()
|
||||
{
|
||||
VideoGrid.Visibility = Visibility.Visible;
|
||||
Camera.Content = "Switch off Camera";
|
||||
VideoService.StartVideoStream(VideoSwapChainPanel, PreviewSwapChainPanel);
|
||||
Camera.IsEnabled = true;
|
||||
}
|
||||
|
||||
private void EndingCallGuiUpdates()
|
||||
{
|
||||
IncomingCallStackPanel.Visibility = Visibility.Collapsed;
|
||||
CallButton.IsEnabled = true;
|
||||
HangOut.IsEnabled = false;
|
||||
Sound.IsEnabled = false;
|
||||
Camera.IsEnabled = false;
|
||||
Mic.IsEnabled = false;
|
||||
VideoGrid.Visibility = Visibility.Collapsed;
|
||||
Camera.Content = "Switch on Camera";
|
||||
Mic.Content = "Mute";
|
||||
Sound.Content = "Switch off Sound";
|
||||
}
|
||||
|
||||
private void CallInProgressGuiUpdates()
|
||||
{
|
||||
IncomingCallStackPanel.Visibility = Visibility.Collapsed;
|
||||
CallButton.IsEnabled = false;
|
||||
HangOut.IsEnabled = true;
|
||||
Sound.IsEnabled = true;
|
||||
Camera.IsEnabled = true;
|
||||
Mic.IsEnabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
34
uwp/cs/03_OutgoingCall/Views/LoginPage.xaml
Normal file
@@ -0,0 +1,34 @@
|
||||
<Page
|
||||
x:Class="_03_OutgoingCall.Views.LoginPage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
|
||||
<Grid KeyUp="GridKeyUp">
|
||||
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="0.15*" />
|
||||
<RowDefinition Height="0.85*" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Border Grid.Row="0" Background="{ThemeResource SystemAccentColorLight3}">
|
||||
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Style="{ThemeResource HeaderTextBlockStyle}" Text="Login Form" />
|
||||
</Border>
|
||||
|
||||
<StackPanel Grid.Row="1" VerticalAlignment="Center">
|
||||
|
||||
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Orientation="Vertical">
|
||||
<TextBlock Text="Identity :" />
|
||||
<TextBox x:Name="Identity" Width="350" MinWidth="350" MaxWidth="350" Text="sip:" />
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Margin="0,10,0,0" HorizontalAlignment="Center" VerticalAlignment="Center" Orientation="Vertical">
|
||||
<TextBlock Text="Password :" />
|
||||
<PasswordBox x:Name="Password" Width="350" MinWidth="350" MaxWidth="350" PlaceholderText="myPasswd" />
|
||||
</StackPanel>
|
||||
|
||||
<Button x:Name="LogIn" Click="LogInClick" Content="Login" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,10,0,0" />
|
||||
|
||||
<TextBlock x:Name="RegistrationText" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,10,0,0" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Page>
|
||||
112
uwp/cs/03_OutgoingCall/Views/LoginPage.xaml.cs
Normal file
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
* Copyright (c) 2010-2020 Belledonne Communications SARL.
|
||||
*
|
||||
* This file is part of Linphone TutorialCS.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using _03_OutgoingCall.Service;
|
||||
using Linphone;
|
||||
using Windows.System;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Input;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
|
||||
namespace _03_OutgoingCall.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// A really simple app for a first Login with LinphoneSDK x UWP
|
||||
/// </summary>
|
||||
public sealed partial class LoginPage : Page
|
||||
{
|
||||
private CoreService CoreService { get; } = CoreService.Instance;
|
||||
|
||||
public LoginPage()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
|
||||
protected override void OnNavigatedTo(NavigationEventArgs e)
|
||||
{
|
||||
base.OnNavigatedTo(e);
|
||||
CoreService.AddOnAccountRegistrationStateChangedDelegate(OnAccountRegistrationStateChanged);
|
||||
}
|
||||
|
||||
protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
|
||||
{
|
||||
CoreService.RemoveOnAccountRegistrationStateChangedDelegate(OnAccountRegistrationStateChanged);
|
||||
base.OnNavigatingFrom(e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when you click on the "Login" button.
|
||||
/// </summary>
|
||||
private void LogInClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (LogIn.IsEnabled)
|
||||
{
|
||||
LogIn.IsEnabled = false;
|
||||
|
||||
CoreService.LogIn(Identity.Text, Password.Password);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when a key is pressed and released on the login page.
|
||||
/// If you pressed "Enter", simulate a login click.
|
||||
/// </summary>
|
||||
private void GridKeyUp(object sender, KeyRoutedEventArgs e)
|
||||
{
|
||||
if (VirtualKey.Enter.Equals(e.Key))
|
||||
{
|
||||
LogInClick(null, null);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This method is called every time the RegistrationState is updated by background core's actions.
|
||||
/// In this example we use this to update the GUI.
|
||||
/// </summary>
|
||||
private void OnAccountRegistrationStateChanged(Core core, Account account, RegistrationState state, string message)
|
||||
{
|
||||
RegistrationText.Text = "Your registration state is : " + state.ToString();
|
||||
switch (state)
|
||||
{
|
||||
case RegistrationState.Cleared:
|
||||
case RegistrationState.None:
|
||||
CoreService.ClearCoreAfterLogOut();
|
||||
LogIn.IsEnabled = true;
|
||||
break;
|
||||
|
||||
case RegistrationState.Ok:
|
||||
LogIn.IsEnabled = false;
|
||||
this.Frame.Navigate(typeof(NavigationRoot));
|
||||
break;
|
||||
|
||||
case RegistrationState.Progress:
|
||||
LogIn.IsEnabled = false;
|
||||
break;
|
||||
|
||||
case RegistrationState.Failed:
|
||||
LogIn.IsEnabled = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
32
uwp/cs/03_OutgoingCall/Views/NavigationRoot.xaml
Normal file
@@ -0,0 +1,32 @@
|
||||
<Page
|
||||
x:Class="_03_OutgoingCall.Views.NavigationRoot"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Loaded="Page_Loaded">
|
||||
|
||||
<Grid x:Name="NavRootGrid" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
||||
|
||||
<NavigationView
|
||||
x:Name="navview"
|
||||
AlwaysShowHeader="False"
|
||||
ItemInvoked="Navview_ItemInvoked"
|
||||
PaneDisplayMode="Top"
|
||||
IsBackButtonVisible="Collapsed">
|
||||
<NavigationView.MenuItems>
|
||||
<NavigationViewItem Content="Calls" IsSelected="True">
|
||||
<NavigationViewItem.Icon>
|
||||
<FontIcon FontFamily="Segoe MDL2 Assets" Glyph="" />
|
||||
</NavigationViewItem.Icon>
|
||||
</NavigationViewItem>
|
||||
</NavigationView.MenuItems>
|
||||
<NavigationView.PaneFooter>
|
||||
<NavigationViewItem Content="Sign out" Tapped="SignOut_Tapped">
|
||||
<NavigationViewItem.Icon>
|
||||
<FontIcon FontFamily="Segoe MDL2 Assets" Glyph="" />
|
||||
</NavigationViewItem.Icon>
|
||||
</NavigationViewItem>
|
||||
</NavigationView.PaneFooter>
|
||||
<Frame x:Name="AppNavFrame" Navigated="AppNavFrame_Navigated" />
|
||||
</NavigationView>
|
||||
</Grid>
|
||||
</Page>
|
||||
109
uwp/cs/03_OutgoingCall/Views/NavigationRoot.xaml.cs
Normal file
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* Copyright (c) 2010-2020 Belledonne Communications SARL.
|
||||
*
|
||||
* This file is part of Linphone TutorialCS.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using _03_OutgoingCall.Service;
|
||||
using System;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Input;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
|
||||
namespace _03_OutgoingCall.Views
|
||||
{
|
||||
public sealed partial class NavigationRoot : Page
|
||||
{
|
||||
private CoreService CoreService { get; } = CoreService.Instance;
|
||||
private bool hasLoadedPreviously;
|
||||
|
||||
public NavigationRoot()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
|
||||
private void Page_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// Only do an inital navigate the first time the page loads
|
||||
// when we switch out of compactoverloadmode this will fire but we don't want to navigate because
|
||||
// there is already a page loaded
|
||||
if (!hasLoadedPreviously)
|
||||
{
|
||||
AppNavFrame.Navigate(typeof(CallsPage));
|
||||
hasLoadedPreviously = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void AppNavFrame_Navigated(object sender, NavigationEventArgs e)
|
||||
{
|
||||
switch (e.SourcePageType)
|
||||
{
|
||||
case Type c when e.SourcePageType == typeof(CallsPage):
|
||||
((NavigationViewItem)navview.MenuItems[0]).IsSelected = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private async void Navview_ItemInvoked(NavigationView sender, NavigationViewItemInvokedEventArgs args)
|
||||
{
|
||||
if (args.IsSettingsInvoked)
|
||||
{
|
||||
ContentDialog noSettingsDialog = new ContentDialog
|
||||
{
|
||||
Title = "No settings",
|
||||
Content = "There is no settings in this little app",
|
||||
CloseButtonText = "OK"
|
||||
};
|
||||
|
||||
ContentDialogResult result = await noSettingsDialog.ShowAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
string invokedItemValue = args.InvokedItem as string;
|
||||
if (invokedItemValue != null && invokedItemValue.Contains("Calls"))
|
||||
{
|
||||
AppNavFrame.Navigate(typeof(CallsPage));
|
||||
}
|
||||
}
|
||||
|
||||
private void SignOut_Tapped(object sender, TappedRoutedEventArgs e)
|
||||
{
|
||||
DisplaySignOutDialog();
|
||||
}
|
||||
|
||||
private async void DisplaySignOutDialog()
|
||||
{
|
||||
ContentDialog signOutDialog = new ContentDialog
|
||||
{
|
||||
Title = "Sign out ?",
|
||||
Content = "All your current calls and actions will be canceled, are you sure to continue ?",
|
||||
PrimaryButtonText = "Sign out",
|
||||
CloseButtonText = "Cancel"
|
||||
};
|
||||
|
||||
ContentDialogResult result = await signOutDialog.ShowAsync();
|
||||
|
||||
if (result == ContentDialogResult.Primary)
|
||||
{
|
||||
CoreService.Core.TerminateAllCalls();
|
||||
CoreService.LogOut();
|
||||
|
||||
this.Frame.Navigate(typeof(LoginPage));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||