@@ -535,9 +535,11 @@ impl MediaEngine {
535
535
let payload_type = apt. parse :: < u8 > ( ) ?;
536
536
537
537
let mut apt_match = CodecMatch :: None ;
538
+ let mut apt_codec = None ;
538
539
for codec in exact_matches {
539
540
if codec. payload_type == payload_type {
540
541
apt_match = CodecMatch :: Exact ;
542
+ apt_codec = Some ( codec) ;
541
543
break ;
542
544
}
543
545
}
@@ -546,6 +548,7 @@ impl MediaEngine {
546
548
for codec in partial_matches {
547
549
if codec. payload_type == payload_type {
548
550
apt_match = CodecMatch :: Partial ;
551
+ apt_codec = Some ( codec) ;
549
552
break ;
550
553
}
551
554
}
@@ -555,8 +558,22 @@ impl MediaEngine {
555
558
return Ok ( CodecMatch :: None ) ; // not an error, we just ignore this codec we don't support
556
559
}
557
560
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
+
558
575
// 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) ;
560
577
if match_type == CodecMatch :: Exact && apt_match == CodecMatch :: Partial {
561
578
match_type = CodecMatch :: Partial ;
562
579
}
0 commit comments