rtp

package module
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 16, 2020 License: MIT Imports: 11 Imported by: 9

README


Pion RTP

A Go implementation of RTP

Pion RTP Sourcegraph Widget Slack Widget
Build Status GoDoc Coverage Status Go Report Card


Roadmap

The library is used as a part of our WebRTC implementation. Please refer to that roadmap to track our major milestones.

Community

Pion has an active community on the Golang Slack. Sign up and join the #pion channel for discussions and support. You can also use Pion mailing list.

We are always looking to support your projects. Please reach out if you have something to build!

If you need commercial support or don't want to use public methods you can contact us at team@pion.ly

Contributing

Check out the contributing wiki to join the group of amazing people making this project possible:

License

MIT License - see LICENSE for full text

Documentation

Overview

Package rtp provides RTP packetizer and depacketizer

Index

Constants

View Source
const (
	MIME_TYPE_UNSET = iota
	MIME_TYPE_AUDIO
	MIME_TYPE_VIDEO
)
View Source
const (
	SUB_TYPE_UNSET = iota
	SUB_TYPE_VP8
	SUB_TYPE_VP9
	SUB_TYPE_H264

	SUB_TYPE_OPUS

	SUB_TYPE_RED
	SUB_TYPE_ULPFEC
)

Variables

This section is empty.

Functions

func ProcessRtpPacket

func ProcessRtpPacket(packet *Packet, codetype CodeType)

func ProcessRtpPacketH264

func ProcessRtpPacketH264(packet *Packet) codecs.PayloadDescriptor

func ProcessRtpPacketVP8

func ProcessRtpPacketVP8(packet *Packet) codecs.PayloadDescriptor

Types

type AbsSendTimeExtension

type AbsSendTimeExtension struct {
	Timestamp uint64
}

AbsSendTimeExtension is a extension payload format in http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time

func NewAbsSendTimeExtension

func NewAbsSendTimeExtension(sendTime time.Time) *AbsSendTimeExtension

NewAbsSendTimeExtension makes new AbsSendTimeExtension from time.Time.

func (*AbsSendTimeExtension) Estimate

func (t *AbsSendTimeExtension) Estimate(receive time.Time) time.Time

Estimate absolute send time according to the receive time. Note that if the transmission delay is larger than 64 seconds, estimated time will be wrong.

func (*AbsSendTimeExtension) Marshal

func (t *AbsSendTimeExtension) Marshal() ([]byte, error)

Marshal serializes the members to buffer.

func (*AbsSendTimeExtension) Unmarshal

func (t *AbsSendTimeExtension) Unmarshal(rawData []byte) error

Unmarshal parses the passed byte slice and stores the result in the members.

type AudioLevelExtension

type AudioLevelExtension struct {
	Level uint8
	Voice bool
}

AudioLevelExtension is a extension payload format described in https://tools.ietf.org/html/rfc6464

Implementation based on: https://chromium.googlesource.com/external/webrtc/+/e2a017725570ead5946a4ca8235af27470ca0df9/webrtc/modules/rtp_rtcp/source/rtp_header_extensions.cc#49

One byte format: 0 1 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ID | len=0 |V| level | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Two byte format: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ID | len=1 |V| level | 0 (pad) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

func (*AudioLevelExtension) Marshal

func (a *AudioLevelExtension) Marshal() ([]byte, error)

Marshal serializes the members to buffer

func (*AudioLevelExtension) Unmarshal

func (a *AudioLevelExtension) Unmarshal(rawData []byte) error

Unmarshal parses the passed byte slice and stores the result in the members

type CodeType

type CodeType struct {
	MimeType int
	SubType  int
}

type Depacketizer

type Depacketizer interface {
	Unmarshal(packet []byte) ([]byte, error)
}

Depacketizer depacketizes a RTP payload, removing any RTP specific data from the payload

type Extension

type Extension struct {
	// contains filtered or unexported fields
}

Extension RTP Header extension

type Header struct {
	Version          uint8
	Padding          bool
	Extension        bool
	Marker           bool
	PayloadOffset    int
	PayloadType      uint8
	SequenceNumber   uint16
	Timestamp        uint32
	SSRC             uint32
	CSRC             []uint32
	ExtensionProfile uint16
	Extensions       []Extension
}

Header represents an RTP packet header NOTE: PayloadOffset is populated by Marshal/Unmarshal and should not be modified

func (*Header) DelExtension

func (h *Header) DelExtension(id uint8) error

DelExtension Removes an RTP Header extension

func (*Header) GetExtension

