@@ -406,7 +406,7 @@ func (m *MediaEngine) collectStats(collector *statsReportCollector) {
406
406
}
407
407
408
408
// Look up a codec and enable if it exists
409
- func (m * MediaEngine ) matchRemoteCodec (remoteCodec RTPCodecParameters , typ RTPCodecType , exactMatches , partialMatches []RTPCodecParameters ) (codecMatchType , error ) {
409
+ func (m * MediaEngine ) matchRemoteCodec (remoteCodec RTPCodecParameters , typ RTPCodecType , exactMatches , partialMatches []RTPCodecParameters ) (RTPCodecParameters , codecMatchType , error ) {
410
410
codecs := m .videoCodecs
411
411
if typ == RTPCodecTypeAudio {
412
412
codecs = m .audioCodecs
@@ -416,7 +416,7 @@ func (m *MediaEngine) matchRemoteCodec(remoteCodec RTPCodecParameters, typ RTPCo
416
416
if apt , hasApt := remoteFmtp .Parameter ("apt" ); hasApt {
417
417
payloadType , err := strconv .ParseUint (apt , 10 , 8 )
418
418
if err != nil {
419
- return codecMatchNone , err
419
+ return RTPCodecParameters {}, codecMatchNone , err
420
420
}
421
421
422
422
aptMatch := codecMatchNone
@@ -440,7 +440,7 @@ func (m *MediaEngine) matchRemoteCodec(remoteCodec RTPCodecParameters, typ RTPCo
440
440
}
441
441
442
442
if aptMatch == codecMatchNone {
443
- return codecMatchNone , nil // not an error, we just ignore this codec we don't support
443
+ return RTPCodecParameters {}, codecMatchNone , nil // not an error, we just ignore this codec we don't support
444
444
}
445
445
446
446
// replace the apt value with the original codec's payload type
@@ -450,15 +450,15 @@ func (m *MediaEngine) matchRemoteCodec(remoteCodec RTPCodecParameters, typ RTPCo
450
450
}
451
451
452
452
// if apt's media codec is partial match, then apt codec must be partial match too
453
- _ , matchType := codecParametersFuzzySearch (toMatchCodec , codecs )
453
+ localCodec , matchType := codecParametersFuzzySearch (toMatchCodec , codecs )
454
454
if matchType == codecMatchExact && aptMatch == codecMatchPartial {
455
455
matchType = codecMatchPartial
456
456
}
457
- return matchType , nil
457
+ return localCodec , matchType , nil
458
458
}
459
459
460
- _ , matchType := codecParametersFuzzySearch (remoteCodec , codecs )
461
- return matchType , nil
460
+ localCodec , matchType := codecParametersFuzzySearch (remoteCodec , codecs )
461
+ return localCodec , matchType , nil
462
462
}
463
463
464
464
// Update header extensions from a remote media section
@@ -560,16 +560,18 @@ func (m *MediaEngine) updateFromRemoteDescription(desc sdp.SessionDescription) e
560
560
exactMatches := make ([]RTPCodecParameters , 0 , len (codecs ))
561
561
partialMatches := make ([]RTPCodecParameters , 0 , len (codecs ))
562
562
563
- for _ , codec := range codecs {
564
- matchType , mErr := m .matchRemoteCodec (codec , typ , exactMatches , partialMatches )
563
+ for _ , remoteCodec := range codecs {
564
+ localCodec , matchType , mErr := m .matchRemoteCodec (remoteCodec , typ , exactMatches , partialMatches )
565
565
if mErr != nil {
566
566
return mErr
567
567
}
568
568
569
+ remoteCodec .RTCPFeedback = rtcpFeedbackIntersection (localCodec .RTCPFeedback , remoteCodec .RTCPFeedback )
570
+
569
571
if matchType == codecMatchExact {
570
- exactMatches = append (exactMatches , codec )
572
+ exactMatches = append (exactMatches , remoteCodec )
571
573
} else if matchType == codecMatchPartial {
572
- partialMatches = append (partialMatches , codec )
574
+ partialMatches = append (partialMatches , remoteCodec )
573
575
}
574
576
}
575
577
0 commit comments