import { SignallingProtocol, ITransport, Messages, KeepaliveMonitor } from '@epicgames-ps/lib-pixelstreamingcommon-ue5.8'; import { StreamController } from '../VideoPlayer/StreamController'; import { FreezeFrameController } from '../FreezeFrame/FreezeFrameController'; import { AFKController } from '../AFK/AFKController'; import { DataChannelController } from '../DataChannel/DataChannelController'; import { PeerConnectionController } from '../PeerConnectionController/PeerConnectionController'; import { AggregatedStats } from '../PeerConnectionController/AggregatedStats'; import { Config } from '../Config/Config'; import { FileTemplate } from '../Util/FileUtil'; import { InputClassesFactory } from '../Inputs/InputClassesFactory'; import { VideoPlayer } from '../VideoPlayer/VideoPlayer'; import { StreamMessageController, MessageDirection } from '../UeInstanceMessage/StreamMessageController'; import { ResponseController } from '../UeInstanceMessage/ResponseController'; import { SendMessageController } from '../UeInstanceMessage/SendMessageController'; import { ToStreamerMessagesController } from '../UeInstanceMessage/ToStreamerMessagesController'; import { DataChannelSender } from '../DataChannel/DataChannelSender'; import { InputCoordTranslator } from '../Util/InputCoordTranslator'; import { PixelStreaming } from '../PixelStreaming/PixelStreaming'; import { DataChannelLatencyTestRequest } from '../DataChannel/DataChannelLatencyTestResults'; import { IInputController } from '../Inputs/IInputController'; import { GamepadController } from '../Inputs/GamepadController'; /** * Entry point for the WebRTC Player */ export declare class WebRtcPlayerController { config: Config; responseController: ResponseController; sdpConstraints: RTCOfferOptions; transport: ITransport; protocol: SignallingProtocol; sendrecvDataChannelController: DataChannelController; recvDataChannelController: DataChannelController; dataChannelSender: DataChannelSender; datachannelOptions: RTCDataChannelInit; videoPlayer: VideoPlayer; streamController: StreamController; peerConnectionController: PeerConnectionController; inputClassesFactory: InputClassesFactory; freezeFrameController: FreezeFrameController; shouldShowPlayOverlay: boolean; afkController: AFKController; latencyStartTime: number; pixelStreaming: PixelStreaming; streamMessageController: StreamMessageController; sendMessageController: SendMessageController; toStreamerMessagesController: ToStreamerMessagesController; keyboardController: IInputController; mouseController: IInputController; touchController: IInputController; gamePadController: GamepadController; coordinateConverter: InputCoordTranslator; isUsingSFU: boolean; isUsingSVC: boolean; isQualityController: boolean; statsTimerHandle: number; file: FileTemplate; preferredCodec: string; peerConfig: RTCConfiguration; videoAvgQp: number; locallyClosed: boolean; enableAutoReconnect: boolean; forceReconnect: boolean; reconnectAttempt: number; isReconnecting: boolean; disconnectMessage: string; subscribedStream: string; signallingUrlBuilder: () => string; autoJoinTimer: ReturnType; keepalive: KeepaliveMonitor; playerId: string | null; /** * * @param config - the frontend config object * @param pixelStreaming - the PixelStreaming object */ constructor(config: Config, pixelStreaming: PixelStreaming); /** * Destroys the video player and makes sure resources are freed. This helps to prevent the issue in chrome * where it refuses to make new video players. */ destroyVideoPlayer(): void; /** * Handles when a message is received * @param event - Message Event */ handleOnMessage(event: MessageEvent): void; /** * Register message all handlers */ registerMessageHandlers(): void; /** * Activate the logic associated with a command from UE * @param message */ onCommand(message: ArrayBuffer): void; handleOnScreenKeyboardCommand(command: any): void; /** * Handles a protocol message received from the streamer * @param message the message data from the streamer */ onProtocolMessage(message: ArrayBuffer): void; /** * Handles an input control message when it is received from the streamer * @param message The input control message */ onInputControlOwnership(message: ArrayBuffer): void; /** * * @param message */ onGamepadResponse(message: ArrayBuffer): void; onAfkTriggered(): void; /** * Set whether we should timeout when afk. * @param afkEnabled If true we timeout when idle for some given amount of time. */ setAfkEnabled(afkEnabled: boolean): void; /** * Attempt a reconnection to the signalling server. Manual trigger */ tryReconnect(message: string): void; /** * Does the actual reconnect work. Used by the auto reconnect feature to skip the manual flag. */ doReconnect(message: string): void; /** * Loads a freeze frame if it is required otherwise shows the play overlay */ loadFreezeFrameOrShowPlayOverlay(): void; /** * Process the freeze frame and load it * @param message The freeze frame data in bytes */ onFreezeFrameMessage(message: ArrayBuffer): void; /** * Enable the video after hiding a freeze frame */ invalidateFreezeFrameAndEnableVideo(): void; /** * Prep datachannel data for processing file extension * @param data the file extension data */ onFileExtension(data: ArrayBuffer): void; /** * Prep datachannel data for processing the file mime type * @param data the file mime type data */ onFileMimeType(data: ArrayBuffer): void; /** * Prep datachannel data for processing the file contents * @param data the file contents data */ onFileContents(data: ArrayBuffer): void; /** * Plays the stream audio and video source and sets up other pieces while the stream starts */ playStream(): void; /** * Plays the video stream */ private playVideo; /** * Enable the video to play automatically if enableAutoplay is true */ autoPlayVideoOrSetUpPlayOverlay(): void; /** * Connect to the Signaling server */ connectToSignallingServer(): void; /** * This will start the handshake to the signalling server * @param peerConfig - RTC Configuration Options from the Signaling server * @remark RTC Peer Connection on Ice Candidate event have it handled by handle Send Ice Candidate */ startSession(peerConfig: RTCConfiguration): void; /** * Checks the peer connection options for a turn server and returns true or false */ checkTurnServerAvailability(options: RTCConfiguration): boolean; /** * Handles when a Config Message is received contains the Peer Connection Options required (STUN and TURN Server Info) * @param messageConfig - Config Message received from the signaling server */ handleOnConfigMessage(messageConfig: Messages.config): void; handlePingMessage(pingMessage: Messages.ping): void; /** * Handles when the signalling server gives us the list of streamer ids. */ handleStreamerListMessage(messageStreamerList: Messages.streamerList): void; handleSubscribeFailedMessage(subscribeFailedMessage: Messages.subscribeFailed): void; handleStreamerIDChangedMessage(streamerIDChangedMessage: Messages.streamerIdChanged): void; /** * Handle the RTC Answer from the signaling server * @param Answer - Answer SDP from the peer. */ handleWebRtcAnswer(Answer: Messages.answer): void; /** * Handle the RTC offer from a WebRTC peer (received through the signalling server). * @param Offer - Offer SDP from the peer. */ handleWebRtcOffer(Offer: Messages.offer): void; /** * Handle when the SFU provides the peer with its data channels * @param DataChannels - The message from the SFU containing the data channels ids */ handleWebRtcSFUPeerDatachannels(DataChannels: Messages.peerDataChannels): void; handlePostWebrtcNegotiation(): void; /** * Handler for when a remote ICE candidate is received. * @param iceCandidateInit - Initialization data used to make the actual ICE Candidate. */ handleIceCandidate(iceCandidateInit: RTCIceCandidateInit): void; /** * Send the ice Candidate to the signaling server via websocket * @param iceEvent - RTC Peer ConnectionIceEvent) { */ handleSendIceCandidate(iceEvent: RTCPeerConnectionIceEvent): void; /** * Send the ice Candidate to the signaling server via websocket * @param iceEvent - RTC Peer ConnectionIceEvent) { */ handleDataChannel(datachannelEvent: RTCDataChannelEvent): void; /** * Send the RTC Offer Session to the Signaling server via websocket * @param offer - RTC Session Description */ handleSendWebRTCOffer(offer: RTCSessionDescriptionInit): void; /** * Send the RTC Offer Session to the Signaling server via websocket * @param answer - RTC Session Description */ handleSendWebRTCAnswer(answer: RTCSessionDescriptionInit): void; /** * Set the freeze frame overlay to the player div */ setUpMouseAndFreezeFrame(): void; /** * Close the Connection to the signaling server */ closeSignalingServer(message: string, allowReconnect: boolean): void; /** * Close the peer connection */ closePeerConnection(): void; /** * Close all connections */ close(): void; /** * Fires a Video Stats Event in the RTC Peer Connection */ getStats(): void; /** * Send a Latency Test Request to the UE Instance */ sendLatencyTest(): void; /** * Send a Data Channel Latency Test Request to the UE Instance */ sendDataChannelLatencyTest(descriptor: DataChannelLatencyTestRequest): void; /** * Send the MinQP encoder setting to the UE Instance. * @param minQP - The lower bound for QP when encoding * valid values are (1-51) where: * 1 = Best quality but highest bitrate. * 51 = Worst quality but lowest bitrate. * By default the minQP is 1 meaning the encoder is free * to aim for the best quality it can on the given network link. */ sendEncoderMinQP(minQP: number): void; /** * Send the MaxQP encoder setting to the UE Instance. * @param maxQP - The upper bound for QP when encoding * valid values are (1-51) where: * 1 = Best quality but highest bitrate. * 51 = Worst quality but lowest bitrate. * By default the maxQP is 51 meaning the encoder is free * to drop quality as low as needed on the given network link. */ sendEncoderMaxQP(maxQP: number): void; /** * Send the MinQuality encoder setting to the UE Instance. * @param minQuality - The lower bound for quality when encoding * valid values are (0-100) where: * 0 = Worst quality. * 100 = Best quality. */ sendEncoderMinQuality(minQuality: number): void; /** * Send the MaxQuality encoder setting to the UE Instance. * @param maxQuality - The upper bound for quality when encoding * valid values are (0-100) where: * 0 = Worst quality. * 100 = Best quality. */ sendEncoderMaxQuality(maxQuality: number): void; /** * Send the { WebRTC.MinBitrate: SomeNumber }} command to UE to set * the minimum bitrate that we allow WebRTC to use * (note setting this too high in poor networks can be problematic). * @param minBitrate - The minimum bitrate we would like WebRTC to not fall below. */ sendWebRTCMinBitrate(minBitrate: number): void; /** * Send the { WebRTC.MaxBitrate: SomeNumber }} command to UE to set * the minimum bitrate that we allow WebRTC to use * (note setting this too low could result in blocky video). * @param minBitrate - The minimum bitrate we would like WebRTC to not fall below. */ sendWebRTCMaxBitrate(maxBitrate: number): void; /** * Send the { WebRTC.Fps: SomeNumber }} UE 5.0+ * and { WebRTC.MaxFps } UE 4.27 command to set * the maximum fps we would like WebRTC to stream at. * @param fps - The maximum stream fps. */ sendWebRTCFps(fps: number): void; /** * Sends the UI Descriptor `stat fps` to the UE Instance */ sendShowFps(): void; /** * Send an Iframe request to the streamer */ sendIframeRequest(): void; /** * Checks whether the to-streamer (send) data channel is open and ready to send. * @returns true if the data channel exists and its readyState is 'open'. */ isDataChannelOpen(): boolean; /** * Send a UIInteraction message */ emitUIInteraction(descriptor: object | string): void; /** * Send a Command message */ emitCommand(descriptor: object): void; /** * Send a console command message */ emitConsoleCommand(command: string): void; /** * Sends a request to the UE Instance to have ownership of Quality */ sendRequestQualityControlOwnership(): void; /** * Send a `TextBoxEntry` message back to UE. * @param contents The new contents of the UE side text box. */ sendTextboxEntry(contents: string): void; /** * Handles when a Latency Test Result are received from the UE Instance * @param message - Latency Test Timings */ handleLatencyTestResult(message: ArrayBuffer): void; /** * Handles when a Data Channel Latency Test Response is received from the UE Instance * @param message - Data Channel Latency Test Response */ handleDataChannelLatencyTestResponse(message: ArrayBuffer): void; /** * Handles when the Encoder and Web RTC Settings are received from the UE Instance * @param message - Initial Encoder and Web RTC Settings */ handleInitialSettings(message: ArrayBuffer): void; /** * Handles when the Quantization Parameter are received from the UE Instance * @param message - Encoders Quantization Parameter */ handleVideoEncoderAvgQP(message: ArrayBuffer): void; /** * Handles when the video element has been loaded with a srcObject */ handleVideoInitialized(): void; /** * Flag set if the user has Quality Ownership * @param message - Does the current client have Quality Ownership */ onQualityControlOwnership(message: ArrayBuffer): void; /** * Handles when the Aggregated stats are Collected * @param stats - Aggregated Stats */ handleVideoStats(stats: AggregatedStats): void; /** * To Resize the Video Player element */ resizePlayerStyle(): void; setPreferredCodec(codec: string): void; setVideoEncoderAvgQP(avgQP: number): void; /** * enables/disables keyboard event listeners */ setKeyboardInputEnabled(isEnabled: boolean): void; /** * enables/disables mouse event listeners */ setMouseInputEnabled(isEnabled: boolean): void; /** * enables/disables touch event listeners */ setTouchInputEnabled(isEnabled: boolean): void; /** * enables/disables game pad event listeners */ setGamePadInputEnabled(isEnabled: boolean): void; registerDataChannelEventEmitters(dataChannel: DataChannelController): void; registerMessageHandler(name: string, direction: MessageDirection, handler?: (data: ArrayBuffer | Array) => void): void; }