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

Local rtcp-fb values are used when answering #1968

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions mediaengine.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build !js
// +build !js

package webrtc
Expand Down Expand Up @@ -534,6 +535,19 @@ func (m *MediaEngine) getCodecsByKind(typ RTPCodecType) []RTPCodecParameters {
return nil
}

func (m *MediaEngine) getLocalCodecsByKind(typ RTPCodecType) []RTPCodecParameters {
m.mu.RLock()
defer m.mu.RUnlock()

if typ == RTPCodecTypeVideo {
return m.videoCodecs
} else if typ == RTPCodecTypeAudio {
return m.audioCodecs
}

return nil
}

func (m *MediaEngine) getRTPParametersByKind(typ RTPCodecType, directions []RTPTransceiverDirection) RTPParameters {
m.mu.RLock()
defer m.mu.RUnlock()
Expand Down
9 changes: 8 additions & 1 deletion sdp.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build !js
// +build !js

package webrtc
Expand Down Expand Up @@ -326,13 +327,19 @@ func addTransceiverSDP(d *sdp.SessionDescription, isPlanB, shouldAddCandidates b
WithPropertyAttribute(sdp.AttrKeyRTCPMux).
WithPropertyAttribute(sdp.AttrKeyRTCPRsize)

localCodecs := mediaEngine.getLocalCodecsByKind(t.Kind())
codecs := t.getCodecs()
for _, codec := range codecs {
name := strings.TrimPrefix(codec.MimeType, "audio/")
name = strings.TrimPrefix(name, "video/")
media.WithCodec(uint8(codec.PayloadType), name, codec.ClockRate, codec.Channels, codec.SDPFmtpLine)

for _, feedback := range codec.RTPCodecCapability.RTCPFeedback {
rtcpFeedback := codec.RTPCodecCapability.RTCPFeedback
if c, matchType := codecParametersFuzzySearch(codec, localCodecs); matchType != codecMatchNone {
rtcpFeedback = c.RTCPFeedback
}

for _, feedback := range rtcpFeedback {
media.WithValueAttribute("rtcp-fb", fmt.Sprintf("%d %s %s", codec.PayloadType, feedback.Type, feedback.Parameter))
}
}
Expand Down