A RTP stack for Go

Related tags

Network GoRTP
Overview

RTP/RTCP stack for Go

This Go package implements a RTP/RTCP stack for Go. The package is a sub-package of the standard Go net package and uses standard net package functions.

How to build

The rtp sources use the GOPATH directory structure. To build, test, and run the software just add the main goRTP directory to GOPATH. For further information about this structure run go help gopath and follow the instructions. The rtp package is below the package net to make clear that rtp is a network related package.

To build the package just run go build net/rtp and then go install net/rtp. To excecute the tests just run go test net/rtp. The tests check if the code works with the current Go installation on your system. It should PASS.

A demo program is available and is called rtpmain. Use go build net/rtpmain to build it. The command go install net/rtpmain installs it in the bin directory of the main directory.

How to use

This is a pure RTP / RTCP stack and it does not contain any media processing, for example generating or packing the payload for audio or video codecs.

The directory src/net/rtpmain contains an example Go program that performs a RTP some tests on localhost that shows how to setup a RTP session, an output stream and how to send and receive RTP data and control events. Parts of this program are used in the package documentation.

The software should be ready to use for many RTP applications. Standard point-to-point RTP applications should not pose any problems. RTP multi-cast using IP multi-cast addresses is not supported. If somebody really requires IP multi-cast it could be added at the transport level.

RTCP reporting works without support from application. The stack reports RTCP packets and if the stack created new input streams and an application may connect to the control channel to receive the RTCP events. Just have a look into the example program. The RTCP fields in the stream structures are accessible - however, to use them you may need to have some know-how of the RTCP definitions and reporting.

The documentation

After you downloaded the code you may use standard godoc to get a nice formatted documentation. Just change into the src directory, run godoc -http=:6060 -path=".", point your browser at localhost:6060, and select src at the top of the page.

I've added some package global documentation and tried to document the globally visible methods and functions.

Before you start hacking please have a look into the documentation first, in particular the package documentation (doc.go).

Some noteable features

  • The current release V1.0.0 computes the RTCP intervals based on the length of RTCP compound packets and the bandwidth allocated to RTCP. The application may set the bandwidth, if no set GoRTP makes somes educated guesses.

  • The application may set the maximum number of output and input streams even while the RTP session is active. If the application des not set GoRTP sets the values to 5 and 30 respectively.

  • GoRTP produces SR and RR reports and the associated SDES for active streams only, thus it implements the activity check as defined in chapter 6.4

  • An appplication may use GoRTP in simple RTP mode. In this mode only RTP data packets are exchanged between the peers. No RTCP service is active, no statistic counters, and GoRTP discards RTCP packets it receives.

  • GoRTP limits the number of RR to 31 per RTCP report interval. GoRTP does not add an additional RR packet in case it detects more than 31 active input streams. This restriction is mainly due to MTU contraints of modern Ethernet or DSL based networks. The MTU is usually about 1500 bytes, GoRTP limits the RTP/RTCP packet size to 1200 bytes. The length of an RR is 24 bytes, thus 31 RR already require 774 bytes. Adding some data for SR and SDES fills the rest.

  • An application may register to a control event channel and GoRTP delivers a nice set of control and error events. The events cover:

    • Creation of a new input stream when receiving an RTP or RTCP packet and the SSRC was not known
    • RTCP events to inform about RTCP packets and received reports
    • Error events
  • Currently GoRTP supports only SR, RR, SDES, and BYE RTCP packets. Inside SDES GoRTP does not support SDES Private and SDES H.323 items.

