Commit 26adf17a authored by Ghislain MARY's avatar Ghislain MARY

Add voip call resources allocation and phone call background task to the tester for Windows 10.

parent d4ed7e0e
......@@ -30,7 +30,9 @@
<ClCompile Include="MS2TesterHost.cpp" />
</ItemGroup>
<ItemGroup>
<AppxManifest Include="..\Package.appxmanifest" />
<AppxManifest Include="..\Package.appxmanifest">
<SubType>Designer</SubType>
</AppxManifest>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\..\..\mswinrtvid\windows10\libmswinrtvid\libmswinrtvid.vcxproj">
......@@ -97,7 +99,7 @@
<DisableSpecificWarnings>28204</DisableSpecificWarnings>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<SubSystem>Windows</SubSystem>
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
</Link>
</ItemDefinitionGroup>
......
......@@ -4,6 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.ApplicationModel.AppService;
using Windows.ApplicationModel.Background;
namespace MS2TesterTasks
{
......@@ -63,6 +64,24 @@ namespace MS2TesterTasks
}
}
public static BackgroundTaskDeferral PhoneCallTaskDeferral
{
set
{
lock (_lock)
{
_phoneCallTaskDeferral = value;
}
}
get
{
lock (_lock)
{
return _phoneCallTaskDeferral;
}
}
}
public static void InitVideo()
{
......@@ -132,6 +151,7 @@ namespace MS2TesterTasks
private static Object _lock = new Object();
private static AppServiceRequest _appRequest = null;
private static AppServiceDeferral _appDeferral = null;
private static BackgroundTaskDeferral _phoneCallTaskDeferral = null;
private static BackgroundRequest _request = BackgroundRequest.InValid;
}
}
......@@ -111,18 +111,20 @@
<Compile Include="AppService.cs" />
<Compile Include="BackgroundOperation.cs" />
<Compile Include="CurrentOperation.cs" />
<Compile Include="PhoneCallTask.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\..\..\mswinrtvid\windows10\libmswinrtvid\libmswinrtvid.vcxproj">
<Project>{2d0e44c4-e51d-4911-b876-345d1e5e5209}</Project>
<Name>libmswinrtvid</Name>
</ProjectReference>
<ProjectReference Include="..\ms2-tester-runtime-component\ms2-tester-runtime-component.vcxproj">
<Project>{1d1b61e3-695e-4535-8f3f-b26e2cb0f342}</Project>
<Name>ms2-tester-runtime-component</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<SDKReference Include="WindowsMobile, Version=10.0.10240.0">
<Name>Windows Mobile Extensions for the UWP</Name>
</SDKReference>
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '14.0' ">
<VisualStudioVersion>14.0</VisualStudioVersion>
</PropertyGroup>
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.ApplicationModel.Background;
namespace MS2TesterTasks
{
public sealed class PhoneCallTask : IBackgroundTask
{
private BackgroundTaskDeferral mDeferral;
public void Run(IBackgroundTaskInstance taskInstance)
{
mDeferral = taskInstance.GetDeferral();
CurrentOperation.PhoneCallTaskDeferral = mDeferral;
taskInstance.Canceled += TaskInstance_Canceled;
}
private void TaskInstance_Canceled(IBackgroundTaskInstance sender, BackgroundTaskCancellationReason reason)
{
if (mDeferral != null)
{
mDeferral.Complete();
}
CurrentOperation.PhoneCallTaskDeferral = null;
}
}
}
......@@ -24,6 +24,12 @@
<uap:SplashScreen Image="Assets\SplashScreen.png" />
</uap:VisualElements>
<Extensions>
<uap:Extension Category="windows.voipCall"></uap:Extension>
<Extension Category="windows.backgroundTasks" EntryPoint="MS2TesterTasks.PhoneCallTask">
<BackgroundTasks ServerName="MS2TesterHost">
<Task Type="systemEvent" />
</BackgroundTasks>
</Extension>
<uap:Extension Category="windows.appService" EntryPoint="MS2TesterTasks.AppService">
<uap:AppService Name="MS2TesterTasks.AppService" ServerName="MS2TesterHost" />
</uap:Extension>
......@@ -35,14 +41,23 @@
</Applications>
<Capabilities>
<Capability Name="internetClient" />
<Capability Name="internetClientServer" />
<uap:Capability Name="voipCall" />
<DeviceCapability Name="microphone" />
<DeviceCapability Name="webcam" />
</Capabilities>
<Extensions>
<Extension Category="windows.activatableClass.outOfProcessServer">
<OutOfProcessServer ServerName="MS2TesterHost">
<Path>MS2TesterHost.exe</Path>
<Instancing>singleInstance</Instancing>
<ActivatableClass ActivatableClassId="MS2TesterHost.Dummy" />
</OutOfProcessServer>
</Extension>
<Extension Category="windows.activatableClass.inProcessServer">
<InProcessServer>
<Path>libmswinrtvid.dll</Path>
<ActivatableClass ActivatableClassId="libmswinrtvid.SchemeHandler" ThreadingModel="both"/>
<ActivatableClass ActivatableClassId="libmswinrtvid.SchemeHandler" ThreadingModel="both" />
</InProcessServer>
</Extension>
</Extensions>
......
......@@ -16,7 +16,6 @@
<ScrollViewer>
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
......@@ -66,14 +65,24 @@
<Button x:Name="ChangeCameraButton" Content="Change camera" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="8" Click="ChangeCameraButton_Click" IsEnabled="{Binding ElementName=VideoToggleButton, Path=IsChecked}"/>
</StackPanel>
</Grid>
<Grid Grid.Row="1" MaxHeight="320">
<Grid Grid.Row="1" Width="640" Height="480" HorizontalAlignment="Center" BorderBrush="Black" BorderThickness="2">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.5*"/>
<ColumnDefinition Width="0.5*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<SwapChainPanel x:Name="PreviewSwapChainPanel" Grid.Column="0"/>
<SwapChainPanel x:Name="VideoSwapChainPanel" Grid.Column="1"/>
<SwapChainPanel x:Name="VideoSwapChainPanel" Width="640" Height="480" Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="3" Grid.RowSpan="3"/>
<SwapChainPanel x:Name="PreviewSwapChainPanel" Width="160" Height="120" Grid.Column="2" Grid.Row="2" RenderTransformOrigin="0.5,0.5">
<SwapChainPanel.RenderTransform>
<CompositeTransform ScaleX="-1"/>
</SwapChainPanel.RenderTransform>
</SwapChainPanel>
</Grid>
</Grid>
</ScrollViewer>
......
......@@ -8,6 +8,7 @@ using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Threading.Tasks;
using Windows.ApplicationModel.Calls;
using Windows.Devices.Sensors;
using Windows.Foundation;
using Windows.Foundation.Collections;
......@@ -203,6 +204,12 @@ namespace ms2_tester
_videoSource.Start(VideoSwapChainPanel);
_previewSource = new libmswinrtvid.SwapChainPanelSource();
_previewSource.Start(PreviewSwapChainPanel);
var vcc = VoipCallCoordinator.GetDefault();
var entryPoint = typeof(PhoneCallTask).FullName;
var status = await vcc.ReserveCallResourcesAsync(entryPoint);
var capabilities = VoipPhoneCallMedia.Audio | VoipPhoneCallMedia.Video;
call = vcc.RequestNewOutgoingCall("FooContext", "FooContact", "MS2Tester", capabilities);
call.NotifyCallActive();
OperationResult result = await MS2TesterHelper.StartVideoStream(VideoSwapChainPanel.Name, PreviewSwapChainPanel.Name, camera, codec, videoSize, frameRate, bitRate);
if (result == OperationResult.Succeeded)
{
......@@ -237,6 +244,8 @@ namespace ms2_tester
{
Debug.WriteLine(String.Format("StopVideoStream: Exception {0}", e.Message));
}
call.NotifyCallEnded();
call = null;
}
private async void ChangeCamera(String camera)
......@@ -347,6 +356,7 @@ namespace ms2_tester
}
private VoipPhoneCall call;
private ApplicationViewOrientation displayOrientation;
private DisplayInformation displayInformation;
private SimpleOrientationSensor orientationSensor;
......
......@@ -164,12 +164,23 @@
<Project>{1d1b61e3-695e-4535-8f3f-b26e2cb0f342}</Project>
<Name>ms2-tester-runtime-component</Name>
</ProjectReference>
<ProjectReference Include="MS2TesterHost\MS2TesterHost.vcxproj">
<Project>{8a1a89b3-f2db-4428-a571-f0dff2e1eec1}</Project>
<Name>MS2TesterHost</Name>
</ProjectReference>
<ProjectReference Include="MS2TesterTasks\MS2TesterTasks.csproj">
<Project>{1ba81d48-5fc4-47fc-8a08-524c4b2859dd}</Project>
<Name>MS2TesterTasks</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup />
<ItemGroup>
<SDKReference Include="WindowsDesktop, Version=10.0.10240.0">
<Name>Windows Desktop Extensions for the UWP</Name>
</SDKReference>
<SDKReference Include="WindowsMobile, Version=10.0.10240.0">
<Name>Windows Mobile Extensions for the UWP</Name>
</SDKReference>
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '14.0' ">
<VisualStudioVersion>14.0</VisualStudioVersion>
</PropertyGroup>
......
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