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 · 0 comments
Labels
bug Something isn't working difficulty:moderate

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")
	}
}
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

No branches or pull requests

2 participants