package rtcp
import (
"encoding/binary"
"fmt"
)
type PictureLossIndication struct {
SenderSSRC uint32
MediaSSRC uint32
}
const (
pliLength = 2
)
func (p PictureLossIndication ) Marshal () ([]byte , error ) {
rawPacket := make ([]byte , p .MarshalSize ())
packetBody := rawPacket [headerLength :]
binary .BigEndian .PutUint32 (packetBody , p .SenderSSRC )
binary .BigEndian .PutUint32 (packetBody [4 :], p .MediaSSRC )
h := Header {
Count : FormatPLI ,
Type : TypePayloadSpecificFeedback ,
Length : pliLength ,
}
hData , err := h .Marshal ()
if err != nil {
return nil , err
}
copy (rawPacket , hData )
return rawPacket , nil
}
func (p *PictureLossIndication ) 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 != TypePayloadSpecificFeedback || h .Count != FormatPLI {
return errWrongType
}
p .SenderSSRC = binary .BigEndian .Uint32 (rawPacket [headerLength :])
p .MediaSSRC = binary .BigEndian .Uint32 (rawPacket [headerLength +ssrcLength :])
return nil
}
func (p *PictureLossIndication ) Header () Header {
return Header {
Count : FormatPLI ,
Type : TypePayloadSpecificFeedback ,
Length : pliLength ,
}
}
func (p *PictureLossIndication ) MarshalSize () int {
return headerLength + ssrcLength *2
}
func (p *PictureLossIndication ) String () string {
return fmt .Sprintf ("PictureLossIndication %x %x" , p .SenderSSRC , p .MediaSSRC )
}
func (p *PictureLossIndication ) DestinationSSRC () []uint32 {
return []uint32 {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 .