go-rtp: bitbucket.org/liamstask/go-rtp/rtp Index | Files

package rtp

import "bitbucket.org/liamstask/go-rtp/rtp"


Package Files

handler.go interval.go packetRtcp.go packetRtp.go session.go source.go transport.go transportUdp.go


const (
    RtcpSenderReport   = 200
    RtcpReceiverReport = 201
    RtcpSdes           = 202
    RtcpBye            = 203

RTCP packet types

const (
    SdesEnd       = iota // end of SDES list, null octet
    SdesCname            // canonical name
    SdesName             // user name
    SdesEmail            // user's electronic mail address
    SdesPhone            // user's phone number
    SdesLoc              // geographic user location
    SdesTool             // name of application or tool
    SdesNote             // notice about the source
    SdesPriv             // private extensions
    SdesH323Caddr        // H.323 callable address


SDES chunk types

const (
    Audio = 1 << 0
    Video = 1 << 1


var PayloadTypes = map[uint8]*PayloadType{
    0:  {Audio, 8000, 1, "PCMU"},
    3:  {Audio, 8000, 1, "GSM"},
    4:  {Audio, 8000, 1, "G723"},
    5:  {Audio, 8000, 1, "DVI4"},
    6:  {Audio, 16000, 1, "DVI4"},
    7:  {Audio, 8000, 1, "LPC"},
    8:  {Audio, 8000, 1, "PCMA"},
    9:  {Audio, 8000, 1, "G722"},
    10: {Audio, 44100, 2, "L16"},
    11: {Audio, 44100, 1, "L16"},
    12: {Audio, 8000, 1, "QCELP"},
    13: {Audio, 8000, 1, "CN"},
    14: {Audio, 90000, 0, "MPA"},
    15: {Audio, 8000, 1, "G728"},
    16: {Audio, 11025, 1, "DVI4"},
    17: {Audio, 22050, 1, "DVI4"},
    18: {Audio, 8000, 1, "G729"},
    25: {Video, 90000, 0, "CelB"},
    26: {Video, 90000, 0, "JPEG"},
    28: {Video, 90000, 0, "nv"},
    31: {Video, 90000, 0, "H261"},
    32: {Video, 90000, 0, "MPV"},
    33: {Audio | Video, 90000, 0, "MP2T"},
    34: {Video, 90000, 0, "H263"},

type ByePacket

type ByePacket struct {
    Header *RtcpFixedHeader
    Srcs   []uint32
    Reason string

type CtrlEvent

type CtrlEvent struct {
    EventType int    // Either a Stream event or a Rtcp* packet type event, e.g. RtcpSR, RtcpRR, RtcpSdes, RtcpBye
    Ssrc      uint32 // the input stream's SSRC
    Index     uint32 // and its index
    Reason    string // Resaon string if it was available, empty otherwise

type CtrlEventHandler

type CtrlEventHandler interface {

type CtrlEventHandlerFunc

type CtrlEventHandlerFunc func(*CtrlEvent)

func (CtrlEventHandlerFunc) HandleCtrlEvent

func (f CtrlEventHandlerFunc) HandleCtrlEvent(e *CtrlEvent)

type PayloadType

type PayloadType struct {
    Media      int // audio or video
    SampleRate int
    Channels   int
    Name       string

type ReceiverReport

type ReceiverReport struct {
    Header  *RtcpFixedHeader
    SyncSrc uint8

type ReceptionReport

type ReceptionReport struct {
    Ssrc             uint32
    FracLost         uint8
    PacketsLost      uint32
    HighSeqNum       uint32
    Jitter           uint32
    LastSRTimestamp  uint32
    DelaySinceLastSR uint32

sub-struct within a SenderReport

type RtcpFixedHeader

type RtcpFixedHeader struct {
    Version    uint8
    Padding    bool
    RCount     uint8
    PacketType uint8
    Length     int // in bytes

each RTCP packet begins with a fixed header

type RtcpHandler

type RtcpHandler interface {

type RtcpHandlerFunc

type RtcpHandlerFunc func(*RtcpPacket)

func (RtcpHandlerFunc) HandleRtcp

func (f RtcpHandlerFunc) HandleRtcp(p *RtcpPacket)

type RtcpPacket

type RtcpPacket struct {
    // contains filtered or unexported fields

func (*RtcpPacket) ByePacket

func (p *RtcpPacket) ByePacket(h *RtcpFixedHeader, pos int) *ByePacket

Extract a BYE packet starting at pos

func (*RtcpPacket) Header

func (p *RtcpPacket) Header(pos int) *RtcpFixedHeader

Extract the fixed size header from this packet starting at pos

func (*RtcpPacket) SdesPacket

func (p *RtcpPacket) SdesPacket(h *RtcpFixedHeader, pos int) *SdesPacket

Extract an SDES packet starting at pos

func (*RtcpPacket) SenderReport

func (p *RtcpPacket) SenderReport(h *RtcpFixedHeader, pos int) *SenderReport

Extract a sender report from this packet starting at pos.

type RtpHandler

type RtpHandler interface {

type RtpHandlerFunc

type RtpHandlerFunc func(*RtpPacket)

func (RtpHandlerFunc) HandleRtp

func (f RtpHandlerFunc) HandleRtp(p *RtpPacket)

type RtpHeader

type RtpHeader struct {
    Version     uint8
    Padding     bool
    Extension   bool
    CsrcCount   uint8 // 0 - 15
    Marker      bool
    PayloadType uint8
    SeqNum      uint16 // init'd randomly to avoid plaintext attacks
    Timestamp   uint32
    SyncSrc     uint32
    CsrcList    []uint32 // len == CsrcCount

Fixed size header for all RTP packets

func (*RtpHeader) IsValid

func (h *RtpHeader) IsValid() bool

type RtpPacket

type RtpPacket struct {
    // contains filtered or unexported fields

func (*RtpPacket) Header

func (p *RtpPacket) Header() (*RtpHeader, error)

Extract the fixed size header from the beginning of this packet

type SdesChunk

type SdesChunk struct {
    Ssrc  uint32
    Items []SdesItem

type SdesItem

type SdesItem struct {
    Type uint8
    Text string

type SdesPacket

type SdesPacket struct {
    Header *RtcpFixedHeader
    Chunks []SdesChunk

type SenderReport

type SenderReport struct {
    Header  *RtcpFixedHeader
    SyncSrc uint32

    // sender info
    NtpTimestamp uint64
    RtpTimestamp uint32
    PacketCount  uint32
    OctetCount   uint32

    ReceptionReports []ReceptionReport

type Session

type Session struct {
    RtpHandler       RtpHandler
    RtcpHandler      RtcpHandler
    CtrlEventHandler CtrlEventHandler
    Transport        Transport

    sync.RWMutex // locks access to state below
    // contains filtered or unexported fields

func NewSession

func NewSession(t Transport) *Session

func (*Session) HandleRtcp

func (s *Session) HandleRtcp(p *RtcpPacket)

a new RTCP packet has arrived from our transport.

any RTCP packet can be compound, which means individual packets can be stacked back to back in the same transport layer packet.

func (*Session) HandleRtp

func (s *Session) HandleRtp(p *RtpPacket)

a new RTP packet has arrived from our transport

func (*Session) Start

func (s *Session) Start() error

type Source

type Source struct {
    // contains filtered or unexported fields

type Transport

type Transport interface {
    ListenAndServe() error

Transport sends and receives data on the wire

type TransportHandler

type TransportHandler interface {

Transport reports new data to its TransportHandler

type TransportUDP

type TransportUDP struct {
    Handler  TransportHandler
    RtpAddr  string
    RtcpAddr string

func NewTransportUDP

func NewTransportUDP(rtp, rtcp string) *TransportUDP

func (*TransportUDP) ListenAndServe

func (t *TransportUDP) ListenAndServe() error

listen for both incoming rtp and rtcp data

func (*TransportUDP) SetHandler

func (t *TransportUDP) SetHandler(h TransportHandler)

Package rtp imports 8 packages (graph) and is imported by 1 packages. Updated 2014-01-14. Refresh now. Tools for package owners.