Commit ec09b263 authored by Ghislain MARY's avatar Ghislain MARY

Add video button.

parent 1eeb9d97
......@@ -22,6 +22,11 @@ namespace Linphone.Views
public InCallModel()
: base()
{
if (LinphoneManager.Instance.LinphoneCore.IsVideoSupported()
&& LinphoneManager.Instance.LinphoneCore.IsVideoEnabled())
{
this.videoButtonVisibility = Visibility.Visible;
}
}
#region Actions
......@@ -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
#region Video properties
......@@ -388,6 +417,7 @@ namespace Linphone.Views
private Visibility microphoneButtonVisibility = Visibility.Visible;
private Visibility speakerButtonVisibility = Visibility.Visible;
private Visibility statsButtonVisibility = Visibility.Visible;
private Visibility videoButtonVisibility = Visibility.Collapsed;
private Boolean isVideoActive = false;
private Uri remoteVideoUri = null;
private Visibility remoteVideoVisibility = Visibility.Collapsed;
......
......@@ -519,6 +519,32 @@ namespace Linphone.Model
}
#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
/// <summary>
/// Callback for LinphoneCoreListener
......
......@@ -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>
/// Looks up a localized string similar to Video enabled.
/// </summary>
......
......@@ -392,4 +392,7 @@ http://www.linphone.org/m/help
<data name="SelfViewEnabledSetting" xml:space="preserve">
<value>Self view enabled</value>
</data>
<data name="Video" xml:space="preserve">
<value>video</value>
</data>
</root>
\ No newline at end of file
......@@ -39,6 +39,7 @@
<TextBlock Style="{StaticResource PhoneTextNormalStyle}"/>
</StackPanel>
<!-- Statistics panel -->
<StackPanel x:Name="statsPanel" Grid.Row="1" Margin="12,17,0,28" Visibility="Collapsed">
<Grid Grid.Row="1" Margin="0,0,0,0">
<Grid.RowDefinitions>
......@@ -70,7 +71,8 @@
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<!-- Status text -->
<TextBlock
Grid.Row="0"
x:Name="Status"
......@@ -78,19 +80,22 @@
Text="{Binding Path=LocalizedResources.Dialing, Source={StaticResource LocalizedStrings}}"
Margin="12,0,12,0"
FontSize="20" />
<!-- Contact text -->
<TextBlock
Grid.Row="1"
x:Name="Contact"
Margin="12,0,12,0"
FontSize="60"/>
<!-- Number text -->
<TextBlock
Grid.Row="2"
x:Name="Number"
Margin="12,0,12,0"
FontSize="25"/>
<!-- Buttons -->
<Grid
x:Name="buttons"
Grid.Row="3"
......@@ -255,6 +260,22 @@
</StackPanel>
</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
x:Name="numpad"
Grid.Row="3"
......@@ -443,6 +464,7 @@
</Grid>
</Grid>
<!-- Remote video media element -->
<Grid Grid.RowSpan="3" Canvas.ZIndex="-2">
<MediaElement
x:Name="remoteVideo"
......@@ -453,7 +475,8 @@
RenderTransformOrigin="0.5,0.5"
Stretch="Uniform"/>
</Grid>
<!-- Local video media element -->
<Grid Grid.RowSpan="3" Canvas.ZIndex="-1">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
......
......@@ -23,6 +23,8 @@ namespace Linphone.Views
private const string micOff = "/Assets/AppBar/mic.png";
private const string pauseOn = "/Assets/AppBar/play.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 fadeTimer;
......@@ -145,6 +147,16 @@ namespace Linphone.Views
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>
/// Called when the mute status of the microphone changes.
/// </summary>
......@@ -240,6 +252,7 @@ namespace Linphone.Views
{
// Show video if it was not shown yet
((InCallModel)ViewModel).IsVideoActive = true;
video.IsChecked = true;
ButtonsFadeInAnimation.Begin();
StartFadeTimer();
}
......@@ -247,6 +260,7 @@ namespace Linphone.Views
{
// Stop video if it is no longer active
((InCallModel)ViewModel).IsVideoActive = false;
video.IsChecked = false;
}
});
} 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