add RTP/VP9 encoder and decoder (#152)

This commit is contained in:
Alessandro Ros
2022-11-14 18:46:26 +01:00
committed by GitHub
parent 34545becc3
commit e264304710
13 changed files with 537 additions and 27 deletions

View File

@@ -36,15 +36,15 @@ func main() {
}
// find the VP8 track
vp8Track, vp8TrackID := func() (*gortsplib.TrackVP8, int) {
for i, track := range tracks {
track := func() *gortsplib.TrackVP8 {
for _, track := range tracks {
if tt, ok := track.(*gortsplib.TrackVP8); ok {
return tt, i
return tt
}
}
return nil, -1
return nil
}()
if vp8Track == nil {
if track == nil {
panic("VP8 track not found")
}
@@ -54,10 +54,6 @@ func main() {
// called when a RTP packet arrives
c.OnPacketRTP = func(ctx *gortsplib.ClientOnPacketRTPCtx) {
if ctx.TrackID != vp8TrackID {
return
}
// decode a VP8 frame from the RTP packet
vf, _, err := dec.Decode(ctx.Packet)
if err != nil {
@@ -67,8 +63,8 @@ func main() {
log.Printf("received frame of size %d\n", len(vf))
}
// setup and read all tracks
err = c.SetupAndPlay(tracks, baseURL)
// setup and read the VP8 track only
err = c.SetupAndPlay(gortsplib.Tracks{track}, baseURL)
if err != nil {
panic(err)
}