Skip to content

Commit

Permalink
Release PR
Browse files Browse the repository at this point in the history
  • Loading branch information
raviteja83 authored Jun 6, 2024
2 parents 29f7d58 + 613eebc commit 7c3716d
Show file tree
Hide file tree
Showing 38 changed files with 386 additions and 112 deletions.
2 changes: 1 addition & 1 deletion examples/prebuilt-react-integration/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/hls-player/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/hls-stats/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/hms-video-store/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/hms-video-store/src/IHMSActions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { TranscriptionConfig } from './interfaces/transcription-config';
import { FindPeerByNameRequestParams } from './signal/interfaces';
import {
HLSConfig,
HLSTimedMetadata,
Expand Down Expand Up @@ -561,6 +562,7 @@ export interface IHMSActions<T extends HMSGenericTypes = { sessionStore: Record<
lowerRemotePeerHand(peerId: string): Promise<void>;
getPeerListIterator(options?: HMSPeerListIteratorOptions): HMSPeerListIterator;
getPeer(peerId: string): Promise<HMSPeer | undefined>;
findPeerByName(options: FindPeerByNameRequestParams): Promise<{ offset: number; eof?: boolean; peers: HMSPeer[] }>;
/**
* Method to override the default settings for playlist tracks
* @param {HMSPlaylistSettings} settings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export abstract class RunningTrackAnalytics {
| RemoteAudioTrackAnalytics
| RemoteVideoTrackAnalytics;

protected getLatestStat() {
getLatestStat() {
return this.tempStats[this.tempStats.length - 1];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,23 @@ export class SubscribeStatsAnalytics extends BaseStatsAnalytics {
const remoteTracksStats = hmsStats.getAllRemoteTracksStats();
let shouldCreateSample = false;
Object.keys(remoteTracksStats).forEach(trackID => {
const trackStats = remoteTracksStats[trackID];
const track = this.store.getTrackById(trackID);
const trackStats = remoteTracksStats[trackID];
const prevTrackStats = this.trackAnalytics.get(trackID)?.getLatestStat();

// eslint-disable-next-line complexity
const getCalculatedJitterBufferDelay = (trackStats: HMSTrackStats, prevTrackStats?: TempStats) => {
const prevJBDelay = prevTrackStats?.jitterBufferDelay || 0;
const prevJBEmittedCount = prevTrackStats?.jitterBufferEmittedCount || 0;
const currentJBDelay = (trackStats?.jitterBufferDelay || 0) - prevJBDelay;
const currentJBEmittedCount = (trackStats?.jitterBufferEmittedCount || 0) - prevJBEmittedCount;

const getCalculatedJitterBufferDelay = (trackStats: HMSTrackStats) =>
trackStats.jitterBufferDelay &&
trackStats.jitterBufferEmittedCount &&
(trackStats.jitterBufferDelay / trackStats.jitterBufferEmittedCount) * 1000;
return currentJBEmittedCount > 0
? (currentJBDelay * 1000) / currentJBEmittedCount
: prevTrackStats?.calculatedJitterBufferDelay || 0;
};

const calculatedJitterBufferDelay = getCalculatedJitterBufferDelay(trackStats);
const calculatedJitterBufferDelay = getCalculatedJitterBufferDelay(trackStats, prevTrackStats);

const avSync = this.calculateAvSyncForStat(trackStats, hmsStats);
const newTempStat: TempStats = { ...trackStats, calculatedJitterBufferDelay, avSync };
Expand Down
12 changes: 6 additions & 6 deletions packages/hms-video-store/src/interfaces/config.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import InitialSettings from './settings';

/**
* the config object tells the SDK options you want to join with
* @link https://docs.100ms.live/javascript/v2/features/preview
* @link https://docs.100ms.live/javascript/v2/features/join
*/

export type HMSICEServer = {
urls: string[];
userName?: string;
password?: string;
};

/**
* the config object tells the SDK options you want to join with
* @link https://docs.100ms.live/javascript/v2/features/preview
* @link https://docs.100ms.live/javascript/v2/features/join
*/

export interface HMSConfig {
/**
* the name of the peer, can be later accessed via peer.name and can also be changed mid call.
Expand Down
2 changes: 2 additions & 0 deletions packages/hms-video-store/src/interfaces/role.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { HMSTranscriptionMode } from './room';
import { SimulcastLayers } from './simulcast-layers';

export type HMSRoleName = string;
Expand All @@ -23,6 +24,7 @@ export interface HMSRole {
pollRead: boolean;
pollWrite: boolean;
whiteboard?: Array<HMSPermissionType>;
transcriptions?: Record<HMSTranscriptionMode, Array<HMSPermissionType>>;
};
priority: number;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ export interface Info {
type: HMSPeerType;
}

export interface FindPeerByNameInfo {
name: string;
peer_id: string;
role: string;
type: HMSPeerType;
}

export enum HMSRecordingState {
NONE = 'none',
INITIALISED = 'initialised',
Expand Down Expand Up @@ -79,13 +86,27 @@ interface PluginPermissions {
};
}

interface TranscriptionPluginPermissions {
permissions?: {
// list of roles
admin?: Array<string>;
};
mode: HMSTranscriptionMode;
}

export enum Plugins {
WHITEBOARD = 'whiteboard',
TRANSCRIPTIONS = 'transcriptions',
}

export interface PolicyParams {
name: string;
known_roles: {
[role: string]: HMSRole;
};
plugins: {
[plugin in 'whiteboard']?: PluginPermissions;
[Plugins.WHITEBOARD]?: PluginPermissions;
[Plugins.TRANSCRIPTIONS]?: TranscriptionPluginPermissions[];
};
template_id: string;
app_data?: Record<string, string>;
Expand Down
16 changes: 15 additions & 1 deletion packages/hms-video-store/src/reactive-store/HMSNotifications.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { EventEmitter2 as EventEmitter } from 'eventemitter2';
import { PEER_NOTIFICATION_TYPES, POLL_NOTIFICATION_TYPES, TRACK_NOTIFICATION_TYPES } from './common/mapping';
import {
PEER_NOTIFICATION_TYPES,
POLL_NOTIFICATION_TYPES,
TRACK_NOTIFICATION_TYPES,
TRANSCRIPTION_NOTIFICATION_TYPES,
} from './common/mapping';
import { IHMSStore } from '../IHMSStore';
import * as sdkTypes from '../internal';
import {
Expand Down Expand Up @@ -172,6 +177,14 @@ export class HMSNotifications<T extends HMSGenericTypes = { sessionStore: Record
}
}

sendTranscriptionUpdate(transcriptions?: sdkTypes.HMSTranscriptionInfo[]) {
const notification = this.createNotification(
TRANSCRIPTION_NOTIFICATION_TYPES[sdkTypes.HMSRoomUpdate.TRANSCRIPTION_STATE_UPDATED],
transcriptions,
HMSNotificationSeverity.INFO,
);
this.emitEvent(notification);
}
private emitEvent(notification: HMSNotification) {
this.eventEmitter.emit(HMS_NOTIFICATION_EVENT, notification);
}
Expand All @@ -190,6 +203,7 @@ export class HMSNotifications<T extends HMSGenericTypes = { sessionStore: Record
| HMSDeviceChangeEvent
| HMSPlaylistItem<T>
| sdkTypes.HMSPoll
| sdkTypes.HMSTranscriptionInfo[]
| null,
severity?: HMSNotificationSeverity,
message = '',
Expand Down
9 changes: 9 additions & 0 deletions packages/hms-video-store/src/reactive-store/HMSSDKActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ import {
selectTracksMap,
selectVideoTrackByID,
} from '../selectors';
import { FindPeerByNameRequestParams } from '../signal/interfaces';

/**
* This class implements the IHMSActions interface for 100ms SDK. It connects with SDK
Expand Down Expand Up @@ -608,6 +609,11 @@ export class HMSSDKActions<T extends HMSGenericTypes = { sessionStore: Record<st
return undefined;
}

async findPeerByName(options: FindPeerByNameRequestParams) {
const { offset, peers, eof } = await this.sdk.findPeerByName(options);
return { offset, eof, peers: peers.map(peer => SDKToHMS.convertPeer(peer) as HMSPeer) };
}

getPeerListIterator(options?: HMSPeerListIteratorOptions) {
const iterator = this.sdk.getPeerListIterator(options);
return {
Expand Down Expand Up @@ -1096,6 +1102,9 @@ export class HMSSDKActions<T extends HMSGenericTypes = { sessionStore: Record<st
this.setState(store => {
Object.assign(store.room, SDKToHMS.convertRoom(room, this.sdk.getLocalPeer()?.peerId));
}, type);
if (type === sdkTypes.HMSRoomUpdate.TRANSCRIPTION_STATE_UPDATED) {
this.hmsNotifications.sendTranscriptionUpdate(room.transcriptions);
}
}

protected onPeerUpdate(type: sdkTypes.HMSPeerUpdate, sdkPeer: sdkTypes.HMSPeer | sdkTypes.HMSPeer[]) {
Expand Down
8 changes: 8 additions & 0 deletions packages/hms-video-store/src/reactive-store/common/mapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,11 @@ export const POLL_NOTIFICATION_TYPES: PollNotificationMap = {
[sdkTypes.HMSPollsUpdate.POLL_STATS_UPDATED]: HMSNotificationTypes.POLL_VOTES_UPDATED,
[sdkTypes.HMSPollsUpdate.POLLS_LIST]: HMSNotificationTypes.POLLS_LIST,
};

type TranscriptionNotificationMap = {
[key in sdkTypes.HMSRoomUpdate.TRANSCRIPTION_STATE_UPDATED]: HMSNotificationTypes;
};

export const TRANSCRIPTION_NOTIFICATION_TYPES: TranscriptionNotificationMap = {
[sdkTypes.HMSRoomUpdate.TRANSCRIPTION_STATE_UPDATED]: HMSNotificationTypes.TRANSCRIPTION_STATE_UPDATED,
};
9 changes: 8 additions & 1 deletion packages/hms-video-store/src/schema/notification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { HMSMessage } from './message';
import { HMSPeer, HMSTrack } from './peer';
import { HMSPlaylistItem } from './playlist';
import { HMSChangeMultiTrackStateRequest, HMSChangeTrackStateRequest, HMSLeaveRoomRequest } from './requests';
import { HMSPoll } from '../internal';
import { HMSPoll, HMSTranscriptionInfo } from '../internal';

interface BaseNotification {
id: number;
Expand Down Expand Up @@ -78,6 +78,10 @@ export interface HMSPollNotification extends BaseNotification {
data: HMSPoll;
}

export interface HMSTranscriptionNotification extends BaseNotification {
type: HMSNotificationTypes.TRANSCRIPTION_STATE_UPDATED;
data: HMSTranscriptionInfo[];
}
export type HMSNotification =
| HMSPeerNotification
| HMSPeerListNotification
Expand All @@ -89,6 +93,7 @@ export type HMSNotification =
| HMSLeaveRoomRequestNotification
| HMSDeviceChangeEventNotification
| HMSReconnectionNotification
| HMSTranscriptionNotification
| HMSPlaylistItemNotification<any>;

export enum HMSNotificationSeverity {
Expand Down Expand Up @@ -126,6 +131,7 @@ export enum HMSNotificationTypes {
POLL_VOTES_UPDATED = 'POLL_VOTES_UPDATED',
POLLS_LIST = 'POLLS_LIST',
HAND_RAISE_CHANGED = 'HAND_RAISE_CHANGED',
TRANSCRIPTION_STATE_UPDATED = 'TRANSCRIPTION_STATE_UPDATED',
}

export type HMSNotificationMapping<T extends HMSNotificationTypes, C = any> = {
Expand Down Expand Up @@ -159,6 +165,7 @@ export type HMSNotificationMapping<T extends HMSNotificationTypes, C = any> = {
[HMSNotificationTypes.POLLS_LIST]: HMSPollNotification;
[HMSNotificationTypes.POLL_CREATED]: HMSPollNotification;
[HMSNotificationTypes.HAND_RAISE_CHANGED]: HMSPeerNotification;
[HMSNotificationTypes.TRANSCRIPTION_STATE_UPDATED]: HMSTranscriptionNotification;
}[T];

export type MappedNotifications<Type extends HMSNotificationTypes[]> = {
Expand Down
45 changes: 41 additions & 4 deletions packages/hms-video-store/src/sdk/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,19 @@ import {
HMSTrackType,
HMSVideoTrack,
} from '../media/tracks';
import { HMSNotificationMethod, PeerLeaveRequestNotification, SendMessage } from '../notification-manager';
import {
HMSNotificationMethod,
PeerLeaveRequestNotification,
PeerNotificationInfo,
SendMessage,
} from '../notification-manager';
import { createRemotePeer } from '../notification-manager/managers/utils';
import { NotificationManager } from '../notification-manager/NotificationManager';
import { SessionStore } from '../session-store';
import { InteractivityCenter } from '../session-store/interactivity-center';
import { InitConfig, InitFlags } from '../signal/init/models';
import {
FindPeerByNameRequestParams,
HLSRequestParams,
HLSTimedMetadataParams,
HLSVariant,
Expand Down Expand Up @@ -718,11 +724,11 @@ export class HMSSdk implements HMSInterface {
let recipientPeer = this.store.getPeerById(peerId);
if (!recipientPeer) {
if (isLargeRoom) {
const { peers } = await this.transport.signal.findPeers({ peers: [peerId], limit: 1 });
if (peers.length === 0) {
const peer = await this.transport.signal.getPeer({ peer_id: peerId });
if (!peer) {
throw ErrorFactory.GenericErrors.ValidationFailed('Invalid peer - peer not present in the room', peerId);
}
recipientPeer = createRemotePeer(peers[0], this.store);
recipientPeer = createRemotePeer(peer, this.store);
} else {
throw ErrorFactory.GenericErrors.ValidationFailed('Invalid peer - peer not present in the room', peerId);
}
Expand All @@ -739,6 +745,37 @@ export class HMSSdk implements HMSInterface {
return undefined;
}

async findPeerByName({ query, limit = 10, offset }: FindPeerByNameRequestParams) {
const {
peers,
offset: responseOffset,
eof,
} = await this.transport.signal.findPeerByName({ query: query?.toLowerCase(), limit, offset });
if (peers.length > 0) {
return {
offset: responseOffset,
eof,
peers: peers.map(peerInfo => {
return createRemotePeer(
{
peer_id: peerInfo.peer_id,
role: peerInfo.role,
groups: [],
info: {
name: peerInfo.name,
data: '',
user_id: '',
type: peerInfo.type,
},
} as PeerNotificationInfo,
this.store,
);
}),
};
}
return { offset: responseOffset, peers: [] };
}

private async sendMessageInternal({ recipientRoles, recipientPeer, type = 'chat', message }: HMSMessageInput) {
if (message.replace(/\u200b/g, ' ').trim() === '') {
HMSLogger.w(this.TAG, 'sendMessage', 'Ignoring empty message send');
Expand Down
Loading

0 comments on commit 7c3716d

Please sign in to comment.