Esempio n. 1
0
        public ARDVideoCallView(CGRect frame) : base(frame)
        {
            RemoteView = new RTCEAGLVideoView
            {
                Delegate = this
            };

            AddSubview(RemoteView);

            LocalVideoView = new RTCCameraPreviewView();
            AddSubview(LocalVideoView);

            StatsView        = new ARDStatsView(CGRect.Empty);
            StatsView.Hidden = true;
            AddSubview(StatsView);

            _routeChangeButton = new UIButton(UIButtonType.Custom);
            _routeChangeButton.BackgroundColor     = UIColor.White;
            _routeChangeButton.Layer.CornerRadius  = kButtonSize / 2;
            _routeChangeButton.Layer.MasksToBounds = true;
            _routeChangeButton.SetImage(UIImage.FromBundle("ic_surround_sound_black_24dp.png"), UIControlState.Normal);
            _routeChangeButton.TouchUpInside += OnRouteChange;
            AddSubview(_routeChangeButton);


            _cameraSwitchButton = new UIButton(UIButtonType.Custom);
            _cameraSwitchButton.BackgroundColor     = UIColor.White;
            _cameraSwitchButton.Layer.CornerRadius  = kButtonSize / 2;
            _cameraSwitchButton.Layer.MasksToBounds = true;
            _cameraSwitchButton.SetImage(UIImage.FromBundle("ic_switch_video_black_24dp.png"), UIControlState.Normal);
            _cameraSwitchButton.TouchUpInside += OnCameraSwitch;
            AddSubview(_cameraSwitchButton);

            _hangupButton = new UIButton(UIButtonType.Custom);
            _hangupButton.BackgroundColor     = UIColor.White;
            _hangupButton.Layer.CornerRadius  = kButtonSize / 2;
            _hangupButton.Layer.MasksToBounds = true;
            _hangupButton.SetImage(UIImage.FromBundle("ic_call_end_black_24dp.png").ChangeColor(UIColor.Red), UIControlState.Normal);
            _hangupButton.TouchUpInside += OnHangup;
            AddSubview(_hangupButton);

            StatusLabel           = new UILabel();
            StatusLabel.Font      = UIFont.FromName("Roboto", 16);
            StatusLabel.TextColor = UIColor.White;
            AddSubview(StatusLabel);

            var tapRecognizer = new UITapGestureRecognizer(DidTripleTap);

            tapRecognizer.NumberOfTapsRequired = 3;

            AddGestureRecognizer(tapRecognizer);
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
        void SetupUI()
        {
            var width  = View.Frame.Width;
            var height = View.Frame.Height;
            int y      = 0;

            remoteView                = new RTCEAGLVideoView(new CGRect(0, y, width, height));
            y                         = y + 100;
            localView                 = new RTCEAGLVideoView(new CGRect(0, y, width, 100));
            localView.Hidden          = true;
            y                         = y + 200;
            buttonContainerView       = new UIView();
            buttonContainerView.Frame = new CGRect(0, y, width, 100);

            audioButton = UIButton.FromType(UIButtonType.RoundedRect);
            audioButton.SetTitle("audio", UIControlState.Normal);
            audioButton.TouchUpInside += AudioButton_TouchUpInside;

            videoButton = UIButton.FromType(UIButtonType.RoundedRect);
            videoButton.SetTitle("video", UIControlState.Normal);
            videoButton.TouchUpInside += VideoButton_TouchUpInside;

            hangupButton = UIButton.FromType(UIButtonType.RoundedRect);
            hangupButton.SetTitle("hang-up", UIControlState.Normal);
            hangupButton.TouchUpInside += HangupButton_TouchUpInside;

            buttonContainerView.Add(audioButton);
            buttonContainerView.Add(videoButton);
            buttonContainerView.Add(hangupButton);

            urlLabel = new UILabel {
                TextColor = UIColor.White
            };

            y = y + 100;
            urlLabel.Frame = new CGRect(0, y, width, 100);

            Add(remoteView);
            Add(localView);
            Add(buttonContainerView);
            Add(urlLabel);
        }
Esempio n. 4
0
        public void DidReceiveLocalVideoTrack(RTCVideoTrack localVideoTrack)
        {
            _localVideoTrack = localVideoTrack;
            if (ObjCRuntime.Runtime.Arch == ObjCRuntime.Arch.SIMULATOR)
            {
                var localView = new RTCEAGLVideoView();
                View.AddSubview(localView);

                var bounds          = View.Bounds;
                var localVideoFrame = new CGRect(0, 0, 100f, 100f);
                // Place the view in the bottom right.
                localVideoFrame.Location = new CGPoint(
                    bounds.GetMaxX() - localVideoFrame.Size.Width - 8, bounds.GetMaxY() - localVideoFrame.Size.Height - 8 - AppDelegate.SafeAreaInsets.Top);

                localView.Frame = localVideoFrame;


                _localVideoTrack.AddRenderer(localView);
            }
        }
Esempio n. 5
0
        public void DidChangeVideoSize(RTCEAGLVideoView videoView, CGSize size)
        {
            UIDeviceOrientation orientation = UIDevice.CurrentDevice.Orientation;

            UIView.Animate(0.4f, () =>
            {
                var containerWidth     = View.Frame.Size.Width;
                var containerHeight    = View.Frame.Size.Height;
                var defaultAspectRatio = new CGSize(4, 3);

                CGSize aspectRatio = size.IsEmpty ? defaultAspectRatio : size;
                CGRect videoRect   = View.Bounds;
                if (videoView == localView)
                {
                    //Resize the Local View depending if it is full screen or thumbnail
                    localVideoSize = size;

                    if (remoteVideoTrack != null)
                    {
                        videoRect = new CGRect(0.0f, 0.0f, containerWidth / 4.0f, containerHeight / 4.0f);
                        if (orientation == UIDeviceOrientation.LandscapeLeft || orientation == UIDeviceOrientation.LandscapeRight)
                        {
                            videoRect = new CGRect(0.0f, 0.0f, containerHeight / 4.0f, containerWidth / 4.0f);
                        }
                    }
                    CGRect videoFrame = AVFoundation.AVUtilities.WithAspectRatio(videoRect, aspectRatio);                     //AVMakeRectWithAspectRatioInsideRect(aspectRatio, videoRect);


                    //			//Resize the localView accordingly
                    //			[self.localViewWidthConstraint setConstant: videoFrame.size.width];

                    //			[self.localViewHeightConstraint setConstant:videoFrame.size.height];
                    //            if (self.remoteVideoTrack) {
                    //                [self.localViewBottomConstraint setConstant:28.0f]; //bottom right corner
                    //                [self.localViewRightConstraint setConstant:28.0f];
                    //            } else {
                    //                [self.localViewBottomConstraint setConstant:containerHeight/2.0f - videoFrame.size.height/2.0f]; //center
                    //                [self.localViewRightConstraint setConstant:containerWidth/2.0f - videoFrame.size.width/2.0f]; //center
                    //            }
                }
                else if (videoView == remoteView)
                {
                    //Resize Remote View
                    remoteVideoSize = size;

                    CGRect videoFrame = AVFoundation.AVUtilities.WithAspectRatio(videoRect, aspectRatio);                     //AVMakeRectWithAspectRatioInsideRect(aspectRatio, videoRect);
                    if (isZoom)
                    {
                        //Set Aspect Fill
                        var scale = Math.Max(containerWidth / videoFrame.Size.Width, containerHeight / videoFrame.Size.Height);

                        var newSize = new CGSize(videoFrame.Size.Width * scale, videoFrame.Size.Height * scale);

                        //videoFrame.Size.Width *= scale;
                        //videoFrame.size.height *= scale;
                        videoFrame.Size = newSize;
                    }
                    //            [self.remoteViewTopConstraint setConstant:containerHeight/2.0f - videoFrame.size.height/2.0f];
                    //            [self.remoteViewBottomConstraint setConstant:containerHeight/2.0f - videoFrame.size.height/2.0f];
                    //            [self.remoteViewLeftConstraint setConstant:containerWidth/2.0f - videoFrame.size.width/2.0f]; //center
                    //            [self.remoteViewRightConstraint setConstant:containerWidth/2.0f - videoFrame.size.width/2.0f]; //center
                }
                View.LayoutIfNeeded();
            });
        }
Esempio n. 6
0
 public override void DidChangeVideoSize(RTCEAGLVideoView videoView, CGSize size)
 {
 }