Skip to content

Commit

Permalink
docs: updated inline code comments for HMSActions
Browse files Browse the repository at this point in the history
  • Loading branch information
ygit committed Dec 5, 2024
1 parent 0f0dace commit 28b264b
Showing 1 changed file with 76 additions and 3 deletions.
79 changes: 76 additions & 3 deletions packages/hms-video-store/src/IHMSActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,14 @@ import { HMSStats } from './webrtc-stats';
* @category Core
*/
export interface IHMSActions<T extends HMSGenericTypes = { sessionStore: Record<string, any> }> {
/**
* Preview function can be used to preview the camera and microphone before joining the room.
* This function is useful when you want to check and/or modify the camera and microphone settings before joining the Room.
* @param config preview config with camera and microphone devices
* @returns Promise<void> - resolves when the preview is successful
*/
preview(config: HMSMidCallPreviewConfig | HMSPreviewConfig): Promise<void>;

/**
* join function can be used to join the room, if the room join is successful,
* current details of participants and track details are populated in the store.
Expand Down Expand Up @@ -101,13 +108,15 @@ export interface IHMSActions<T extends HMSGenericTypes = { sessionStore: Record<
* This method adds the track to the local peer's list of auxiliary tracks and publishes it to make it available to remote peers.
* @param track MediaStreamTrack - Track to be added
* @param type HMSTrackSource - 'regular' | 'screen' | 'plugin' - Source of track - default: 'regular'
* @returns Promise<void> - resolves when the track is added
*/
addTrack(track: MediaStreamTrack, type: HMSTrackSource): Promise<void>;

/**
* You can use the removeTrack method to remove an auxiliary track.
* This method removes the track from the local peer's list of auxiliary tracks and unpublishes it.
* @param trackId string - ID of the track to be removed
* @returns Promise<void> - resolves when the track is removed
*/
removeTrack(trackId: HMSTrackID): Promise<void>;

Expand All @@ -123,20 +132,23 @@ export interface IHMSActions<T extends HMSGenericTypes = { sessionStore: Record<
* Send a plain text message to all the other participants in the room.
* @param message - string message to broadcast
* @param type - type of message. For example: image, video etc. - optional defaults to chat
* @returns Promise<void> - resolves when the message is sent
*/
sendBroadcastMessage(message: string, type?: string): Promise<void>;
/**
*
* @param message - string message to send
* @param roles - roles to which to send the message
* @param type - type of message. For example: image, video etc. - optional defaults to chat
* @returns Promise<void> - resolves when the message is sent
*/
sendGroupMessage(message: string, roles: HMSRoleName[], type?: string): Promise<void>;
/**
*
* @param message
* @param peerID - id of the peer to which message has to be sent
* @param type - type of message. For example: image, video etc. - optional defaults to chat
* @returns Promise<void> - resolves when the message is sent
*/
sendDirectMessage(message: string, peerID: HMSPeerID, type?: string): Promise<void>;

Expand All @@ -155,18 +167,21 @@ export interface IHMSActions<T extends HMSGenericTypes = { sessionStore: Record<
/**
* This function can be used to enable/disable(unmute/mute) local audio track
* @param enabled boolean - true to unmute, false to mute
* @returns Promise<void> - resolves when the audio is enabled
*/
setLocalAudioEnabled(enabled: boolean): Promise<void>;

/**
* This function can be used to enable/disable(unmute/mute) local video track
* @param enabled boolean - true to unmute, false to mute
* @returns Promise<void> - resolves when the video is enabled
*/
setLocalVideoEnabled(enabled: boolean): Promise<void>;

/**
* @param trackId string - ID of the track whose mute status needs to be set
* @param enabled boolean - true when we want to unmute the track and false when we want to unmute it
* @returns Promise<void> - resolves when the track is enabled
*/
setEnabledTrack(trackId: HMSTrackID, enabled: boolean): Promise<void>;

Expand All @@ -186,6 +201,7 @@ export interface IHMSActions<T extends HMSGenericTypes = { sessionStore: Record<

/**
* Toggle the camera between front and back if the both the camera's exist
* @returns Promise<void> - resolves when the camera is toggled
*/
switchCamera(): Promise<void>;

Expand All @@ -196,6 +212,7 @@ export interface IHMSActions<T extends HMSGenericTypes = { sessionStore: Record<
* the stream coming from server saving significant bandwidth for the user.
* @param localTrackID trackID as stored in the store for the peer
* @param videoElement HTML native element where the video has to be shown
* @returns Promise<void> - resolves when the video is attached
*/
attachVideo(localTrackID: HMSTrackID, videoElement: HTMLVideoElement): Promise<void>;

Expand All @@ -208,13 +225,14 @@ export interface IHMSActions<T extends HMSGenericTypes = { sessionStore: Record<
* Set the output volume of audio tracks(overall/particular audio track)
* @param value number between 0-100
* @param trackId string If undefined sets the overall volume(of every audio track in the room); If valid - set the volume of particular audio track
*
* @returns Promise<void> - resolves when the volume is set
*/
setVolume(value: number, trackId?: HMSTrackID): Promise<void>;

/**
* Set the audio output(speaker) device
* @param deviceId string deviceId of the audio output device
* @returns Promise<void> - resolves when the audio output device is set
*/
setAudioOutputDevice(deviceId: string): Promise<void>;

Expand Down Expand Up @@ -300,19 +318,22 @@ export interface IHMSActions<T extends HMSGenericTypes = { sessionStore: Record<
* @param forPeerId The remote peer id whose role needs to be changed
* @param toRole The name of the new role.
* @param [force] this being true would mean that user won't get a request to accept role change
* @returns Promise<void> - resolves when the role is changed
*/
changeRoleOfPeer(forPeerId: HMSPeerID, toRole: HMSRoleName, force?: boolean): Promise<void>;

/**
* Request for a role change of a remote peer. Can be forced.
* @param roles List of roles whose role needs to be changed
* @param toRole The name of the new role.
* @returns Promise<void> - resolves when the role is changed
*/
changeRoleOfPeersWithRoles(roles: HMSRoleName[], toRole: HMSRoleName): Promise<void>;

/**
* Accept the role change request received
* @param {HMSRoleChangeRequest} request The original request that was received
* @returns Promise<void> - resolves when the role is accepted
*/
acceptChangeRole(request: HMSRoleChangeRequest): Promise<void>;

Expand All @@ -327,12 +348,14 @@ export interface IHMSActions<T extends HMSGenericTypes = { sessionStore: Record<
* This can be used to mute/unmute a remote peer's track
* @param forRemoteTrackID The track ID or array of track IDs for which you want to change the state
* @param enabled `true` if you wish to enable(unmute permission is required) the track, `false` if you wish to disable(mute permission is required) the track
* @returns Promise<void> - resolves when the track state is changed
*/
setRemoteTrackEnabled(forRemoteTrackID: HMSTrackID | HMSTrackID[], enabled: boolean): Promise<void>;

/**
* Use this to mute/unmute multiple tracks by source, role or type
* @param {HMSChangeMultiTrackStateParams} params
* @returns Promise<void> - resolves when the track state is changed
*/
setRemoteTracksEnabled(params: HMSChangeMultiTrackStateParams): Promise<void>;

Expand All @@ -341,19 +364,24 @@ export interface IHMSActions<T extends HMSGenericTypes = { sessionStore: Record<
* Most browsers have limitations where an audio can not be played if there was no user interaction.
* SDK throws an autoplay error in this case, this method can be called after an UI interaction
* to resolve the autoplay error
* @returns Promise<void> - resolves when the autoplay error is resolved
*/
unblockAudio: () => Promise<void>;

/**
* If you have the **endRoom** permission, you can end the room. That means everyone will be kicked out.
* If lock is passed as true, the room cannot be used further.
* @param lock boolean - true to lock the room
* @param reason string - reason for ending the room
* @returns Promise<void> - resolves when the room is ended
*/
endRoom: (lock: boolean, reason: string) => Promise<void>;

/**
* After leave send feedback to backend for call quality purpose.
* @param feedback
* @param eventEndpoint
* @param feedback HMSSessionFeedback - feedback object
* @param eventEndpoint string - endpoint to send feedback
* @returns Promise<void> - resolves when the feedback is submitted
*/
submitSessionFeedback(feedback: HMSSessionFeedback, eventEndpoint?: string): Promise<void>;

Expand All @@ -363,6 +391,7 @@ export interface IHMSActions<T extends HMSGenericTypes = { sessionStore: Record<
* @param reason a string explaining why the peer is removed from the room.
* This string could be used to notify the user before they're removed from the room
* using the `REMOVED_FROM_ROOM` type of notification
* @returns Promise<void> - resolves when the peer is removed
*/
removePeer(peerID: HMSPeerID, reason: string): Promise<void>;

Expand All @@ -373,11 +402,13 @@ export interface IHMSActions<T extends HMSGenericTypes = { sessionStore: Record<
* @param params.RTMPURLs The list of ingest URLs where the call as visible in the meeting url should be streamed.
* Optional, when not specified the method is used to just start the recording.
* @param params.record If you want to start the recording or not.
* @returns Promise<void> - resolves when the RTMP streaming and recording is started
*/
startRTMPOrRecording(params: RTMPRecordingConfig): Promise<void>;

/**
* If you want to stop both RTMP streaming and recording.
* @returns Promise<void> - resolves when the RTMP streaming and recording is stopped
*/
stopRTMPAndRecording(): Promise<void>;

Expand All @@ -386,10 +417,14 @@ export interface IHMSActions<T extends HMSGenericTypes = { sessionStore: Record<
* otherwise @param params.variants.meetingURL This is the meeting url which is opened in a headless chrome instance for generating the HLS feed.
* Make sure this url leads the joiner straight to the room without any preview screen or requiring additional clicks.
* Note that streaming of only one url is currently supported and only the first variant passed will be honored.
* @param params HLSConfig - HLSConfig object with the required fields
* @returns Promise<void> - resolves when the HLS streaming is started
*/
startHLSStreaming(params?: HLSConfig): Promise<void>;
/**
* If you want to stop HLS streaming. The passed in arguments is not considered at the moment, and everything related to HLS is stopped.
* @param params HLSConfig - HLSConfig object with the required fields
* @returns Promise<void> - resolves when the HLS streaming is stopped
*/
stopHLSStreaming(params?: HLSConfig): Promise<void>;

Expand Down Expand Up @@ -590,11 +625,45 @@ export interface IHMSActions<T extends HMSGenericTypes = { sessionStore: Record<
*/
interactivityCenter: IHMSInteractivityCenter;

/**
* raise hand for local peer
* @returns Promise<void> - resolves when the hand is raised
*/
raiseLocalPeerHand(): Promise<void>;

/**
* lower hand for local peer
* @returns Promise<void> - resolves when the hand is lowered
*/
lowerLocalPeerHand(): Promise<void>;

/**
* raise hand for remote peer
* @param peerId string - ID of the peer
* @returns Promise<void> - resolves when the hand is raised
*/
raiseRemotePeerHand(peerId: string): Promise<void>;

/**
* lower hand for remote peer
* @param peerId string - ID of the peer
* @returns Promise<void> - resolves when the hand is lowered
*/
lowerRemotePeerHand(peerId: string): Promise<void>;

/**
* get the list of peers in the room
* @see https://www.100ms.live/docs/react-native/v2/how-to-guides/interact-with-room/peer/large-room
* @param options HMSPeerListIteratorOptions - options for the peer list iterator
* @returns HMSPeerListIterator - iterator for the peer list
*/
getPeerListIterator(options?: HMSPeerListIteratorOptions): HMSPeerListIterator;

/**
* get the peer object by peerId
* @param peerId string - ID of the peer
* @returns Promise<HMSPeer | undefined> - resolves with the peer object
*/
getPeer(peerId: string): Promise<HMSPeer | undefined>;
findPeerByName(options: FindPeerByNameRequestParams): Promise<{ offset: number; eof?: boolean; peers: HMSPeer[] }>;
/**
Expand All @@ -603,7 +672,11 @@ export interface IHMSActions<T extends HMSGenericTypes = { sessionStore: Record<
*/
setPlaylistSettings(settings: HMSPlaylistSettings): void;

/**
* Method to initialize diagnostics. Should only be called after joining.
*/
initDiagnostics(): HMSDiagnosticsInterface;

/**
* @internal
* Method to get enabled flags and endpoints. Should only be called after joining.
Expand Down

0 comments on commit 28b264b

Please sign in to comment.