Skip to content

Commit

Permalink
fix: revert audio changes for media channel
Browse files Browse the repository at this point in the history
  • Loading branch information
amar-1995 committed Sep 26, 2024
1 parent 740015c commit b76bb41
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export class AudioSinkManager {
);
this.eventBus.analytics.publish(AnalyticsEventFactory.audioPlaybackError(ex));
if (audioEl?.error?.code === MediaError.MEDIA_ERR_DECODE) {
// try to wait for main execution to complete.
// try to wait for main execution to complete first
await sleep(500);
this.removeAudioElement(audioEl, track);
await this.handleTrackAdd({ track, peer, callListener: false });
Expand Down
1 change: 0 additions & 1 deletion packages/hms-video-store/src/connection/HMSConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ export default abstract class HMSConnection {
try {
const offer = await this.nativeConnection.createOffer(options);
HMSLogger.d(TAG, `[role=${this.role}] createOffer offer=${JSON.stringify(offer, null, 1)}`);
offer.sdp = offer.sdp?.replace(/(m=audio .*\r\n)/g, '$1a=content:main\r\na=content:call\r\n');
return enableOpusDtx(fixMsid(offer, tracks));
} catch (error) {
throw ErrorFactory.WebrtcErrors.CreateOfferFailed(this.action, (error as Error).message);
Expand Down
14 changes: 7 additions & 7 deletions packages/hms-video-store/src/device-manager/DeviceManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ErrorFactory } from '../error/ErrorFactory';
import { HMSException } from '../error/HMSException';
import { EventBus } from '../events/EventBus';
import { DeviceMap, HMSDeviceChangeEvent, SelectedDevices } from '../interfaces';
import { getAudioDeviceCategory, isIOS } from '../internal';
import { isIOS } from '../internal';
import { HMSAudioTrackSettingsBuilder, HMSVideoTrackSettingsBuilder } from '../media/settings';
import { HMSLocalAudioTrack, HMSLocalTrack, HMSLocalVideoTrack } from '../media/tracks';
import { Store } from '../sdk/store';
Expand Down Expand Up @@ -443,14 +443,14 @@ export class DeviceManager implements HMSDeviceManager {
let earpiece: InputDeviceInfo | null = null;

for (const device of this.audioInput) {
const deviceCategory = getAudioDeviceCategory(device.label);
if (deviceCategory === 'speakerphone') {
const label = device.label.toLowerCase();
if (label.includes('speakerphone')) {
speakerPhone = device;
} else if (deviceCategory === 'wired') {
} else if (label.includes('wired')) {
wired = device;
} else if (deviceCategory === 'bluetooth') {
} else if (/airpods|buds|wireless|bluetooth/gi.test(label)) {
bluetoothDevice = device;
} else if (deviceCategory === 'speakerhone') {
} else if (label.includes('earpiece')) {
earpiece = device;
}
}
Expand Down Expand Up @@ -498,7 +498,7 @@ export class DeviceManager implements HMSDeviceManager {
this.earpieceSelected = true;
return;
}
await localAudioTrack.setSettings({ deviceId: 'default' }, true);
await localAudioTrack.setSettings({ deviceId: earpiece?.deviceId }, true);
this.earpieceSelected = true;
}
await localAudioTrack.setSettings(
Expand Down
11 changes: 5 additions & 6 deletions packages/hms-video-store/src/media/tracks/HMSLocalAudioTrack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,12 +248,11 @@ export class HMSLocalAudioTrack extends HMSAudioTrack {
*/
async setProcessedTrack(processedTrack?: MediaStreamTrack) {
// if all plugins are removed reset everything back to native track
// if (!processedTrack) {
// this.processedTrack = undefined;
// } else if (processedTrack !== this.processedTrack) {
// this.processedTrack = processedTrack;
// }
console.log('process track ', processedTrack);
if (!processedTrack) {
this.processedTrack = undefined;
} else if (processedTrack !== this.processedTrack) {
this.processedTrack = processedTrack;
}
await this.replaceSenderTrack();
}

Expand Down

0 comments on commit b76bb41

Please sign in to comment.