Пример #1
0
 public frmSettings(RTCControl iConfRTCControl)
 {
     InitializeComponent();
     iconfRTC = iConfRTCControl;
     cbAudioDevices.SelectionChangeCommitted += SelectedDeviceValueChanged;
     cbVideoDevices.SelectionChangeCommitted += SelectedDeviceValueChanged;
 }
Пример #2
0
        public MainWindow()
        {
            InitializeComponent();

            //initilize webrtc
            RTC.Init();

            rtcControl = new RTCControl();

            currParticipants = new List <CurrentParticipants>();

            //setup events
            rtcControl.ErrorConnectSignaling  += RtcControl_ErrorConnectSignaling;
            rtcControl.ConnectedToSignaling   += RtcControl_ConnectedToSignaling;
            rtcControl.RTCInitialized         += WebRTCInitialized;
            rtcControl.UserJoinedMeeting      += RtcControl_UserJoinedMeeting;
            rtcControl.UserLeftMeeting        += RtcControl_UserLeftMeeting;
            rtcControl.ILeftMeeting           += RtcControl_ILeftMeeting;
            rtcControl.IJoinedMeeting         += RtcControl_IJoinedMeeting;
            rtcControl.MeetingMessageReceived += RtcControl_MeetingMessageReceived;


            model = new AppModel();

            this.DataContext = model;

            model.PropertyChanged += Model_PropertyChanged;


            //set the initial signaling url .. this is where our signalr server is running from
            model.SignalingUrl = System.Configuration.ConfigurationManager.AppSettings["SignalingUrl"];

            rtcControl.SignalingType = SignalingTypes.Socketio; //SignalingTypes.SignalR; // SignalingTypes.Socketio;
            rtcControl.SignalingUrl  = model.SignalingUrl;

            SetupCommands();

            ShowMessage("Initializing WebRTC", System.Windows.Media.Brushes.MediumBlue, true);

            rtcControl.Width  = 480;
            rtcControl.Height = 360;

            //we add our own video to the list of videos
            videoList.Children.Add(rtcControl);

            //we initialize webrtc - mandatory call!
        }
Пример #3
0
        //void h_InConference(iConfRTC.Shared.ConferenceEventArgs e)
        //{
        //    ShowMessage((e.userName == model.UserName ? "You " : e.userName) + " joined " + e.conferenceId);
        //    // MessageBox.Show("You (" + e.userName + ") have joined  conference  + e.conferenceId);
        //    h.EnableOverlay("In conference : " + e.conferenceId, "position:absolute;bottom:0px;color:#FFF;text-align:center;font-size:20px;background-color:rgba(221,221,221,0.3);width:640px;padding:10px0;z-index:2147483647;font-family: Verdana, Geneva, sans-serif;", true);
        //}

        private void ProcessParticipants(List <MeetingParticipants> participants, string sessionJoined, bool isSharing)
        {
            foreach (var participant in participants)
            {
                if (participant.Session != rtcControl.MySession) //you are already seeing yourself :)
                {
                    var sessionExists = currParticipants.Any(p => p.Session == participant.Session);

                    if (!sessionExists)
                    {
                        var viewer = new RTCControl
                        {
                            SignalingType = SignalingTypes.Socketio,
                            SignalingUrl  = model.SignalingUrl,
                            Height        = 360,
                            Width         = 480,
                            Visibility    = System.Windows.Visibility.Visible,
                            ToolTip       = participant.UserName,
                            MySession     = participant.Session
                        };

                        int elementPosition = videoList.Children.Add(viewer);
                        currParticipants.Add(new CurrentParticipants
                        {
                            Session         = participant.Session,
                            UserName        = participant.UserName,
                            ElementPosition = elementPosition,
                            Viewer          = viewer
                        });

                        MainWindow1.UpdateLayout();
                        AttachLoadingAdorner(viewer, participant.UserName);

                        //only call webrtc functions when WebRTC is ready!!
                        viewer.RTCInitialized += (((object a) =>
                        {
                            //you can add a turn server here
                            //viewer.AddIceServer(url: "numb.viagenie.ca", userName: "******", password: "******", clearFirst: false, type: "turn");
                            //viewer.AddIceServer("stun.voiparound.com");

                            //webrtc is ready, connect to signaling
                            viewer.ViewSession(participant.UserName, participant.Session);
                        }));
                    }
                }
            }
        }
