Skip to content

Commit

Permalink
save
Browse files Browse the repository at this point in the history
  • Loading branch information
balazskreith committed Mar 24, 2024
1 parent 8a158e3 commit 740c694
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 15 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@observertc/observer-js",
"version": "0.40.10-beta",
"version": "0.40.11-beta",
"description": "Server Side NodeJS Library for processing ObserveRTC Samples",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down
50 changes: 40 additions & 10 deletions src/ObservedClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export type ObservedClientEvents = {
remoteCandidate: IceRemoteCandidate,
}],
usingturn: [boolean],
usermediaerror: [string],
};

export declare interface ObservedClient<AppData extends Record<string, unknown> = Record<string, unknown>> {
Expand Down Expand Up @@ -252,7 +253,11 @@ export class ObservedClient<AppData extends Record<string, unknown> = Record<str
{
type: CallMetaType.OPERATION_SYSTEM,
payload: sample.os,
}, this.userId);
},
this.userId,
undefined,
sample.timestamp
);

this.reports.addCallMetaReport(callMetaReport);
}
Expand All @@ -272,7 +277,11 @@ export class ObservedClient<AppData extends Record<string, unknown> = Record<str
{
type: CallMetaType.ENGINE,
payload: sample.engine,
}, this.userId);
},
this.userId,
undefined,
sample.timestamp
);

this.reports.addCallMetaReport(callMetaReport);
}
Expand All @@ -293,7 +302,11 @@ export class ObservedClient<AppData extends Record<string, unknown> = Record<str
{
type: CallMetaType.PLATFORM,
payload: sample.platform,
}, this.userId);
},
this.userId,
undefined,
sample.timestamp
);

this.reports.addCallMetaReport(callMetaReport);
}
Expand All @@ -313,7 +326,11 @@ export class ObservedClient<AppData extends Record<string, unknown> = Record<str
{
type: CallMetaType.BROWSER,
payload: sample.browser,
}, this.userId);
},
this.userId,
undefined,
sample.timestamp
);

this.reports.addCallMetaReport(callMetaReport);
}
Expand All @@ -328,7 +345,11 @@ export class ObservedClient<AppData extends Record<string, unknown> = Record<str
{
type: CallMetaType.MEDIA_CONSTRAINT,
payload: mediaConstraint,
}, this.userId);
},
this.userId,
undefined,
sample.timestamp
);

this.reports.addCallMetaReport(callMetaReport);
}
Expand All @@ -343,7 +364,11 @@ export class ObservedClient<AppData extends Record<string, unknown> = Record<str
{
type: CallMetaType.LOCAL_SDP,
payload: localSDP,
}, this.userId);
},
this.userId,
undefined,
sample.timestamp
);

this.reports.addCallMetaReport(callMetaReport);
}
Expand Down Expand Up @@ -390,10 +415,13 @@ export class ObservedClient<AppData extends Record<string, unknown> = Record<str
this.clientId, {
type: CallMetaType.USER_MEDIA_ERROR,
payload: userMediaError,
}, this.userId);
},
this.userId,
);

this.reports.addCallMetaReport(callMetaReport);
this.userMediaErrors.push(userMediaError);
this.emit('usermediaerror', userMediaError);
}

for (const certificate of sample.certificates ?? []) {
Expand All @@ -405,7 +433,9 @@ export class ObservedClient<AppData extends Record<string, unknown> = Record<str
this.clientId, {
type: CallMetaType.CERTIFICATE,
payload: certificate,
}, this.userId);
},
this.userId
);

this.reports.addCallMetaReport(callMetaReport);
}
Expand Down Expand Up @@ -606,7 +636,7 @@ export class ObservedClient<AppData extends Record<string, unknown> = Record<str
continue;
}

peerConnection.ICE.addLocalCandidate(iceLocalCandidate);
peerConnection.ICE.addLocalCandidate(iceLocalCandidate, sample.timestamp);
}

for (const iceRemoteCandidate of sample.iceRemoteCandidates ?? []) {
Expand All @@ -621,7 +651,7 @@ export class ObservedClient<AppData extends Record<string, unknown> = Record<str
continue;
}

peerConnection.ICE.addRemoteCandidate(iceRemoteCandidate);
peerConnection.ICE.addRemoteCandidate(iceRemoteCandidate, sample.timestamp);
}

for (const candidatePair of sample.iceCandidatePairs ?? []) {
Expand Down
16 changes: 12 additions & 4 deletions src/ObservedICE.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export class ObservedICE extends EventEmitter {
this.emit('close');
}

public addLocalCandidate(candidate: IceLocalCandidate) {
public addLocalCandidate(candidate: IceLocalCandidate, sampleTimestamp?: number) {
if (!candidate.id) return;

const newCandidate = !this._localCandidates.has(candidate.id);
Expand All @@ -116,15 +116,19 @@ export class ObservedICE extends EventEmitter {
this.peerConnection.client.clientId, {
type: CallMetaType.ICE_LOCAL_CANDIDATE,
payload: candidate,
}, this.peerConnection.client.userId);
},
this.peerConnection.client.userId,
this.peerConnection.peerConnectionId,
sampleTimestamp,
);

this.reports.addCallMetaReport(callMetaReport);

this.emit('new-local-candidate', candidate);
}
}

public addRemoteCandidate(candidate: IceRemoteCandidate) {
public addRemoteCandidate(candidate: IceRemoteCandidate, sampleTimestamp?: number) {
if (!candidate.id) return;

const newCandidate = !this._remoteCandidates.has(candidate.id);
Expand All @@ -140,7 +144,11 @@ export class ObservedICE extends EventEmitter {
this.peerConnection.client.clientId, {
type: CallMetaType.ICE_REMOTE_CANDIDATE,
payload: candidate,
}, this.peerConnection.client.userId);
},
this.peerConnection.client.userId,
this.peerConnection.peerConnectionId,
sampleTimestamp
);

this.reports.addCallMetaReport(callMetaReport);

Expand Down
2 changes: 2 additions & 0 deletions src/ObservedSfu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ export class ObservedSfu<AppData extends Record<string, unknown> = Record<string
this._timeZoneOffsetInHours = sample.timeZoneOffsetInHours;
}

this._marker = sample.marker;

const now = Date.now();
const elapsedTimeInMs = now - this._updated;

Expand Down
1 change: 1 addition & 0 deletions src/common/callMetaReports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export function createCallMetaReport(
clientId: string,
reportType: CallMetaReportType,
userId?: string,
peerConnectionId?: string,
timestamp?: number
) {
const report: CallMetaReport = {
Expand Down

0 comments on commit 740c694

Please sign in to comment.