Coder Social home page Coder Social logo

rtp's Introduction

rtp

github.com/turboladen/rtp

<img src=“https://secure.travis-ci.org/turboladen/rtp.png?branch=master” alt=“Build Status” />

DESCRIPTION

This is a RTP library that provides the most basic features of the Real-Time Transport Protocol (RTP, RFC 3550). While the protocol allows for extensions that define new ways for transporting encoded audio/video, this library doesn’t yet deal with any specific media types. My current goal is simply for transporting a single RTP stream of data and allowing you to inspect its packets.

FEATURES/PROBLEMS

Features:

  • Receive a single RTP stream over UDP or TCP, unicast or multicast

  • Parse RTP packet headers

  • Inspect packets on the fly

Future goals will include:

  • RTCP

  • Multiplexed sessions

  • Decoding of basic audio/video codec headers

  • Decoding of some popular A/V extension headers (h.264, et al.)

  • An easy way to hand over your data to an app that will decode your A/V stream(s)

  • Sending an RTP stream

SYNOPSIS

Streaming to file

With its default settings, an {RTP::Receiver} will open a UDP socket on port 6790, within a Thread, on 0.0.0.0 and capture the data it receives to a file.

receiver = RTP::Receiver.new      # Uses a Tempfile by default
receiver.rtp_port                 # => 6790
receiver.transport_protocol       # => :UDP
receiver.multicast?               # => false
receiver.unicast?                 # => true
receiver.start
sleep 5
receiver.stop
receiver.capture_file.size        # => 20040

To init a Receiver with some other options…

options = {
  rtp_port: 9000,
  transport_protocol: :TCP,
  ip_address: '239.255.255.251',  # Multicast!
  strip_headers: true,            # Strips RTP headers before writing to file
  capture_file: File.new('data.rtp', 'wb')
}
receiver = RTP::Receiver.new(options)
receiver.start
sleep 5
receiver.stop
receiver.capture_file.size        # => 18848

Packet inspecting

To inspect (and do what you like with) packets as they come in…

receiver = RTP::Receiver.new
receiver.start do |packet|
  puts "Sequence number: #{packet.sequence_number}"  # => Sequence number: 2931830
end
sleep 5
receiver.stop
receiver.capture_file.size        # => 0

Notice how no data was written to file when the block was passed to #start. The idea there is to save on I/O; if you’re inspecting packets, it’s not fair to assume you want to save the data to a file. If you do, however, in that case, you can simply do so within the block.

REQUIREMENTS

  • (Tested) Rubies

    • 1.9.2

    • 1.9.3

  • RubyGems:

    • bindata

    • log_switch

INSTALL

$ gem install rtp

DEVELOPERS

After checking out the source, run:

$ bundle install

This task will install any missing dependencies for you.

rtp's People

Contributors

rumblinthebronx avatar tindron avatar turboladen avatar

Watchers

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