|
4 | 4 | package webrtc |
5 | 5 |
|
6 | 6 | import ( |
| 7 | + "fmt" |
7 | 8 | "regexp" |
| 9 | + "strings" |
8 | 10 | "testing" |
9 | 11 |
|
10 | 12 | "github.com/pion/sdp/v3" |
@@ -548,3 +550,87 @@ a=rtpmap:111 opus/48000/2 |
548 | 550 | assert.NotEqual(t, 2, extensions[voIndex].ID) |
549 | 551 | assert.NotEqual(t, 5, extensions[voIndex].ID) |
550 | 552 | } |
| 553 | + |
| 554 | +func TestCaseInsensitiveMimeType(t *testing.T) { |
| 555 | + const offerSdp = ` |
| 556 | +v=0 |
| 557 | +o=- 8448668841136641781 4 IN IP4 127.0.0.1 |
| 558 | +s=- |
| 559 | +t=0 0 |
| 560 | +a=group:BUNDLE 0 1 2 |
| 561 | +a=extmap-allow-mixed |
| 562 | +a=msid-semantic: WMS 4beea6b0-cf95-449c-a1ec-78e16b247426 |
| 563 | +m=video 9 UDP/TLS/RTP/SAVPF 96 127 |
| 564 | +c=IN IP4 0.0.0.0 |
| 565 | +a=rtcp:9 IN IP4 0.0.0.0 |
| 566 | +a=ice-ufrag:1/MvHwjAyVf27aLu |
| 567 | +a=ice-pwd:3dBU7cFOBl120v33cynDvN1E |
| 568 | +a=ice-options:google-ice |
| 569 | +a=fingerprint:sha-256 75:74:5A:A6:A4:E5:52:F4:A7:67:4C:01:C7:EE:91:3F:21:3D:A2:E3:53:7B:6F:30:86:F2:30:AA:65:FB:04:24 |
| 570 | +a=setup:actpass |
| 571 | +a=mid:1 |
| 572 | +a=sendonly |
| 573 | +a=rtpmap:96 VP8/90000 |
| 574 | +a=rtcp-fb:96 goog-remb |
| 575 | +a=rtcp-fb:96 transport-cc |
| 576 | +a=rtcp-fb:96 ccm fir |
| 577 | +a=rtcp-fb:96 nack |
| 578 | +a=rtcp-fb:96 nack pli |
| 579 | +a=rtpmap:127 H264/90000 |
| 580 | +a=rtcp-fb:127 goog-remb |
| 581 | +a=rtcp-fb:127 transport-cc |
| 582 | +a=rtcp-fb:127 ccm fir |
| 583 | +a=rtcp-fb:127 nack |
| 584 | +a=rtcp-fb:127 nack pli |
| 585 | +a=fmtp:127 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42001f |
| 586 | +
|
| 587 | +` |
| 588 | + |
| 589 | + for _, mimeTypeVp8 := range []string{ |
| 590 | + "video/vp8", |
| 591 | + "video/VP8", |
| 592 | + } { |
| 593 | + t.Run(fmt.Sprintf("MimeType: %s", mimeTypeVp8), func(t *testing.T) { |
| 594 | + me := &MediaEngine{} |
| 595 | + feedback := []RTCPFeedback{ |
| 596 | + {Type: TypeRTCPFBTransportCC}, |
| 597 | + {Type: TypeRTCPFBCCM, Parameter: "fir"}, |
| 598 | + {Type: TypeRTCPFBNACK}, |
| 599 | + {Type: TypeRTCPFBNACK, Parameter: "pli"}, |
| 600 | + } |
| 601 | + |
| 602 | + for _, codec := range []RTPCodecParameters{ |
| 603 | + { |
| 604 | + RTPCodecCapability: RTPCodecCapability{MimeType: mimeTypeVp8, ClockRate: 90000, RTCPFeedback: feedback}, |
| 605 | + PayloadType: 96, |
| 606 | + }, |
| 607 | + { |
| 608 | + RTPCodecCapability: RTPCodecCapability{MimeType: "video/h264", ClockRate: 90000, SDPFmtpLine: "level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42001f", RTCPFeedback: feedback}, |
| 609 | + PayloadType: 127, |
| 610 | + }, |
| 611 | + } { |
| 612 | + assert.NoError(t, me.RegisterCodec(codec, RTPCodecTypeVideo)) |
| 613 | + } |
| 614 | + |
| 615 | + api := NewAPI(WithMediaEngine(me)) |
| 616 | + pc, err := api.NewPeerConnection(Configuration{ |
| 617 | + SDPSemantics: SDPSemanticsUnifiedPlan, |
| 618 | + }) |
| 619 | + assert.NoError(t, err) |
| 620 | + |
| 621 | + offer := SessionDescription{ |
| 622 | + Type: SDPTypeOffer, |
| 623 | + SDP: offerSdp, |
| 624 | + } |
| 625 | + |
| 626 | + assert.NoError(t, pc.SetRemoteDescription(offer)) |
| 627 | + answer, err := pc.CreateAnswer(nil) |
| 628 | + assert.NoError(t, err) |
| 629 | + assert.NotNil(t, answer) |
| 630 | + assert.NoError(t, pc.SetLocalDescription(answer)) |
| 631 | + assert.True(t, strings.Contains(answer.SDP, "VP8") || strings.Contains(answer.SDP, "vp8")) |
| 632 | + |
| 633 | + assert.NoError(t, pc.Close()) |
| 634 | + }) |
| 635 | + } |
| 636 | +} |
0 commit comments