@100mslive/hms-video-store
Version:
@100mslive Core SDK which abstracts the complexities of webRTC while providing a reactive store for data management with a unidirectional data flow
54 lines (53 loc) • 2.39 kB
TypeScript
import { EventBus } from '../../events/EventBus';
import { HMSUpdateListener } from '../../interfaces';
import { HMSRemoteTrack } from '../../media/tracks';
import { HMSPeer } from '../../sdk/models/peer';
import { Store } from '../../sdk/store';
import { OnTrackLayerUpdateNotification, TrackState, TrackStateNotification } from '../HMSNotifications';
/**
* Handles:
* - Incoming track meta-data from BIZ(signal) to match a track to a peer.
* - Incoming MediaStreamTracks(wrapped in HMSTracks) from RTCMediaChannel.
* - Mute/unmute track meta-data updates from BIZ.
*
* Since track meta-data and RTC tracks come in asynchronously,
* we store the track meta-data(TrackState) in SDK Store and tracks temporarily here in tracksToProcess.
*
* Once we have both TrackState and track,
* we add it to peer, send listener.onTrackUpdate and remove it from tracksToProcess.
*
* Gotchas:
* - TRACK_UPDATE comes before TRACK_ADD -> update state, process pending tracks when TRACK_ADD arrives.
*/
export declare class TrackManager {
store: Store;
eventBus: EventBus;
listener?: HMSUpdateListener | undefined;
TAG: string;
private tracksToProcess;
constructor(store: Store, eventBus: EventBus, listener?: HMSUpdateListener | undefined);
/**
* Add event from biz on track-add
* @param params TrackStateNotification
*/
handleTrackMetadataAdd(params: TrackStateNotification): void;
/**
* Sets the tracks to peer and returns the peer
*/
handleTrackAdd: (track: HMSRemoteTrack) => void;
handleTrackRemovedPermanently: (notification: TrackStateNotification) => void;
/**
* Sets the track of corresponding peer to null and returns the peer
*/
handleTrackRemove(track: HMSRemoteTrack, remove?: boolean): void;
handleTrackLayerUpdate: (params: OnTrackLayerUpdateNotification) => void;
handleTrackUpdate: (params: TrackStateNotification, callListener?: boolean) => void;
processTrackInfo: (_trackInfo: TrackState, _peerId: string, _callListener?: boolean) => void;
processPendingTracks: () => void;
private setLayer;
removePeerTracks(hmsPeer: HMSPeer, track: HMSRemoteTrack): void;
private addAudioTrack;
addVideoTrack(hmsPeer: HMSPeer, track: HMSRemoteTrack): void;
addAsPrimaryVideoTrack(hmsPeer: HMSPeer, track: HMSRemoteTrack): boolean;
private processTrackUpdate;
}