mirror of
https://github.com/aler9/gortsplib
synced 2025-10-06 23:52:46 +08:00
move RTP decoders/encoders into pkt/rtpcodecs
This commit is contained in:
26
pkg/rtpcodecs/rtpsimpleaudio/decoder.go
Normal file
26
pkg/rtpcodecs/rtpsimpleaudio/decoder.go
Normal 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
|
||||
}
|
Reference in New Issue
Block a user