import { LogLevel } from "../logging"; import { AudioLevelChangeHandler, RtcAuthParams, RtcOptions, RtcStream } from "../types"; import { CodecPreferences } from "./types"; export declare class BandwidthRtc { private options?; private diagnosticsBatcher; private signaling; private publishingPeerConnection?; private subscribingPeerConnection?; private publishHeartbeatDataChannel?; private publishDiagnosticsDataChannel?; private publishedDataChannels; private subscribeHeartbeatDataChannel?; private subscribeDiagnosticsDataChannel?; private subscribedDataChannels; private publishMutex; private subscribeMutex; private publishedStreams; private subscribedStreams; private subscribingPeerConnectionSdpRevision; private localDtmfSenders; private streamAvailableHandler?; private streamUnavailableHandler?; /** * Construct a new instance of BandwidthRtc * @param logLevel desired log level for logs that will appear in the browser's console, optional */ constructor(logLevel?: LogLevel); /** * Connect to the Bandwidth WebRTC platform * @param authParams connection credentials * @param options additional connection options; usually unnecessary */ connect(authParams: RtcAuthParams, options?: RtcOptions): Promise; /** * Set the log level for logs that will appear in the browser's console * Defaults to "warn" * @param logLevel log level */ setLogLevel(logLevel: LogLevel): void; /** * Set the function that will be called when a subscribed stream becomes available * @param callback callback function */ onStreamAvailable(callback: { (event: RtcStream): void; }): void; /** * Set the function that will be called when a subscribed stream becomes unavailable * @param callback callback function */ onStreamUnavailable(callback: { (streamId: string): void; }): void; /** * Publish media to the Bandwidth WebRTC platform * * This function can publish an existing MediaStream, or it can create and publish a new media stream from MediaStreamConstraints * @param input existing media or specific constraints to publish; optional, defaults to basic audio/video constraints * @param audioLevelChangeHandler handler that can be called when the audio level of the published stream changes (optional) * @param alias stream alias/tag that will be included in subscription events and billing records, should not be PII (optional) */ publish(input?: MediaStreamConstraints | MediaStream, audioLevelChangeHandler?: AudioLevelChangeHandler, alias?: string, codecPreferences?: CodecPreferences): Promise; /** * Unpublish one or more streams. * @param streams streams to unpublish; leave empty to unpublish all streams */ unpublish(...streams: RtcStream[] | string[]): Promise; /** * Returns an array of available video input devices */ getVideoInputs(): Promise; /** * Returns an array of available audio input devices */ getAudioInputs(): Promise; /** * Returns an array of available audio output devices */ getAudioOutputs(): Promise; /** * Returns an array of available media devices, optionally filtered by device kind * @param filter Device kind to filter on */ getMediaDevices(filter?: string): Promise; /** * DTMF Sender that layers DTMF tones onto an existing stream. * @param tone The DTMF tones to send - a string composed of the characters [0-9,*,#,\,]* * @param streamId The optional stream id to play on. */ sendDtmf(tone: string, streamId?: string): void; /** * Enable/disable the mic (audio tracks) * @param enabled whether audio streams should be enabled * @param stream specific stream to operate on; optional, defaults to all streams */ setMicEnabled(enabled: boolean, stream?: RtcStream | string): void; /** * Enable/disable the camera (video tracks) * @param enabled whether video streams should be enabled * @param stream specific stream to operate on; optional, defaults to all streams */ setCameraEnabled(enabled: boolean, stream?: RtcStream | string): void; /** * Disconnect from the Bandwidth WebRTC platform, and tear down all published streams */ disconnect(): void; private offerPublishSdp; private handleSubscribeSdpOffer; private addHeartbeatDataChannel; private addDiagnosticsDataChannel; private setupPublishingPeerConnection; private setupSubscribingPeerConnection; private setupNewPeerConnection; private addStreamToPublishingPeerConnection; private cleanupPublishedStreams; /** * Can be overridden in environments where RTCPeerConnection is not natively present * @returns new RTCPeerConnection */ private createPeerConnection; /** * Can be overridden in environments where MediaStream is not natively present * @returns true if input is a MediaStream, false otherwise */ private isMediaStream; }