status-go/vendor/github.com/pion/rtp/codecs/opus_packet.go

50 lines
1.3 KiB
Go
Raw Normal View History

2024-06-05 20:10:03 +00:00
// SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
// SPDX-License-Identifier: MIT
2022-03-10 09:44:48 +00:00
package codecs
// OpusPayloader payloads Opus packets
type OpusPayloader struct{}
// Payload fragments an Opus packet across one or more byte arrays
2024-06-05 20:10:03 +00:00
func (p *OpusPayloader) Payload(_ uint16, payload []byte) [][]byte {
2022-03-10 09:44:48 +00:00
if payload == nil {
return [][]byte{}
}
out := make([]byte, len(payload))
copy(out, payload)
return [][]byte{out}
}
// OpusPacket represents the Opus header that is stored in the payload of an RTP Packet
type OpusPacket struct {
Payload []byte
audioDepacketizer
}
// Unmarshal parses the passed byte slice and stores the result in the OpusPacket this method is called upon
func (p *OpusPacket) Unmarshal(packet []byte) ([]byte, error) {
if packet == nil {
return nil, errNilPacket
} else if len(packet) == 0 {
return nil, errShortPacket
}
p.Payload = packet
return packet, nil
}
2024-06-05 20:10:03 +00:00
// OpusPartitionHeadChecker checks Opus partition head.
//
// Deprecated: replaced by OpusPacket.IsPartitionHead()
2022-03-10 09:44:48 +00:00
type OpusPartitionHeadChecker struct{}
2024-06-05 20:10:03 +00:00
// IsPartitionHead checks whether if this is a head of the Opus partition.
//
// Deprecated: replaced by OpusPacket.IsPartitionHead()
func (*OpusPartitionHeadChecker) IsPartitionHead(packet []byte) bool {
return (&OpusPacket{}).IsPartitionHead(packet)
}