Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using SetCodecPrefences to constrain the track type disables negotiation of RTX #2996

Open
jech opened this issue Jan 8, 2025 · 1 comment · May be fixed by #3051
Open

Using SetCodecPrefences to constrain the track type disables negotiation of RTX #2996

jech opened this issue Jan 8, 2025 · 1 comment · May be fixed by #3051
Assignees
Labels
bug Something isn't working difficulty:moderate
Milestone

Comments

@jech
Copy link
Member

jech commented Jan 8, 2025

In Galene, I'm using SetCodecPreferences to ensure that we negotiate the right codec for a track forwarded to a client. Unfortunately, this has the side effect of disabling RTX.

Here's a full test:

package rtxtest

import (
	"strings"
	"testing"

	"github.com/pion/webrtc/v4"
)

func TestRTX(t *testing.T) {
	t.Run("NoSetCodecPreferences", func(t *testing.T) { testRTX(t, false) })
	t.Run("SetCodecPreferences", func(t *testing.T) { testRTX(t, true) })
}

func testRTX(t *testing.T, setPreferences bool) {
	pc, err := webrtc.NewPeerConnection(webrtc.Configuration{})
	if err != nil {
		t.Fatalf("NewPeerConnection: %v", err)
	}
	transceiver, err := pc.AddTransceiverFromKind(
		webrtc.RTPCodecTypeVideo,
		webrtc.RTPTransceiverInit{
			Direction: webrtc.RTPTransceiverDirectionRecvonly,
		},
	)

	if setPreferences {
		codec := webrtc.RTPCodecCapability{
			"video/vp8", 90000, 0, "", nil,
		}
		err := transceiver.SetCodecPreferences(
			[]webrtc.RTPCodecParameters{
				{
					RTPCodecCapability: codec,
				},
			},
		)
		if err != nil {
			t.Errorf("SetCodecPreferences: %v", err)
		}
	}

	if err != nil {
		t.Fatalf("AddTransceiverFromKind: %v", err)
	}

	offer, err := pc.CreateOffer(nil)
	if err != nil {
		t.Fatalf("CreateOffer: %v", err)
	}

	if !strings.Contains(offer.SDP, "apt=96") {
		t.Errorf("Didn't try to negotiate RTX")
	}
}
@JoeTurki JoeTurki added bug Something isn't working difficulty:moderate labels Jan 8, 2025
@Sean-Der Sean-Der added this to the V4.1.0 milestone Feb 13, 2025
@stephanrotolante
Copy link
Contributor

I opened up a PR for this issue

@stephanrotolante stephanrotolante self-assigned this Mar 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working difficulty:moderate
Development

Successfully merging a pull request may close this issue.

4 participants