UNPKG

@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

45 lines (44 loc) 2.35 kB
import IConnectionObserver, { RTCIceCandidatePair } from './IConnectionObserver'; import { HMSConnectionRole } from './model'; import { HMSAudioTrackSettings, HMSVideoTrackSettings } from '../media/settings'; import { HMSLocalTrack } from '../media/tracks'; import { TrackState } from '../notification-manager'; import JsonRpcSignal from '../signal/jsonrpc'; export default abstract class HMSConnection { readonly role: HMSConnectionRole; protected readonly signal: JsonRpcSignal; protected abstract readonly observer: IConnectionObserver; abstract readonly nativeConnection: RTCPeerConnection; /** * We keep a list of pending IceCandidates received * from the signalling server. When the peer-connection * is initialized we call [addIceCandidate] for each. * * WARN: * - [HMSPublishConnection] keeps the complete list of candidates (for * ice-connection failed/disconnect) forever. * - [HMSSubscribeConnection] clears this list as soon as we call [addIceCandidate] */ readonly candidates: RTCIceCandidateInit[]; sfuNodeId?: string; selectedCandidatePair?: RTCIceCandidatePair; protected constructor(role: HMSConnectionRole, signal: JsonRpcSignal); get iceConnectionState(): RTCIceConnectionState; get connectionState(): RTCPeerConnectionState; private get action(); setSfuNodeId(nodeId?: string): void; addTransceiver(track: MediaStreamTrack, init: RTCRtpTransceiverInit): RTCRtpTransceiver; createOffer(tracks?: Map<string, TrackState>, options?: RTCOfferOptions): Promise<RTCSessionDescriptionInit>; createAnswer(options?: RTCOfferOptions | undefined): Promise<RTCSessionDescriptionInit>; setLocalDescription(description: RTCSessionDescriptionInit): Promise<void>; setRemoteDescription(description: RTCSessionDescriptionInit): Promise<void>; addIceCandidate(candidate: RTCIceCandidateInit): Promise<void>; get remoteDescription(): RTCSessionDescription | null; getSenders(): Array<RTCRtpSender>; handleSelectedIceCandidatePairs(): void; removeTrack(sender: RTCRtpSender): void; setMaxBitrateAndFramerate(track: HMSLocalTrack, updatedSettings?: HMSAudioTrackSettings | HMSVideoTrackSettings): Promise<void>; getStats(): Promise<RTCStatsReport>; close(): void; private getReceivers; }