Issues
  • Copy raw RTP data, customizable settings, custom PayloadMap

    Copy raw RTP data, customizable settings, custom PayloadMap

    1. AddRemoteNonStrict method to Session;
    2. Make Session configurable with function arguments;
    3. Allow copy RTP data via SetBuffer, SetInUse, SetIsFree methods;
    4. Make buffer sizes customizable. Buffers are reused via sync.Pool;
    5. Allow custom and multiple PayloadMap's;
    opened by vany-egorov 2
  • Licence

    Licence

    I have forked your GoRTP library and noticed that there are no licences attached to your project. Would you consider adding a licence such as common creative or MIT?

    opened by dhx71 2
  • Copy raw RTP data, customizable settings

    Copy raw RTP data, customizable settings

    1. AddRemoteNonStrict method to Session;
    2. Make Session configurable with function arguments;
    3. Allow copy RTP data via SetBuffer, SetInUse, SetIsFree methods;
    4. Make buffer sizes customizable. Buffers are reused via sync.Pool;
    opened by vany-egorov 0
  • Adds DataPacket.Clone() method

    Adds DataPacket.Clone() method

    This PR adds DataPacket.Clone() method so packets could be passed easily between goroutines.

    The use-case i had in mind is when a packet is passed to a goroutine and is freed later on so second goroutine panics.

    To fix this, a clone of a packed could passed instead.

    Please let me know what you think.

    Thank you!

    opened by tonickkozlov 0
  • Changed error format string to use %d for integer values

    Changed error format string to use %d for integer values

    Hi @wernerd ,

    Thank you for merging my previous PR (about gofmt).

    This one changes string formatting to use %d instead of %i in tests to mitigate the following error I received when running go test ./...)

    src/net/rtp/datapacket_test.go:86: Sprintf format %i has unknown verb i
    

    Here's a reproducible example in go playground: https://play.golang.org/p/nUc4EQOxyAR

    Thanks!

    opened by tonickkozlov 0
  • Add support for RFC2333, DTMF payload

    Add support for RFC2333, DTMF payload

    I'm using this package to my SIP-ua. It works well. Thanks alot!

    But found it just ignore DTMF RTP events. This patches are fixes I'm using which include:

    • not ignore DTMF events
    • simple wrapper(helper) of DTMF payload
    opened by suapapa 0
  • Question about sorting multiple remote streams

    Question about sorting multiple remote streams

    Apologies if this is an RTFM fail on my part.

    I'm trying to use this library to connect to multiple remotes, each of which is sending their own stream. I'd like to be able to sort out which incoming packet comes from which remote, without opening different ports for each remote. What's the best way to handle this? I see there's an address attribute of RawPacket, but it's private. What am I missing?

    If there's a better channel for this question I'd be happy to redirect it. Thanks.

    opened by LorenDavie 0
  • add Write method to RawPacket struct

    add Write method to RawPacket struct

    if you want to copy incoming RTP packet as-is. For example when you need to redirect RTP packet from WebRTC to plain RTP:

    pkt := rtp.DataPacket{}
    
    pkt.Write(buf.Bytes())
    // or io.Copy(&pkt, buf)
    
    session.WriteData(&pkt)
    
    opened by vany-egorov 1
  • rtp.Session.WriteData returns 0 regardless of whether the write was successful

    rtp.Session.WriteData returns 0 regardless of whether the write was successful

    Hello and thanks for a very useful library.

    I've noticed that func (rs *Session) WriteData(rp *DataPacket) (n int, err error) always returns n=0 regardless of the outcome of writing into transport.

    Looks like the named return value n is never being assigned.

    https://github.com/wernerd/GoRTP/blob/master/src/net/rtp/session.go#L716

    Is this expected behaviour?

    Thanks!

    opened by tonickkozlov 1
  • panic: runtime error: slice bounds out of range

    panic: runtime error: slice bounds out of range

    panic: runtime error: slice bounds out of range

    goroutine 1937020 [running]: github.com/wernerd/GoRTP/src/net/rtp.(*DataPacket).Payload(0xc422cf4770, 0xc4236d7a10, 0xef9d273c61c19b01, 0xc42136c4a0) /home/albert/code/gocode/src/github.com/wernerd/GoRTP/src/net/rtp/packets.go:381 +0x106 github.com/wernerd/GoRTP/src/net/rtp.(*SsrcStream).recordReceptionData(0xc4200dc240, 0xc422cf4770, 0xc422e8e000, 0x1578b7d9d46f7f6a, 0xc422096501) /home/albert/code/gocode/src/github.com/wernerd/GoRTP/src/net/rtp/stream.go:493 +0xe5 github.com/wernerd/GoRTP/src/net/rtp.(*Session).OnRecvData(0xc422e8e000, 0xc422cf4770, 0x0) /home/albert/code/gocode/src/github.com/wernerd/GoRTP/src/net/rtp/session.go:477 +0x28c github.com/wernerd/GoRTP/src/net/rtp.(*TransportUDP).readDataPacket(0xc42055ee60) /home/albert/code/gocode/src/github.com/wernerd/GoRTP/src/net/rtp/transportUDP.go:170 +0x171 created by github.com/wernerd/GoRTP/src/net/rtp.(*TransportUDP).ListenOnTransports /home/albert/code/gocode/src/github.com/wernerd/GoRTP/src/net/rtp/transportUDP.go:64 +0x14a

    opened by lomoalbert 0
  • This may be a bug

    This may be a bug

    I read this code and found a problem: In sessionlocal.go #137 delete(rs.streamsOut, idx) I think it should changed to delete (rs.streamsIn, idx) Maybe I am wrong, hope to reply as soon as possible

    opened by ChiefMage 0
