import { LocalCameraStream, LocalMicrophoneStream, LocalDisplayStream, LocalSystemAudioStream, RemoteStream } from '@webex/media-helpers'; import { ClientEvent } from '@webex/internal-plugin-metrics'; import { throttle } from 'lodash'; export type MediaDirection = { sendAudio: boolean; sendVideo: boolean; sendShare: boolean; receiveAudio: boolean; receiveVideo: boolean; receiveShare: boolean; }; export type IPVersion = ClientEvent['payload']['ipVersion']; /** * @class MediaProperties */ export default class MediaProperties { audioStream?: LocalMicrophoneStream; mediaDirection: MediaDirection; mediaSettings: any; webrtcMediaConnection: any; remoteAudioStream: RemoteStream; remoteQualityLevel: any; remoteShareStream: RemoteStream; remoteVideoStream: RemoteStream; shareVideoStream?: LocalDisplayStream; shareAudioStream?: LocalSystemAudioStream; videoDeviceId: any; videoStream?: LocalCameraStream; namespace: string; mediaIssueCounters: { [key: string]: number; }; throttledSendMediaIssueMetric: ReturnType; /** * @param {Object} [options] -- to auto construct * @returns {MediaProperties} */ constructor(); /** * Retrieves the preferred video input device * @returns {Object|null} */ getVideoDeviceId(): any; setMediaDirection(mediaDirection: any): void; setMediaSettings(type: any, values: any): void; setMediaPeerConnection(mediaPeerConnection: any): void; setLocalVideoStream(videoStream?: LocalCameraStream): void; setLocalAudioStream(audioStream?: LocalMicrophoneStream): void; setLocalShareVideoStream(shareVideoStream?: LocalDisplayStream): void; setLocalShareAudioStream(shareAudioStream?: LocalSystemAudioStream): void; setRemoteQualityLevel(remoteQualityLevel: any): void; setRemoteShareStream(remoteShareStream: RemoteStream): void; /** * Sets the remote audio stream * @param {RemoteStream} remoteAudioStream RemoteStream to save * @returns {void} */ setRemoteAudioStream(remoteAudioStream: RemoteStream): void; /** * Sets the remote video stream * @param {RemoteStream} remoteVideoStream RemoteStream to save * @returns {void} */ setRemoteVideoStream(remoteVideoStream: RemoteStream): void; /** * Stores the preferred video input device * @param {string} deviceId Preferred video input device * @returns {void} */ setVideoDeviceId(deviceId: string): void; /** * Clears the webrtcMediaConnection. This method should be called after * peer connection is closed and no longer needed. * @returns {void} */ unsetPeerConnection(): void; /** * Removes both remote audio and video from class instance * @returns {void} */ unsetRemoteMedia(): void; unsetRemoteShareStream(): void; /** * Unsets all remote streams * @returns {void} */ unsetRemoteStreams(): void; /** * Returns if we have at least one local share stream or not. * @returns {Boolean} */ hasLocalShareStream(): boolean; /** * Waits for the webrtc media connection to be connected. * * @param {string} correlationId * @returns {Promise} */ waitForMediaConnectionConnected(correlationId: string): Promise; /** * Returns ICE transport information: * - selectedCandidatePairChanges - number of times the selected candidate pair was changed, it should be at least 1 for successful connections * it will be -1 if browser doesn't supply this information * - numTransports - number of transports (should be 1 if we're using bundle) * * @param {Array} allStatsReports array of RTC stats reports * @returns {Object} */ private getTransportInfo; /** * Checks if the given IP address is IPv6 * @param {string} ip address to check * @returns {boolean} true if the address is IPv6, false otherwise */ private isIPv6; /** Finds out if we connected using IPv4 or IPv6 * @param {RTCPeerConnection} webrtcMediaConnection * @param {Array} allStatsReports array of RTC stats reports * @returns {string} IPVersion */ private getConnectionIpVersion; /** * Returns the type of a connection that has been established * It should be 'UDP' | 'TCP' | 'TURN-TLS' | 'TURN-TCP' | 'TURN-UDP' | 'unknown' * * If connection was not established, it returns 'unknown' * * @param {Array} allStatsReports array of RTC stats reports * @returns {string} */ private getConnectionType; /** * Returns information about current webrtc media connection * * @returns {Promise} */ getCurrentConnectionInfo(): Promise<{ connectionType: string; ipVersion?: IPVersion; selectedCandidatePairChanges: number; numTransports: number; }>; /** * Sends a metric about a media issue. Metrics are throttled so that we don't * send too many of them, but include a count so that we know how many issues * were detected. * * @param {string} issueType * @param {string} issueSubType * @param {string} correlationId * @returns {void} */ sendMediaIssueMetric(issueType: string, issueSubType: string, correlationId: any): void; }