summaryrefslogtreecommitdiff
path: root/vendor/github.com/pion/rtp/codecs/opus_packet.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/pion/rtp/codecs/opus_packet.go')
-rw-r--r--vendor/github.com/pion/rtp/codecs/opus_packet.go44
1 files changed, 44 insertions, 0 deletions
diff --git a/vendor/github.com/pion/rtp/codecs/opus_packet.go b/vendor/github.com/pion/rtp/codecs/opus_packet.go
new file mode 100644
index 0000000..504741f
--- /dev/null
+++ b/vendor/github.com/pion/rtp/codecs/opus_packet.go
@@ -0,0 +1,44 @@
+package codecs
+
+// OpusPayloader payloads Opus packets
+type OpusPayloader struct{}
+
+// Payload fragments an Opus packet across one or more byte arrays
+func (p *OpusPayloader) Payload(mtu int, payload []byte) [][]byte {
+ 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
+}
+
+// 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
+}
+
+// OpusPartitionHeadChecker checks Opus partition head
+type OpusPartitionHeadChecker struct{}
+
+// IsPartitionHead checks whether if this is a head of the Opus partition
+func (*OpusPartitionHeadChecker) IsPartitionHead(packet []byte) bool {
+ p := &OpusPacket{}
+ if _, err := p.Unmarshal(packet); err != nil {
+ return false
+ }
+ return true
+}