Skip to content

Commit

Permalink
fix(meetings): ensure non-undefined value for peripheral information …
Browse files Browse the repository at this point in the history
…property (#3281)
  • Loading branch information
mccarthytyler committed Jan 9, 2024
1 parent dfbe9c2 commit 09ace65
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
6 changes: 2 additions & 4 deletions packages/@webex/plugin-meetings/src/statsAnalyzer/index.ts
Expand Up @@ -198,18 +198,16 @@ export class StatsAnalyzer extends EventsScope {
newMqa.intervalMetadata.peerReflexiveIP = this.statsResults.connectionType.local.ipAddress;

// Adding peripheral information
newMqa.intervalMetadata.peripherals = [];

newMqa.intervalMetadata.peripherals.push({information: _UNKNOWN_, name: MEDIA_DEVICES.SPEAKER});
if (this.statsResults['audio-send']) {
newMqa.intervalMetadata.peripherals.push({
information: this.statsResults['audio-send']?.trackLabel,
information: this.statsResults['audio-send'].trackLabel || _UNKNOWN_,
name: MEDIA_DEVICES.MICROPHONE,
});
}
if (this.statsResults['video-send']) {
newMqa.intervalMetadata.peripherals.push({
information: this.statsResults['video-send']?.trackLabel,
information: this.statsResults['video-send'].trackLabel || _UNKNOWN_,
name: MEDIA_DEVICES.CAMERA,
});
}
Expand Down
Expand Up @@ -7,6 +7,7 @@ import {ConnectionState} from '@webex/internal-media-core';
import {StatsAnalyzer, EVENTS} from '../../../../src/statsAnalyzer';
import NetworkQualityMonitor from '../../../../src/networkQualityMonitor';
import testUtils from '../../../utils/testUtils';
import {MEDIA_DEVICES, _UNKNOWN_} from '@webex/plugin-meetings/src/constants';

const {assert} = chai;

Expand Down Expand Up @@ -119,6 +120,7 @@ describe('plugin-meetings', () => {
audio: {
senders: [
{
localTrackLabel: 'fake-microphone',
report: [
{
type: 'outbound-rtp',
Expand Down Expand Up @@ -173,6 +175,7 @@ describe('plugin-meetings', () => {
video: {
senders: [
{
localTrackLabel: 'fake-camera',
report: [
{
type: 'outbound-rtp',
Expand Down Expand Up @@ -413,6 +416,27 @@ describe('plugin-meetings', () => {
assert.strictEqual(mqeData.audioTransmit[0].common.transportType, 'TLS');
assert.strictEqual(mqeData.videoReceive[0].common.transportType, 'TLS');
});

it('emits the correct peripherals in MEDIA_QUALITY events', async () => {
await startStatsAnalyzer({expected: {receiveVideo: true}});

await progressTime();

assert.strictEqual(mqeData.intervalMetadata.peripherals.find((val) => val.name === MEDIA_DEVICES.MICROPHONE).information, 'fake-microphone');
assert.strictEqual(mqeData.intervalMetadata.peripherals.find((val) => val.name === MEDIA_DEVICES.CAMERA).information, 'fake-camera');
});

it('emits the correct peripherals in MEDIA_QUALITY events when localTrackLabel is undefined', async () => {
fakeStats.audio.senders[0].localTrackLabel = undefined;
fakeStats.video.senders[0].localTrackLabel = undefined;

await startStatsAnalyzer({expected: {receiveVideo: true}});

await progressTime();

assert.strictEqual(mqeData.intervalMetadata.peripherals.find((val) => val.name === MEDIA_DEVICES.MICROPHONE).information, _UNKNOWN_);
assert.strictEqual(mqeData.intervalMetadata.peripherals.find((val) => val.name === MEDIA_DEVICES.CAMERA).information, _UNKNOWN_);
});
});
});
});

0 comments on commit 09ace65

Please sign in to comment.