Commit 7feb1b96 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Added change camera button

parent 1bd28054
......@@ -72,7 +72,7 @@ namespace Xamarin.Droid
captureCamera = new SurfaceView(this);
ViewGroup.LayoutParams cparams = new ViewGroup.LayoutParams(320, 240);
captureCamera.LayoutParameters = cparams;
captureCamera.Holder.SetFixedSize(320, 240);
captureCamera.Holder.SetFixedSize(240, 320);
fl.AddView(displayCamera);
fl.AddView(captureCamera);
......
......@@ -21,7 +21,11 @@
<Label x:Name="call_status" HorizontalOptions="Center" />
<Label x:Name="call_stats" HorizontalOptions="Center" />
<Button x:Name="video" Text="Start Video" Clicked="OnVideoClicked" HorizontalOptions="Center" IsEnabled="False" />
<StackLayout Orientation="Horizontal" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
<Button x:Name="video" Text="Start Video" Clicked="OnVideoClicked" HorizontalOptions="Center" IsEnabled="False" />
<Button x:Name="camera" Text="Change Camera" Clicked="OnCameraClicked" HorizontalOptions="Center" IsEnabled="False" />
</StackLayout>
<StackLayout Orientation="Horizontal" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
<Button x:Name="logs" Text="Upload Logs" Clicked="onUploadLogsCliked" HorizontalOptions="Center" />
<Label x:Name="logsUrl" Text="" HorizontalOptions="Center" />
......
......@@ -6,6 +6,7 @@ using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using Xamarin.Forms;
using Android.Util;
namespace Xamarin
{
......@@ -50,7 +51,7 @@ namespace Xamarin
if (lc.CallsNb > 0)
{
video.IsEnabled = state == CallState.StreamsRunning;
if (state == CallState.IncomingReceived)
{
call.Text = "Answer Call (" + lcall.RemoteAddressAsString + ")";
......@@ -77,6 +78,7 @@ namespace Xamarin
call_stats.Text = "";
video_call.Text = "Start Video Call";
}
camera.IsEnabled = video.IsEnabled;
}
private void OnStats(Core lc, Call call, CallStats stats)
......@@ -202,6 +204,56 @@ namespace Xamarin
}
}
private void OnCameraClicked(object sender, EventArgs e)
{
if (Core.CallsNb > 0)
{
Call call = Core.CurrentCall;
if (call.State == CallState.StreamsRunning)
{
try
{
string currentDevice = Core.VideoDevice;
IEnumerable<string> devices = Core.VideoDevicesList;
int index = 0;
foreach (string d in devices)
{
if (d == currentDevice)
{
break;
}
index++;
}
String newDevice;
if (index == 1)
{
newDevice = devices.ElementAt(0);
}
else if (devices.Count() > 1)
{
newDevice = devices.ElementAt(1);
}
else
{
newDevice = devices.ElementAt(index);
}
Core.VideoDevice = newDevice;
Core.UpdateCall(call, call.Params);
}
catch (ArithmeticException)
{
#if WINDOWS_UWP
Debug.WriteLine("Cannot swtich camera : no camera");
#else
Console.WriteLine("Cannot swtich camera : no camera");
#endif
}
}
}
}
private void onUploadLogsCliked(object sender, EventArgs e)
{
Core.LogCollectionUploadServerUrl = "https://www.linphone.org:444/lft.php";
......
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