Commit 250f96c5 authored by Ghislain MARY's avatar Ghislain MARY

Handle camera toggling.

parent d1fb9e67
......@@ -416,7 +416,11 @@ void Linphone::Core::LinphoneCore::DeferCallUpdate(Linphone::Core::LinphoneCall^
void Linphone::Core::LinphoneCore::UpdateCall(Linphone::Core::LinphoneCall^ call, Linphone::Core::LinphoneCallParams^ params)
{
gApiLock.Lock();
linphone_core_update_call(this->lc, call->call, params->params);
if (params != nullptr) {
linphone_core_update_call(this->lc, call->call, params->params);
} else {
linphone_core_update_call(this->lc, call->call, nullptr);
}
gApiLock.Unlock();
}
......
......@@ -22,11 +22,8 @@ namespace Linphone.Views
public InCallModel()
: base()
{
if (LinphoneManager.Instance.LinphoneCore.IsVideoSupported()
&& LinphoneManager.Instance.LinphoneCore.IsVideoEnabled())
{
this.videoButtonVisibility = Visibility.Visible;
}
VideoButtonVisibility = Visibility.Visible;
CameraButtonVisibility = Visibility.Visible;
}
#region Actions
......@@ -258,6 +255,31 @@ namespace Linphone.Views
}
}
/// <summary>
/// Visibility of the camera button.
/// </summary>
public Visibility CameraButtonVisibility
{
get
{
return this.cameraButtonVisibility;
}
set
{
if (!LinphoneManager.Instance.LinphoneCore.IsVideoSupported()
|| !LinphoneManager.Instance.LinphoneCore.IsVideoEnabled()
|| (LinphoneManager.Instance.NumberOfCameras < 2))
{
value = Visibility.Collapsed;
}
if (this.cameraButtonVisibility != value)
{
this.cameraButtonVisibility = value;
this.OnPropertyChanged();
}
}
}
#endregion
#region Video properties
......@@ -418,6 +440,7 @@ namespace Linphone.Views
private Visibility speakerButtonVisibility = Visibility.Visible;
private Visibility statsButtonVisibility = Visibility.Visible;
private Visibility videoButtonVisibility = Visibility.Collapsed;
private Visibility cameraButtonVisibility = Visibility.Collapsed;
private Boolean isVideoActive = false;
private Uri remoteVideoUri = null;
private Visibility remoteVideoVisibility = Visibility.Collapsed;
......
......@@ -277,27 +277,7 @@ namespace Linphone.Model
if (LinphoneCore.IsVideoSupported())
{
String frontCamera = null;
String backCamera = null;
foreach (String device in LinphoneCore.GetVideoDevices())
{
if (device.EndsWith(CameraSensorLocation.Front.ToString()))
{
frontCamera = device;
}
else if (device.EndsWith(CameraSensorLocation.Back.ToString()))
{
backCamera = device;
}
}
if (frontCamera != null)
{
LinphoneCore.SetVideoDevice(frontCamera);
}
else if (backCamera != null)
{
LinphoneCore.SetVideoDevice(backCamera);
}
DetectCameras();
}
lastNetworkState = DeviceNetworkInformation.IsNetworkAvailable;
......@@ -519,6 +499,8 @@ namespace Linphone.Model
}
#endregion
#region Video handling
/// <summary>
/// Enables disables video.
/// </summary>
......@@ -544,6 +526,77 @@ namespace Linphone.Model
return false;
}
private int nbCameras = 0;
private String frontCamera = null;
private String backCamera = null;
private void DetectCameras()
{
int nbCameras = 0;
foreach (String device in LinphoneCore.GetVideoDevices())
{
if (device.EndsWith(CameraSensorLocation.Front.ToString()))
{
frontCamera = device;
nbCameras++;
}
else if (device.EndsWith(CameraSensorLocation.Back.ToString()))
{
backCamera = device;
nbCameras++;
}
}
String currentDevice = LinphoneCore.GetVideoDevice();
if ((currentDevice != frontCamera) && (currentDevice != backCamera))
{
if (frontCamera != null)
{
LinphoneCore.SetVideoDevice(frontCamera);
}
else if (backCamera != null)
{
LinphoneCore.SetVideoDevice(backCamera);
}
}
this.nbCameras = nbCameras;
}
/// <summary>
/// Gets the number of cameras available on the device (int).
/// </summary>
public int NumberOfCameras
{
get
{
return nbCameras;
}
}
/// <summary>
/// Toggles the camera used for video capture.
/// </summary>
public void ToggleCameras()
{
if (NumberOfCameras >= 2)
{
String currentDevice = LinphoneCore.GetVideoDevice();
if (currentDevice == frontCamera)
{
LinphoneCore.SetVideoDevice(backCamera);
}
else if (currentDevice == backCamera)
{
LinphoneCore.SetVideoDevice(frontCamera);
}
if (LinphoneCore.IsInCall())
{
LinphoneCall call = LinphoneCore.GetCurrentCall();
//LinphoneCore.UpdateCall(call, null);
}
}
}
#endregion
#region LinphoneCoreListener Callbacks
/// <summary>
/// Callback for LinphoneCoreListener
......
......@@ -112,6 +112,7 @@
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<!-- Animations -->
<Grid.Resources>
<Storyboard x:Name="ButtonsFadeOutAnimation">
<DoubleAnimation
......@@ -302,6 +303,20 @@
</StackPanel>
</ToggleButton>
<Button
x:Name="camera"
Grid.Row="3"
Grid.Column="0"
BorderThickness="0"
Margin="-10"
Click="camera_Click_1"
Visibility="{Binding CameraButtonVisibility}"
Background="Transparent">
<StackPanel Orientation="Vertical">
<Image x:Name="cameraImg" Source="/Assets/AppBar/feature.camera.png" Stretch="None"/>
</StackPanel>
</Button>
<!-- Numeric pad buttons -->
<Grid
x:Name="numpad"
......
......@@ -157,6 +157,11 @@ namespace Linphone.Views
videoImg.Source = new BitmapImage(new Uri(isVideoToggled ? videoOn : videoOff, UriKind.RelativeOrAbsolute));
}
private void camera_Click_1(object sender, RoutedEventArgs e)
{
LinphoneManager.Instance.ToggleCameras();
}
/// <summary>
/// Called when the mute status of the microphone changes.
/// </summary>
......
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