Skip to content
This repository has been archived by the owner on Mar 16, 2022. It is now read-only.

Commit

Permalink
fix bug : apt is ignored in first negotiation
Browse files Browse the repository at this point in the history
  • Loading branch information
cnderrauber committed Apr 20, 2021
1 parent 093840a commit be9490b
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions mediaengine.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -347,7 +347,23 @@ 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
}
}
Expand Down Expand Up @@ -416,7 +432,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
}
Expand Down

0 comments on commit be9490b

Please sign in to comment.