Skip to content

Commit

Permalink
lint: code fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
eugeny-dementev committed Dec 25, 2024
1 parent b7db99f commit 1a39ff9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/WebRTCIssueDetector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
} from './detectors';
import { CompositeRTCStatsParser, RTCStatsParser } from './parser';
import createLogger from './utils/logger';
import { MissingStreamDataDetector } from './detectors/MissingStreamDataDetector';
import MissingStreamDataDetector from './detectors/MissingStreamDataDetector';

class WebRTCIssueDetector {
readonly eventEmitter: WebRTCIssueEmitter;
Expand Down
16 changes: 10 additions & 6 deletions src/detectors/MissingStreamDataDetector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@ import {
IssuePayload,
IssueReason,
IssueType,
WebRTCStatsParsed
WebRTCStatsParsed,
} from '../types';
import BaseIssueDetector from './BaseIssueDetector';

interface MissingStreamDetectorParams {
timeoutMs?: number;
}

export class MissingStreamDataDetector extends BaseIssueDetector {
export default class MissingStreamDataDetector extends BaseIssueDetector {
readonly #lastMarkedAt = new Map<string, number>();

readonly #timeoutMs: number;

constructor(params: MissingStreamDetectorParams = {}) {
Expand Down Expand Up @@ -57,11 +58,15 @@ export class MissingStreamDataDetector extends BaseIssueDetector {
return issues;
}

private detectMissingData(commonStreamStats: CommonParsedInboundStreamStats[], type: IssueType, reason: IssueReason): IssueDetectorResult {
private detectMissingData(
commonStreamStats: CommonParsedInboundStreamStats[],
type: IssueType,
reason: IssueReason,
): IssueDetectorResult {
const issues: IssuePayload[] = [];

commonStreamStats.forEach((inboundItem) => {
const trackId = inboundItem.track.trackIdentifier
const trackId = inboundItem.track.trackIdentifier;

if (inboundItem.bytesReceived === 0 && !inboundItem.track.detached && !inboundItem.track.ended) {
const hasIssue = this.markIssue(trackId);
Expand All @@ -87,7 +92,7 @@ export class MissingStreamDataDetector extends BaseIssueDetector {
}
});

return issues
return issues;
}

private markIssue(trackId: string): boolean {
Expand All @@ -106,4 +111,3 @@ export class MissingStreamDataDetector extends BaseIssueDetector {
this.#lastMarkedAt.delete(trackId);
}
}

3 changes: 1 addition & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -446,5 +446,4 @@ type CommonFields<T, U> = {
: T[K];
};


export type CommonParsedInboundStreamStats = CommonFields<ParsedInboundVideoStreamStats, ParsedInboundAudioStreamStats>
export type CommonParsedInboundStreamStats = CommonFields<ParsedInboundVideoStreamStats, ParsedInboundAudioStreamStats>;

0 comments on commit 1a39ff9

Please sign in to comment.