func (h *Header) GetExtension(id uint8) []byte

GetExtension returns an RTP header extension

func (*Header) Marshal

func (h *Header) Marshal() (buf []byte, err error)

Marshal serializes the header into bytes.

func (*Header) MarshalSize

func (h *Header) MarshalSize() int

MarshalSize returns the size of the header once marshaled.

func (*Header) MarshalTo

func (h *Header) MarshalTo(buf []byte) (n int, err error)

MarshalTo serializes the header and writes to the buffer.

func (*Header) SetExtension

func (h *Header) SetExtension(id uint8, payload []byte) error

SetExtension sets an RTP header extension

func (*Header) Unmarshal

func (h *Header) Unmarshal(rawPacket []byte) error

Unmarshal parses the passed byte slice and stores the result in the Header this method is called upon

type Packet

type Packet struct {
	Header
	Raw     []byte
	Payload []byte

	//miaobinwei
	RawLen                   int
	PayloadLength            int
	PayloadPadding           uint8
	PayloadDescriptorHandler codecs.PayloadDescriptor
}

Packet represents an RTP Packet NOTE: Raw is populated by Marshal/Unmarshal and should not be modified

func (*Packet) Clone

func (p *Packet) Clone() *Packet

func (*Packet) GetSpatialLayer

func (p *Packet) GetSpatialLayer() uint8

func (*Packet) GetTemporalLayer

func (p *Packet) GetTemporalLayer() uint8

func (*Packet) IsKeyFrame

func (p *Packet) IsKeyFrame() bool

miaobinwei

func (*Packet) Marshal

func (p *Packet) Marshal() (buf []byte, err error)

Marshal serializes the packet into bytes.

func (*Packet) MarshalSize

func (p *Packet) MarshalSize() int

MarshalSize returns the size of the packet once marshaled.

func (*Packet) MarshalTo

func (p *Packet) MarshalTo(buf []byte) (n int, err error)

MarshalTo serializes the packet and writes to the buffer.

func (*Packet) ReadAbsSendTime

func (p *Packet) ReadAbsSendTime(absId uint8, time *uint32) bool

func (*Packet) RtxDecode

func (p *Packet) RtxDecode(payloadType uint8, ssrc uint32) bool

func (Packet) String

func (p Packet) String() string

String helps with debugging by printing packet information in a readable way

func (*Packet) Unmarshal

func (p *Packet) Unmarshal(rawPacket []byte) error

Unmarshal parses the passed byte slice and stores the result in the Packet this method is called upon

type Packetizer

type Packetizer interface {
	Packetize(payload []byte, samples uint32) []*Packet
	EnableAbsSendTime(value int)
}

Packetizer packetizes a payload

func NewPacketizer

func NewPacketizer(mtu int, pt uint8, ssrc uint32, payloader Payloader, sequencer Sequencer, clockRate uint32) Packetizer

NewPacketizer returns a new instance of a Packetizer for a specific payloader

type PartitionHeadChecker

type PartitionHeadChecker interface {
	IsPartitionHead([]byte) bool
}

PartitionHeadChecker is the interface that checks whether the packet is keyframe or not

type Payloader

type Payloader interface {
	Payload(mtu int, payload []byte) [][]byte
}

Payloader payloads a byte array for use as rtp.Packet payloads

type Sequencer

type Sequencer interface {
	NextSequenceNumber() uint16
	RollOverCount() uint64
}

Sequencer generates sequential sequence numbers for building RTP packets

func NewFixedSequencer

func NewFixedSequencer(s uint16) Sequencer

NewFixedSequencer returns a new sequencer starting from a specific sequence number

func NewRandomSequencer

func NewRandomSequencer() Sequencer

NewRandomSequencer returns a new sequencer starting from a random sequence number

type TransportCCExtension

type TransportCCExtension struct {
	TransportSequence uint16
}

TransportCCExtension is a extension payload format in https://tools.ietf.org/html/draft-holmer-rmcat-transport-wide-cc-extensions-01 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 0xBE | 0xDE | length=1 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ID | L=1 |transport-wide sequence number | zero padding | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

func (*TransportCCExtension) Marshal

func (t *TransportCCExtension) Marshal() ([]byte, error)

Marshal serializes the members to buffer

func (*TransportCCExtension) Unmarshal

func (t *TransportCCExtension) Unmarshal(rawData []byte) error

Unmarshal parses the passed byte slice and stores the result in the members

Directories

Path Synopsis
Package codecs implements codec specific RTP payloader/depayloaders
Package codecs implements codec specific RTP payloader/depayloaders

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL