Commit d5a61343 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Improved incall dilplayed time

parent deb185e5
......@@ -24,7 +24,7 @@ Linphone::Core::LinphoneAddress^ Linphone::Core::LinphoneCall::GetRemoteAddress(
Linphone::Core::CallDirection Linphone::Core::LinphoneCall::GetDirection()
{
return Linphone::Core::CallDirection::Incoming;
return (Linphone::Core::CallDirection)linphone_call_get_dir(this->call);
}
Linphone::Core::LinphoneCallLog^ Linphone::Core::LinphoneCall::GetCallLog()
......@@ -122,6 +122,13 @@ void Linphone::Core::LinphoneCall::CallContext::set(Platform::Object^ cc)
this->callContext = cc;
}
Platform::Object^ Linphone::Core::LinphoneCall::GetCallStartTimeFromContext()
{
if (this->callContext != nullptr) {
return ((Windows::Phone::Networking::Voip::VoipPhoneCall^)this->callContext)->StartTime;
}
return nullptr;
}
Platform::Object^ Linphone::Core::LinphoneCall::CallContext::get()
{
......
......@@ -89,6 +89,8 @@ namespace Linphone
Platform::String^ GetRemoteUserAgent();
Platform::String^ GetRemoteContact();
Platform::Object^ GetCallStartTimeFromContext();
property Platform::Object^ CallContext
{
Platform::Object^ get();
......
......@@ -236,6 +236,7 @@ void Linphone::Core::LinphoneCore::TerminateCall(Linphone::Core::LinphoneCall^ c
Linphone::Core::LinphoneCall^ Linphone::Core::LinphoneCore::GetCurrentCall()
{
std::lock_guard<std::recursive_mutex> lock(g_apiLock);
::LinphoneCall *call = linphone_core_get_current_call(this->lc);
Linphone::Core::RefToPtrProxy<Linphone::Core::LinphoneCall^> *proxy = reinterpret_cast< Linphone::Core::RefToPtrProxy<Linphone::Core::LinphoneCall^> *>(linphone_call_get_user_pointer(call));
Linphone::Core::LinphoneCall^ lCall = (proxy) ? proxy->Ref() : nullptr;
......
using Linphone.Model;
using Linphone.Core;
using Linphone.Model;
using Microsoft.Phone.Controls;
using System;
using System.ComponentModel;
......@@ -8,6 +9,7 @@ using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using Windows.Phone.Networking.Voip;
namespace Linphone.Views
{
......@@ -24,7 +26,6 @@ namespace Linphone.Views
private const string pauseOff = "/Assets/AppBar/pause.png";
private Timer timer;
private Stopwatch watch;
/// <summary>
/// Public constructor.
......@@ -32,7 +33,6 @@ namespace Linphone.Views
public InCall()
{
InitializeComponent();
watch = new Stopwatch();
var call = LinphoneManager.Instance.LinphoneCore.GetCurrentCall();
if (call != null && call.GetState() == Core.LinphoneCallState.StreamsRunning)
......@@ -78,6 +78,11 @@ namespace Linphone.Views
/// </summary>
protected override void OnNavigatedFrom(NavigationEventArgs nee)
{
if (timer != null)
{
timer.Dispose();
}
base.OnNavigatedFrom(nee);
this.ViewModel.MuteListener = null;
this.ViewModel.PauseListener = null;
......@@ -151,23 +156,21 @@ namespace Linphone.Views
if (!isCallPaused)
{
timer = new Timer(new TimerCallback(timerTick), null, 0, 1000);
watch.Start();
}
else
else if (timer != null)
{
if (timer != null)
{
timer.Dispose();
}
watch.Stop();
timer.Dispose();
}
}
private void timerTick(Object state)
{
var ss = watch.ElapsedMilliseconds / 1000;
var mm = ss / 60;
ss = ss % 60;
LinphoneCall call = LinphoneManager.Instance.LinphoneCore.GetCurrentCall();
DateTimeOffset startTime = (DateTimeOffset)call.GetCallStartTimeFromContext();
DateTimeOffset now = DateTimeOffset.Now;
TimeSpan elapsed = now.Subtract(startTime);
var ss = elapsed.Seconds;
var mm = elapsed.Minutes;
Status.Dispatcher.BeginInvoke(delegate()
{
Status.Text = mm.ToString("00") + ":" + ss.ToString("00");
......
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