Beispiel #1
0
        public VideoCallView(CGRect _frame, bool _useCameraPreview) : base(_frame)
        {
            RemoteView = new RTCEAGLVideoView
            {
                Delegate = this
            };
            AddSubview(RemoteView);

            if (_useCameraPreview)
            {
                LocalVideoView = new RTCCameraPreviewView();
            }
            else
            {
                LocalVideoView = new RTCEAGLVideoView
                {
                    Delegate = this
                };
            }
            AddSubview(LocalVideoView);

            StatsView        = new StatsView(_frame);
            StatsView.Hidden = true;
            AddSubview(StatsView);

            routeChangeBtn = new UIButton(UIButtonType.InfoDark);
            routeChangeBtn.TouchUpInside += OnRouteChanged;
            AddSubview(routeChangeBtn);

            cameraSwitchBtn = new UIButton(UIButtonType.DetailDisclosure);
            cameraSwitchBtn.TouchUpInside += OnCameraSwitched;
            AddSubview(cameraSwitchBtn);

            hangUpBtn = new UIButton(UIButtonType.Close);
            hangUpBtn.TouchUpInside += OnHangup;
            AddSubview(hangUpBtn);

            StatusLabel           = new UILabel();
            StatusLabel.Font      = UIFont.SystemFontOfSize(16);
            StatusLabel.TextColor = UIColor.White;
            AddSubview(StatusLabel);

            var tapRecognizer = new UITapGestureRecognizer(DidTripleTapped);

            tapRecognizer.NumberOfTapsRequired = 3;

            AddGestureRecognizer(tapRecognizer);
        }
Beispiel #2
0
        public override void LayoutSubviews()
        {
            base.LayoutSubviews();

            var bounds = Bounds;

            if (remoteVideoSize.Width > 0 && remoteVideoSize.Height > 0)
            {
                // Aspect fill remote video into bounds.

                var    remoteVideoFrame = bounds.WithAspectRatio(remoteVideoSize);
                nfloat scale            = 1f;
                if (remoteVideoFrame.Size.Width > remoteVideoFrame.Size.Height)
                {
                    // Scale by height.
                    scale = bounds.Size.Height / remoteVideoFrame.Size.Height;
                }
                else
                {
                    // Scale by width.
                    scale = bounds.Size.Width / remoteVideoFrame.Size.Width;
                }

                remoteVideoFrame.Size = new CGSize(remoteVideoFrame.Size.Width * scale, remoteVideoFrame.Size.Height * scale);
                RemoteView.Frame      = remoteVideoFrame;
                RemoteView.Center     = new CGPoint(bounds.GetMidX(), bounds.GetMidY());
            }
            else
            {
                RemoteView.Frame = bounds;
            }
            // Aspect fit local video view into a square box.
            var localVideoFrame = new CGRect(0, 0, kLocalVideoViewSize, kLocalVideoViewSize);

            // Place the view in the bottom right.
            localVideoFrame.Location = new CGPoint(
                bounds.GetMaxX() - localVideoFrame.Size.Width - kLocalVideoViewPadding, bounds.GetMaxY() - localVideoFrame.Size.Height - kLocalVideoViewPadding - AppDelegate.SafeAreaInsets.Top);

            LocalVideoView.Frame = localVideoFrame;

            // Place stats at the top.
            var statsSize = StatsView.SizeThatFits(bounds.Size);

            StatsView.Frame = new CGRect(bounds.GetMinX(), bounds.GetMinY() + kStatusBarHeight + AppDelegate.SafeAreaInsets.Top, statsSize.Width, statsSize.Height);

            // Place hangup button in the bottom left.
            hangUpBtn.Frame = new CGRect(bounds.GetMinX() + kButtonPadding, bounds.GetMaxY() - kButtonPadding - kButtonSize - AppDelegate.SafeAreaInsets.Bottom, kButtonSize, kButtonSize);

            // Place button to the right of hangup button.
            var cameraSwitchFrame = hangUpBtn.Frame;

            cameraSwitchFrame.Location = new CGPoint(cameraSwitchFrame.GetMaxX() + kButtonPadding, cameraSwitchFrame.Location.Y);
            cameraSwitchBtn.Frame      = cameraSwitchFrame;

            // Place route button to the right of camera button.
            var routeChangeFrame = cameraSwitchBtn.Frame;

            routeChangeFrame.Location = new CGPoint(routeChangeFrame.GetMaxX() + kButtonPadding, routeChangeFrame.Location.Y);
            routeChangeBtn.Frame      = routeChangeFrame;

            StatusLabel.SizeToFit();
            StatusLabel.Center = new CGPoint(bounds.GetMidX(), bounds.GetMidY());
        }