/// <summary> /// Queue a work item to be called by a background thread /// </summary> /// <param name="waitCallback">WaitCallback delegate to be invoked</param> /// <param name="parameters">Array of objects to pass as parameters</param> internal static void QueueUserWorkItem(RtpEvents.RaiseEvent del, object[] parameters) { syncWorkItems.Enqueue(new WorkItem(del, parameters)); if( peakQueueLength < syncWorkItems.Count ) peakQueueLength = syncWorkItems.Count; newWorkItem.Set(); }
internal void RaiseFrameReceivedEvent(object[] args) { if (!RtpEvents.FireEvent(FrameReceived, args)) { FrameReceivedEventArgs ea = (FrameReceivedEventArgs)args[1]; eventLog.WriteEntry("FrameReceivedEvent - " + ea.RtpStream.SSRC, EventLogEntryType.Warning, (int)RtpEL.ID.FrameReceived); } }
internal void RaiseFrameReceivedEvent(object[] args) { if (!RtpEvents.FireEvent(FrameReceived, args)) { FrameReceivedEventArgs ea = (FrameReceivedEventArgs)args[1]; eventLog.WriteEntry(string.Format(CultureInfo.CurrentCulture, Strings.FrameReceivedEvent, ea.RtpStream.SSRC), EventLogEntryType.Warning, (int)RtpEL.ID.FrameReceived); } }
static void OnNewRtpStream(object sender, RtpEvents.RtpStreamEventArgs ea) { Console.Out.WriteLine("New RTP stream"); if (session != sender) return; RtpStream stream = ea.RtpStream; stream.FrameReceived += new RtpStream.FrameReceivedEventHandler(stream_FrameReceived); }
private void RtpReceiverReport(object sender, RtpEvents.ReceiverReportEventArgs ea) { // We'll take a receiver report from any RtpSession if(ea.SenderCName != cName) { if (ea.SourceCName == cName) { networkSend = true; } } }
private static void _RtpStreamAdded(object sender, RtpEvents.RtpStreamEventArgs ea) { Debug.Assert(Conference.ActiveVenue != null); lock(Conference.ActiveVenue) { ICapabilityViewer iCV = null; Guid capabilityKey = Capability.IDFromRtpStream(ea.RtpStream); if (capabilityViewers.ContainsKey(capabilityKey)) { iCV = (ICapabilityViewer)capabilityViewers[capabilityKey]; if (iCV.Owned && iCV.Owner == null) { // The owner is unknown, and this stream may contain the owner info; if so, set it Capability.CapabilityType ctype = Capability.ChannelFromRtpStream(ea.RtpStream); if (ctype == Capability.CapabilityType.Owned) // The owned type designates that the stream is coming from the Owner { iCV.Owner = participants[ea.RtpStream.Properties.CName]; iCV.Owner.AddCapabilityViewer(iCV); } } iCV.StreamAdded(ea.RtpStream); } else { // Try to convert an existing ICapabilitySender into an ICapabilityViewer if it exists... if (capabilitySenders.ContainsKey(capabilityKey)) { iCV = capabilitySenders[capabilityKey] as ICapabilityViewer; } if (iCV == null) // None found, create a new CapabilityViewer from scratch { iCV = Conference.CreateCapabilityForRtpStream(ea.RtpStream); } // Make sure we add the stream first before calling RaiseCapabilityViewerAdded so that ICapability.Owner will be set when CapabilityViewerAdded is handled iCV.StreamAdded(ea.RtpStream); AddCapabilityViewer(iCV); } Conference.RaiseCapabilityParticipantAdded(iCV, participants[ea.RtpStream.Properties.CName]); } }
private static void _RtpParticipantAdded(object sender, RtpEvents.RtpParticipantEventArgs ea) { Debug.Assert(Conference.ActiveVenue != null); string identifier = ea.RtpParticipant.CName; Participant participant = null; lock(Conference.ActiveVenue) { if (Conference.participants.ContainsKey(identifier)) { participant = (Participant)participants[identifier]; } } // Do the expensive call outside the lock if( participant == null ) { participant = venues.GetParticipant( ea.RtpParticipant.CName, ea.RtpParticipant.Name, ea.RtpParticipant.Email, ea.RtpParticipant.Phone ); } lock(Conference.ActiveVenue) { // If there is a long delay at the Venue Server, this participant could have exited and come back // already, so they may be already in the venue as well, the Venue may have been exited. if (!participants.ContainsKey(participant.Identifier)) { participants.Add(participant.Identifier, participant); } try { if (ParticipantAdded != null) { FormInvoke(ParticipantAdded, new object[] { participant } ); } if (logActivity) { eventLog.WriteEntry("Added " + participant.ToString(), EventLogEntryType.Information, 1); } } catch (ThreadAbortException) {} catch (Exception e) { eventLog.WriteEntry(e.ToString(),EventLogEntryType.Error, 99); } } }
private static void RtpStreamRemoved(object sender, RtpEvents.RtpStreamEventArgs ea) { // Filter out events from other RtpSession instances if (sender == RtpSession) { Conference.FormInvoke(new RtpEvents.RtpStreamRemovedEventHandler( _RtpStreamRemoved), new object[] { sender, ea } ); } }
private static void RaiseParticipantTimeout(object sender, RtpEvents.RtpParticipantEventArgs ea) { // Filter out events from other RtpListener instances if (sender != rtpSession) { return; } try { Participant p = (Participant)participants[ea.RtpParticipant.CName]; if (ParticipantTimeout != null) { ParticipantTimeout(p); } else { if (p == null) { eventLog.WriteEntry("Participant Timeout, CName == " + ea.RtpParticipant.CName, EventLogEntryType.Warning, 10); } else { eventLog.WriteEntry("Participant Timeout, " + p.ToString() , EventLogEntryType.Warning, 10); } } } catch (ThreadAbortException) {} catch (Exception e) { eventLog.WriteEntry(e.ToString(), EventLogEntryType.Error, 99); } }
private static void RaiseNetworkTimeout(object sender, RtpEvents.NetworkTimeoutEventArgs ea) { // Filter out events from other RtpListener instances if (sender != rtpSession) { return; } try { if (NetworkTimeout != null) { NetworkTimeout(); } else { eventLog.WriteEntry("Network Timeout", EventLogEntryType.Warning, 9); } } catch (ThreadAbortException) {} catch (Exception e) { eventLog.WriteEntry(e.ToString(), EventLogEntryType.Error, 99); } }
public WorkItem(RtpEvents.RaiseEvent method, object[] parameters) { this.method = method; this.parameters = parameters; }
// CF1, CF3 private void RtpStreamAdded(object sender, RtpEvents.RtpStreamEventArgs ea) { rtpStream = ea.RtpStream; }
private void RtpStreamRemoved(object sender, RtpEvents.RtpStreamEventArgs ea) { ea.RtpStream.FrameReceived -= new RtpStream.FrameReceivedEventHandler(FrameReceived); }
private void RtpParticipantRemoved(object sender, RtpEvents.RtpParticipantEventArgs ea) { ShowMessage(string.Format(CultureInfo.CurrentCulture, Strings.HasLeftTheChatSession, ea.RtpParticipant.Name)); }
private void RtpParticipantRemoved(object sender, RtpEvents.RtpParticipantEventArgs ea) { ShowMessage(string.Format("{0} has left the chat session.", ea.RtpParticipant.Name)); }
internal void RaiseDataStoppedEvent(object[] args) { RtpEvents.FireEvent(DataStopped, args); }
/// <summary> /// the streams gone away...stop recording /// </summary> /// <param name="SSRC">what's gone</param> private void OnRtpStreamRemoved( object sender, RtpEvents.RtpStreamEventArgs ea ) { if (this.rtpSession != sender) return; RtpStream stream = ea.RtpStream; eventLog.WriteEntry(string.Format(CultureInfo.CurrentCulture, "Rtp stream ended: {0}, {1}", stream.Properties.CName, stream.Properties.Name), EventLogEntryType.Information, ArchiveServiceEventLog.ID.Information); // Stop listening to the stream. StreamRecorder sm = (StreamRecorder)streams[stream.SSRC]; perfCounter.RemoveInstanceForCollection(sm); sm.StopListening(); streams.Remove(stream.SSRC); // Set the countdown timer if the venue is empty if( streams.Count == 0 ) { this.stopTimer = new Timer(new TimerCallback(StopRecordingCallee), null, Constants.StopAfterVenueEmptySec*1000, Timeout.Infinite); } }
/// <summary> /// Creates a <see cref="ParticipantModel"/> and <see cref="RTPMessageReceiver"/> /// whenever a new stream is connected to the venue. The <see cref="ParticipantModel"/> /// is added to the current <see cref="ClassroomModel"/>. /// </summary> private void HandleStreamAdded(object sender, RtpEvents.RtpStreamEventArgs args) { using(Synchronizer.Lock(this.m_Sender.m_Classroom.SyncRoot)) { using(Synchronizer.Lock(this)) { if(this.m_Disposed) throw new ObjectDisposedException("RTPMessageSender"); RtpStream stream = args.RtpStream; // Ignore streams that are not part of our session. if(this.m_Sender.m_RtpSession.ContainsStream(stream)) { // Ignore streams that are not DynamicPresentations. if(stream.PayloadType == PayloadType.dynamicPresentation) { // Ignore our own stream, but create a listener for all others. if(stream.SSRC != this.m_Sender.m_RtpSender.SSRC) { // If we've not seen this client before, create a new ParticipantModel, // identified by the participant's CName, which, if the participant // is running Classroom Presenter, is a Guid string. string cname = stream.Properties.CName; // It's possible for a participant to generate more than one Rtp stream, // so we need to keep a different table for m_Participants than m_Receivers. ParticipantModel participant = ((ParticipantModel) this.m_Participants[cname]); if(participant == null) { // Also get the remote client's HumanName from the participant data. RtpParticipant client = this.m_Sender.m_RtpSession.Participants[cname]; participant = new ParticipantModel(new Guid(cname), client.Name); // Add the participant to our table. this.m_Participants.Add(cname, participant); } // Add the participant to the classroom if it is not already a member. if(!this.m_Sender.m_Classroom.Participants.Contains(participant)) this.m_Sender.m_Classroom.Participants.Add(participant); // Create a receiver for this specific stream (there may be more than one stream per participant) // and add it to the table of receivers so it can be disposed when the stream is removed. RTPMessageReceiver receiver = new RTPMessageReceiver(this.m_Sender, stream, this.m_Sender.m_Model, this.m_Sender.m_Classroom, participant); this.m_Receivers.Add(stream, receiver); } } } } } }
private static void RaisePacketOutOfSequence(object sender, RtpEvents.PacketOutOfSequenceEventArgs packetOutOfSequenceEventArgs) { // Filter out events from other RtpListener instances if (!rtpSession.ContainsStream((RtpStream)sender)) { return; } try { ICapability cv = capabilityViewers[Capability.IDFromRtpStream(packetOutOfSequenceEventArgs.RtpStream)]; if (PacketOutOfSequence != null) { PacketOutOfSequence(cv, packetOutOfSequenceEventArgs.LostPackets); } else { if (cv != null) { eventLog.WriteEntry("PacketOutOfSequence, packets lost = " + packetOutOfSequenceEventArgs.LostPackets + ", " + cv.ToString(), EventLogEntryType.Warning, 14); } else { eventLog.WriteEntry("PacketOutOfSequence, packets lost = " + packetOutOfSequenceEventArgs.LostPackets + ", ssrc == " + packetOutOfSequenceEventArgs.RtpStream.SSRC, EventLogEntryType.Warning, 14); } } } catch (ThreadAbortException) {} catch (Exception e) { eventLog.WriteEntry(e.ToString(), EventLogEntryType.Error, 99); } }
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 static void RtpParticipantAdded(object sender, RtpEvents.RtpParticipantEventArgs ea) { // Because the RtpSession Adds a Participant in its constructor, the RtpSession // reference has not been initialized yet (null). Check for null, so we don't lose // the participant added event. if(RtpSession != null) { // Filter out events from other RtpSession instances if (sender != RtpSession) { return; } } Conference.FormInvoke(new RtpEvents.RtpParticipantAddedEventHandler(_RtpParticipantAdded), new object[] { sender, ea }); }
/// <summary> /// we have a new stream - start recording /// </summary> /// <param name="SSRC">what's arrived</param> private void OnNewRtpStream( object sender, RtpEvents.RtpStreamEventArgs ea) { if (this.rtpSession != sender) return; RtpStream stream = ea.RtpStream; if( streams.ContainsKey(stream.SSRC) ) return; Trace.WriteLine("New stream found: " + stream.Properties.CName + ", " + stream.Properties.Name); if ( participants[stream.Properties.CName] != null ) { ParticipantWrapper participant = (ParticipantWrapper)participants[stream.Properties.CName]; StreamRecorder sm = new StreamRecorder(participant.participantID, stream, perfCounter); streams[stream.SSRC] = sm; perfCounter.AddInstanceForCollection(sm); // Make sure we don't stop recording now if( this.stopTimer != null ) { stopTimer.Dispose(); stopTimer = null; } } else { eventLog.WriteEntry("Detected stream for unknown participant, ignoring. CNAME: " + stream.Properties.CName, EventLogEntryType.Error, ArchiveServiceEventLog.ID.Error); } }
private static void _RaiseDuplicateIdentityDetected(object sender, RtpEvents.DuplicateCNameDetectedEventArgs ea) { try { if (DuplicateIdentityDetected != null) { DuplicateIdentityDetected( null, new DuplicateIdentityDetectedEventArgs(ea.IPAddresses)); } if (Conference.ActiveVenue != null) { Conference.LeaveVenue(); } string message = "A duplicate of the local Identity was detected on the network between " + ea.IPAddresses[0].ToString() + " & " + ea.IPAddresses[1].ToString() + ". Venue.Leave() has been called."; eventLog.WriteEntry(message, EventLogEntryType.Error, 15); } catch (ThreadAbortException) {} catch (Exception e) { eventLog.WriteEntry(e.ToString(), EventLogEntryType.Error, 99); } }
/// <summary> /// the streams gone away...stop recording /// </summary> /// <param name="SSRC">what's gone</param> private void OnRtpStreamRemoved( object sender, RtpEvents.RtpStreamEventArgs ea ) { if (this.rtpSession != sender) return; RtpStream stream = ea.RtpStream; Trace.WriteLine("Rtp stream ended: " + stream.Properties.CName + ", " + stream.Properties.Name); // Stop listening to the stream. StreamRecorder sm = (StreamRecorder)streams[stream.SSRC]; perfCounter.RemoveInstanceForCollection(sm); sm.StopListening(); streams.Remove(stream.SSRC); // Set the countdown timer if the venue is empty if( streams.Count == 0 ) { this.stopTimer = new Timer(new TimerCallback(StopRecordingCallee), null, Constants.StopAfterVenueEmptySec*1000, Timeout.Infinite); } }
private static void _RtpParticipantRemoved(object sender, RtpEvents.RtpParticipantEventArgs ea) { Debug.Assert(Conference.ActiveVenue != null); lock(Conference.ActiveVenue) { RemoveParticipant(participants[ea.RtpParticipant.CName]); } }
private static void RaiseCapabilityTimeout(object sender, RtpEvents.RtpStreamEventArgs ea) { // Filter out events from other RtpListener instances if (sender != rtpSession) { return; } try { ICapability capability = capabilityViewers[Capability.IDFromRtpStream(ea.RtpStream)]; if (CapabilityTimeout != null) { CapabilityTimeout(null, new CapabilityEventArgs(capability)); } else { if (capability != null) { eventLog.WriteEntry("Capability Timeout, " + capability.ToString() , EventLogEntryType.Warning, 11); } else { eventLog.WriteEntry("Capability Timeout, ssrc == " + ea.RtpStream.SSRC, EventLogEntryType.Warning, 11); } } } catch (ThreadAbortException) {} catch (Exception e) { eventLog.WriteEntry(e.ToString(), EventLogEntryType.Error, 99); } }
private static void _RtpStreamRemoved(object sender, RtpEvents.RtpStreamEventArgs ea) { lock(Conference.ActiveVenue) { ICapabilityViewer iCV = (ICapabilityViewer)capabilityViewers[Capability.IDFromRtpStream(ea.RtpStream)]; if (iCV != null) { iCV.StreamRemoved(ea.RtpStream); Conference.RaiseCapabilityParticipantRemoved(iCV, participants[ea.RtpStream.Properties.CName]); // If there are no streams, shut it down if (iCV.RtpStreams.Length == 0) { DisposeCapability(iCV); } else if(iCV.Owner != null) { // Owned capabilities should stop when there are no incoming streams from the owner bool foundOwnerStream = false; string ownerCName = iCV.Owner.Identifier; foreach( RtpStream stream in iCV.RtpStreams ) { if( stream.Properties.CName == ownerCName ) { foundOwnerStream = true; break; } } if (!foundOwnerStream) { DisposeCapability(iCV); } } } } }
private static void RaiseDuplicateIdentityDetected(object sender, RtpEvents.DuplicateCNameDetectedEventArgs ea) { // Filter out events from other RtpSession instances if (sender == rtpSession) { Conference.FormInvoke(new RtpEvents.DuplicateCNameDetectedEventHandler( _RaiseDuplicateIdentityDetected), new object[] { sender, ea } ); } }
private void DuplicateCNameDetected (object sender, RtpEvents.DuplicateCNameDetectedEventArgs ea) { if (sender == rtpSession) { string msg = string.Format("A duplicate CNAME was detected between {0} and {1}. Connectivity testing terminating.", ea.IPAddresses[0].ToString(), ea.IPAddresses[1].ToString()); eventLog.WriteEntry(msg, EventLogEntryType.Error, 0); System.Windows.Forms.MessageBox.Show(msg); Dispose(); } }
private static void RaiseFrameOutOfSequence(object sender, RtpEvents.FrameOutOfSequenceEventArgs ea) { // Filter out events from other RtpListener instances if (!rtpSession.ContainsStream((RtpStream)sender)) { return; } try { ICapability cv = capabilityViewers[Capability.IDFromRtpStream(ea.RtpStream)]; if (FrameOutOfSequence != null) { FrameOutOfSequence(cv, ea.LostFrames, ea.Message); } else { if (cv != null) { eventLog.WriteEntry("FrameOutOfSequence, lostFrames = " + ea.LostFrames + ", message = " + ea.Message + ", " + cv.ToString(), EventLogEntryType.Warning, 13); } else { eventLog.WriteEntry("FrameOutOfSequence, lostFrames = " + ea.LostFrames + ", message = " + ea.Message + ", ssrc == " + ea.RtpStream.SSRC, EventLogEntryType.Warning, 13); } } } catch (ThreadAbortException) {} catch (Exception e) { eventLog.WriteEntry(e.ToString(), EventLogEntryType.Error, 99); } }
internal void RaiseFirstFrameReceivedEvent(object[] args) { RtpEvents.FireEvent(FirstFrameReceived, args); }
private static void RaiseInvalidPacket(object sender, RtpEvents.InvalidPacketInFrameEventArgs ea) { // Filter out events from other RtpListener instances if (!rtpSession.ContainsStream((RtpStream)sender)) { return; } try { ICapability cv = capabilityViewers[Capability.IDFromRtpStream(ea.RtpStream)]; if (InvalidPacket != null) { InvalidPacket(cv, ea.Reason); } else { if (cv != null) { eventLog.WriteEntry("Invalid Packet, " + cv.ToString() + ", " + ea.Reason, EventLogEntryType.Warning, 7); } else { eventLog.WriteEntry("Invalid Packet, ssrc == " + ea.RtpStream.SSRC + ", " + ea.Reason, EventLogEntryType.Warning, 7); } } } catch (ThreadAbortException) {} catch (Exception e) { eventLog.WriteEntry(e.ToString(), EventLogEntryType.Error, 99); } }
private void HiddenSockExHandler(object session, RtpEvents.HiddenSocketExceptionEventArgs hseea) { if (Conference.ActiveVenue != null && hseea.Session == Conference.RtpSession) { btnLeaveConference.PerformClick(); MessageBox.Show(this, "Your internet connection no longer appears to be working. Please check your internet connection.", "SocketException", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private static void RaiseInvalidPacket(object sender, RtpEvents.InvalidPacketEventArgs ea) { // Filter out events from other RtpSession instances if (sender != rtpSession) { return; } try { if (InvalidPacket != null) { InvalidPacket(null, ea.Reason); } else { eventLog.WriteEntry("Invalid Packet, unknown CapabilityViewer, " + ea.Reason, EventLogEntryType.Warning, 8); } } catch (ThreadAbortException) {} catch (Exception e) { eventLog.WriteEntry(e.ToString() , EventLogEntryType.Error, 99); } }