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

80 lines (79 loc) 3.13 kB
import { HMSTrackType } from './HMSTrackType'; import { HMSMediaStream } from '../streams'; export declare type HMSTrackSource = 'regular' | 'screen' | 'plugin' | 'audioplaylist' | 'videoplaylist' | string; export declare abstract class HMSTrack { /** * @internal */ readonly stream: HMSMediaStream; source?: HMSTrackSource; peerId?: string; transceiver?: RTCRtpTransceiver; /** * @internal to print as a helpful identifier alongside logs */ logIdentifier: string; /** The native mediastream track, for local, this changes on mute/unmute(for video), * and on device change. * @internal */ nativeTrack: MediaStreamTrack; /** * Firefox doesn't respect the track id as sent from the backend when calling peerconnection.ontrack callback. This * breaks correlation of future track updates from backend. So we're storing the sdp track id as present in the * original offer along with the track as well and will let this override the native track id for any correlation * purpose. * This applies for remote tracks only. * @internal */ private sdpTrackId?; /** * @internal * The local track id is changed on mute/unmute or when device id changes, this is abstracted as an internal * detail of HMSTrack and the variable is used for this enacapsulation where the first track id is remembered * and treated as the fixed track id for this HMSTrack. This simplifies things for the user of the sdk who * do not have to worry about changing track IDs. * This applies for local tracks only. */ private firstTrackId?; abstract readonly type: HMSTrackType; get enabled(): boolean; /** * firstTrackId => encapsulates change in local track ids * sdpTrackId => fixes remote track updates correlation on firefox */ get trackId(): string; getMediaTrackSettings(): MediaTrackSettings; /** * Get performance metrics from attached plugins (e.g., effects SDK). * Override in subclasses that support plugins. * @returns Object with plugin names as keys and their metrics as values, or undefined */ getPluginsMetrics(): Record<string, Record<string, unknown> | undefined> | undefined; setEnabled(value: boolean): Promise<void>; protected constructor(stream: HMSMediaStream, track: MediaStreamTrack, source?: HMSTrackSource); /** * @internal */ setSdpTrackId(sdpTrackId: string): void; /** * @internal */ protected setFirstTrackId(trackId: string): void; isTrackNotPublishing: () => boolean; /** * @internal * It will send event to analytics when interruption start/stop */ sendInterruptionEvent({ started, reason }: { started: boolean; reason: string; }): import("../../analytics/AnalyticsEvent").default; /** * @internal * take care of - * 1. https://bugs.chromium.org/p/chromium/issues/detail?id=1232649 * 2. stopping any tracks * 3. plugins related cleanups and stopping */ cleanup(): void; toString(): string; }