Click or drag to resize
JitterBufferT Class

Handles the creation and release of complete RTP frames.

Inheritance Hierarchy
SystemObject
  StreamCoders.RtpJitterBufferT

Namespace: StreamCoders.Rtp
Assembly: MediaBase (in MediaBase.dll) Version: 2.0.5.0 (2.0.5.0)
Syntax
public class JitterBuffer<T>
where T : new(), RtpFrame

Type Parameters

T
The type of RtpFrame to create.

The JitterBufferT type exposes the following members.

Constructors
  NameDescription
Public methodJitterBufferT
Initializes a new instance of the JitterBufferT class
Top
Properties
  NameDescription
Public propertyCompleteCount
Public propertyCount
Gets the number of frames currently maintained in jitter buffer.
Public propertyDroppedFrames
Top
Methods
  NameDescription
Public methodAddPacket(RtpPacket)
Adds a packet to the jitter. This method will automatically create a frame if one does not already exist and call playoutBufferToUse.UpdateRelativeTimestamp once on the frame object.
Public methodAddPacketT1(RtpPacket)
Adds a packet to the jitter. This method will automatically create a frame if one does not already exist and call playoutBufferToUse.UpdateRelativeTimestamp once on the frame object.
Public methodClear
Removes all frames from jitter buffer.
Public methodContainsFrame
Checks whether a frame is already contained within the jitter.
Public methodFindCompleteFrame
Finds the first available frame to be release from the jitter.
Public methodSetPlayoutBuffer
Set this to maintain playoutBufferToUse times from within the jitter buffer. RTCP updates will still have to be managed from the outside by sharing the object.
Top
Fields
  NameDescription
Public fieldAdaptiveExpiry
Adaptive expiry automatically adjusts the Expiry time by measuring the weighed average time of frame completion. Avg += 1/16 * (previous - current); The initial FrameExpiry in this scenario is still important as the algorithm needs a starting point.
Public fieldAdaptiveMaximumThreshold
In an adaptive expiry scenario, the maximum change is FrameExpiry * AdaptiveMaximumThreshold.
Public fieldAdaptiveOvershootFactor
The adaptive overshoot factor.
Public fieldCheckFrameComplete
Some framing types don't set a marker bit. If set to false, the jitter will not check if the frame is complete and will release it upon FrameExpiry.
Public fieldCheckGaps
Check whether frame gaps exist as criteria for a complete frame.
Public fieldFrameExpiry
Time to wait before a frame is released from the jitter.
Public fieldMinimumFrameAge
The minimum age a frame must have before it is released by the jitter.
Public fieldName
The name.
Public fieldSkipLateOrIncompleteFrames
If set to true, the jitter will not release partially completed frames (due to packet loss etc.). A frame is considered late when the frame age is 1.5 times that of FrameExpiry.
Top
Extension Methods
  NameDescription
Public Extension MethodCopyOverloaded.
Creates a copy of the object.
(Defined by ObjectExtensions.)
Public Extension MethodCopy(Object)Overloaded.
Creates a deep copy of the object using the supplied object as a target for the copy operation.
(Defined by ObjectExtensions.)
Top
Remarks
The current critera for a complete frame is:
  • RTPFrame.FrameComplete (no sequence gaps and Marker bit set)
  • RTPFrame.IsExpired == true

To handle alternative critera on when a frame is complete, this class needs to be derived and method FindCompleteFrame will need to be overridden.

Examples
Example
class Program
  {
      static JitterBuffer<H264Frame> jitter = new JitterBuffer<H264Frame>();

      static void Main(string[] args)
      {

          // Create participant and hook up RTP received event.
          var participant = ParticipantHelper.CreateUdpParticipant(IPAddress.Parse("127.0.0.1"), 12000, null, 0);
          participant.OnRtpReceive += participant_OnRtpReceive;


          while(true)
          {
              var frame = jitter.FindCompleteFrame();
              if (frame == null) continue;

              Console.WriteLine("Complete frame received {0}", frame.Timestamp);
          }
      }

      static void participant_OnRtpReceive(object sender, RtpPacket Packet, ArraySegment<byte> RawPacket, EndPoint remoteEndpoint)
      {
          jitter.AddPacket(Packet);
      }
  }
See Also