Skip to content

Commit

Permalink
feat(webrtc): enable audio dtx
Browse files Browse the repository at this point in the history
  • Loading branch information
lambiengcode committed Oct 10, 2023
1 parent cb766be commit 7fc81f8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
12 changes: 12 additions & 0 deletions lib/services/webrtc/helpers/extensions/sdp_extensions.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
extension SdpX on String {
String removeRTCPMux() {
return replaceAll(RegExp(r'a=rtcp-mux.*\r\n'), '');
}

String enableAudioDTX() {
return replaceAll(
'a=fmtp:111 minptime=10;useinbandfec=1',
'a=fmtp:111 minptime=10;useinbandfec=1;usedtx=1',
);
}
}
16 changes: 1 addition & 15 deletions lib/services/webrtc/helpers/webrtc_utils.dart
Original file line number Diff line number Diff line change
@@ -1,15 +1 @@
class WebRTCUtils {
static String removeRTCPMux(String sdp) {
sdp = sdp.replaceAll(RegExp(r'a=rtcp-mux.*\r\n'), '');

return sdp;
}

static String enableAudioDTX({required String sdp}) {
sdp = sdp.replaceAll(
'a=fmtp:111 minptime=10;useinbandfec=1',
'a=fmtp:111 minptime=10;useinbandfec=1;usedtx=1',
);
return sdp;
}
}
class WebRTCUtils {}
5 changes: 3 additions & 2 deletions lib/services/webrtc/webrtc_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:waterbus/features/app/bloc/bloc.dart';
import 'package:waterbus/features/meeting/presentation/bloc/meeting/meeting_bloc.dart';
import 'package:waterbus/services/socket.dart';
import 'package:waterbus/services/webrtc/abstract/webrtc_interface.dart';
import 'package:waterbus/services/webrtc/helpers/extensions/sdp_extensions.dart';
import 'package:waterbus/services/webrtc/models/call_state.dart';

@LazySingleton(as: WaterbusWebRTCManager)
Expand Down Expand Up @@ -60,9 +61,9 @@ class WaterbusWebRTCManagerIpml extends WaterbusWebRTCManager {
_publisherPeer?.onRenegotiationNeeded = () async {
if ((await _publisherPeer?.getRemoteDescription()) != null) return;

final String sdp = await _createOffer(_publisherPeer!);
String sdp = await _createOffer(_publisherPeer!);

// sdp = WebRTCUtils.enableAudioDTX(sdp: sdp);
sdp = sdp.enableAudioDTX();

final RTCSessionDescription description = RTCSessionDescription(
sdp,
Expand Down

0 comments on commit 7fc81f8

Please sign in to comment.