async run()

in src/task/SetRemoteDescriptionTask.ts [30:101]


  async run(): Promise<void> {
    const peer = this.context.peer;
    if (!peer) {
      this.logAndThrow('session does not have peer connection; bypass set remote description');
    }

    let sdp = this.context.sdpAnswer;
    sdp = new SDP(sdp).withoutServerReflexiveCandidates().sdp;
    if (this.context.audioProfile) {
      sdp = new SDP(sdp).withAudioMaxAverageBitrate(this.context.audioProfile.audioBitrateBps).sdp;
      if (this.context.audioProfile.isStereo()) {
        sdp = new SDP(sdp).withStereoAudio().sdp;
      }
    }

    if (
      this.context.videoSendCodecPreferences !== undefined &&
      this.context.videoSendCodecPreferences.length > 0
    ) {
      sdp = new SDP(sdp).withVideoSendCodecPreferences(
        this.context.meetingSupportedVideoSendCodecPreferences !== undefined
          ? this.context.meetingSupportedVideoSendCodecPreferences
          : this.context.videoSendCodecPreferences
      ).sdp;
    }
    this.context.prioritizedSendVideoCodecCapabilities = new SDP(
      sdp
    ).prioritizedSendVideoCodecCapabilities();
    this.context.currentVideoSendCodec =
      this.context.prioritizedSendVideoCodecCapabilities.length > 0
        ? this.context.prioritizedSendVideoCodecCapabilities[0]
        : undefined;

    const mediaStream = this.context.activeVideoInput;
    if (mediaStream !== undefined) {
      const attendeeId = this.context.audioVideoController.configuration.credentials.attendeeId;
      const isContent = new DefaultModality(attendeeId).hasModality(
        DefaultModality.MODALITY_CONTENT
      );
      const videoTrack = mediaStream.getVideoTracks()[0];
      if (isContent) {
        if (
          this.context.currentVideoSendCodec?.codecName === VideoCodecCapability.av1Main().codecName
        ) {
          // Based on our experiments: "text" contentHint gives good coding performance for content share using AV1
          // @ts-ignore
          videoTrack.contentHint = 'text';
          this.logger.info(`Setting content hint to text for AV1, attendee: ${attendeeId}`);
        } else if (this.context.audioVideoController.configuration.enableSVC) {
          // Set content hint to `motion` as a workaround for the issue Chrome cannot enable
          // temporal scalability for screen share
          // https://bugs.chromium.org/p/chromium/issues/detail?id=1433486
          // @ts-ignore
          videoTrack.contentHint = 'motion';
          this.logger.info(`Setting content hint to motion to enable SVC, attendee: ${attendeeId}`);
        }
      }
    }

    this.logger.info(`processed remote description is >>>${sdp}<<<`);
    const remoteDescription: RTCSessionDescription = {
      type: 'answer',
      sdp: sdp,
      toJSON: null,
    };

    try {
      await this.createICEConnectionCompletedPromise(remoteDescription);
    } catch (err) {
      throw err;
    }
  }