diff --git a/package.json b/package.json index 66a2829c30..e5563b31c0 100644 --- a/package.json +++ b/package.json @@ -128,7 +128,7 @@ "redux-ts-utils": "3.2.2", "reselect": "4.0.0", "rimraf": "2.6.2", - "ringrtc": "https://github.com/signalapp/signal-ringrtc-node.git#0cd60f529d8f17734fe19e7195c9fd3c3f4271db", + "ringrtc": "https://github.com/signalapp/signal-ringrtc-node.git#9e295f8d6f4652cc77538f3e2e88f6348344d367", "sanitize-filename": "1.6.3", "sanitize.css": "11.0.0", "semver": "5.4.1", diff --git a/ts/components/CallingDeviceSelection.stories.tsx b/ts/components/CallingDeviceSelection.stories.tsx index f8129250ff..831315f56d 100644 --- a/ts/components/CallingDeviceSelection.stories.tsx +++ b/ts/components/CallingDeviceSelection.stories.tsx @@ -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]; diff --git a/ts/services/calling.ts b/ts/services/calling.ts index 1270e6b859..aca1e44e36 100644 --- a/ts/services/calling.ts +++ b/ts/services/calling.ts @@ -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; } diff --git a/ts/types/Calling.ts b/ts/types/Calling.ts index c698a792cd..c4b9574a14 100644 --- a/ts/types/Calling.ts +++ b/ts/types/Calling.ts @@ -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. diff --git a/yarn.lock b/yarn.lock index c2fe339f1a..959c3b9742 100644 --- a/yarn.lock +++ b/yarn.lock @@ -13568,9 +13568,9 @@ rimraf@~2.4.0: dependencies: glob "^6.0.1" -"ringrtc@https://github.com/signalapp/signal-ringrtc-node.git#0cd60f529d8f17734fe19e7195c9fd3c3f4271db": - version "2.5.0" - resolved "https://github.com/signalapp/signal-ringrtc-node.git#0cd60f529d8f17734fe19e7195c9fd3c3f4271db" +"ringrtc@https://github.com/signalapp/signal-ringrtc-node.git#9e295f8d6f4652cc77538f3e2e88f6348344d367": + version "2.5.1" + resolved "https://github.com/signalapp/signal-ringrtc-node.git#9e295f8d6f4652cc77538f3e2e88f6348344d367" ripemd160@^2.0.0, ripemd160@^2.0.1: version "2.0.1"