Commit ec09b263 authored by Ghislain MARY's avatar Ghislain MARY

Add video button.

parent 1eeb9d97
...@@ -22,6 +22,11 @@ namespace Linphone.Views ...@@ -22,6 +22,11 @@ namespace Linphone.Views
public InCallModel() public InCallModel()
: base() : base()
{ {
if (LinphoneManager.Instance.LinphoneCore.IsVideoSupported()
&& LinphoneManager.Instance.LinphoneCore.IsVideoEnabled())
{
this.videoButtonVisibility = Visibility.Visible;
}
} }
#region Actions #region Actions
...@@ -229,6 +234,30 @@ namespace Linphone.Views ...@@ -229,6 +234,30 @@ namespace Linphone.Views
} }
} }
/// <summary>
/// Visibility of the video button.
/// </summary>
public Visibility VideoButtonVisibility
{
get
{
return this.videoButtonVisibility;
}
set
{
if (!LinphoneManager.Instance.LinphoneCore.IsVideoSupported()
|| !LinphoneManager.Instance.LinphoneCore.IsVideoEnabled())
{
value = Visibility.Collapsed;
}
if (this.videoButtonVisibility != value)
{
this.videoButtonVisibility = value;
this.OnPropertyChanged();
}
}
}
#endregion #endregion
#region Video properties #region Video properties
...@@ -388,6 +417,7 @@ namespace Linphone.Views ...@@ -388,6 +417,7 @@ namespace Linphone.Views
private Visibility microphoneButtonVisibility = Visibility.Visible; private Visibility microphoneButtonVisibility = Visibility.Visible;
private Visibility speakerButtonVisibility = Visibility.Visible; private Visibility speakerButtonVisibility = Visibility.Visible;
private Visibility statsButtonVisibility = Visibility.Visible; private Visibility statsButtonVisibility = Visibility.Visible;
private Visibility videoButtonVisibility = Visibility.Collapsed;
private Boolean isVideoActive = false; private Boolean isVideoActive = false;
private Uri remoteVideoUri = null; private Uri remoteVideoUri = null;
private Visibility remoteVideoVisibility = Visibility.Collapsed; private Visibility remoteVideoVisibility = Visibility.Collapsed;
......
...@@ -519,6 +519,32 @@ namespace Linphone.Model ...@@ -519,6 +519,32 @@ namespace Linphone.Model
} }
#endregion #endregion
/// <summary>
/// Enables disables video.
/// </summary>
/// <param name="enable">Wether to enable or disable video</param>
/// <returns>true if the operation has been successful, false otherwise</returns>
public bool EnableVideo(bool enable)
{
if (LinphoneCore.IsInCall())
{
LinphoneCall call = LinphoneCore.GetCurrentCall();
if (enable != call.IsCameraEnabled())
{
call.EnableCamera(enable);
LinphoneCallParams parameters = call.GetCurrentParamsCopy();
parameters.EnableVideo(enable);
if (enable)
{
// TODO: Handle bandwidth limitation
}
LinphoneCore.UpdateCall(call, parameters);
return true;
}
}
return false;
}
#region LinphoneCoreListener Callbacks #region LinphoneCoreListener Callbacks
/// <summary> /// <summary>
/// Callback for LinphoneCoreListener /// Callback for LinphoneCoreListener
......
...@@ -840,6 +840,15 @@ namespace Linphone.Resources { ...@@ -840,6 +840,15 @@ namespace Linphone.Resources {
} }
} }
/// <summary>
/// Looks up a localized string similar to video.
/// </summary>
public static string Video {
get {
return ResourceManager.GetString("Video", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Video enabled. /// Looks up a localized string similar to Video enabled.
/// </summary> /// </summary>
......
...@@ -392,4 +392,7 @@ http://www.linphone.org/m/help ...@@ -392,4 +392,7 @@ http://www.linphone.org/m/help
<data name="SelfViewEnabledSetting" xml:space="preserve"> <data name="SelfViewEnabledSetting" xml:space="preserve">
<value>Self view enabled</value> <value>Self view enabled</value>
</data> </data>
<data name="Video" xml:space="preserve">
<value>video</value>
</data>
</root> </root>
\ No newline at end of file
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
<TextBlock Style="{StaticResource PhoneTextNormalStyle}"/> <TextBlock Style="{StaticResource PhoneTextNormalStyle}"/>
</StackPanel> </StackPanel>
<!-- Statistics panel -->
<StackPanel x:Name="statsPanel" Grid.Row="1" Margin="12,17,0,28" Visibility="Collapsed"> <StackPanel x:Name="statsPanel" Grid.Row="1" Margin="12,17,0,28" Visibility="Collapsed">
<Grid Grid.Row="1" Margin="0,0,0,0"> <Grid Grid.Row="1" Margin="0,0,0,0">
<Grid.RowDefinitions> <Grid.RowDefinitions>
...@@ -70,7 +71,8 @@ ...@@ -70,7 +71,8 @@
<RowDefinition Height="Auto"></RowDefinition> <RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="*"></RowDefinition> <RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<!-- Status text -->
<TextBlock <TextBlock
Grid.Row="0" Grid.Row="0"
x:Name="Status" x:Name="Status"
...@@ -78,19 +80,22 @@ ...@@ -78,19 +80,22 @@
Text="{Binding Path=LocalizedResources.Dialing, Source={StaticResource LocalizedStrings}}" Text="{Binding Path=LocalizedResources.Dialing, Source={StaticResource LocalizedStrings}}"
Margin="12,0,12,0" Margin="12,0,12,0"
FontSize="20" /> FontSize="20" />
<!-- Contact text -->
<TextBlock <TextBlock
Grid.Row="1" Grid.Row="1"
x:Name="Contact" x:Name="Contact"
Margin="12,0,12,0" Margin="12,0,12,0"
FontSize="60"/> FontSize="60"/>
<!-- Number text -->
<TextBlock <TextBlock
Grid.Row="2" Grid.Row="2"
x:Name="Number" x:Name="Number"
Margin="12,0,12,0" Margin="12,0,12,0"
FontSize="25"/> FontSize="25"/>
<!-- Buttons -->
<Grid <Grid
x:Name="buttons" x:Name="buttons"
Grid.Row="3" Grid.Row="3"
...@@ -255,6 +260,22 @@ ...@@ -255,6 +260,22 @@
</StackPanel> </StackPanel>
</ToggleButton> </ToggleButton>
<ToggleButton
x:Name="video"
Grid.Row="2"
Grid.Column="1"
BorderThickness="0"
Margin="-10"
Checked="video_Checked_1"
Visibility="{Binding VideoButtonVisibility}"
Background="{StaticResource PhoneChromeBrush}">
<StackPanel Orientation="Vertical">
<Image x:Name="videoImg" Source="/Assets/AppBar/feature.video.png" Stretch="None"/>
<TextBlock HorizontalAlignment="Center" FontSize="20" Text="{Binding Path=LocalizedResources.Video, Source={StaticResource LocalizedStrings}}" TextWrapping="Wrap" Margin="5,0,5,10"/>
</StackPanel>
</ToggleButton>
<!-- Numeric pad buttons -->
<Grid <Grid
x:Name="numpad" x:Name="numpad"
Grid.Row="3" Grid.Row="3"
...@@ -443,6 +464,7 @@ ...@@ -443,6 +464,7 @@
</Grid> </Grid>
</Grid> </Grid>
<!-- Remote video media element -->
<Grid Grid.RowSpan="3" Canvas.ZIndex="-2"> <Grid Grid.RowSpan="3" Canvas.ZIndex="-2">
<MediaElement <MediaElement
x:Name="remoteVideo" x:Name="remoteVideo"
...@@ -453,7 +475,8 @@ ...@@ -453,7 +475,8 @@
RenderTransformOrigin="0.5,0.5" RenderTransformOrigin="0.5,0.5"
Stretch="Uniform"/> Stretch="Uniform"/>
</Grid> </Grid>
<!-- Local video media element -->
<Grid Grid.RowSpan="3" Canvas.ZIndex="-1"> <Grid Grid.RowSpan="3" Canvas.ZIndex="-1">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="*" /> <RowDefinition Height="*" />
......
...@@ -23,6 +23,8 @@ namespace Linphone.Views ...@@ -23,6 +23,8 @@ namespace Linphone.Views
private const string micOff = "/Assets/AppBar/mic.png"; private const string micOff = "/Assets/AppBar/mic.png";
private const string pauseOn = "/Assets/AppBar/play.png"; private const string pauseOn = "/Assets/AppBar/play.png";
private const string pauseOff = "/Assets/AppBar/pause.png"; private const string pauseOff = "/Assets/AppBar/pause.png";
private const string videoOn = "/Assets/AppBar/feature.video.png";
private const string videoOff = "/Assets/AppBar/feature.video.png";
private Timer oneSecondTimer; private Timer oneSecondTimer;
private Timer fadeTimer; private Timer fadeTimer;
...@@ -145,6 +147,16 @@ namespace Linphone.Views ...@@ -145,6 +147,16 @@ namespace Linphone.Views
statsPanel.Visibility = areStatsVisible ? Visibility.Visible : Visibility.Collapsed; statsPanel.Visibility = areStatsVisible ? Visibility.Visible : Visibility.Collapsed;
} }
private void video_Checked_1(object sender, RoutedEventArgs e)
{
bool isVideoToggled = (bool)video.IsChecked;
videoImg.Source = new BitmapImage(new Uri(isVideoToggled ? videoOn : videoOff, UriKind.RelativeOrAbsolute));
if (!LinphoneManager.Instance.EnableVideo(isVideoToggled))
{
if (isVideoToggled) video.IsChecked = false;
}
}
/// <summary> /// <summary>
/// Called when the mute status of the microphone changes. /// Called when the mute status of the microphone changes.
/// </summary> /// </summary>
...@@ -240,6 +252,7 @@ namespace Linphone.Views ...@@ -240,6 +252,7 @@ namespace Linphone.Views
{ {
// Show video if it was not shown yet // Show video if it was not shown yet
((InCallModel)ViewModel).IsVideoActive = true; ((InCallModel)ViewModel).IsVideoActive = true;
video.IsChecked = true;
ButtonsFadeInAnimation.Begin(); ButtonsFadeInAnimation.Begin();
StartFadeTimer(); StartFadeTimer();
} }
...@@ -247,6 +260,7 @@ namespace Linphone.Views ...@@ -247,6 +260,7 @@ namespace Linphone.Views
{ {
// Stop video if it is no longer active // Stop video if it is no longer active
((InCallModel)ViewModel).IsVideoActive = false; ((InCallModel)ViewModel).IsVideoActive = false;
video.IsChecked = false;
} }
}); });
} catch { } catch {
......
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