(t *testing.T)
| 419 | } |
| 420 | |
| 421 | func TestDisablePublishCodec(t *testing.T) { |
| 422 | participant := newParticipantForTestWithOpts("123", &participantOpts{ |
| 423 | publisher: true, |
| 424 | clientConf: &livekit.ClientConfiguration{ |
| 425 | DisabledCodecs: &livekit.DisabledCodecs{ |
| 426 | Publish: []*livekit.Codec{ |
| 427 | {Mime: "video/h264"}, |
| 428 | }, |
| 429 | }, |
| 430 | }, |
| 431 | }) |
| 432 | |
| 433 | for _, codec := range participant.enabledPublishCodecs { |
| 434 | require.False(t, mime.IsMimeTypeStringH264(codec.Mime)) |
| 435 | } |
| 436 | |
| 437 | sink := &routingfakes.FakeMessageSink{} |
| 438 | participant.SwapResponseSink(sink, types.SignallingCloseReasonUnknown) |
| 439 | var publishReceived atomic.Bool |
| 440 | sink.WriteMessageCalls(func(msg proto.Message) error { |
| 441 | if res, ok := msg.(*livekit.SignalResponse); ok { |
| 442 | if published := res.GetTrackPublished(); published != nil { |
| 443 | publishReceived.Store(true) |
| 444 | require.NotEmpty(t, published.Track.Codecs) |
| 445 | require.True(t, mime.IsMimeTypeStringVP8(published.Track.Codecs[0].MimeType)) |
| 446 | } |
| 447 | } |
| 448 | return nil |
| 449 | }) |
| 450 | |
| 451 | // simulcast codec response should pick an alternative |
| 452 | participant.AddTrack(&livekit.AddTrackRequest{ |
| 453 | Cid: "cid1", |
| 454 | Type: livekit.TrackType_VIDEO, |
| 455 | SimulcastCodecs: []*livekit.SimulcastCodec{{ |
| 456 | Codec: "h264", |
| 457 | Cid: "cid1", |
| 458 | }}, |
| 459 | }) |
| 460 | |
| 461 | require.Eventually(t, func() bool { return publishReceived.Load() }, 5*time.Second, 10*time.Millisecond) |
| 462 | |
| 463 | // publishing a supported codec should not change |
| 464 | publishReceived.Store(false) |
| 465 | sink.WriteMessageCalls(func(msg proto.Message) error { |
| 466 | if res, ok := msg.(*livekit.SignalResponse); ok { |
| 467 | if published := res.GetTrackPublished(); published != nil { |
| 468 | publishReceived.Store(true) |
| 469 | require.NotEmpty(t, published.Track.Codecs) |
| 470 | require.True(t, mime.IsMimeTypeStringVP8(published.Track.Codecs[0].MimeType)) |
| 471 | } |
| 472 | } |
| 473 | return nil |
| 474 | }) |
| 475 | participant.AddTrack(&livekit.AddTrackRequest{ |
| 476 | Cid: "cid2", |
| 477 | Type: livekit.TrackType_VIDEO, |
| 478 | SimulcastCodecs: []*livekit.SimulcastCodec{{ |
nothing calls this directly
no test coverage detected