Skip to content

Commit

Permalink
Release PR
Browse files Browse the repository at this point in the history
  • Loading branch information
raviteja83 authored Apr 5, 2024
2 parents 7c3e871 + 5cb0983 commit ee72aff
Show file tree
Hide file tree
Showing 62 changed files with 433 additions and 230 deletions.
6 changes: 5 additions & 1 deletion examples/prebuilt-react-integration/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,9 @@ import { getRoomCodeFromUrl } from './utils';
export default function App() {
const roomCode = getRoomCodeFromUrl();

return <HMSPrebuilt roomCode={roomCode} />;
return (
<HMSPrebuilt
roomCode={roomCode}
/>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ class RunningLocalTrackAnalytics extends RunningTrackAnalytics {
avg_available_outgoing_bitrate_bps: this.calculateAverage('availableOutgoingBitrate'),
avg_bitrate_bps: this.calculateAverage('bitrate'),
avg_fps: this.calculateAverage('framesPerSecond'),
total_packets_lost: this.calculateDifferenceForSample('packetsLost'),
total_packets_sent: this.calculateDifferenceForSample('packetsSent'),
total_packets_lost: this.getLatestStat().packetsLost,
total_packets_sent: this.getLatestStat().packetsSent,
total_packet_sent_delay_sec: parseFloat(this.calculateDifferenceForSample('totalPacketSendDelay').toFixed(4)),
total_fir_count: this.calculateDifferenceForSample('firCount'),
total_pli_count: this.calculateDifferenceForSample('pliCount'),
Expand Down
68 changes: 36 additions & 32 deletions packages/hms-video-store/src/audio-sink-manager/AudioSinkManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export class AudioSinkManager {
private state = { ...INITIAL_STATE };
private listener?: HMSUpdateListener;
private timer: ReturnType<typeof setInterval> | null = null;
private earpieceSelected = false;

constructor(private store: Store, private deviceManager: DeviceManager, private eventBus: EventBus) {
this.eventBus.audioTrackAdded.subscribe(this.handleTrackAdd);
Expand Down Expand Up @@ -285,42 +286,45 @@ export class AudioSinkManager {
*/
// eslint-disable-next-line complexity
private autoSelectAudioOutput = async () => {
if (this.audioSink?.children.length === 0) {
let bluetoothDevice: InputDeviceInfo | null = null;
let speakerPhone: InputDeviceInfo | null = null;
let wired: InputDeviceInfo | null = null;
let earpiece: InputDeviceInfo | null = null;
if (!this.audioSink?.children.length) {
HMSLogger.d(this.TAG, 'No remote audio added yet');
return;
}
let bluetoothDevice: InputDeviceInfo | null = null;
let speakerPhone: InputDeviceInfo | null = null;
let wired: InputDeviceInfo | null = null;
let earpiece: InputDeviceInfo | null = null;

for (const device of this.deviceManager.audioInput) {
if (device.label.toLowerCase().includes('speakerphone')) {
speakerPhone = device;
}
if (device.label.toLowerCase().includes('wired')) {
wired = device;
}
if (device.label.toLowerCase().includes('bluetooth')) {
bluetoothDevice = device;
}
if (device.label.toLowerCase().includes('earpiece')) {
earpiece = device;
}
for (const device of this.deviceManager.audioInput) {
const label = device.label.toLowerCase();
if (label.includes('speakerphone')) {
speakerPhone = device;
} else if (label.includes('wired')) {
wired = device;
} else if (label.includes('bluetooth')) {
bluetoothDevice = device;
} else if (label.includes('earpiece')) {
earpiece = device;
}
const localAudioTrack = this.store.getLocalPeer()?.audioTrack;
if (localAudioTrack && earpiece) {
const externalDeviceID = bluetoothDevice?.deviceId || wired?.deviceId || speakerPhone?.deviceId;
HMSLogger.d(this.TAG, 'externalDeviceID', externalDeviceID);
// already selected appropriate device
if (localAudioTrack.settings.deviceId === externalDeviceID) {
return;
}
}
const localAudioTrack = this.store.getLocalPeer()?.audioTrack;
if (localAudioTrack && earpiece) {
const externalDeviceID = bluetoothDevice?.deviceId || wired?.deviceId || speakerPhone?.deviceId;
HMSLogger.d(this.TAG, 'externalDeviceID', externalDeviceID);
// already selected appropriate device
if (localAudioTrack.settings.deviceId === externalDeviceID) {
return;
}
if (!this.earpieceSelected) {
await localAudioTrack.setSettings({ deviceId: earpiece?.deviceId }, true);
await localAudioTrack.setSettings(
{
deviceId: externalDeviceID,
},
true,
);
this.earpieceSelected = true;
}
await localAudioTrack.setSettings(
{
deviceId: externalDeviceID,
},
true,
);
}
};
}
2 changes: 1 addition & 1 deletion packages/hms-video-store/src/error/ErrorFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const ErrorFactory = {
ErrorCodes.WebSocketConnectionErrors.WEBSOCKET_CONNECTION_LOST,
'WebSocketConnectionLost',
action,
`Network connection lost `,
`Network connection lost`,
description,
);
},
Expand Down
1 change: 1 addition & 0 deletions packages/hms-video-store/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export {
parsedUserAgent,
simulcastMapping,
DeviceType,
HMSPeerType,
} from './internal';

export type {
Expand Down
6 changes: 6 additions & 0 deletions packages/hms-video-store/src/interfaces/peer/hms-peer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { HMSAudioTrack, HMSTrack, HMSVideoTrack } from '../../media/tracks';
import { HMSRole } from '../role';

export enum HMSPeerType {
SIP = 'sip',
REGULAR = 'regular',
}

export interface HMSPeer {
peerId: string;
name: string;
Expand All @@ -16,6 +21,7 @@ export interface HMSPeer {
groups?: string[];
realtime?: boolean;
isHandRaised: boolean;
type: HMSPeerType;

updateRole(newRole: HMSRole): void;
updateName(newName: string): void;
Expand Down
1 change: 1 addition & 0 deletions packages/hms-video-store/src/interfaces/peer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export type { HMSPeer } from './hms-peer';
export type { HMSLocalPeer } from './hms-local-peer';
export type { HMSRemotePeer } from './hms-remote-peer';
export type { HMSConnectionQuality } from './connection-quality';
export { HMSPeerType } from './hms-peer';
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,21 @@ export interface HMSWhiteboard {
open?: boolean; // whether whiteboard is open or not
title?: string;
owner?: string; // user id for whiteboard owner
addr?: string; // address to be used to connect to whiteboard service
token?: string; // security token to be used for whiteboard API
permissions?: Array<HMSPermissionType>;
presence?: boolean;
attributes?: Array<{ name: string; value: unknown }>;
/**
* the URL that needs to be used as the iframe src
*/
url?: string;
/**
* address to be used to connect to whiteboard grpc communication service
* @internal
*/
addr?: string;
/**
* security token to be used for whiteboard API
* @internal
*/
token?: string;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { VideoTrackLayerUpdate } from '../connection/channel-messages';
import { HMSPeerType } from '../interfaces/peer/hms-peer';
import { HMSRole } from '../interfaces/role';
import { HMSLocalTrack } from '../media/tracks';
import { HMSTrack, HMSTrackSource } from '../media/tracks/HMSTrack';
Expand Down Expand Up @@ -39,6 +40,7 @@ export interface Info {
name: string;
data: string;
user_id: string;
type: HMSPeerType;
}

export enum HMSRecordingState {
Expand Down
11 changes: 8 additions & 3 deletions packages/hms-video-store/src/notification-manager/fixtures.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { MessageNotification, PeerListNotification, PeerNotification, SpeakerList } from './HMSNotifications';
import { HMSPeerType } from '../interfaces';

export const FAKE_PEER_ID = 'peer_id_1';

export const fakePeer: PeerNotification = {
peer_id: 'peer_id_0',
info: { data: 'data', name: 'Sarvesh0', user_id: 'customer_user_id' },
info: { data: 'data', name: 'Sarvesh0', user_id: 'customer_user_id', type: HMSPeerType.REGULAR },
role: 'host',
tracks: {},
groups: [],
Expand All @@ -17,6 +18,7 @@ export const fakePeerList: PeerListNotification = {
name: 'Sarvesh1',
data: 'data',
user_id: 'customer_user_id',
type: HMSPeerType.REGULAR,
},
role: 'host',
peer_id: FAKE_PEER_ID,
Expand All @@ -32,7 +34,7 @@ export const fakePeerList: PeerListNotification = {
track_id_2: {
mute: false,
type: 'video',
source: 'regular',
source: HMSPeerType.REGULAR,
description: '',
track_id: 'track_id_2',
stream_id: 'stream_id_1',
Expand All @@ -45,6 +47,7 @@ export const fakePeerList: PeerListNotification = {
name: 'Sarvesh3',
data: 'data',
user_id: 'customer_user_id',
type: HMSPeerType.REGULAR,
},
peer_id: 'peer_id_3',
role: 'viewer',
Expand Down Expand Up @@ -85,6 +88,7 @@ export const fakeReconnectPeerList: PeerListNotification = {
name: 'Sarvesh1',
data: 'data',
user_id: 'customer_user_id',
type: HMSPeerType.REGULAR,
},
role: 'host',
peer_id: FAKE_PEER_ID,
Expand All @@ -100,7 +104,7 @@ export const fakeReconnectPeerList: PeerListNotification = {
track_id_2: {
mute: false,
type: 'video',
source: 'regular',
source: HMSPeerType.REGULAR,
description: '',
track_id: 'track_id_2',
stream_id: 'stream_id_1',
Expand All @@ -113,6 +117,7 @@ export const fakeReconnectPeerList: PeerListNotification = {
name: 'Sarvesh2',
data: 'data',
user_id: 'customer_user_id',
type: HMSPeerType.REGULAR,
},
peer_id: 'peer_id_2',
role: 'viewer',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export class PeerListManager {
name: peer.name,
data: peer.metadata || '',
user_id: peer.customerUserId || '',
type: peer.type,
},
tracks: {},
groups: [],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { HMSUpdateListener, HMSWhiteboard } from '../../interfaces';
import { Store } from '../../sdk/store';
import HMSTransport from '../../transport';
import { constructWhiteboardURL } from '../../utils/whiteboard';
import { HMSNotificationMethod } from '../HMSNotificationMethod';
import { WhiteboardInfo } from '../HMSNotifications';

Expand Down Expand Up @@ -31,11 +32,19 @@ export class WhiteboardManager {
whiteboard.open = isOwner ? prev?.open : open;
whiteboard.owner = whiteboard.open ? notification.owner : undefined;

if (!isOwner && whiteboard.open) {
const response = await this.transport.signal.getWhiteboard({ id: notification.id });
whiteboard.token = response.token;
whiteboard.addr = response.addr;
whiteboard.permissions = response.permissions;
if (whiteboard.open) {
if (isOwner) {
whiteboard.url = prev?.url;
whiteboard.token = prev?.token;
whiteboard.addr = prev?.addr;
whiteboard.permissions = prev?.permissions;
} else {
const response = await this.transport.signal.getWhiteboard({ id: notification.id });
whiteboard.url = constructWhiteboardURL(response.token, response.addr, this.store.getEnv());
whiteboard.token = response.token;
whiteboard.addr = response.addr;
whiteboard.permissions = response.permissions;
}
}

this.store.setWhiteboard(whiteboard);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ export const createRemotePeer = (notifPeer: PeerNotificationInfo, store: Store)
customerUserId: notifPeer.info.user_id,
metadata: notifPeer.info.data,
groups: notifPeer.groups,
type: notifPeer.info.type,
});
};
12 changes: 10 additions & 2 deletions packages/hms-video-store/src/reactive-store/HMSSDKActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,10 @@ export class HMSSDKActions<T extends HMSGenericTypes = { sessionStore: Record<st
HMSLogger.w('sendMessage', 'Failed to send message', messageInput);
throw Error(`sendMessage Failed - ${JSON.stringify(messageInput)}`);
}
const ignoreMessage = !!messageInput.type && this.ignoredMessageTypes.includes(messageInput.type);
if (ignoreMessage) {
return;
}
const localPeer = this.sdk.getLocalPeer();
const hmsMessage: HMSMessage = {
read: true,
Expand All @@ -427,9 +431,13 @@ export class HMSSDKActions<T extends HMSGenericTypes = { sessionStore: Record<st
senderName: localPeer?.name,
sender: localPeer?.peerId,
senderRole: localPeer?.role?.name,
ignored: !!messageInput.type && this.ignoredMessageTypes.includes(messageInput.type),
ignored: false,
};
this.putMessageInStore(hmsMessage);
// update directly to store without batch
this.setState(store => {
store.messages.byID[hmsMessage.id] = hmsMessage;
store.messages.allIDs.push(hmsMessage.id);
}, 'newMessage');
}

setMessageRead(readStatus: boolean, messageId?: string) {
Expand Down
1 change: 1 addition & 0 deletions packages/hms-video-store/src/reactive-store/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export class SDKToHMS {
joinedAt: sdkPeer.joinedAt,
groups: sdkPeer.groups,
isHandRaised: sdkPeer.isHandRaised,
type: sdkPeer.type,
};
}

Expand Down
2 changes: 2 additions & 0 deletions packages/hms-video-store/src/schema/peer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
HMSSimulcastLayerDefinition,
ScreenCaptureHandle,
} from '../interfaces';
import { HMSPeerType } from '../interfaces/peer/hms-peer';

export type HMSPeerID = string;
export type HMSTrackID = string;
Expand Down Expand Up @@ -42,6 +43,7 @@ export interface HMSPeer {
joinedAt?: Date;
groups?: HMSGroupName[];
isHandRaised: boolean;
type: HMSPeerType;
}

/**
Expand Down
Loading

0 comments on commit ee72aff

Please sign in to comment.