move RTP decoders/encoders into pkt/rtpcodecs

This commit is contained in:
aler9
2022-11-15 23:08:36 +01:00
parent 9795e9175a
commit c2c0230669
49 changed files with 14 additions and 15 deletions

View File

@@ -0,0 +1,26 @@
package rtpsimpleaudio
import (
"time"
"github.com/pion/rtp"
"github.com/aler9/gortsplib/pkg/rtptimedec"
)
// Decoder is a RTP/simple audio decoder.
type Decoder struct {
SampleRate int
timeDecoder *rtptimedec.Decoder
}
// Init initializes the decoder.
func (d *Decoder) Init() {
d.timeDecoder = rtptimedec.New(d.SampleRate)
}
// Decode decodes an audio frame from a RTP packet.
func (d *Decoder) Decode(pkt *rtp.Packet) ([]byte, time.Duration, error) {
return pkt.Payload, d.timeDecoder.Decode(pkt.Timestamp), nil
}