Commit 2a5718d4 authored by Ghislain MARY's avatar Ghislain MARY

Add SwapChainPanel for video preview on Windows 10.

parent 1f21d2d2
......@@ -58,12 +58,13 @@ namespace ms2_tester.Helpers
return null;
}
public static async Task<OperationResult> StartVideoStream(String swapChainPanelName, String camera, String codec, String videoSize, UInt32 frameRate, UInt32 bitRate)
public static async Task<OperationResult> StartVideoStream(String videoSwapChainPanelName, String previewSwapChainPanelName, String camera, String codec, String videoSize, UInt32 frameRate, UInt32 bitRate)
{
AppServiceHelper appServiceHelper = new AppServiceHelper();
ValueSet message = new ValueSet();
message[StartVideoStreamArguments.SwapChainPanelName.ToString()] = swapChainPanelName;
message[StartVideoStreamArguments.VideoSwapChainPanelName.ToString()] = videoSwapChainPanelName;
message[StartVideoStreamArguments.PreviewSwapChainPanelName.ToString()] = previewSwapChainPanelName;
message[StartVideoStreamArguments.Camera.ToString()] = camera;
message[StartVideoStreamArguments.Codec.ToString()] = codec;
message[StartVideoStreamArguments.VideoSize.ToString()] = videoSize;
......
......@@ -63,7 +63,8 @@ namespace MS2TesterTasks
CurrentOperation.Request = BackgroundRequest.StartVideoStream;
CurrentOperation.AppRequestDeferral = deferral;
CurrentOperation.StartVideoStream(
message[StartVideoStreamArguments.SwapChainPanelName.ToString()] as String,
message[StartVideoStreamArguments.VideoSwapChainPanelName.ToString()] as String,
message[StartVideoStreamArguments.PreviewSwapChainPanelName.ToString()] as String,
message[StartVideoStreamArguments.Camera.ToString()] as String,
message[StartVideoStreamArguments.Codec.ToString()] as String,
message[StartVideoStreamArguments.VideoSize.ToString()] as String,
......
......@@ -23,7 +23,8 @@ namespace MS2TesterTasks
public enum StartVideoStreamArguments
{
SwapChainPanelName,
VideoSwapChainPanelName,
PreviewSwapChainPanelName,
Camera,
Codec,
VideoSize,
......
......@@ -88,11 +88,11 @@ namespace MS2TesterTasks
}
}
public static void StartVideoStream(String swapChainPanelName, String camera, String codec, String videoSize, UInt32 frameRate, UInt32 bitRate)
public static void StartVideoStream(String videoSwapChainPanelName, String previewSwapChainPanelName, String camera, String codec, String videoSize, UInt32 frameRate, UInt32 bitRate)
{
lock (_lock)
{
ms2_tester_runtime_component.MS2Tester.Instance.startVideoStream(swapChainPanelName, camera, codec, videoSize, frameRate, bitRate);
ms2_tester_runtime_component.MS2Tester.Instance.startVideoStream(videoSwapChainPanelName, previewSwapChainPanelName, camera, codec, videoSize, frameRate, bitRate);
}
}
......
......@@ -67,16 +67,13 @@
</StackPanel>
</Grid>
<Grid Grid.Row="1" MaxHeight="320">
<SwapChainPanel x:Name="VideoSwapChainPanel" HorizontalAlignment="Center" Height="320" Margin="0,0,0,0" VerticalAlignment="Center" Width="1024"/>
</Grid>
<Grid Grid.Row="2" MaxHeight="320">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.5*"/>
<ColumnDefinition Width="0.5*"/>
</Grid.ColumnDefinitions>
<CaptureElement x:Name="LocalVideo" Stretch="Uniform" Grid.Column="0"/>
<MediaElement x:Name="RemoteVideo" Stretch="Uniform" MediaFailed="RemoteVideo_MediaFailed" MediaEnded="RemoteVideo_MediaEnded" MediaOpened="RemoteVideo_MediaOpened" PartialMediaFailureDetected="RemoteVideo_PartialMediaFailureDetected" RateChanged="RemoteVideo_RateChanged" SizeChanged="RemoteVideo_SizeChanged" CurrentStateChanged="RemoteVideo_CurrentStateChanged" Grid.Column="1"/>
<SwapChainPanel x:Name="PreviewSwapChainPanel" Grid.Column="0"/>
<SwapChainPanel x:Name="VideoSwapChainPanel" Grid.Column="1"/>
</Grid>
</Grid>
</ScrollViewer>
......
......@@ -83,42 +83,6 @@ namespace ms2_tester
((Frame)Window.Current.Content).GoBack();
}
private void RemoteVideo_MediaFailed(object sender, ExceptionRoutedEventArgs e)
{
System.Diagnostics.Debug.WriteLine("RemoteVideo_MediaFailed");
}
private void RemoteVideo_MediaEnded(object sender, RoutedEventArgs e)
{
System.Diagnostics.Debug.WriteLine("RemoteVideo_MediaEnded");
}
private void RemoteVideo_MediaOpened(object sender, RoutedEventArgs e)
{
System.Diagnostics.Debug.WriteLine("RemoteVideo_MediaOpened");
}
private void RemoteVideo_PartialMediaFailureDetected(MediaElement sender, PartialMediaFailureDetectedEventArgs args)
{
System.Diagnostics.Debug.WriteLine("RemoteVideo_PartialMediaFailureDetected");
}
private void RemoteVideo_RateChanged(object sender, RateChangedRoutedEventArgs e)
{
System.Diagnostics.Debug.WriteLine("RemoteVideo_RateChanged");
}
private void RemoteVideo_SizeChanged(object sender, SizeChangedEventArgs e)
{
System.Diagnostics.Debug.WriteLine(String.Format("RemoteVideo_SizeChanged from {0}x{1} to {2}x{3}", e.PreviousSize.Width, e.PreviousSize.Height, e.NewSize.Width, e.NewSize.Height));
}
private void RemoteVideo_CurrentStateChanged(object sender, RoutedEventArgs e)
{
MediaElement mediaElement = sender as MediaElement;
System.Diagnostics.Debug.WriteLine(String.Format("RemoteVideo_CurrentStateChanged: {0}", mediaElement.CurrentState));
}
private void VideoToggleButton_Checked(object sender, RoutedEventArgs e)
{
ToggleButton b = sender as ToggleButton;
......@@ -131,14 +95,17 @@ namespace ms2_tester
UInt32.TryParse((FramerateComboBox.SelectedItem as ComboBoxItem).Content as String, out frameRate);
UInt32 bitRate = 1500;
UInt32.TryParse(BitrateTextBox.Text, out bitRate);
//MS2Tester.Instance.startVideoStream(LocalVideo, RemoteVideo, camera, codec, videoSize, frameRate, bitRate);
StartVideoStream(camera, codec, videoSize, frameRate, bitRate);
}
else
{
if (_source != null)
if (_videoSource != null)
{
_videoSource.Stop();
}
if (_previewSource != null)
{
_source.Stop();
_previewSource.Stop();
}
StopVideoStream();
}
......@@ -229,9 +196,11 @@ namespace ms2_tester
{
try
{
_source = new libmswinrtvid.SwapChainPanelSource();
_source.Start(VideoSwapChainPanel);
OperationResult result = await MS2TesterHelper.StartVideoStream(VideoSwapChainPanel.Name, camera, codec, videoSize, frameRate, bitRate);
_videoSource = new libmswinrtvid.SwapChainPanelSource();
_videoSource.Start(VideoSwapChainPanel);
_previewSource = new libmswinrtvid.SwapChainPanelSource();
_previewSource.Start(PreviewSwapChainPanel);
OperationResult result = await MS2TesterHelper.StartVideoStream(VideoSwapChainPanel.Name, PreviewSwapChainPanel.Name, camera, codec, videoSize, frameRate, bitRate);
if (result == OperationResult.Succeeded)
{
Debug.WriteLine("StartVideoStream: success");
......@@ -379,6 +348,7 @@ namespace ms2_tester
private DisplayInformation displayInformation;
private SimpleOrientationSensor orientationSensor;
private SimpleOrientation deviceOrientation;
private libmswinrtvid.SwapChainPanelSource _source;
private libmswinrtvid.SwapChainPanelSource _videoSource;
private libmswinrtvid.SwapChainPanelSource _previewSource;
}
}
......@@ -205,7 +205,7 @@ void MS2Tester::uninitVideo()
wcstombs(cst, wst.c_str(), sizeof(cst))
void MS2Tester::startVideoStream(Platform::String^ swapChainPanelName, Platform::String^ camera, Platform::String^ codec, Platform::String^ videoSize, unsigned int frameRate, unsigned int bitRate)
void MS2Tester::startVideoStream(Platform::String^ videoSwapChainPanelName, Platform::String^ previewSwapChainPanelName, Platform::String^ camera, Platform::String^ codec, Platform::String^ videoSize, unsigned int frameRate, unsigned int bitRate)
{
ms_filter_enable_statistics(TRUE);
ms_filter_reset_statistics();
......@@ -239,8 +239,11 @@ void MS2Tester::startVideoStream(Platform::String^ swapChainPanelName, Platform:
PayloadType *pt = rtp_profile_get_payload(&av_profile, payload);
pt->normal_bitrate = bitRate * 1000;
_videoStream = video_stream_new(20000, 0, FALSE);
RefToPtrProxy<Platform::String^> *nativeWindowId = new RefToPtrProxy<Platform::String^>(swapChainPanelName);
RefToPtrProxy<Platform::String^> *nativeWindowId = new RefToPtrProxy<Platform::String^>(videoSwapChainPanelName);
video_stream_set_native_window_id(_videoStream, nativeWindowId);
RefToPtrProxy<Platform::String^> *nativePreviewWindowId = new RefToPtrProxy<Platform::String^>(previewSwapChainPanelName);
video_stream_set_native_preview_window_id(_videoStream, nativePreviewWindowId);
video_stream_use_preview_video_window(_videoStream, TRUE);
video_stream_set_display_filter_name(_videoStream, "MSWinRTDis");
video_stream_use_video_preset(_videoStream, "custom");
video_stream_set_sent_video_size(_videoStream, vsize);
......
......@@ -24,7 +24,7 @@ namespace ms2_tester_runtime_component
void runAllToXml();
void initVideo();
void uninitVideo();
void startVideoStream(Platform::String^ swapChainPanelName, Platform::String^ camera, Platform::String^ codec, Platform::String^ videoSize, unsigned int frameRate, unsigned int bitRate);
void startVideoStream(Platform::String^ videoSwapChainPanelName, Platform::String^ previewSwapChainPanelName, Platform::String^ camera, Platform::String^ codec, Platform::String^ videoSize, unsigned int frameRate, unsigned int bitRate);
void stopVideoStream();
int getOrientation() { return _deviceRotation; }
void setOrientation(int degrees);
......
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