Skip to content

Commit 679b18b

Browse files
digiboridevSERDUN
authored andcommitted
fix: skip static payloads sanitizing if no rtpmap (#968)
1 parent 08bd059 commit 679b18b

2 files changed

Lines changed: 18 additions & 10 deletions

File tree

lib/features/call/utils/sdp_mod_builder.dart

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,10 @@ class SDPModBuilder {
235235
if (media['fmtp'] is List<dynamic>) originalFmtps.addAll(media['fmtp'] as List<dynamic>);
236236
if (media['rtcpFb'] is List<dynamic>) originalRtcpFbs.addAll(media['rtcpFb'] as List<dynamic>);
237237

238-
// PCMU(0), PCMA(8), G722(9), CN(13) are static payload types that supports by our WebRTC stack.
239-
final staticPayloads = ['0', '8', '9', '13'];
238+
final staticPayloads = RTPCodecProfile.values
239+
.where((p) => p.staticPayload != null)
240+
.map((p) => p.staticPayload.toString())
241+
.toSet();
240242

241243
final modedRtpMaps = originalRtpMaps.where((r) => !staticPayloads.contains(r['payload'].toString()));
242244
final modedFmtps = originalFmtps.where((f) => !staticPayloads.contains(f['payload'].toString()));
@@ -366,13 +368,18 @@ class SDPModBuilder {
366368
/// Get the codec profile payload id.
367369
/// Return codec by specific profile using fmtp records for multiprofile codecs
368370
/// e.g. H264 with profile 42e01f, 42e034, 640c34 etc.
369-
/// Elsewhere return codec finded by rtp records.
371+
/// Elsewhere return codec finded by rtp records or by static payloads if they are defined.
370372
dynamic _getProfileId(RTPCodecProfile profile) {
371373
final media = _getMedia(profile.kind);
372374
if (media == null) return null;
373375

374-
final rtps = media['rtp'] as List<dynamic>;
375-
final fmtps = media['fmtp'] as List<dynamic>;
376+
final payloads = media['payloads'] is String ? (media['payloads'] as String).split(' ') : [];
377+
if (profile.staticPayload != null && payloads.contains(profile.staticPayload.toString())) {
378+
return profile.staticPayload;
379+
}
380+
381+
final rtps = media['rtp'] is List<dynamic> ? media['rtp'] as List<dynamic> : const [];
382+
final fmtps = media['fmtp'] is List<dynamic> ? media['fmtp'] as List<dynamic> : const [];
376383

377384
final rtp = rtps.firstWhereOrNull((r) {
378385
final sameCodec = r['codec'] == profile.codec.sdpKey;

lib/models/rtp_codec_profile.dart

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
enum RTPCodecProfile {
44
opus(RTPCodecKind.audio, RTPCodec.opus, 48000, channels: 2),
5-
g722(RTPCodecKind.audio, RTPCodec.g722, 8000),
5+
g722(RTPCodecKind.audio, RTPCodec.g722, 8000, staticPayload: 9),
66
ilbc(RTPCodecKind.audio, RTPCodec.ilbc, 8000),
7-
pcmu(RTPCodecKind.audio, RTPCodec.pcmu, 8000),
8-
pcma(RTPCodecKind.audio, RTPCodec.pcma, 8000),
7+
pcmu(RTPCodecKind.audio, RTPCodec.pcmu, 8000, staticPayload: 0),
8+
pcma(RTPCodecKind.audio, RTPCodec.pcma, 8000, staticPayload: 8),
99
comfortNoise_32k(RTPCodecKind.audio, RTPCodec.cn, 32000),
1010
comfortNoise_16k(RTPCodecKind.audio, RTPCodec.cn, 16000),
11-
comfortNoise_8k(RTPCodecKind.audio, RTPCodec.cn, 8000),
11+
comfortNoise_8k(RTPCodecKind.audio, RTPCodec.cn, 8000, staticPayload: 13),
1212
telephoneEvent_48k(RTPCodecKind.audio, RTPCodec.telephoneEvent, 48000),
1313
telephoneEvent_16k(RTPCodecKind.audio, RTPCodec.telephoneEvent, 16000),
1414
telephoneEvent_8k(RTPCodecKind.audio, RTPCodec.telephoneEvent, 8000),
@@ -23,13 +23,14 @@ enum RTPCodecProfile {
2323
av1(RTPCodecKind.video, RTPCodec.av1, 90000),
2424
redundancy_video(RTPCodecKind.video, RTPCodec.red, 90000);
2525

26-
const RTPCodecProfile(this.kind, this.codec, this.rate, {this.channels, this.levelId});
26+
const RTPCodecProfile(this.kind, this.codec, this.rate, {this.channels, this.levelId, this.staticPayload});
2727

2828
final RTPCodecKind kind;
2929
final RTPCodec codec;
3030
final int rate;
3131
final int? channels;
3232
final String? levelId;
33+
final int? staticPayload;
3334
}
3435

3536
enum RTPCodec {

0 commit comments

Comments
 (0)