Exemplo n.º 1
0
        private void OnNewRtpParticipant(object sender, RtpEvents.RtpParticipantEventArgs ea)
        {
            if (this.rtpSession != sender)
            {
                return;
            }

            RtpParticipant participant = ea.RtpParticipant;

            Trace.WriteLine("New participant: " + participant.CName);

            // we want to ignore ourselves
            if (participant.CName != Constants.PersistenceCName)
            {
                // Make sure this isn't someone who briefly lost connectivity.
                if (!participants.ContainsKey(participant.CName))
                {
                    string newPartName = participant.Name;
                    if (newPartName == null || newPartName == String.Empty)
                    {
                        newPartName = participant.CName;
                    }

                    int participantID = DBHelper.CreateParticipant(
                        conferenceID,
                        participant.CName,
                        newPartName);

                    participants.Add(participant.CName, new ParticipantWrapper(participant, participantID));
                }

                foreach (uint ssrc in participant.SSRCs)
                {
                    OnNewRtpStream(sender, new RtpEvents.RtpStreamEventArgs(rtpSession.Streams[ssrc]));
                }
            }
        }
        private void OnNewRtpParticipant(object sender, RtpEvents.RtpParticipantEventArgs ea)
        {
            try {
                RtpParticipant participant = ea.RtpParticipant;

                eventLog.WriteEntry("OnNewRtpParticipant: " + participant.CName,
                                    EventLogEntryType.Information, ArchiveServiceEventLog.ID.Information);

                if (this.rtpSession != sender)
                {
                    eventLog.WriteEntry("OnNewRtpParticipant: this.rtpSession and sender don't match.",
                                        EventLogEntryType.Information, ArchiveServiceEventLog.ID.Information);
                    if (this.rtpSession == null)
                    {
                        //Note this can happen because participants are added during the rtpSession constructor!!
                        eventLog.WriteEntry("OnNewRtpParticipant: this.rtpSession is null.",
                                            EventLogEntryType.Information, ArchiveServiceEventLog.ID.Information);
                    }
                    if (sender == null)
                    {
                        eventLog.WriteEntry("OnNewRtpParticipant: sender is null.",
                                            EventLogEntryType.Information, ArchiveServiceEventLog.ID.Information);
                    }
                    //return;
                }

                //eventLog.WriteEntry(string.Format(CultureInfo.CurrentCulture, "New participant: {0}", participant.CName));

                // we want to ignore ourselves
                if (participant.CName != Constants.PersistenceCName)
                {
                    // Make sure this isn't someone who briefly lost connectivity.
                    if (!participants.ContainsKey(participant.CName))
                    {
                        string newPartName = participant.Name;
                        if (newPartName == null || newPartName == String.Empty)
                        {
                            newPartName = participant.CName;
                        }

                        int participantID = DBHelper.CreateParticipant(
                            conferenceID,
                            participant.CName,
                            newPartName);

                        participants.Add(participant.CName, new ParticipantWrapper(participant, participantID));

                        eventLog.WriteEntry("OnNewRtpParticipant completed participant Add.",
                                            EventLogEntryType.Information, ArchiveServiceEventLog.ID.Information);
                    }
                    else
                    {
                        eventLog.WriteEntry("OnNewRtpParticipant already in participants hashtable ",
                                            EventLogEntryType.Information, ArchiveServiceEventLog.ID.Information);
                    }

                    foreach (uint ssrc in participant.SSRCs)
                    {
                        if (this.rtpSession == null)
                        {
                            eventLog.WriteEntry("OnNewRtpParticipant: Failed to add streams because this.rtpSession is null.",
                                                EventLogEntryType.Warning, ArchiveServiceEventLog.ID.Warning);
                        }
                        else
                        {
                            OnNewRtpStream(this.rtpSession, new RtpEvents.RtpStreamEventArgs(rtpSession.Streams[ssrc]));
                        }
                    }
                }
                else
                {
                    eventLog.WriteEntry("OnNewRtpParticipant ignoring ourself. ",
                                        EventLogEntryType.Information, ArchiveServiceEventLog.ID.Information);
                }
            }
            catch (Exception e) {
                eventLog.WriteEntry("OnNewRtpParticipant exception: " + e.ToString(),
                                    EventLogEntryType.Warning, ArchiveServiceEventLog.ID.Warning);
            }
        }