rtprtcp

package
v0.19.10 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RTCPPacketTypeSR = 200 // 0xc8 Sender Report
	RTCPPacketTypeRR = 201 // 0xc9 Receiver Report

	RTCPVersion = 2
)
View Source
const (
	NALUTypeAVCSingleMax = 23
	NALUTypeAVCSTAPA     = 24 // one packet, multiple nals
	NALUTypeAVCFUA       = 28
)
View Source
const (
	PositionTypeSingle    uint8 = 1
	PositionTypeFUAStart  uint8 = 2
	PositionTypeFUAMiddle uint8 = 3
	PositionTypeFUAEnd    uint8 = 4
	PositionTypeSTAPA     uint8 = 5
)
View Source
const MaxRTPRTCPPacketSize = 1500
View Source
const (
	NALUTypeHEVCFUA = 49
)
View Source
const (
	RTPFixedHeaderLength = 12
)

Variables

View Source
var ErrRTCP = errors.New("lal.rtcp: fxxk")
View Source
var ErrRTP = errors.New("lal.rtp: fxxk")

Functions

func CompareSeq

func CompareSeq(a, b uint16) int

比较序号的值,内部处理序号翻转问题,见单元测试中的例子

func MSWLSW2NTP

func MSWLSW2NTP(msw, lsw uint64) uint64

msw是ntp的高32位,lsw是ntp的低32位

func MSWLSW2UnixNano

func MSWLSW2UnixNano(msw, lsw uint64) uint64

将ntp时间戳(高32位低32位分开的形式)转换为Unix时间戳

func NTP2UnixNano

func NTP2UnixNano(v uint64) uint64

将ntp时间戳转换为Unix时间戳,Unix时间戳单位是纳秒

func SubSeq

func SubSeq(a, b uint16) int

a减b的值,内部处理序号翻转问题,如果a小于b,则返回负值,见单元测试中的例子

Types

type OnAVPacket

type OnAVPacket func(pkt base.AVPacket)

pkt: pkt.Timestamp RTP包头中的时间戳(pts)经过clockrate换算后的时间戳,单位毫秒

                注意,不支持带B帧的视频流,pts和dts永远相同
pkt.PayloadType base.AVPacketPTXXX
pkt.Payload     如果是AAC,返回的是raw frame,一个AVPacket只包含一帧
                如果是AVC或HEVC,一个AVPacket可能包含多个NAL(受STAP-A影响),所以NAL前包含4字节的长度信息
                AAC引用的是接收到的RTP包中的内存块
                AVC或者HEVC是新申请的内存块,回调结束后,内部不再使用该内存块

type RR

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

func (*RR) Pack

func (r *RR) Pack() []byte

type RRProducer

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

func NewRRProducer

func NewRRProducer(clockRate int) *RRProducer

func (*RRProducer) FeedRTPPacket

func (r *RRProducer) FeedRTPPacket(seq uint16)

每次收到rtp包,都将seq序号传入这个函数

func (*RRProducer) Produce

func (r *RRProducer) Produce(lsr uint32) []byte

收到sr包时,产生rr包

lsr: 从sr包中获取,见func SR.GetMiddleNTP @return: rr包的二进制数据

type RTCPHeader

type RTCPHeader struct {
	Version       uint8  // 2b
	Padding       uint8  // 1b
	CountOrFormat uint8  // 5b
	PacketType    uint8  // 8b
	Length        uint16 // 16b, byte length = (length+1) * 4
}

func ParseRTCPHeader

func ParseRTCPHeader(b []byte) RTCPHeader

func (*RTCPHeader) PackTo

func (r *RTCPHeader) PackTo(out []byte)

out 传出参数,注意,调用方保证长度>=4

type RTPHeader

type RTPHeader struct {
	Version    uint8  // 2b  *
	Padding    uint8  // 1b
	Extension  uint8  // 1
	CsrcCount  uint8  // 4b
	Mark       uint8  // 1b  *
	PacketType uint8  // 7b
	Seq        uint16 // 16b **
	Timestamp  uint32 // 32b ****
	SSRC       uint32 // 32b **** Synchronization source
	// contains filtered or unexported fields
}

func ParseRTPPacket

func ParseRTPPacket(b []byte) (h RTPHeader, err error)

type RTPPacket

type RTPPacket struct {
	Header RTPHeader
	Raw    []byte // 包含header内存
	// contains filtered or unexported fields
}

type RTPPacketList

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

type RTPPacketListItem

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

type RTPUnpacker

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

func NewRTPUnpacker

func NewRTPUnpacker(payloadType base.AVPacketPT, clockRate int, maxSize int, onAVPacket OnAVPacket) *RTPUnpacker

func (*RTPUnpacker) Feed

func (r *RTPUnpacker) Feed(pkt RTPPacket)

输入收到的rtp包

type SR

type SR struct {
	SenderSSRC uint32
	MSW        uint32 // NTP timestamp, most significant word
	LSW        uint32 // NTP timestamp, least significant word
	Timestamp  uint32
	PktCnt     uint32
	OctetCnt   uint32
}

func ParseSR

func ParseSR(b []byte) SR

rfc3550 6.4.1

b rtcp包,包含包头

func (*SR) GetMiddleNTP

func (s *SR) GetMiddleNTP() uint32

Jump to

Keyboard shortcuts

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