项目作者: pixelbender

项目描述 :
Go implementation of SDP (Session Description Protocol)
高级语言: Go
项目地址: git://github.com/pixelbender/go-sdp.git
创建时间: 2016-09-12T21:32:02Z
项目社区:https://github.com/pixelbender/go-sdp

开源协议:MIT License

下载


go-sdp

Go implementation of SDP (Session Description Protocol). No external dependencies.

Build Status
Go Report Card
GoDoc

Features

  • SDP Encoder/Decoder

Installation

  1. go get github.com/pixelbender/go-sdp/...

SDP Decoding

  1. package main
  2. import (
  3. "github.com/pixelbender/go-sdp/sdp"
  4. "fmt"
  5. )
  6. func main() {
  7. sess, err := sdp.ParseString(`v=0
  8. o=alice 2890844526 2890844526 IN IP4 alice.example.org
  9. s=Example
  10. c=IN IP4 127.0.0.1
  11. t=0 0
  12. a=sendrecv
  13. m=audio 10000 RTP/AVP 0 8
  14. a=rtpmap:0 PCMU/8000
  15. a=rtpmap:8 PCMA/8000`)
  16. if err != nil {
  17. fmt.Println(err)
  18. } else {
  19. fmt.Println(sess.Media[0].Format[0].Name) // prints PCMU
  20. }
  21. }

SDP Encoding

  1. package main
  2. import (
  3. "github.com/pixelbender/go-sdp/sdp"
  4. "fmt"
  5. )
  6. func main() {
  7. sess := &sdp.Session{
  8. Origin: &sdp.Origin{
  9. Username: "alice",
  10. Address: "alice.example.org",
  11. SessionID: 2890844526,
  12. SessionVersion: 2890844526,
  13. },
  14. Name: "Example",
  15. Connection: &sdp.Connection{
  16. Address: "127.0.0.1",
  17. },
  18. Media: []*sdp.Media{
  19. {
  20. Type: "audio",
  21. Port: 10000,
  22. Proto: "RTP/AVP",
  23. Format: []*sdp.Format{
  24. {Payload: 0, Name: "PCMU", ClockRate: 8000},
  25. {Payload: 8, Name: "PCMA", ClockRate: 8000},
  26. },
  27. },
  28. },
  29. Mode: sdp.SendRecv,
  30. }
  31. fmt.Println(sess.String())
  32. }

Attributes mapping

Scope Attribute Property
session, media sendrecv, recvonly, sendonly, inactive Session.Mode, Media.Mode
media rtpmap Media.Format
media rtcp-fb Format.Feedback
media fmtp Format.Params

Specifications