private void DisposeFrame() { frame.Dispose(); frame = null; }
private void InitializeFrame() { InitializePacketSize(); frame = new RtpFrame((uint)packetSize, payloadType, payloadPara, ts); }
/// <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) { int frame_Index = 0; int packets_Size = 0; #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(128, packetTS, returnBufferHandler); currentFrameTS = packetTS; } try { // Store the packet // payload type is jpeg frame_Index = packet.JpgOffset/packet.MaxPayloadSize; frame.ApproximatePacketsInFrame((uint)frame_Index + 1); frame[frame_Index] = 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) if (packet.Marker) { packets_Size = frame_Index + 1; frame.PacketsInFrame = (uint)packets_Size; } 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++; } }
private void DisposeFrame() { frame.Dispose(); frame = null; }
private void InitializeFrame() { InitializePacketSize(); frame = new RtpFrame((uint)packetSize, payloadType, payloadPara, ts); }
/// <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) { int frame_Index = 0; int packets_Size = 0; #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(128, packetTS, returnBufferHandler); currentFrameTS = packetTS; } try { // Store the packet // payload type is jpeg frame_Index = packet.JpgOffset / packet.MaxPayloadSize; frame.ApproximatePacketsInFrame((uint)frame_Index + 1); frame[frame_Index] = 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) if (packet.Marker) { packets_Size = frame_Index + 1; frame.PacketsInFrame = (uint)packets_Size; } 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++; } }