protected override void OnCreate(Bundle bundle) { Java.Lang.JavaSystem.LoadLibrary("bctoolbox"); Java.Lang.JavaSystem.LoadLibrary("ortp"); Java.Lang.JavaSystem.LoadLibrary("mediastreamer_base"); Java.Lang.JavaSystem.LoadLibrary("mediastreamer_voip"); Java.Lang.JavaSystem.LoadLibrary("linphone"); // This is mandatory for Android LinphoneAndroid.setAndroidContext(JNIEnv.Handle, this.Handle); TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; base.OnCreate(bundle); AssetManager assets = Assets; string path = FilesDir.AbsolutePath; string rc_path = path + "/default_rc"; using (var br = new BinaryReader(Application.Context.Assets.Open("linphonerc_default"))) { using (var bw = new BinaryWriter(new FileStream(rc_path, FileMode.Create))) { byte[] buffer = new byte[2048]; int length = 0; while ((length = br.Read(buffer, 0, buffer.Length)) > 0) { bw.Write(buffer, 0, length); } } } global::Xamarin.Forms.Forms.Init(this, bundle); application = new App(rc_path); captureCamera = new Org.Linphone.Mediastream.Video.Display.GL2JNIView(this); captureCamera.Holder.SetFixedSize(1920, 1080); AndroidVideoWindowImpl androidView = new AndroidVideoWindowImpl(captureCamera, null, null); application.LinphoneCore.NativeVideoWindowId = androidView.Handle; application.LinphoneCore.VideoDisplayEnabled = true; application.getLayoutView().Children.Add(captureCamera); LoadApplication(application); }
protected override void OnCreate(Bundle bundle) { Java.Lang.JavaSystem.LoadLibrary("bctoolbox"); Java.Lang.JavaSystem.LoadLibrary("ortp"); Java.Lang.JavaSystem.LoadLibrary("mediastreamer_base"); Java.Lang.JavaSystem.LoadLibrary("mediastreamer_voip"); Java.Lang.JavaSystem.LoadLibrary("linphone"); // This is mandatory for Android LinphoneAndroid.setAndroidContext(JNIEnv.Handle, this.Handle); TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; base.OnCreate(bundle); AssetManager assets = Assets; string path = FilesDir.AbsolutePath; string rc_path = path + "/default_rc"; using (var br = new BinaryReader(Application.Context.Assets.Open("linphonerc_default"))) { using (var bw = new BinaryWriter(new FileStream(rc_path, FileMode.Create))) { byte[] buffer = new byte[2048]; int length = 0; while ((length = br.Read(buffer, 0, buffer.Length)) > 0) { bw.Write(buffer, 0, length); } } } Xamarin.Forms.Forms.Init(this, bundle); LoadApplication(new App(rc_path)); }
public static void Start() { Java.Lang.JavaSystem.LoadLibrary("c++_shared"); Java.Lang.JavaSystem.LoadLibrary("bctoolbox"); Java.Lang.JavaSystem.LoadLibrary("ortp"); Java.Lang.JavaSystem.LoadLibrary("mediastreamer"); Java.Lang.JavaSystem.LoadLibrary("linphone"); // This is mandatory for Android LinphoneAndroid.setAndroidContext(JNIEnv.Handle, Application.Context.Handle); AssetManager assets = Application.Context.Assets; string path = Application.Context.FilesDir.AbsolutePath; string rc_path = path + "/default_rc"; string ca_path = path + "/rootca.pem"; using (var br = new BinaryReader(Application.Context.Assets.Open("linphonerc_default"))) { using (var bw = new BinaryWriter(new FileStream(rc_path, FileMode.Create))) { byte[] buffer = new byte[2048]; int length = 0; while ((length = br.Read(buffer, 0, buffer.Length)) > 0) { bw.Write(buffer, 0, length); } } RcPath = rc_path; CaPath = ca_path; } string factory_path = path + "/factory_rc"; if (!File.Exists(factory_path)) { using (StreamReader sr = new StreamReader(assets.Open("linphonerc_factory"))) { string content = sr.ReadToEnd(); File.WriteAllText(factory_path, content); } } FactoryPath = factory_path; //ScheduleJob(); //var startServiceIntent = new Intent(Application.Context, typeof(LinphoneJobService)); //Application.Context.StartService(startServiceIntent); if (Int32.Parse(global::Android.OS.Build.VERSION.Sdk) >= 23) { List <string> Permissions = new List <string>(); if (Application.Context.CheckSelfPermission(Manifest.Permission.RecordAudio) != Permission.Granted) { Permissions.Add(Manifest.Permission.RecordAudio); } if (Permissions.Count > 0) { var currentActivity = (Activity)Xamarin.Forms.Forms.Context; currentActivity.RequestPermissions(Permissions.ToArray(), PERMISSIONS_REQUEST); } } }
protected override void OnCreate(Bundle bundle) { Java.Lang.JavaSystem.LoadLibrary("c++_shared"); Java.Lang.JavaSystem.LoadLibrary("bctoolbox"); Java.Lang.JavaSystem.LoadLibrary("ortp"); Java.Lang.JavaSystem.LoadLibrary("mediastreamer_base"); Java.Lang.JavaSystem.LoadLibrary("mediastreamer_voip"); Java.Lang.JavaSystem.LoadLibrary("linphone"); // This is mandatory for Android LinphoneAndroid.setAndroidContext(JNIEnv.Handle, this.Handle); TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; base.OnCreate(bundle); AssetManager assets = Assets; string path = FilesDir.AbsolutePath; string rc_path = path + "/default_rc"; if (!File.Exists(rc_path)) { using (StreamReader sr = new StreamReader(assets.Open("linphonerc_default"))) { string content = sr.ReadToEnd(); File.WriteAllText(rc_path, content); } } string factory_path = path + "/factory_rc"; if (!File.Exists(factory_path)) { using (StreamReader sr = new StreamReader(assets.Open("linphonerc_factory"))) { string content = sr.ReadToEnd(); File.WriteAllText(factory_path, content); } } global::Xamarin.Forms.Forms.Init(this, bundle); App.ConfigFilePath = rc_path; App.FactoryFilePath = factory_path; App app = new App(); // Do not add an arg to App constructor app.Manager.AndroidContext = this; LinearLayout fl = new LinearLayout(this); ViewGroup.LayoutParams lparams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent); fl.LayoutParameters = lparams; displayCamera = new Org.Linphone.Mediastream.Video.Display.GL2JNIView(this); ViewGroup.LayoutParams dparams = new ViewGroup.LayoutParams(640, 480); displayCamera.LayoutParameters = dparams; displayCamera.Holder.SetFixedSize(640, 480); captureCamera = new SurfaceView(this); ViewGroup.LayoutParams cparams = new ViewGroup.LayoutParams(320, 240); captureCamera.LayoutParameters = cparams; captureCamera.Holder.SetFixedSize(240, 320); fl.AddView(displayCamera); fl.AddView(captureCamera); AndroidVideoWindowImpl androidView = new AndroidVideoWindowImpl(displayCamera, captureCamera, null); app.Core.NativeVideoWindowId = androidView.Handle; app.Core.NativePreviewWindowId = captureCamera.Handle; app.getLayoutView().Children.Add(fl); app.Core.VideoDisplayEnabled = true; app.Core.VideoCaptureEnabled = true; LoadApplication(app); }