Class CaptureCanvasStream

Captures the canvas stream and handles the transport connection for screen sharing.

The options for capturing the canvas stream.

The parameters required for capturing and managing the canvas stream.

The canvas element to capture the stream from.

The current canvas stream, if any.

Function to update the canvas stream state.

The current screen producer, if any.

The current local screen producer, if any.

Flag indicating if the transport has been created.

Flag indicating if the local transport has been created.

The local socket instance used for communication.

Function to update the screen producer state.

Function to update the local screen producer state.

Function to pause execution for a specified duration.

Function to create a send transport for the screen.

Function to connect the send transport for the screen.

Function to disconnect the send transport for the screen.

Flag indicating whether to start or stop the canvas stream.

A promise that resolves when the operation is complete.

const canvasElement = document.querySelector('#canvas') as HTMLCanvasElement;
const options = {
parameters: {
canvasWhiteboard: canvasElement,
updateCanvasStream: (stream) => console.log("Canvas Stream Updated:", stream),
updateScreenProducer: (producer) => console.log("Screen Producer Updated:", producer),
updateLocalScreenProducer: (localProducer) => console.log("Local Screen Producer Updated:", localProducer),
createSendTransport: async (params) => console.log("Transport created with", params),
connectSendTransportScreen: async (options) => console.log("Transport connected with", options),
disconnectSendTransportScreen: async (params) => console.log("Transport disconnected with", params),
sleep: ({ ms }) => new Promise(resolve => setTimeout(resolve, ms)),
},
start: true,
};
await captureCanvasStream(options);

Constructors

Methods

Constructors

Methods