mirror of
https://github.com/pion/webrtc.git
synced 2025-09-27 03:25:58 +08:00
Properly handle non-media probes
libwebrtc has started sending media probes on an unannounced SSRC(0). Currently Pion will ignore this as the SSRC hasn't been declared explicitly and no RID/MID RTP Headers. This adds a special case to accept SSRC 0 and Read the RTP packets. This allows the TWCC reports to properly be generated.
This commit is contained in:
@@ -225,12 +225,59 @@ func Test_InterceptorRegistry_Build(t *testing.T) {
|
||||
},
|
||||
})
|
||||
|
||||
peerConnectionA, err := NewAPI(WithInterceptorRegistry(ir)).NewPeerConnection(Configuration{})
|
||||
assert.NoError(t, err)
|
||||
|
||||
peerConnectionB, err := NewAPI(WithInterceptorRegistry(ir)).NewPeerConnection(Configuration{})
|
||||
peerConnectionA, peerConnectionB, err := NewAPI(WithInterceptorRegistry(ir)).newPair(Configuration{})
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.Equal(t, 2, registryBuildCount)
|
||||
closePairNow(t, peerConnectionA, peerConnectionB)
|
||||
}
|
||||
|
||||
func Test_Interceptor_ZeroSSRC(t *testing.T) {
|
||||
to := test.TimeOut(time.Second * 20)
|
||||
defer to.Stop()
|
||||
|
||||
report := test.CheckRoutines(t)
|
||||
defer report()
|
||||
|
||||
track, err := NewTrackLocalStaticRTP(RTPCodecCapability{MimeType: MimeTypeVP8}, "video", "pion")
|
||||
assert.NoError(t, err)
|
||||
|
||||
offerer, answerer, err := newPair()
|
||||
assert.NoError(t, err)
|
||||
|
||||
_, err = offerer.AddTrack(track)
|
||||
assert.NoError(t, err)
|
||||
|
||||
probeReceiverCreated := make(chan struct{})
|
||||
|
||||
go func() {
|
||||
sequenceNumber := uint16(0)
|
||||
for range time.NewTicker(time.Millisecond * 20).C {
|
||||
track.mu.Lock()
|
||||
if len(track.bindings) == 1 {
|
||||
_, err = track.bindings[0].writeStream.WriteRTP(&rtp.Header{
|
||||
Version: 2,
|
||||
SSRC: 0,
|
||||
SequenceNumber: sequenceNumber,
|
||||
}, []byte{0, 1, 2, 3, 4, 5})
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
sequenceNumber++
|
||||
track.mu.Unlock()
|
||||
|
||||
if nonMediaBandwidthProbe, ok := answerer.nonMediaBandwidthProbe.Load().(*RTPReceiver); ok {
|
||||
assert.Equal(t, len(nonMediaBandwidthProbe.Tracks()), 1)
|
||||
close(probeReceiverCreated)
|
||||
return
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
assert.NoError(t, signalPair(offerer, answerer))
|
||||
|
||||
peerConnectionConnected := untilConnectionState(PeerConnectionStateConnected, offerer, answerer)
|
||||
peerConnectionConnected.Wait()
|
||||
|
||||
<-probeReceiverCreated
|
||||
closePairNow(t, offerer, answerer)
|
||||
}
|
||||
|
Reference in New Issue
Block a user