Skip to content

vidtec/rtp-packet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

70 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RTP-PACKET

A library for decoding/manipulation of RTP packets as per RFC 3550.

Version History

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

Getting Started

Maven dependancy

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>

Features

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

Usage - RTP

All packet creation and reading undergoes complete validation. It is not possible to create an RTP packet that is not valid according to spec.

Creating RTP Packets

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).

Reading RTP Packets

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).

Writing RTP Packets

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>);

Usage - RTCP

All packet creation and reading undergoes complete validation. It is not possible to create an RTCP packet that is not valid according to spec.

Compound Packets

Creating Compound Packets

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> ... );

Reading Compound Packets

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).

Writing Compound Packets

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>);

Versioning

This project uses SemVer for versioning. For the versions available, see the tags on this repository.

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details

Thanks

This project acknowledges the EJ Technologies' assistance to the open-source community through it's open-source java profiler licensing. Thank you.

About

A parser/writer of RTP & RTCP packets with no external dependancies

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages