mirror of https://github.com/OpenVidu/openvidu.git
openvidu-testapp: RTCIceCandidate stats for publisher and subscriber peer connections
parent
91aa127dad
commit
d44e24592d
|
@ -1205,17 +1205,23 @@ export class OpenviduInstanceComponent {
|
||||||
const sub: PCTransport = this.getSubscriberPC()!;
|
const sub: PCTransport = this.getSubscriberPC()!;
|
||||||
return JSON.stringify(
|
return JSON.stringify(
|
||||||
{
|
{
|
||||||
publisher: {
|
PCTransports: {
|
||||||
connectedAddress: await pub.getConnectedAddress(),
|
publisher: {
|
||||||
connectionState: pub.getConnectionState(),
|
connectedAddress: await pub.getConnectedAddress(),
|
||||||
iceConnectionState: pub.getICEConnectionState(),
|
connectionState: pub.getConnectionState(),
|
||||||
signallingState: pub.getSignallingState(),
|
iceConnectionState: pub.getICEConnectionState(),
|
||||||
|
signallingState: pub.getSignallingState(),
|
||||||
|
},
|
||||||
|
subscriber: {
|
||||||
|
connectedAddress: await sub.getConnectedAddress(),
|
||||||
|
connectionState: sub.getConnectionState(),
|
||||||
|
iceConnectionState: sub.getICEConnectionState(),
|
||||||
|
signallingState: sub.getSignallingState(),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
subscriber: {
|
RTCIceCandidateStats: {
|
||||||
connectedAddress: await sub.getConnectedAddress(),
|
publisher: await this.getPublisherRTCIceCandidateStats(),
|
||||||
connectionState: sub.getConnectionState(),
|
subscriber: await this.getSubscriberRTCIceCandidateStats(),
|
||||||
iceConnectionState: sub.getICEConnectionState(),
|
|
||||||
signallingState: sub.getSignallingState(),
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
null,
|
null,
|
||||||
|
@ -1238,4 +1244,56 @@ export class OpenviduInstanceComponent {
|
||||||
getSubscriberPC(): PCTransport | undefined {
|
getSubscriberPC(): PCTransport | undefined {
|
||||||
return this.room?.localParticipant.engine.pcManager?.subscriber;
|
return this.room?.localParticipant.engine.pcManager?.subscriber;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getPublisherRTCIceCandidateStats() {
|
||||||
|
return this.getRTCIceCandidateStats(this.getPublisherPC()!);
|
||||||
|
}
|
||||||
|
|
||||||
|
async getSubscriberRTCIceCandidateStats() {
|
||||||
|
return this.getRTCIceCandidateStats(this.getSubscriberPC()!);
|
||||||
|
}
|
||||||
|
|
||||||
|
async getRTCIceCandidateStats(pcTransport: PCTransport) {
|
||||||
|
return new Promise(async (resolve) => {
|
||||||
|
let selectedCandidatePairId: string = '';
|
||||||
|
const stats: any = await new Promise((res) => {
|
||||||
|
const reports_stats: any[] = [];
|
||||||
|
pcTransport.getStats().then((stats: any) => {
|
||||||
|
stats.forEach((report: any) => {
|
||||||
|
if (report.type === 'transport') {
|
||||||
|
if (report.selectedCandidatePairId) {
|
||||||
|
selectedCandidatePairId = report.selectedCandidatePairId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (report.type === 'candidate-pair') {
|
||||||
|
console.log('Candidate Pair Report:', report);
|
||||||
|
const report_stats_object = {
|
||||||
|
report: report,
|
||||||
|
stats: stats,
|
||||||
|
};
|
||||||
|
reports_stats.push(report_stats_object);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return res(reports_stats);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
const selectedCandidates = [] as any[];
|
||||||
|
for (const report_stats_object of stats) {
|
||||||
|
if (report_stats_object.report.id === selectedCandidatePairId) {
|
||||||
|
selectedCandidates.push(
|
||||||
|
report_stats_object.stats.get(
|
||||||
|
report_stats_object.report.localCandidateId
|
||||||
|
)
|
||||||
|
);
|
||||||
|
console.log(
|
||||||
|
'Selected Candidate:',
|
||||||
|
report_stats_object.stats.get(
|
||||||
|
report_stats_object.report.localCandidateId
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return resolve(selectedCandidates);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue