Skip to content

Commit 5e75f3a

Browse files
PerondasPerondas
andauthored
Fixed bugs in message.dart & rtc_session.dart (#332)
* Fixed error in message.dart * Fixed regression from code cleanup Could no longer mute/unmute Co-authored-by: Perondas <Pperondas@gmail.com>
1 parent d22ca84 commit 5e75f3a

File tree

2 files changed

+19
-20
lines changed

2 files changed

+19
-20
lines changed

lib/src/message.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,10 @@ class Message extends EventManager with Applicant {
146146
if (_closed) {
147147
return;
148148
}
149-
if (RegExp(r'^1[0-9]{2}$').hasMatch(response!.status_code)) {
149+
if (RegExp(r'^1[0-9]{2}$').hasMatch(response!.status_code.toString())) {
150150
// Ignore provisional responses.
151-
} else if (RegExp(r'^2[0-9]{2}$').hasMatch(response.status_code)) {
151+
} else if (RegExp(r'^2[0-9]{2}$')
152+
.hasMatch(response.status_code.toString())) {
152153
_succeeded('remote', response);
153154
} else {
154155
String cause = Utils.sipErrorCause(response.status_code);

lib/src/rtc_session.dart

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,10 @@ class RTCSession extends EventManager implements Owner {
129129
String? _tones;
130130

131131
// Mute/Hold state.
132-
bool? _audioMuted;
133-
bool? _videoMuted;
134-
bool? _localHold;
135-
bool? _remoteHold;
132+
bool _audioMuted = false;
133+
bool _videoMuted = false;
134+
bool _localHold = false;
135+
bool _remoteHold = false;
136136

137137
late RFC4028Timers _sessionTimers;
138138

@@ -955,23 +955,22 @@ class RTCSession extends EventManager implements Owner {
955955
*/
956956
void mute([bool audio = true, bool video = true]) {
957957
logger.d('mute()');
958+
bool changed = false;
958959

959-
bool audioMuted = false, videoMuted = false;
960-
961-
if (_audioMuted == false && audio) {
962-
audioMuted = true;
960+
if (!_audioMuted && audio) {
963961
_audioMuted = true;
962+
changed = true;
964963
_toggleMuteAudio(true);
965964
}
966965

967-
if (_videoMuted == false && video) {
968-
videoMuted = true;
966+
if (!_videoMuted && video) {
969967
_videoMuted = true;
968+
changed = true;
970969
_toggleMuteVideo(true);
971970
}
972971

973-
if (audioMuted == true || videoMuted == true) {
974-
_onmute(audioMuted, videoMuted);
972+
if (changed) {
973+
_onmute(_audioMuted, _videoMuted);
975974
}
976975
}
977976

@@ -980,29 +979,28 @@ class RTCSession extends EventManager implements Owner {
980979
*/
981980
void unmute([bool audio = true, bool video = true]) {
982981
logger.d('unmute()');
983-
984-
bool audioUnMuted = false, videoUnMuted = false;
982+
bool changed = false;
985983

986984
if (_audioMuted == true && audio) {
987-
audioUnMuted = true;
988985
_audioMuted = false;
989986

990987
if (_localHold == false) {
988+
changed = true;
991989
_toggleMuteAudio(false);
992990
}
993991
}
994992

995993
if (_videoMuted == true && video) {
996-
videoUnMuted = true;
997994
_videoMuted = false;
998995

999996
if (_localHold == false) {
997+
changed = true;
1000998
_toggleMuteVideo(false);
1001999
}
10021000
}
10031001

1004-
if (audioUnMuted == true || videoUnMuted == true) {
1005-
_onunmute(audioUnMuted, videoUnMuted);
1002+
if (changed) {
1003+
_onunmute(!_audioMuted, !_videoMuted);
10061004
}
10071005
}
10081006

0 commit comments

Comments
 (0)