Пример #4
0
        private void ProcessParticipants(List <MeetingParticipants> participants, string sessionJoined, bool isSharing)
        {
            foreach (var participant in participants)
            {
                if (participant.Session != rtcControl.MySession) //you are already seeing yourself :)
                {
                    var sessionExists = currParticipants.Any(p => p.Session == participant.Session);

                    if (!sessionExists)
                    {
                        var viewer = new RTCControl
                        {
                            SignalingType = SignalingTypes.Socketio,
                            SignalingUrl  = model.SignalingUrl,
                            Height        = 360,
                            Width         = 480,
                            Visibility    = System.Windows.Visibility.Visible,
                            ToolTip       = participant.UserName,
                            MySession     = participant.Session
                        };

                        int elementPosition = videoList.Children.Add(viewer);
                        currParticipants.Add(new CurrentParticipants
                        {
                            Session         = participant.Session,
                            UserName        = participant.UserName,
                            ElementPosition = elementPosition,
                            Viewer          = viewer
                        });

                        MainWindow1.UpdateLayout();
                        AttachLoadingAdorner(viewer, participant.UserName);

                        //only call webrtc functions when WebRTC is ready!!
                        viewer.RTCInitialized += (((object a) =>
                        {
                            viewer.ViewSession(participant.UserName, participant.Session);
                        }));
                    }
                }
            }
        }
Пример #5
0
        /// <summary>
        /// This is where we go through each participant and setup a viewer which is another instance of the iConfRTC control
        /// </summary>
        /// <param name="participants">the list of participants of the meeting</param>
        private void ProcessParticipants(List <MeetingParticipants> participants)
        {
            foreach (var participant in participants)
            {
                if (participant.Session != rtcControl.MySession)
                {
                    RTCControl viewer;
                    viewer = new RTCControl();
                    viewer.SignalingType = SignalingTypes.Socketio;// SignalingTypes.SignalR;// SignalingTypes.Socketio;
                    viewer.SignalingUrl  = model.SignalingUrl;
                    viewer.Height        = 360;
                    viewer.Width         = 480;


                    viewer.Visibility = System.Windows.Visibility.Visible;
                    viewer.ToolTip    = participant.UserName;
                    viewer.MySession  = participant.Session;



                    //check to see if we are already viewing the session
                    foreach (object item in videoList.Children)
                    {
                        if (item.GetType() == typeof(RTCControl))
                        {
                            var session = (item as RTCControl).MySession;
                            if (session != null)
                            {
                                if (session == participant.Session)
                                {
                                    return;
                                }
                                else
                                {
                                    continue;
                                }
                            }
                        }
                    }

                    int elementPosition = videoList.Children.Add(viewer);
                    currParticipants.Add(new CurrentParticipants {
                        Session = participant.Session, UserName = participant.UserName, ElementPosition = elementPosition, Viewer = viewer
                    });

                    MainWindow1.UpdateLayout();
                    AttachLoadingAdorner(viewer, participant.UserName, participant.Session);


                    ///only call webrtc functions when WebRTC is ready!!
                    viewer.RTCInitialized += (((object a) =>
                    {
                        //you can add a turn server here
                        //viewer.AddIceServer(url: "numb.viagenie.ca", userName: "******", password: "******", clearFirst: false, type: "turn");
                        //viewer.AddIceServer("stun.voiparound.com");

                        //webrtc is ready, connect to signaling
                        string ranUser = Helper.RandomString(8);
                        viewer.ViewSession(participant.Session);
                    }));
                }
            }
        }
Пример #6
0
        public FrmMain()
        {
            //Always intialize the WebRTC engine first!
            RTC.Init();

            InitializeComponent();

            currParticipants = new List <CurrentParticipants>();

            snd = new SoundPlayer();

            ShowStatus("Initializing RTC..");

            iconfRTC = new RTCControl {
                Dock = DockStyle.Fill
            };

            settings = new frmSettings(iconfRTC);

            //setup the signaling
            iconfRTC.SignalingUrl  = ConfigurationManager.AppSettings["SignalingUrl"];
            iconfRTC.SignalingType = SignalingTypes.Socketio;

            //logging
            iconfRTC.LoggingEnabled = true;
            iconfRTC.LogFilePath    = Path.GetTempPath() + @"\rtclog.txt";

            #region iConfRTC Events

            iconfRTC.DoubleClick            += IconfRTC_DoubleClick;
            iconfRTC.RTCInitialized         += IconfRTC_RTCInitialized;
            iconfRTC.IJoinedMeeting         += IconfRTC_IJoinedMeeting;
            iconfRTC.UserJoinedMeeting      += IconfRTC_UserJoinedMeeting;
            iconfRTC.UserLeftMeeting        += IconfRTC_UserLeftMeeting;
            iconfRTC.ILeftMeeting           += IconfRTC_ILeftMeeting;
            iconfRTC.NewDevices             += IconfRTC_NewDevices;
            iconfRTC.MeetingMessageReceived += IconfRTC_MeetingMessageReceived;

            #endregion


            var pnlMyViewerParent = new OutlookPanelEx()
            {
                Width = 480, Height = 360, Visible = true, HeaderText = ""
            };


            pnlMyViewerParent.Controls.Add(iconfRTC);



            pnlLayout.Controls.Add(pnlMyViewerParent);

            //rtf text  box for chat
            rtBox = new HtmlPanel {
                Parent = pnlFill, Dock = DockStyle.Fill, AutoScroll = true
            };

            chatFont = new Font(Font, FontStyle.Bold);

            pnlLayout.Show();

            PositionJoinPanel();
        }
Пример #7
0
        private void ProcessParticipants(List <MeetingParticipants> participants, string sessionJoined, bool isSharing)
        {
            //when a user joins a meeting we receive a list of meeting participants ( including yourself )
            //we go through the list , create viewers (RTCControls) for each participant and call ViewSession,
            //passing along the participant's sessionId

            foreach (var participant in participants)
            {
                if (participant.Session != iconfRTC.MySession) //you are already seeing yourself :)
                {
                    if (participant.UserName == "sharing-" + iconfRTC.MyUserName)
                    {
                        return;
                    }

                    var sessionExists = currParticipants.Any(p => p.Session == participant.Session);

                    if (!sessionExists)
                    {
                        var viewer = new RTCControl
                        {
                            SignalingType = SignalingTypes.Socketio,
                            SignalingUrl  = iconfRTC.SignalingUrl,
                            Dock          = DockStyle.Fill
                        };



                        var pnlViewerParent = new OutlookPanelEx()
                        {
                            Tag    = participant.Session,
                            Width  = 480,
                            Height = 360
                        };


                        pnlViewerParent.Controls.Add(viewer);

                        if (participant.Session == sessionJoined && isSharing)
                        {
                            //overlay sharing picturebox
                            var overlayPicture = new PictureBox
                            {
                                SizeMode = PictureBoxSizeMode.AutoSize,
                                Image    = pbSharing.Image,
                                Dock     = DockStyle.Fill,
                                Anchor   = AnchorStyles.Bottom | AnchorStyles.Right
                            };
                            overlayPicture.Show();
                            pnlViewerParent.Controls.Add(overlayPicture);
                            overlayPicture.BringToFront();
                            var workingArea = pnlViewerParent.Bounds;
                            overlayPicture.Location = new Point(workingArea.Right - Size.Width,
                                                                workingArea.Bottom - Size.Height);
                        }

                        pnlViewerParent.Visible    = true;
                        pnlViewerParent.HeaderText = participant.UserName;
                        pnlLayout.Controls.Add(pnlViewerParent);

                        currParticipants.Add(new CurrentParticipants
                        {
                            Session     = participant.Session,
                            UserName    = participant.UserName,
                            PanelLayout = pnlViewerParent,
                            RTCControl  = viewer
                        });


                        //only call webrtc functions when WebRTC is ready!!
                        viewer.RTCInitialized += a =>
                        {
                            //you can add additional ice servers if you'd like
                            //  viewer.AddIceServer(url: "numb.viagenie.ca", userName: "******", password: "******", clearFirst: false, type: "turn");
                            //viewer.AddIceServer("stun.voiparound.com");

                            //webrtc is ready, connect to signaling
                            viewer.ViewSession(participant.UserName, participant.Session);
                        };
                    }
                }
            }
        }