Esempio n. 1
0
        public Future <FM.IceLink.LocalMedia> StopLocalMedia()
        {
            return(Promise <FM.IceLink.LocalMedia> .WrapPromise <FM.IceLink.LocalMedia>(() =>
            {
                if (LocalCameraMedia == null && LocalScreenMedia == null)
                {
                    return Promise <FM.IceLink.LocalMedia> .ResolveNow <FM.IceLink.LocalMedia>(null);
                }

                // Stop the local media.
                if (LocalScreenMedia != null)
                {
                    return LocalScreenMedia.Stop();
                }
                else
                {
                    return LocalCameraMedia.Stop();
                }
            }).Then((o) =>
            {
                // Tear down the layout manager.
                var layoutManager = LayoutManager;
                if (layoutManager != null)
                {
                    layoutManager.RemoveRemoteViews();
                    layoutManager.UnsetLocalView();
                    LayoutManager = null;
                }

                // Tear down the local camera media.
                if (LocalCameraMedia != null)
                {
                    LocalCameraMedia.Destroy(); // LocalCameraMedia.Destroy() will also destroy AecContext.
                    LocalCameraMedia = null;
                }

                // Tear down the local screen media.
                if (LocalScreenMedia != null)
                {
                    LocalScreenMedia.Destroy(); // LocalScreenMedia.Destroy() will also destroy AecContext.
                    LocalScreenMedia = null;
                }
            }));
        }
Esempio n. 2
0
        public Future <FM.IceLink.LocalMedia> StartLocalMedia(Android.Content.Context context, AbsoluteLayout container)
#endif
        {
            return(_certificatePromise.Then <FM.IceLink.LocalMedia>((cert) =>
            {
                _certificate = cert;

                if (!EnableAudioSend && !EnableVideoSend)
                {
                    LayoutManager = new XamarinLayoutManager(container);

                    return Promise <FM.IceLink.LocalMedia> .ResolveNow <FM.IceLink.LocalMedia>(null);
                }
                else
                {
                    Xamarin.Forms.View localView;
                    // Set up the local media.
                    if (!EnableScreenShare)
                    {
#if __IOS__
                        LocalCameraMedia = new LocalCameraMedia(!EnableAudioSend, !EnableVideoSend, null);
#else
                        if (EnableAudioSend)
                        {
                            _AecContext = new AecContext();
                            LocalCameraMedia = new LocalCameraMedia(context, !EnableAudioSend, !EnableVideoSend, _AecContext);
                        }
                        else
                        {
                            LocalCameraMedia = new LocalCameraMedia(context, !EnableAudioSend, !EnableVideoSend, null);
                        }
#endif
                        localView = new FMView(((LocalCameraMedia)LocalCameraMedia).GetView());
                    }
                    else
                    {
#if __IOS__
                        LocalScreenMedia = new LocalScreenMedia(!EnableAudioSend, !EnableVideoSend, null);
#else
                        if (EnableAudioSend)
                        {
                            _AecContext = new AecContext();
                            LocalScreenMedia = new LocalScreenMedia(MediaProjection, context, !EnableAudioSend, !EnableVideoSend, _AecContext);
                        }
                        else
                        {
                            LocalScreenMedia = new LocalScreenMedia(MediaProjection, context, !EnableAudioSend, !EnableVideoSend, null);
                        }
#endif
                        localView = new FMView(LocalScreenMedia.View);
                    }

                    // Set up the layout manager.
                    LayoutManager = new XamarinLayoutManager(container);

                    // Add the local preview to the layout.
                    if (localView != null)
                    {
                        LayoutManager.SetLocalView(localView);

                        // TODO Context menu
                        //LocalMedia.View.ContextMenu = videoChat.LocalContextMenu;
                    }

                    // Start the local media.
                    if (!EnableScreenShare)
                    {
                        return LocalCameraMedia.Start();
                    }
                    else
                    {
                        return LocalScreenMedia.Start();
                    }
                }
            }));
        }