A library for decoding/manipulation of RTP packets as per RFC 3550.
Version | Date | CHanges |
---|---|---|
2.0.2 | June 2020 | Resolve ISSUE-2: issues with RTCP packet length decoding |
2.0.1 | June 2020 | Resolve ISSUE-1: issues with DatagramPacket reading |
2.0.0 | May 2020 | Added support for RTCP as per RFC 3550 |
1.0.0 | March 2020 | Initial Release - RTP support as per RFC 3550 |
In order to use this library, simply include the maven dependancy as shown below.
<dependency>
<groupId>org.vidtec</groupId>
<artifactId>rtp-packet</artifactId>
<version>2.0.2</version>
</dependency>
The rtp-packet library incorporates the following features:
- Builder style packet instance creation.
- Reading packets from byte[], DatagramPacket
- Writing packets to byte[], DatagramPacket
General properties of RTPPacket:
- All packet objects are fully validated against RFC 3550 during instantiation
- All packet objects are immutable
- Getter methods to extract data points
- Automatic handling of padding
- Automatic handling of header extensions
General properties of RTCPPacket:
- All packet objects are fully validated against RFC 3550 during instantiation
- All packet objects are immutable
- Getter methods to extract data points
- Automatic handling of padding
- Automatic handling of compound packets
All packet creation and reading undergoes complete validation. It is not possible to create an RTP packet that is not valid according to spec.
In order to create a packet by hand, you can use the builder pattern to create a packet.
final RTPPacket p = RTPPacket.builder()
.withMarker()
.withRequiredHeaderFields(<packet_type, <seq_num>, <ssrc>, <timestamp>)
.withCsrcIdentifiers(... <csrcs> ...)
.withHeaderExtension(<profile>, <extension_header>)
.withPayload(<payload>)
.build();
NB: The build()
method will throw an IllegalArgumentException
if any of the data supplied would lead to creating of an invalid packet (according to RFC 3550).
To create a new packet from a byte[]
final RTPPacket p = RTPPacket.fromByteArray(<byte_array>);
NB: This method will throw an IllegalArgumentException
if any of the data supplied would lead to creating of an invalid packet (according to RFC 3550).
To create a new packet from a DatagramPacket
final RTPPacket p = RTPPacket.fromDatagramPacket(<datagram_packet>);
NB: This method will throw an IllegalArgumentException
if any of the data supplied would lead to creating of an invalid packet (according to RFC 3550).
To create a new packet from a byte[]
final RTPPacket p = RTPPacket.fromByteArray(<byte_array>);
To create a new packet from a DatagramPacket
final RTPPacket p = RTPPacket.fromDatagramPacket(<datagram_packet>);
All packet creation and reading undergoes complete validation. It is not possible to create an RTCP packet that is not valid according to spec.
In order to create a packet by hand, you can use the builder pattern to create a packet.
final RTCPPackets p = RTCPPackets.builder()
.withPacket( ... <RTCPPackets> ... )
.build();
or the shorthand version
final RTCPPackets p = RTCPPackets.buildWithPackets( ... <RTCPPackets> ... );
To create a new packet from a byte[]
final RTCPPackets p = RTCPPackets.fromByteArray(<byte_array>);
NB: This method will throw an IllegalArgumentException
if any of the data supplied would lead to creating of an invalid packet (according to RFC 3550).
To create a new packet from a DatagramPacket
final RTCPPackets p = RTCPPackets.fromDatagramPacket(<datagram_packet>);
NB: This method will throw an IllegalArgumentException
if any of the data supplied would lead to creating of an invalid packet (according to RFC 3550).
To create a new packet from a byte[]
final RTCPPackets p = RTCPPackets.fromByteArray(<byte_array>);
To create a new packet from a DatagramPacket
final RTCPPackets p = RTCPPackets.fromDatagramPacket(<datagram_packet>);
This project uses SemVer for versioning. For the versions available, see the tags on this repository.
This project is licensed under the Apache License 2.0 - see the LICENSE file for details
This project acknowledges the EJ Technologies' assistance to the open-source community through it's open-source java profiler licensing. Thank you.