Commit 72487dcb authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Some minor changes for Android

parent 4c359f3d
[net]
mtu=1300
#Because dynamic bitrate adaption can increase bitrate, we must allow "no limit"
download_bw=0
upload_bw=0
force_ice_disablement=0
[sip]
guess_hostname=1
register_only_when_network_is_up=1
auto_net_state_mon=0
auto_answer_replacing_calls=1
ping_with_options=0
rls_uri=
use_cpim=1
linphone_specs=groupchat
[rtp]
audio_rtp_port=7076
video_rtp_port=9078
audio_jitt_comp=60
video_jitt_comp=60
nortp_timeout=30
disable_upnp=1
[sound]
playback_dev_id=
ringer_dev_id=
capture_dev_id=
dtmf_player_amp=0.1
[misc]
max_calls=10
history_max_size=100
enable_basic_to_client_group_chat_room_migration=0
enable_simple_group_chat_message_state=0
aggregate_imdn=1
\ No newline at end of file
......@@ -51,10 +51,20 @@ namespace Xamarin.Droid
File.WriteAllText(rc_path, sr.ReadToEnd());
}
}
string factory_path = path + "/factory_rc";
if (!File.Exists(factory_path))
{
using (StreamReader sr = new StreamReader(assets.Open("linphonerc_factory")))
{
File.WriteAllText(factory_path, sr.ReadToEnd());
}
}
global::Xamarin.Forms.Forms.Init(this, bundle);
App app = new App(); // Do not add an arg to App constructor
app.ConfigFilePath = rc_path;
app.FactoryFilePath = factory_path;
app.Manager.AndroidContext = this;
LinearLayout fl = new LinearLayout(this);
ViewGroup.LayoutParams lparams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);
......
......@@ -9,5 +9,9 @@
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS"/>
<uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS"/>
<application android:label="Xamarin.Android"></application>
</manifest>
\ No newline at end of file
......@@ -101,6 +101,9 @@
<Name>Liblinphone</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<AndroidAsset Include="Assets\linphonerc_factory" />
</ItemGroup>
<Import Project="..\Xamarin\Xamarin.projitems" Label="Shared" />
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
</Project>
\ No newline at end of file
......@@ -11,6 +11,7 @@ namespace Xamarin
public partial class App : Application
{
public string ConfigFilePath { get; set; }
public string FactoryFilePath { get; set; }
public LinphoneManager Manager { get; set; }
......@@ -27,7 +28,7 @@ namespace Xamarin
InitializeComponent();
Manager = new LinphoneManager();
Manager.Init(ConfigFilePath);
Manager.Init(ConfigFilePath, FactoryFilePath);
MainPage = new MainPage();
}
......
......@@ -8,6 +8,7 @@ using Xamarin.Forms;
#if ANDROID
using Android.Util;
using Android.App;
#endif
namespace Xamarin
......@@ -16,6 +17,12 @@ namespace Xamarin
{
public Core Core { get; set; }
#if ANDROID
public Activity AndroidContext { get; set; }
#endif
private System.Timers.Timer Timer;
public LinphoneManager()
{
LinphoneWrapper.setNativeLogHandler();
......@@ -26,17 +33,17 @@ namespace Xamarin
Debug.WriteLine("LinphoneWrapper.cs version is " + LinphoneWrapper.VERSION);
}
public void Init(string configPath)
public void Init(string configPath, string factoryPath)
{
CoreListener listener = Factory.Instance.CreateCoreListener();
listener.OnGlobalStateChanged = OnGlobal;
#if ANDROID
// Giving app context in CreateCore is mandatory for Android to be able to load grammars (and other assets) from AAR
Core = Factory.Instance.CreateCore(listener, configPath, null, IntPtr.Zero, LinphoneAndroid.AndroidContext);
Core = Factory.Instance.CreateCore(listener, configPath, factoryPath, IntPtr.Zero, LinphoneAndroid.AndroidContext);
// Required to be able to store logs as file
Core.SetLogCollectionPath(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData));
#else
Core = Factory.Instance.CreateCore(listener, ConfigFilePath, null);
Core = Factory.Instance.CreateCore(listener, configPath, factoryPath);
#endif
Core.NetworkReachable = true;
}
......@@ -47,34 +54,30 @@ namespace Xamarin
TimeSpan period = TimeSpan.FromSeconds(1);
ThreadPoolTimer PeriodicTimer = ThreadPoolTimer.CreatePeriodicTimer(LinphoneCoreIterate , period);
#else
Thread iterate = new Thread(LinphoneCoreIterate);
iterate.IsBackground = false;
iterate.Start();
Timer = new System.Timers.Timer();
Timer.Interval = 20;
Timer.Elapsed += OnTimedEvent;
Timer.Enabled = true;
#endif
}
#if WINDOWS_UWP
private void LinphoneCoreIterate(ThreadPoolTimer timer) {
#else
private void LinphoneCoreIterate()
private void OnTimedEvent(object sender, System.Timers.ElapsedEventArgs e)
{
#if ANDROID
AndroidContext.RunOnUiThread(() => Core.Iterate());
#else
Device.BeginInvokeOnMainThread(() => Core.Iterate());
#endif
}
#if WINDOWS_UWP
private void LinphoneCoreIterate(ThreadPoolTimer timer) {
while (true)
{
#if WINDOWS_UWP
CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.High,
() => {
LinphoneCore.Iterate();
});
#else
Device.BeginInvokeOnMainThread(() =>
{
Core.Iterate();
});
Thread.Sleep(50);
#endif
CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.High, () => LinphoneCore.Iterate());
}
}
#endif
private void OnLog(LoggingService logService, string domain, LogLevel lev, string message)
{
......
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