package webrtc import ( "github.com/pion/rtp" "github.com/pion/webrtc/v4" ) // forwardRTP reads packets from sub and writes them to the correct track // based on payload type (H.264 → video, Opus → audio). Payload-type // inspection is the simplest M1 approach; M2 will switch to per-track // source channels once the process resolver manages separate video/audio // UDP ports. func forwardRTP(done <-chan struct{}, sub <-chan *rtp.Packet, video, audio *webrtc.TrackLocalStaticRTP) { for { select { case <-done: return case pkt, ok := <-sub: if !ok { return } // Pion default H.264 PT = 102, Opus PT = 111. If the publisher // uses different PTs we'll revisit in M2 — for M1 PoC we // configure FFmpeg to these values explicitly in the publisher // script. switch pkt.PayloadType { case 102: _ = video.WriteRTP(pkt) case 111: _ = audio.WriteRTP(pkt) default: // Unknown PT — drop. Log in M3. } } } }