mirror of
https://github.com/pion/webrtc.git
synced 2025-09-27 03:25:58 +08:00
Fixes MediaEngine: codec apt negotiation
codec has apt fmtp can't negotiation because it's apt payloadtype can't be found in negotiation codecs.
This commit is contained in:
@@ -334,7 +334,7 @@ func (m *MediaEngine) collectStats(collector *statsReportCollector) {
|
||||
}
|
||||
|
||||
// Look up a codec and enable if it exists
|
||||
func (m *MediaEngine) matchRemoteCodec(remoteCodec RTPCodecParameters, typ RTPCodecType) (codecMatchType, error) {
|
||||
func (m *MediaEngine) matchRemoteCodec(remoteCodec RTPCodecParameters, typ RTPCodecType, exactMatches, partialMatches []RTPCodecParameters) (codecMatchType, error) {
|
||||
codecs := m.videoCodecs
|
||||
if typ == RTPCodecTypeAudio {
|
||||
codecs = m.audioCodecs
|
||||
@@ -347,7 +347,24 @@ func (m *MediaEngine) matchRemoteCodec(remoteCodec RTPCodecParameters, typ RTPCo
|
||||
return codecMatchNone, err
|
||||
}
|
||||
|
||||
if _, _, err = m.getCodecByPayload(PayloadType(payloadType)); err != nil {
|
||||
var aptFound bool
|
||||
for _, codec := range exactMatches {
|
||||
if codec.PayloadType == PayloadType(payloadType) {
|
||||
aptFound = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if !aptFound {
|
||||
for _, codec := range partialMatches {
|
||||
if codec.PayloadType == PayloadType(payloadType) {
|
||||
aptFound = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if !aptFound {
|
||||
return codecMatchNone, nil // not an error, we just ignore this codec we don't support
|
||||
}
|
||||
}
|
||||
@@ -416,7 +433,7 @@ func (m *MediaEngine) updateFromRemoteDescription(desc sdp.SessionDescription) e
|
||||
partialMatches := make([]RTPCodecParameters, 0, len(codecs))
|
||||
|
||||
for _, codec := range codecs {
|
||||
matchType, mErr := m.matchRemoteCodec(codec, typ)
|
||||
matchType, mErr := m.matchRemoteCodec(codec, typ, exactMatches, partialMatches)
|
||||
if mErr != nil {
|
||||
return mErr
|
||||
}
|
||||
|
@@ -280,6 +280,33 @@ a=rtpmap:96 VP8/90000
|
||||
_, _, err := m.getCodecByPayload(96)
|
||||
assert.NoError(t, err)
|
||||
})
|
||||
|
||||
t.Run("Matches when rtx apt exists", func(t *testing.T) {
|
||||
const profileLevels = `v=0
|
||||
o=- 4596489990601351948 2 IN IP4 127.0.0.1
|
||||
s=-
|
||||
t=0 0
|
||||
m=video 60323 UDP/TLS/RTP/SAVPF 96 97
|
||||
a=rtpmap:96 VP8/90000
|
||||
a=rtpmap:97 rtx/90000
|
||||
a=fmtp:97 apt=96
|
||||
`
|
||||
m := MediaEngine{}
|
||||
assert.NoError(t, m.RegisterCodec(RTPCodecParameters{
|
||||
RTPCodecCapability: RTPCodecCapability{MimeTypeVP8, 90000, 0, "", nil},
|
||||
PayloadType: 96,
|
||||
}, RTPCodecTypeVideo))
|
||||
assert.NoError(t, m.RegisterCodec(RTPCodecParameters{
|
||||
RTPCodecCapability: RTPCodecCapability{"video/rtx", 90000, 0, "apt=96", nil},
|
||||
PayloadType: 97,
|
||||
}, RTPCodecTypeVideo))
|
||||
assert.NoError(t, m.updateFromRemoteDescription(mustParse(profileLevels)))
|
||||
|
||||
assert.True(t, m.negotiatedVideo)
|
||||
|
||||
_, _, err := m.getCodecByPayload(97)
|
||||
assert.NoError(t, err)
|
||||
})
|
||||
}
|
||||
|
||||
func TestMediaEngineHeaderExtensionDirection(t *testing.T) {
|
||||
|
Reference in New Issue
Block a user