-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
44537e2
commit ff67f0f
Showing
10 changed files
with
156 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { OutboundTrackMonitor } from "../monitors/OutboundTrackMonitor"; | ||
import { Detector } from "./Detector"; | ||
|
||
|
||
export class DryOutboundTrackDetector implements Detector { | ||
public readonly name = 'dry-outbound-track-detector'; | ||
|
||
public constructor( | ||
public readonly trackMonitor: OutboundTrackMonitor, | ||
) { | ||
} | ||
|
||
private _evented = false; | ||
|
||
private get peerConnection() { | ||
return this.trackMonitor.getPeerConnection(); | ||
} | ||
|
||
private get config() { | ||
return this.peerConnection.parent.config.dryOutboundTrackDetector; | ||
} | ||
|
||
private _activatedAt?: number; | ||
|
||
public update() { | ||
if (this._evented || this.config.disabled) return; | ||
if (this.trackMonitor.getOutboundRtps()?.[0].bytesSent !== 0) return; | ||
if (this.trackMonitor.track.muted || this.trackMonitor.track.readyState !== 'live') { | ||
this._activatedAt = undefined; | ||
return; | ||
} | ||
|
||
if (!this._activatedAt) { | ||
this._activatedAt = Date.now(); | ||
} | ||
|
||
const duration = Date.now() - this._activatedAt; | ||
|
||
if (duration < this.config.thresholdInMs) return; | ||
|
||
this._evented = true; | ||
|
||
const clientMonitor = this.peerConnection.parent; | ||
|
||
clientMonitor.emit('dry-outbound-track', { | ||
trackMonitor: this.trackMonitor, | ||
clientMonitor: clientMonitor, | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { PeerConnectionMonitor } from "../monitors/PeerConnectionMonitor"; | ||
import { Detector } from "./Detector"; | ||
|
||
export class IceTupleChangeDetector implements Detector { | ||
public readonly name = 'ice-tuple-change-detector'; | ||
|
||
public constructor( | ||
public readonly pcMonitor: PeerConnectionMonitor, | ||
) { | ||
} | ||
|
||
public readonly tuples = new Set<string>(); | ||
|
||
public update() { | ||
if (this.pcMonitor.closed) return; | ||
|
||
const selectedIceCandidatePairs = this.pcMonitor.selectedIceCandidatePairs; | ||
const wasEmpty = this.tuples.size === 0; | ||
let changed = false; | ||
const curentTuples = new Set<string>(); | ||
|
||
for (const pair of selectedIceCandidatePairs) { | ||
const local = pair.getLocalCandidate(); | ||
const remote = pair.getRemoteCandidate(); | ||
const tuple = `${local?.address}:${local?.port}:${remote?.address}:${remote?.port}:${local?.protocol}`; | ||
|
||
curentTuples.add(tuple); | ||
if (!this.tuples.has(tuple)) { | ||
changed = true; | ||
this.tuples.add(tuple); | ||
} | ||
} | ||
for (const tuple of this.tuples) { | ||
if (!curentTuples.has(tuple)) { | ||
changed = true; | ||
this.tuples.delete(tuple); | ||
} | ||
} | ||
|
||
if (wasEmpty || !changed) return; | ||
|
||
this.pcMonitor.parent.emit('ice-tuple-changed', { | ||
clientMonitor: this.pcMonitor.parent, | ||
peerConnectionMonitor: this.pcMonitor, | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters