RtcVideoRenderer constructor

RtcVideoRenderer(
  1. MediaTrack track
)

Implementation

RtcVideoRenderer(MediaTrack track) : super(track.getTrack()) {
  Log.debug('RtcVideoRenderer()', '$runtimeType');

  if (track is LocalMediaTrack) {
    autoRotate = false;

    if (PlatformUtils.isMobile) {
      mirror = track.getTrack().facingMode() == webrtc.FacingMode.user;
    } else {
      mirror = track.mediaSourceKind() == MediaSourceKind.device;
    }
  }

  // Listen for video to start having frames to be displayed.
  _delegate.onCanPlay = () {
    Log.debug(
      '[${track.kind()} ${track.mediaSourceKind()}] canPlay',
      '$runtimeType',
    );

    canPlay.value = true;
  };

  // Listen for resizes to update [width] and [height].
  _delegate.onResize = () {
    Log.debug(
      '[${track.kind()} ${track.mediaSourceKind()}] resized to ${_delegate.videoWidth}x${_delegate.videoHeight}',
      '$runtimeType',
    );

    width.value =
        _delegate.videoWidth == 0 ? width.value : _delegate.videoWidth;
    height.value =
        _delegate.videoHeight == 0 ? height.value : _delegate.videoHeight;

    canPlay.value = canPlay.value || _delegate.videoHeight != 0;
  };
}