mirror of
https://github.com/aler9/gortsplib
synced 2025-10-16 04:00:46 +08:00
add RTP/VP9 encoder and decoder (#152)
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user