Owner
Werner Dittmann
Werner Dittmann
Go SIP Stack

GoSIPs Go SIP Stack (http://www.GoSIPs.org) The objective of GoSIPs is to develop a Golang stack interface and implementation to the Session Initiatio

Rain Liu 119 May 26, 2022
A decentralized P2P networking stack written in Go.

noise noise is an opinionated, easy-to-use P2P network stack for decentralized applications, and cryptographic protocols written in Go. noise is made

Perlin Network 1.7k Jul 28, 2022
The Dual-Stack Dynamic DNS client, the world's first dynamic DNS client built for IPv6.

dsddns DsDDNS is the Dual-Stack Dynamic DNS client. A dynamic DNS client keeps your DNS records in sync with the IP addresses associated with your hom

Ryan Young 11 Jul 8, 2022
A modular is an opinionated, easy-to-use P2P network stack for decentralized applications written in Go.

xlibp2p xlibp2p is an opinionated, easy-to-use P2P network stack for decentralized applications written in Go. xlibp2p is made to be minimal, robust,

XFS Network 63 Jul 10, 2022
Carbyne Stack serverless compute service for secure multiparty computation

Carbyne Stack Ephemeral Service Ephemeral is a serverless compute service for secure multiparty computation based on Knative, Istio and Kubernetes. DI

Carbyne Stack 9 Jun 17, 2022
Technical specifications for the IPFS protocol stack

IPFS Specifications This repository contains the specs for the IPFS Protocol and associated subsystems. Understanding the meaning of the spec badges a

IPFS 969 Aug 12, 2022
Xlibp2p: an opinionated, easy-to-use P2P network stack for decentralized applications written in Go

xlibp2p xlibp2p is an opinionated, easy-to-use P2P network stack for decentraliz

null 2 Feb 21, 2022
Fix Burp Suite's horrible TLS stack & spoof any browser fingerprint

Awesome TLS This extension hijacks Burp's HTTP and TLS stack to make it more powerful and less prone to fingerprinting by all kinds of WAFs. It does t

Sleeyax 61 Jul 29, 2022
A RTP -> WebRTC broadcast server for Project Lightspeed.

Project Lightspeed WebRTC A RTP -> WebRTC server based on Pion written in Go. This server accepts RTP packets on port 65535 and broadcasts them via We

Garrett GRVY Graves 70 Jun 23, 2022
Package gostackparse parses goroutines stack traces as produced by panic() or debug.Stack() at ~300 MiB/s.

gostackparse Package gostackparse parses goroutines stack traces as produced by panic() or debug.Stack() at ~300 MiB/s. Parsing this data can be usefu

Datadog, Inc. 76 Jul 25, 2022
Elastic Stack Docker + Sample Go AppElastic Stack Docker + Sample Go App

?? Elastic Stack Docker + Sample Go App Test Elastic Stack which includes Elasticsearch, Kibana, Filebeat and Metricbeat. It comes with a very simple

Ruben Delgado 0 Jan 14, 2022
A slice-based implementation of a stack. In Go!

Stackgo Stackgo is a slice-based implementation of a simple stack in Go. It uses a pre-alloc pagination strategy which adds little memory overhead to

Alessandro Diaferia 15 Dec 13, 2021
Lightweight RESTful database engine based on stack data structures

piladb [pee-lah-dee-bee]. pila means stack or battery in Spanish. piladb is a lightweight RESTful database engine based on stack data structures. Crea

Fernando Álvarez 195 Jul 1, 2022
Reduce debugging time while programming Go. Use static and stack-trace analysis to determine which func call causes the error.

Errlog: reduce debugging time while programming Introduction Use errlog to improve error logging and speed up debugging while you create amazing code

Martin Joly 407 Jul 27, 2022
Golang errors with stack trace and source fragments.

Golang Errors with Stack Trace and Source Fragments Tired of uninformative error output? Probably this will be more convenient: Example package main

null 730 Aug 11, 2022
A safe way to execute functions asynchronously, recovering them in case of panic. It also provides an error stack aiming to facilitate fail causes discovery.

Async Provides a safe way to execute functions asynchronously, recovering them in case of panic. It also provides an error stack aiming to facilitate

Studio Sol Comunicação Digital Ltda 108 Jul 27, 2022
A high productivity, full-stack web framework for the Go language.

Revel Framework A high productivity, full-stack web framework for the Go language. Current Version: 1.0.0 (2020-07-11) Supports go.mod package managem

Revel Framework 12.7k Aug 5, 2022
Diameter stack and Base Protocol (RFC 6733) for the Go programming language

Diameter Base Protocol Package go-diameter is an implementation of the Diameter Base Protocol RFC 6733 and a stack for the Go programming language. St

Alexandre Fiori 204 Jul 27, 2022
Go SIP Stack

GoSIPs Go SIP Stack (http://www.GoSIPs.org) The objective of GoSIPs is to develop a Golang stack interface and implementation to the Session Initiatio

Rain Liu 119 May 26, 2022
Go http.Hander based middleware stack with context sharing

wrap Package wrap creates a fast and flexible middleware stack for http.Handlers. Features small; core is only 13 LOC based on http.Handler interface;

go-on - web toolkit in Go 59 Apr 5, 2022
Sample full stack micro services application built using the go-Micro framework.

goTemp goTemp is a full stack Golang microservices sample application built using go-micro. The application is built as a series of services that prov

null 62 Jul 28, 2022
Lambda stack to turn off and destroy all resources from your personal AWS Account to avoid billing surprises

AWS, Turn off my Account, please Lambda stack to turn off and destroy all resources from your personal AWS Account to avoid billing surprises Resource

Matheus Fidelis 63 Apr 10, 2022
goTempM is a full stack Golang microservices sample application built on top of the Micro platform.

goTempM is a full stack Golang microservices sample application built on top of the Micro platform.

null 27 Jul 12, 2022
Same as fmt.Errorf but with stack trace.

Annotation with stack trace for go1.13 Go 1.13 contains support for error wrapping. Now you can add additional information to an error by wrapping it

Roman Budnikov 39 Dec 25, 2020
stack-rpc 快速开发包

Micro 快速开发工具包 项目进行中 本仓库旨在提供面向 stack-rpc 生产环境的快速开发包。 目录 快速开始示例 控制台示例 以最常见的登录流程为例,实现一个场景简单,但包含微服务各种治理能力的示例 Hipster Shop示例 参考GoogleCloudPlatform/microser

Stack Labs 383 Jul 26, 2022
Golang && Back-end Stack , Continually updated

Stack Here Golang OS Net Note Tool Delve Authentication Paper Paper ?? Link GO官方文档 GO Official Doc GO官方博客 GO Official Blog GO官方仓库

G 212 Jul 21, 2022
A decentralized P2P networking stack written in Go.

noise noise is an opinionated, easy-to-use P2P network stack for decentralized applications, and cryptographic protocols written in Go. noise is made

Perlin Network 1.7k Jul 28, 2022
Lightweight, Simple, Quick, Thread-Safe Golang Stack Implementation

stack Lightweight, Simple, Quick, Thread-Safe Golang Stack Implementation Purpose Provide a fast, thread safe, and generic Golang Stack API with minim

Brendan Wilson 5 May 3, 2022
The Dual-Stack Dynamic DNS client, the world's first dynamic DNS client built for IPv6.

dsddns DsDDNS is the Dual-Stack Dynamic DNS client. A dynamic DNS client keeps your DNS records in sync with the IP addresses associated with your hom

Ryan Young 11 Jul 8, 2022