Documentation
¶
Overview ¶
Package rtp provides RTP packetizer and depacketizer
Index ¶
- type AbsCaptureTimeExtension
- type AbsSendTimeExtension
- type AudioLevelExtension
- type DTMFEvent
- type DTMFPacketizer
- type Depacketizer
- type Extension
- type Header
- func (h Header) Clone() Header
- func (h *Header) DelExtension(id uint8) error
- func (h *Header) GetExtension(id uint8) []byte
- func (h *Header) GetExtensionIDs() []uint8
- func (h Header) Marshal() (buf []byte, err error)
- func (h Header) MarshalSize() int
- func (h Header) MarshalTo(buf []byte) (n int, err error)
- func (h *Header) SetExtension(id uint8, payload []byte) error
- func (h *Header) Unmarshal(buf []byte) (n int, err error)
- type HeaderExtension
- type OneByteHeaderExtension
- func (e *OneByteHeaderExtension) Del(id uint8) error
- func (e *OneByteHeaderExtension) Get(id uint8) []byte
- func (e *OneByteHeaderExtension) GetIDs() []uint8
- func (e OneByteHeaderExtension) Marshal() ([]byte, error)
- func (e OneByteHeaderExtension) MarshalSize() int
- func (e OneByteHeaderExtension) MarshalTo(buf []byte) (int, error)
- func (e *OneByteHeaderExtension) Set(id uint8, buf []byte) error
- func (e *OneByteHeaderExtension) Unmarshal(buf []byte) (int, error)
- type Packet
- type Packetizer
- type PartitionHeadChecker
- type Payloader
- type PlayoutDelayExtension
- type RawExtension
- func (e *RawExtension) Del(id uint8) error
- func (e *RawExtension) Get(id uint8) []byte
- func (e *RawExtension) GetIDs() []uint8
- func (e RawExtension) Marshal() ([]byte, error)
- func (e RawExtension) MarshalSize() int
- func (e RawExtension) MarshalTo(buf []byte) (int, error)
- func (e *RawExtension) Set(id uint8, payload []byte) error
- func (e *RawExtension) Unmarshal(buf []byte) (int, error)
- type Sequencer
- type TransportCCExtension
- type TwoByteHeaderExtension
- func (e *TwoByteHeaderExtension) Del(id uint8) error
- func (e *TwoByteHeaderExtension) Get(id uint8) []byte
- func (e *TwoByteHeaderExtension) GetIDs() []uint8
- func (e TwoByteHeaderExtension) Marshal() ([]byte, error)
- func (e TwoByteHeaderExtension) MarshalSize() int
- func (e TwoByteHeaderExtension) MarshalTo(buf []byte) (int, error)
- func (e *TwoByteHeaderExtension) Set(id uint8, buf []byte) error
- func (e *TwoByteHeaderExtension) Unmarshal(buf []byte) (int, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AbsCaptureTimeExtension ¶
AbsCaptureTimeExtension is a extension payload format in http://www.webrtc.org/experiments/rtp-hdrext/abs-capture-time 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=7 | absolute capture timestamp (bit 0-23) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | absolute capture timestamp (bit 24-55) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ... (56-63) | +-+-+-+-+-+-+-+-+
func NewAbsCaptureTimeExtension ¶
func NewAbsCaptureTimeExtension(captureTime time.Time) *AbsCaptureTimeExtension
NewAbsCaptureTimeExtension makes new AbsCaptureTimeExtension from time.Time.
func NewAbsCaptureTimeExtensionWithCaptureClockOffset ¶
func NewAbsCaptureTimeExtensionWithCaptureClockOffset(captureTime time.Time, captureClockOffset time.Duration) *AbsCaptureTimeExtension
NewAbsCaptureTimeExtensionWithCaptureClockOffset makes new AbsCaptureTimeExtension from time.Time and a clock offset.
func (AbsCaptureTimeExtension) CaptureTime ¶
func (t AbsCaptureTimeExtension) CaptureTime() time.Time
CaptureTime produces the estimated time.Time represented by this extension.
func (AbsCaptureTimeExtension) EstimatedCaptureClockOffsetDuration ¶
func (t AbsCaptureTimeExtension) EstimatedCaptureClockOffsetDuration() *time.Duration
EstimatedCaptureClockOffsetDuration produces the estimated time.Duration represented by this extension.
func (AbsCaptureTimeExtension) Marshal ¶
func (t AbsCaptureTimeExtension) Marshal() ([]byte, error)
Marshal serializes the members to buffer.
func (*AbsCaptureTimeExtension) Unmarshal ¶
func (t *AbsCaptureTimeExtension) Unmarshal(rawData []byte) error
Unmarshal parses the passed byte slice and stores the result in the members.
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 ¶
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 DTMFEvent ¶
type DTMFEvent struct {
Event byte // 0-15 (0-9, *, #, A-D)
End bool // end-of-event flag
Volume byte // 0-63
Duration uint16 // in timestamp units
}
DTMFEvent represents a DTMF telephony event as defined in RFC 4733.
type DTMFPacketizer ¶
type DTMFPacketizer struct {
// contains filtered or unexported fields
}
DTMFPacketizer creates RTP packets for DTMF events (RFC 4733). It shares a Sequencer with the audio packetizer so that sequence numbers remain monotonically increasing across both streams.
func NewDTMFPacketizer ¶
func NewDTMFPacketizer(pt uint8, ssrc uint32, sequencer Sequencer) *DTMFPacketizer
NewDTMFPacketizer returns a new DTMFPacketizer. The sequencer should be shared with the audio Packetizer so that RTP sequence numbers are continuous.
func (*DTMFPacketizer) PacketizeEvent ¶
func (d *DTMFPacketizer) PacketizeEvent(event DTMFEvent, marker bool) *Packet
PacketizeEvent builds a single RTP packet carrying a 4-byte RFC 4733 telephony-event payload. The caller controls the marker bit (should be true for the first packet of an event).
func (*DTMFPacketizer) StartEvent ¶
func (d *DTMFPacketizer) StartEvent(timestamp uint32)
StartEvent records the RTP timestamp that marks the beginning of a new DTMF event. All packets belonging to this event will carry this timestamp as required by RFC 4733.
type Depacketizer ¶
type Depacketizer interface {
Unmarshal(packet []byte) ([]byte, error)
// Checks if the packet is at the beginning of a partition. This
// should return false if the result could not be determined, in
// which case the caller will detect timestamp discontinuities.
IsPartitionHead(payload []byte) bool
// Checks if the packet is at the end of a partition. This should
// return false if the result could not be determined.
IsPartitionTail(marker bool, payload []byte) bool
}
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 ¶
type Header struct {
Version uint8
Padding bool
Extension bool
Marker bool
PayloadType uint8
SequenceNumber uint16
Timestamp uint32
SSRC uint32
CSRC []uint32
ExtensionProfile uint16
Extensions []Extension
// Deprecated: will be removed in a future version.
PayloadOffset int
}
Header represents an RTP packet header
func (*Header) DelExtension ¶
DelExtension Removes an RTP Header extension
func (*Header) GetExtension ¶
GetExtension returns an RTP header extension
func (*Header) GetExtensionIDs ¶
GetExtensionIDs returns an extension id array
func (Header) MarshalSize ¶
MarshalSize returns the size of the header once marshaled.
func (*Header) SetExtension ¶
SetExtension sets an RTP header extension
type HeaderExtension ¶
type HeaderExtension interface {
Set(id uint8, payload []byte) error
GetIDs() []uint8
Get(id uint8) []byte
Del(id uint8) error
Unmarshal(buf []byte) (int, error)
Marshal() ([]byte, error)
MarshalTo(buf []byte) (int, error)
MarshalSize() int
}
HeaderExtension represents an RTP extension header.
type OneByteHeaderExtension ¶
type OneByteHeaderExtension struct {
// contains filtered or unexported fields
}
OneByteHeaderExtension is an RFC8285 one-byte header extension.
func (*OneByteHeaderExtension) Del ¶
func (e *OneByteHeaderExtension) Del(id uint8) error
Del deletes the extension with the specified ID.
func (*OneByteHeaderExtension) Get ¶
func (e *OneByteHeaderExtension) Get(id uint8) []byte
Get returns the payload of the extension with the given ID.
func (*OneByteHeaderExtension) GetIDs ¶
func (e *OneByteHeaderExtension) GetIDs() []uint8
GetIDs returns the available IDs.
func (OneByteHeaderExtension) Marshal ¶
func (e OneByteHeaderExtension) Marshal() ([]byte, error)
Marshal returns the extension payload.
func (OneByteHeaderExtension) MarshalSize ¶
func (e OneByteHeaderExtension) MarshalSize() int
MarshalSize returns the size of the extension payload.
func (OneByteHeaderExtension) MarshalTo ¶
func (e OneByteHeaderExtension) MarshalTo(buf []byte) (int, error)
MarshalTo writes the extension payload to the given buffer.
type Packet ¶
type Packet struct {
Header
Payload []byte
PaddingSize byte
// Deprecated: will be removed in a future version.
Raw []byte
}
Packet represents an RTP Packet
func (Packet) MarshalSize ¶
MarshalSize returns the size of the packet once marshaled.
type Packetizer ¶
type Packetizer interface {
Packetize(payload []byte, samples uint32) []*Packet
EnableAbsSendTime(value int)
SkipSamples(skippedSamples uint32)
SetMarker(val bool)
CurrentTimestamp() uint32
}
Packetizer packetizes a payload
func NewPacketizer ¶
func NewPacketizer(mtu uint16, 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 ¶
PartitionHeadChecker is the interface that checks whether the packet is keyframe or not
type PlayoutDelayExtension ¶
type PlayoutDelayExtension struct {
// contains filtered or unexported fields
}
PlayoutDelayExtension is a extension payload format in http://www.webrtc.org/experiments/rtp-hdrext/playout-delay 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=2 | MIN delay | MAX delay | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
func (PlayoutDelayExtension) Marshal ¶
func (p PlayoutDelayExtension) Marshal() ([]byte, error)
Marshal serializes the members to buffer
func (*PlayoutDelayExtension) Unmarshal ¶
func (p *PlayoutDelayExtension) Unmarshal(rawData []byte) error
Unmarshal parses the passed byte slice and stores the result in the members
type RawExtension ¶
type RawExtension struct {
// contains filtered or unexported fields
}
RawExtension represents an RFC3550 header extension.
func (*RawExtension) Del ¶
func (e *RawExtension) Del(id uint8) error
Del deletes the extension with the specified ID.
func (*RawExtension) Get ¶
func (e *RawExtension) Get(id uint8) []byte
Get returns the payload of the extension with the given ID.
func (*RawExtension) GetIDs ¶
func (e *RawExtension) GetIDs() []uint8
GetIDs returns the available IDs.
func (RawExtension) Marshal ¶
func (e RawExtension) Marshal() ([]byte, error)
Marshal returns the raw extension payload.
func (RawExtension) MarshalSize ¶
func (e RawExtension) MarshalSize() int
MarshalSize returns the size of the extension when marshaled.
func (RawExtension) MarshalTo ¶
func (e RawExtension) MarshalTo(buf []byte) (int, error)
MarshalTo marshals the extension to the given buffer.
type Sequencer ¶
Sequencer generates sequential sequence numbers for building RTP packets
func NewFixedSequencer ¶
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
type TwoByteHeaderExtension ¶
type TwoByteHeaderExtension struct {
// contains filtered or unexported fields
}
TwoByteHeaderExtension is an RFC8285 two-byte header extension.
func (*TwoByteHeaderExtension) Del ¶
func (e *TwoByteHeaderExtension) Del(id uint8) error
Del deletes the extension with the specified ID.
func (*TwoByteHeaderExtension) Get ¶
func (e *TwoByteHeaderExtension) Get(id uint8) []byte
Get returns the payload of the extension with the given ID.
func (*TwoByteHeaderExtension) GetIDs ¶
func (e *TwoByteHeaderExtension) GetIDs() []uint8
GetIDs returns the available IDs.
func (TwoByteHeaderExtension) Marshal ¶
func (e TwoByteHeaderExtension) Marshal() ([]byte, error)
Marshal returns the extension payload.
func (TwoByteHeaderExtension) MarshalSize ¶
func (e TwoByteHeaderExtension) MarshalSize() int
MarshalSize returns the size of the extension payload.
func (TwoByteHeaderExtension) MarshalTo ¶
func (e TwoByteHeaderExtension) MarshalTo(buf []byte) (int, error)
MarshalTo marshals the extension to the given buffer.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package codecs implements codec specific RTP payloader/depayloaders
|
Package codecs implements codec specific RTP payloader/depayloaders |
|
av1/frame
Package frame provides code to construct complete media frames from packetized media.
|
Package frame provides code to construct complete media frames from packetized media. |
|
av1/obu
Package obu implements tools for working with the Open Bitstream Unit.
|
Package obu implements tools for working with the Open Bitstream Unit. |
|
pkg
|
|
|
frame
Package frame is deprecated.
|
Package frame is deprecated. |
|
obu
Package obu is deprecated.
|
Package obu is deprecated. |