Commit 22342644 authored by Ghislain MARY's avatar Ghislain MARY
Browse files

Correctly handle video when putting the app in the background during a video call.

In this case the video is disabled, and will be enabled again when
restoring the ap to the foreground.
parent 68627672
......@@ -14,6 +14,7 @@ sip_port=-1
sip_tcp_port=-1
sip_tls_port=-1
inactive_video_on_pause=1
defer_update_default=1
[rtp]
audio_jitt_comp=60
......
......@@ -941,10 +941,21 @@ namespace Linphone.Model
VideoPolicy policy = LinphoneManager.Instance.LinphoneCore.VideoPolicy;
LinphoneCallParams remoteParams = call.RemoteParams;
LinphoneCallParams localParams = call.GetCurrentParamsCopy();
if (!policy.AutomaticallyAccept && remoteParams.VideoEnabled && !localParams.VideoEnabled && !LinphoneManager.Instance.LinphoneCore.InConference)
if (remoteParams.VideoEnabled && !localParams.VideoEnabled && !LinphoneManager.Instance.LinphoneCore.InConference)
{
LinphoneManager.Instance.LinphoneCore.DeferCallUpdate(call);
videoAdded = true;
if (policy.AutomaticallyAccept)
{
localParams.VideoEnabled = true;
LinphoneManager.Instance.LinphoneCore.AcceptCallUpdate(call, localParams);
}
else
{
videoAdded = true;
}
}
else
{
LinphoneManager.Instance.LinphoneCore.AcceptCallUpdate(call, localParams);
}
if (CallListener != null)
......
......@@ -149,6 +149,8 @@ namespace Linphone.Model
#region Constants settings names
private const string LogLevelKeyName = "LogLevel";
private const string VideoActiveWhenGoingToBackgroundKeyName = "VideoActiveWhenGoingToBackground";
private const string VideoAutoAcceptWhenGoingToBackgroundKeyName = "VideoAutoAcceptWhenGoingToBackground";
#endregion
/// <summary>
......@@ -173,6 +175,8 @@ namespace Linphone.Model
public void Load()
{
dict[LogLevelKeyName] = Config.GetInt(ApplicationSection, LogLevelKeyName, (int)OutputTraceLevel.Message).ToString();
dict[VideoActiveWhenGoingToBackgroundKeyName] = Config.GetBool(ApplicationSection, VideoActiveWhenGoingToBackgroundKeyName, false).ToString();
dict[VideoAutoAcceptWhenGoingToBackgroundKeyName] = Config.GetBool(ApplicationSection, VideoAutoAcceptWhenGoingToBackgroundKeyName, true).ToString();
}
/// <summary>
......@@ -192,6 +196,14 @@ namespace Linphone.Model
Logger.Warn("Failed setting the log level name {0}", Get(LogLevelKeyName));
}
}
if (ValueChanged(VideoActiveWhenGoingToBackgroundKeyName))
{
Config.SetBool(ApplicationSection, VideoActiveWhenGoingToBackgroundKeyName, Convert.ToBoolean(GetNew(VideoActiveWhenGoingToBackgroundKeyName)));
}
if (ValueChanged(VideoAutoAcceptWhenGoingToBackgroundKeyName))
{
Config.SetBool(ApplicationSection, VideoAutoAcceptWhenGoingToBackgroundKeyName, Convert.ToBoolean(GetNew(VideoAutoAcceptWhenGoingToBackgroundKeyName)));
}
}
#endregion
......@@ -232,6 +244,36 @@ namespace Linphone.Model
Set(LogLevelKeyName, ((int)value).ToString());
}
}
/// <summary>
/// Save if the video was active when going to background.
/// </summary>
public Boolean VideoActiveWhenGoingToBackground
{
get
{
return Convert.ToBoolean(Get(VideoActiveWhenGoingToBackgroundKeyName));
}
set
{
Set(VideoActiveWhenGoingToBackgroundKeyName, value.ToString());
}
}
/// <summary>
/// Save the video auto accept policy when going to background.
/// </summary>
public Boolean VideoAutoAcceptWhenGoingToBackground
{
get
{
return Convert.ToBoolean(Get(VideoAutoAcceptWhenGoingToBackgroundKeyName));
}
set
{
Set(VideoAutoAcceptWhenGoingToBackgroundKeyName, value.ToString());
}
}
#endregion
}
......
......@@ -214,6 +214,9 @@ namespace Linphone.Views
}
}
ApplicationSettingsManager settings = new ApplicationSettingsManager();
settings.Load();
// Callback CallStateChanged set too late when call is incoming, so trigger it manually
if (LinphoneManager.Instance.LinphoneCore.CallsNb > 0)
{
......@@ -221,9 +224,24 @@ namespace Linphone.Views
if (call.State == LinphoneCallState.StreamsRunning)
{
CallStateChanged(call, LinphoneCallState.StreamsRunning);
if (settings.VideoActiveWhenGoingToBackground)
{
LinphoneManager.Instance.LinphoneCore.VideoPolicy.AutomaticallyAccept = settings.VideoAutoAcceptWhenGoingToBackground;
LinphoneCallParams callParams = call.GetCurrentParamsCopy();
callParams.VideoEnabled = true;
LinphoneManager.Instance.LinphoneCore.UpdateCall(call, callParams);
}
}
else if (call.State == LinphoneCallState.UpdatedByRemote)
{
// The call was updated by the remote party while we were in background
LinphoneManager.Instance.CallState(call, call.State, "call updated while in background");
}
}
settings.VideoActiveWhenGoingToBackground = false;
settings.Save();
oneSecondTimer = new DispatcherTimer();
oneSecondTimer.Interval = TimeSpan.FromSeconds(1);
oneSecondTimer.Tick += timerTick;
......@@ -331,6 +349,28 @@ namespace Linphone.Views
/// </summary>
protected override void OnNavigatedFrom(NavigationEventArgs nee)
{
if (((InCallModel)ViewModel).IsVideoActive)
{
LinphoneCall call = null;
try
{
call = (LinphoneCall)LinphoneManager.Instance.LinphoneCore.Calls[0];
}
catch (System.ArgumentOutOfRangeException) { }
if (call != null)
{
ApplicationSettingsManager settings = new ApplicationSettingsManager();
settings.Load();
settings.VideoActiveWhenGoingToBackground = true;
settings.VideoAutoAcceptWhenGoingToBackground = LinphoneManager.Instance.LinphoneCore.VideoPolicy.AutomaticallyAccept;
settings.Save();
LinphoneManager.Instance.LinphoneCore.VideoPolicy.AutomaticallyAccept = false;
LinphoneCallParams callParams = call.GetCurrentParamsCopy();
callParams.VideoEnabled = false;
LinphoneManager.Instance.LinphoneCore.UpdateCall(call, callParams);
}
}
oneSecondTimer.Stop();
if (fadeTimer != null)
{
......
linphone @ ced44d17
Subproject commit 74ad3ed63f99dd65ca2c9881731ae18cbc0e92c8
Subproject commit ced44d17eb7a3ec9e1f70fb1ded728c4ceab42d0
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