private void InitAndroidView(int width, int height)
        {
            captureCamera = new Org.Linphone.Mediastream.Video.Display.GL2JNIView(Context);

            var displayMetrics = new DisplayMetrics();
            var ctx            = Application.Context;
            var windowManager  = ctx.GetSystemService(Context.WindowService).JavaCast <IWindowManager>();

            windowManager.DefaultDisplay.GetMetrics(displayMetrics);

            int width_android  = (int)(width / (1f / displayMetrics.Density));
            int height_android = (int)(height / (1f / displayMetrics.Density));

            captureCamera.Holder.SetFixedSize(width_android, height_android);
            ViewGroup.LayoutParams cparams = new ViewGroup.LayoutParams(width_android, height_android);
            captureCamera.LayoutParameters = cparams;

            androidView = new AndroidVideoWindowImpl(captureCamera, null, null);

            androidVideoWindowListener = new AndroidVideoWindowListener();
            androidVideoWindowListener.OnVideoRenderingSurfaceReadyEvent     += OnVideoRenderingSurfaceReady;
            androidVideoWindowListener.OnVideoRenderingSurfaceDestroyedEvent += OnVideoRenderingSurfaceDestroyed;


            androidView.SetListener(androidVideoWindowListener);

            captureCamera.SetZOrderOnTop(false);
            captureCamera.SetZOrderMediaOverlay(true);
        }
 public void OnVideoRenderingSurfaceDestroyed(AndroidVideoWindowImpl p0)
 {
     OnVideoRenderingSurfaceDestroyedEvent?.Invoke(
         this,
         new AndroidVideoWindowListenerArgs
     {
         androidVideoWindowImpl = p0,
     });
 }
 public void OnVideoRenderingSurfaceReady(AndroidVideoWindowImpl p0, SurfaceView p1)
 {
     OnVideoRenderingSurfaceReadyEvent?.Invoke(
         this,
         new AndroidVideoWindowListenerArgs
     {
         androidVideoWindowImpl = p0,
         surfaceView            = p1
     });
 }
Exemplo n.º 4
0
        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);
        }
 public void OnVideoPreviewSurfaceReady(AndroidVideoWindowImpl p0, SurfaceView p1)
 {
 }
 public void OnVideoPreviewSurfaceDestroyed(AndroidVideoWindowImpl p0)
 {
 }
Exemplo n.º 7
0
        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);
        }