merge format and formatdecenc into formats (#222)

This commit is contained in:
Alessandro Ros
2023-04-01 13:23:16 +02:00
committed by GitHub
parent 03b96abf84
commit af3ed2bd83
161 changed files with 217 additions and 219 deletions

View File

@@ -0,0 +1,26 @@
package rtpsimpleaudio
import (
"time"
"github.com/pion/rtp"
"github.com/bluenviron/gortsplib/v3/pkg/rtptime"
)
// Decoder is a RTP/simple audio decoder.
type Decoder struct {
SampleRate int
timeDecoder *rtptime.Decoder
}
// Init initializes the decoder.
func (d *Decoder) Init() {
d.timeDecoder = rtptime.NewDecoder(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
}