@@ -535,9 +535,11 @@ impl MediaEngine {
535535 let payload_type = apt. parse :: < u8 > ( ) ?;
536536
537537 let mut apt_match = CodecMatch :: None ;
538+ let mut apt_codec = None ;
538539 for codec in exact_matches {
539540 if codec. payload_type == payload_type {
540541 apt_match = CodecMatch :: Exact ;
542+ apt_codec = Some ( codec) ;
541543 break ;
542544 }
543545 }
@@ -546,6 +548,7 @@ impl MediaEngine {
546548 for codec in partial_matches {
547549 if codec. payload_type == payload_type {
548550 apt_match = CodecMatch :: Partial ;
551+ apt_codec = Some ( codec) ;
549552 break ;
550553 }
551554 }
@@ -555,8 +558,22 @@ impl MediaEngine {
555558 return Ok ( CodecMatch :: None ) ; // not an error, we just ignore this codec we don't support
556559 }
557560
561+ // replace the apt value with the original codec's payload type
562+ let mut to_match_codec = remote_codec. clone ( ) ;
563+ if let Some ( apt_codec) = apt_codec {
564+ let ( apt_matched, mt) = codec_parameters_fuzzy_search ( apt_codec, codecs) ;
565+ if mt == apt_match {
566+ to_match_codec. capability . sdp_fmtp_line =
567+ to_match_codec. capability . sdp_fmtp_line . replacen (
568+ & format ! ( "apt={payload_type}" ) ,
569+ & format ! ( "apt={}" , apt_matched. payload_type) ,
570+ 1 ,
571+ ) ;
572+ }
573+ }
574+
558575 // if apt's media codec is partial match, then apt codec must be partial match too
559- let ( _, mut match_type) = codec_parameters_fuzzy_search ( remote_codec , codecs) ;
576+ let ( _, mut match_type) = codec_parameters_fuzzy_search ( & to_match_codec , codecs) ;
560577 if match_type == CodecMatch :: Exact && apt_match == CodecMatch :: Partial {
561578 match_type = CodecMatch :: Partial ;
562579 }
0 commit comments