gortc / Sdp
Licence: bsd-3-clause
RFC 4566 SDP implementation in go
Stars: ✭ 109
Projects that are alternatives of or similar to Sdp
sirdez
Glorious Binary Serialization and Deserialization for TypeScript.
Stars: ✭ 20 (-81.65%)
Mutual labels: encoding, protocol
sms
A Go library for encoding and decoding SMSs
Stars: ✭ 37 (-66.06%)
Mutual labels: encoding, decoder
Dockerfiles
Optimized media, analytics and graphics software stack images. Use the dockerfile(s) in your project or as a recipe book for bare metal installation.
Stars: ✭ 98 (-10.09%)
Mutual labels: encoding, webrtc
AnimatedGif
📼 A high performance .NET library for reading and creating animated GIFs
Stars: ✭ 106 (-2.75%)
Mutual labels: encoding, decoder
Base62
PHP Base62 encoder and decoder for integers and big integers with Laravel 5 support.
Stars: ✭ 16 (-85.32%)
Mutual labels: encoding, decoder
Saltyrtc Meta
Protocol description and organisational information for SaltyRTC implementations.
Stars: ✭ 67 (-38.53%)
Mutual labels: webrtc, protocol
Base62.js
🔡 A javascript Base62 encode/decoder for node.js
Stars: ✭ 108 (-0.92%)
Mutual labels: encoding, decoder
Reverse Engineering Bluetooth Protocols
Intercepting Bluetooth device communication and simulating packet responses of an iPhone from a Raspberry Pi 3
Stars: ✭ 105 (-3.67%)
Mutual labels: protocol
Licode Erizoclientios
IOS Erizo client library for Licode WebRTC Framework
Stars: ✭ 107 (-1.83%)
Mutual labels: webrtc
Opentok Ios Sdk Samples Swift
Sample applications using the OpenTok iOS SDK in Swift
Stars: ✭ 105 (-3.67%)
Mutual labels: webrtc
Webrtc Experiment
WebRTC, WebRTC and WebRTC. Everything here is all about WebRTC!!
Stars: ✭ 10,335 (+9381.65%)
Mutual labels: webrtc
Jlm
A fast LSTM Language Model for large vocabulary language like Japanese and Chinese
Stars: ✭ 105 (-3.67%)
Mutual labels: decoder
Gocmpp
An implementation of China Mobile Peer to Peer protocol in golang for both client and server sides.
Stars: ✭ 108 (-0.92%)
Mutual labels: protocol
Callroulette
A WebRTC demo using Python (asyncio + aiohttp) as the backend
Stars: ✭ 104 (-4.59%)
Mutual labels: webrtc
Opentok Network Test
Sample app to test network connectivity and statistics (bps, packet-lost)
Stars: ✭ 104 (-4.59%)
Mutual labels: webrtc
Dex Protocols
A list of protocols for decentralized exchange
Stars: ✭ 109 (+0%)
Mutual labels: protocol
Simplewebrtcexample ios
Simple example for WebRTC on iOS written in swift5
Stars: ✭ 108 (-0.92%)
Mutual labels: webrtc
SDP
Package sdp implements SDP: Session Description Protocol [RFC4566]. Complies to gortc principles as core package.
Examples
See examples folder.
Also there is online SDP example that gets
RTCPeerConnection.localDescription.sdp
using WebRTC,
sends it to server, decodes as sdp.Session
and renders it on web page.
SDP example:
v=0
o=jdoe 2890844526 2890842807 IN IP4 10.47.16.5
s=SDP Seminar
i=A Seminar on the session description protocol
u=http://www.example.com/seminars/sdp.pdf
[email protected] (Jane Doe)
p=12345
c=IN IP4 224.2.17.12/127
b=CT:154798
t=2873397496 2873404696
r=7d 1h 0 25h
k=clear:ab8c4df8b8f4as8v8iuy8re
a=recvonly
m=audio 49170 RTP/AVP 0
m=video 51372 RTP/AVP 99
b=AS:66781
k=prompt
a=rtpmap:99 h263-1998/90000
Encode:
package main
import (
"fmt"
"net"
"time"
"gortc.io/sdp"
)
func main() {
var (
s sdp.Session
b []byte
)
// defining medias
audio := sdp.Media{
Description: sdp.MediaDescription{
Type: "audio",
Port: 49170,
Formats: []string{"0"},
Protocol: "RTP/AVP",
},
}
video := sdp.Media{
Description: sdp.MediaDescription{
Type: "video",
Port: 51372,
Formats: []string{"99"},
Protocol: "RTP/AVP",
},
Bandwidths: sdp.Bandwidths{
sdp.BandwidthApplicationSpecific: 66781,
},
Encryption: sdp.Encryption{
Method: "prompt",
},
}
video.AddAttribute("rtpmap", "99", "h263-1998/90000")
// defining message
m := &sdp.Message{
Origin: sdp.Origin{
Username: "jdoe",
SessionID: 2890844526,
SessionVersion: 2890842807,
Address: "10.47.16.5",
},
Name: "SDP Seminar",
Info: "A Seminar on the session description protocol",
URI: "http://www.example.com/seminars/sdp.pdf",
Email: "[email protected] (Jane Doe)",
Phone: "12345",
Connection: sdp.ConnectionData{
IP: net.ParseIP("224.2.17.12"),
TTL: 127,
},
Bandwidths: sdp.Bandwidths{
sdp.BandwidthConferenceTotal: 154798,
},
Timing: []sdp.Timing{
{
Start: sdp.NTPToTime(2873397496),
End: sdp.NTPToTime(2873404696),
Repeat: 7 * time.Hour * 24,
Active: 3600 * time.Second,
Offsets: []time.Duration{
0,
25 * time.Hour,
},
},
},
Encryption: sdp.Encryption{
Method: "clear",
Key: "ab8c4df8b8f4as8v8iuy8re",
},
Medias: []sdp.Media{audio, video},
}
m.AddFlag("recvonly")
// appending message to session
s = m.Append(s)
// appending session to byte buffer
b = s.AppendTo(b)
fmt.Println(string(b))
}
Decode:
package main
import (
"fmt"
"io"
"io/ioutil"
"log"
"os"
"gortc.io/sdp"
)
func main() {
name := "example.sdp"
if len(os.Args) > 1 {
name = os.Args[1]
}
var (
s sdp.Session
b []byte
err error
f io.ReadCloser
)
fmt.Println("sdp file:", name)
if f, err = os.Open(name); err != nil {
log.Fatal("err:", err)
}
defer f.Close()
if b, err = ioutil.ReadAll(f); err != nil {
log.Fatal("err:", err)
}
if s, err = sdp.DecodeSession(b, s); err != nil {
log.Fatal("err:", err)
}
for k, v := range s {
fmt.Println(k, v)
}
d := sdp.NewDecoder(s)
m := new(sdp.Message)
if err = d.Decode(m); err != nil {
log.Fatal("err:", err)
}
fmt.Println("Decoded session", m.Name)
fmt.Println("Info:", m.Info)
fmt.Println("Origin:", m.Origin)
}
Also, low-level Session struct can be used directly to compose SDP message:
package main
import (
"fmt"
"gortc.io/sdp"
)
func main() {
var (
s sdp.Session
b []byte
)
b = s.AddVersion(0).
AddMediaDescription(sdp.MediaDescription{
Type: "video",
Port: 51372,
Formats: []string{"99"},
Protocol: "RTP/AVP",
}).
AddAttribute("rtpmap", "99", "h263-1998/90000").
AddLine(sdp.TypeEmail, "[email protected]").
AddRaw('ü', "vαlue").
AppendTo(b)
// and so on
fmt.Println(string(b))
// Output:
// v=0
// m=video 51372 RTP/AVP 99
// a=rtpmap:99 h263-1998/90000
// [email protected]
// ü=vαlue
}
Supported params
- [x] v (protocol version)
- [x] o (originator and session identifier)
- [x] s (session name)
- [x] i (session information)
- [x] u (URI of description)
- [x] e (email address)
- [x] p (phone number)
- [x] c (connection information)
- [x] b (zero or more bandwidth information lines)
- [x] t (time)
- [x] r (repeat)
- [x] z (time zone adjustments)
- [x] k (encryption key)
- [x] a (zero or more session attribute lines)
- [x] m (media name and transport address)
TODO:
- [x] Encoding
- [x] Parsing
- [x] High level encoding
- [x] High level decoding
- [x] Examples
- [x] CI
- [x] More examples and docs
- [x] Online example
- [ ] io.Reader and io.Writer interop
- [ ] Include to high-level CI
Possible optimizations
There are comments // ALLOCATIONS: suboptimal.
and // CPU: suboptimal.
that indicate suboptimal implementation that can be optimized. There are often
a benchmarks for this pieces.
Benchmarks
goos: linux
goarch: amd64
pkg: github.com/gortc/sdp
PASS
benchmark iter time/iter bytes alloc allocs
--------- ---- --------- ----------- ------
BenchmarkDecoder_Decode-12 300000 4884.00 ns/op 3166 B/op 93 allocs/op
BenchmarkEncode-12 1000000 1577.00 ns/op 0 B/op 0 allocs/op
BenchmarkSession_AddConnectionData-12 20000000 114.00 ns/op 0 B/op 0 allocs/op
BenchmarkAppendIP-12 50000000 37.90 ns/op 0 B/op 0 allocs/op
BenchmarkAppendByte-12 100000000 11.00 ns/op 0 B/op 0 allocs/op
BenchmarkAppendInt-12 100000000 11.90 ns/op 0 B/op 0 allocs/op
BenchmarkSession_EX1-12 3000000 578.00 ns/op 16 B/op 1 allocs/op
BenchmarkAppendRune-12 200000000 6.70 ns/op 0 B/op 0 allocs/op
BenchmarkDecode-12 100000000 13.10 ns/op 0 B/op 0 allocs/op
BenchmarkDecodeSession-12 5000000 234.00 ns/op 0 B/op 0 allocs/op
ok github.com/gortc/sdp 16.820s
Build status
License
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].