Class ProcessConsumerTransports

Processes consumer transports by pausing and resuming them based on certain conditions.

This method checks the state of each consumer transport and determines whether to pause or resume based on the validity of the producer ID in relation to the provided streams. It utilizes a sleep function to introduce a delay before pausing the transports.

The options for processing consumer transports.

The list of consumer transports to process.

The list of local streams.

The parameters for processing, including:

  • {Array} options.parameters.remoteScreenStream - The list of remote screen streams.
  • {Array<Stream | Participant>} options.parameters.oldAllStreams - The list of old streams.
  • {Array<Stream | Participant>} options.parameters.newLimitedStreams - The list of new limited streams.
  • {Function} options.parameters.sleep - A function to pause execution for a specified duration.
  • {Function} options.parameters.getUpdatedAllParams - Function to get updated parameters.

A promise that resolves when the processing is complete.

Will throw an error if there is an issue processing consumer transports.

const options = {
consumerTransports: [],
lStreams_: [],
parameters: {
remoteScreenStream: [],
oldAllStreams: [],
newLimitedStreams: [],
sleep: async ({ ms }) => new Promise(resolve => setTimeout(resolve, ms)),
},
};

await processConsumerTransports(options);

Constructors

Methods

  • Processes consumer transports by pausing and resuming them based on certain conditions.

    Parameters

    Returns Promise<void>

    • A promise that resolves when the processing is complete.
    • Throws an error if there is an issue processing consumer transports.

    The function performs the following steps:

    1. Destructures and updates the parameters.
    2. Defines a helper function to check if a producerId is valid in given stream arrays.
    3. Filters consumer transports to resume based on certain conditions.
    4. Filters consumer transports to pause based on certain conditions.
    5. Pauses consumer transports after a short delay.
    6. Emits consumer-pause event for each filtered transport (not audio).
    7. Emits consumer-resume event for each filtered transport (not audio).