@100mslive/hms-video-store
Advanced tools
Comparing version 0.2.58 to 0.2.59
import { IHMSNotifications } from '../IHMSNotifications'; | ||
import { IHMSStore } from '../IHMSStore'; | ||
import * as sdkTypes from './sdkTypes'; | ||
import { HMSNotification, HMSPeer, HMSException, HMSMessage, HMSChangeTrackStateRequest, HMSLeaveRoomRequest, HMSDeviceChangeEvent } from '../schema'; | ||
import { HMSNotification, HMSPeer, HMSException, HMSMessage, HMSChangeTrackStateRequest, HMSChangeMultiTrackStateRequest, HMSLeaveRoomRequest, HMSDeviceChangeEvent } from '../schema'; | ||
export declare class HMSNotifications implements IHMSNotifications { | ||
@@ -20,4 +20,5 @@ private id; | ||
sendChangeTrackStateRequest(request: HMSChangeTrackStateRequest): void; | ||
sendChangeMultiTrackStateRequest(request: HMSChangeMultiTrackStateRequest): void; | ||
private emitEvent; | ||
private createNotification; | ||
} |
@@ -1,6 +0,6 @@ | ||
import { HMSMessage, HMSTrackID, HMSTrackSource, IHMSPlaylistActions } from '../schema'; | ||
import { HMSMessage, HMSTrackID, HMSTrackSource, HMSChangeMultiTrackStateParams, IHMSPlaylistActions } from '../schema'; | ||
import { IHMSActions } from '../IHMSActions'; | ||
import * as sdkTypes from './sdkTypes'; | ||
import { HMSRoleChangeRequest } from '../selectors'; | ||
import { HMSAudioPlugin, HMSChangeTrackStateRequest as SDKHMSChangeTrackStateRequest, HMSException as SDKHMSException, HMSLogLevel, HMSSdk, HMSSimulcastLayer, HMSTrack as SDKHMSTrack, HMSVideoPlugin } from '@100mslive/hms-video'; | ||
import { HMSAudioPlugin, HMSException as SDKHMSException, HMSLogLevel, HMSChangeTrackStateRequest as SDKHMSChangeTrackStateRequest, HMSChangeMultiTrackStateRequest as SDKHMSChangeMultiTrackStateRequest, HMSSdk, HMSSimulcastLayer, HMSTrack as SDKHMSTrack, HMSVideoPlugin } from '@100mslive/hms-video'; | ||
import { IHMSStore } from '../IHMSStore'; | ||
@@ -78,2 +78,3 @@ import { HMSNotifications } from './HMSNotifications'; | ||
setRemoteTrackEnabled(trackID: HMSTrackID | HMSTrackID[], enabled: boolean): Promise<void>; | ||
setRemoteTracksEnabled(params: HMSChangeMultiTrackStateParams): Promise<void>; | ||
setLogLevel(level: HMSLogLevel): void; | ||
@@ -110,2 +111,3 @@ private resetState; | ||
protected onChangeTrackStateRequest(request: SDKHMSChangeTrackStateRequest): void; | ||
protected onChangeMultiTrackStateRequest(request: SDKHMSChangeMultiTrackStateRequest): void; | ||
protected onReconnected(): void; | ||
@@ -112,0 +114,0 @@ protected onReconnecting(sdkError: SDKHMSException): void; |
import { HMSConfig, HMSSimulcastLayer, HMSAudioTrackSettings, HMSVideoTrackSettings, HMSLogLevel, HMSVideoPlugin, HMSAudioPlugin } from '@100mslive/hms-video'; | ||
import { HMSMessageID, HMSPeerID, HMSRoleName, HMSTrackID, HMSTrackSource, IHMSPlaylistActions } from './schema'; | ||
import { HMSMessageID, HMSPeerID, HMSRoleName, HMSTrackID, HMSTrackSource, IHMSPlaylistActions, HMSChangeMultiTrackStateRequest } from './schema'; | ||
import { HMSRoleChangeRequest } from './selectors'; | ||
@@ -195,2 +195,8 @@ import { RTMPRecordingConfig } from './hmsSDKStore/sdkTypes'; | ||
/** | ||
* Use this to mute/unmute multipe tracks by source, role or type | ||
* @param {HMSChangeMultiTrackStateRequest} params | ||
*/ | ||
setRemoteTracksEnabled(params: HMSChangeMultiTrackStateRequest): Promise<void>; | ||
/** | ||
* Method to be called with some UI interaction after autoplay error is received | ||
* Most browsers have limitations where an audio can not be played if there was no user interaction. | ||
@@ -197,0 +203,0 @@ * SDK throws an autoplay error in this case, this method can be called after an UI interaction |
@@ -30,2 +30,3 @@ export interface HMSNotification { | ||
CHANGE_TRACK_STATE_REQUEST = "CHANGE_TRACK_STATE_REQUEST", | ||
CHANGE_MULTI_TRACK_STATE_REQUEST = "CHANGE_MULTI_TRACK_STATE_REQUEST", | ||
ROOM_ENDED = "ROOM_ENDED", | ||
@@ -32,0 +33,0 @@ REMOVED_FROM_ROOM = "REMOVED_FROM_ROOM", |
@@ -0,1 +1,2 @@ | ||
import { HMSTrackSource } from '.'; | ||
import { HMSPeer, HMSPeerID, HMSTrack } from './peer'; | ||
@@ -13,2 +14,15 @@ import { HMSRoleName } from './role'; | ||
} | ||
export interface HMSChangeMultiTrackStateRequest { | ||
requestedBy: HMSPeer; | ||
tracks: HMSTrack[]; | ||
enabled: boolean; | ||
type?: 'audio' | 'video'; | ||
source?: HMSTrackSource; | ||
} | ||
export interface HMSChangeMultiTrackStateParams { | ||
enabled: boolean; | ||
roles?: HMSRoleName[]; | ||
type?: 'audio' | 'video'; | ||
source?: HMSTrackSource; | ||
} | ||
export interface HMSLeaveRoomRequest { | ||
@@ -15,0 +29,0 @@ requestedBy: HMSPeer; |
{ | ||
"version": "0.2.58", | ||
"version": "0.2.59", | ||
"license": "MIT", | ||
@@ -58,7 +58,7 @@ "main": "dist/index.js", | ||
"peerDependencies": { | ||
"@100mslive/hms-video": "0.0.204", | ||
"@100mslive/hms-video": "0.0.205", | ||
"events": "^3.3.0" | ||
}, | ||
"devDependencies": { | ||
"@100mslive/hms-video": "0.0.204", | ||
"@100mslive/hms-video": "0.0.205", | ||
"@size-limit/file": "^5.0.3", | ||
@@ -65,0 +65,0 @@ "events": "^3.3.0", |
@@ -16,2 +16,3 @@ import EventEmitter from 'events'; | ||
HMSChangeTrackStateRequest, | ||
HMSChangeMultiTrackStateRequest, | ||
HMSLeaveRoomRequest, | ||
@@ -130,2 +131,11 @@ HMSDeviceChangeEvent, | ||
sendChangeMultiTrackStateRequest(request: HMSChangeMultiTrackStateRequest) { | ||
const notification = this.createNotification( | ||
HMSNotificationTypes.CHANGE_MULTI_TRACK_STATE_REQUEST, | ||
request, | ||
HMSNotificationSeverity.INFO, | ||
); | ||
this.emitEvent(notification); | ||
} | ||
private emitEvent(notification: HMSNotification) { | ||
@@ -143,2 +153,3 @@ this.eventEmitter.emit(HMS_NOTIFICATION_EVENT, notification); | ||
| HMSChangeTrackStateRequest | ||
| HMSChangeMultiTrackStateRequest | ||
| HMSLeaveRoomRequest | ||
@@ -145,0 +156,0 @@ | HMSDeviceChangeEvent |
@@ -14,2 +14,3 @@ import { | ||
HMSTrackSource, | ||
HMSChangeMultiTrackStateParams, | ||
IHMSPlaylistActions, | ||
@@ -37,2 +38,3 @@ } from '../schema'; | ||
selectTrackByID, | ||
selectTracksMap, | ||
} from '../selectors'; | ||
@@ -43,3 +45,2 @@ import { HMSLogger } from '../../common/ui-logger'; | ||
HMSAudioTrack as SDKHMSAudioTrack, | ||
HMSChangeTrackStateRequest as SDKHMSChangeTrackStateRequest, | ||
HMSException as SDKHMSException, | ||
@@ -54,2 +55,5 @@ HMSLeaveRoomRequest as SDKHMSLeaveRoomRequest, | ||
HMSRoleChangeRequest as SDKHMSRoleChangeRequest, | ||
HMSChangeTrackStateRequest as SDKHMSChangeTrackStateRequest, | ||
HMSChangeMultiTrackStateParams as SDKHMSChangeMultiTrackStateParams, | ||
HMSChangeMultiTrackStateRequest as SDKHMSChangeMultiTrackStateRequest, | ||
HMSSdk, | ||
@@ -459,2 +463,15 @@ HMSSimulcastLayer, | ||
async setRemoteTracksEnabled(params: HMSChangeMultiTrackStateParams) { | ||
const sdkRequest: SDKHMSChangeMultiTrackStateParams = { | ||
enabled: params.enabled, | ||
type: params.type, | ||
source: params.source, | ||
}; | ||
if (params.roles) { | ||
const rolesMap = this.store.getState(selectRolesMap); | ||
sdkRequest.roles = params.roles.map(role => rolesMap[role]); | ||
} | ||
await this.sdk.changeMultiTrackState(sdkRequest); | ||
} | ||
setLogLevel(level: HMSLogLevel) { | ||
@@ -487,2 +504,3 @@ HMSLogger.level = level; | ||
onChangeTrackStateRequest: this.onChangeTrackStateRequest.bind(this), | ||
onChangeMultiTrackStateRequest: this.onChangeMultiTrackStateRequest.bind(this), | ||
onRemovedFromRoom: this.onRemovedFromRoom.bind(this), | ||
@@ -800,2 +818,33 @@ }); | ||
protected onChangeMultiTrackStateRequest(request: SDKHMSChangeMultiTrackStateRequest) { | ||
const requestedBy = this.store.getState(selectPeerByID(request.requestedBy.peerId)); | ||
if (!requestedBy) { | ||
return this.logPossibleInconsistency( | ||
`Not found peer who requested track state change, ${request.requestedBy}`, | ||
); | ||
} | ||
if (!request.enabled) { | ||
this.syncRoomState('changeMultiTrackStateRequest'); | ||
} | ||
const tracks: HMSTrack[] = []; | ||
const tracksMap = this.store.getState(selectTracksMap); | ||
for (const track of request.tracks) { | ||
const storeTrackID = this.getStoreLocalTrackIDfromSDKTrack(track); | ||
if (storeTrackID && tracksMap[storeTrackID]) { | ||
tracks.push(tracksMap[storeTrackID]); | ||
} | ||
} | ||
this.hmsNotifications.sendChangeMultiTrackStateRequest({ | ||
requestedBy, | ||
tracks, | ||
enabled: request.enabled, | ||
type: request.type, | ||
source: request.source, | ||
}); | ||
} | ||
protected onReconnected() { | ||
@@ -802,0 +851,0 @@ this.syncRoomState('reconnectedSync'); |
@@ -17,2 +17,3 @@ import { | ||
IHMSPlaylistActions, | ||
HMSChangeMultiTrackStateRequest, | ||
} from './schema'; | ||
@@ -240,2 +241,9 @@ import { HMSRoleChangeRequest } from './selectors'; | ||
/** | ||
* Use this to mute/unmute multipe tracks by source, role or type | ||
* @param {HMSChangeMultiTrackStateRequest} params | ||
*/ | ||
setRemoteTracksEnabled(params: HMSChangeMultiTrackStateRequest): Promise<void>; | ||
/** | ||
* Method to be called with some UI interaction after autoplay error is received | ||
* Most browsers have limitations where an audio can not be played if there was no user interaction. | ||
@@ -242,0 +250,0 @@ * SDK throws an autoplay error in this case, this method can be called after an UI interaction |
@@ -31,2 +31,3 @@ export interface HMSNotification { | ||
CHANGE_TRACK_STATE_REQUEST = 'CHANGE_TRACK_STATE_REQUEST', | ||
CHANGE_MULTI_TRACK_STATE_REQUEST = 'CHANGE_MULTI_TRACK_STATE_REQUEST', | ||
ROOM_ENDED = 'ROOM_ENDED', | ||
@@ -33,0 +34,0 @@ REMOVED_FROM_ROOM = 'REMOVED_FROM_ROOM', |
@@ -0,1 +1,2 @@ | ||
import { HMSTrackSource } from '.'; | ||
import { HMSPeer, HMSPeerID, HMSTrack } from './peer'; | ||
@@ -16,2 +17,17 @@ import { HMSRoleName } from './role'; | ||
export interface HMSChangeMultiTrackStateRequest { | ||
requestedBy: HMSPeer; | ||
tracks: HMSTrack[]; | ||
enabled: boolean; | ||
type?: 'audio' | 'video'; | ||
source?: HMSTrackSource; | ||
} | ||
export interface HMSChangeMultiTrackStateParams { | ||
enabled: boolean; | ||
roles?: HMSRoleName[]; | ||
type?: 'audio' | 'video'; | ||
source?: HMSTrackSource; | ||
} | ||
export interface HMSLeaveRoomRequest { | ||
@@ -18,0 +34,0 @@ requestedBy: HMSPeer; |
@@ -382,4 +382,3 @@ import { HMSMessage, HMSPeer, HMSPeerID, HMSRoom, HMSRoomState, HMSStore } from '../schema'; | ||
export const selectPermissions = createSelector(selectLocalPeerRole, role => role?.permissions); | ||
export const selectRecordingState = createSelector(selectRoom, room => room.recording); | ||
export const selectRTMPState = createSelector(selectRoom, room => room.rtmp); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1362401
15083