mirror of
https://github.com/pion/webrtc.git
synced 2025-10-17 20:51:13 +08:00

*Avoid a type switch in srtp.go *Add support for transport layer nack and slice loss indication messages *Add String() functions for several RTCP packets to aid in debugging *Add support for transparent profile extensions to ReceiverReport messages Relates to #119
63 lines
1.2 KiB
Go
63 lines
1.2 KiB
Go
package rtcp
|
|
|
|
// Packet represents an RTCP packet, a protocol used for out-of-band statistics and control information for an RTP session
|
|
type Packet interface {
|
|
Header() Header
|
|
// DestinationSSRC returns an array of SSRC values that this packet refers to.
|
|
DestinationSSRC() []uint32
|
|
|
|
Marshal() ([]byte, error)
|
|
Unmarshal(rawPacket []byte) error
|
|
}
|
|
|
|
// Unmarshal is a factory a polymorphic RTCP packet, and its header,
|
|
func Unmarshal(rawPacket []byte) (Packet, Header, error) {
|
|
var h Header
|
|
var p Packet
|
|
|
|
err := h.Unmarshal(rawPacket)
|
|
if err != nil {
|
|
return nil, h, err
|
|
}
|
|
|
|
switch h.Type {
|
|
case TypeSenderReport:
|
|
p = new(SenderReport)
|
|
|
|
case TypeReceiverReport:
|
|
p = new(ReceiverReport)
|
|
|
|
case TypeSourceDescription:
|
|
p = new(SourceDescription)
|
|
|
|
case TypeGoodbye:
|
|
p = new(Goodbye)
|
|
|
|
case TypeTransportSpecificFeedback:
|
|
switch h.Count {
|
|
case tlnFMT:
|
|
p = new(TransportLayerNack)
|
|
case rrrFMT:
|
|
p = new(RapidResynchronizationRequest)
|
|
default:
|
|
p = new(RawPacket)
|
|
}
|
|
|
|
case TypePayloadSpecificFeedback:
|
|
switch h.Count {
|
|
case pliFMT:
|
|
p = new(PictureLossIndication)
|
|
case sliFMT:
|
|
p = new(SliceLossIndication)
|
|
default:
|
|
p = new(RawPacket)
|
|
}
|
|
|
|
default:
|
|
p = new(RawPacket)
|
|
}
|
|
|
|
err = p.Unmarshal(rawPacket)
|
|
return p, h, err
|
|
}
|