mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2025-06-28 12:19:54 +00:00
ui: rely on different value in stats when checking calls media (#5007)
* ui: rely on different value in stats when checking calls media * int64
This commit is contained in:
parent
b01efd9d0a
commit
fabbe0285d
3 changed files with 14 additions and 17 deletions
|
@ -306,8 +306,7 @@ final class WebRTCClient: NSObject, RTCVideoViewDelegate, RTCFrameEncryptorDeleg
|
|||
func setupMuteUnmuteListener(_ transceiver: RTCRtpTransceiver, _ track: RTCMediaStreamTrack) {
|
||||
// logger.log("Setting up mute/unmute listener in the call without encryption for mid = \(transceiver.mid)")
|
||||
Task {
|
||||
// for some reason even for disabled tracks one packet arrives (seeing this on screenVideo track)
|
||||
var lastPacketsReceived = 1
|
||||
var lastBytesReceived: Int64 = 0
|
||||
// muted initially
|
||||
var mutedSeconds = 4
|
||||
while let call = self.activeCall, transceiver.receiver.track?.readyState == .live {
|
||||
|
@ -315,8 +314,8 @@ final class WebRTCClient: NSObject, RTCVideoViewDelegate, RTCFrameEncryptorDeleg
|
|||
let stat = stats.statistics.values.first(where: { stat in stat.type == "inbound-rtp"})
|
||||
if let stat {
|
||||
//logger.debug("Stat \(stat.debugDescription)")
|
||||
let packets = stat.values["packetsReceived"] as! Int
|
||||
if packets <= lastPacketsReceived {
|
||||
let bytes = stat.values["bytesReceived"] as! Int64
|
||||
if bytes <= lastBytesReceived {
|
||||
mutedSeconds += 1
|
||||
if mutedSeconds == 3 {
|
||||
await MainActor.run {
|
||||
|
@ -329,7 +328,7 @@ final class WebRTCClient: NSObject, RTCVideoViewDelegate, RTCFrameEncryptorDeleg
|
|||
self.onMediaMuteUnmute(transceiver.mid, false)
|
||||
}
|
||||
}
|
||||
lastPacketsReceived = packets
|
||||
lastBytesReceived = bytes
|
||||
mutedSeconds = 0
|
||||
}
|
||||
}
|
||||
|
|
|
@ -955,8 +955,7 @@ const processCommand = (function () {
|
|||
function setupMuteUnmuteListener(transceiver, track) {
|
||||
// console.log("Setting up mute/unmute listener in the call without encryption for mid = ", transceiver.mid)
|
||||
let inboundStatsId = "";
|
||||
// for some reason even for disabled tracks one packet arrives (seeing this on screenVideo track)
|
||||
let lastPacketsReceived = 1;
|
||||
let lastBytesReceived = 0;
|
||||
// muted initially
|
||||
let mutedSeconds = 4;
|
||||
let statsInterval = setInterval(async () => {
|
||||
|
@ -970,9 +969,9 @@ const processCommand = (function () {
|
|||
});
|
||||
}
|
||||
if (inboundStatsId) {
|
||||
// even though MSDN site says `packetsReceived` is available in WebView 80+, in reality it's available even in 69
|
||||
const packets = (_a = stats.get(inboundStatsId)) === null || _a === void 0 ? void 0 : _a.packetsReceived;
|
||||
if (packets <= lastPacketsReceived) {
|
||||
// even though MSDN site says `bytesReceived` is available in WebView 80+, in reality it's available even in 69
|
||||
const bytes = (_a = stats.get(inboundStatsId)) === null || _a === void 0 ? void 0 : _a.bytesReceived;
|
||||
if (bytes <= lastBytesReceived) {
|
||||
mutedSeconds++;
|
||||
if (mutedSeconds == 3) {
|
||||
onMediaMuteUnmute(transceiver.mid, true);
|
||||
|
@ -982,7 +981,7 @@ const processCommand = (function () {
|
|||
if (mutedSeconds >= 3) {
|
||||
onMediaMuteUnmute(transceiver.mid, false);
|
||||
}
|
||||
lastPacketsReceived = packets;
|
||||
lastBytesReceived = bytes;
|
||||
mutedSeconds = 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1272,8 +1272,7 @@ const processCommand = (function () {
|
|||
function setupMuteUnmuteListener(transceiver: RTCRtpTransceiver, track: MediaStreamTrack) {
|
||||
// console.log("Setting up mute/unmute listener in the call without encryption for mid = ", transceiver.mid)
|
||||
let inboundStatsId = ""
|
||||
// for some reason even for disabled tracks one packet arrives (seeing this on screenVideo track)
|
||||
let lastPacketsReceived = 1
|
||||
let lastBytesReceived = 0
|
||||
// muted initially
|
||||
let mutedSeconds = 4
|
||||
let statsInterval = setInterval(async () => {
|
||||
|
@ -1286,9 +1285,9 @@ const processCommand = (function () {
|
|||
})
|
||||
}
|
||||
if (inboundStatsId) {
|
||||
// even though MSDN site says `packetsReceived` is available in WebView 80+, in reality it's available even in 69
|
||||
const packets = (stats as any).get(inboundStatsId)?.packetsReceived
|
||||
if (packets <= lastPacketsReceived) {
|
||||
// even though MSDN site says `bytesReceived` is available in WebView 80+, in reality it's available even in 69
|
||||
const bytes = (stats as any).get(inboundStatsId)?.bytesReceived
|
||||
if (bytes <= lastBytesReceived) {
|
||||
mutedSeconds++
|
||||
if (mutedSeconds == 3) {
|
||||
onMediaMuteUnmute(transceiver.mid, true)
|
||||
|
@ -1297,7 +1296,7 @@ const processCommand = (function () {
|
|||
if (mutedSeconds >= 3) {
|
||||
onMediaMuteUnmute(transceiver.mid, false)
|
||||
}
|
||||
lastPacketsReceived = packets
|
||||
lastBytesReceived = bytes
|
||||
mutedSeconds = 0
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue