@@ -9,6 +9,7 @@ package webrtc
9
9
//
10
10
import (
11
11
"context"
12
+ "fmt"
12
13
"io"
13
14
"sync/atomic"
14
15
"testing"
@@ -237,6 +238,68 @@ func Test_InterceptorRegistry_Build(t *testing.T) {
237
238
closePairNow (t , peerConnectionA , peerConnectionB )
238
239
}
239
240
241
+ // TestConfigureFlexFEC03_FECParameters tests only that FEC parameters are correctly set and that SDP contains FEC info.
242
+ // FEC between 2 Pion clients is not currently supported and cannot be negotiated due to the blocking issue:
243
+ // https://github.com/pion/webrtc/issues/3109
244
+ func TestConfigureFlexFEC03_FECParameters (t * testing.T ) {
245
+ to := test .TimeOut (time .Second * 20 )
246
+ defer to .Stop ()
247
+
248
+ report := test .CheckRoutines (t )
249
+ defer report ()
250
+
251
+ mediaEngine := & MediaEngine {}
252
+
253
+ assert .NoError (t , mediaEngine .RegisterCodec (RTPCodecParameters {
254
+ RTPCodecCapability : RTPCodecCapability {MimeType : MimeTypeVP8 , ClockRate : 90000 },
255
+ PayloadType : 96 ,
256
+ }, RTPCodecTypeVideo ))
257
+
258
+ interceptorRegistry := & interceptor.Registry {}
259
+
260
+ fecPayloadType := PayloadType (120 )
261
+ assert .NoError (t , ConfigureFlexFEC03 (fecPayloadType , mediaEngine , interceptorRegistry ))
262
+
263
+ assert .NoError (t , RegisterDefaultInterceptors (mediaEngine , interceptorRegistry ))
264
+
265
+ api := NewAPI (WithMediaEngine (mediaEngine ), WithInterceptorRegistry (interceptorRegistry ))
266
+
267
+ pc , err := api .NewPeerConnection (Configuration {})
268
+ assert .NoError (t , err )
269
+ defer func () { assert .NoError (t , pc .Close ()) }()
270
+
271
+ track , err := NewTrackLocalStaticSample (RTPCodecCapability {MimeType : MimeTypeVP8 }, "video" , "pion" )
272
+ assert .NoError (t , err )
273
+
274
+ sender , err := pc .AddTrack (track )
275
+ assert .NoError (t , err )
276
+
277
+ offer , err := pc .CreateOffer (nil )
278
+ assert .NoError (t , err )
279
+
280
+ assert .Contains (t , offer .SDP , "a=rtpmap:120 flexfec-03/90000" )
281
+
282
+ assert .NoError (t , pc .SetLocalDescription (offer ))
283
+
284
+ params := sender .GetParameters ()
285
+ assert .NotZero (t , params .Encodings [0 ].FEC .SSRC , "FEC SSRC should be non-zero" )
286
+
287
+ expectedFECGroup := fmt .Sprintf ("FEC-FR %d %d" , params .Encodings [0 ].SSRC , params .Encodings [0 ].FEC .SSRC )
288
+ assert .Contains (t , offer .SDP , expectedFECGroup , "SDP should contain FEC-FR ssrc-group" )
289
+
290
+ var fecCodecFound bool
291
+ for _ , codec := range params .Codecs {
292
+ if codec .MimeType == MimeTypeFlexFEC03 && codec .PayloadType == fecPayloadType {
293
+ fecCodecFound = true
294
+ assert .Equal (t , uint32 (90000 ), codec .ClockRate )
295
+ assert .Equal (t , "repair-window=10000000" , codec .SDPFmtpLine )
296
+
297
+ break
298
+ }
299
+ }
300
+ assert .True (t , fecCodecFound , "FlexFEC-03 codec should be registered" )
301
+ }
302
+
240
303
func Test_Interceptor_ZeroSSRC (t * testing.T ) {
241
304
to := test .TimeOut (time .Second * 20 )
242
305
defer to .Stop ()
0 commit comments