Update to RingRTC v2.5.1

Co-authored-by: Vladimir Skuratovich <vlad@signal.org>
This commit is contained in:
Jim Gustafson 2020-08-27 12:21:10 -07:00 committed by Josh Perez
parent e9cf5ba67c
commit 90bf0f4eea
5 changed files with 32 additions and 35 deletions

View file

@ -14,7 +14,8 @@ const i18n = setupI18n('en', enMessages);
const audioDevice = {
name: '',
index: 0,
same_name_index: 0,
uniqueId: '',
i18nKey: undefined,
};
const createProps = ({
@ -45,19 +46,20 @@ stories.add('Default', () => {
stories.add('Some Devices', () => {
const availableSpeakers = [
{
name: 'Default - Internal Microphone',
name: 'Default',
index: 0,
same_name_index: 0,
uniqueId: 'Default',
i18nKey: 'default_communication_device',
},
{
name: "Natalie's Airpods (Bluetooth)",
index: 1,
same_name_index: 1,
uniqueId: 'aa',
},
{
name: 'UE Boom (Bluetooth)',
index: 2,
same_name_index: 2,
uniqueId: 'bb',
},
];
const selectedSpeaker = availableSpeakers[0];
@ -73,33 +75,35 @@ stories.add('Some Devices', () => {
stories.add('All Devices', () => {
const availableSpeakers = [
{
name: 'Default - Internal Speakers',
name: 'Default',
index: 0,
same_name_index: 0,
uniqueId: 'Default',
i18nKey: 'default_communication_device',
},
{
name: "Natalie's Airpods (Bluetooth)",
index: 1,
same_name_index: 1,
uniqueId: 'aa',
},
{
name: 'UE Boom (Bluetooth)',
index: 2,
same_name_index: 2,
uniqueId: 'bb',
},
];
const selectedSpeaker = availableSpeakers[0];
const availableMicrophones = [
{
name: 'Default - Internal Microphone',
name: 'Default',
index: 0,
same_name_index: 0,
uniqueId: 'Default',
i18nKey: 'default_communication_device',
},
{
name: "Natalie's Airpods (Bluetooth)",
index: 1,
same_name_index: 1,
uniqueId: 'aa',
},
];
const selectedMicrophone = availableMicrophones[0];

View file

@ -207,10 +207,8 @@ export class CallingClass {
for (let i = 0; i < a.availableMicrophones.length; i++) {
if (
a.availableMicrophones[i].name !== b.availableMicrophones[i].name ||
a.availableMicrophones[i].unique_id !==
b.availableMicrophones[i].unique_id ||
a.availableMicrophones[i].same_name_index !==
b.availableMicrophones[i].same_name_index
a.availableMicrophones[i].uniqueId !==
b.availableMicrophones[i].uniqueId
) {
return false;
}
@ -218,9 +216,7 @@ export class CallingClass {
for (let i = 0; i < a.availableSpeakers.length; i++) {
if (
a.availableSpeakers[i].name !== b.availableSpeakers[i].name ||
a.availableSpeakers[i].unique_id !== b.availableSpeakers[i].unique_id ||
a.availableSpeakers[i].same_name_index !==
b.availableSpeakers[i].same_name_index
a.availableSpeakers[i].uniqueId !== b.availableSpeakers[i].uniqueId
) {
return false;
}
@ -327,21 +323,18 @@ export class CallingClass {
// No preference stored
return undefined;
}
// Match by UUID first, if available
if (preferred.unique_id) {
// Match by uniqueId first, if available
if (preferred.uniqueId) {
const matchIndex = available.findIndex(
d => d.unique_id === preferred.unique_id
d => d.uniqueId === preferred.uniqueId
);
if (matchIndex !== -1) {
return matchIndex;
}
}
// Match by name second, and if there are multiple such names - by instance index.
// Match by name second
const matchingNames = available.filter(d => d.name === preferred.name);
if (matchingNames.length > preferred.same_name_index) {
return matchingNames[preferred.same_name_index].index;
}
if (matchingNames.length > 0) {
return matchingNames[0].index;
}

View file

@ -1,13 +1,13 @@
// Must be kept in sync with RingRTC.AudioDevice
export interface AudioDevice {
// Name, present on every platform.
// Device name.
name: string;
// Index of this device, starting from 0.
index: number;
// Index of this device out of all devices sharing the same name.
same_name_index: number;
// If present, a unique and stable identifier of this device. Only available on WIndows.
unique_id?: string;
// A unique and somewhat stable identifier of this device.
uniqueId: string;
// If present, the identifier of a localized string to substitute for the device name.
i18nKey?: string;
}
// This must be kept in sync with RingRTC.CallState.