package rtcp
import (
"encoding/binary"
"fmt"
)
type RapidResynchronizationRequest struct {
SenderSSRC uint32
MediaSSRC uint32
}
type RapidResynchronisationRequest = RapidResynchronizationRequest
const (
rrrLength = 2
rrrHeaderLength = ssrcLength * 2
rrrMediaOffset = 4
)
func (p RapidResynchronizationRequest ) Marshal () ([]byte , error ) {
rawPacket := make ([]byte , p .MarshalSize ())
packetBody := rawPacket [headerLength :]
binary .BigEndian .PutUint32 (packetBody , p .SenderSSRC )
binary .BigEndian .PutUint32 (packetBody [rrrMediaOffset :], p .MediaSSRC )
hData , err := p .Header ().Marshal ()
if err != nil {
return nil , err
}
copy (rawPacket , hData )
return rawPacket , nil
}
func (p *RapidResynchronizationRequest ) Unmarshal (rawPacket []byte ) error {
if len (rawPacket ) < (headerLength + (ssrcLength * 2 )) {
return errPacketTooShort
}
var h Header
if err := h .Unmarshal (rawPacket ); err != nil {
return err
}
if h .Type != TypeTransportSpecificFeedback || h .Count != FormatRRR {
return errWrongType
}
p .SenderSSRC = binary .BigEndian .Uint32 (rawPacket [headerLength :])
p .MediaSSRC = binary .BigEndian .Uint32 (rawPacket [headerLength +ssrcLength :])
return nil
}
func (p *RapidResynchronizationRequest ) MarshalSize () int {
return headerLength + rrrHeaderLength
}
func (p *RapidResynchronizationRequest ) Header () Header {
return Header {
Count : FormatRRR ,
Type : TypeTransportSpecificFeedback ,
Length : rrrLength ,
}
}
func (p *RapidResynchronizationRequest ) DestinationSSRC () []uint32 {
return []uint32 {p .MediaSSRC }
}
func (p *RapidResynchronizationRequest ) String () string {
return fmt .Sprintf ("RapidResynchronizationRequest %x %x" , p .SenderSSRC , p .MediaSSRC )
}
The pages are generated with Golds v0.8.2 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds .