publishMedia method Null safety

Future<void> publishMedia(
  1. {String? audioCodec,
  2. String? videCodec,
  3. int? bitrate,
  4. bool? record,
  5. String? filename,
  6. String? newDisplayName,
  7. int? audioLevelAverage,
  8. int? audioActivePackets,
  9. List<Map<String, String>>? descriptions,
  10. RTCSessionDescription? offer}
)

sends the publish request to JanusVideoRoom. It should be called once VideoRoomJoinedEvent is received from server.

Implementation

Future<void> publishMedia(
    {String? audioCodec,
    String? videCodec,
    int? bitrate,
    bool? record,
    String? filename,
    String? newDisplayName,
    int? audioLevelAverage,
    int? audioActivePackets,
    List<Map<String, String>>? descriptions,
    RTCSessionDescription? offer}) async {
  var payload = {
    "request": "publish",
    "audiocodec": audioCodec,
    "videocodec": videCodec,
    "bitrate": bitrate,
    "record": record,
    "filename": filename,
    "display": newDisplayName,
    "audio_level_average": audioLevelAverage,
    "audio_active_packets": audioActivePackets,
    "descriptions": descriptions
  }..removeWhere((key, value) => value == null);
  if (offer == null) {
    offer = await this.createOffer(audioRecv: false, audioSend: true, videoRecv: false, videoSend: true);
  }
  await this.send(data: payload, jsep: offer);
}