Commit 6dadd72a authored by Margaux Clerc's avatar Margaux Clerc

Fix incall preview

parent 909542ca
......@@ -6,6 +6,9 @@ firewall_policy=ice
[sip]
default_proxy=0
media_encryption=none
sip_port=-1
sip_tcp_port=-1
sip_tls_port=-1
[misc]
log_collection_upload_server_url=https://www.linphone.org:444/lft.php
......
......@@ -24,13 +24,14 @@ using Linphone.Views;
using System.IO;
using Windows.Storage;
using Windows.Phone.Media.Devices;
using Windows.System.Profile;
using Windows.Networking.PushNotifications;
using Windows.ApplicationModel.Calls;
using LinphoneTasks;
using Windows.Networking.Connectivity;
using System.Text;
using Windows.Foundation.Metadata;
using Windows.UI.Notifications;
using Windows.Data.Xml.Dom;
namespace Linphone.Model
{
......@@ -185,6 +186,11 @@ namespace Linphone.Model
Core.ResetLogCollection();
}
public bool isMobileVersion()
{
return ApiInformation.IsApiContractPresent("Windows.Phone.PhoneContract", 1);
}
#endregion
#region CallLogs
......@@ -374,7 +380,7 @@ namespace Linphone.Model
public event MessageReceivedEventHandler MessageReceived;
public MessageReceivedListener MessageListener { get; set; }
//public ToastNotification MessageReceivedNotification { get; set; }
public ToastNotification MessageReceivedNotification { get; set; }
void CoreListener.MessageReceived(ChatRoom room, ChatMessage message)
{
if (CoreDispatcher == null) return;
......@@ -388,43 +394,30 @@ namespace Linphone.Model
Address fromAddress = message.FromAddress;
string sipAddress = String.Format("{0}@{1}", fromAddress.UserName, fromAddress.Domain);
Debug.WriteLine("[LinphoneManager] Message received from " + sipAddress + ": " + message.Text + "\r\n");
if (MessageListener != null && MessageListener.GetSipAddressAssociatedWithDisplayConversation() != null && MessageListener.GetSipAddressAssociatedWithDisplayConversation().Equals(sipAddress))
{
MessageListener.MessageReceived(message);
}
else
} else
{
/*string dateStr = Utils.FormatDate(message.Time):
string url = message.ExternalBodyUrl;
url = url.Replace("\"", "");
if (MessageReceivedNotification != null)
{
MessageReceivedNotification.Dismiss();
}
MessageReceivedNotification = new CustomMessageBox()
{
Title = dateStr,
Caption = url.Length > 0 ? AppResources.ImageMessageReceived : AppResources.MessageReceived,
Message = url.Length > 0 ? "" : message.Text,
LeftButtonContent = AppResources.Close,
RightButtonContent = AppResources.Show
};
MessageReceivedNotification.Dismissed += (s, e) =>
{
switch (e.Result)
{
case CustomMessageBoxResult.RightButton:
BaseModel.CurrentPage.NavigationService.Navigate(new Uri("/Views/Chat.xaml?sip=" + Utils.ReplacePlusInUri(message.PeerAddress.AsStringUriOnly()), UriKind.RelativeOrAbsolute));
break;
}
};
MessageReceivedNotification.Show();*/
string url = message.ExternalBodyUrl;
url = url.Replace("\"", "");
if (MessageReceivedNotification != null)
{
ToastNotificationManager.History.Clear();
}
XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02);
XmlNodeList toastTextElements = toastXml.GetElementsByTagName("text");
toastTextElements[0].AppendChild(toastXml.CreateTextNode(sipAddress));
toastTextElements[1].AppendChild(toastXml.CreateTextNode(message.Text));
IXmlNode toastNode = toastXml.SelectSingleNode("/toast");
((XmlElement)toastNode).SetAttribute("launch", "chat ? sip = " + sipAddress);
MessageReceivedNotification = new ToastNotification(toastXml);
ToastNotificationManager.CreateToastNotifier().Show(MessageReceivedNotification);
}
});
#pragma warning restore CS4014 // Dans la mesure où cet appel n'est pas attendu, l'exécution de la méthode actuelle continue avant la fin de l'appel
......@@ -432,7 +425,12 @@ namespace Linphone.Model
public void FileTransferProgressIndication(ChatMessage message, int offset, int total)
{
Debug.WriteLine(String.Format("FileTransferProgressIndication: {0}/{1}", offset, total));
if (CoreDispatcher == null) return;
#pragma warning disable CS4014 // Dans la mesure où cet appel n'est pas attendu, l'exécution de la méthode actuelle continue avant la fin de l'appel
CoreDispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
{
Debug.WriteLine(String.Format("FileTransferProgressIndication: {0}/{1}", offset, total));
});
}
......@@ -460,8 +458,8 @@ namespace Linphone.Model
#endregion
#region Video Management
private String frontCamera = null;
private String backCamera = null;
private List<String> _cameras;
private int numberOfCameras = 0;
public bool IsVideoAvailable
{
......@@ -495,39 +493,23 @@ namespace Linphone.Model
{
get
{
return Core.VideoDevices.Count;
return numberOfCameras;
}
}
private void DetectCameras()
{
int nbCameras = 0;
_cameras = new List<string>();
foreach (String device in LinphoneManager.Instance.Core.VideoDevices)
{
if (device.Contains("Front"))
{
frontCamera = device;
nbCameras++;
}
else if (device.Contains("Back"))
if (!device.Contains("StaticImage"))
{
backCamera = device;
_cameras.Add(device);
nbCameras++;
}
}
String currentDevice = LinphoneManager.Instance.Core.VideoDevice;
if ((currentDevice != frontCamera) && (currentDevice != backCamera))
{
if (frontCamera != null)
{
Core.VideoDevice = frontCamera;
}
else if (backCamera != null)
{
Core.VideoDevice = backCamera;
}
}
numberOfCameras = nbCameras;
}
public void ToggleCameras()
......@@ -535,14 +517,7 @@ namespace Linphone.Model
if (NumberOfCameras >= 2)
{
String currentDevice = Core.VideoDevice;
if (currentDevice == frontCamera)
{
Core.VideoDevice = backCamera;
}
else if (currentDevice == backCamera)
{
Core.VideoDevice = frontCamera;
}
Core.VideoDevice = _cameras.ElementAt((_cameras.IndexOf(Core.VideoDevice) + 1) % _cameras.Count());
if (Core.IsInCall)
{
......@@ -629,7 +604,7 @@ namespace Linphone.Model
else if (state == CallState.UpdatedByRemote)
{
bool remoteVideo = call.RemoteParams.IsVideoEnabled;
bool localVideo = call.CurrentParams.Copy().IsVideoEnabled;
bool localVideo = call.CurrentParams.IsVideoEnabled;
bool autoAcceptCameraPolicy = Core.VideoPolicy.AutomaticallyAccept;
if (remoteVideo && !localVideo && !autoAcceptCameraPolicy)
{
......
......@@ -87,9 +87,9 @@
</Grid.ColumnDefinitions>
<SwapChainPanel x:Name="VideoSwapChainPanel" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="3" Grid.RowSpan="3"/>
<SwapChainPanel x:Name="PreviewSwapChainPanel" Grid.Column="2" Grid.Row="3" Width="120" Height="160" RenderTransformOrigin="0.5,0.5">
<SwapChainPanel x:Name="PreviewSwapChainPanel" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Column="2" Grid.Row="2" RenderTransformOrigin="0.5,0.5">
<SwapChainPanel.RenderTransform>
<CompositeTransform ScaleX="-1"/>
<CompositeTransform x:Name="PreviewRender" ScaleX="-1"/>
</SwapChainPanel.RenderTransform>
</SwapChainPanel>
</Grid>
......
......@@ -128,6 +128,14 @@ namespace Linphone.Views
private void buttons_CameraClick(object sender)
{
LinphoneManager.Instance.ToggleCameras();
if(LinphoneManager.Instance.Core.VideoDevice.Contains("Front"))
{
PreviewRender.ScaleX = -1;
} else
{
PreviewRender.ScaleX = 1;
}
}
private void buttons_StatsClick(object sender, bool areStatsVisible)
......@@ -171,7 +179,10 @@ namespace Linphone.Views
oneSecondTimer.Stop();
}
ToggleFullScreenMode(false);
if (LinphoneManager.Instance.isMobileVersion())
{
ToggleFullScreenMode(false);
}
/*if (fadeTimer != null)
{
fadeTimer.Dispose();
......@@ -308,8 +319,8 @@ namespace Linphone.Views
VideoGrid.Width = ActualWidth;
}
VideoGrid.Height = VideoGrid.Width * 3 / 4;
PreviewSwapChainPanel.Width = VideoGrid.Width / 4;
PreviewSwapChainPanel.Height = VideoGrid.Height / 4;
//PreviewSwapChainPanel.Width = VideoGrid.Width / 4;
//PreviewSwapChainPanel.Height = VideoGrid.Height / 4;
}
private void Video_Tapped(object sender, TappedRoutedEventArgs e)
......@@ -326,10 +337,21 @@ namespace Linphone.Views
private void displayVideo(bool isVisible)
{
ToggleFullScreenMode(isVisible);
if (LinphoneManager.Instance.isMobileVersion())
{
ToggleFullScreenMode(isVisible);
}
if (isVisible)
{
//AdaptVideoSize();
if (LinphoneManager.Instance.Core.VideoDevice.Contains("Front"))
{
PreviewRender.ScaleX = -1;
}
else
{
PreviewRender.ScaleX = 1;
}
buttons.Visibility = Visibility.Collapsed;
VideoGrid.Visibility = Visibility.Visible;
ContactHeader.Visibility = Visibility.Collapsed;
......
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