mirror of https://bitbucket.org/ausocean/av.git
rtp: added some commenting
This commit is contained in:
parent
1cebc821d1
commit
efe2333683
|
@ -40,11 +40,11 @@ const (
|
|||
timestampFreq = 90000 // Hz
|
||||
mtsSize = 188
|
||||
bufferSize = 1000
|
||||
maxMtsPerRtp = 7
|
||||
bufferCap = 7 * 188
|
||||
sendLength = 7 * 188
|
||||
)
|
||||
|
||||
// Encoder implements io writer and provides functionality to wrap data into
|
||||
// rtp packets
|
||||
type Encoder struct {
|
||||
dst io.Writer
|
||||
ssrc uint32
|
||||
|
@ -63,10 +63,12 @@ func NewEncoder(dst io.Writer, fps int) *Encoder {
|
|||
ssrc: rand.Uint32(),
|
||||
frameInterval: time.Duration(float64(time.Second) / float64(fps)),
|
||||
fps: fps,
|
||||
buffer: make([]byte, 0, bufferCap),
|
||||
buffer: make([]byte, 0, sendLength),
|
||||
}
|
||||
}
|
||||
|
||||
// Write provides an interface between a prior encoder and this rtp encoder,
|
||||
// so that multiple layers of packetization can occur.
|
||||
func (e *Encoder) Write(data []byte) (int, error) {
|
||||
e.buffer = append(e.buffer, data...)
|
||||
for len(e.buffer) >= sendLength {
|
||||
|
|
|
@ -36,6 +36,7 @@ const (
|
|||
rtpVer = 2
|
||||
)
|
||||
|
||||
// Pkt provides fields consistent with RFC3550 definition of an rtp packet
|
||||
type Pkt struct {
|
||||
V byte // Version (currently 2)
|
||||
P byte // Padding indicator (0 => padding, 1 => padding)
|
||||
|
@ -50,6 +51,7 @@ type Pkt struct {
|
|||
Padding byte // No of bytes of padding
|
||||
}
|
||||
|
||||
// Bytes provides a byte slice of the packet
|
||||
func (p *Pkt) Bytes() []byte {
|
||||
if p.V == 0 {
|
||||
p.V = rtpVer
|
||||
|
|
Loading…
Reference in New Issue