resumeLocalSendTransportAudio function

Future<void> resumeLocalSendTransportAudio(
  1. ResumeSendTransportAudioOptions options
)

Resumes the local send transport for audio by resuming the local audio producer and updating the state.

Parameters:

  • options (ResumeSendTransportAudioOptions): Contains the parameters required for resuming the local audio transport.

Workflow:

  1. Resume Local Audio Producer:
    • If an active local audio producer exists, it is resumed.
    • The local state is updated to reflect the resumed producer.

Returns:

  • A Future<void> that completes when the local audio transport is successfully resumed.

Error Handling:

  • Logs errors to the console in debug mode and rethrows them for higher-level handling.

Example Usage:

final options = ResumeSendTransportAudioOptions(
  parameters: myResumeSendTransportAudioParameters,
);

resumeLocalSendTransportAudio(options)
  .then(() => print('Local audio send transport resumed successfully'))
  .catchError((error) => print('Error resuming local audio send transport: $error'));

Implementation

Future<void> resumeLocalSendTransportAudio(
    ResumeSendTransportAudioOptions options) async {
  try {
    final parameters = options.parameters;

    final Producer? localAudioProducer = parameters.localAudioProducer;

    // Resume the local audio producer and update the state
    if (localAudioProducer != null) {
      localAudioProducer.resume();
      parameters.updateLocalAudioProducer?.call(localAudioProducer);
    }
  } catch (error) {
    if (kDebugMode) {
      print('Error resuming local audio send transport: $error');
    }
    rethrow; // Re-throw to propagate the error
  }
}