Git Product home page Git Product logo

rtp-packet's Introduction

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.

rtp-packet's People

Contributors

gareth-floodgate avatar gareth-floodgate-cognitran avatar vidtec avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.