示例#1
0
        /// <summary>
        /// This method is called when participant closes source.
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="e">Event data.</param>
        private void Participant_SourceRemoved(object sender,RTP_SourceEventArgs e)
        {
            if(m_IsDisposed){
                return;
            }

            // Get SSRC here, BeginInvoke is anynchronous and source may dispose at same time.
            uint ssrc = e.Source.SSRC;

            // Move processing to UI thread.
            this.BeginInvoke(new MethodInvoker(delegate(){
                TreeNode nodeParticipant = FindParticipantNode((RTP_Participant)sender);
                if(nodeParticipant != null){
                    foreach(TreeNode nodeSource in nodeParticipant.Nodes[0].Nodes){
                        if(nodeSource.Text == ssrc.ToString()){
                            nodeSource.Remove();
                            break;
                        }
                    }
                }
            }));
        }
示例#2
0
        /// <summary>
        /// This method is called when participant creates new source. 
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="e">Event data.</param>
        private void Participant_SourceAdded(object sender,RTP_SourceEventArgs e)
        {
            if(m_IsDisposed){
                return;
            }

            e.Source.StateChanged += new EventHandler(Source_StateChanged);

            // Move processing to UI thread.
            this.BeginInvoke(new MethodInvoker(delegate(){
                TreeNode nodeParticipant = null;
                if(e.Source is RTP_Source_Remote){
                    nodeParticipant = FindParticipantNode(((RTP_Source_Remote)e.Source).Participant);
                }
                else{
                    nodeParticipant = FindParticipantNode(((RTP_Source_Local)e.Source).Participant);
                }
                TreeNode nodeSource = nodeParticipant.Nodes[0].Nodes.Add(e.Source.SSRC.ToString());
                nodeSource.Tag = new RTP_SourceInfo(e.Source);

                if(e.Source.State == RTP_SourceState.Active){
                    TreeNode nodeSourceStream = nodeSource.Nodes.Add("RTP Stream");
                    if(e.Source is RTP_Source_Local){
                        nodeSourceStream.Tag = new RTP_SendStreamInfo(((RTP_Source_Local)e.Source).Stream);
                    }
                    else{
                        nodeSourceStream.Tag = new RTP_ReceiveStreamInfo(((RTP_Source_Remote)e.Source).Stream);
                    }
                }
            }));
        }