@livedigital/client 2.22.1 → 2.22.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -7,8 +7,14 @@ import {
|
|
|
7
7
|
} from '../types';
|
|
8
8
|
|
|
9
9
|
class VideoCodecMismatchDetector implements IssueDetector {
|
|
10
|
+
readonly UNKNOWN_DECODER = 'unknown';
|
|
11
|
+
|
|
10
12
|
#lastProcessedStats: { [connectionId: string]: WebRTCStatsEventData | undefined } = {};
|
|
11
13
|
|
|
14
|
+
#lastDecoderWithIssue: {
|
|
15
|
+
[connectionId: string]: { [ssrc: string]: string | undefined } | undefined;
|
|
16
|
+
} = {};
|
|
17
|
+
|
|
12
18
|
detect(data: WebRTCStatsEventData): IssueDetectorResult {
|
|
13
19
|
const issues = this.processData(data);
|
|
14
20
|
this.#lastProcessedStats[data.connection.id] = data;
|
|
@@ -17,31 +23,56 @@ class VideoCodecMismatchDetector implements IssueDetector {
|
|
|
17
23
|
|
|
18
24
|
private processData(data: WebRTCStatsEventData): IssueDetectorResult {
|
|
19
25
|
const issues: IssueDetectorResult = [];
|
|
20
|
-
const
|
|
26
|
+
const { id: connectionId } = data.connection;
|
|
27
|
+
const previousInboundRTPVideoStreamsStats = this.#lastProcessedStats[connectionId]?.video.inbound;
|
|
21
28
|
|
|
22
29
|
data.video.inbound.forEach((streamStats) => {
|
|
23
30
|
const { decoderImplementation: currentDecoder, ssrc } = streamStats;
|
|
24
31
|
const prevStats = previousInboundRTPVideoStreamsStats?.find((item) => item.ssrc === ssrc);
|
|
25
32
|
|
|
33
|
+
// skipping the first iteration on purpose
|
|
26
34
|
if (!prevStats) {
|
|
27
35
|
return;
|
|
28
36
|
}
|
|
29
37
|
|
|
30
|
-
|
|
38
|
+
if (currentDecoder !== this.UNKNOWN_DECODER) {
|
|
39
|
+
this.setLastDecoderWithIssue(connectionId, ssrc, undefined);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (!this.hadLastDecoderWithIssue(connectionId, ssrc)) {
|
|
44
|
+
this.setLastDecoderWithIssue(connectionId, ssrc, this.UNKNOWN_DECODER);
|
|
31
45
|
|
|
32
|
-
if (currentDecoder === 'unknown' && prevDecoder !== 'unknown') {
|
|
33
46
|
issues.push({
|
|
47
|
+
ssrc,
|
|
34
48
|
type: IssueType.Stream,
|
|
35
49
|
reason: IssueReason.VideoCodecMismatchIssue,
|
|
36
|
-
ssrc: streamStats.ssrc,
|
|
37
50
|
trackIdentifier: streamStats.track.trackIdentifier,
|
|
38
|
-
debug: `mimeType: ${streamStats.mimeType}, decoderImplementation: ${
|
|
51
|
+
debug: `mimeType: ${streamStats.mimeType}, decoderImplementation: ${currentDecoder}`,
|
|
39
52
|
});
|
|
40
53
|
}
|
|
41
54
|
});
|
|
42
55
|
|
|
43
56
|
return issues;
|
|
44
57
|
}
|
|
58
|
+
|
|
59
|
+
private setLastDecoderWithIssue(connectionId: string, ssrc: number, decoder: string | undefined): void {
|
|
60
|
+
const issues = this.#lastDecoderWithIssue[connectionId] ?? {};
|
|
61
|
+
|
|
62
|
+
if (decoder === undefined) {
|
|
63
|
+
delete issues[ssrc];
|
|
64
|
+
} else {
|
|
65
|
+
issues[ssrc] = decoder;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
this.#lastDecoderWithIssue[connectionId] = issues;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
private hadLastDecoderWithIssue(connectionId: string, ssrc: number): boolean {
|
|
72
|
+
const issues = this.#lastDecoderWithIssue[connectionId];
|
|
73
|
+
const decoder = issues && issues[ssrc];
|
|
74
|
+
return decoder === this.UNKNOWN_DECODER;
|
|
75
|
+
}
|
|
45
76
|
}
|
|
46
77
|
|
|
47
78
|
export default VideoCodecMismatchDetector;
|