Пример #1
0
        private void Send()
        {
            // Apply transformations to packet data
            if (packetTransform != null)
            {
                for (int i = 0; i < frame.PacketCount; i++)
                {
                    packetTransform.Encode(frame[i]);
                }
            }

            try
            {
                SendPackets();
            }
            catch (Exception e)
            {
                eventLog.WriteEntry(string.Format(CultureInfo.CurrentCulture, Strings.ErrorDuringRtpSenderSend,
                                                  e.ToString()), EventLogEntryType.Error, (int)RtpEL.ID.Error);

                Dispose();
                throw;
            }

            // Record performance data
            int pxInFrame = this.frame.PacketCount;

            frameLength = (int)frame.Length;

            framesSent++;
            packetsSent += (uint)pxInFrame;
            bytesSent   += (uint)frameLength;

            if (pxInFrame < pcPxPerFrameMin)
            {
                pcPxPerFrameMin = pxInFrame;
            }

            if (pxInFrame > pcPxPerFrameMax)
            {
                pcPxPerFrameMax = pxInFrame;
            }

            if (frameLength < pcBytesPerFrameMin)
            {
                pcBytesPerFrameMin = frameLength;
            }

            if (frameLength > pcBytesPerFrameMax)
            {
                pcBytesPerFrameMax = frameLength;
            }
        }
Пример #2
0
        private void Send()
        {
            try
            {
                SendPackets();
            }
            catch (Exception e)
            {
                eventLog.WriteEntry("Error during RtpSender.Send \r\n" + e.ToString(),
                                    EventLogEntryType.Error, (int)RtpEL.ID.Error);

                Dispose();
                throw;
            }

            // Record performance data
            int pxInFrame = this.frame.PacketCount;

            frameLength = (int)frame.Length;

            framesSent++;
            packetsSent += (uint)pxInFrame;
            bytesSent   += (uint)frameLength;

            if (pxInFrame < pcPxPerFrameMin)
            {
                pcPxPerFrameMin = pxInFrame;
            }

            if (pxInFrame > pcPxPerFrameMax)
            {
                pcPxPerFrameMax = pxInFrame;
            }

            if (frameLength < pcBytesPerFrameMin)
            {
                pcBytesPerFrameMin = frameLength;
            }

            if (frameLength > pcBytesPerFrameMax)
            {
                pcBytesPerFrameMax = frameLength;
            }
        }
Пример #3
0
        public ConnectivityDetector()
        {
            try
            {
                cName = "ConnectivityDetector@" + HostName;

                InitializeWellKnownHosts();
                InitializeNetwork();

                // Wait N seconds, and only call this once
                updateThread = new System.Threading.Timer(new TimerCallback(UpdateThread), null, updateInterval, updateInterval);
            }
            catch (Exception e)
            {
                eventLog.WriteEntry(e.ToString(), EventLogEntryType.Error, 0);
            }
        }
Пример #4
0
        /// <summary>
        /// newPacket is how RtpListener sends an incoming RtpPacket who's SSRC matches this
        /// RtpStream into the RtpStream's queue for processing
        ///
        /// This method assumes there is only one thread calling newPacket
        /// </summary>
        internal virtual void ProcessPacket(RtpPacket packet)
        {
            #region Mark this stream and its participant as not stale
            stale = 0;
            // TODO - trade SdesData for Participant JVE
            // TODO - mark participant or we will destory and recreate streams JVE
//            if (participant != null)
//            {
//                participant.stale = 0;
//            }
            #endregion

            // Mark raw packet received
            packetsLost += LostPackets(ref maxSeq, packet.Sequence);
            packetsReceived++;
            bytesReceived += packet.PayloadSize;

            #region Reject Late Packets

            uint packetTS = packet.TimeStamp;
            uint deltaTS  = 0;

            if (packetsReceived != 1) // Skip this test if we're in a startup state
            {
                deltaTS = unchecked (packetTS - currentFrameTS);

                if (deltaTS > HALF_UINT_MAX)
                {
                    packetsReceivedLate++;
                    returnBufferHandler(packet.ReleaseBuffer());
                    return;
                }
            }

            #endregion

            // A packet from a future frame has been received, so send out the incomplete current frame
            // Note we cannot check for deltaTS == 1 because we may miss more than 1 frame
            if (deltaTS > 0)
            {
                if (frame != null)
                {
                    frame.Dispose();
                    frame = null;
                }

                RtpRetransmit.FrameIncomplete(this, (int)deltaTS);
            }

            // We're receiving the first packet for a new frame
            if (frame == null)
            {
                frame          = new RtpFrame(packet.PacketsInFrame, packetTS, returnBufferHandler);
                currentFrameTS = packetTS;
            }

            try
            {
                // Store the packet
                frame[packet.FrameIndex] = packet;
            }
            catch (DuplicatePacketException)
            {
                // Note: We have already updated the performance counters for these bytes / this packet
                // and we are rejecting it now.  So pcs could be higher than expected.
                eventLog.WriteEntry("Duplicate packet received in RtpStream - " + packet.ToString(),
                                    EventLogEntryType.Error, (int)RtpEL.ID.DuplicatePacketReceived);

                return;
            }

            // We've received the correct number of data packets, so we can now re-create the frame
            if (frame.Complete)
            {
                // Raise the event
                OnFrameReceivedEvent(frame.Data);

                // Clean up frame - like returning packets to RtpListener
                frame.Dispose();
                frame = null;

                // CXP RtpSenders increment by 1, to do otherwise is a signal from the Sender
                // which means the stream needs to know what the signal means
                currentFrameTS++;
            }
        }
Пример #5
0
 internal static void RaiseAppPacketReceivedEvent(object[] args)
 {
     if (!FireEvent(AppPacketReceived, args))
     {
         eventLog.WriteEntry("AppPacketReceivedEvent", EventLogEntryType.Information,
                             (int)RtpEL.ID.AppPacketReceived);
     }
 }
Пример #6
0
        internal static void RaiseDuplicateCNameDetectedEvent(object[] args)
        {
            if (!FireEvent(DuplicateCNameDetected, args))
            {
                DuplicateCNameDetectedEventArgs ea = (DuplicateCNameDetectedEventArgs)args[1];

                string message = string.Format(CultureInfo.CurrentCulture, Strings.DuplicateCNameDetected,
                                               ea.IPAddresses[0].ToString(), ea.IPAddresses[1].ToString());

                eventLog.WriteEntry(message, EventLogEntryType.Warning, (int)RtpEL.ID.DuplicateCNameEvent);
            }
        }